Skip to content

Commit 75431f7

Browse files
committed
Simplified CanvasRenderer line dash code.
1 parent 5089e05 commit 75431f7

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/renderers/CanvasRenderer.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,23 @@ THREE.CanvasRenderer = function ( parameters ) {
9292
_gradientMapQuality --; // Fix UVs
9393

9494
// dash+gap fallbacks for Firefox and everything else
95-
if( ! _context.setLineDash ) {
96-
if( 'mozDash' in _context ) {
97-
_context.setLineDash = function( values ) {
98-
if( values[0] == null || values[1] == null) {
99-
_context.mozDash = null;
100-
} else {
101-
_context.mozDash = values;
102-
}
95+
96+
if ( _context.setLineDash === undefined ) {
97+
98+
if ( _context.mozDash !== undefined ) {
99+
100+
_context.setLineDash = function ( values ) {
101+
102+
_context.mozDash = values[ 0 ] !== null ? values : null;
103+
103104
}
105+
104106
} else {
105-
_context.setLineDash = function( values ) {}
107+
108+
_context.setLineDash = function ( values ) {}
109+
106110
}
111+
107112
}
108113

109114
this.domElement = _canvas;
@@ -1291,12 +1296,12 @@ THREE.CanvasRenderer = function ( parameters ) {
12911296

12921297
function setDashAndGap( dashSizeValue, gapSizeValue ) {
12931298

1294-
if( _contextDashSize !== dashSizeValue || _contextGapSize !== gapSizeValue ) {
1295-
1296-
_context.setLineDash([ dashSizeValue, gapSizeValue ]);
1299+
if ( _contextDashSize !== dashSizeValue || _contextGapSize !== gapSizeValue ) {
1300+
1301+
_context.setLineDash( [ dashSizeValue, gapSizeValue ] );
12971302
_contextDashSize = dashSizeValue;
12981303
_contextGapSize = gapSizeValue;
1299-
1304+
13001305
}
13011306

13021307
}

0 commit comments

Comments
 (0)