소스 검색

InstancedBufferGeometry: Fix .copy() and .clone()

Mugen87 8 년 전
부모
커밋
af197833fe
2개의 변경된 파일10개의 추가작업 그리고 35개의 파일을 삭제
  1. 4 1
      examples/webgl_buffergeometry_instancing_billboards.html
  2. 6 34
      src/core/InstancedBufferGeometry.js

+ 4 - 1
examples/webgl_buffergeometry_instancing_billboards.html

@@ -139,7 +139,10 @@
 			scene = new THREE.Scene();
 
 			geometry = new THREE.InstancedBufferGeometry();
-			geometry.copy( new THREE.CircleBufferGeometry( 1, 6 ) );
+			var circleGeometry = new THREE.CircleBufferGeometry( 1, 6 );
+
+			geometry.index = circleGeometry.index;
+			geometry.attributes = circleGeometry.attributes;
 
 			var particleCount = 75000;
 

+ 6 - 34
src/core/InstancedBufferGeometry.js

@@ -19,47 +19,19 @@ InstancedBufferGeometry.prototype = Object.assign( Object.create( BufferGeometry
 
 	isInstancedBufferGeometry: true,
 
-	addGroup: function ( start, count, materialIndex ) {
-
-		this.groups.push( {
-
-			start: start,
-			count: count,
-			materialIndex: materialIndex
-
-		} );
-
-	},
-
 	copy: function ( source ) {
 
-		var index = source.index;
-
-		if ( index !== null ) {
-
-			this.setIndex( index.clone() );
+		BufferGeometry.prototype.copy.call( this, source );
 
-		}
+		this.maxInstancedCount = source.maxInstancedCount;
 
-		var attributes = source.attributes;
-
-		for ( var name in attributes ) {
-
-			var attribute = attributes[ name ];
-			this.addAttribute( name, attribute.clone() );
-
-		}
-
-		var groups = source.groups;
-
-		for ( var i = 0, l = groups.length; i < l; i ++ ) {
+		return this;
 
-			var group = groups[ i ];
-			this.addGroup( group.start, group.count, group.materialIndex );
+	},
 
-		}
+	clone: function () {
 
-		return this;
+		return new this.constructor().copy( this );
 
 	}