@@ -488,66 +488,39 @@ THREE.CanvasRenderer = function ( parameters ) {
488488
489489 }
490490
491- //
492-
493- var bitmap = texture . image ;
494-
495- if ( texture . repeat . x <= 1 && texture . repeat . y <= 1 ) { // rotation supported
496-
497- var ox = bitmap . width * texture . offset . x ;
498- var oy = bitmap . height * ( 1 - texture . offset . y - texture . repeat . y ) ;
499-
500- var sx = bitmap . width * texture . repeat . x ;
501- var sy = bitmap . height * texture . repeat . y ;
502-
503- _context . save ( ) ;
504-
505- _context . translate ( v1 . x , v1 . y ) ;
506-
507- if ( material . rotation !== 0 ) _context . rotate ( material . rotation ) ;
508-
509- _context . scale ( scaleX , - scaleY ) ;
510-
511- _context . drawImage ( bitmap , ox , oy , sx , sy , - 0.5 , - 0.5 , 1 , 1 ) ;
512-
513- _context . restore ( ) ;
514-
515- } else { // repeat.x or repeat.y > 1 // rotation not supported
516-
517- var ox = bitmap . width * texture . offset . x ;
518- var oy = bitmap . height * texture . offset . y ;
491+ var pattern = _patterns [ texture . id ] ;
519492
520- var sx = bitmap . width * texture . repeat . x ;
521- var sy = bitmap . height * texture . repeat . y ;
493+ if ( pattern !== undefined ) {
522494
523- var cx = sx / scaleX ;
524- var cy = sy / scaleY ;
495+ setFillStyle ( pattern ) ;
525496
526- var pattern = _patterns [ texture . id ] ;
527-
528- if ( pattern !== undefined ) {
529-
530- setFillStyle ( pattern ) ;
531-
532- } else {
533-
534- setFillStyle ( 'rgba( 0, 0, 0, 1 )' ) ;
497+ } else {
535498
536- }
499+ setFillStyle ( 'rgba( 0, 0, 0, 1 )' ) ;
537500
538- _context . save ( ) ;
501+ }
539502
540- _context . scale ( 1 / cx , 1 / cy ) ;
503+ //
541504
542- _context . translate ( v1 . x * cx - 0.5 * sx - ox , v1 . y * cy - 0.5 * sy - oy ) ;
505+ var bitmap = texture . image ;
543506
544- // if ( material.rotation !== 0 ) _context.rotate( material.rotation ); // rotation not supported when using patterns (origin is offset)
507+ var ox = bitmap . width * texture . offset . x ;
508+ var oy = bitmap . height * texture . offset . y ;
545509
546- _context . fillRect ( ox , oy , sx , sy ) ;
510+ var sx = bitmap . width * texture . repeat . x ;
511+ var sy = bitmap . height * texture . repeat . y ;
547512
548- _context . restore ( ) ;
513+ var cx = scaleX / sx ;
514+ var cy = scaleY / sy ;
549515
550- }
516+ _context . save ( ) ;
517+ _context . translate ( v1 . x , v1 . y ) ;
518+ if ( material . rotation !== 0 ) _context . rotate ( material . rotation ) ;
519+ _context . translate ( - scaleX / 2 , - scaleY / 2 ) ;
520+ _context . scale ( cx , cy ) ;
521+ _context . translate ( - ox , - oy ) ;
522+ _context . fillRect ( ox , oy , sx , sy ) ;
523+ _context . restore ( ) ;
551524
552525 } else { // no texture
553526
0 commit comments