Browse Source

Add clone property to BufferAttribute.js

Based off BufferGeometry implementation
dubejf 11 năm trước cách đây
mục cha
commit
b17e3a5d55
1 tập tin đã thay đổi với 25 bổ sung0 xóa
  1. 25 0
      src/core/BufferAttribute.js

+ 25 - 0
src/core/BufferAttribute.js

@@ -100,6 +100,31 @@ THREE.BufferAttribute.prototype = {
 
 
 		return this;
 		return this;
 
 
+	},
+
+	clone: function () {
+
+		var attribute = new THREE.BufferAttribute( null, this.itemSize );
+
+		var types = [ Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array ];
+
+		var sourceArray = this.array;
+
+		for ( var i = 0, il = types.length; i < il; i ++ ) {
+
+			var type = types[ i ];
+
+			if ( sourceArray instanceof type ) {
+
+				attribute.array = new type( sourceArray );
+				break;
+
+			}
+
+		}
+
+		return attribute;
+
 	}
 	}
 
 
 };
 };