Browse Source

Buffer attribute size is fixed at creation. Remove unneeded recalculations (#9658)

* remove repeated calculation from renderer

* remove now redundant getter
aardgoose 9 years ago
parent
commit
3ac4adefcc
2 changed files with 4 additions and 12 deletions
  1. 2 6
      src/core/BufferAttribute.js
  2. 2 6
      src/core/InterleavedBuffer.js

+ 2 - 6
src/core/BufferAttribute.js

@@ -20,6 +20,7 @@ function BufferAttribute( array, itemSize, normalized ) {
 
 	this.array = array;
 	this.itemSize = itemSize;
+	this.count = array.length / itemSize;
 	this.normalized = normalized === true;
 
 	this.dynamic = false;
@@ -35,12 +36,6 @@ BufferAttribute.prototype = {
 
 	isBufferAttribute: true,
 
-	get count() {
-
-		return this.array.length / this.itemSize;
-
-	},
-
 	set needsUpdate( value ) {
 
 		if ( value === true ) this.version ++;
@@ -59,6 +54,7 @@ BufferAttribute.prototype = {
 
 		this.array = new source.array.constructor( source.array );
 		this.itemSize = source.itemSize;
+		this.count = source.count;
 		this.normalized = source.normalized;
 
 		this.dynamic = source.dynamic;

+ 2 - 6
src/core/InterleavedBuffer.js

@@ -10,6 +10,7 @@ function InterleavedBuffer( array, stride ) {
 
 	this.array = array;
 	this.stride = stride;
+	this.count = array.length / stride;
 
 	this.dynamic = false;
 	this.updateRange = { offset: 0, count: - 1 };
@@ -30,12 +31,6 @@ InterleavedBuffer.prototype = {
 
 	},
 
-	get count () {
-
-		return this.array.length / this.stride;
-
-	},
-
 	set needsUpdate( value ) {
 
 		if ( value === true ) this.version ++;
@@ -53,6 +48,7 @@ InterleavedBuffer.prototype = {
 	copy: function ( source ) {
 
 		this.array = new source.array.constructor( source.array );
+		this.count = source.count;
 		this.stride = source.stride;
 		this.dynamic = source.dynamic;