Browse Source

Add typechecking for array argument in BufferAttribute (#9445)

Younes Riad 9 years ago
parent
commit
3d2dd7aba7
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/core/BufferAttribute.js

+ 6 - 0
src/core/BufferAttribute.js

@@ -10,6 +10,12 @@ import { _Math } from '../math/Math';
 
 function BufferAttribute( array, itemSize, normalized ) {
 
+	if (array.buffer instanceof ArrayBuffer === false) {
+
+		throw new TypeError( 'THREE.BufferAttribute: array should be an instance of Uint8Array, Int8Array, Uint16Array, Int16Array, or Float32Array.' );
+
+	}
+
 	this.uuid = _Math.generateUUID();
 
 	this.array = array;