Browse Source

* Workaround for Opera bug (clearRect not working with context with negative scale)
* Additional `Matrix4` and `Vector3` methods

Mr.doob 15 years ago
parent
commit
216b4eeee2

+ 6 - 0
README.md

@@ -130,6 +130,12 @@ Thanks to the power of the internets (and github <3) these people have kindly he
 
 
 ### Change Log ###
 ### Change Log ###
 
 
+2010 08 21 - **r16** (35.592 kb)
+
+* Workaround for Opera bug (clearRect not working with context with negative scale)
+* Additional `Matrix4` and `Vector3` methods
+
+
 2010 07 23 - **r15** (32.440 kb)
 2010 07 23 - **r15** (32.440 kb)
 
 
 * Using new object `UV` instead of `Vector2` where it should be used
 * Using new object `UV` instead of `Vector2` where it should be used

File diff suppressed because it is too large
+ 0 - 1
build/Three.js


File diff suppressed because it is too large
+ 0 - 1
build/ThreeDebug.js


+ 0 - 2
examples/camera_free.html

@@ -148,7 +148,6 @@
 
 
 				renderer = new THREE.CanvasRenderer();
 				renderer = new THREE.CanvasRenderer();
 				renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
 				renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
-				renderer.autoClear = false;
 
 
 				container.appendChild(renderer.domElement);
 				container.appendChild(renderer.domElement);
 
 
@@ -264,7 +263,6 @@
 				debugContext.closePath();
 				debugContext.closePath();
 				debugContext.stroke();
 				debugContext.stroke();
 
 
-				renderer.clear();
 				renderer.render(scene, camera);
 				renderer.render(scene, camera);
 
 
 				stats.update();
 				stats.update();

+ 2 - 0
src/core/Color.js

@@ -4,8 +4,10 @@
 
 
 THREE.Color = function ( hex ) {
 THREE.Color = function ( hex ) {
 
 
+	/*
 	this.r; this.g; this.b; this.a;
 	this.r; this.g; this.b; this.a;
 	this.hex;
 	this.hex;
+	*/
 
 
 	this.__styleString = 'rgba(0, 0, 0, 1)';
 	this.__styleString = 'rgba(0, 0, 0, 1)';
 
 

+ 10 - 5
src/core/Rectangle.js

@@ -2,12 +2,11 @@
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
  */
  */
 
 
-THREE.Rectangle = function ( x1, y1, x2, y2 ) {
+THREE.Rectangle = function () {
 
 
-	var _x1 = x1, _y1 = y1,
-	_x2 = x2, _y2 = y2,
-	_width = _x2 - _x1, _height = _y2 - _y1,
-	_isEmpty = false;
+	var _x1, _y1, _x2, _y2,
+	_width, _height,
+	_isEmpty = true;
 
 
 	function resize() {
 	function resize() {
 
 
@@ -162,6 +161,12 @@ THREE.Rectangle = function ( x1, y1, x2, y2 ) {
 
 
 	};
 	};
 
 
+	this.isEmpty = function () {
+
+		return _isEmpty;
+
+	};
+
 	this.toString = function () {
 	this.toString = function () {
 
 
 		return "THREE.Rectangle (x1: " + _x1 + ", y1: " + _y2 + ", x2: " + _x2 + ", y1: " + _y1 + ", width: " + _width + ", height: " + _height + ")";
 		return "THREE.Rectangle (x1: " + _x1 + ", y1: " + _y2 + ", x2: " + _x2 + ", y1: " + _y1 + ", width: " + _width + ", height: " + _height + ")";

+ 8 - 0
src/core/Vector3.js

@@ -104,6 +104,14 @@ THREE.Vector3.prototype = {
 
 
 	},
 	},
 
 
+	divideScalar: function ( s ) {
+
+		this.x /= s;
+		this.y /= s;
+		this.z /= s;
+
+	},
+
 	dot: function ( v ) {
 	dot: function ( v ) {
 
 
 		return this.x * v.x + this.y * v.y + this.z * v.z;
 		return this.x * v.x + this.y * v.y + this.z * v.z;

+ 23 - 9
src/renderers/CanvasRenderer.js

@@ -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 )  {

+ 1 - 1
utils/builder.py

@@ -3,7 +3,7 @@ import os
 
 
 # MERGER
 # MERGER
 
 
-rev = 14
+rev = 16
 
 
 files = []
 files = []
 files.append('Three.js')
 files.append('Three.js')

+ 1 - 1
utils/builder_debug.py

@@ -3,7 +3,7 @@ import os
 
 
 # MERGER
 # MERGER
 
 
-rev = 14
+rev = 16
 
 
 files = []
 files = []
 files.append('Three.js')
 files.append('Three.js')

Some files were not shown because too many files changed in this diff