Skip to content

Commit 3ac4ade

Browse files
aardgoosemrdoob
authored andcommitted
Buffer attribute size is fixed at creation. Remove unneeded recalculations (mrdoob#9658)
* remove repeated calculation from renderer * remove now redundant getter
1 parent d2399c7 commit 3ac4ade

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/core/BufferAttribute.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function BufferAttribute( array, itemSize, normalized ) {
2020

2121
this.array = array;
2222
this.itemSize = itemSize;
23+
this.count = array.length / itemSize;
2324
this.normalized = normalized === true;
2425

2526
this.dynamic = false;
@@ -35,12 +36,6 @@ BufferAttribute.prototype = {
3536

3637
isBufferAttribute: true,
3738

38-
get count() {
39-
40-
return this.array.length / this.itemSize;
41-
42-
},
43-
4439
set needsUpdate( value ) {
4540

4641
if ( value === true ) this.version ++;
@@ -59,6 +54,7 @@ BufferAttribute.prototype = {
5954

6055
this.array = new source.array.constructor( source.array );
6156
this.itemSize = source.itemSize;
57+
this.count = source.count;
6258
this.normalized = source.normalized;
6359

6460
this.dynamic = source.dynamic;

src/core/InterleavedBuffer.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function InterleavedBuffer( array, stride ) {
1010

1111
this.array = array;
1212
this.stride = stride;
13+
this.count = array.length / stride;
1314

1415
this.dynamic = false;
1516
this.updateRange = { offset: 0, count: - 1 };
@@ -30,12 +31,6 @@ InterleavedBuffer.prototype = {
3031

3132
},
3233

33-
get count () {
34-
35-
return this.array.length / this.stride;
36-
37-
},
38-
3934
set needsUpdate( value ) {
4035

4136
if ( value === true ) this.version ++;
@@ -53,6 +48,7 @@ InterleavedBuffer.prototype = {
5348
copy: function ( source ) {
5449

5550
this.array = new source.array.constructor( source.array );
51+
this.count = source.count;
5652
this.stride = source.stride;
5753
this.dynamic = source.dynamic;
5854

0 commit comments

Comments
 (0)