@@ -29,6 +29,8 @@ THREE.CanvasRenderer = function ( parameters ) {
29
29
_contextLineWidth = null ,
30
30
_contextLineCap = null ,
31
31
_contextLineJoin = null ,
32
+ _contextDashSize = null ,
33
+ _contextGapSize = 0 ,
32
34
33
35
_v1 , _v2 , _v3 , _v4 ,
34
36
_v5 = new THREE . RenderableVertex ( ) ,
@@ -89,6 +91,21 @@ THREE.CanvasRenderer = function ( parameters ) {
89
91
90
92
_gradientMapQuality -- ; // Fix UVs
91
93
94
+ // 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
+ }
103
+ }
104
+ } else {
105
+ _context . setLineDash = function ( values ) { }
106
+ }
107
+ }
108
+
92
109
this . domElement = _canvas ;
93
110
94
111
this . devicePixelRatio = parameters . devicePixelRatio !== undefined
@@ -573,6 +590,18 @@ THREE.CanvasRenderer = function ( parameters ) {
573
590
setLineCap ( material . linecap ) ;
574
591
setLineJoin ( material . linejoin ) ;
575
592
setStrokeStyle ( material . color . getStyle ( ) ) ;
593
+ setDashAndGap ( null , null ) ;
594
+
595
+ _context . stroke ( ) ;
596
+ _elemBox . expandByScalar ( material . linewidth * 2 ) ;
597
+
598
+ } else if ( material instanceof THREE . LineDashedMaterial ) {
599
+
600
+ setLineWidth ( material . linewidth ) ;
601
+ setLineCap ( material . linecap ) ;
602
+ setLineJoin ( material . linejoin ) ;
603
+ setStrokeStyle ( material . color . getStyle ( ) ) ;
604
+ setDashAndGap ( material . dashSize , material . gapSize ) ;
576
605
577
606
_context . stroke ( ) ;
578
607
_elemBox . expandByScalar ( material . linewidth * 2 ) ;
@@ -1260,4 +1289,16 @@ THREE.CanvasRenderer = function ( parameters ) {
1260
1289
1261
1290
}
1262
1291
1292
+ function setDashAndGap ( dashSizeValue , gapSizeValue ) {
1293
+
1294
+ if ( _contextDashSize !== dashSizeValue || _contextGapSize !== gapSizeValue ) {
1295
+
1296
+ _context . setLineDash ( [ dashSizeValue , gapSizeValue ] ) ;
1297
+ _contextDashSize = dashSizeValue ;
1298
+ _contextGapSize = gapSizeValue ;
1299
+
1300
+ }
1301
+
1302
+ }
1303
+
1263
1304
} ;
0 commit comments