zincjs 3.0.0 → 3.0.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/README.md +27 -22
- package/build/zinc.js +2 -2
- package/build/zinc.js.map +1 -1
- package/package.json +4 -1
- package/src/controls.js +1332 -1241
- package/src/geometryCSG.js +111 -115
- package/src/glyphsetCSG.js +51 -55
- package/src/loaders/GLTFToZincJSLoader.js +31 -33
- package/src/loaders/JSONLoader.js +339 -449
- package/src/loaders/OBJLoader.js +654 -851
- package/src/loaders/STLLoader.js +271 -329
- package/src/loaders/niftiReader.js +90 -59
- package/src/loaders/primitivesLoader.js +55 -52
- package/src/minimap.js +63 -43
- package/src/primitives/geometry.js +40 -44
- package/src/primitives/glyph.js +16 -19
- package/src/primitives/glyphset.js +229 -185
- package/src/primitives/label.js +29 -31
- package/src/primitives/lines.js +20 -20
- package/src/primitives/lines2.js +33 -39
- package/src/primitives/lod.js +43 -43
- package/src/primitives/marker.js +31 -32
- package/src/primitives/markerCluster.js +32 -35
- package/src/primitives/pointset.js +86 -83
- package/src/primitives/texturePrimitive.js +9 -10
- package/src/primitives/textureSlides.js +84 -97
- package/src/primitives/textureVolume.js +46 -49
- package/src/primitives/tubeLines.js +108 -108
- package/src/primitives/zincObject.js +176 -184
- package/src/region.js +145 -155
- package/src/renderRequests.js +3 -3
- package/src/renderer.js +635 -620
- package/src/scene.js +479 -419
- package/src/sceneExporter.js +22 -17
- package/src/sceneLoader.js +542 -296
- package/src/shaders/rgbVolumeRender.js +11 -18
- package/src/shaders/textureArray.js +5 -12
- package/src/shaders/textureSlide.js +10 -17
- package/src/shaders/volumeRender.js +11 -18
- package/src/shaders/volumeRender_old.js +11 -18
- package/src/shaders/volumeTexture.js +7 -14
- package/src/textSprite.js +23 -19
- package/src/texture/texture.js +14 -15
- package/src/texture/textureArray.js +14 -16
- package/src/three/InstancedPoints.js +2 -9
- package/src/three/Loader.js +334 -315
- package/src/three/line/Line.js +165 -215
- package/src/three/line/LineSegments.js +40 -55
- package/src/three/line/LineSegments2.js +322 -366
- package/src/three/line/LineSegmentsGeometry.js +239 -280
- package/src/three-js-csg.js +260 -252
- package/src/tsl/glyphRenderMaterial.js +12 -3
- package/src/tsl/glyphTransform.js +51 -29
- package/src/tsl/textureSlides.js +23 -24
- package/src/utilities.js +309 -371
- package/src/videoHandler.js +76 -83
- package/src/workers/geometryCSG.worker.js +33 -36
- package/src/workers/geometryCSGInternal.js +39 -44
- package/src/zinc.js +4 -7
- package/vite.config.js +7 -7
|
@@ -42,9 +42,9 @@ const TextureSlides = function (textureIn) {
|
|
|
42
42
|
*
|
|
43
43
|
* @param {SLIDE_SETTINGS} slideSettings - An array to each slide settings.
|
|
44
44
|
*/
|
|
45
|
-
this.createSlides = slideSettings => {
|
|
46
|
-
slideSettings.forEach(slide => this.createSlide(slide));
|
|
47
|
-
}
|
|
45
|
+
this.createSlides = (slideSettings) => {
|
|
46
|
+
slideSettings.forEach((slide) => this.createSlide(slide));
|
|
47
|
+
};
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Set the value of the uniforms for a specific mesh in this
|
|
@@ -63,20 +63,20 @@ const TextureSlides = function (textureIn) {
|
|
|
63
63
|
mesh.position.y = 0;
|
|
64
64
|
mesh.position.z = 0;
|
|
65
65
|
switch (settings.direction) {
|
|
66
|
-
case
|
|
66
|
+
case 'x':
|
|
67
67
|
const rotation = -Math.PI / 2;
|
|
68
68
|
mesh.rotation.y = rotation;
|
|
69
69
|
uniforms.direction.value = 1;
|
|
70
70
|
uniforms.slide.value.set(settings.value, 0, 0);
|
|
71
71
|
mesh.position.x = settings.value;
|
|
72
72
|
break;
|
|
73
|
-
case
|
|
73
|
+
case 'y':
|
|
74
74
|
mesh.rotation.x = Math.PI / 2;
|
|
75
75
|
uniforms.direction.value = 2;
|
|
76
76
|
uniforms.slide.value.set(0, settings.value, 0);
|
|
77
77
|
mesh.position.y = settings.value;
|
|
78
78
|
break;
|
|
79
|
-
case
|
|
79
|
+
case 'z':
|
|
80
80
|
uniforms.direction.value = 3;
|
|
81
81
|
uniforms.slide.value.set(0, 0, settings.value);
|
|
82
82
|
mesh.position.z = settings.value;
|
|
@@ -86,7 +86,7 @@ const TextureSlides = function (textureIn) {
|
|
|
86
86
|
}
|
|
87
87
|
material.needsUpdate = true;
|
|
88
88
|
this.boundingBoxUpdateRequired = true;
|
|
89
|
-
}
|
|
89
|
+
};
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Modify the mesh based on a setting
|
|
@@ -94,12 +94,10 @@ const TextureSlides = function (textureIn) {
|
|
|
94
94
|
* @param {SLIDE_SETTINGS} settings - s.
|
|
95
95
|
*/
|
|
96
96
|
this.modifySlideSettings = (settings) => {
|
|
97
|
-
if (settings && settings.id &&
|
|
98
|
-
settings.id in idTextureMap &&
|
|
99
|
-
idTextureMap[settings.id]) {
|
|
97
|
+
if (settings && settings.id && settings.id in idTextureMap && idTextureMap[settings.id]) {
|
|
100
98
|
setUniformSlideSettingsOfMesh(idTextureMap[settings.id], settings);
|
|
101
99
|
}
|
|
102
|
-
}
|
|
100
|
+
};
|
|
103
101
|
|
|
104
102
|
/**
|
|
105
103
|
* Create a slide required for visualisation based on the slide settings.
|
|
@@ -109,7 +107,7 @@ const TextureSlides = function (textureIn) {
|
|
|
109
107
|
* @return {SLIDE_SETTINGS} - Returned settings, it includes the newly
|
|
110
108
|
* created mesh's id.
|
|
111
109
|
*/
|
|
112
|
-
this.createSlide = settings => {
|
|
110
|
+
this.createSlide = (settings) => {
|
|
113
111
|
if (this.texture && this.texture.isTextureArray && this.texture.isReady()) {
|
|
114
112
|
if (settings && settings.direction && settings.value !== undefined) {
|
|
115
113
|
const geometry = new THREE.PlaneGeometry(1, 1);
|
|
@@ -126,7 +124,7 @@ const TextureSlides = function (textureIn) {
|
|
|
126
124
|
uniforms: uniforms,
|
|
127
125
|
glslVersion: shader.glslVersion,
|
|
128
126
|
side: THREE.DoubleSide,
|
|
129
|
-
transparent: false
|
|
127
|
+
transparent: false,
|
|
130
128
|
};
|
|
131
129
|
const material = this.texture.getMaterial(options);
|
|
132
130
|
material.needsUpdate = true;
|
|
@@ -146,7 +144,7 @@ const TextureSlides = function (textureIn) {
|
|
|
146
144
|
return slideSettings;
|
|
147
145
|
}
|
|
148
146
|
}
|
|
149
|
-
}
|
|
147
|
+
};
|
|
150
148
|
|
|
151
149
|
/**
|
|
152
150
|
* Return a copy of texture settings used by this object.
|
|
@@ -155,7 +153,7 @@ const TextureSlides = function (textureIn) {
|
|
|
155
153
|
*/
|
|
156
154
|
this.getTextureSettings = () => {
|
|
157
155
|
return [...textureSettings];
|
|
158
|
-
}
|
|
156
|
+
};
|
|
159
157
|
|
|
160
158
|
/**
|
|
161
159
|
* Return a copy of texture settings with corresponding id used by this object.
|
|
@@ -165,10 +163,10 @@ const TextureSlides = function (textureIn) {
|
|
|
165
163
|
this.getTextureSettingsWithId = (id) => {
|
|
166
164
|
for (let i = 0; i < textureSettings.length; i++) {
|
|
167
165
|
if (id === textureSettings[i].id) {
|
|
168
|
-
return {...textureSettings[i]};
|
|
166
|
+
return { ...textureSettings[i] };
|
|
169
167
|
}
|
|
170
168
|
}
|
|
171
|
-
}
|
|
169
|
+
};
|
|
172
170
|
|
|
173
171
|
/**
|
|
174
172
|
* Get the array of slides, return them in an array
|
|
@@ -178,21 +176,19 @@ const TextureSlides = function (textureIn) {
|
|
|
178
176
|
this.getSlides = () => {
|
|
179
177
|
if (this.morph) return [...this.morph.children];
|
|
180
178
|
return [];
|
|
181
|
-
}
|
|
179
|
+
};
|
|
182
180
|
|
|
183
181
|
/**
|
|
184
182
|
* Clean up all internal objects.
|
|
185
183
|
*/
|
|
186
184
|
this.dispose = () => {
|
|
187
|
-
this.morph.children.forEach(slide => {
|
|
188
|
-
if (slide.geometry)
|
|
189
|
-
|
|
190
|
-
if (slide.material)
|
|
191
|
-
slide.material.dispose();
|
|
185
|
+
this.morph.children.forEach((slide) => {
|
|
186
|
+
if (slide.geometry) slide.geometry.dispose();
|
|
187
|
+
if (slide.material) slide.material.dispose();
|
|
192
188
|
});
|
|
193
189
|
TexturePrimitive.prototype.dispose.call(this);
|
|
194
190
|
this.boundingBoxUpdateRequired = true;
|
|
195
|
-
}
|
|
191
|
+
};
|
|
196
192
|
|
|
197
193
|
//Expand the boundingbox with slide settings
|
|
198
194
|
const expandBoxWithSettings = (box, settings, vector) => {
|
|
@@ -223,7 +219,7 @@ const TextureSlides = function (textureIn) {
|
|
|
223
219
|
break;
|
|
224
220
|
}
|
|
225
221
|
}
|
|
226
|
-
}
|
|
222
|
+
};
|
|
227
223
|
|
|
228
224
|
/**
|
|
229
225
|
* Get the bounding box of this slides.
|
|
@@ -233,20 +229,18 @@ const TextureSlides = function (textureIn) {
|
|
|
233
229
|
* @return {THREE.Box3}.
|
|
234
230
|
*/
|
|
235
231
|
this.getBoundingBox = () => {
|
|
236
|
-
if (this.morph && this.morph.children && this.morph.visible &&
|
|
237
|
-
this.boundingBoxUpdateRequired) {
|
|
232
|
+
if (this.morph && this.morph.children && this.morph.visible && this.boundingBoxUpdateRequired) {
|
|
238
233
|
this.cachedBoundingBox.makeEmpty();
|
|
239
234
|
const vector = new THREE.Vector3(0, 0, 0);
|
|
240
|
-
this.morph.children.forEach(slide => {
|
|
241
|
-
expandBoxWithSettings(this.cachedBoundingBox, slide.material.uniforms,
|
|
242
|
-
vector);
|
|
235
|
+
this.morph.children.forEach((slide) => {
|
|
236
|
+
expandBoxWithSettings(this.cachedBoundingBox, slide.material.uniforms, vector);
|
|
243
237
|
});
|
|
244
|
-
this.morph.updateMatrixWorld
|
|
238
|
+
this.morph.updateMatrixWorld(true, true);
|
|
245
239
|
this.cachedBoundingBox.applyMatrix4(this.morph.matrixWorld);
|
|
246
240
|
this.boundingBoxUpdateRequired = false;
|
|
247
241
|
}
|
|
248
242
|
return this.cachedBoundingBox;
|
|
249
|
-
}
|
|
243
|
+
};
|
|
250
244
|
|
|
251
245
|
this.applyTransformation = (rotation, position, scale) => {
|
|
252
246
|
const matrix = new THREE.Matrix4();
|
|
@@ -266,60 +260,63 @@ const TextureSlides = function (textureIn) {
|
|
|
266
260
|
0,
|
|
267
261
|
0,
|
|
268
262
|
0,
|
|
269
|
-
0
|
|
263
|
+
0,
|
|
270
264
|
);
|
|
271
265
|
const quaternion = new THREE.Quaternion().setFromRotationMatrix(matrix);
|
|
272
266
|
this.morph.position.set(...position);
|
|
273
|
-
this.morph.quaternion.copy(
|
|
267
|
+
this.morph.quaternion.copy(quaternion);
|
|
274
268
|
this.morph.scale.set(...scale);
|
|
275
269
|
this.morph.updateMatrix();
|
|
276
270
|
this.boundingBoxUpdateRequired = true;
|
|
277
|
-
}
|
|
271
|
+
};
|
|
278
272
|
|
|
279
273
|
this.setRenderOrder = (order) => {
|
|
280
274
|
//multiilayers
|
|
281
275
|
this.morph.renderOrder = order;
|
|
282
|
-
}
|
|
276
|
+
};
|
|
283
277
|
|
|
284
278
|
this.initialise = (textureData, finishCallback) => {
|
|
285
279
|
if (textureData) {
|
|
286
280
|
const locations = textureData.locations;
|
|
287
281
|
if (locations && locations.length > 0) {
|
|
288
|
-
this.applyTransformation(
|
|
289
|
-
locations[0].
|
|
290
|
-
|
|
282
|
+
this.applyTransformation(
|
|
283
|
+
locations[0].orientation,
|
|
284
|
+
locations[0].position,
|
|
285
|
+
locations[0].scale,
|
|
286
|
+
);
|
|
287
|
+
if ('flipY' in locations[0]) {
|
|
291
288
|
flipY = locations[0].flipY;
|
|
292
289
|
}
|
|
293
|
-
if (
|
|
290
|
+
if ('flipZ' in locations[0]) {
|
|
294
291
|
flipZ = locations[0].flipZ;
|
|
295
292
|
}
|
|
296
293
|
}
|
|
297
294
|
this.createSlides(textureData.settings.slides);
|
|
298
|
-
if (finishCallback != undefined &&
|
|
295
|
+
if (finishCallback != undefined && typeof finishCallback == 'function') {
|
|
299
296
|
finishCallback(this);
|
|
300
297
|
}
|
|
301
298
|
}
|
|
302
|
-
}
|
|
299
|
+
};
|
|
303
300
|
|
|
304
301
|
this.showEdges = (color) => {
|
|
305
302
|
if (!edgesLine) {
|
|
306
|
-
const geometry = new THREE.BoxGeometry(
|
|
303
|
+
const geometry = new THREE.BoxGeometry(1, 1, 1);
|
|
307
304
|
geometry.translate(0.5, 0.5, 0.5);
|
|
308
|
-
const edges = new THREE.EdgesGeometry(
|
|
309
|
-
edgesLine = new THREE.LineSegments(edges, new THREE.LineBasicMaterial(
|
|
310
|
-
this.group.add(
|
|
305
|
+
const edges = new THREE.EdgesGeometry(geometry);
|
|
306
|
+
edgesLine = new THREE.LineSegments(edges, new THREE.LineBasicMaterial({ color }));
|
|
307
|
+
this.group.add(edgesLine);
|
|
311
308
|
} else {
|
|
312
309
|
edgesLine.material.color = color;
|
|
313
310
|
}
|
|
314
311
|
edgesLine.visible = true;
|
|
315
|
-
}
|
|
312
|
+
};
|
|
316
313
|
|
|
317
314
|
this.hideEdges = () => {
|
|
318
315
|
if (edgesLine) {
|
|
319
316
|
edgesLine.visible = false;
|
|
320
317
|
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
318
|
+
};
|
|
319
|
+
};
|
|
323
320
|
|
|
324
321
|
TextureSlides.prototype = Object.create(TexturePrimitive.prototype);
|
|
325
322
|
TextureSlides.prototype.constructor = TextureSlides;
|
|
@@ -12,130 +12,130 @@ import { ZincObject } from './zincObject';
|
|
|
12
12
|
* @return {TubeLines}
|
|
13
13
|
*/
|
|
14
14
|
const TubeLines = function () {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
ZincObject.call(this);
|
|
16
|
+
this.isTubeLines = true;
|
|
17
|
+
let dataIn = {};
|
|
18
|
+
let geometryConfig = { radius: 1, radialSegments: 8, smooth: false };
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
20
|
+
/**
|
|
21
|
+
* Create the line segements using geometry and material.
|
|
22
|
+
*
|
|
23
|
+
* @param {THREE.Geomtry} geometryIn - Geometry of lines to be rendered.
|
|
24
|
+
* @param {THREE.Material} materialIn - Material to be set for the lines.
|
|
25
|
+
* @param {Object} options - Provide various options
|
|
26
|
+
* @param {Boolean} options.localTimeEnabled - A flag to indicate either the lines is
|
|
27
|
+
* time dependent.
|
|
28
|
+
* @param {Boolean} options.localMorphColour - A flag to indicate either the colour is
|
|
29
|
+
* time dependent.
|
|
30
|
+
*/
|
|
31
|
+
this.createLineSegment = (geometryIn, materialIn, options) => {
|
|
32
|
+
if (geometryIn && materialIn) {
|
|
33
|
+
dataIn = { geometryIn, materialIn, options };
|
|
34
|
+
const geometry = getTubeLinesGeometry(extractVertices(geometryIn));
|
|
35
|
+
const material = new THREE.MeshStandardMaterial({ color: materialIn.color });
|
|
36
|
+
const mesh = new THREE.Mesh(geometry, material);
|
|
37
|
+
this.setMesh(mesh, options.localTimeEnabled, options.localMorphColour);
|
|
39
38
|
}
|
|
39
|
+
};
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
/**
|
|
42
42
|
* Set the width for the lines.
|
|
43
43
|
*
|
|
44
44
|
* @param {Number} width - Width of the lines.
|
|
45
45
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Set the opacity of this Geometry. This function will also set the transparent
|
|
56
|
-
* according to the provided alpha value.
|
|
57
|
-
*
|
|
58
|
-
* @param {Number} alpah - Alpha value to set for this geometry,
|
|
59
|
-
* can be any value between from 0 to 1.0.
|
|
60
|
-
*/
|
|
61
|
-
this.setAlpha = function (alpha) {
|
|
62
|
-
this.requestRender();
|
|
63
|
-
let mesh = this.getMorph();
|
|
64
|
-
mesh.material.opacity = alpha;
|
|
65
|
-
mesh.material.transparent = alpha < 1.0;
|
|
66
|
-
mesh.material.depthWrite = alpha > 0.5;
|
|
46
|
+
this.setWidth = (width) => {
|
|
47
|
+
this.requestRender();
|
|
48
|
+
if (this.morph && this.morph.material) {
|
|
49
|
+
this.morph.material.linewidth = width;
|
|
50
|
+
this.morph.material.needsUpdate = true;
|
|
67
51
|
}
|
|
52
|
+
};
|
|
68
53
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Set the opacity of this Geometry. This function will also set the transparent
|
|
56
|
+
* according to the provided alpha value.
|
|
57
|
+
*
|
|
58
|
+
* @param {Number} alpah - Alpha value to set for this geometry,
|
|
59
|
+
* can be any value between from 0 to 1.0.
|
|
60
|
+
*/
|
|
61
|
+
this.setAlpha = function (alpha) {
|
|
62
|
+
this.requestRender();
|
|
63
|
+
let mesh = this.getMorph();
|
|
64
|
+
mesh.material.opacity = alpha;
|
|
65
|
+
mesh.material.transparent = alpha < 1.0;
|
|
66
|
+
mesh.material.depthWrite = alpha > 0.5;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Set the wireframe mode for this geometry.
|
|
71
|
+
* @param {Boolean} wireframe
|
|
72
|
+
*/
|
|
73
|
+
this.setWireframe = (wireframe) => {
|
|
74
|
+
this.requestRender();
|
|
75
|
+
let mesh = this.getMorph();
|
|
76
|
+
mesh.material.wireframe = wireframe;
|
|
77
|
+
};
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Update tube radius/radialSegments value
|
|
81
|
+
*
|
|
82
|
+
* @param {Float} radius The radius of the tube.
|
|
83
|
+
* @param {Integer} radialSegments The number of segments that make up the cross-section.
|
|
84
|
+
*/
|
|
85
|
+
this.setTubeLines = (radius, radialSegments) => {
|
|
86
|
+
this.requestRender();
|
|
87
|
+
if (radius && radialSegments) {
|
|
88
|
+
const { geometryIn } = dataIn;
|
|
89
|
+
let mesh = this.getMorph();
|
|
90
|
+
mesh.geometry.dispose();
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
92
|
+
geometryConfig = Object.assign(geometryConfig, { radius, radialSegments });
|
|
93
|
+
mesh.geometry = getTubeLinesGeometry(extractVertices(geometryIn));
|
|
95
94
|
}
|
|
95
|
+
};
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
return vertices;
|
|
97
|
+
/**
|
|
98
|
+
* Read the position attribute of a BufferGeometry into an array of
|
|
99
|
+
* THREE.Vector3, since TubeGeometry/CatmullRomCurve3/LineCurve3 need
|
|
100
|
+
* actual Vector3 instances to work with, not a flat typed array.
|
|
101
|
+
*
|
|
102
|
+
* @param {THREE.BufferGeometry} geometry
|
|
103
|
+
* @returns {Array}
|
|
104
|
+
*/
|
|
105
|
+
const extractVertices = (geometry) => {
|
|
106
|
+
const position = geometry.getAttribute('position');
|
|
107
|
+
const vertices = [];
|
|
108
|
+
for (let i = 0; i < position.count; i++) {
|
|
109
|
+
vertices.push(new THREE.Vector3().fromBufferAttribute(position, i));
|
|
112
110
|
}
|
|
111
|
+
return vertices;
|
|
112
|
+
};
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
return finalGeometry;
|
|
114
|
+
/**
|
|
115
|
+
* Get merged geometry from list of geometry vertices
|
|
116
|
+
*
|
|
117
|
+
* @param {Array} vertices - An array of THREE.Vector3 vertices.
|
|
118
|
+
* @returns {Object}
|
|
119
|
+
*/
|
|
120
|
+
const getTubeLinesGeometry = (vertices) => {
|
|
121
|
+
const { radius, radialSegments, smooth } = geometryConfig;
|
|
122
|
+
let finalGeometry;
|
|
123
|
+
if (smooth) {
|
|
124
|
+
const curve = new THREE.CatmullRomCurve3(vertices);
|
|
125
|
+
finalGeometry = new THREE.TubeGeometry(curve, vertices.length, radius, radialSegments, false);
|
|
126
|
+
} else {
|
|
127
|
+
const geometries = [];
|
|
128
|
+
for (let i = 0; i + 1 < vertices.length; i = i + 2) {
|
|
129
|
+
const curve = new THREE.LineCurve3(vertices[i], vertices[i + 1]);
|
|
130
|
+
const tubeGeometry = new THREE.TubeGeometry(curve, 1, radius, radialSegments, false);
|
|
131
|
+
geometries.push(tubeGeometry);
|
|
132
|
+
}
|
|
133
|
+
finalGeometry = mergeGeometries(geometries, true);
|
|
134
|
+
geometries.forEach((g) => g.dispose());
|
|
137
135
|
}
|
|
138
|
-
|
|
136
|
+
return finalGeometry;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
139
|
|
|
140
140
|
TubeLines.prototype = Object.create(ZincObject.prototype);
|
|
141
141
|
export { TubeLines };
|