|
|
@@ -6,7 +6,7 @@ import { materialColor, materialLineScale, materialLineDashSize, materialLineGap
|
|
|
import { modelViewMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
|
import { positionGeometry } from '../../nodes/accessors/Position.js';
|
|
|
import { mix, smoothstep } from '../../nodes/math/MathNode.js';
|
|
|
-import { Fn, varying, float, vec2, vec3, vec4, If } from '../../nodes/tsl/TSLBase.js';
|
|
|
+import { Fn, float, vec2, vec3, vec4, If } from '../../nodes/tsl/TSLBase.js';
|
|
|
import { uv } from '../../nodes/accessors/UV.js';
|
|
|
import { viewport } from '../../nodes/display/ScreenNode.js';
|
|
|
import { dashSize, gapSize } from '../../nodes/core/PropertyNode.js';
|
|
|
@@ -94,6 +94,21 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
const start = vec4( modelViewMatrix.mul( vec4( instanceStart, 1.0 ) ) ).toVar( 'start' );
|
|
|
const end = vec4( modelViewMatrix.mul( vec4( instanceEnd, 1.0 ) ) ).toVar( 'end' );
|
|
|
|
|
|
+ if ( useDash ) {
|
|
|
+
|
|
|
+ const dashScaleNode = this.dashScaleNode ? float( this.dashScaleNode ) : materialLineScale;
|
|
|
+ const offsetNode = this.offsetNode ? float( this.offsetNodeNode ) : materialLineDashOffset;
|
|
|
+
|
|
|
+ const instanceDistanceStart = attribute( 'instanceDistanceStart' );
|
|
|
+ const instanceDistanceEnd = attribute( 'instanceDistanceEnd' );
|
|
|
+
|
|
|
+ let lineDistance = positionGeometry.y.lessThan( 0.5 ).select( dashScaleNode.mul( instanceDistanceStart ), dashScaleNode.mul( instanceDistanceEnd ) );
|
|
|
+ lineDistance = lineDistance.add( offsetNode );
|
|
|
+
|
|
|
+ varyingProperty( 'float', 'lineDistance' ).assign( lineDistance );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
if ( useWorldUnits ) {
|
|
|
|
|
|
varyingProperty( 'vec3', 'worldStart' ).assign( start.xyz );
|
|
|
@@ -258,24 +273,16 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
|
|
|
if ( useDash ) {
|
|
|
|
|
|
- const offsetNode = this.offsetNode ? float( this.offsetNodeNode ) : materialLineDashOffset;
|
|
|
- const dashScaleNode = this.dashScaleNode ? float( this.dashScaleNode ) : materialLineScale;
|
|
|
const dashSizeNode = this.dashSizeNode ? float( this.dashSizeNode ) : materialLineDashSize;
|
|
|
const gapSizeNode = this.dashSizeNode ? float( this.dashGapNode ) : materialLineGapSize;
|
|
|
|
|
|
dashSize.assign( dashSizeNode );
|
|
|
gapSize.assign( gapSizeNode );
|
|
|
|
|
|
- const instanceDistanceStart = attribute( 'instanceDistanceStart' );
|
|
|
- const instanceDistanceEnd = attribute( 'instanceDistanceEnd' );
|
|
|
-
|
|
|
- const lineDistance = positionGeometry.y.lessThan( 0.5 ).select( dashScaleNode.mul( instanceDistanceStart ), materialLineScale.mul( instanceDistanceEnd ) );
|
|
|
-
|
|
|
- const vLineDistance = varying( lineDistance.add( materialLineDashOffset ) );
|
|
|
- const vLineDistanceOffset = offsetNode ? vLineDistance.add( offsetNode ) : vLineDistance;
|
|
|
+ const vLineDistance = varyingProperty( 'float', 'lineDistance' );
|
|
|
|
|
|
vUv.y.lessThan( - 1.0 ).or( vUv.y.greaterThan( 1.0 ) ).discard(); // discard endcaps
|
|
|
- vLineDistanceOffset.mod( dashSize.add( gapSize ) ).greaterThan( dashSize ).discard(); // todo - FIX
|
|
|
+ vLineDistance.mod( dashSize.add( gapSize ) ).greaterThan( dashSize ).discard(); // todo - FIX
|
|
|
|
|
|
}
|
|
|
|