three-stdlib 2.14.1 → 2.15.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/csm/CSM.cjs.js +1 -1
- package/csm/CSM.js +8 -8
- package/csm/CSMFrustum.cjs.js +1 -0
- package/csm/CSMFrustum.d.ts +19 -0
- package/csm/{Frustum.js → CSMFrustum.js} +8 -7
- package/csm/CSMShader.cjs.js +1 -0
- package/csm/CSMShader.d.ts +4 -0
- package/csm/{Shader.js → CSMShader.js} +52 -36
- package/curves/CurveExtras.d.ts +52 -54
- package/geometries/ParametricGeometries.cjs.js +1 -1
- package/geometries/ParametricGeometries.js +91 -99
- package/geometries/ParametricGeometry.cjs.js +1 -0
- package/geometries/ParametricGeometry.d.ts +18 -0
- package/geometries/ParametricGeometry.js +87 -0
- package/index.cjs.js +1 -1
- package/index.d.ts +3 -77
- package/index.js +4 -1
- package/interactive/InteractiveGroup.cjs.js +1 -0
- package/interactive/InteractiveGroup.d.ts +5 -0
- package/interactive/InteractiveGroup.js +87 -0
- package/lines/Line2.cjs.js +1 -1
- package/lines/Line2.d.ts +7 -5
- package/lines/Line2.js +2 -5
- package/lines/LineGeometry.cjs.js +1 -1
- package/lines/LineGeometry.d.ts +6 -8
- package/lines/LineGeometry.js +28 -39
- package/lines/LineMaterial.cjs.js +1 -1
- package/lines/LineMaterial.d.ts +23 -19
- package/lines/LineMaterial.js +263 -107
- package/lines/LineSegments2.cjs.js +1 -1
- package/lines/LineSegments2.d.ts +12 -20
- package/lines/LineSegments2.js +272 -125
- package/lines/LineSegmentsGeometry.cjs.js +1 -1
- package/lines/LineSegmentsGeometry.d.ts +18 -16
- package/lines/LineSegmentsGeometry.js +30 -40
- package/lines/Wireframe.cjs.js +1 -1
- package/lines/Wireframe.js +39 -39
- package/lines/WireframeGeometry2.cjs.js +1 -1
- package/lines/WireframeGeometry2.js +8 -9
- package/loaders/GLTFLoader.d.ts +2 -9
- package/loaders/LUT3dlLoader.d.ts +2 -2
- package/loaders/LUTCubeLoader.d.ts +2 -2
- package/loaders/RGBELoader.cjs.js +1 -1
- package/loaders/RGBELoader.js +1 -9
- package/loaders/VOXLoader.d.ts +2 -2
- package/objects/Reflector.d.ts +1 -0
- package/objects/ReflectorForSSRPass.d.ts +4 -4
- package/objects/Refractor.d.ts +1 -0
- package/objects/Water2.d.ts +1 -1
- package/package.json +2 -1
- package/postprocessing/LUTPass.d.ts +3 -3
- package/postprocessing/SSAARenderPass.d.ts +1 -1
- package/postprocessing/SSRPass.d.ts +3 -3
- package/shaders/BokehShader2.d.ts +27 -72
- package/shaders/BokehShader2.js +0 -1
- package/shaders/index.cjs.js +1 -1
- package/shaders/index.d.ts +2 -1
- package/shaders/index.js +1 -1
- package/csm/Frustum.cjs.js +0 -1
- package/csm/Shader.cjs.js +0 -1
- package/loaders/VRMLoader.d.ts +0 -19
- package/nodes/Nodes.d.ts +0 -106
- package/nodes/accessors/CameraNode.d.ts +0 -29
- package/nodes/accessors/NormalNode.d.ts +0 -13
- package/nodes/accessors/PositionNode.d.ts +0 -15
- package/nodes/accessors/ReflectNode.d.ts +0 -12
- package/nodes/accessors/UVNode.d.ts +0 -10
- package/nodes/core/AttributeNode.d.ts +0 -13
- package/nodes/core/ConstNode.d.ts +0 -22
- package/nodes/core/ExpressionNode.d.ts +0 -5
- package/nodes/core/FunctionCallNode.d.ts +0 -17
- package/nodes/core/FunctionNode.d.ts +0 -28
- package/nodes/core/InputNode.d.ts +0 -12
- package/nodes/core/Node.d.ts +0 -34
- package/nodes/core/NodeBuilder.d.ts +0 -149
- package/nodes/core/NodeFrame.d.ts +0 -17
- package/nodes/core/NodeUniform.d.ts +0 -17
- package/nodes/core/NodeUtils.d.ts +0 -7
- package/nodes/core/TempNode.d.ts +0 -23
- package/nodes/core/VarNode.d.ts +0 -12
- package/nodes/materials/MeshStandardNodeMaterial.d.ts +0 -21
- package/nodes/materials/NodeMaterial.d.ts +0 -28
- package/nodes/math/CondNode.d.ts +0 -26
- package/nodes/math/MathNode.d.ts +0 -57
- package/nodes/math/OperatorNode.d.ts +0 -17
- package/nodes/procedural/CheckerNode.d.ts +0 -17
- package/nodes/utils/JoinNode.d.ts +0 -15
- package/nodes/utils/TimerNode.d.ts +0 -19
- package/objects/ReflectorRTT.d.ts +0 -6
package/lines/LineMaterial.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
import
|
2
|
-
import { Vector2, ShaderLib, UniformsUtils, UniformsLib, ShaderMaterial, Color } from 'three';
|
1
|
+
import { UniformsLib, Vector2, ShaderLib, UniformsUtils, ShaderMaterial } from 'three';
|
3
2
|
|
4
3
|
/**
|
5
4
|
* parameters = {
|
@@ -13,32 +12,32 @@ import { Vector2, ShaderLib, UniformsUtils, UniformsLib, ShaderMaterial, Color }
|
|
13
12
|
* resolution: <Vector2>, // to be set by renderer
|
14
13
|
* }
|
15
14
|
*/
|
16
|
-
|
15
|
+
UniformsLib.line = {
|
16
|
+
worldUnits: {
|
17
|
+
value: 1
|
18
|
+
},
|
17
19
|
linewidth: {
|
18
20
|
value: 1
|
19
21
|
},
|
20
22
|
resolution: {
|
21
23
|
value: new Vector2(1, 1)
|
22
24
|
},
|
25
|
+
dashOffset: {
|
26
|
+
value: 0
|
27
|
+
},
|
23
28
|
dashScale: {
|
24
29
|
value: 1
|
25
30
|
},
|
26
31
|
dashSize: {
|
27
32
|
value: 1
|
28
33
|
},
|
29
|
-
dashOffset: {
|
30
|
-
value: 0
|
31
|
-
},
|
32
34
|
gapSize: {
|
33
35
|
value: 1
|
34
|
-
}
|
35
|
-
|
36
|
-
opacity: {
|
37
|
-
value: 1
|
38
|
-
}
|
36
|
+
} // todo FIX - maybe change to totalSize
|
37
|
+
|
39
38
|
};
|
40
39
|
ShaderLib['line'] = {
|
41
|
-
uniforms: UniformsUtils.merge([UniformsLib.common, UniformsLib.fog,
|
40
|
+
uniforms: UniformsUtils.merge([UniformsLib.common, UniformsLib.fog, UniformsLib.line]),
|
42
41
|
vertexShader:
|
43
42
|
/* glsl */
|
44
43
|
`
|
@@ -57,7 +56,23 @@ ShaderLib['line'] = {
|
|
57
56
|
attribute vec3 instanceColorStart;
|
58
57
|
attribute vec3 instanceColorEnd;
|
59
58
|
|
60
|
-
|
59
|
+
#ifdef WORLD_UNITS
|
60
|
+
|
61
|
+
varying vec4 worldPos;
|
62
|
+
varying vec3 worldStart;
|
63
|
+
varying vec3 worldEnd;
|
64
|
+
|
65
|
+
#ifdef USE_DASH
|
66
|
+
|
67
|
+
varying vec2 vUv;
|
68
|
+
|
69
|
+
#endif
|
70
|
+
|
71
|
+
#else
|
72
|
+
|
73
|
+
varying vec2 vUv;
|
74
|
+
|
75
|
+
#endif
|
61
76
|
|
62
77
|
#ifdef USE_DASH
|
63
78
|
|
@@ -94,17 +109,27 @@ ShaderLib['line'] = {
|
|
94
109
|
#ifdef USE_DASH
|
95
110
|
|
96
111
|
vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
|
112
|
+
vUv = uv;
|
97
113
|
|
98
114
|
#endif
|
99
115
|
|
100
116
|
float aspect = resolution.x / resolution.y;
|
101
117
|
|
102
|
-
vUv = uv;
|
103
|
-
|
104
118
|
// camera space
|
105
119
|
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
|
106
120
|
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
|
107
121
|
|
122
|
+
#ifdef WORLD_UNITS
|
123
|
+
|
124
|
+
worldStart = start.xyz;
|
125
|
+
worldEnd = end.xyz;
|
126
|
+
|
127
|
+
#else
|
128
|
+
|
129
|
+
vUv = uv;
|
130
|
+
|
131
|
+
#endif
|
132
|
+
|
108
133
|
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
|
109
134
|
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
110
135
|
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
@@ -131,50 +156,108 @@ ShaderLib['line'] = {
|
|
131
156
|
vec4 clipEnd = projectionMatrix * end;
|
132
157
|
|
133
158
|
// ndc space
|
134
|
-
|
135
|
-
|
159
|
+
vec3 ndcStart = clipStart.xyz / clipStart.w;
|
160
|
+
vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
|
136
161
|
|
137
162
|
// direction
|
138
|
-
vec2 dir = ndcEnd - ndcStart;
|
163
|
+
vec2 dir = ndcEnd.xy - ndcStart.xy;
|
139
164
|
|
140
165
|
// account for clip-space aspect ratio
|
141
166
|
dir.x *= aspect;
|
142
167
|
dir = normalize( dir );
|
143
168
|
|
144
|
-
|
145
|
-
vec2 offset = vec2( dir.y, - dir.x );
|
169
|
+
#ifdef WORLD_UNITS
|
146
170
|
|
147
|
-
|
148
|
-
|
149
|
-
|
171
|
+
// get the offset direction as perpendicular to the view vector
|
172
|
+
vec3 worldDir = normalize( end.xyz - start.xyz );
|
173
|
+
vec3 offset;
|
174
|
+
if ( position.y < 0.5 ) {
|
150
175
|
|
151
|
-
|
152
|
-
if ( position.x < 0.0 ) offset *= - 1.0;
|
176
|
+
offset = normalize( cross( start.xyz, worldDir ) );
|
153
177
|
|
154
|
-
|
155
|
-
if ( position.y < 0.0 ) {
|
178
|
+
} else {
|
156
179
|
|
157
|
-
|
180
|
+
offset = normalize( cross( end.xyz, worldDir ) );
|
158
181
|
|
159
|
-
|
182
|
+
}
|
160
183
|
|
161
|
-
|
184
|
+
// sign flip
|
185
|
+
if ( position.x < 0.0 ) offset *= - 1.0;
|
162
186
|
|
163
|
-
|
187
|
+
float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
|
188
|
+
|
189
|
+
// don't extend the line if we're rendering dashes because we
|
190
|
+
// won't be rendering the endcaps
|
191
|
+
#ifndef USE_DASH
|
192
|
+
|
193
|
+
// extend the line bounds to encompass endcaps
|
194
|
+
start.xyz += - worldDir * linewidth * 0.5;
|
195
|
+
end.xyz += worldDir * linewidth * 0.5;
|
196
|
+
|
197
|
+
// shift the position of the quad so it hugs the forward edge of the line
|
198
|
+
offset.xy -= dir * forwardOffset;
|
199
|
+
offset.z += 0.5;
|
200
|
+
|
201
|
+
#endif
|
202
|
+
|
203
|
+
// endcaps
|
204
|
+
if ( position.y > 1.0 || position.y < 0.0 ) {
|
164
205
|
|
165
|
-
|
166
|
-
offset *= linewidth;
|
206
|
+
offset.xy += dir * 2.0 * forwardOffset;
|
167
207
|
|
168
|
-
|
169
|
-
|
208
|
+
}
|
209
|
+
|
210
|
+
// adjust for linewidth
|
211
|
+
offset *= linewidth * 0.5;
|
212
|
+
|
213
|
+
// set the world position
|
214
|
+
worldPos = ( position.y < 0.5 ) ? start : end;
|
215
|
+
worldPos.xyz += offset;
|
216
|
+
|
217
|
+
// project the worldpos
|
218
|
+
vec4 clip = projectionMatrix * worldPos;
|
219
|
+
|
220
|
+
// shift the depth of the projected points so the line
|
221
|
+
// segments overlap neatly
|
222
|
+
vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
|
223
|
+
clip.z = clipPose.z * clip.w;
|
224
|
+
|
225
|
+
#else
|
226
|
+
|
227
|
+
vec2 offset = vec2( dir.y, - dir.x );
|
228
|
+
// undo aspect ratio adjustment
|
229
|
+
dir.x /= aspect;
|
230
|
+
offset.x /= aspect;
|
231
|
+
|
232
|
+
// sign flip
|
233
|
+
if ( position.x < 0.0 ) offset *= - 1.0;
|
234
|
+
|
235
|
+
// endcaps
|
236
|
+
if ( position.y < 0.0 ) {
|
170
237
|
|
171
|
-
|
172
|
-
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
|
238
|
+
offset += - dir;
|
173
239
|
|
174
|
-
|
175
|
-
offset *= clip.w;
|
240
|
+
} else if ( position.y > 1.0 ) {
|
176
241
|
|
177
|
-
|
242
|
+
offset += dir;
|
243
|
+
|
244
|
+
}
|
245
|
+
|
246
|
+
// adjust for linewidth
|
247
|
+
offset *= linewidth;
|
248
|
+
|
249
|
+
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
|
250
|
+
offset /= resolution.y;
|
251
|
+
|
252
|
+
// select end
|
253
|
+
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
|
254
|
+
|
255
|
+
// back to clip space
|
256
|
+
offset *= clip.w;
|
257
|
+
|
258
|
+
clip.xy += offset;
|
259
|
+
|
260
|
+
#endif
|
178
261
|
|
179
262
|
gl_Position = clip;
|
180
263
|
|
@@ -191,24 +274,70 @@ ShaderLib['line'] = {
|
|
191
274
|
`
|
192
275
|
uniform vec3 diffuse;
|
193
276
|
uniform float opacity;
|
277
|
+
uniform float linewidth;
|
194
278
|
|
195
279
|
#ifdef USE_DASH
|
196
280
|
|
197
|
-
uniform float dashSize;
|
198
281
|
uniform float dashOffset;
|
282
|
+
uniform float dashSize;
|
199
283
|
uniform float gapSize;
|
200
284
|
|
201
285
|
#endif
|
202
286
|
|
203
287
|
varying float vLineDistance;
|
204
288
|
|
289
|
+
#ifdef WORLD_UNITS
|
290
|
+
|
291
|
+
varying vec4 worldPos;
|
292
|
+
varying vec3 worldStart;
|
293
|
+
varying vec3 worldEnd;
|
294
|
+
|
295
|
+
#ifdef USE_DASH
|
296
|
+
|
297
|
+
varying vec2 vUv;
|
298
|
+
|
299
|
+
#endif
|
300
|
+
|
301
|
+
#else
|
302
|
+
|
303
|
+
varying vec2 vUv;
|
304
|
+
|
305
|
+
#endif
|
306
|
+
|
205
307
|
#include <common>
|
206
308
|
#include <color_pars_fragment>
|
207
309
|
#include <fog_pars_fragment>
|
208
310
|
#include <logdepthbuf_pars_fragment>
|
209
311
|
#include <clipping_planes_pars_fragment>
|
210
312
|
|
211
|
-
|
313
|
+
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
|
314
|
+
|
315
|
+
float mua;
|
316
|
+
float mub;
|
317
|
+
|
318
|
+
vec3 p13 = p1 - p3;
|
319
|
+
vec3 p43 = p4 - p3;
|
320
|
+
|
321
|
+
vec3 p21 = p2 - p1;
|
322
|
+
|
323
|
+
float d1343 = dot( p13, p43 );
|
324
|
+
float d4321 = dot( p43, p21 );
|
325
|
+
float d1321 = dot( p13, p21 );
|
326
|
+
float d4343 = dot( p43, p43 );
|
327
|
+
float d2121 = dot( p21, p21 );
|
328
|
+
|
329
|
+
float denom = d2121 * d4343 - d4321 * d4321;
|
330
|
+
|
331
|
+
float numer = d1343 * d4321 - d1321 * d4343;
|
332
|
+
|
333
|
+
mua = numer / denom;
|
334
|
+
mua = clamp( mua, 0.0, 1.0 );
|
335
|
+
mub = ( d1343 + d4321 * ( mua ) ) / d4343;
|
336
|
+
mub = clamp( mub, 0.0, 1.0 );
|
337
|
+
|
338
|
+
return vec2( mua, mub );
|
339
|
+
|
340
|
+
}
|
212
341
|
|
213
342
|
void main() {
|
214
343
|
|
@@ -224,31 +353,67 @@ ShaderLib['line'] = {
|
|
224
353
|
|
225
354
|
float alpha = opacity;
|
226
355
|
|
227
|
-
#ifdef
|
356
|
+
#ifdef WORLD_UNITS
|
228
357
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
float dlen = fwidth( len2 );
|
358
|
+
// Find the closest points on the view ray and the line segment
|
359
|
+
vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
|
360
|
+
vec3 lineDir = worldEnd - worldStart;
|
361
|
+
vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
|
234
362
|
|
235
|
-
|
363
|
+
vec3 p1 = worldStart + lineDir * params.x;
|
364
|
+
vec3 p2 = rayEnd * params.y;
|
365
|
+
vec3 delta = p1 - p2;
|
366
|
+
float len = length( delta );
|
367
|
+
float norm = len / linewidth;
|
236
368
|
|
237
|
-
|
369
|
+
#ifndef USE_DASH
|
238
370
|
|
239
|
-
|
371
|
+
#ifdef USE_ALPHA_TO_COVERAGE
|
372
|
+
|
373
|
+
float dnorm = fwidth( norm );
|
374
|
+
alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
|
375
|
+
|
376
|
+
#else
|
377
|
+
|
378
|
+
if ( norm > 0.5 ) {
|
379
|
+
|
380
|
+
discard;
|
381
|
+
|
382
|
+
}
|
383
|
+
|
384
|
+
#endif
|
385
|
+
|
386
|
+
#endif
|
240
387
|
|
241
388
|
#else
|
242
389
|
|
243
|
-
|
390
|
+
#ifdef USE_ALPHA_TO_COVERAGE
|
244
391
|
|
245
|
-
|
246
|
-
|
247
|
-
|
392
|
+
// artifacts appear on some hardware if a derivative is taken within a conditional
|
393
|
+
float a = vUv.x;
|
394
|
+
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
395
|
+
float len2 = a * a + b * b;
|
396
|
+
float dlen = fwidth( len2 );
|
248
397
|
|
249
|
-
|
398
|
+
if ( abs( vUv.y ) > 1.0 ) {
|
250
399
|
|
251
|
-
|
400
|
+
alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
|
401
|
+
|
402
|
+
}
|
403
|
+
|
404
|
+
#else
|
405
|
+
|
406
|
+
if ( abs( vUv.y ) > 1.0 ) {
|
407
|
+
|
408
|
+
float a = vUv.x;
|
409
|
+
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
410
|
+
float len2 = a * a + b * b;
|
411
|
+
|
412
|
+
if ( len2 > 1.0 ) discard;
|
413
|
+
|
414
|
+
}
|
415
|
+
|
416
|
+
#endif
|
252
417
|
|
253
418
|
#endif
|
254
419
|
|
@@ -269,39 +434,16 @@ ShaderLib['line'] = {
|
|
269
434
|
};
|
270
435
|
|
271
436
|
class LineMaterial extends ShaderMaterial {
|
272
|
-
constructor(parameters
|
437
|
+
constructor(parameters) {
|
273
438
|
super({
|
439
|
+
type: 'LineMaterial',
|
274
440
|
uniforms: UniformsUtils.clone(ShaderLib['line'].uniforms),
|
275
441
|
vertexShader: ShaderLib['line'].vertexShader,
|
276
442
|
fragmentShader: ShaderLib['line'].fragmentShader,
|
277
443
|
clipping: true // required for clipping support
|
278
444
|
|
279
445
|
});
|
280
|
-
|
281
|
-
* Everytime I remove this, everything just breaks,
|
282
|
-
* so I'm just gonna leave it here.
|
283
|
-
*/
|
284
|
-
|
285
|
-
_defineProperty(this, "isLineMaterial", true);
|
286
|
-
|
287
|
-
_defineProperty(this, "dashed", false);
|
288
|
-
|
289
|
-
_defineProperty(this, "color", new Color(0x000000));
|
290
|
-
|
291
|
-
_defineProperty(this, "lineWidth", 0);
|
292
|
-
|
293
|
-
_defineProperty(this, "dashScale", 0);
|
294
|
-
|
295
|
-
_defineProperty(this, "dashOffset", 0);
|
296
|
-
|
297
|
-
_defineProperty(this, "dashSize", 0);
|
298
|
-
|
299
|
-
_defineProperty(this, "opacity", 0);
|
300
|
-
|
301
|
-
_defineProperty(this, "resolution", new Vector2());
|
302
|
-
|
303
|
-
_defineProperty(this, "alphaToCoverage", false);
|
304
|
-
|
446
|
+
this.isLineMaterial = true;
|
305
447
|
Object.defineProperties(this, {
|
306
448
|
color: {
|
307
449
|
enumerable: true,
|
@@ -309,8 +451,20 @@ class LineMaterial extends ShaderMaterial {
|
|
309
451
|
return this.uniforms.diffuse.value;
|
310
452
|
},
|
311
453
|
set: function (value) {
|
312
|
-
|
313
|
-
|
454
|
+
this.uniforms.diffuse.value = value;
|
455
|
+
}
|
456
|
+
},
|
457
|
+
worldUnits: {
|
458
|
+
enumerable: true,
|
459
|
+
get: function () {
|
460
|
+
return 'WORLD_UNITS' in this.defines;
|
461
|
+
},
|
462
|
+
set: function (value) {
|
463
|
+
if (value === true) {
|
464
|
+
this.defines.WORLD_UNITS = '';
|
465
|
+
} else {
|
466
|
+
delete this.defines.WORLD_UNITS;
|
467
|
+
}
|
314
468
|
}
|
315
469
|
},
|
316
470
|
linewidth: {
|
@@ -322,6 +476,25 @@ class LineMaterial extends ShaderMaterial {
|
|
322
476
|
this.uniforms.linewidth.value = value;
|
323
477
|
}
|
324
478
|
},
|
479
|
+
dashed: {
|
480
|
+
enumerable: true,
|
481
|
+
get: function () {
|
482
|
+
return Boolean('USE_DASH' in this.defines);
|
483
|
+
},
|
484
|
+
|
485
|
+
set(value) {
|
486
|
+
if (Boolean(value) !== Boolean('USE_DASH' in this.defines)) {
|
487
|
+
this.needsUpdate = true;
|
488
|
+
}
|
489
|
+
|
490
|
+
if (value === true) {
|
491
|
+
this.defines.USE_DASH = '';
|
492
|
+
} else {
|
493
|
+
delete this.defines.USE_DASH;
|
494
|
+
}
|
495
|
+
}
|
496
|
+
|
497
|
+
},
|
325
498
|
dashScale: {
|
326
499
|
enumerable: true,
|
327
500
|
get: function () {
|
@@ -379,38 +552,21 @@ class LineMaterial extends ShaderMaterial {
|
|
379
552
|
alphaToCoverage: {
|
380
553
|
enumerable: true,
|
381
554
|
get: function () {
|
382
|
-
return Boolean('
|
555
|
+
return Boolean('USE_ALPHA_TO_COVERAGE' in this.defines);
|
383
556
|
},
|
384
557
|
set: function (value) {
|
385
|
-
if (Boolean(value) !== Boolean('
|
558
|
+
if (Boolean(value) !== Boolean('USE_ALPHA_TO_COVERAGE' in this.defines)) {
|
386
559
|
this.needsUpdate = true;
|
387
560
|
}
|
388
561
|
|
389
|
-
if (value) {
|
390
|
-
this.defines.
|
562
|
+
if (value === true) {
|
563
|
+
this.defines.USE_ALPHA_TO_COVERAGE = '';
|
391
564
|
this.extensions.derivatives = true;
|
392
565
|
} else {
|
393
|
-
delete this.defines.
|
566
|
+
delete this.defines.USE_ALPHA_TO_COVERAGE;
|
394
567
|
this.extensions.derivatives = false;
|
395
568
|
}
|
396
569
|
}
|
397
|
-
},
|
398
|
-
dashed: {
|
399
|
-
enumerable: true,
|
400
|
-
get: function () {
|
401
|
-
return Boolean('USE_DASH' in this.defines);
|
402
|
-
},
|
403
|
-
set: function (value) {
|
404
|
-
if (Boolean(value) !== Boolean('USE_DASH' in this.defines)) {
|
405
|
-
this.needsUpdate = true;
|
406
|
-
}
|
407
|
-
|
408
|
-
if (value) {
|
409
|
-
this.defines.USE_DASH = '';
|
410
|
-
} else {
|
411
|
-
delete this.defines.USE_DASH;
|
412
|
-
}
|
413
|
-
}
|
414
570
|
}
|
415
571
|
});
|
416
572
|
this.setValues(parameters);
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three"),e=require("./LineSegmentsGeometry.cjs.js"),n=require("./LineMaterial.cjs.js");const r=new t.Vector3,i=new t.Vector3,a=new t.Vector4,o=new t.Vector4,s=new t.Vector4,c=new t.Vector3,l=new t.Matrix4,u=new t.Line3,p=new t.Vector3,d=new t.Box3,f=new t.Sphere,m=new t.Vector4;let y,x,w,h;function b(t,e,n){return m.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),m.multiplyScalar(1/m.w),m.x=h/n.width,m.y=h/n.height,m.applyMatrix4(t.projectionMatrixInverse),m.multiplyScalar(1/m.w),Math.abs(Math.max(m.x,m.y))}class M extends t.Mesh{constructor(t=new e.LineSegmentsGeometry,r=new n.LineMaterial({color:16777215*Math.random()})){super(t,r),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,a=e.attributes.instanceEnd,o=new Float32Array(2*n.count);for(let t=0,e=0,s=n.count;t<s;t++,e+=2)r.fromBufferAttribute(n,t),i.fromBufferAttribute(a,t),o[e]=0===e?0:o[e-1],o[e+1]=o[e]+r.distanceTo(i);const s=new t.InstancedInterleavedBuffer(o,2,1);return e.setAttribute("instanceDistanceStart",new t.InterleavedBufferAttribute(s,1,0)),e.setAttribute("instanceDistanceEnd",new t.InterleavedBufferAttribute(s,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;null!==i||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const m=void 0!==e.params.Line2&&e.params.Line2.threshold||0;y=e.ray;const M=this.matrixWorld,S=this.geometry,g=this.material;let B,z;if(h=g.linewidth+m,x=S.attributes.instanceStart,w=S.attributes.instanceEnd,null===S.boundingSphere&&S.computeBoundingSphere(),f.copy(S.boundingSphere).applyMatrix4(M),r)B=.5*h;else{B=b(i,Math.max(i.near,f.distanceToPoint(y.origin)),g.resolution)}if(f.radius+=B,!1!==y.intersectsSphere(f)){if(null===S.boundingBox&&S.computeBoundingBox(),d.copy(S.boundingBox).applyMatrix4(M),r)z=.5*h;else{z=b(i,Math.max(i.near,d.distanceToPoint(y.origin)),g.resolution)}d.expandByScalar(z),!1!==y.intersectsBox(d)&&(r?function(e,n){for(let r=0,i=x.count;r<i;r++){u.start.fromBufferAttribute(x,r),u.end.fromBufferAttribute(w,r);const i=new t.Vector3,a=new t.Vector3;y.distanceSqToSegment(u.start,u.end,a,i),a.distanceTo(i)<.5*h&&n.push({point:a,pointOnLine:i,distance:y.origin.distanceTo(a),object:e,face:null,faceIndex:r,uv:null,uv2:null})}}(this,n):function(e,n,r){const i=n.projectionMatrix,d=e.material.resolution,f=e.matrixWorld,m=e.geometry,x=m.attributes.instanceStart,w=m.attributes.instanceEnd,b=-n.near;y.at(1,s),s.w=1,s.applyMatrix4(n.matrixWorldInverse),s.applyMatrix4(i),s.multiplyScalar(1/s.w),s.x*=d.x/2,s.y*=d.y/2,s.z=0,c.copy(s),l.multiplyMatrices(n.matrixWorldInverse,f);for(let n=0,s=x.count;n<s;n++){if(a.fromBufferAttribute(x,n),o.fromBufferAttribute(w,n),a.w=1,o.w=1,a.applyMatrix4(l),o.applyMatrix4(l),a.z>b&&o.z>b)continue;if(a.z>b){const t=a.z-o.z,e=(a.z-b)/t;a.lerp(o,e)}else if(o.z>b){const t=o.z-a.z,e=(o.z-b)/t;o.lerp(a,e)}a.applyMatrix4(i),o.applyMatrix4(i),a.multiplyScalar(1/a.w),o.multiplyScalar(1/o.w),a.x*=d.x/2,a.y*=d.y/2,o.x*=d.x/2,o.y*=d.y/2,u.start.copy(a),u.start.z=0,u.end.copy(o),u.end.z=0;const s=u.closestPointToPointParameter(c,!0);u.at(s,p);const m=t.MathUtils.lerp(a.z,o.z,s),M=m>=-1&&m<=1,S=c.distanceTo(p)<.5*h;if(M&&S){u.start.fromBufferAttribute(x,n),u.end.fromBufferAttribute(w,n),u.start.applyMatrix4(f),u.end.applyMatrix4(f);const i=new t.Vector3,a=new t.Vector3;y.distanceSqToSegment(u.start,u.end,a,i),r.push({point:a,pointOnLine:i,distance:y.origin.distanceTo(a),object:e,face:null,faceIndex:n,uv:null,uv2:null})}}}(this,i,n))}}}exports.LineSegments2=M;
|
package/lines/LineSegments2.d.ts
CHANGED
@@ -1,22 +1,14 @@
|
|
1
|
-
import { Mesh
|
2
|
-
|
3
|
-
import { LineMaterial } from '
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
import { Mesh } from 'three';
|
2
|
+
|
3
|
+
import { LineMaterial } from './LineMaterial';
|
4
|
+
import { LineSegmentsGeometry } from './LineSegmentsGeometry';
|
5
|
+
|
6
|
+
export class LineSegments2 extends Mesh {
|
7
|
+
geometry: LineSegmentsGeometry;
|
8
|
+
material: LineMaterial;
|
9
|
+
|
7
10
|
constructor(geometry?: LineSegmentsGeometry, material?: LineMaterial);
|
8
|
-
|
9
|
-
|
10
|
-
computeLineDistances
|
11
|
-
private rayStart;
|
12
|
-
private rayEnd;
|
13
|
-
private ssOrigin;
|
14
|
-
private ssOrigin3;
|
15
|
-
private mvMatrix;
|
16
|
-
private line;
|
17
|
-
private closestPoint;
|
18
|
-
raycast: (raycaster: Raycaster, intersects: Array<Intersection & {
|
19
|
-
pointOnLine: Vector3;
|
20
|
-
}>) => void;
|
11
|
+
readonly isLineSegments2: true;
|
12
|
+
|
13
|
+
computeLineDistances(): this;
|
21
14
|
}
|
22
|
-
export { LineSegments2 };
|