Browse Source

More canvas renderer texture tweaks.

Mr.doob 11 years ago
parent
commit
fcfe0d0502
2 changed files with 13 additions and 11 deletions
  1. 8 8
      examples/misc_ubiquity_test2.html
  2. 5 3
      src/renderers/CanvasRenderer.js

+ 8 - 8
examples/misc_ubiquity_test2.html

@@ -76,9 +76,9 @@
 						tex.repeat.y = 0.1 * THREE.Math.randInt( 1, 3 );
 
 						var material = new THREE.SpriteMaterial( { map: tex } );
-						var sprite = new THREE.Sprite( material );
+						material.rotation = 0.5 * Math.PI * ( Math.random() - 0.5 );
 
-						sprite.material.rotation = 0.5 * Math.PI * ( Math.random() - 0.5 );
+						var sprite = new THREE.Sprite( material );
 
 						sprite.position.x = Math.random() * 1000 - 500;
 						sprite.position.y = Math.random() * 1000 - 500;
@@ -119,17 +119,17 @@
 
 				// SPRITES - PNG
 
-				for ( var i = 0; i < 20; i ++ ) {
+				texture3 = THREE.ImageUtils.loadTexture( 'textures/sprite1.png' );
+				texture3.wrapS = THREE.ClampToEdgeWrapping;
+				texture3.wrapT = THREE.ClampToEdgeWrapping;
 
-					texture3 = THREE.ImageUtils.loadTexture( 'textures/sprite1.png' );
-					texture3.wrapS = THREE.ClampToEdgeWrapping;
-					texture3.wrapT = THREE.ClampToEdgeWrapping;
+				for ( var i = 0; i < 20; i ++ ) {
 
 					var material = new THREE.SpriteMaterial( { map: texture3 } );
+					material.rotation = 2 * Math.PI * ( Math.random() - 0.5 );
+					
 					var sprite = new THREE.Sprite( material );
 
-					sprite.material.rotation = 2 * Math.PI * ( Math.random() - 0.5 );
-
 					sprite.position.x = Math.random() * 1000 - 500;
 					sprite.position.y = Math.random() * 1000 - 500;
 					sprite.position.z = Math.random() * 1000 - 500;

+ 5 - 3
src/renderers/CanvasRenderer.js

@@ -445,11 +445,11 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 			var texture = material.map;
 
-			if ( texture !== null ) {
+			if ( texture !== null && texture.image !== undefined ) {
 
 				if ( texture.hasEventListener( 'update', onTextureUpdate ) === false ) {
 
-					if ( texture.image !== undefined && texture.image.width > 0 ) {
+					if ( texture.image.width > 0 ) {
 
 						textureToPattern( texture );
 
@@ -647,7 +647,9 @@ THREE.CanvasRenderer = function ( parameters ) {
 				 ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin )
 				 : fillPath( _color );
 
-		} else if ( material instanceof THREE.MeshBasicMaterial || material instanceof THREE.MeshLambertMaterial || material instanceof THREE.MeshPhongMaterial ) {
+		} else if ( material instanceof THREE.MeshBasicMaterial ||
+				    material instanceof THREE.MeshLambertMaterial ||
+				    material instanceof THREE.MeshPhongMaterial ) {
 
 			if ( material.map !== null ) {