|
@@ -10,7 +10,7 @@ THREE.CanvasRenderer = function () {
|
|
_context = _canvas.getContext( '2d' ),
|
|
_context = _canvas.getContext( '2d' ),
|
|
_width, _height, _widthHalf, _heightHalf,
|
|
_width, _height, _widthHalf, _heightHalf,
|
|
_clipRect = new THREE.Rectangle(),
|
|
_clipRect = new THREE.Rectangle(),
|
|
- _clearRect = new THREE.Rectangle( 0, 0, 0, 0 ),
|
|
|
|
|
|
+ _clearRect = new THREE.Rectangle(),
|
|
_bboxRect = new THREE.Rectangle(),
|
|
_bboxRect = new THREE.Rectangle(),
|
|
_vector2 = new THREE.Vector2(),
|
|
_vector2 = new THREE.Vector2(),
|
|
|
|
|
|
@@ -28,19 +28,29 @@ THREE.CanvasRenderer = function () {
|
|
_canvas.width = _width;
|
|
_canvas.width = _width;
|
|
_canvas.height = _height;
|
|
_canvas.height = _height;
|
|
|
|
|
|
- _context.setTransform( 1, 0, 0, -1, _widthHalf, _heightHalf );
|
|
|
|
-
|
|
|
|
_clipRect.set( - _widthHalf, - _heightHalf, _widthHalf, _heightHalf );
|
|
_clipRect.set( - _widthHalf, - _heightHalf, _widthHalf, _heightHalf );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
this.clear = function () {
|
|
this.clear = function () {
|
|
|
|
|
|
- _clearRect.inflate( 1 );
|
|
|
|
- _clearRect.minSelf( _clipRect );
|
|
|
|
- _context.clearRect( _clearRect.getX(), _clearRect.getY(), _clearRect.getWidth(), _clearRect.getHeight() );
|
|
|
|
- _clearRect.empty();
|
|
|
|
|
|
+ if ( !_clearRect.isEmpty() ) {
|
|
|
|
+
|
|
|
|
+ _clearRect.inflate( 1 );
|
|
|
|
+ _clearRect.minSelf( _clipRect );
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ _context.setTransform( 1, 0, 0, - 1, _widthHalf, _heightHalf );
|
|
|
|
+ _context.clearRect( _clearRect.getX(), _clearRect.getY(), _clearRect.getWidth(), _clearRect.getHeight() );
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ // Opera workaround
|
|
|
|
+ _context.setTransform( 1, 0, 0, 1, _widthHalf, _heightHalf );
|
|
|
|
+ _context.clearRect( _clearRect.getX(), - ( _clearRect.getHeight() + _clearRect.getY() ), _clearRect.getWidth(), _clearRect.getHeight() );
|
|
|
|
+
|
|
|
|
+ _clearRect.empty();
|
|
|
|
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
this.render = function ( scene, camera ) {
|
|
this.render = function ( scene, camera ) {
|
|
@@ -50,19 +60,21 @@ THREE.CanvasRenderer = function () {
|
|
width, height, scaleX, scaleY, offsetX, offsetY,
|
|
width, height, scaleX, scaleY, offsetX, offsetY,
|
|
bitmap, bitmapWidth, bitmapHeight;
|
|
bitmap, bitmapWidth, bitmapHeight;
|
|
|
|
|
|
|
|
+ this.project( scene, camera );
|
|
|
|
+
|
|
if ( this.autoClear ) {
|
|
if ( this.autoClear ) {
|
|
|
|
|
|
this.clear();
|
|
this.clear();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ _context.setTransform( 1, 0, 0, - 1, _widthHalf, _heightHalf );
|
|
|
|
+
|
|
/* DEBUG
|
|
/* DEBUG
|
|
_context.fillStyle = 'rgba(0, 255, 255, 0.5)';
|
|
_context.fillStyle = 'rgba(0, 255, 255, 0.5)';
|
|
_context.fillRect( _clipRect.getX(), _clipRect.getY(), _clipRect.getWidth(), _clipRect.getHeight() );
|
|
_context.fillRect( _clipRect.getX(), _clipRect.getY(), _clipRect.getWidth(), _clipRect.getHeight() );
|
|
*/
|
|
*/
|
|
|
|
|
|
- this.project( scene, camera );
|
|
|
|
-
|
|
|
|
for ( e = 0, el = this.renderList.length; e < el; e++ ) {
|
|
for ( e = 0, el = this.renderList.length; e < el; e++ ) {
|
|
|
|
|
|
element = this.renderList[ e ];
|
|
element = this.renderList[ e ];
|
|
@@ -497,6 +509,8 @@ THREE.CanvasRenderer = function () {
|
|
_context.strokeRect( _clearRect.getX(), _clearRect.getY(), _clearRect.getWidth(), _clearRect.getHeight() );
|
|
_context.strokeRect( _clearRect.getX(), _clearRect.getY(), _clearRect.getWidth(), _clearRect.getHeight() );
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
+ _context.setTransform( 1, 0, 0, 1, 0, 0 );
|
|
|
|
+
|
|
};
|
|
};
|
|
|
|
|
|
function drawTexturedTriangle( bitmap, v1x, v1y, v2x, v2y, v3x, v3y, uv1u, uv1v, uv2u, uv2v, uv3u, uv3v ) {
|
|
function drawTexturedTriangle( bitmap, v1x, v1y, v2x, v2y, v3x, v3y, uv1u, uv1v, uv2u, uv2v, uv3u, uv3v ) {
|