zincjs 2.4.0 → 2.4.1-beta.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 +3 -486
- package/build/zinc.js.map +1 -1
- package/package.json +3 -4
- package/src/controls.js +1 -1
- package/src/geometryCSG.js +1 -1
- package/src/glyphsetCSG.js +1 -1
- package/src/loaders/GLTFToZincJSLoader.js +1 -1
- package/src/loaders/JSONLoader.js +204 -377
- package/src/loaders/OBJLoader.js +1 -1
- package/src/loaders/STLLoader.js +1 -1
- package/src/loaders/niftiReader.js +6 -4
- package/src/loaders/primitivesLoader.js +7 -9
- package/src/minimap.js +1 -1
- package/src/primitives/geometry.js +11 -29
- package/src/primitives/glyph.js +1 -1
- package/src/primitives/glyphset.js +2 -4
- package/src/primitives/label.js +1 -1
- package/src/primitives/lines.js +12 -5
- package/src/primitives/lines2.js +4 -8
- package/src/primitives/lod.js +9 -3
- package/src/primitives/marker.js +1 -1
- package/src/primitives/markerCluster.js +1 -1
- package/src/primitives/pointset.js +368 -52
- package/src/primitives/textureSlides.js +59 -16
- package/src/primitives/textureVolume.js +1 -1
- package/src/primitives/tubeLines.js +20 -3
- package/src/primitives/zincObject.js +13 -1
- package/src/region.js +1 -1
- package/src/renderer.js +17 -13
- package/src/scene.js +20 -8
- package/src/sceneLoader.js +1 -1
- package/src/shaders/rgbVolumeRender.js +1 -1
- package/src/shaders/textureSlide.js +1 -1
- package/src/texture/texture.js +1 -1
- package/src/texture/textureArray.js +9 -2
- package/src/three/GLTFExporter.js +55 -2
- package/src/three/InstancedPoints.js +73 -0
- package/src/three/Loader.js +1 -1
- package/src/three/line/Line.js +1 -1
- package/src/three/line/LineSegments.js +1 -1
- package/src/three/line/LineSegments2.js +24 -39
- package/src/three/line/LineSegmentsGeometry.js +1 -1
- package/src/tls/morphColorMaterial.js +65 -0
- package/src/tls/pointsMaterial.js +79 -0
- package/src/tls/textureSlides.js +126 -0
- package/src/utilities.js +47 -70
- package/src/videoHandler.js +1 -2
- package/src/workers/geometryCSG.worker.js +1 -1
- package/src/workers/geometryCSGInternal.js +1 -1
- package/src/zinc.js +1 -1
- package/vite.config.js +3 -1
- package/src/primitives/augmentShader.js +0 -45
- package/src/three/Geometry.js +0 -2176
- package/src/three/Points.js +0 -224
- package/src/three/line/LineMaterial.js +0 -726
|
@@ -1,726 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ShaderLib,
|
|
3
|
-
ShaderMaterial,
|
|
4
|
-
UniformsLib,
|
|
5
|
-
UniformsUtils,
|
|
6
|
-
Vector2,
|
|
7
|
-
} from 'three';
|
|
8
|
-
|
|
9
|
-
UniformsLib.line = {
|
|
10
|
-
|
|
11
|
-
worldUnits: { value: 1 },
|
|
12
|
-
linewidth: { value: 1 },
|
|
13
|
-
resolution: { value: new Vector2() },
|
|
14
|
-
dashOffset: { value: 0 },
|
|
15
|
-
dashScale: { value: 1 },
|
|
16
|
-
dashSize: { value: 1 },
|
|
17
|
-
gapSize: { value: 1 } // todo FIX - maybe change to totalSize
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
ShaderLib[ 'line' ] = {
|
|
22
|
-
|
|
23
|
-
uniforms: UniformsUtils.merge( [
|
|
24
|
-
UniformsLib.common,
|
|
25
|
-
UniformsLib.fog,
|
|
26
|
-
UniformsLib.line
|
|
27
|
-
] ),
|
|
28
|
-
|
|
29
|
-
vertexShader:
|
|
30
|
-
/* glsl */`
|
|
31
|
-
#include <common>
|
|
32
|
-
#include <color_pars_vertex>
|
|
33
|
-
#include <fog_pars_vertex>
|
|
34
|
-
#include <logdepthbuf_pars_vertex>
|
|
35
|
-
#include <clipping_planes_pars_vertex>
|
|
36
|
-
|
|
37
|
-
uniform float linewidth;
|
|
38
|
-
uniform vec2 resolution;
|
|
39
|
-
|
|
40
|
-
attribute vec3 instanceStart;
|
|
41
|
-
attribute vec3 instanceEnd;
|
|
42
|
-
|
|
43
|
-
attribute vec3 instanceColorStart;
|
|
44
|
-
attribute vec3 instanceColorEnd;
|
|
45
|
-
|
|
46
|
-
#ifdef WORLD_UNITS
|
|
47
|
-
|
|
48
|
-
varying vec4 worldPos;
|
|
49
|
-
varying vec3 worldStart;
|
|
50
|
-
varying vec3 worldEnd;
|
|
51
|
-
|
|
52
|
-
#ifdef USE_DASH
|
|
53
|
-
|
|
54
|
-
varying vec2 vUv;
|
|
55
|
-
|
|
56
|
-
#endif
|
|
57
|
-
|
|
58
|
-
#else
|
|
59
|
-
|
|
60
|
-
varying vec2 vUv;
|
|
61
|
-
|
|
62
|
-
#endif
|
|
63
|
-
|
|
64
|
-
#ifdef USE_DASH
|
|
65
|
-
|
|
66
|
-
uniform float dashScale;
|
|
67
|
-
attribute float instanceDistanceStart;
|
|
68
|
-
attribute float instanceDistanceEnd;
|
|
69
|
-
varying float vLineDistance;
|
|
70
|
-
|
|
71
|
-
#endif
|
|
72
|
-
|
|
73
|
-
float trimSegmentAlpha( const in vec4 start, const in vec4 end ) {
|
|
74
|
-
|
|
75
|
-
// compute the interpolation factor needed to trim the segment so it terminates
|
|
76
|
-
// between the camera plane and the near plane
|
|
77
|
-
|
|
78
|
-
// conservative estimate of the near plane
|
|
79
|
-
float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
|
|
80
|
-
float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
|
|
81
|
-
|
|
82
|
-
// we need different nearEstimate formula for reversed and default depth buffer
|
|
83
|
-
// a is positive with a reversed depth buffer so it can be used for controlling the code flow
|
|
84
|
-
float nearEstimate = ( a > 0.0 ) ? ( - b / ( a + 1.0 ) ) : ( - 0.5 * b / a );
|
|
85
|
-
|
|
86
|
-
return ( nearEstimate - start.z ) / ( end.z - start.z );
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
void main() {
|
|
91
|
-
|
|
92
|
-
#ifdef USE_COLOR
|
|
93
|
-
|
|
94
|
-
vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
|
|
95
|
-
|
|
96
|
-
#endif
|
|
97
|
-
|
|
98
|
-
float aspect = resolution.x / resolution.y;
|
|
99
|
-
|
|
100
|
-
// camera space
|
|
101
|
-
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
|
|
102
|
-
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
|
|
103
|
-
|
|
104
|
-
#ifdef USE_DASH
|
|
105
|
-
|
|
106
|
-
float lineDistanceStart = dashScale * instanceDistanceStart;
|
|
107
|
-
float lineDistanceEnd = dashScale * instanceDistanceEnd;
|
|
108
|
-
|
|
109
|
-
#endif
|
|
110
|
-
|
|
111
|
-
#ifdef WORLD_UNITS
|
|
112
|
-
|
|
113
|
-
worldStart = start.xyz;
|
|
114
|
-
worldEnd = end.xyz;
|
|
115
|
-
|
|
116
|
-
#else
|
|
117
|
-
|
|
118
|
-
vUv = uv;
|
|
119
|
-
|
|
120
|
-
#endif
|
|
121
|
-
|
|
122
|
-
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
|
|
123
|
-
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
|
124
|
-
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
|
125
|
-
// perhaps there is a more elegant solution -- WestLangley
|
|
126
|
-
|
|
127
|
-
bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
|
|
128
|
-
|
|
129
|
-
if ( perspective ) {
|
|
130
|
-
|
|
131
|
-
if ( start.z < 0.0 && end.z >= 0.0 ) {
|
|
132
|
-
|
|
133
|
-
float alpha = trimSegmentAlpha( start, end );
|
|
134
|
-
end.xyz = mix( start.xyz, end.xyz, alpha );
|
|
135
|
-
|
|
136
|
-
#ifdef USE_DASH
|
|
137
|
-
|
|
138
|
-
lineDistanceEnd = mix( lineDistanceStart, lineDistanceEnd, alpha );
|
|
139
|
-
|
|
140
|
-
#endif
|
|
141
|
-
|
|
142
|
-
} else if ( end.z < 0.0 && start.z >= 0.0 ) {
|
|
143
|
-
|
|
144
|
-
float alpha = trimSegmentAlpha( end, start );
|
|
145
|
-
start.xyz = mix( end.xyz, start.xyz, alpha );
|
|
146
|
-
|
|
147
|
-
#ifdef USE_DASH
|
|
148
|
-
|
|
149
|
-
lineDistanceStart = mix( lineDistanceEnd, lineDistanceStart, alpha );
|
|
150
|
-
|
|
151
|
-
#endif
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
#ifdef USE_DASH
|
|
158
|
-
|
|
159
|
-
vLineDistance = ( position.y < 0.5 ) ? lineDistanceStart : lineDistanceEnd;
|
|
160
|
-
vUv = uv;
|
|
161
|
-
|
|
162
|
-
#endif
|
|
163
|
-
|
|
164
|
-
// clip space
|
|
165
|
-
vec4 clipStart = projectionMatrix * start;
|
|
166
|
-
vec4 clipEnd = projectionMatrix * end;
|
|
167
|
-
|
|
168
|
-
// ndc space
|
|
169
|
-
vec3 ndcStart = clipStart.xyz / clipStart.w;
|
|
170
|
-
vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
|
|
171
|
-
|
|
172
|
-
// direction
|
|
173
|
-
vec2 dir = ndcEnd.xy - ndcStart.xy;
|
|
174
|
-
|
|
175
|
-
// account for clip-space aspect ratio
|
|
176
|
-
dir.x *= aspect;
|
|
177
|
-
dir = normalize( dir );
|
|
178
|
-
|
|
179
|
-
#ifdef WORLD_UNITS
|
|
180
|
-
|
|
181
|
-
vec3 worldDir = normalize( end.xyz - start.xyz );
|
|
182
|
-
vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
|
|
183
|
-
vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
|
|
184
|
-
vec3 worldFwd = cross( worldDir, worldUp );
|
|
185
|
-
worldPos = position.y < 0.5 ? start: end;
|
|
186
|
-
|
|
187
|
-
// height offset
|
|
188
|
-
float hw = linewidth * 0.5;
|
|
189
|
-
worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;
|
|
190
|
-
|
|
191
|
-
// don't extend the line if we're rendering dashes because we
|
|
192
|
-
// won't be rendering the endcaps
|
|
193
|
-
#ifndef USE_DASH
|
|
194
|
-
|
|
195
|
-
// cap extension
|
|
196
|
-
worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;
|
|
197
|
-
|
|
198
|
-
// add width to the box
|
|
199
|
-
worldPos.xyz += worldFwd * hw;
|
|
200
|
-
|
|
201
|
-
// endcaps
|
|
202
|
-
if ( position.y > 1.0 || position.y < 0.0 ) {
|
|
203
|
-
|
|
204
|
-
worldPos.xyz -= worldFwd * 2.0 * hw;
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
#endif
|
|
209
|
-
|
|
210
|
-
// project the worldpos
|
|
211
|
-
vec4 clip = projectionMatrix * worldPos;
|
|
212
|
-
|
|
213
|
-
// shift the depth of the projected points so the line
|
|
214
|
-
// segments overlap neatly
|
|
215
|
-
vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
|
|
216
|
-
clip.z = clipPose.z * clip.w;
|
|
217
|
-
|
|
218
|
-
#else
|
|
219
|
-
|
|
220
|
-
vec2 offset = vec2( dir.y, - dir.x );
|
|
221
|
-
// undo aspect ratio adjustment
|
|
222
|
-
dir.x /= aspect;
|
|
223
|
-
offset.x /= aspect;
|
|
224
|
-
|
|
225
|
-
// sign flip
|
|
226
|
-
if ( position.x < 0.0 ) offset *= - 1.0;
|
|
227
|
-
|
|
228
|
-
// endcaps
|
|
229
|
-
if ( position.y < 0.0 ) {
|
|
230
|
-
|
|
231
|
-
offset += - dir;
|
|
232
|
-
|
|
233
|
-
} else if ( position.y > 1.0 ) {
|
|
234
|
-
|
|
235
|
-
offset += dir;
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// adjust for linewidth
|
|
240
|
-
offset *= linewidth;
|
|
241
|
-
|
|
242
|
-
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
|
|
243
|
-
offset /= resolution.y;
|
|
244
|
-
|
|
245
|
-
// select end
|
|
246
|
-
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
|
|
247
|
-
|
|
248
|
-
// back to clip space
|
|
249
|
-
offset *= clip.w;
|
|
250
|
-
|
|
251
|
-
clip.xy += offset;
|
|
252
|
-
|
|
253
|
-
#endif
|
|
254
|
-
|
|
255
|
-
gl_Position = clip;
|
|
256
|
-
|
|
257
|
-
vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
|
|
258
|
-
|
|
259
|
-
#include <logdepthbuf_vertex>
|
|
260
|
-
#include <clipping_planes_vertex>
|
|
261
|
-
#include <fog_vertex>
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
`,
|
|
265
|
-
|
|
266
|
-
fragmentShader:
|
|
267
|
-
/* glsl */`
|
|
268
|
-
uniform vec3 diffuse;
|
|
269
|
-
uniform float opacity;
|
|
270
|
-
uniform float linewidth;
|
|
271
|
-
|
|
272
|
-
#ifdef USE_DASH
|
|
273
|
-
|
|
274
|
-
uniform float dashOffset;
|
|
275
|
-
uniform float dashSize;
|
|
276
|
-
uniform float gapSize;
|
|
277
|
-
|
|
278
|
-
#endif
|
|
279
|
-
|
|
280
|
-
varying float vLineDistance;
|
|
281
|
-
|
|
282
|
-
#ifdef WORLD_UNITS
|
|
283
|
-
|
|
284
|
-
varying vec4 worldPos;
|
|
285
|
-
varying vec3 worldStart;
|
|
286
|
-
varying vec3 worldEnd;
|
|
287
|
-
|
|
288
|
-
#ifdef USE_DASH
|
|
289
|
-
|
|
290
|
-
varying vec2 vUv;
|
|
291
|
-
|
|
292
|
-
#endif
|
|
293
|
-
|
|
294
|
-
#else
|
|
295
|
-
|
|
296
|
-
varying vec2 vUv;
|
|
297
|
-
|
|
298
|
-
#endif
|
|
299
|
-
|
|
300
|
-
#include <common>
|
|
301
|
-
#include <color_pars_fragment>
|
|
302
|
-
#include <fog_pars_fragment>
|
|
303
|
-
#include <logdepthbuf_pars_fragment>
|
|
304
|
-
#include <clipping_planes_pars_fragment>
|
|
305
|
-
|
|
306
|
-
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
|
|
307
|
-
|
|
308
|
-
float mua;
|
|
309
|
-
float mub;
|
|
310
|
-
|
|
311
|
-
vec3 p13 = p1 - p3;
|
|
312
|
-
vec3 p43 = p4 - p3;
|
|
313
|
-
|
|
314
|
-
vec3 p21 = p2 - p1;
|
|
315
|
-
|
|
316
|
-
float d1343 = dot( p13, p43 );
|
|
317
|
-
float d4321 = dot( p43, p21 );
|
|
318
|
-
float d1321 = dot( p13, p21 );
|
|
319
|
-
float d4343 = dot( p43, p43 );
|
|
320
|
-
float d2121 = dot( p21, p21 );
|
|
321
|
-
|
|
322
|
-
float denom = d2121 * d4343 - d4321 * d4321;
|
|
323
|
-
|
|
324
|
-
float numer = d1343 * d4321 - d1321 * d4343;
|
|
325
|
-
|
|
326
|
-
mua = numer / denom;
|
|
327
|
-
mua = clamp( mua, 0.0, 1.0 );
|
|
328
|
-
mub = ( d1343 + d4321 * ( mua ) ) / d4343;
|
|
329
|
-
mub = clamp( mub, 0.0, 1.0 );
|
|
330
|
-
|
|
331
|
-
return vec2( mua, mub );
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
void main() {
|
|
336
|
-
|
|
337
|
-
float alpha = opacity;
|
|
338
|
-
vec4 diffuseColor = vec4( diffuse, alpha );
|
|
339
|
-
|
|
340
|
-
#include <clipping_planes_fragment>
|
|
341
|
-
|
|
342
|
-
#ifdef USE_DASH
|
|
343
|
-
|
|
344
|
-
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
|
|
345
|
-
|
|
346
|
-
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
|
|
347
|
-
|
|
348
|
-
#endif
|
|
349
|
-
|
|
350
|
-
#ifdef WORLD_UNITS
|
|
351
|
-
|
|
352
|
-
// Find the closest points on the view ray and the line segment
|
|
353
|
-
vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
|
|
354
|
-
vec3 lineDir = worldEnd - worldStart;
|
|
355
|
-
vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
|
|
356
|
-
|
|
357
|
-
vec3 p1 = worldStart + lineDir * params.x;
|
|
358
|
-
vec3 p2 = rayEnd * params.y;
|
|
359
|
-
vec3 delta = p1 - p2;
|
|
360
|
-
float len = length( delta );
|
|
361
|
-
float norm = len / linewidth;
|
|
362
|
-
|
|
363
|
-
#ifndef USE_DASH
|
|
364
|
-
|
|
365
|
-
#ifdef USE_ALPHA_TO_COVERAGE
|
|
366
|
-
|
|
367
|
-
float dnorm = fwidth( norm );
|
|
368
|
-
alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
|
|
369
|
-
|
|
370
|
-
#else
|
|
371
|
-
|
|
372
|
-
if ( norm > 0.5 ) {
|
|
373
|
-
|
|
374
|
-
discard;
|
|
375
|
-
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
#endif
|
|
379
|
-
|
|
380
|
-
#endif
|
|
381
|
-
|
|
382
|
-
#else
|
|
383
|
-
|
|
384
|
-
#ifdef USE_ALPHA_TO_COVERAGE
|
|
385
|
-
|
|
386
|
-
// artifacts appear on some hardware if a derivative is taken within a conditional
|
|
387
|
-
float a = vUv.x;
|
|
388
|
-
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
389
|
-
float len2 = a * a + b * b;
|
|
390
|
-
float dlen = fwidth( len2 );
|
|
391
|
-
|
|
392
|
-
if ( abs( vUv.y ) > 1.0 ) {
|
|
393
|
-
|
|
394
|
-
alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
#else
|
|
399
|
-
|
|
400
|
-
if ( abs( vUv.y ) > 1.0 ) {
|
|
401
|
-
|
|
402
|
-
float a = vUv.x;
|
|
403
|
-
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
404
|
-
float len2 = a * a + b * b;
|
|
405
|
-
|
|
406
|
-
if ( len2 > 1.0 ) discard;
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
#endif
|
|
411
|
-
|
|
412
|
-
#endif
|
|
413
|
-
|
|
414
|
-
#include <logdepthbuf_fragment>
|
|
415
|
-
#include <color_fragment>
|
|
416
|
-
|
|
417
|
-
gl_FragColor = vec4( diffuseColor.rgb, alpha );
|
|
418
|
-
|
|
419
|
-
#include <tonemapping_fragment>
|
|
420
|
-
#include <colorspace_fragment>
|
|
421
|
-
#include <fog_fragment>
|
|
422
|
-
#include <premultiplied_alpha_fragment>
|
|
423
|
-
|
|
424
|
-
}
|
|
425
|
-
`
|
|
426
|
-
};
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* A material for drawing wireframe-style geometries.
|
|
430
|
-
*
|
|
431
|
-
* Unlike {@link LineBasicMaterial}, it supports arbitrary line widths and allows using world units
|
|
432
|
-
* instead of screen space units. This material is used with {@link LineSegments2} and {@link Line2}.
|
|
433
|
-
*
|
|
434
|
-
* This module can only be used with {@link WebGLRenderer}. When using {@link WebGPURenderer},
|
|
435
|
-
* use {@link Line2NodeMaterial}.
|
|
436
|
-
*
|
|
437
|
-
* @augments ShaderMaterial
|
|
438
|
-
* @three_import import { LineMaterial } from 'three/addons/lines/LineMaterial.js';
|
|
439
|
-
*/
|
|
440
|
-
class LineMaterial extends ShaderMaterial {
|
|
441
|
-
|
|
442
|
-
/**
|
|
443
|
-
* Constructs a new line segments geometry.
|
|
444
|
-
*
|
|
445
|
-
* @param {Object} [parameters] - An object with one or more properties
|
|
446
|
-
* defining the material's appearance. Any property of the material
|
|
447
|
-
* (including any property from inherited materials) can be passed
|
|
448
|
-
* in here. Color values can be passed any type of value accepted
|
|
449
|
-
* by {@link Color#set}.
|
|
450
|
-
*/
|
|
451
|
-
constructor( parameters ) {
|
|
452
|
-
|
|
453
|
-
super( {
|
|
454
|
-
|
|
455
|
-
type: 'LineMaterial',
|
|
456
|
-
uniforms: UniformsUtils.clone( ShaderLib[ 'line' ].uniforms ),
|
|
457
|
-
|
|
458
|
-
vertexShader: ShaderLib[ 'line' ].vertexShader,
|
|
459
|
-
fragmentShader: ShaderLib[ 'line' ].fragmentShader,
|
|
460
|
-
|
|
461
|
-
clipping: true // required for clipping support
|
|
462
|
-
|
|
463
|
-
} );
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* This flag can be used for type testing.
|
|
467
|
-
*
|
|
468
|
-
* @type {boolean}
|
|
469
|
-
* @readonly
|
|
470
|
-
* @default true
|
|
471
|
-
*/
|
|
472
|
-
this.isLineMaterial = true;
|
|
473
|
-
|
|
474
|
-
this.setValues( parameters );
|
|
475
|
-
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* The material's color.
|
|
480
|
-
*
|
|
481
|
-
* @type {Color}
|
|
482
|
-
* @default (1,1,1)
|
|
483
|
-
*/
|
|
484
|
-
get color() {
|
|
485
|
-
|
|
486
|
-
return this.uniforms.diffuse.value;
|
|
487
|
-
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
set color( value ) {
|
|
491
|
-
|
|
492
|
-
this.uniforms.diffuse.value = value;
|
|
493
|
-
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Whether the material's sizes (width, dash gaps) are in world units.
|
|
498
|
-
*
|
|
499
|
-
* @type {boolean}
|
|
500
|
-
* @default false
|
|
501
|
-
*/
|
|
502
|
-
get worldUnits() {
|
|
503
|
-
|
|
504
|
-
return 'WORLD_UNITS' in this.defines;
|
|
505
|
-
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
set worldUnits( value ) {
|
|
509
|
-
|
|
510
|
-
if ( ( value === true ) !== this.worldUnits ) {
|
|
511
|
-
|
|
512
|
-
this.needsUpdate = true;
|
|
513
|
-
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
if ( value === true ) {
|
|
517
|
-
|
|
518
|
-
this.defines.WORLD_UNITS = '';
|
|
519
|
-
|
|
520
|
-
} else {
|
|
521
|
-
|
|
522
|
-
delete this.defines.WORLD_UNITS;
|
|
523
|
-
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
* Controls line thickness in CSS pixel units when `worldUnits` is `false` (default),
|
|
530
|
-
* or in world units when `worldUnits` is `true`.
|
|
531
|
-
*
|
|
532
|
-
* @type {number}
|
|
533
|
-
* @default 1
|
|
534
|
-
*/
|
|
535
|
-
get linewidth() {
|
|
536
|
-
|
|
537
|
-
return this.uniforms.linewidth.value;
|
|
538
|
-
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
set linewidth( value ) {
|
|
542
|
-
|
|
543
|
-
if ( ! this.uniforms.linewidth ) return;
|
|
544
|
-
this.uniforms.linewidth.value = value;
|
|
545
|
-
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* Whether the line is dashed, or solid.
|
|
550
|
-
*
|
|
551
|
-
* @type {boolean}
|
|
552
|
-
* @default false
|
|
553
|
-
*/
|
|
554
|
-
get dashed() {
|
|
555
|
-
|
|
556
|
-
return 'USE_DASH' in this.defines;
|
|
557
|
-
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
set dashed( value ) {
|
|
561
|
-
|
|
562
|
-
if ( ( value === true ) !== this.dashed ) {
|
|
563
|
-
|
|
564
|
-
this.needsUpdate = true;
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
if ( value === true ) {
|
|
569
|
-
|
|
570
|
-
this.defines.USE_DASH = '';
|
|
571
|
-
|
|
572
|
-
} else {
|
|
573
|
-
|
|
574
|
-
delete this.defines.USE_DASH;
|
|
575
|
-
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
/**
|
|
581
|
-
* The scale of the dashes and gaps.
|
|
582
|
-
*
|
|
583
|
-
* @type {number}
|
|
584
|
-
* @default 1
|
|
585
|
-
*/
|
|
586
|
-
get dashScale() {
|
|
587
|
-
|
|
588
|
-
return this.uniforms.dashScale.value;
|
|
589
|
-
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
set dashScale( value ) {
|
|
593
|
-
|
|
594
|
-
this.uniforms.dashScale.value = value;
|
|
595
|
-
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
/**
|
|
599
|
-
* The size of the dash.
|
|
600
|
-
*
|
|
601
|
-
* @type {number}
|
|
602
|
-
* @default 1
|
|
603
|
-
*/
|
|
604
|
-
get dashSize() {
|
|
605
|
-
|
|
606
|
-
return this.uniforms.dashSize.value;
|
|
607
|
-
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
set dashSize( value ) {
|
|
611
|
-
|
|
612
|
-
this.uniforms.dashSize.value = value;
|
|
613
|
-
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
/**
|
|
617
|
-
* Where in the dash cycle the dash starts.
|
|
618
|
-
*
|
|
619
|
-
* @type {number}
|
|
620
|
-
* @default 0
|
|
621
|
-
*/
|
|
622
|
-
get dashOffset() {
|
|
623
|
-
|
|
624
|
-
return this.uniforms.dashOffset.value;
|
|
625
|
-
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
set dashOffset( value ) {
|
|
629
|
-
|
|
630
|
-
this.uniforms.dashOffset.value = value;
|
|
631
|
-
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
/**
|
|
635
|
-
* The size of the gap.
|
|
636
|
-
*
|
|
637
|
-
* @type {number}
|
|
638
|
-
* @default 0
|
|
639
|
-
*/
|
|
640
|
-
get gapSize() {
|
|
641
|
-
|
|
642
|
-
return this.uniforms.gapSize.value;
|
|
643
|
-
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
set gapSize( value ) {
|
|
647
|
-
|
|
648
|
-
this.uniforms.gapSize.value = value;
|
|
649
|
-
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
/**
|
|
653
|
-
* The opacity.
|
|
654
|
-
*
|
|
655
|
-
* @type {number}
|
|
656
|
-
* @default 1
|
|
657
|
-
*/
|
|
658
|
-
get opacity() {
|
|
659
|
-
|
|
660
|
-
return this.uniforms.opacity.value;
|
|
661
|
-
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
set opacity( value ) {
|
|
665
|
-
|
|
666
|
-
if ( ! this.uniforms ) return;
|
|
667
|
-
this.uniforms.opacity.value = value;
|
|
668
|
-
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* The size of the viewport, in screen pixels. This must be kept updated to make
|
|
673
|
-
* screen-space rendering accurate. The `LineSegments2.onBeforeRender` callback
|
|
674
|
-
* performs the update for visible objects.
|
|
675
|
-
*
|
|
676
|
-
* @type {Vector2}
|
|
677
|
-
*/
|
|
678
|
-
get resolution() {
|
|
679
|
-
|
|
680
|
-
return this.uniforms.resolution.value;
|
|
681
|
-
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
set resolution( value ) {
|
|
685
|
-
|
|
686
|
-
this.uniforms.resolution.value.copy( value );
|
|
687
|
-
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
/**
|
|
691
|
-
* Whether to use alphaToCoverage or not. When enabled, this can improve the
|
|
692
|
-
* anti-aliasing of line edges when using MSAA.
|
|
693
|
-
*
|
|
694
|
-
* @type {boolean}
|
|
695
|
-
*/
|
|
696
|
-
get alphaToCoverage() {
|
|
697
|
-
|
|
698
|
-
return 'USE_ALPHA_TO_COVERAGE' in this.defines;
|
|
699
|
-
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
set alphaToCoverage( value ) {
|
|
703
|
-
|
|
704
|
-
if ( ! this.defines ) return;
|
|
705
|
-
|
|
706
|
-
if ( ( value === true ) !== this.alphaToCoverage ) {
|
|
707
|
-
|
|
708
|
-
this.needsUpdate = true;
|
|
709
|
-
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
if ( value === true ) {
|
|
713
|
-
|
|
714
|
-
this.defines.USE_ALPHA_TO_COVERAGE = '';
|
|
715
|
-
|
|
716
|
-
} else {
|
|
717
|
-
|
|
718
|
-
delete this.defines.USE_ALPHA_TO_COVERAGE;
|
|
719
|
-
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
export { LineMaterial };
|