Browse Source

BufferGeometry: Added setIndexArray(). See #10603.

Mr.doob 8 years ago
parent
commit
a8b8af084c
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/core/BufferGeometry.js

+ 7 - 1
src/core/BufferGeometry.js

@@ -1,7 +1,7 @@
 import { Vector3 } from '../math/Vector3';
 import { Box3 } from '../math/Box3';
 import { EventDispatcher } from './EventDispatcher';
-import { BufferAttribute, Float32BufferAttribute } from './BufferAttribute';
+import { BufferAttribute, Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from './BufferAttribute';
 import { Sphere } from '../math/Sphere';
 import { DirectGeometry } from './DirectGeometry';
 import { Object3D } from './Object3D';
@@ -56,6 +56,12 @@ BufferGeometry.prototype = {
 
 	},
 
+	setIndexArray: function ( indices ) {
+
+		this.index = new ( _Math.arrayMax( indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 );
+
+	},
+
 	addAttribute: function ( name, attribute ) {
 
 		if ( ( attribute && attribute.isBufferAttribute ) === false && ( attribute && attribute.isInterleavedBufferAttribute ) === false ) {