zincjs 2.1.0 → 2.2.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 +64 -64
- package/build/zinc.js.map +1 -1
- package/package.json +8 -5
- package/src/controls.js +1 -2
- 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 +10 -10
- package/src/utilities.js +1 -19
- package/src/zinc.js +1 -2
- package/vite.config.js +3 -2
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zincjs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "ZincJS (Web-based-Zinc-Visualisation)",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "build/zinc.js",
|
|
6
7
|
"directories": {
|
|
7
8
|
"doc": "docs"
|
|
@@ -44,18 +45,20 @@
|
|
|
44
45
|
"url": "https://github.com/alan-wu/ZincJS/issues"
|
|
45
46
|
},
|
|
46
47
|
"homepage": "http://alan-wu.github.io/ZincJS/",
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=20"
|
|
50
|
+
},
|
|
47
51
|
"devDependencies": {
|
|
48
|
-
"@vitest/coverage-v8": "^1.
|
|
52
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
49
53
|
"auto-changelog": "^2.4.0",
|
|
50
54
|
"chai": "^4.1.0",
|
|
51
55
|
"gl": "^8.1.6",
|
|
52
56
|
"happy-dom": "^20.10.6",
|
|
53
57
|
"jsdoc": "^4.0.2",
|
|
54
58
|
"msw": "^2.14.6",
|
|
55
|
-
"vite": "^
|
|
59
|
+
"vite": "^8.2.1",
|
|
56
60
|
"vite-plugin-node-polyfills": "^0.28.0",
|
|
57
|
-
"vitest": "^1.
|
|
58
|
-
"webpack-node-externals": "^3.0.0"
|
|
61
|
+
"vitest": "^4.1.11"
|
|
59
62
|
},
|
|
60
63
|
"dependencies": {
|
|
61
64
|
"css-element-queries": "^1.2.2",
|
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) {
|
|
@@ -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.LoopRepeat;
|
|
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) {
|
|
@@ -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) {
|
|
@@ -982,7 +982,7 @@ const SceneLoader = function (sceneIn) {
|
|
|
982
982
|
* for each glyphset and geometry that has been written in.
|
|
983
983
|
*/
|
|
984
984
|
this.loadMetadataURL = (targetRegion, url, finishCallback, allCompletedCallback, options) => {
|
|
985
|
-
const requestURL =
|
|
985
|
+
const requestURL = url;
|
|
986
986
|
fetch(requestURL)
|
|
987
987
|
.then((response) => {
|
|
988
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;
|
package/vite.config.js
CHANGED
|
@@ -7,7 +7,7 @@ export default defineConfig({
|
|
|
7
7
|
outDir: 'build',
|
|
8
8
|
minify: true,
|
|
9
9
|
lib: {
|
|
10
|
-
entry: path.resolve(
|
|
10
|
+
entry: path.resolve(import.meta.dirname, 'src/zinc.js'),
|
|
11
11
|
name: 'Zinc',
|
|
12
12
|
fileName: () => 'zinc.js',
|
|
13
13
|
formats: ['es', 'umd'],
|
|
@@ -25,7 +25,8 @@ export default defineConfig({
|
|
|
25
25
|
'css-element-queries': 'cssElememtQueries',
|
|
26
26
|
three: 'THREE',
|
|
27
27
|
'three-spritetext': 'SpriteText',
|
|
28
|
-
'three/examples/jsm/loaders/GLTFLoader': 'GLTFLoader'
|
|
28
|
+
'three/examples/jsm/loaders/GLTFLoader': 'GLTFLoader',
|
|
29
|
+
'fflate': 'fflate'
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
},
|