瀏覽代碼

PropertyBinding: Added morphTarget support with BufferGeometry

Mugen87 8 年之前
父節點
當前提交
f375cf243b
共有 1 個文件被更改,包括 33 次插入8 次删除
  1. 33 8
      src/animation/PropertyBinding.js

+ 33 - 8
src/animation/PropertyBinding.js

@@ -616,19 +616,44 @@ Object.assign( PropertyBinding.prototype, { // prototype, continued
 
 				}
 
-				if ( ! targetObject.geometry.morphTargets ) {
+				if ( targetObject.geometry.isBufferGeometry ) {
 
-					console.error( '  can not bind to morphTargetInfluences becasuse node does not have a geometry.morphTargets', this );
-					return;
+					if ( ! targetObject.geometry.morphAttributes ) {
 
-				}
+						console.error( '  can not bind to morphTargetInfluences becasuse node does not have a geometry.morphAttributes', this );
+						return;
+
+					}
+
+					for ( var i = 0; i < this.node.geometry.morphAttributes.position.length; i ++ ) {
 
-				for ( var i = 0; i < this.node.geometry.morphTargets.length; i ++ ) {
+						if ( targetObject.geometry.morphAttributes.position[ i ].name === propertyIndex ) {
+
+							propertyIndex = i;
+							break;
+
+						}
+
+					}
 
-					if ( targetObject.geometry.morphTargets[ i ].name === propertyIndex ) {
 
-						propertyIndex = i;
-						break;
+				} else {
+
+					if ( ! targetObject.geometry.morphTargets ) {
+
+						console.error( '  can not bind to morphTargetInfluences becasuse node does not have a geometry.morphTargets', this );
+						return;
+
+					}
+
+					for ( var i = 0; i < this.node.geometry.morphTargets.length; i ++ ) {
+
+						if ( targetObject.geometry.morphTargets[ i ].name === propertyIndex ) {
+
+							propertyIndex = i;
+							break;
+
+						}
 
 					}