Browse Source

Copy BufferGeo to self or InstancedGeo

Ben Adams 10 years ago
parent
commit
c49dcddcdb
1 changed files with 27 additions and 0 deletions
  1. 27 0
      src/core/BufferGeometry.js

+ 27 - 0
src/core/BufferGeometry.js

@@ -1209,6 +1209,33 @@ THREE.BufferGeometry.prototype = {
 		return geometry;
 
 	},
+	
+	copy: function ( geometry ) {
+		
+		for ( var attr in geometry.attributes ) {
+
+			var sourceAttr = geometry.attributes[attr];
+			this.addAttribute( attr, sourceAttr.clone() );
+
+		}
+
+		for ( var i = 0, il = geometry.offsets.length; i < il; i++ ) {
+
+			var offset = geometry.offsets[i];
+
+			this.offsets.push( {
+
+				start: offset.start,
+				index: offset.index,
+				count: offset.count
+
+			} );
+
+		}
+
+		return this;
+
+	},
 
 	dispose: function () {