浏览代码

Sprite: material.uvOffset/uvScale to material.map.offset/repeat.
Sadly I don’t know how how to maintain backwards compatibility in a nice way. Nor show a deprecated message :/

Mr.doob 11 年之前
父节点
当前提交
063b88a9df
共有 3 个文件被更改,包括 13 次插入10 次删除
  1. 2 2
      examples/webgl_sprites.html
  2. 11 2
      src/extras/renderers/plugins/SpritePlugin.js
  3. 0 6
      src/materials/SpriteMaterial.js

+ 2 - 2
examples/webgl_sprites.html

@@ -76,8 +76,8 @@
 
 
 						material = materialC.clone();
 						material = materialC.clone();
 						material.color.setHSL( 0.5 * Math.random(), 0.75, 0.5 );
 						material.color.setHSL( 0.5 * Math.random(), 0.75, 0.5 );
-						material.uvScale.set( 2, 2 );
-						material.uvOffset.set( -0.5, -0.5 );
+						material.map.offset.set( -0.5, -0.5 );
+						material.map.repeat.set( 2, 2 );
 
 
 					}
 					}
 
 

+ 11 - 2
src/extras/renderers/plugins/SpritePlugin.js

@@ -194,8 +194,17 @@ THREE.SpritePlugin = function () {
 
 
 			}
 			}
 
 
-			_gl.uniform2f( uniforms.uvScale, material.uvScale.x, material.uvScale.y );
-			_gl.uniform2f( uniforms.uvOffset, material.uvOffset.x, material.uvOffset.y );
+			if ( material.map !== null ) {
+
+				_gl.uniform2f( uniforms.uvOffset, material.map.offset.x, material.map.offset.y );
+				_gl.uniform2f( uniforms.uvScale, material.map.repeat.x, material.map.repeat.y );
+
+			} else {
+
+				_gl.uniform2f( uniforms.uvOffset, 0, 0 );
+				_gl.uniform2f( uniforms.uvScale, 1, 1 );
+
+			}
 
 
 			_gl.uniform1f( uniforms.opacity, material.opacity );
 			_gl.uniform1f( uniforms.opacity, material.opacity );
 			_gl.uniform3f( uniforms.color, material.color.r, material.color.g, material.color.b );
 			_gl.uniform3f( uniforms.color, material.color.r, material.color.g, material.color.b );

+ 0 - 6
src/materials/SpriteMaterial.js

@@ -30,9 +30,6 @@ THREE.SpriteMaterial = function ( parameters ) {
 
 
 	this.fog = false;
 	this.fog = false;
 
 
-	this.uvOffset = new THREE.Vector2( 0, 0 );
-	this.uvScale  = new THREE.Vector2( 1, 1 );
-
 	// set parameters
 	// set parameters
 
 
 	this.setValues( parameters );
 	this.setValues( parameters );
@@ -52,9 +49,6 @@ THREE.SpriteMaterial.prototype.clone = function () {
 
 
 	material.rotation = this.rotation;
 	material.rotation = this.rotation;
 
 
-	material.uvOffset.copy( this.uvOffset );
-	material.uvScale.copy( this.uvScale );
-
 	material.fog = this.fog;
 	material.fog = this.fog;
 
 
 	return material;
 	return material;