zincjs 1.20.1 → 2.0.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 +292 -2648
- package/build/zinc.js.map +1 -1
- package/package.json +17 -20
- package/src/controls.js +33 -25
- package/src/geometryCSG.js +25 -23
- package/src/glyphsetCSG.js +15 -13
- package/src/loaders/GLTFToZincJSLoader.js +11 -9
- package/src/loaders/JSONLoader.js +14 -14
- package/src/loaders/niftiReader.js +0 -3
- package/src/loaders/primitivesLoader.js +4 -3
- package/src/minimap.js +6 -4
- package/src/primitives/augmentShader.js +3 -1
- package/src/primitives/geometry.js +16 -14
- package/src/primitives/glyph.js +7 -5
- package/src/primitives/glyphset.js +9 -7
- package/src/primitives/label.js +5 -2
- package/src/primitives/lines.js +13 -10
- package/src/primitives/lines2.js +8 -9
- package/src/primitives/lod.js +9 -9
- package/src/primitives/marker.js +22 -16
- package/src/primitives/markerCluster.js +14 -12
- package/src/primitives/pointset.js +8 -8
- package/src/primitives/texturePrimitive.js +7 -6
- package/src/primitives/textureSlides.js +8 -6
- package/src/primitives/textureVolume.js +8 -6
- package/src/primitives/tubeLines.js +14 -13
- package/src/primitives/zincObject.js +13 -9
- package/src/region.js +65 -66
- package/src/renderer.js +8 -5
- package/src/scene.js +26 -16
- package/src/sceneExporter.js +3 -3
- package/src/sceneLoader.js +109 -88
- package/src/shaders/rgbVolumeRender.js +8 -7
- package/src/shaders/textureArray.js +8 -7
- package/src/shaders/textureSlide.js +7 -6
- package/src/shaders/volumeRender.js +8 -7
- package/src/shaders/volumeRender_old.js +8 -7
- package/src/shaders/volumeTexture.js +9 -8
- package/src/texture/texture.js +9 -9
- package/src/texture/textureArray.js +5 -4
- package/src/three/Loader.js +0 -2
- package/src/three/Points.js +2 -2
- package/src/three-js-csg.js +538 -538
- package/src/utilities.js +49 -41
- package/src/videoHandler.js +11 -9
- package/src/workers/geometryCSG.worker.js +68 -67
- package/src/workers/geometryCSGInternal.js +12 -11
- package/src/zinc.js +49 -25
- package/vite.config.js +29 -0
- package/build/zinc.frontend.js +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zincjs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "ZincJS (Web-based-Zinc-Visualisation)",
|
|
5
5
|
"main": "build/zinc.js",
|
|
6
6
|
"directories": {
|
|
@@ -12,18 +12,19 @@
|
|
|
12
12
|
"README.md",
|
|
13
13
|
"src/*",
|
|
14
14
|
"build/zinc.js",
|
|
15
|
-
"build/zinc.frontend.js",
|
|
16
15
|
"build/zinc.js.map",
|
|
17
|
-
"
|
|
16
|
+
"vite.config.js"
|
|
18
17
|
],
|
|
19
18
|
"scripts": {
|
|
20
|
-
"build-bundle": "
|
|
21
|
-
"
|
|
22
|
-
"test": "
|
|
19
|
+
"build-bundle": "vite build",
|
|
20
|
+
"test-watch": "vitest",
|
|
21
|
+
"test": "vitest run --reporter=junit --outputFile=test-results.xml",
|
|
22
|
+
"test-standard": "vitest run",
|
|
23
23
|
"changelog": "auto-changelog -p --output CHANGELOG.md --template keepachangelog",
|
|
24
24
|
"jsdoc": "jsdoc -c jsdoc_conf.json",
|
|
25
25
|
"version": "npm run build-bundle;npm run jsdoc;npm run changelog; git add CHANGELOG.md docs",
|
|
26
26
|
"release:beta": "npm version prerelease --preid=beta; npm publish --tag beta",
|
|
27
|
+
"release:major": "npm version major; npm publish",
|
|
27
28
|
"release:minor": "npm version minor; npm publish",
|
|
28
29
|
"release:patch": "npm version patch; npm publish"
|
|
29
30
|
},
|
|
@@ -44,27 +45,23 @@
|
|
|
44
45
|
},
|
|
45
46
|
"homepage": "http://alan-wu.github.io/ZincJS/",
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"@babel/preset-env": "^7.23.9",
|
|
48
|
+
"@vitest/coverage-v8": "^1.6.1",
|
|
49
49
|
"auto-changelog": "^2.4.0",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
50
|
+
"chai": "^4.1.0",
|
|
51
|
+
"gl": "^6.0.2",
|
|
52
|
+
"happy-dom": "^20.10.6",
|
|
53
53
|
"jsdoc": "^4.0.2",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
54
|
+
"msw": "^2.14.6",
|
|
55
|
+
"vite": "^5.0.10",
|
|
56
|
+
"vite-plugin-node-polyfills": "^0.28.0",
|
|
57
|
+
"vitest": "^1.6.1",
|
|
57
58
|
"webpack-node-externals": "^3.0.0"
|
|
58
59
|
},
|
|
59
60
|
"dependencies": {
|
|
60
61
|
"css-element-queries": "^1.2.2",
|
|
61
62
|
"lodash": "^4.17.19",
|
|
62
|
-
"nifti-reader-js": "
|
|
63
|
-
"promise-polyfill": "^8.1.3",
|
|
63
|
+
"nifti-reader-js": "0.8.0",
|
|
64
64
|
"three": "^0.130.1",
|
|
65
|
-
"three-spritetext": "1.6.2"
|
|
66
|
-
"url-loader": "^4.1.1",
|
|
67
|
-
"url-polyfill": "^1.1.7",
|
|
68
|
-
"webworkify-webpack": "^2.1.5"
|
|
65
|
+
"three-spritetext": "1.6.2"
|
|
69
66
|
}
|
|
70
67
|
}
|
package/src/controls.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { resolveURL } from './utilities';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Object with containg viewport information used in ZincJS.
|
|
@@ -851,18 +851,24 @@ const CameraControls = function ( object, domElement, renderer, scene ) {
|
|
|
851
851
|
* @param {requestCallback} finishCallback - The callback once the path is load.
|
|
852
852
|
*/
|
|
853
853
|
this.loadPathURL = (path_url, finishCallback) => {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
854
|
+
const requestURL = resolveURL(path_url);
|
|
855
|
+
fetch(requestURL)
|
|
856
|
+
.then((response) => {
|
|
857
|
+
if (!response.ok) {
|
|
858
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
859
|
+
}
|
|
860
|
+
return response.json();
|
|
861
|
+
})
|
|
862
|
+
.then((pathData) => {
|
|
863
|
+
this.loadPath(pathData);
|
|
864
|
+
if (finishCallback !== undefined && typeof finishCallback === 'function') {
|
|
865
|
+
finishCallback();
|
|
866
|
+
}
|
|
867
|
+
})
|
|
868
|
+
.catch((error) => {
|
|
869
|
+
console.error(`Failed to load path asset from: ${requestURL}`, error);
|
|
870
|
+
});
|
|
871
|
+
|
|
866
872
|
}
|
|
867
873
|
|
|
868
874
|
/**
|
|
@@ -1593,7 +1599,7 @@ const RayCaster = function (sceneIn, hostSceneIn, callbackFunctionIn, hoverCallb
|
|
|
1593
1599
|
const renderer = rendererIn;
|
|
1594
1600
|
const callbackFunction = callbackFunctionIn;
|
|
1595
1601
|
const hoverCallbackFunction = hoverCallbackFunctionIn;
|
|
1596
|
-
|
|
1602
|
+
let enabled = true;
|
|
1597
1603
|
const raycaster = new THREE.Raycaster();
|
|
1598
1604
|
raycaster.params.Line.threshold = 0.1;
|
|
1599
1605
|
raycaster.params.Points.threshold = 1;
|
|
@@ -1607,11 +1613,11 @@ const RayCaster = function (sceneIn, hostSceneIn, callbackFunctionIn, hoverCallb
|
|
|
1607
1613
|
let pickableObjects = undefined;
|
|
1608
1614
|
|
|
1609
1615
|
this.enable = () => {
|
|
1610
|
-
|
|
1616
|
+
enabled = true;
|
|
1611
1617
|
}
|
|
1612
1618
|
|
|
1613
1619
|
this.disable = () => {
|
|
1614
|
-
|
|
1620
|
+
enabled = false;
|
|
1615
1621
|
}
|
|
1616
1622
|
|
|
1617
1623
|
this.getIntersectsObject = (zincCamera) => {
|
|
@@ -2095,11 +2101,13 @@ const NDCCameraControl = function () {
|
|
|
2095
2101
|
}
|
|
2096
2102
|
};
|
|
2097
2103
|
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2104
|
+
export {
|
|
2105
|
+
Viewport,
|
|
2106
|
+
CameraControls,
|
|
2107
|
+
SmoothCameraTransition,
|
|
2108
|
+
RotateCameraTransition,
|
|
2109
|
+
RayCaster,
|
|
2110
|
+
CameraAutoTumble,
|
|
2111
|
+
StereoEffect,
|
|
2112
|
+
NDCCameraControl
|
|
2113
|
+
}
|
package/src/geometryCSG.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { ThreeBSPWrapper } from './three-js-csg';
|
|
3
|
+
import { Geometry } from './primitives/geometry';
|
|
4
|
+
import GeometryWorker from './workers/geometryCSG.worker.js?worker';
|
|
5
|
+
import { GeometryCSGInternal } from './workers/geometryCSGInternal';
|
|
6
|
+
|
|
7
|
+
const ThreeBSP = ThreeBSPWrapper(THREE);
|
|
7
8
|
const JSONLoader = THREE.BufferGeometryLoader;
|
|
8
9
|
|
|
10
|
+
|
|
9
11
|
const GeometryCSG = function (hostIn) {
|
|
10
12
|
//ZincGeoemtry of the main geometry
|
|
11
13
|
let host = undefined;
|
|
@@ -15,7 +17,7 @@ const GeometryCSG = function (hostIn) {
|
|
|
15
17
|
let worker = undefined;
|
|
16
18
|
let onProgress = false;
|
|
17
19
|
let myResolve = undefined;
|
|
18
|
-
|
|
20
|
+
|
|
19
21
|
var createGeometryFromJSON = json => {
|
|
20
22
|
const material = host.getMorph().material.clone();
|
|
21
23
|
material.morphTargets = false;
|
|
@@ -28,7 +30,7 @@ const GeometryCSG = function (hostIn) {
|
|
|
28
30
|
newGeometry.setMorph(mesh);
|
|
29
31
|
return newGeometry;
|
|
30
32
|
}
|
|
31
|
-
|
|
33
|
+
|
|
32
34
|
var workerEventHandler = ev => {
|
|
33
35
|
switch (ev.data.action) {
|
|
34
36
|
case 'message':
|
|
@@ -45,13 +47,13 @@ const GeometryCSG = function (hostIn) {
|
|
|
45
47
|
throw 'Cannot handle specified action.';
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
|
-
|
|
50
|
+
|
|
49
51
|
var initialise = hostIn => {
|
|
50
52
|
if (work !== undefined) {
|
|
51
|
-
|
|
53
|
+
worker = new GeometryWorker();
|
|
52
54
|
}
|
|
53
55
|
if (!worker) {
|
|
54
|
-
core = new
|
|
56
|
+
core = new GeometryCSGInternal(hostIn);
|
|
55
57
|
} else {
|
|
56
58
|
if (hostIn && hostIn.isGeometry) {
|
|
57
59
|
let mesh = hostIn.getMorph();
|
|
@@ -63,14 +65,14 @@ const GeometryCSG = function (hostIn) {
|
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
|
-
|
|
68
|
+
|
|
67
69
|
this.getHostGeometry = () => {
|
|
68
70
|
const tempCSG = new ThreeBSP(host.getMorph());
|
|
69
71
|
return new createZincGeometry(tempCSG);
|
|
70
72
|
}
|
|
71
|
-
|
|
73
|
+
|
|
72
74
|
this.getGeometry = () => host;
|
|
73
|
-
|
|
75
|
+
|
|
74
76
|
const createZincGeometry = csgMesh => {
|
|
75
77
|
const material = host.getMorph().material.clone();
|
|
76
78
|
material.morphTargets = false;
|
|
@@ -81,11 +83,11 @@ const GeometryCSG = function (hostIn) {
|
|
|
81
83
|
newGeometry.setMorph(newMesh);
|
|
82
84
|
return newGeometry;
|
|
83
85
|
}
|
|
84
|
-
|
|
86
|
+
|
|
85
87
|
this.setCSG = CSG => {
|
|
86
88
|
core.setCSG(CSG);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
+
}
|
|
90
|
+
|
|
89
91
|
const sendToWork = (guestGeometry, action, resolve, reject) => {
|
|
90
92
|
if (!onProgress) {
|
|
91
93
|
let mesh = guestGeometry.getMorph();
|
|
@@ -97,7 +99,7 @@ const GeometryCSG = function (hostIn) {
|
|
|
97
99
|
reject("On progress");
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
|
-
|
|
102
|
+
|
|
101
103
|
this.intersect = guestGeometry => {
|
|
102
104
|
return new Promise((resolve, reject) => {
|
|
103
105
|
if (worker) {
|
|
@@ -110,7 +112,7 @@ const GeometryCSG = function (hostIn) {
|
|
|
110
112
|
}
|
|
111
113
|
});
|
|
112
114
|
};
|
|
113
|
-
|
|
115
|
+
|
|
114
116
|
this.subtract = guestGeometry => {
|
|
115
117
|
return new Promise((resolve, reject) => {
|
|
116
118
|
if (worker) {
|
|
@@ -123,7 +125,7 @@ const GeometryCSG = function (hostIn) {
|
|
|
123
125
|
}
|
|
124
126
|
});
|
|
125
127
|
}
|
|
126
|
-
|
|
128
|
+
|
|
127
129
|
this.union = guestGeometry => {
|
|
128
130
|
return new Promise((resolve, reject) => {
|
|
129
131
|
if (worker) {
|
|
@@ -136,13 +138,13 @@ const GeometryCSG = function (hostIn) {
|
|
|
136
138
|
}
|
|
137
139
|
});
|
|
138
140
|
}
|
|
139
|
-
|
|
141
|
+
|
|
140
142
|
this.terminateWorker = () => {
|
|
141
143
|
if (worker)
|
|
142
144
|
worker.terminate();
|
|
143
145
|
}
|
|
144
|
-
|
|
146
|
+
|
|
145
147
|
initialise(hostIn);
|
|
146
148
|
};
|
|
147
149
|
|
|
148
|
-
|
|
150
|
+
export { GeometryCSG };
|
package/src/glyphsetCSG.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { ThreeBSPWrapper } from './three-js-csg';
|
|
3
|
+
import { Glyphset } from './primitives/glyphset';
|
|
4
|
+
|
|
5
|
+
const ThreeBSP = ThreeBSPWrapper(THREE);
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Provides an object which takes in a glyphset, convert it into a CSG and further
|
|
7
9
|
* action such as intersect with another geometry may be performed.
|
|
8
|
-
*
|
|
10
|
+
*
|
|
9
11
|
* @class
|
|
10
12
|
* @author Alan Wu
|
|
11
13
|
* @return {GlyphsetCSG}
|
|
@@ -16,17 +18,17 @@ const GlyphsetCSG = function (hostIn) {
|
|
|
16
18
|
host = hostIn;
|
|
17
19
|
const hostCSGs = new Array();
|
|
18
20
|
const currentIntersect = undefined;
|
|
19
|
-
|
|
21
|
+
|
|
20
22
|
this.setGlyphset = hostIn => {
|
|
21
23
|
if (hostIn && hostIn.isGlyphset)
|
|
22
24
|
host = hostIn;
|
|
23
25
|
hostCSG = undefined;
|
|
24
26
|
}
|
|
25
|
-
|
|
27
|
+
|
|
26
28
|
this.getGlyphset = () => {
|
|
27
29
|
return host;
|
|
28
30
|
}
|
|
29
|
-
|
|
31
|
+
|
|
30
32
|
const prepareCSGForGlyphs = () => {
|
|
31
33
|
return glyph => {
|
|
32
34
|
const mesh = glyph.getMesh();
|
|
@@ -42,7 +44,7 @@ const GlyphsetCSG = function (hostIn) {
|
|
|
42
44
|
}
|
|
43
45
|
};
|
|
44
46
|
};
|
|
45
|
-
|
|
47
|
+
|
|
46
48
|
const prepareCSG = guestGeometry => {
|
|
47
49
|
if (host && guestGeometry && guestGeometry.getMorph()) {
|
|
48
50
|
if (hostCSGs.length == 0) {
|
|
@@ -53,11 +55,11 @@ const GlyphsetCSG = function (hostIn) {
|
|
|
53
55
|
}
|
|
54
56
|
return undefined;
|
|
55
57
|
};
|
|
56
|
-
|
|
58
|
+
|
|
57
59
|
this.intersect = guestGeometry => {
|
|
58
60
|
const guestCSG = prepareCSG(guestGeometry);
|
|
59
61
|
if ((hostCSGs.length > 0) && guestCSG) {
|
|
60
|
-
const glyphset = new
|
|
62
|
+
const glyphset = new Glyphset();
|
|
61
63
|
for (let i = 0; i < hostCSGs.length; i++) {
|
|
62
64
|
const hostCSG = hostCSGs[i];
|
|
63
65
|
const intersect = hostCSG.csg.intersect(guestCSG);
|
|
@@ -72,13 +74,13 @@ const GlyphsetCSG = function (hostIn) {
|
|
|
72
74
|
glyph.setLabel(hostCSG.label);
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
|
-
const newCSG = new GlyphsetCSG(glyphset);
|
|
77
|
+
const newCSG = new GlyphsetCSG(glyphset);
|
|
76
78
|
return newCSG;
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
return undefined;
|
|
80
82
|
}
|
|
81
|
-
|
|
83
|
+
|
|
82
84
|
};
|
|
83
85
|
|
|
84
|
-
|
|
86
|
+
export { GlyphsetCSG };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
3
|
+
import { Geometry } from '../primitives/geometry';
|
|
4
|
+
import { Lines } from '../primitives/lines';
|
|
5
|
+
import { Pointset } from '../primitives/pointset';
|
|
4
6
|
|
|
5
7
|
const GLTFToZincJSLoader = function () {
|
|
6
8
|
|
|
@@ -24,11 +26,11 @@ const GLTFToZincJSLoader = function () {
|
|
|
24
26
|
} else {
|
|
25
27
|
let zincGeometry = undefined;
|
|
26
28
|
if (object.type === "Mesh") {
|
|
27
|
-
zincGeometry = new
|
|
29
|
+
zincGeometry = new Geometry();
|
|
28
30
|
} else if (object.type === "LineSegments") {
|
|
29
|
-
zincGeometry = new
|
|
31
|
+
zincGeometry = new Lines();
|
|
30
32
|
} else if (object.type === "Points") {
|
|
31
|
-
zincGeometry = new
|
|
33
|
+
zincGeometry = new Pointset();
|
|
32
34
|
}
|
|
33
35
|
if (zincGeometry) {
|
|
34
36
|
let localTimeEnabled = false;
|
|
@@ -63,7 +65,7 @@ const GLTFToZincJSLoader = function () {
|
|
|
63
65
|
|
|
64
66
|
/**
|
|
65
67
|
* Load GLTF into this scene object.
|
|
66
|
-
*
|
|
68
|
+
*
|
|
67
69
|
* @param {String} url - URL to the GLTF file
|
|
68
70
|
* @param {Function} finishCallback - Callback function which will be called
|
|
69
71
|
* once the glyphset is succssfully load in.
|
|
@@ -72,7 +74,7 @@ const GLTFToZincJSLoader = function () {
|
|
|
72
74
|
const path = url.substring(0, url.lastIndexOf("/") + 1);
|
|
73
75
|
const filename = url.substring(url.lastIndexOf("/") + 1, url.length);
|
|
74
76
|
const loader = new GLTFLoader().setPath(path);
|
|
75
|
-
|
|
77
|
+
|
|
76
78
|
loader.load( filename, function ( gltf ) {
|
|
77
79
|
console.log(gltf)
|
|
78
80
|
_this.parseGLTFObjects(gltf.scene, region, 0, finishCallback);
|
|
@@ -83,4 +85,4 @@ const GLTFToZincJSLoader = function () {
|
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
|
|
86
|
-
|
|
88
|
+
export { GLTFToZincJSLoader };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { Face3 } from '../three/Geometry';
|
|
3
|
+
import { Geometry } from '../three/Geometry';
|
|
4
|
+
import { Loader } from '../three/Loader';
|
|
5
|
+
import { VideoHandler } from '../videoHandler';
|
|
6
|
+
|
|
7
|
+
const AnimationClip = THREE.AnimationClip;
|
|
8
|
+
const Color = THREE.Color;
|
|
9
|
+
const DefaultLoadingManager = THREE.DefaultLoadingManager;
|
|
10
|
+
const FileLoader = THREE.FileLoader;
|
|
11
|
+
const LoaderUtils = THREE.LoaderUtils;
|
|
12
|
+
const Vector2 = THREE.Vector2;
|
|
13
|
+
const Vector3 = THREE.Vector3;
|
|
14
|
+
const Vector4 = THREE.Vector4;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* @author mrdoob / http://mrdoob.com/
|
|
@@ -141,9 +141,6 @@ function convertNiftiToUint8Array(niftiHeader, niftiImage) {
|
|
|
141
141
|
default: throw new Error("Unsupported NIfTI data type");
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
const slope = niftiHeader.scl_slope || 1.0;
|
|
145
|
-
const intercept = niftiHeader.scl_inter || 0.0;
|
|
146
|
-
|
|
147
144
|
let min = Infinity;
|
|
148
145
|
let max = -Infinity;
|
|
149
146
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { JSONLoader } from './JSONLoader';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
3
|
const FileLoader = THREE.FileLoader;
|
|
4
4
|
|
|
5
5
|
const mergeGlyphData = (glyphData) => {
|
|
@@ -174,7 +174,7 @@ const MultiSourcesHandler = function(numberIn, onLoadCallback, options) {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
const PrimitivesLoader = function () {
|
|
178
178
|
let concurrentDownloads = 0;
|
|
179
179
|
const MAX_DOWNLOAD = 20;
|
|
180
180
|
this.crossOrigin = "Anonymous";
|
|
@@ -304,3 +304,4 @@ exports.PrimitivesLoader = function () {
|
|
|
304
304
|
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
export { PrimitivesLoader };
|
package/src/minimap.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This provide a full scale minimap. It will always
|
|
5
5
|
* display the whole map.
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
7
|
* @class
|
|
8
8
|
* @author Alan Wu
|
|
9
9
|
* @return {Minimap}
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
const Minimap = function (sceneIn) {
|
|
12
12
|
let targetScene = sceneIn;
|
|
13
13
|
this.camera = new THREE.OrthographicCamera(
|
|
14
14
|
-0.5, 0.5, 0.5, -0.5, 0.01, 10);
|
|
@@ -24,7 +24,7 @@ exports.Minimap = function (sceneIn) {
|
|
|
24
24
|
] );
|
|
25
25
|
let positionAttributes = new THREE.BufferAttribute( vertices, 3 );
|
|
26
26
|
geometry.setAttribute( 'position', positionAttributes);
|
|
27
|
-
var material = new THREE.MeshBasicMaterial( { color: 0x333333,
|
|
27
|
+
var material = new THREE.MeshBasicMaterial( { color: 0x333333,
|
|
28
28
|
depthTest: false,
|
|
29
29
|
depthWrite: false,
|
|
30
30
|
opacity: 0.5,
|
|
@@ -88,3 +88,5 @@ exports.Minimap = function (sceneIn) {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
+
|
|
92
|
+
export { Minimap };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Provide additional shaders to render time dependent color.
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
const augmentMorphColor = function() {
|
|
6
6
|
return function(shader) {
|
|
7
7
|
shader.vertexShader = shader.vertexShader.replace(
|
|
8
8
|
'#include <color_pars_vertex>',
|
|
@@ -24,3 +24,5 @@ exports.augmentMorphColor = function() {
|
|
|
24
24
|
);
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
export { augmentMorphColor };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { toBufferGeometry } from '../utilities';
|
|
3
|
+
import { augmentMorphColor } from './augmentShader';
|
|
4
|
+
import { ZincObject} from './zincObject';
|
|
3
5
|
|
|
4
6
|
const createMeshForGeometry = (geometryIn, materialIn, options) => {
|
|
5
7
|
// First copy the geometry
|
|
@@ -40,7 +42,7 @@ const createMeshForGeometry = (geometryIn, materialIn, options) => {
|
|
|
40
42
|
}
|
|
41
43
|
//material = PhongToToon(material);
|
|
42
44
|
if (options.localMorphColour && geometry.morphAttributes[ "color" ]) {
|
|
43
|
-
material.onBeforeCompile =
|
|
45
|
+
material.onBeforeCompile = augmentMorphColor();
|
|
44
46
|
}
|
|
45
47
|
} else {
|
|
46
48
|
let videoTexture = geometry._video.createCanvasVideoTexture();
|
|
@@ -54,27 +56,27 @@ const createMeshForGeometry = (geometryIn, materialIn, options) => {
|
|
|
54
56
|
});
|
|
55
57
|
this.videoHandler = geometry._video;
|
|
56
58
|
}
|
|
57
|
-
return new THREE.Mesh(geometry, material);
|
|
59
|
+
return new THREE.Mesh(geometry, material);
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
/**
|
|
61
63
|
* Provides an object which stores geometry and provides method which controls its animations.
|
|
62
64
|
* This is created when a valid json file containging geometry is read into a {@link Zinc.Scene}
|
|
63
65
|
* object.
|
|
64
|
-
*
|
|
66
|
+
*
|
|
65
67
|
* @class
|
|
66
68
|
* @author Alan Wu
|
|
67
69
|
* @return {Geometry}
|
|
68
70
|
*/
|
|
69
71
|
const Geometry = function () {
|
|
70
|
-
|
|
72
|
+
ZincObject.call(this);
|
|
71
73
|
// THREE.Geometry or THREE.BufferGeometry
|
|
72
74
|
this.videoHandler = undefined;
|
|
73
75
|
this.isGeometry = true;
|
|
74
76
|
|
|
75
77
|
/**
|
|
76
78
|
* Create the mesh for rendering
|
|
77
|
-
*
|
|
79
|
+
*
|
|
78
80
|
* @param {THREE.Geomtry} geometryIn - Geometry to be rendered.
|
|
79
81
|
* @param {THREE.Material} materialIn - Material to be set for the geometry.
|
|
80
82
|
* @param {Object} options - Provide various options
|
|
@@ -89,7 +91,7 @@ const Geometry = function () {
|
|
|
89
91
|
//Skip if there is a morph already
|
|
90
92
|
if (this.morph && this.morph.geometry && (geometryIn != undefined))
|
|
91
93
|
return;
|
|
92
|
-
const mesh = createMeshForGeometry(geometryIn, materialIn, options);
|
|
94
|
+
const mesh = createMeshForGeometry(geometryIn, materialIn, options);
|
|
93
95
|
this.setMesh(mesh, options.localTimeEnabled, options.localMorphColour);
|
|
94
96
|
}
|
|
95
97
|
|
|
@@ -114,7 +116,7 @@ const Geometry = function () {
|
|
|
114
116
|
new THREE.Vector2((v3.x + offset.x)/range.x ,(v3.y + offset.y)/range.y)
|
|
115
117
|
]);
|
|
116
118
|
}
|
|
117
|
-
geometry.uvsNeedUpdate = true;
|
|
119
|
+
geometry.uvsNeedUpdate = true;
|
|
118
120
|
}
|
|
119
121
|
|
|
120
122
|
/**
|
|
@@ -124,10 +126,10 @@ const Geometry = function () {
|
|
|
124
126
|
this.checkTransparentMesh = function() {
|
|
125
127
|
this._lod.checkTransparentMesh();
|
|
126
128
|
}
|
|
127
|
-
|
|
129
|
+
|
|
128
130
|
/**
|
|
129
131
|
* Set wireframe display for this geometry.
|
|
130
|
-
*
|
|
132
|
+
*
|
|
131
133
|
* @param {Boolean} wireframe - Flag to turn on/off wireframe display.
|
|
132
134
|
*/
|
|
133
135
|
this.setWireframe = wireframe => {
|
|
@@ -157,9 +159,9 @@ const Geometry = function () {
|
|
|
157
159
|
}
|
|
158
160
|
}
|
|
159
161
|
}
|
|
160
|
-
|
|
162
|
+
|
|
161
163
|
|
|
162
164
|
}
|
|
163
165
|
|
|
164
|
-
Geometry.prototype = Object.create(
|
|
165
|
-
|
|
166
|
+
Geometry.prototype = Object.create(ZincObject.prototype);
|
|
167
|
+
export { Geometry };
|
package/src/primitives/glyph.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { Label } from './label';
|
|
3
|
+
import { ZincObject } from './zincObject';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Zinc representation of glyph graphic, it contains the colours,
|
|
@@ -13,7 +15,7 @@ const THREE = require('three');
|
|
|
13
15
|
* @return {Glyph}
|
|
14
16
|
*/
|
|
15
17
|
const Glyph = function (geometry, materialIn, idIn, glyphsetIn) {
|
|
16
|
-
|
|
18
|
+
ZincObject.call(this);
|
|
17
19
|
let material = undefined;
|
|
18
20
|
if (materialIn) {
|
|
19
21
|
material = materialIn.clone();
|
|
@@ -80,7 +82,7 @@ const Glyph = function (geometry, materialIn, idIn, glyphsetIn) {
|
|
|
80
82
|
label = undefined;
|
|
81
83
|
}
|
|
82
84
|
if (labelString && (typeof labelString === 'string' || labelString instanceof String)) {
|
|
83
|
-
label = new
|
|
85
|
+
label = new Label(labelString, colour);
|
|
84
86
|
label.setPosition(_position[0], _position[1], _position[2]);
|
|
85
87
|
const sprite = label.getSprite();
|
|
86
88
|
sprite.material.alphaTest = 0.5;
|
|
@@ -180,5 +182,5 @@ const Glyph = function (geometry, materialIn, idIn, glyphsetIn) {
|
|
|
180
182
|
}
|
|
181
183
|
}
|
|
182
184
|
|
|
183
|
-
Glyph.prototype = Object.create(
|
|
184
|
-
|
|
185
|
+
Glyph.prototype = Object.create(ZincObject.prototype);
|
|
186
|
+
export { Glyph };
|