提交 7777df42 编写于 作者: M Mr.doob

Removed Rectangle.

上级 8b97c343
......@@ -14,8 +14,8 @@ THREE.SVGRenderer = function () {
_v1, _v2, _v3, _v4,
_clipRect = new THREE.Rectangle(),
_bboxRect = new THREE.Rectangle(),
_clipBox = new THREE.Box2(),
_elemBox = new THREE.Box2(),
_enableLighting = false,
_color = new THREE.Color(),
......@@ -69,7 +69,8 @@ THREE.SVGRenderer = function () {
_svg.setAttribute( 'width', _svgWidth );
_svg.setAttribute( 'height', _svgHeight );
_clipRect.set( - _svgWidthHalf, - _svgHeightHalf, _svgWidthHalf, _svgHeightHalf );
_clipBox.min.set( - _svgWidthHalf, - _svgHeightHalf );
_clipBox.max.set( _svgWidthHalf, _svgHeightHalf );
};
......@@ -121,7 +122,7 @@ THREE.SVGRenderer = function () {
if ( material === undefined || material.visible === false ) continue;
_bboxRect.empty();
_elemBox.makeEmpty();
if ( element instanceof THREE.RenderableParticle ) {
......@@ -137,17 +138,14 @@ THREE.SVGRenderer = function () {
_v1.positionScreen.x *= _svgWidthHalf; _v1.positionScreen.y *= - _svgHeightHalf;
_v2.positionScreen.x *= _svgWidthHalf; _v2.positionScreen.y *= - _svgHeightHalf;
_bboxRect.addPoint( _v1.positionScreen.x, _v1.positionScreen.y );
_bboxRect.addPoint( _v2.positionScreen.x, _v2.positionScreen.y );
_elemBox.setFromPoints( [ _v1.positionScreen, _v2.positionScreen ] );
if ( !_clipRect.intersects( _bboxRect ) ) {
if ( _clipBox.isIntersectionBox( _elemBox ) === true ) {
continue;
renderLine( _v1, _v2, element, material, scene );
}
renderLine( _v1, _v2, element, material, scene );
} else if ( element instanceof THREE.RenderableFace3 ) {
_v1 = element.v1; _v2 = element.v2; _v3 = element.v3;
......@@ -156,18 +154,14 @@ THREE.SVGRenderer = function () {
_v2.positionScreen.x *= _svgWidthHalf; _v2.positionScreen.y *= - _svgHeightHalf;
_v3.positionScreen.x *= _svgWidthHalf; _v3.positionScreen.y *= - _svgHeightHalf;
_bboxRect.addPoint( _v1.positionScreen.x, _v1.positionScreen.y );
_bboxRect.addPoint( _v2.positionScreen.x, _v2.positionScreen.y );
_bboxRect.addPoint( _v3.positionScreen.x, _v3.positionScreen.y );
_elemBox.setFromPoints( [ _v1.positionScreen, _v2.positionScreen, _v3.positionScreen ] );
if ( !_clipRect.intersects( _bboxRect ) ) {
if ( _clipBox.isIntersectionBox( _elemBox ) === true ) {
continue;
renderFace3( _v1, _v2, _v3, element, material, scene );
}
renderFace3( _v1, _v2, _v3, element, material, scene );
} else if ( element instanceof THREE.RenderableFace4 ) {
_v1 = element.v1; _v2 = element.v2; _v3 = element.v3; _v4 = element.v4;
......@@ -177,19 +171,14 @@ THREE.SVGRenderer = function () {
_v3.positionScreen.x *= _svgWidthHalf; _v3.positionScreen.y *= -_svgHeightHalf;
_v4.positionScreen.x *= _svgWidthHalf; _v4.positionScreen.y *= -_svgHeightHalf;
_bboxRect.addPoint( _v1.positionScreen.x, _v1.positionScreen.y );
_bboxRect.addPoint( _v2.positionScreen.x, _v2.positionScreen.y );
_bboxRect.addPoint( _v3.positionScreen.x, _v3.positionScreen.y );
_bboxRect.addPoint( _v4.positionScreen.x, _v4.positionScreen.y );
_elemBox.setFromPoints( [ _v1.positionScreen, _v2.positionScreen, _v3.positionScreen, _v4.positionScreen ] );
if ( !_clipRect.intersects( _bboxRect) ) {
if ( _clipBox.isIntersectionBox( _elemBox ) === true ) {
continue;
renderFace4( _v1, _v2, _v3, _v4, element, material, scene );
}
renderFace4( _v1, _v2, _v3, _v4, element, material, scene );
}
}
......
......@@ -196,8 +196,10 @@ THREE.Box2.prototype = {
// using 6 splitting planes to rule out intersections.
if ( ( box.max.x < this.min.x ) || ( box.min.x > this.max.x ) ||
( box.max.y < this.min.y ) || ( box.min.y > this.max.y ) ) {
if ( ( box.max.x < this.min.x ) ||
( box.min.x > this.max.x ) ||
( box.max.y < this.min.y ) ||
( box.min.y > this.max.y ) ) {
return false;
......
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.Rectangle = function () {
var _left = 0;
var _top = 0;
var _right = 0;
var _bottom = 0;
var _width = 0;
var _height = 0;
var _isEmpty = true;
function resize() {
_width = _right - _left;
_height = _bottom - _top;
}
this.getX = function () {
return _left;
};
this.getY = function () {
return _top;
};
this.getWidth = function () {
return _width;
};
this.getHeight = function () {
return _height;
};
this.getLeft = function() {
return _left;
};
this.getTop = function() {
return _top;
};
this.getRight = function() {
return _right;
};
this.getBottom = function() {
return _bottom;
};
this.set = function ( left, top, right, bottom ) {
_isEmpty = false;
_left = left; _top = top;
_right = right; _bottom = bottom;
resize();
};
this.addPoint = function ( x, y ) {
if ( _isEmpty === true ) {
_isEmpty = false;
_left = x; _top = y;
_right = x; _bottom = y;
resize();
} else {
_left = _left < x ? _left : x; // Math.min( _left, x );
_top = _top < y ? _top : y; // Math.min( _top, y );
_right = _right > x ? _right : x; // Math.max( _right, x );
_bottom = _bottom > y ? _bottom : y; // Math.max( _bottom, y );
resize();
}
};
this.add3Points = function ( x1, y1, x2, y2, x3, y3 ) {
if ( _isEmpty === true ) {
_isEmpty = false;
_left = x1 < x2 ? ( x1 < x3 ? x1 : x3 ) : ( x2 < x3 ? x2 : x3 );
_top = y1 < y2 ? ( y1 < y3 ? y1 : y3 ) : ( y2 < y3 ? y2 : y3 );
_right = x1 > x2 ? ( x1 > x3 ? x1 : x3 ) : ( x2 > x3 ? x2 : x3 );
_bottom = y1 > y2 ? ( y1 > y3 ? y1 : y3 ) : ( y2 > y3 ? y2 : y3 );
resize();
} else {
_left = x1 < x2 ? ( x1 < x3 ? ( x1 < _left ? x1 : _left ) : ( x3 < _left ? x3 : _left ) ) : ( x2 < x3 ? ( x2 < _left ? x2 : _left ) : ( x3 < _left ? x3 : _left ) );
_top = y1 < y2 ? ( y1 < y3 ? ( y1 < _top ? y1 : _top ) : ( y3 < _top ? y3 : _top ) ) : ( y2 < y3 ? ( y2 < _top ? y2 : _top ) : ( y3 < _top ? y3 : _top ) );
_right = x1 > x2 ? ( x1 > x3 ? ( x1 > _right ? x1 : _right ) : ( x3 > _right ? x3 : _right ) ) : ( x2 > x3 ? ( x2 > _right ? x2 : _right ) : ( x3 > _right ? x3 : _right ) );
_bottom = y1 > y2 ? ( y1 > y3 ? ( y1 > _bottom ? y1 : _bottom ) : ( y3 > _bottom ? y3 : _bottom ) ) : ( y2 > y3 ? ( y2 > _bottom ? y2 : _bottom ) : ( y3 > _bottom ? y3 : _bottom ) );
resize();
};
};
this.addRectangle = function ( r ) {
if ( _isEmpty === true ) {
_isEmpty = false;
_left = r.getLeft(); _top = r.getTop();
_right = r.getRight(); _bottom = r.getBottom();
resize();
} else {
_left = _left < r.getLeft() ? _left : r.getLeft(); // Math.min(_left, r.getLeft() );
_top = _top < r.getTop() ? _top : r.getTop(); // Math.min(_top, r.getTop() );
_right = _right > r.getRight() ? _right : r.getRight(); // Math.max(_right, r.getRight() );
_bottom = _bottom > r.getBottom() ? _bottom : r.getBottom(); // Math.max(_bottom, r.getBottom() );
resize();
}
};
this.inflate = function ( v ) {
_left -= v; _top -= v;
_right += v; _bottom += v;
resize();
};
this.minSelf = function ( r ) {
_left = _left > r.getLeft() ? _left : r.getLeft(); // Math.max( _left, r.getLeft() );
_top = _top > r.getTop() ? _top : r.getTop(); // Math.max( _top, r.getTop() );
_right = _right < r.getRight() ? _right : r.getRight(); // Math.min( _right, r.getRight() );
_bottom = _bottom < r.getBottom() ? _bottom : r.getBottom(); // Math.min( _bottom, r.getBottom() );
resize();
};
this.intersects = function ( r ) {
// http://gamemath.com/2011/09/detecting-whether-two-boxes-overlap/
if ( _right < r.getLeft() ) return false;
if ( _left > r.getRight() ) return false;
if ( _bottom < r.getTop() ) return false;
if ( _top > r.getBottom() ) return false;
return true;
};
this.empty = function () {
_isEmpty = true;
_left = 0; _top = 0;
_right = 0; _bottom = 0;
resize();
};
this.isEmpty = function () {
return _isEmpty;
};
};
......@@ -51,9 +51,9 @@ THREE.CanvasRenderer = function ( parameters ) {
_image, _uvs,
_uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y,
_clipBox2 = new THREE.Box2(),
_clearBox2 = new THREE.Box2(),
_elemBox2 = new THREE.Box2(),
_clipBox = new THREE.Box2(),
_clearBox = new THREE.Box2(),
_elemBox = new THREE.Box2(),
_enableLighting = false,
_ambientLight = new THREE.Color(),
......@@ -112,10 +112,10 @@ THREE.CanvasRenderer = function ( parameters ) {
_canvas.width = _canvasWidth;
_canvas.height = _canvasHeight;
_clipBox2.min.set( - _canvasWidthHalf, - _canvasHeightHalf );
_clipBox2.max.set( _canvasWidthHalf, _canvasHeightHalf );
_clearBox2.min.set( - _canvasWidthHalf, - _canvasHeightHalf );
_clearBox2.max.set( _canvasWidthHalf, _canvasHeightHalf );
_clipBox.min.set( - _canvasWidthHalf, - _canvasHeightHalf );
_clipBox.max.set( _canvasWidthHalf, _canvasHeightHalf );
_clearBox.min.set( - _canvasWidthHalf, - _canvasHeightHalf );
_clearBox.max.set( _canvasWidthHalf, _canvasHeightHalf );
_contextGlobalAlpha = 1;
_contextGlobalCompositeOperation = 0;
......@@ -132,8 +132,8 @@ THREE.CanvasRenderer = function ( parameters ) {
_clearColor.copy( color );
_clearOpacity = opacity !== undefined ? opacity : 1;
_clearBox2.min.set( - _canvasWidthHalf, - _canvasHeightHalf );
_clearBox2.max.set( _canvasWidthHalf, _canvasHeightHalf );
_clearBox.min.set( - _canvasWidthHalf, - _canvasHeightHalf );
_clearBox.max.set( _canvasWidthHalf, _canvasHeightHalf );
};
......@@ -142,8 +142,8 @@ THREE.CanvasRenderer = function ( parameters ) {
_clearColor.setHex( hex );
_clearOpacity = opacity !== undefined ? opacity : 1;
_clearBox2.min.set( - _canvasWidthHalf, - _canvasHeightHalf );
_clearBox2.max.set( _canvasWidthHalf, _canvasHeightHalf );
_clearBox.min.set( - _canvasWidthHalf, - _canvasHeightHalf );
_clearBox.max.set( _canvasWidthHalf, _canvasHeightHalf );
};
......@@ -157,14 +157,14 @@ THREE.CanvasRenderer = function ( parameters ) {
_context.setTransform( 1, 0, 0, - 1, _canvasWidthHalf, _canvasHeightHalf );
if ( _clearBox2.empty() === false ) {
if ( _clearBox.empty() === false ) {
_clearBox2.intersect( _clipBox2 );
_clearBox2.expandByScalar( 2 );
_clearBox.intersect( _clipBox );
_clearBox.expandByScalar( 2 );
if ( _clearOpacity < 1 ) {
_context.clearRect( _clearBox2.min.x | 0, _clearBox2.min.y | 0, ( _clearBox2.max.x - _clearBox2.min.x ) | 0, ( _clearBox2.max.y - _clearBox2.min.y ) | 0 );
_context.clearRect( _clearBox.min.x | 0, _clearBox.min.y | 0, ( _clearBox.max.x - _clearBox.min.x ) | 0, ( _clearBox.max.y - _clearBox.min.y ) | 0 );
}
......@@ -175,11 +175,11 @@ THREE.CanvasRenderer = function ( parameters ) {
setFillStyle( 'rgba(' + Math.floor( _clearColor.r * 255 ) + ',' + Math.floor( _clearColor.g * 255 ) + ',' + Math.floor( _clearColor.b * 255 ) + ',' + _clearOpacity + ')' );
_context.fillRect( _clearBox2.min.x | 0, _clearBox2.min.y | 0, ( _clearBox2.max.x - _clearBox2.min.x ) | 0, ( _clearBox2.max.y - _clearBox2.min.y ) | 0 );
_context.fillRect( _clearBox.min.x | 0, _clearBox.min.y | 0, ( _clearBox.max.x - _clearBox.min.x ) | 0, ( _clearBox.max.y - _clearBox.min.y ) | 0 );
}
_clearBox2.makeEmpty();
_clearBox.makeEmpty();
}
......@@ -210,7 +210,7 @@ THREE.CanvasRenderer = function ( parameters ) {
/* DEBUG
_context.fillStyle = 'rgba( 0, 255, 255, 0.5 )';
_context.fillRect( _clipBox2.min.x, _clipBox2.min.y, _clipBox2.max.x - _clipBox2.min.x, _clipBox2.max.y - _clipBox2.min.y );
_context.fillRect( _clipBox.min.x, _clipBox.min.y, _clipBox.max.x - _clipBox.min.x, _clipBox.max.y - _clipBox.min.y );
*/
_enableLighting = _lights.length > 0;
......@@ -229,7 +229,7 @@ THREE.CanvasRenderer = function ( parameters ) {
if ( material === undefined || material.visible === false ) continue;
_elemBox2.makeEmpty();
_elemBox.makeEmpty();
if ( element instanceof THREE.RenderableParticle ) {
......@@ -245,9 +245,9 @@ THREE.CanvasRenderer = function ( parameters ) {
_v1.positionScreen.x *= _canvasWidthHalf; _v1.positionScreen.y *= _canvasHeightHalf;
_v2.positionScreen.x *= _canvasWidthHalf; _v2.positionScreen.y *= _canvasHeightHalf;
_elemBox2.setFromPoints( [ _v1.positionScreen, _v2.positionScreen ] );
_elemBox.setFromPoints( [ _v1.positionScreen, _v2.positionScreen ] );
if ( _clipBox2.isIntersectionBox( _elemBox2 ) === true ) {
if ( _clipBox.isIntersectionBox( _elemBox ) === true ) {
renderLine( _v1, _v2, element, material, scene );
......@@ -270,9 +270,9 @@ THREE.CanvasRenderer = function ( parameters ) {
}
_elemBox2.setFromPoints( [ _v1.positionScreen, _v2.positionScreen, _v3.positionScreen ] );
_elemBox.setFromPoints( [ _v1.positionScreen, _v2.positionScreen, _v3.positionScreen ] );
if ( _clipBox2.isIntersectionBox( _elemBox2 ) === true ) {
if ( _clipBox.isIntersectionBox( _elemBox ) === true ) {
renderFace3( _v1, _v2, _v3, 0, 1, 2, element, material, scene );
......@@ -301,9 +301,9 @@ THREE.CanvasRenderer = function ( parameters ) {
}
_elemBox2.setFromPoints( [ _v1.positionScreen, _v2.positionScreen, _v3.positionScreen, _v4.positionScreen ] );
_elemBox.setFromPoints( [ _v1.positionScreen, _v2.positionScreen, _v3.positionScreen, _v4.positionScreen ] );
if ( _clipBox2.isIntersectionBox( _elemBox2 ) === true ) {
if ( _clipBox.isIntersectionBox( _elemBox ) === true ) {
renderFace4( _v1, _v2, _v3, _v4, _v5, _v6, element, material, scene );
......@@ -315,17 +315,17 @@ THREE.CanvasRenderer = function ( parameters ) {
/* DEBUG
_context.lineWidth = 1;
_context.strokeStyle = 'rgba( 0, 255, 0, 0.5 )';
_context.strokeRect( _elemBox2.min.x, _elemBox2.min.y, _elemBox2.max.x - _elemBox2.min.x, _elemBox2.max.y - _elemBox2.min.y );
_context.strokeRect( _elemBox.min.x, _elemBox.min.y, _elemBox.max.x - _elemBox.min.x, _elemBox.max.y - _elemBox.min.y );
*/
_clearBox2.union( _elemBox2 );
_clearBox.union( _elemBox );
}
/* DEBUG
_context.lineWidth = 1;
_context.strokeStyle = 'rgba( 255, 0, 0, 0.5 )';
_context.strokeRect( _clearBox2.min.x, _clearBox2.min.y, _clearBox2.max.x - _clearBox2.min.x, _clearBox2.max.y - _clearBox2.min.y );
_context.strokeRect( _clearBox.min.x, _clearBox.min.y, _clearBox.max.x - _clearBox.min.x, _clearBox.max.y - _clearBox.min.y );
*/
_context.setTransform( 1, 0, 0, 1, 0, 0 );
......@@ -436,10 +436,10 @@ THREE.CanvasRenderer = function ( parameters ) {
scaleX *= element.scale.x * _canvasWidthHalf;
scaleY *= element.scale.y * _canvasHeightHalf;
_elemBox2.min.set( v1.x - scaleX, v1.y - scaleY );
_elemBox2.max.set( v1.x + scaleX, v1.y + scaleY );
_elemBox.min.set( v1.x - scaleX, v1.y - scaleY );
_elemBox.max.set( v1.x + scaleX, v1.y + scaleY );
if ( _clipBox2.isIntersectionBox( _elemBox2 ) === false ) {
if ( _clipBox.isIntersectionBox( _elemBox ) === false ) {
return;
......@@ -468,10 +468,10 @@ THREE.CanvasRenderer = function ( parameters ) {
// TODO: Rotations break this...
_elemBox2.min.set( v1.x - width, v1.y - height );
_elemBox2.max.set( v1.x + width, v1.y + height );
_elemBox.min.set( v1.x - width, v1.y - height );
_elemBox.max.set( v1.x + width, v1.y + height );
if ( _clipBox2.isIntersectionBox( _elemBox2 ) === false ) {
if ( _clipBox.isIntersectionBox( _elemBox ) === false ) {
return;
......@@ -503,10 +503,10 @@ THREE.CanvasRenderer = function ( parameters ) {
width = element.scale.x * _canvasWidthHalf;
height = element.scale.y * _canvasHeightHalf;
_elemBox2.min.set( v1.x - width, v1.y - height );
_elemBox2.max.set( v1.x + width, v1.y + height );
_elemBox.min.set( v1.x - width, v1.y - height );
_elemBox.max.set( v1.x + width, v1.y + height );
if ( _clipBox2.isIntersectionBox( _elemBox2 ) === false ) {
if ( _clipBox.isIntersectionBox( _elemBox ) === false ) {
return;
......@@ -545,7 +545,7 @@ THREE.CanvasRenderer = function ( parameters ) {
setStrokeStyle( material.color.getStyle() );
_context.stroke();
_elemBox2.expandByScalar( material.linewidth * 2 );
_elemBox.expandByScalar( material.linewidth * 2 );
}
......@@ -922,7 +922,7 @@ THREE.CanvasRenderer = function ( parameters ) {
_context.stroke();
_elemBox2.expandByScalar( linewidth * 2 );
_elemBox.expandByScalar( linewidth * 2 );
}
......
......@@ -11,7 +11,6 @@
"../src/math/Sphere.js",
"../src/math/Plane.js",
"../src/math/Frustum.js",
"../src/math/Rectangle.js",
"../src/math/Math.js",
"../src/math/Triangle.js",
"../src/math/Quaternion.js",
......
......@@ -11,7 +11,6 @@
"../src/math/Ray.js",
"../src/math/Frustum.js",
"../src/math/Plane.js",
"../src/math/Rectangle.js",
"../src/math/Sphere.js",
"../src/math/Math.js",
"../src/math/Quaternion.js",
......
......@@ -11,7 +11,6 @@
"../src/math/Ray.js",
"../src/math/Frustum.js",
"../src/math/Plane.js",
"../src/math/Rectangle.js",
"../src/math/Sphere.js",
"../src/math/Math.js",
"../src/math/Quaternion.js",
......
......@@ -7,7 +7,6 @@
"../src/math/Matrix3.js",
"../src/math/Matrix4.js",
"../src/math/Frustum.js",
"../src/math/Rectangle.js",
"../src/math/Math.js",
"../src/math/Quaternion.js",
"../src/math/Vertex.js",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册