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
package/src/three/line/Line.js
CHANGED
|
@@ -2,14 +2,13 @@ import {
|
|
|
2
2
|
BufferGeometry,
|
|
3
3
|
Float32BufferAttribute,
|
|
4
4
|
LineBasicMaterial,
|
|
5
|
-
|
|
5
|
+
Matrix4,
|
|
6
6
|
Object3D,
|
|
7
7
|
Ray,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
Sphere,
|
|
9
|
+
Vector3,
|
|
10
10
|
} from 'three/webgpu';
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
const _start = /*@__PURE__*/ new Vector3();
|
|
14
13
|
const _end = /*@__PURE__*/ new Vector3();
|
|
15
14
|
const _inverseMatrix = /*@__PURE__*/ new Matrix4();
|
|
@@ -21,273 +20,224 @@ const _tempA = /*@__PURE__*/ new Vector3();
|
|
|
21
20
|
const _tempB = /*@__PURE__*/ new Vector3();
|
|
22
21
|
|
|
23
22
|
class Line extends Object3D {
|
|
23
|
+
constructor(geometry = new BufferGeometry(), material = new LineBasicMaterial()) {
|
|
24
|
+
super();
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
super();
|
|
28
|
-
|
|
29
|
-
this.type = 'Line';
|
|
30
|
-
|
|
31
|
-
this.geometry = geometry;
|
|
32
|
-
this.material = material;
|
|
33
|
-
|
|
34
|
-
this.updateMorphTargets();
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
copy( source ) {
|
|
39
|
-
|
|
40
|
-
super.copy( source );
|
|
41
|
-
|
|
42
|
-
this.material = source.material;
|
|
43
|
-
this.geometry = source.geometry;
|
|
44
|
-
|
|
45
|
-
return this;
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
computeLineDistances() {
|
|
50
|
-
|
|
51
|
-
const geometry = this.geometry;
|
|
52
|
-
|
|
53
|
-
if ( geometry.isBufferGeometry ) {
|
|
54
|
-
|
|
55
|
-
// we assume non-indexed geometry
|
|
56
|
-
|
|
57
|
-
if ( geometry.index === null ) {
|
|
58
|
-
|
|
59
|
-
const positionAttribute = geometry.attributes.position;
|
|
60
|
-
const lineDistances = [ 0 ];
|
|
61
|
-
|
|
62
|
-
for ( let i = 1, l = positionAttribute.count; i < l; i ++ ) {
|
|
26
|
+
this.type = 'Line';
|
|
63
27
|
|
|
64
|
-
|
|
65
|
-
|
|
28
|
+
this.geometry = geometry;
|
|
29
|
+
this.material = material;
|
|
66
30
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
geometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );
|
|
73
|
-
|
|
74
|
-
} else {
|
|
75
|
-
|
|
76
|
-
console.warn( 'THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
} else if ( geometry.isGeometry ) {
|
|
31
|
+
this.updateMorphTargets();
|
|
32
|
+
}
|
|
81
33
|
|
|
82
|
-
|
|
34
|
+
copy(source) {
|
|
35
|
+
super.copy(source);
|
|
83
36
|
|
|
84
|
-
|
|
37
|
+
this.material = source.material;
|
|
38
|
+
this.geometry = source.geometry;
|
|
85
39
|
|
|
86
|
-
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
87
42
|
|
|
88
|
-
|
|
43
|
+
computeLineDistances() {
|
|
44
|
+
const geometry = this.geometry;
|
|
45
|
+
|
|
46
|
+
if (geometry.isBufferGeometry) {
|
|
47
|
+
// we assume non-indexed geometry
|
|
48
|
+
|
|
49
|
+
if (geometry.index === null) {
|
|
50
|
+
const positionAttribute = geometry.attributes.position;
|
|
51
|
+
const lineDistances = [0];
|
|
52
|
+
|
|
53
|
+
for (let i = 1, l = positionAttribute.count; i < l; i++) {
|
|
54
|
+
_start.fromBufferAttribute(positionAttribute, i - 1);
|
|
55
|
+
_end.fromBufferAttribute(positionAttribute, i);
|
|
56
|
+
|
|
57
|
+
lineDistances[i] = lineDistances[i - 1];
|
|
58
|
+
lineDistances[i] += _start.distanceTo(_end);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
geometry.setAttribute('lineDistance', new Float32BufferAttribute(lineDistances, 1));
|
|
62
|
+
} else {
|
|
63
|
+
console.warn(
|
|
64
|
+
'THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.',
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
} else if (geometry.isGeometry) {
|
|
68
|
+
console.error(
|
|
69
|
+
'THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.',
|
|
70
|
+
);
|
|
71
|
+
}
|
|
89
72
|
|
|
90
|
-
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
91
75
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
76
|
+
raycast(raycaster, intersects) {
|
|
77
|
+
const geometry = this.geometry;
|
|
78
|
+
const matrixWorld = this.matrixWorld;
|
|
79
|
+
const threshold = raycaster.params.Line.threshold;
|
|
95
80
|
const drawRange = geometry.drawRange;
|
|
96
81
|
const morphPosition = geometry.morphAttributes.position;
|
|
97
82
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
|
101
|
-
|
|
102
|
-
_sphere.copy( geometry.boundingSphere );
|
|
103
|
-
_sphere.applyMatrix4( matrixWorld );
|
|
104
|
-
_sphere.radius += threshold;
|
|
105
|
-
|
|
106
|
-
if ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;
|
|
107
|
-
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
_inverseMatrix.copy( matrixWorld ).invert();
|
|
111
|
-
_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );
|
|
112
|
-
|
|
113
|
-
const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
|
|
114
|
-
const localThresholdSq = localThreshold * localThreshold;
|
|
115
|
-
|
|
116
|
-
const vStart = new Vector3();
|
|
117
|
-
const vEnd = new Vector3();
|
|
118
|
-
const interSegment = new Vector3();
|
|
119
|
-
const interRay = new Vector3();
|
|
120
|
-
const step = this.isLineSegments ? 2 : 1;
|
|
121
|
-
|
|
122
|
-
if ( geometry.isBufferGeometry ) {
|
|
83
|
+
// Checking boundingSphere distance to ray
|
|
123
84
|
|
|
124
|
-
|
|
125
|
-
const attributes = geometry.attributes;
|
|
126
|
-
const positionAttribute = attributes.position;
|
|
85
|
+
if (geometry.boundingSphere === null) geometry.computeBoundingSphere();
|
|
127
86
|
|
|
128
|
-
|
|
87
|
+
_sphere.copy(geometry.boundingSphere);
|
|
88
|
+
_sphere.applyMatrix4(matrixWorld);
|
|
89
|
+
_sphere.radius += threshold;
|
|
129
90
|
|
|
130
|
-
|
|
131
|
-
const end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
|
|
91
|
+
if (raycaster.ray.intersectsSphere(_sphere) === false) return;
|
|
132
92
|
|
|
133
|
-
|
|
93
|
+
//
|
|
134
94
|
|
|
135
|
-
|
|
136
|
-
|
|
95
|
+
_inverseMatrix.copy(matrixWorld).invert();
|
|
96
|
+
_ray.copy(raycaster.ray).applyMatrix4(_inverseMatrix);
|
|
137
97
|
|
|
138
|
-
|
|
98
|
+
const localThreshold = threshold / ((this.scale.x + this.scale.y + this.scale.z) / 3);
|
|
99
|
+
const localThresholdSq = localThreshold * localThreshold;
|
|
139
100
|
|
|
140
|
-
|
|
101
|
+
const vStart = new Vector3();
|
|
102
|
+
const vEnd = new Vector3();
|
|
103
|
+
const interSegment = new Vector3();
|
|
104
|
+
const interRay = new Vector3();
|
|
105
|
+
const step = this.isLineSegments ? 2 : 1;
|
|
141
106
|
|
|
142
|
-
|
|
107
|
+
if (geometry.isBufferGeometry) {
|
|
108
|
+
const index = geometry.index;
|
|
109
|
+
const attributes = geometry.attributes;
|
|
110
|
+
const positionAttribute = attributes.position;
|
|
143
111
|
|
|
144
|
-
|
|
112
|
+
if (index !== null) {
|
|
113
|
+
const start = Math.max(0, drawRange.start);
|
|
114
|
+
const end = Math.min(index.count, drawRange.start + drawRange.count);
|
|
145
115
|
|
|
146
|
-
|
|
116
|
+
for (let i = start, l = end - 1; i < l; i += step) {
|
|
117
|
+
const a = index.getX(i);
|
|
118
|
+
const b = index.getX(i + 1);
|
|
147
119
|
|
|
148
|
-
|
|
120
|
+
calculatePosition(vStart, vEnd, this, positionAttribute, morphPosition, a, b);
|
|
149
121
|
|
|
150
|
-
|
|
122
|
+
const distSq = _ray.distanceSqToSegment(vStart, vEnd, interRay, interSegment);
|
|
151
123
|
|
|
152
|
-
|
|
153
|
-
// What do we want? intersection point on the ray or on the segment??
|
|
154
|
-
// point: raycaster.ray.at( distance ),
|
|
155
|
-
point: interSegment.clone().applyMatrix4( this.matrixWorld ),
|
|
156
|
-
index: i,
|
|
157
|
-
face: null,
|
|
158
|
-
faceIndex: null,
|
|
159
|
-
object: this
|
|
124
|
+
if (distSq > localThresholdSq) continue;
|
|
160
125
|
|
|
161
|
-
|
|
126
|
+
interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation
|
|
162
127
|
|
|
163
|
-
|
|
128
|
+
const distance = raycaster.ray.origin.distanceTo(interRay);
|
|
164
129
|
|
|
165
|
-
|
|
130
|
+
if (distance < raycaster.near || distance > raycaster.far) continue;
|
|
166
131
|
|
|
167
|
-
|
|
168
|
-
|
|
132
|
+
intersects.push({
|
|
133
|
+
distance: distance,
|
|
134
|
+
// What do we want? intersection point on the ray or on the segment??
|
|
135
|
+
// point: raycaster.ray.at( distance ),
|
|
136
|
+
point: interSegment.clone().applyMatrix4(this.matrixWorld),
|
|
137
|
+
index: i,
|
|
138
|
+
face: null,
|
|
139
|
+
faceIndex: null,
|
|
140
|
+
object: this,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
const start = Math.max(0, drawRange.start);
|
|
145
|
+
const end = Math.min(positionAttribute.count, drawRange.start + drawRange.count);
|
|
169
146
|
|
|
170
|
-
|
|
147
|
+
for (let i = start, l = end - 1; i < l; i += step) {
|
|
148
|
+
calculatePosition(vStart, vEnd, this, positionAttribute, morphPosition, i, i + 1);
|
|
171
149
|
|
|
172
|
-
|
|
150
|
+
const distSq = _ray.distanceSqToSegment(vStart, vEnd, interRay, interSegment);
|
|
173
151
|
|
|
174
|
-
|
|
152
|
+
if (distSq > localThresholdSq) continue;
|
|
175
153
|
|
|
176
|
-
|
|
154
|
+
interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation
|
|
177
155
|
|
|
178
|
-
|
|
156
|
+
const distance = raycaster.ray.origin.distanceTo(interRay);
|
|
179
157
|
|
|
180
|
-
|
|
158
|
+
if (distance < raycaster.near || distance > raycaster.far) continue;
|
|
181
159
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
} else if ( geometry.isGeometry ) {
|
|
202
|
-
|
|
203
|
-
console.error( 'THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
updateMorphTargets() {
|
|
210
|
-
|
|
211
|
-
const geometry = this.geometry;
|
|
212
|
-
|
|
213
|
-
if ( geometry.isBufferGeometry ) {
|
|
214
|
-
|
|
215
|
-
const morphAttributes = geometry.morphAttributes;
|
|
216
|
-
const keys = Object.keys( morphAttributes );
|
|
217
|
-
|
|
218
|
-
if ( keys.length > 0 ) {
|
|
219
|
-
|
|
220
|
-
const morphAttribute = morphAttributes[ keys[ 0 ] ];
|
|
221
|
-
|
|
222
|
-
if ( morphAttribute !== undefined ) {
|
|
223
|
-
|
|
224
|
-
this.morphTargetInfluences = [];
|
|
225
|
-
this.morphTargetDictionary = {};
|
|
226
|
-
|
|
227
|
-
for ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {
|
|
228
|
-
|
|
229
|
-
const name = morphAttribute[ m ].name || String( m );
|
|
230
|
-
|
|
231
|
-
this.morphTargetInfluences.push( 0 );
|
|
232
|
-
this.morphTargetDictionary[ name ] = m;
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
} else {
|
|
160
|
+
intersects.push({
|
|
161
|
+
distance: distance,
|
|
162
|
+
// What do we want? intersection point on the ray or on the segment??
|
|
163
|
+
// point: raycaster.ray.at( distance ),
|
|
164
|
+
point: interSegment.clone().applyMatrix4(this.matrixWorld),
|
|
165
|
+
index: i,
|
|
166
|
+
face: null,
|
|
167
|
+
faceIndex: null,
|
|
168
|
+
object: this,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
} else if (geometry.isGeometry) {
|
|
173
|
+
console.error(
|
|
174
|
+
'THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.',
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
241
178
|
|
|
242
|
-
|
|
179
|
+
updateMorphTargets() {
|
|
180
|
+
const geometry = this.geometry;
|
|
243
181
|
|
|
244
|
-
|
|
182
|
+
if (geometry.isBufferGeometry) {
|
|
183
|
+
const morphAttributes = geometry.morphAttributes;
|
|
184
|
+
const keys = Object.keys(morphAttributes);
|
|
245
185
|
|
|
246
|
-
|
|
186
|
+
if (keys.length > 0) {
|
|
187
|
+
const morphAttribute = morphAttributes[keys[0]];
|
|
247
188
|
|
|
248
|
-
|
|
189
|
+
if (morphAttribute !== undefined) {
|
|
190
|
+
this.morphTargetInfluences = [];
|
|
191
|
+
this.morphTargetDictionary = {};
|
|
249
192
|
|
|
250
|
-
|
|
193
|
+
for (let m = 0, ml = morphAttribute.length; m < ml; m++) {
|
|
194
|
+
const name = morphAttribute[m].name || String(m);
|
|
251
195
|
|
|
252
|
-
|
|
196
|
+
this.morphTargetInfluences.push(0);
|
|
197
|
+
this.morphTargetDictionary[name] = m;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
const morphTargets = geometry.morphTargets;
|
|
253
203
|
|
|
204
|
+
if (morphTargets !== undefined && morphTargets.length > 0) {
|
|
205
|
+
console.error(
|
|
206
|
+
'THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.',
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
254
211
|
}
|
|
255
212
|
|
|
256
|
-
function calculatePosition(
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
vEnd.fromBufferAttribute( position, b );
|
|
213
|
+
function calculatePosition(vStart, vEnd, object, position, morphPosition, a, b) {
|
|
214
|
+
vStart.fromBufferAttribute(position, a);
|
|
215
|
+
vEnd.fromBufferAttribute(position, b);
|
|
260
216
|
|
|
261
217
|
var morphInfluences = object.morphTargetInfluences;
|
|
262
218
|
|
|
263
|
-
if (
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
_morphB.set( 0, 0, 0 );
|
|
267
|
-
|
|
268
|
-
for ( var i = 0, il = morphPosition.length; i < il; i ++ ) {
|
|
219
|
+
if (morphPosition && morphInfluences) {
|
|
220
|
+
_morphA.set(0, 0, 0);
|
|
221
|
+
_morphB.set(0, 0, 0);
|
|
269
222
|
|
|
270
|
-
|
|
271
|
-
var
|
|
223
|
+
for (var i = 0, il = morphPosition.length; i < il; i++) {
|
|
224
|
+
var influence = morphInfluences[i];
|
|
225
|
+
var morphAttribute = morphPosition[i];
|
|
272
226
|
|
|
273
|
-
if (
|
|
227
|
+
if (influence === 0) continue;
|
|
274
228
|
|
|
275
|
-
_tempA.fromBufferAttribute(
|
|
276
|
-
_tempB.fromBufferAttribute(
|
|
277
|
-
|
|
278
|
-
_morphA.addScaledVector( _tempA.sub( vStart ), influence );
|
|
279
|
-
_morphB.addScaledVector( _tempB.sub( vEnd ), influence );
|
|
229
|
+
_tempA.fromBufferAttribute(morphAttribute, a);
|
|
230
|
+
_tempB.fromBufferAttribute(morphAttribute, b);
|
|
280
231
|
|
|
232
|
+
_morphA.addScaledVector(_tempA.sub(vStart), influence);
|
|
233
|
+
_morphB.addScaledVector(_tempB.sub(vEnd), influence);
|
|
281
234
|
}
|
|
282
235
|
|
|
283
|
-
vStart.add(
|
|
284
|
-
vEnd.add(
|
|
285
|
-
|
|
236
|
+
vStart.add(_morphA);
|
|
237
|
+
vEnd.add(_morphB);
|
|
286
238
|
}
|
|
287
|
-
|
|
288
239
|
}
|
|
289
240
|
|
|
290
241
|
Line.prototype.isLine = true;
|
|
291
242
|
|
|
292
|
-
|
|
293
|
-
export { Line };
|
|
243
|
+
export { Line };
|
|
@@ -1,65 +1,50 @@
|
|
|
1
1
|
import { Line } from './Line.js';
|
|
2
|
-
import {
|
|
3
|
-
Float32BufferAttribute,
|
|
4
|
-
Vector3
|
|
5
|
-
} from 'three/webgpu';
|
|
2
|
+
import { Float32BufferAttribute, Vector3 } from 'three/webgpu';
|
|
6
3
|
|
|
7
4
|
const _start = /*@__PURE__*/ new Vector3();
|
|
8
5
|
const _end = /*@__PURE__*/ new Vector3();
|
|
9
6
|
|
|
10
7
|
class LineSegments extends Line {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
} else if ( geometry.isGeometry ) {
|
|
52
|
-
|
|
53
|
-
console.error( 'THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return this;
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
8
|
+
constructor(geometry, material) {
|
|
9
|
+
super(geometry, material);
|
|
10
|
+
|
|
11
|
+
this.type = 'LineSegments';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
computeLineDistances() {
|
|
15
|
+
const geometry = this.geometry;
|
|
16
|
+
|
|
17
|
+
if (geometry.isBufferGeometry) {
|
|
18
|
+
// we assume non-indexed geometry
|
|
19
|
+
|
|
20
|
+
if (geometry.index === null) {
|
|
21
|
+
const positionAttribute = geometry.attributes.position;
|
|
22
|
+
const lineDistances = [];
|
|
23
|
+
|
|
24
|
+
for (let i = 0, l = positionAttribute.count; i < l; i += 2) {
|
|
25
|
+
_start.fromBufferAttribute(positionAttribute, i);
|
|
26
|
+
_end.fromBufferAttribute(positionAttribute, i + 1);
|
|
27
|
+
|
|
28
|
+
lineDistances[i] = i === 0 ? 0 : lineDistances[i - 1];
|
|
29
|
+
lineDistances[i + 1] = lineDistances[i] + _start.distanceTo(_end);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
geometry.setAttribute('lineDistance', new Float32BufferAttribute(lineDistances, 1));
|
|
33
|
+
} else {
|
|
34
|
+
console.warn(
|
|
35
|
+
'THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.',
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
} else if (geometry.isGeometry) {
|
|
39
|
+
console.error(
|
|
40
|
+
'THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.',
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
61
46
|
}
|
|
62
47
|
|
|
63
48
|
LineSegments.prototype.isLineSegments = true;
|
|
64
49
|
|
|
65
|
-
export { LineSegments };
|
|
50
|
+
export { LineSegments };
|