浏览代码

Merge pull request #13888 from WestLangley/dev-texture_update_matrix

Add Texture.updateMatrix() method
Mr.doob 7 年之前
父节点
当前提交
9b7e901438
共有 3 个文件被更改,包括 21 次插入19 次删除
  1. 13 7
      docs/api/textures/Texture.html
  2. 2 12
      src/renderers/WebGLRenderer.js
  3. 6 0
      src/textures/Texture.js

+ 13 - 7
docs/api/textures/Texture.html

@@ -154,21 +154,21 @@
 
 		<h3>[property:Vector2 center]</h3>
 		<p>
-		Indicates where the center of rotation is. To rotate around the center point set this value to (0.5, 0.5). Default value is (0.0, 0.0).
+		The point around which rotation occurs. A value of (0.5, 0.5) corresponds to the center of the texture. Default is (0, 0), the lower left.
 		</p>
 
 		<h3>[property:boolean matrixAutoUpdate]</h3>
 		<p>
-		Whether to update the texture's uv-transform [property:Matrix3 matrix] based on the [property:Vector2 offset],
-		[property:Vector2 repeat], and [property:number rotation] settings. True by default.
+		Whether to update the texture's uv-transform [page:Texture.matrix .matrix] from the texture properties [page:Texture.offset .offset], [page:Texture.repeat .repeat],
+		[page:Texture.rotation .rotation], and [page:Texture.center .center]. True by default.
 		Set this to false if you are specifying the uv-transform matrix directly.
 		</p>
 
 		<h3>[property:Matrix3 matrix]</h3>
 		<p>
-		The uv-transform matrix for the texture. Updated by the renderer from the texture properties [property:Vector2 offset], [property:Vector2 repeat],
-		and [property:number rotation] when the texture's [property:boolean matrixAutoUpdate] property is true.
-		When [property:boolean matrixAutoUpdate] property is false, this matrix may be set manually.
+		The uv-transform matrix for the texture. Updated by the renderer from the texture properties [page:Texture.offset .offset], [page:Texture.repeat .repeat],
+		[page:Texture.rotation .rotation], and [page:Texture.center .center] when the texture's [page:Texture.matrixAutoUpdate .matrixAutoUpdate] property is true.
+		When [page:Texture.matrixAutoUpdate .matrixAutoUpdate] property is false, this matrix may be set manually.
 		Default is the identity matrix.
 		</p>
 
@@ -228,6 +228,12 @@
 
 		<h3>[page:EventDispatcher EventDispatcher] methods are available on this class.</h3>
 
+		<h3>[method:null updateMatrix]()</h3>
+		<p>
+		Update the texture's uv-transform [page:Texture.matrix .matrix] from the texture properties [page:Texture.offset .offset], [page:Texture.repeat .repeat],
+		[page:Texture.rotation .rotation], and [page:Texture.center .center].
+		</p>
+
 		<h3>[method:Texture clone]( [param:Texture texture] )</h3>
 		<p>
 		Make copy of the texture. Note this is not a "deep copy", the image is shared.
@@ -246,7 +252,7 @@
 
 		<h3>[method:null transformUv]( uv )</h3>
 		<p>
-		Transform the uv based on the value of this texture's [page:Texture.repeat .repeat], [page:Texture.offset .offset],
+		Transform the uv based on the value of this texture's [page:Texture.offset .offset], [page:Texture.repeat .repeat],
 		[page:Texture.wrapS .wrapS], [page:Texture.wrapT .wrapT] and [page:Texture.flipY .flipY] properties.
 		</p>
 

+ 2 - 12
src/renderers/WebGLRenderer.js

@@ -2050,12 +2050,7 @@ function WebGLRenderer( parameters ) {
 
 			if ( uvScaleMap.matrixAutoUpdate === true ) {
 
-				var offset = uvScaleMap.offset;
-				var repeat = uvScaleMap.repeat;
-				var rotation = uvScaleMap.rotation;
-				var center = uvScaleMap.center;
-
-				uvScaleMap.matrix.setUvTransform( offset.x, offset.y, repeat.x, repeat.y, rotation, center.x, center.y );
+				uvScaleMap.updateMatrix();
 
 			}
 
@@ -2093,12 +2088,7 @@ function WebGLRenderer( parameters ) {
 
 			if ( material.map.matrixAutoUpdate === true ) {
 
-				var offset = material.map.offset;
-				var repeat = material.map.repeat;
-				var rotation = material.map.rotation;
-				var center = material.map.center;
-
-				material.map.matrix.setUvTransform( offset.x, offset.y, repeat.x, repeat.y, rotation, center.x, center.y );
+				material.map.updateMatrix();
 
 			}
 

+ 6 - 0
src/textures/Texture.js

@@ -70,6 +70,12 @@ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
 
 	isTexture: true,
 
+	updateMatrix: function () {
+
+		this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y );
+
+	},
+
 	clone: function () {
 
 		return new this.constructor().copy( this );