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/src/sceneLoader.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { GLTFToZincJSLoader } from './loaders/GLTFToZincJSLoader';
|
|
3
|
+
import { OBJLoader } from './loaders/OBJLoader';
|
|
4
|
+
import { PrimitivesLoader } from './loaders/primitivesLoader';
|
|
5
|
+
import { STLLoader } from './loaders/STLLoader';
|
|
6
|
+
import { Geometry } from './primitives/geometry';
|
|
7
|
+
import { Glyphset } from './primitives/glyphset';
|
|
8
|
+
import { Lines } from './primitives/lines';
|
|
9
|
+
import { Pointset } from './primitives/pointset';
|
|
10
|
+
import { TextureSlides } from './primitives/textureSlides';
|
|
11
|
+
import { TubeLines } from './primitives/tubeLines';
|
|
12
|
+
import { createNewURL, isRegionGroup, resolveURL } from './utilities';
|
|
13
|
+
import Zinc from './zinc';
|
|
9
14
|
|
|
10
15
|
/**
|
|
11
16
|
* A helper class to help with reading / importing primitives and
|
|
@@ -16,7 +21,7 @@ const PrimitivesLoader = require('./loaders/primitivesLoader').PrimitivesLoader;
|
|
|
16
21
|
* @author Alan Wu
|
|
17
22
|
* @return {SceneLoader}
|
|
18
23
|
*/
|
|
19
|
-
|
|
24
|
+
const SceneLoader = function (sceneIn) {
|
|
20
25
|
const scene = sceneIn;
|
|
21
26
|
this.toBeDownloaded = 0;
|
|
22
27
|
this.progressMap = {};
|
|
@@ -79,7 +84,7 @@ exports.SceneLoader = function (sceneIn) {
|
|
|
79
84
|
const promises = [];
|
|
80
85
|
for (const [key, value] of Object.entries(views.Entries)) {
|
|
81
86
|
if (referenceURL) {
|
|
82
|
-
newURL = createNewURL(value, referenceURL);
|
|
87
|
+
const newURL = createNewURL(value, referenceURL);
|
|
83
88
|
promises.push(new Promise((resolve, reject) => {
|
|
84
89
|
// Add parameters if we are sent them
|
|
85
90
|
fetch(newURL)
|
|
@@ -110,26 +115,28 @@ exports.SceneLoader = function (sceneIn) {
|
|
|
110
115
|
*/
|
|
111
116
|
this.loadViewURL = (url, finishCallback) => {
|
|
112
117
|
this.toBeDownloaded += 1;
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if(
|
|
117
|
-
|
|
118
|
-
scene.setupMultipleViews("default", { "default" : viewData });
|
|
119
|
-
scene.resetView();
|
|
120
|
-
viewLoaded = true;
|
|
121
|
-
--this.toBeDownloaded;
|
|
122
|
-
if (finishCallback != undefined && (typeof finishCallback == 'function'))
|
|
123
|
-
finishCallback();
|
|
124
|
-
} else {
|
|
125
|
-
(this.onError(finishCallback))({responseURL: url});
|
|
118
|
+
const requestURL = resolveURL(url);
|
|
119
|
+
fetch(requestURL)
|
|
120
|
+
.then((response) => {
|
|
121
|
+
if (!response.ok) {
|
|
122
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
126
123
|
}
|
|
127
|
-
|
|
124
|
+
return response.json();
|
|
125
|
+
})
|
|
126
|
+
.then((viewData) => {
|
|
127
|
+
scene.setupMultipleViews("default", { "default" : viewData });
|
|
128
|
+
scene.resetView();
|
|
129
|
+
viewLoaded = true;
|
|
130
|
+
--this.toBeDownloaded;
|
|
131
|
+
if (finishCallback !== undefined && typeof finishCallback === 'function') {
|
|
132
|
+
finishCallback();
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
.catch((error) => {
|
|
136
|
+
console.error(`Fetch failed for URL: ${requestURL}`, error);
|
|
137
|
+
(this.onError(finishCallback))({ responseURL: requestURL });
|
|
138
|
+
});
|
|
128
139
|
}
|
|
129
|
-
const requestURL = resolveURL(url);
|
|
130
|
-
xmlhttp.open("GET", requestURL, true);
|
|
131
|
-
xmlhttp.send();
|
|
132
|
-
}
|
|
133
140
|
|
|
134
141
|
/**
|
|
135
142
|
* Load a legacy model(s) format with the provided URLs and parameters. This only loads the geometry
|
|
@@ -142,8 +149,8 @@ exports.SceneLoader = function (sceneIn) {
|
|
|
142
149
|
this.toBeDownloaded += number;
|
|
143
150
|
for (let i = 0; i < number; i++) {
|
|
144
151
|
const filename = urls[i];
|
|
145
|
-
let colour =
|
|
146
|
-
let opacity =
|
|
152
|
+
let colour = Zinc.defaultMaterialColor;
|
|
153
|
+
let opacity = Zinc.defaultOpacity;
|
|
147
154
|
if (colours != undefined && colours[i] != undefined)
|
|
148
155
|
colour = colours[i] ? true : false;
|
|
149
156
|
if (opacities != undefined && opacities[i] != undefined)
|
|
@@ -168,30 +175,42 @@ exports.SceneLoader = function (sceneIn) {
|
|
|
168
175
|
* @deprecated
|
|
169
176
|
*/
|
|
170
177
|
this.loadFromViewURL = (targetRegion, jsonFilePrefix, finishCallback) => {
|
|
171
|
-
const xmlhttp = new XMLHttpRequest();
|
|
172
|
-
xmlhttp.onreadystatechange = () => {
|
|
173
|
-
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
|
174
|
-
const viewData = JSON.parse(xmlhttp.responseText);
|
|
175
|
-
scene.loadView(viewData);
|
|
176
|
-
const urls = [];
|
|
177
|
-
const filename_prefix = jsonFilePrefix + "_";
|
|
178
|
-
for (let i = 0; i < viewData.numberOfResources; i++) {
|
|
179
|
-
const filename = filename_prefix + (i + 1) + ".json";
|
|
180
|
-
urls.push(filename);
|
|
181
|
-
}
|
|
182
|
-
this.loadModelsURL(targetRegion, urls, viewData.colour, viewData.opacity, viewData.timeEnabled, viewData.morphColour, finishCallback);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
178
|
const requestURL = resolveURL(jsonFilePrefix + "_view.json");
|
|
186
|
-
|
|
187
|
-
|
|
179
|
+
fetch(requestURL)
|
|
180
|
+
.then((response) => {
|
|
181
|
+
if (!response.ok) {
|
|
182
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
183
|
+
}
|
|
184
|
+
return response.json();
|
|
185
|
+
})
|
|
186
|
+
.then((viewData) => {
|
|
187
|
+
scene.loadView(viewData);
|
|
188
|
+
const urls = [];
|
|
189
|
+
const filename_prefix = jsonFilePrefix + "_";
|
|
190
|
+
for (let i = 0; i < viewData.numberOfResources; i++) {
|
|
191
|
+
const filename = filename_prefix + (i + 1) + ".json";
|
|
192
|
+
urls.push(filename);
|
|
193
|
+
}
|
|
194
|
+
this.loadModelsURL(
|
|
195
|
+
targetRegion,
|
|
196
|
+
urls,
|
|
197
|
+
viewData.colour,
|
|
198
|
+
viewData.opacity,
|
|
199
|
+
viewData.timeEnabled,
|
|
200
|
+
viewData.morphColour,
|
|
201
|
+
finishCallback
|
|
202
|
+
);
|
|
203
|
+
})
|
|
204
|
+
.catch((error) => {
|
|
205
|
+
console.error(`Failed to load view data from: ${requestURL}`, error);
|
|
206
|
+
});
|
|
188
207
|
}
|
|
189
208
|
|
|
190
209
|
//Internal loader for a regular zinc geometry.
|
|
191
210
|
const linesloader = (region, localTimeEnabled, localMorphColour, groupName,
|
|
192
211
|
anatomicalId, renderOrder, lod, tubeLines, finishCallback) => {
|
|
193
212
|
return (geometry, materials) => {
|
|
194
|
-
const newLines = tubeLines ? new
|
|
213
|
+
const newLines = tubeLines ? new TubeLines() : new Lines();
|
|
195
214
|
let material = undefined;
|
|
196
215
|
if (materials && materials[0]) {
|
|
197
216
|
material = new THREE.LineBasicMaterial({color:materials[0].color.clone()});
|
|
@@ -267,7 +286,7 @@ exports.SceneLoader = function (sceneIn) {
|
|
|
267
286
|
let anatomicalId = (options && options.anatomicalId) ? options.anatomicalId : undefined;
|
|
268
287
|
let displayLabels = (options && options.displayLabels) ? options.displayLabels : undefined;
|
|
269
288
|
let renderOrder = (options && "renderOrder" in options) ? options.renderOrder : undefined;
|
|
270
|
-
const newGlyphset = new
|
|
289
|
+
const newGlyphset = new Glyphset();
|
|
271
290
|
newGlyphset.setDuration(scene.getDuration());
|
|
272
291
|
newGlyphset.groupName = groupName;
|
|
273
292
|
let myCallback = () => {
|
|
@@ -338,7 +357,7 @@ exports.SceneLoader = function (sceneIn) {
|
|
|
338
357
|
//Internal loader for zinc pointset.
|
|
339
358
|
const pointsetloader = (region, localTimeEnabled, localMorphColour, groupName, anatomicalId, renderOrder, finishCallback) => {
|
|
340
359
|
return (geometry, materials) => {
|
|
341
|
-
const newPointset = new
|
|
360
|
+
const newPointset = new Pointset();
|
|
342
361
|
let material = new THREE.PointsMaterial({ alphaTest: 0.5, size: 10, sizeAttenuation: false });
|
|
343
362
|
if (materials && materials[0]) {
|
|
344
363
|
if (1.0 > materials[0].opacity) {
|
|
@@ -378,8 +397,8 @@ exports.SceneLoader = function (sceneIn) {
|
|
|
378
397
|
*/
|
|
379
398
|
this.loadSTL = (region, url, groupName, finishCallback) => {
|
|
380
399
|
this.toBeDownloaded += 1;
|
|
381
|
-
const colour =
|
|
382
|
-
const opacity =
|
|
400
|
+
const colour = Zinc.defaultMaterialColor;
|
|
401
|
+
const opacity = Zinc.defaultOpacity;
|
|
383
402
|
const loader = new STLLoader();
|
|
384
403
|
loader.crossOrigin = "Anonymous";
|
|
385
404
|
loader.load(resolveURL(url), meshloader(region, colour, opacity, false,
|
|
@@ -397,8 +416,8 @@ exports.SceneLoader = function (sceneIn) {
|
|
|
397
416
|
*/
|
|
398
417
|
this.loadOBJ = (region, url, groupName, finishCallback) => {
|
|
399
418
|
this.toBeDownloaded += 1;
|
|
400
|
-
const colour =
|
|
401
|
-
const opacity =
|
|
419
|
+
const colour = Zinc.defaultMaterialColor;
|
|
420
|
+
const opacity = Zinc.defaultOpacity;
|
|
402
421
|
const loader = new OBJLoader();
|
|
403
422
|
loader.crossOrigin = "Anonymous";
|
|
404
423
|
loader.load(resolveURL(url), meshloader(region, colour, opacity, false,
|
|
@@ -420,8 +439,8 @@ exports.SceneLoader = function (sceneIn) {
|
|
|
420
439
|
*/
|
|
421
440
|
const loadSurfaceURL = (region ,url, timeEnabled, morphColour, groupName, finishCallback, options) => {
|
|
422
441
|
this.toBeDownloaded += 1;
|
|
423
|
-
const colour =
|
|
424
|
-
const opacity =
|
|
442
|
+
const colour = Zinc.defaultMaterialColor;
|
|
443
|
+
const opacity = Zinc.defaultOpacity;
|
|
425
444
|
let localTimeEnabled = 0;
|
|
426
445
|
let isInline = (options && options.isInline) ? options.isInline : false;
|
|
427
446
|
let fileFormat = (options && options.fileFormat) ? options.fileFormat : undefined;
|
|
@@ -525,7 +544,7 @@ exports.SceneLoader = function (sceneIn) {
|
|
|
525
544
|
}
|
|
526
545
|
}
|
|
527
546
|
if (textureData.type === "slides") {
|
|
528
|
-
newTexture = new
|
|
547
|
+
newTexture = new TextureSlides();
|
|
529
548
|
}
|
|
530
549
|
if (newTexture) {
|
|
531
550
|
newTexture.groupName = groupName;
|
|
@@ -544,17 +563,6 @@ exports.SceneLoader = function (sceneIn) {
|
|
|
544
563
|
}
|
|
545
564
|
};
|
|
546
565
|
|
|
547
|
-
|
|
548
|
-
//Load a glyphset into this scene.
|
|
549
|
-
const onLoadTextureReady = (region, xmlhttp, groupName, finishCallback, options) => {
|
|
550
|
-
return () => {
|
|
551
|
-
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
|
552
|
-
const textureData = JSON.parse(xmlhttp.responseText);
|
|
553
|
-
loadTexture(region, xmlhttp.responseURL, textureData, groupName, finishCallback, options);
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
};
|
|
557
|
-
|
|
558
566
|
/**
|
|
559
567
|
* Load a texture into this scene object.
|
|
560
568
|
*
|
|
@@ -567,11 +575,21 @@ exports.SceneLoader = function (sceneIn) {
|
|
|
567
575
|
if (isInline) {
|
|
568
576
|
loadTexture(region, undefined, url, groupName, finishCallback, options);
|
|
569
577
|
} else {
|
|
570
|
-
const
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
578
|
+
const requestURL = resolveURL(url);
|
|
579
|
+
fetch(requestURL)
|
|
580
|
+
.then((response) => {
|
|
581
|
+
if (!response.ok) {
|
|
582
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
583
|
+
}
|
|
584
|
+
const referenceURL = response.url || (new URL(requestURL)).href;
|
|
585
|
+
return response.json().then((textureData) => ({ textureData, referenceURL }));
|
|
586
|
+
})
|
|
587
|
+
.then(({textureData, referenceURL}) => {
|
|
588
|
+
loadTexture(region, referenceURL, textureData, groupName, finishCallback, options);
|
|
589
|
+
})
|
|
590
|
+
.catch((error) => {
|
|
591
|
+
console.error(`Fetch failed for texture URL: ${requestURL}`, error);
|
|
592
|
+
});
|
|
575
593
|
}
|
|
576
594
|
}
|
|
577
595
|
|
|
@@ -607,7 +625,7 @@ exports.SceneLoader = function (sceneIn) {
|
|
|
607
625
|
options.opacity = opacity;
|
|
608
626
|
options.localTimeEnabled = localTimeEnabled;
|
|
609
627
|
options.localMorphColour = localMorphColour
|
|
610
|
-
const newGeometry = new
|
|
628
|
+
const newGeometry = new Geometry();
|
|
611
629
|
newGeometry.createMesh(geometryIn, materialIn, options);
|
|
612
630
|
if (newGeometry.getMorph()) {
|
|
613
631
|
newGeometry.setName(groupName);
|
|
@@ -804,8 +822,8 @@ exports.SceneLoader = function (sceneIn) {
|
|
|
804
822
|
* once the glyphset is succssfully load in.
|
|
805
823
|
*/
|
|
806
824
|
this.loadGLTF = (region, url, finishCallback, allCompletedCallback, options) => {
|
|
807
|
-
const
|
|
808
|
-
|
|
825
|
+
const loader = new GLTFToZincJSLoader();
|
|
826
|
+
loader.load(scene, region, url, finishCallback, allCompletedCallback, options);
|
|
809
827
|
}
|
|
810
828
|
|
|
811
829
|
let loadRegions = (currentRegion, referenceURL, regions, callback) => {
|
|
@@ -966,28 +984,31 @@ exports.SceneLoader = function (sceneIn) {
|
|
|
966
984
|
* for each glyphset and geometry that has been written in.
|
|
967
985
|
*/
|
|
968
986
|
this.loadMetadataURL = (targetRegion, url, finishCallback, allCompletedCallback, options) => {
|
|
969
|
-
const xmlhttp = new XMLHttpRequest();
|
|
970
987
|
const requestURL = resolveURL(url);
|
|
971
|
-
|
|
972
|
-
|
|
988
|
+
fetch(requestURL)
|
|
989
|
+
.then((response) => {
|
|
990
|
+
if (!response.ok) {
|
|
991
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
992
|
+
}
|
|
993
|
+
const referenceURL = response.url || (new URL(requestURL)).href;
|
|
994
|
+
return response.json().then((metadata) => ({ metadata, referenceURL }));
|
|
995
|
+
})
|
|
996
|
+
.then(({metadata, referenceURL}) => {
|
|
973
997
|
scene.resetMetadata();
|
|
974
998
|
scene.resetDuration();
|
|
975
999
|
viewLoaded = false;
|
|
976
|
-
let referenceURL = xmlhttp.responseURL;
|
|
977
|
-
if (referenceURL === undefined)
|
|
978
|
-
referenceURL = (new URL(requestURL)).href;
|
|
979
|
-
const metadata = JSON.parse(xmlhttp.responseText);
|
|
980
1000
|
if (Array.isArray(metadata)) {
|
|
981
1001
|
loadVersionOne(targetRegion, metadata, referenceURL, finishCallback, allCompletedCallback, options);
|
|
982
1002
|
} else if (typeof metadata === "object" && metadata !== null) {
|
|
983
|
-
if (metadata.Version
|
|
1003
|
+
if (metadata.Version === "2.0") {
|
|
984
1004
|
loadVersionTwo(targetRegion, metadata, referenceURL, finishCallback, allCompletedCallback);
|
|
985
1005
|
}
|
|
986
1006
|
}
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
xmlhttp.send();
|
|
1007
|
+
})
|
|
1008
|
+
.catch((error) => {
|
|
1009
|
+
console.error(`Fetch failed for URL: ${requestURL}`, error);
|
|
1010
|
+
});
|
|
992
1011
|
}
|
|
993
1012
|
}
|
|
1013
|
+
|
|
1014
|
+
export { SceneLoader };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
3
2
|
const glslVersion = null;
|
|
4
3
|
|
|
5
4
|
const fs =
|
|
@@ -76,7 +75,7 @@ void main()
|
|
|
76
75
|
}
|
|
77
76
|
`;
|
|
78
77
|
|
|
79
|
-
const vs =
|
|
78
|
+
const vs =
|
|
80
79
|
`
|
|
81
80
|
varying vec4 diffuse, ambientGlobal, ambient;
|
|
82
81
|
uniform vec4 texture_scaling;
|
|
@@ -112,7 +111,9 @@ const getUniforms = function() {
|
|
|
112
111
|
}
|
|
113
112
|
};
|
|
114
113
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
export {
|
|
115
|
+
fs,
|
|
116
|
+
vs,
|
|
117
|
+
glslVersion,
|
|
118
|
+
getUniforms
|
|
119
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
2
|
|
|
3
3
|
const glslVersion = THREE.GLSL3;
|
|
4
4
|
|
|
@@ -23,7 +23,7 @@ void main() {
|
|
|
23
23
|
}
|
|
24
24
|
`;
|
|
25
25
|
|
|
26
|
-
const vs =
|
|
26
|
+
const vs =
|
|
27
27
|
`
|
|
28
28
|
out vec3 vUw;
|
|
29
29
|
uniform float depth;
|
|
@@ -44,8 +44,9 @@ const getUniforms = function() {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
export {
|
|
48
|
+
fs,
|
|
49
|
+
vs,
|
|
50
|
+
glslVersion,
|
|
51
|
+
getUniforms
|
|
52
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
3
2
|
const glslVersion = THREE.GLSL3;
|
|
4
3
|
|
|
5
4
|
const fs =
|
|
@@ -92,7 +91,9 @@ const getUniforms = function() {
|
|
|
92
91
|
};
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
export {
|
|
95
|
+
fs,
|
|
96
|
+
vs,
|
|
97
|
+
glslVersion,
|
|
98
|
+
getUniforms
|
|
99
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
3
2
|
const glslVersion = null;
|
|
4
3
|
|
|
5
4
|
const fs =
|
|
@@ -237,7 +236,7 @@ const fs =
|
|
|
237
236
|
}
|
|
238
237
|
`;
|
|
239
238
|
|
|
240
|
-
const vs =
|
|
239
|
+
const vs =
|
|
241
240
|
`
|
|
242
241
|
varying vec4 v_nearpos;
|
|
243
242
|
varying vec4 v_farpos;
|
|
@@ -281,7 +280,9 @@ const getUniforms = function() {
|
|
|
281
280
|
}
|
|
282
281
|
};
|
|
283
282
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
283
|
+
export {
|
|
284
|
+
fs,
|
|
285
|
+
vs,
|
|
286
|
+
glslVersion,
|
|
287
|
+
getUniforms
|
|
288
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
3
2
|
const glslVersion = null;
|
|
4
3
|
|
|
5
4
|
const fs =
|
|
@@ -237,7 +236,7 @@ const fs =
|
|
|
237
236
|
}
|
|
238
237
|
`;
|
|
239
238
|
|
|
240
|
-
const vs =
|
|
239
|
+
const vs =
|
|
241
240
|
`
|
|
242
241
|
varying vec4 v_nearpos;
|
|
243
242
|
varying vec4 v_farpos;
|
|
@@ -281,7 +280,9 @@ const getUniforms = function() {
|
|
|
281
280
|
}
|
|
282
281
|
};
|
|
283
282
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
283
|
+
export {
|
|
284
|
+
fs,
|
|
285
|
+
vs,
|
|
286
|
+
glslVersion,
|
|
287
|
+
getUniforms
|
|
288
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
3
2
|
const glslVersion = THREE.GLSL3;
|
|
4
3
|
|
|
5
4
|
const fs =
|
|
@@ -51,7 +50,7 @@ void main(void) {
|
|
|
51
50
|
// Step 4: Starting from the entry point, march the ray through the volume
|
|
52
51
|
// and sample it
|
|
53
52
|
vec3 p = transformed_eye + t_hit.x * ray_dir;
|
|
54
|
-
p.z = p.z * depth;
|
|
53
|
+
p.z = p.z * depth;
|
|
55
54
|
for (float t = t_hit.x; t < t_hit.y; t += dt) {
|
|
56
55
|
// Step 4.1: Sample the volume, and color it by the transfer function.
|
|
57
56
|
// Note that here we don't use the opacity from the transfer function,
|
|
@@ -73,7 +72,7 @@ void main(void) {
|
|
|
73
72
|
}
|
|
74
73
|
`;
|
|
75
74
|
|
|
76
|
-
const vs =
|
|
75
|
+
const vs =
|
|
77
76
|
`
|
|
78
77
|
uniform vec3 volume_scale;
|
|
79
78
|
|
|
@@ -101,7 +100,9 @@ const getUniforms = function() {
|
|
|
101
100
|
}
|
|
102
101
|
};
|
|
103
102
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
export {
|
|
104
|
+
fs,
|
|
105
|
+
vs,
|
|
106
|
+
glslVersion,
|
|
107
|
+
getUniforms
|
|
108
|
+
}
|
package/src/texture/texture.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Base texture object for importing images and turning them into
|
|
5
5
|
* texures unit that can be used by other texture primitives.
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
7
|
* @class
|
|
8
8
|
* @author Alan Wu
|
|
9
9
|
* @return {Texture}
|
|
@@ -21,11 +21,11 @@ const Texture = function () {
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Read an image from src.
|
|
24
|
-
*
|
|
24
|
+
*
|
|
25
25
|
* @async
|
|
26
26
|
* @param {Image} img - An image object.
|
|
27
27
|
* @param {String} src - Source location of the image.
|
|
28
|
-
*
|
|
28
|
+
*
|
|
29
29
|
* @return {Promise} img on resolve.
|
|
30
30
|
*/
|
|
31
31
|
Texture.prototype.loadImage = function (img, src) {
|
|
@@ -45,12 +45,12 @@ Texture.prototype.loadImage = function (img, src) {
|
|
|
45
45
|
*/
|
|
46
46
|
/**
|
|
47
47
|
* Read an image from src and turn it into Uint8Array.
|
|
48
|
-
*
|
|
48
|
+
*
|
|
49
49
|
* @async
|
|
50
50
|
* @param {Image} img - An image object.
|
|
51
51
|
* @param {String} src - Source location of the image.
|
|
52
52
|
* @param {Canvas} canvas - Canvas html element used for the conversion.
|
|
53
|
-
*
|
|
53
|
+
*
|
|
54
54
|
* @return {IMAGE_UNIT8_RETURN}
|
|
55
55
|
*/
|
|
56
56
|
Texture.prototype.imageToUint8Array = async function (instance, img, src, canvas) {
|
|
@@ -72,7 +72,7 @@ Texture.prototype.loadFromImages = async function (srcArrays) {
|
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Return true if the texture is ready for consumption.
|
|
75
|
-
*
|
|
75
|
+
*
|
|
76
76
|
* @return {Boolean}
|
|
77
77
|
*/
|
|
78
78
|
Texture.prototype.isReady = function () {
|
|
@@ -83,7 +83,7 @@ Texture.prototype.isReady = function () {
|
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
85
|
* Return true if the texture is ready for consumption, otherwise false.
|
|
86
|
-
*
|
|
86
|
+
*
|
|
87
87
|
* @return {Boolean}
|
|
88
88
|
*/
|
|
89
89
|
Texture.prototype.getMaterial = function () {
|
|
@@ -98,4 +98,4 @@ Texture.prototype.getMaterial = function () {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
export { Texture };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { Texture } from './texture';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Texture array object for holding array of images into
|
|
@@ -9,7 +10,7 @@ const THREE = require('three');
|
|
|
9
10
|
* @return {TextureArray}
|
|
10
11
|
*/
|
|
11
12
|
const TextureArray = function () {
|
|
12
|
-
|
|
13
|
+
Texture.call(this);
|
|
13
14
|
this.isTextureArray = true;
|
|
14
15
|
|
|
15
16
|
|
|
@@ -112,5 +113,5 @@ const TextureArray = function () {
|
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
TextureArray.prototype = Object.create(
|
|
116
|
-
|
|
116
|
+
TextureArray.prototype = Object.create(Texture.prototype);
|
|
117
|
+
export { TextureArray };
|
package/src/three/Loader.js
CHANGED
package/src/three/Points.js
CHANGED
|
@@ -83,7 +83,7 @@ class Points extends Object3D {
|
|
|
83
83
|
for ( let i = start, il = end; i < il; i ++ ) {
|
|
84
84
|
|
|
85
85
|
const a = index.getX( i );
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
calculatePosition( this, positionAttribute, morphPosition, a );
|
|
88
88
|
|
|
89
89
|
testPoint( _position, a, localThresholdSq, matrixWorld, raycaster, intersects, this );
|
|
@@ -96,7 +96,7 @@ class Points extends Object3D {
|
|
|
96
96
|
const end = Math.min( positionAttribute.count, ( drawRange.start + drawRange.count ) );
|
|
97
97
|
|
|
98
98
|
for ( let i = start, l = end; i < l; i ++ ) {
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
calculatePosition( this, positionAttribute, morphPosition, i );
|
|
101
101
|
|
|
102
102
|
testPoint( _position, i, localThresholdSq, matrixWorld, raycaster, intersects, this );
|