浏览代码

BufferGeometry: morphAttributes is now an object.

Mr.doob 10 年之前
父节点
当前提交
986df92c44
共有 3 个文件被更改,包括 14 次插入5 次删除
  1. 5 2
      src/core/BufferGeometry.js
  2. 1 1
      src/renderers/WebGLRenderer.js
  3. 8 2
      src/renderers/webgl/WebGLObjects.js

+ 5 - 2
src/core/BufferGeometry.js

@@ -14,7 +14,7 @@ THREE.BufferGeometry = function () {
 
 	this.attributes = {};
 
-	this.morphAttributes = [];
+	this.morphAttributes = {};
 
 	this.drawcalls = [];
 
@@ -344,6 +344,7 @@ THREE.BufferGeometry.prototype = {
 
 		if ( geometry.morphTargets.length > 0 ) {
 
+			var position = [];
 			var morphTargets = geometry.morphTargets;
 
 			for ( var i = 0, l = morphTargets.length; i < l; i ++ ) {
@@ -352,10 +353,12 @@ THREE.BufferGeometry.prototype = {
 
 				var attribute = new THREE.Float32Attribute( morphTarget.length * 3, 3 );
 
-				this.morphAttributes.push( attribute.copyVector3sArray( morphTarget ) );
+				position.push( attribute.copyVector3sArray( morphTarget ) );
 
 			}
 
+			this.morphAttributes.position = position;
+
 			// TODO normals, colors
 
 		}

+ 1 - 1
src/renderers/WebGLRenderer.js

@@ -919,7 +919,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				if ( influence[ 0 ] !== 0 ) {
 
-					var attribute = geometry.morphAttributes[ influence[ 1 ] ];
+					var attribute = geometry.morphAttributes.position[ influence[ 1 ] ];
 
 					geometry.addAttribute( 'morphTarget' + i, attribute );
 

+ 8 - 2
src/renderers/webgl/WebGLObjects.js

@@ -99,9 +99,15 @@ THREE.WebGLObjects = function ( gl, properties, info ) {
 
 		var morphAttributes = geometry.morphAttributes;
 
-		for ( var i = 0, l = morphAttributes.length; i < l; i ++ ) {
+		for ( var name in morphAttributes ) {
 
-			updateAttribute( morphAttributes[ i ], i );
+			var array = morphAttributes[ name ];
+
+			for ( var i = 0, l = array.length; i < l; i ++ ) {
+
+				updateAttribute( array[ i ], i );
+
+			}
 
 		}