( v1, element, material )
| 15728 | } |
| 15729 | |
| 15730 | function renderSprite( v1, element, material ) { |
| 15731 | |
| 15732 | setOpacity( material.opacity ); |
| 15733 | setBlending( material.blending ); |
| 15734 | |
| 15735 | var width, height, scaleX, scaleY, |
| 15736 | bitmap, bitmapWidth, bitmapHeight; |
| 15737 | |
| 15738 | if ( material instanceof THREE.SpriteMaterial || |
| 15739 | material instanceof THREE.ParticleSystemMaterial ) { // Backwards compatibility |
| 15740 | |
| 15741 | if ( material.map.image !== undefined ) { |
| 15742 | |
| 15743 | bitmap = material.map.image; |
| 15744 | bitmapWidth = bitmap.width >> 1; |
| 15745 | bitmapHeight = bitmap.height >> 1; |
| 15746 | |
| 15747 | scaleX = element.scale.x * _canvasWidthHalf; |
| 15748 | scaleY = element.scale.y * _canvasHeightHalf; |
| 15749 | |
| 15750 | width = scaleX * bitmapWidth; |
| 15751 | height = scaleY * bitmapHeight; |
| 15752 | |
| 15753 | // TODO: Rotations break this... |
| 15754 | |
| 15755 | _elemBox.min.set( v1.x - width, v1.y - height ); |
| 15756 | _elemBox.max.set( v1.x + width, v1.y + height ); |
| 15757 | |
| 15758 | if ( _clipBox.isIntersectionBox( _elemBox ) === false ) { |
| 15759 | |
| 15760 | _elemBox.makeEmpty(); |
| 15761 | return; |
| 15762 | |
| 15763 | } |
| 15764 | |
| 15765 | _context.save(); |
| 15766 | _context.translate( v1.x, v1.y ); |
| 15767 | _context.rotate( - element.rotation ); |
| 15768 | _context.scale( scaleX, - scaleY ); |
| 15769 | |
| 15770 | _context.translate( - bitmapWidth, - bitmapHeight ); |
| 15771 | _context.drawImage( bitmap, 0, 0 ); |
| 15772 | _context.restore(); |
| 15773 | |
| 15774 | } else { |
| 15775 | |
| 15776 | scaleX = element.object.scale.x; |
| 15777 | scaleY = element.object.scale.y; |
| 15778 | |
| 15779 | // TODO: Be able to disable this |
| 15780 | |
| 15781 | scaleX *= element.scale.x * _canvasWidthHalf; |
| 15782 | scaleY *= element.scale.y * _canvasHeightHalf; |
| 15783 | |
| 15784 | _elemBox.min.set( v1.x - scaleX, v1.y - scaleY ); |
| 15785 | _elemBox.max.set( v1.x + scaleX, v1.y + scaleY ); |
| 15786 | |
| 15787 | if ( _clipBox.isIntersectionBox( _elemBox ) === false ) { |
no test coverage detected