Skip to content

Commit 7701411

Browse files
authored
LineMaterial: Restore dashOffset. (#22749)
1 parent 00a6928 commit 7701411

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

examples/jsm/lines/LineMaterial.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* dashed: <boolean>,
66
* dashScale: <float>,
77
* dashSize: <float>,
8+
* dashOffset: <float>,
89
* gapSize: <float>,
910
* resolution: <Vector2>, // to be set by renderer
1011
* }
@@ -16,14 +17,15 @@ import {
1617
UniformsLib,
1718
UniformsUtils,
1819
Vector2
19-
} from "../../../build/three.module.js";
20+
} from '../../../build/three.module.js';
2021

2122

2223
UniformsLib.line = {
2324

2425
worldUnits: { value: 1 },
2526
linewidth: { value: 1 },
2627
resolution: { value: new Vector2( 1, 1 ) },
28+
dashOffset: { value: 0 },
2729
dashScale: { value: 1 },
2830
dashSize: { value: 1 },
2931
gapSize: { value: 1 } // todo FIX - maybe change to totalSize
@@ -39,7 +41,7 @@ ShaderLib[ 'line' ] = {
3941
] ),
4042

4143
vertexShader:
42-
/* glsl */`
44+
/* glsl */`
4345
#include <common>
4446
#include <color_pars_vertex>
4547
#include <fog_pars_vertex>
@@ -270,13 +272,14 @@ ShaderLib[ 'line' ] = {
270272
`,
271273

272274
fragmentShader:
273-
/* glsl */`
275+
/* glsl */`
274276
uniform vec3 diffuse;
275277
uniform float opacity;
276278
uniform float linewidth;
277279
278280
#ifdef USE_DASH
279281
282+
uniform float dashOffset;
280283
uniform float dashSize;
281284
uniform float gapSize;
282285
@@ -345,7 +348,7 @@ ShaderLib[ 'line' ] = {
345348
346349
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
347350
348-
if ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
351+
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
349352
350353
#endif
351354

0 commit comments

Comments
 (0)