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
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { Glyph } from './glyph';
|
|
3
|
+
import { ZincObject } from './zincObject';
|
|
4
|
+
import { JSONLoader } from '../loaders/JSONLoader';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* This is a container of {@link Glyph} and their graphical properties
|
|
@@ -12,7 +14,7 @@ const JSONLoader = require('../loaders/JSONLoader').JSONLoader;
|
|
|
12
14
|
* @return {Glyphset}
|
|
13
15
|
*/
|
|
14
16
|
const Glyphset = function () {
|
|
15
|
-
|
|
17
|
+
ZincObject.call(this);
|
|
16
18
|
const glyphList = [];
|
|
17
19
|
let axis1s = undefined;
|
|
18
20
|
let axis2s = undefined;
|
|
@@ -431,7 +433,7 @@ const Glyphset = function () {
|
|
|
431
433
|
*/
|
|
432
434
|
const createGlyphs = (displayLabels) => {
|
|
433
435
|
for (let i = 0; i < numberOfVertices; i++) {
|
|
434
|
-
const glyph = new
|
|
436
|
+
const glyph = new Glyph(undefined, undefined, i, this);
|
|
435
437
|
let label = labels ? labels[i] : undefined;
|
|
436
438
|
label = label ? label : this.groupName;
|
|
437
439
|
if (label) {
|
|
@@ -477,7 +479,7 @@ const Glyphset = function () {
|
|
|
477
479
|
*/
|
|
478
480
|
this.addMeshAsGlyph = (mesh, id) => {
|
|
479
481
|
if (mesh.isMesh) {
|
|
480
|
-
const glyph = new
|
|
482
|
+
const glyph = new Glyph(undefined, undefined, id, this);
|
|
481
483
|
glyph.fromMesh(mesh);
|
|
482
484
|
glyphList.push(glyph);
|
|
483
485
|
this.morph.add(glyph.getGroup())
|
|
@@ -694,5 +696,5 @@ const Glyphset = function () {
|
|
|
694
696
|
}
|
|
695
697
|
}
|
|
696
698
|
|
|
697
|
-
Glyphset.prototype = Object.create(
|
|
698
|
-
|
|
699
|
+
Glyphset.prototype = Object.create(ZincObject.prototype);
|
|
700
|
+
export { Glyphset };
|
package/src/primitives/label.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import SpriteTextModule from 'three-spritetext';
|
|
2
|
+
const SpriteText = SpriteTextModule.default || SpriteTextModule;
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Bitmap labels, this is used with {@link Glyph} to
|
|
@@ -11,7 +12,7 @@ const SpriteText = require('three-spritetext').default;
|
|
|
11
12
|
* @author Alan Wu
|
|
12
13
|
* @return {Label}
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
const Label = function (textIn, colourIn) {
|
|
15
16
|
let text = textIn;
|
|
16
17
|
let sprite = undefined;
|
|
17
18
|
const position = [0, 0, 0];
|
|
@@ -165,5 +166,7 @@ exports.Label = function (textIn, colourIn) {
|
|
|
165
166
|
|
|
166
167
|
};
|
|
167
168
|
|
|
169
|
+
export { Label };
|
|
170
|
+
|
|
168
171
|
|
|
169
172
|
|
package/src/primitives/lines.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { toBufferGeometry } from '../utilities';
|
|
3
|
+
import { augmentMorphColor } from './augmentShader';
|
|
4
|
+
import { LineSegments } from '../three/line/LineSegments';
|
|
5
|
+
import { ZincObject } from './zincObject';
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* Provides an object which stores lines.
|
|
6
9
|
* This is created when a valid json file containing lines is read into a {@link Zinc.Scene}
|
|
7
10
|
* object.
|
|
8
|
-
*
|
|
11
|
+
*
|
|
9
12
|
* @class
|
|
10
13
|
* @author Alan Wu
|
|
11
14
|
* @return {Lines}
|
|
12
15
|
*/
|
|
13
16
|
const Lines = function () {
|
|
14
|
-
|
|
17
|
+
ZincObject.call(this);
|
|
15
18
|
this.isLines = true;
|
|
16
19
|
|
|
17
20
|
/**
|
|
18
21
|
* Create the line segements using geometry and material.
|
|
19
|
-
*
|
|
22
|
+
*
|
|
20
23
|
* @param {THREE.Geomtry} geometryIn - Geometry of lines to be rendered.
|
|
21
24
|
* @param {THREE.Material} materialIn - Material to be set for the lines.
|
|
22
25
|
* @param {Object} options - Provide various options
|
|
@@ -29,15 +32,15 @@ const Lines = function () {
|
|
|
29
32
|
if (geometryIn && materialIn) {
|
|
30
33
|
let geometry = toBufferGeometry(geometryIn, options);
|
|
31
34
|
if (options.localMorphColour && geometry.morphAttributes[ "color" ])
|
|
32
|
-
materialIn.onBeforeCompile =
|
|
33
|
-
let line = new
|
|
35
|
+
materialIn.onBeforeCompile = augmentMorphColor();
|
|
36
|
+
let line = new LineSegments(geometry, materialIn);
|
|
34
37
|
this.setMesh(line, options.localTimeEnabled, options.localMorphColour);
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
42
|
* Set the width for the lines.
|
|
40
|
-
*
|
|
43
|
+
*
|
|
41
44
|
* @param {Number} width - Width of the lines.
|
|
42
45
|
*/
|
|
43
46
|
this.setWidth = width => {
|
|
@@ -69,5 +72,5 @@ const Lines = function () {
|
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
Lines.prototype = Object.create(
|
|
73
|
-
|
|
75
|
+
Lines.prototype = Object.create(ZincObject.prototype);
|
|
76
|
+
export { Lines };
|
package/src/primitives/lines2.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { Lines } from './lines';
|
|
3
|
+
import { LineSegments2 } from '../three/line/LineSegments2';
|
|
4
|
+
import { LineMaterial } from '../three/line/LineMaterial';
|
|
5
|
+
import { LineSegmentsGeometry } from '../three/line/LineSegmentsGeometry';
|
|
7
6
|
/**
|
|
8
7
|
* Provides an object which stores lines.
|
|
9
8
|
* This is created when a valid json file containing lines is read into a {@link Zinc.Scene}
|
|
@@ -14,7 +13,7 @@ const LineSegmentsGeometry = require("../three/line/LineSegmentsGeometry").LineS
|
|
|
14
13
|
* @return {Lines}
|
|
15
14
|
*/
|
|
16
15
|
const Lines2 = function () {
|
|
17
|
-
|
|
16
|
+
Lines.call(this);
|
|
18
17
|
this.isLines2 = true;
|
|
19
18
|
let positions = new Array(300);
|
|
20
19
|
|
|
@@ -178,6 +177,6 @@ const Lines2 = function () {
|
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
179
|
|
|
181
|
-
Lines2.prototype = Object.create(
|
|
180
|
+
Lines2.prototype = Object.create(Lines.prototype);
|
|
182
181
|
Lines2.prototype.constructor = Lines2;
|
|
183
|
-
|
|
182
|
+
export { Lines2 };
|
package/src/primitives/lod.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { toBufferGeometry, updateMorphColorAttribute } from '../utilities';
|
|
3
|
+
import { LineSegments } from '../three/line/LineSegments';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Provides an object which stores meshes at different levels based
|
|
7
7
|
* on specified distance.
|
|
8
8
|
* This object is ued by zincObject to provide mesh at different LODs.
|
|
9
|
-
* A layer is displayed when the distance from the camera is greater
|
|
9
|
+
* A layer is displayed when the distance from the camera is greater
|
|
10
10
|
* than its specified distance and closest compared to other layers.
|
|
11
11
|
* This is intended to be an internal object used only by Zinc Object.
|
|
12
|
-
*
|
|
12
|
+
*
|
|
13
13
|
* This object assumes the centroid and bounding box are consistent between
|
|
14
14
|
* different level of layers.
|
|
15
|
-
*
|
|
15
|
+
*
|
|
16
16
|
* @class
|
|
17
17
|
* @author Alan Wu
|
|
18
18
|
* @return {LOD}
|
|
@@ -148,7 +148,7 @@ const LOD = function (parent) {
|
|
|
148
148
|
this._secondaryMaterial.emissive.copy(this._material.emissive);
|
|
149
149
|
}
|
|
150
150
|
this._secondaryMaterial.needsUpdate = true;
|
|
151
|
-
// THREE.Mesh - for utilities purpose such as rendering
|
|
151
|
+
// THREE.Mesh - for utilities purpose such as rendering
|
|
152
152
|
// transparent surfaces - one for front face and one for back face.
|
|
153
153
|
if (!level.secondaryMesh) {
|
|
154
154
|
level.secondaryMesh = new THREE.Mesh(level.morph.geometry,
|
|
@@ -222,7 +222,7 @@ const LOD = function (parent) {
|
|
|
222
222
|
if (this._parent.isGeometry) {
|
|
223
223
|
mesh = new THREE.Mesh(geometry, material);
|
|
224
224
|
} else if (this._parent.isLines) {
|
|
225
|
-
mesh = new
|
|
225
|
+
mesh = new LineSegments(geometry, material);
|
|
226
226
|
}
|
|
227
227
|
mesh.userData = this._parent;
|
|
228
228
|
mesh.renderOrder = this._renderOrder;
|
|
@@ -396,4 +396,4 @@ const LOD = function (parent) {
|
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
-
|
|
399
|
+
export { LOD };
|
package/src/primitives/marker.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import myImage from '../assets/mapMarker.svg';
|
|
3
|
+
import { createNewSpriteText } from '../utilities';
|
|
4
|
+
import { ZincObject } from './zincObject';
|
|
5
|
+
|
|
2
6
|
const markerImage = new Image(128, 128);
|
|
3
|
-
markerImage.src =
|
|
7
|
+
markerImage.src = myImage;
|
|
4
8
|
const texture = new THREE.Texture();
|
|
5
9
|
texture.image = markerImage;
|
|
6
10
|
texture.needsUpdate = true;
|
|
@@ -13,19 +17,22 @@ const spriteMaterial = new THREE.SpriteMaterial({
|
|
|
13
17
|
depthWrite: false,
|
|
14
18
|
sizeAttenuation: false
|
|
15
19
|
});
|
|
16
|
-
const createNewSpriteText = require('../utilities').createNewSpriteText;
|
|
17
20
|
|
|
18
21
|
/**
|
|
19
22
|
* A special graphics type with a tear drop shape.
|
|
20
23
|
* It is currently used to mark the location of a
|
|
21
24
|
* {@link zincObject}.
|
|
22
|
-
*
|
|
25
|
+
*
|
|
23
26
|
* @class
|
|
24
27
|
* @author Alan Wu
|
|
25
28
|
* @return {Marker}
|
|
26
29
|
*/
|
|
27
30
|
const Marker = function(zincObject) {
|
|
28
|
-
(
|
|
31
|
+
if (Object.getPrototypeOf(this) !== ZincObject.prototype) {
|
|
32
|
+
Object.setPrototypeOf(Marker.prototype, ZincObject.prototype);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
ZincObject.call(this);
|
|
29
36
|
this.texture = texture;
|
|
30
37
|
let sprite = undefined;
|
|
31
38
|
let userTexture = undefined;
|
|
@@ -42,7 +49,7 @@ const Marker = function(zincObject) {
|
|
|
42
49
|
let number = undefined;
|
|
43
50
|
let label = undefined;
|
|
44
51
|
|
|
45
|
-
let initialise = () => {
|
|
52
|
+
let initialise = () => {
|
|
46
53
|
sprite = new THREE.Sprite(spriteMaterial);
|
|
47
54
|
sprite.center.set(0.5, 0);
|
|
48
55
|
this.morph.add(sprite);
|
|
@@ -71,7 +78,7 @@ const Marker = function(zincObject) {
|
|
|
71
78
|
|
|
72
79
|
/**
|
|
73
80
|
* Set the position of the marker.
|
|
74
|
-
*
|
|
81
|
+
*
|
|
75
82
|
* @param {Number} x - x coordinate to be set.
|
|
76
83
|
* @param {Number} y - y coordinate to be set.
|
|
77
84
|
* @param {Number} z - z coordinate to be set.
|
|
@@ -82,9 +89,9 @@ const Marker = function(zincObject) {
|
|
|
82
89
|
|
|
83
90
|
/**
|
|
84
91
|
* Set the size of the marker.
|
|
85
|
-
*
|
|
92
|
+
*
|
|
86
93
|
* @param {Number} size - size to be set.
|
|
87
|
-
*/
|
|
94
|
+
*/
|
|
88
95
|
this.setSpriteSize = size => {
|
|
89
96
|
sprite.scale.set(0.015, 0.02, 1);
|
|
90
97
|
sprite.scale.multiplyScalar(size);
|
|
@@ -158,7 +165,7 @@ const Marker = function(zincObject) {
|
|
|
158
165
|
|
|
159
166
|
/**
|
|
160
167
|
* Clean up this object,
|
|
161
|
-
*/
|
|
168
|
+
*/
|
|
162
169
|
this.dispose = () => {
|
|
163
170
|
if (this.morph) {
|
|
164
171
|
this.morph.clear();
|
|
@@ -201,8 +208,8 @@ const Marker = function(zincObject) {
|
|
|
201
208
|
|
|
202
209
|
/**
|
|
203
210
|
* Set the visibility of this Geometry.
|
|
204
|
-
*
|
|
205
|
-
* @param {Boolean} visible - a boolean flag indicate the visibility to be set
|
|
211
|
+
*
|
|
212
|
+
* @param {Boolean} visible - a boolean flag indicate the visibility to be set
|
|
206
213
|
*/
|
|
207
214
|
this.setVisibility = function(visible) {
|
|
208
215
|
if (visible !== this.visible) {
|
|
@@ -214,7 +221,7 @@ const Marker = function(zincObject) {
|
|
|
214
221
|
|
|
215
222
|
/**
|
|
216
223
|
* Enable and visualise the marker.
|
|
217
|
-
*/
|
|
224
|
+
*/
|
|
218
225
|
this.enable = () => {
|
|
219
226
|
enabled = true;
|
|
220
227
|
this.morph.visible = true;
|
|
@@ -223,7 +230,7 @@ const Marker = function(zincObject) {
|
|
|
223
230
|
|
|
224
231
|
/**
|
|
225
232
|
* Disable and hide the marker.
|
|
226
|
-
*/
|
|
233
|
+
*/
|
|
227
234
|
this.disable = () => {
|
|
228
235
|
enabled = false;
|
|
229
236
|
this.morph.visible = false;
|
|
@@ -234,5 +241,4 @@ const Marker = function(zincObject) {
|
|
|
234
241
|
|
|
235
242
|
}
|
|
236
243
|
|
|
237
|
-
Marker
|
|
238
|
-
exports.Marker = Marker;
|
|
244
|
+
export { Marker };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { ZincObject } from './zincObject';
|
|
2
3
|
const markerImage = new Image(128, 128);
|
|
3
|
-
|
|
4
|
+
import mapMarkerOrange from '../assets/mapMarkerOrange.svg';
|
|
5
|
+
markerImage.src = mapMarkerOrange;
|
|
4
6
|
const texture = new THREE.Texture();
|
|
5
7
|
texture.image = markerImage;
|
|
6
8
|
texture.needsUpdate = true;
|
|
@@ -13,18 +15,18 @@ const spriteMaterial = new THREE.SpriteMaterial({
|
|
|
13
15
|
depthWrite: false,
|
|
14
16
|
sizeAttenuation: false
|
|
15
17
|
});
|
|
16
|
-
|
|
18
|
+
import { createNewSpriteText } from '../utilities';
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* A special graphics type with a tear drop shape.
|
|
20
22
|
* It forms a cluster a marker based on distance.
|
|
21
|
-
*
|
|
23
|
+
*
|
|
22
24
|
* @class
|
|
23
25
|
* @author Alan Wu
|
|
24
26
|
* @return {Marker}
|
|
25
27
|
*/
|
|
26
28
|
const MarkerCluster = function(sceneIn) {
|
|
27
|
-
|
|
29
|
+
ZincObject.call(this);
|
|
28
30
|
this.texture = texture;
|
|
29
31
|
let sprite = undefined;
|
|
30
32
|
let scene = sceneIn;
|
|
@@ -41,9 +43,9 @@ const MarkerCluster = function(sceneIn) {
|
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
45
|
* Set the size of the marker.
|
|
44
|
-
*
|
|
46
|
+
*
|
|
45
47
|
* @param {Number} size - size to be set.
|
|
46
|
-
*/
|
|
48
|
+
*/
|
|
47
49
|
this.setSpriteSize = size => {
|
|
48
50
|
sprite.scale.set(0.015, 0.02, 1);
|
|
49
51
|
sprite.scale.multiplyScalar(size);
|
|
@@ -56,7 +58,7 @@ const MarkerCluster = function(sceneIn) {
|
|
|
56
58
|
|
|
57
59
|
/**
|
|
58
60
|
* Clean up this object,
|
|
59
|
-
*/
|
|
61
|
+
*/
|
|
60
62
|
this.dispose = () => {
|
|
61
63
|
this.clear();
|
|
62
64
|
if (this.morph) {
|
|
@@ -188,7 +190,7 @@ const MarkerCluster = function(sceneIn) {
|
|
|
188
190
|
|
|
189
191
|
/**
|
|
190
192
|
* Enable and visualise the marker.
|
|
191
|
-
*/
|
|
193
|
+
*/
|
|
192
194
|
this.enable = () => {
|
|
193
195
|
enabled = true;
|
|
194
196
|
this.morph.visible = true;
|
|
@@ -196,7 +198,7 @@ const MarkerCluster = function(sceneIn) {
|
|
|
196
198
|
|
|
197
199
|
/**
|
|
198
200
|
* Disable and hide the marker.
|
|
199
|
-
*/
|
|
201
|
+
*/
|
|
200
202
|
this.disable = () => {
|
|
201
203
|
enabled = false;
|
|
202
204
|
this.morph.visible = false;
|
|
@@ -233,5 +235,5 @@ const MarkerCluster = function(sceneIn) {
|
|
|
233
235
|
}
|
|
234
236
|
}
|
|
235
237
|
|
|
236
|
-
MarkerCluster.prototype = Object.create(
|
|
237
|
-
|
|
238
|
+
MarkerCluster.prototype = Object.create(ZincObject.prototype);
|
|
239
|
+
export { MarkerCluster };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { Label } from './label';
|
|
3
|
+
import { Points } from '../three/Points';
|
|
4
|
+
import { ZincObject } from './zincObject';
|
|
5
|
+
import { getCircularTexture, toBufferGeometry } from '../utilities';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Provides an object which stores points and provides method which controls its position.
|
|
@@ -14,7 +14,7 @@ const Label = require('./label').Label;
|
|
|
14
14
|
* @return {Pointset}
|
|
15
15
|
*/
|
|
16
16
|
const Pointset = function () {
|
|
17
|
-
|
|
17
|
+
ZincObject.call(this);
|
|
18
18
|
this.isPointset = true;
|
|
19
19
|
const labelSets = [];
|
|
20
20
|
let labelSize = 1.0;
|
|
@@ -310,5 +310,5 @@ const Pointset = function () {
|
|
|
310
310
|
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
Pointset.prototype = Object.create(
|
|
314
|
-
|
|
313
|
+
Pointset.prototype = Object.create(ZincObject.prototype);
|
|
314
|
+
export { Pointset };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { resolveURL } from '../utilities';
|
|
2
|
+
import { TextureArray } from '../texture/textureArray';
|
|
3
|
+
import { ZincObject } from './zincObject';
|
|
3
4
|
/**
|
|
4
5
|
* Provides a base class object which stores textures and rendering object.
|
|
5
6
|
*
|
|
@@ -8,7 +9,7 @@ const resolveURL = require('../utilities').resolveURL;
|
|
|
8
9
|
* @return {TexturePrimitive}
|
|
9
10
|
*/
|
|
10
11
|
const TexturePrimitive = function (textureIn) {
|
|
11
|
-
|
|
12
|
+
ZincObject.call(this);
|
|
12
13
|
this.isTexturePrimitive = true;
|
|
13
14
|
this.texture = textureIn;
|
|
14
15
|
//List of textureArray object, which is used for
|
|
@@ -28,7 +29,7 @@ const TexturePrimitive = function (textureIn) {
|
|
|
28
29
|
this.load = (textureData, finishCallback, isInline) => {
|
|
29
30
|
if (textureData) {
|
|
30
31
|
if (textureData.images && textureData.images.source) {
|
|
31
|
-
const texture = new
|
|
32
|
+
const texture = new TextureArray();
|
|
32
33
|
const imgArray = [];
|
|
33
34
|
textureData.images.source.forEach(img => {
|
|
34
35
|
imgArray.push(resolveURL(img));
|
|
@@ -67,6 +68,6 @@ const TexturePrimitive = function (textureIn) {
|
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
TexturePrimitive.prototype = Object.create(
|
|
71
|
+
TexturePrimitive.prototype = Object.create(ZincObject.prototype);
|
|
71
72
|
TexturePrimitive.prototype.constructor = TexturePrimitive;
|
|
72
|
-
|
|
73
|
+
export { TexturePrimitive };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import * as shader from '../shaders/textureSlide.js';
|
|
3
|
+
import { TexturePrimitive } from './texturePrimitive';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Provides a class which create a texture stacks in a block
|
|
5
7
|
* with shaders allowing slices of texture to be displayed.
|
|
@@ -12,7 +14,7 @@ const shader = require("../shaders/textureSlide.js");
|
|
|
12
14
|
* @return {TextureSlides}
|
|
13
15
|
*/
|
|
14
16
|
const TextureSlides = function (textureIn) {
|
|
15
|
-
|
|
17
|
+
TexturePrimitive.call(this, textureIn);
|
|
16
18
|
this.isTextureSlides = true;
|
|
17
19
|
const textureSettings = [];
|
|
18
20
|
const idTextureMap = {};
|
|
@@ -238,7 +240,7 @@ const TextureSlides = function (textureIn) {
|
|
|
238
240
|
if (slide.material)
|
|
239
241
|
slide.material.dispose();
|
|
240
242
|
});
|
|
241
|
-
|
|
243
|
+
TexturePrimitive.prototype.dispose.call(this);
|
|
242
244
|
this.boundingBoxUpdateRequired = true;
|
|
243
245
|
}
|
|
244
246
|
|
|
@@ -491,6 +493,6 @@ const TextureSlides = function (textureIn) {
|
|
|
491
493
|
|
|
492
494
|
}
|
|
493
495
|
|
|
494
|
-
TextureSlides.prototype = Object.create(
|
|
496
|
+
TextureSlides.prototype = Object.create(TexturePrimitive.prototype);
|
|
495
497
|
TextureSlides.prototype.constructor = TextureSlides;
|
|
496
|
-
|
|
498
|
+
export { TextureSlides };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import * as shader from '../shaders/volumeRender.js';
|
|
3
|
+
import { TexturePrimitive } from './texturePrimitive.js';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Provides a class which create a texture stacks in a block
|
|
5
7
|
* with shaders allowing slices of texture to be displayed.
|
|
@@ -12,7 +14,7 @@ const shader = require("../shaders/volumeRender.js");
|
|
|
12
14
|
* @return {TextureSlides}
|
|
13
15
|
*/
|
|
14
16
|
const TextureSlides = function (textureIn) {
|
|
15
|
-
|
|
17
|
+
TexturePrimitive.call(this, textureIn);
|
|
16
18
|
this.isTextureVolume = true;
|
|
17
19
|
const textureSettings = [];
|
|
18
20
|
this.morph = new THREE.Group();
|
|
@@ -186,7 +188,7 @@ const TextureSlides = function (textureIn) {
|
|
|
186
188
|
if (slide.material)
|
|
187
189
|
slide.material.dispose();
|
|
188
190
|
});
|
|
189
|
-
|
|
191
|
+
TexturePrimitive.prototype.dispose.call(this);
|
|
190
192
|
this.boundingBoxUpdateRequired = true;
|
|
191
193
|
}
|
|
192
194
|
|
|
@@ -317,6 +319,6 @@ const TextureSlides = function (textureIn) {
|
|
|
317
319
|
}
|
|
318
320
|
}
|
|
319
321
|
|
|
320
|
-
TextureSlides.prototype = Object.create(
|
|
322
|
+
TextureSlides.prototype = Object.create(TexturePrimitive.prototype);
|
|
321
323
|
TextureSlides.prototype.constructor = TextureSlides;
|
|
322
|
-
|
|
324
|
+
export { TextureSlides };
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { mergeGeometries } from '../utilities';
|
|
3
|
+
import { ZincObject } from './zincObject';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Provides an object which stores lines.
|
|
6
7
|
* This is created when a valid json file containing lines is read into a {@link Zinc.Scene}
|
|
7
8
|
* object.
|
|
8
|
-
*
|
|
9
|
+
*
|
|
9
10
|
* @class
|
|
10
11
|
* @author Alan Wu
|
|
11
12
|
* @return {TubeLines}
|
|
12
13
|
*/
|
|
13
14
|
const TubeLines = function () {
|
|
14
|
-
|
|
15
|
+
ZincObject.call(this);
|
|
15
16
|
this.isTubeLines = true;
|
|
16
17
|
let dataIn = {};
|
|
17
18
|
let geometryConfig = { radius: 1, radialSegments: 8, smooth: false };
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Create the line segements using geometry and material.
|
|
21
|
-
*
|
|
22
|
+
*
|
|
22
23
|
* @param {THREE.Geomtry} geometryIn - Geometry of lines to be rendered.
|
|
23
24
|
* @param {THREE.Material} materialIn - Material to be set for the lines.
|
|
24
25
|
* @param {Object} options - Provide various options
|
|
@@ -39,7 +40,7 @@ const TubeLines = function () {
|
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
42
|
* Set the width for the lines.
|
|
42
|
-
*
|
|
43
|
+
*
|
|
43
44
|
* @param {Number} width - Width of the lines.
|
|
44
45
|
*/
|
|
45
46
|
this.setWidth = width => {
|
|
@@ -52,8 +53,8 @@ const TubeLines = function () {
|
|
|
52
53
|
/**
|
|
53
54
|
* Set the opacity of this Geometry. This function will also set the transparent
|
|
54
55
|
* according to the provided alpha value.
|
|
55
|
-
*
|
|
56
|
-
* @param {Number} alpah - Alpha value to set for this geometry,
|
|
56
|
+
*
|
|
57
|
+
* @param {Number} alpah - Alpha value to set for this geometry,
|
|
57
58
|
* can be any value between from 0 to 1.0.
|
|
58
59
|
*/
|
|
59
60
|
this.setAlpha = function (alpha) {
|
|
@@ -65,7 +66,7 @@ const TubeLines = function () {
|
|
|
65
66
|
|
|
66
67
|
/**
|
|
67
68
|
* Set the wireframe mode for this geometry.
|
|
68
|
-
* @param {Boolean} wireframe
|
|
69
|
+
* @param {Boolean} wireframe
|
|
69
70
|
*/
|
|
70
71
|
this.setWireframe = (wireframe) => {
|
|
71
72
|
let mesh = this.getMorph();
|
|
@@ -74,7 +75,7 @@ const TubeLines = function () {
|
|
|
74
75
|
|
|
75
76
|
/**
|
|
76
77
|
* Update tube radius/radialSegments value
|
|
77
|
-
*
|
|
78
|
+
*
|
|
78
79
|
* @param {Float} radius The radius of the tube.
|
|
79
80
|
* @param {Integer} radialSegments The number of segments that make up the cross-section.
|
|
80
81
|
*/
|
|
@@ -91,7 +92,7 @@ const TubeLines = function () {
|
|
|
91
92
|
|
|
92
93
|
/**
|
|
93
94
|
* Get merged geometry from list of geometry vertices
|
|
94
|
-
*
|
|
95
|
+
*
|
|
95
96
|
* @param {Array} vertices - An array of THREE.Vector3 vertices.
|
|
96
97
|
* @returns {Object}
|
|
97
98
|
*/
|
|
@@ -115,5 +116,5 @@ const TubeLines = function () {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
TubeLines.prototype = Object.create(
|
|
119
|
-
|
|
119
|
+
TubeLines.prototype = Object.create(ZincObject.prototype);
|
|
120
|
+
export { TubeLines };
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import {
|
|
3
|
+
createBufferGeometry,
|
|
4
|
+
getBoundingBox,
|
|
5
|
+
removeVertexAtIndex,
|
|
6
|
+
resolveURL
|
|
7
|
+
} from '../utilities';
|
|
8
|
+
import { LOD } from './lod';
|
|
9
|
+
import { Marker } from './marker';
|
|
5
10
|
|
|
6
11
|
let uniqueiId = 0;
|
|
7
12
|
|
|
@@ -23,7 +28,7 @@ const ZincObject = function() {
|
|
|
23
28
|
// THREE.Mesh
|
|
24
29
|
this.morph = undefined;
|
|
25
30
|
this.group = new THREE.Group();
|
|
26
|
-
this._lod = new
|
|
31
|
+
this._lod = new LOD(this);
|
|
27
32
|
/**
|
|
28
33
|
* Groupname given to this geometry.
|
|
29
34
|
*/
|
|
@@ -533,8 +538,7 @@ ZincObject.prototype.getBoundingBox = function() {
|
|
|
533
538
|
let morph = this._lod.getCurrentMorph();
|
|
534
539
|
if (morph && morph.visible) {
|
|
535
540
|
if (this.boundingBoxUpdateRequired) {
|
|
536
|
-
|
|
537
|
-
this._b1, this._v1, this._v2);
|
|
541
|
+
getBoundingBox(morph, this.cachedBoundingBox, this._b1, this._v1, this._v2);
|
|
538
542
|
this.cachedBoundingBox.getCenter(this.center);
|
|
539
543
|
this.radius = this.center.distanceTo(this.cachedBoundingBox.max);
|
|
540
544
|
this.boundingBoxUpdateRequired = false;
|
|
@@ -584,7 +588,7 @@ ZincObject.prototype.updateMarker = function(playAnimation, options) {
|
|
|
584
588
|
let ndcToBeUpdated = options.ndcToBeUpdated;
|
|
585
589
|
if (this.groupName) {
|
|
586
590
|
if (!this.marker) {
|
|
587
|
-
this.marker = new
|
|
591
|
+
this.marker = new Marker(this);
|
|
588
592
|
this.markerUpdateRequired = true;
|
|
589
593
|
}
|
|
590
594
|
if (this.markerUpdateRequired) {
|
|
@@ -807,5 +811,5 @@ ZincObject.prototype.setScaleAll = function(scale) {
|
|
|
807
811
|
}
|
|
808
812
|
}
|
|
809
813
|
|
|
814
|
+
export { ZincObject };
|
|
810
815
|
|
|
811
|
-
exports.ZincObject = ZincObject;
|