Webgl buffer / add utility getSize function

Saves checking whether the buffer was initialized with
an array already
This commit is contained in:
Olivier Guyot
2019-08-30 10:38:02 +02:00
parent e57e660819
commit c48350b666
3 changed files with 28 additions and 2 deletions

View File

@@ -95,6 +95,7 @@ class WebGLArrayBuffer {
}
/**
* Will return null if the buffer was not initialized
* @return {Float32Array|Uint32Array} Array.
*/
getArray() {
@@ -107,6 +108,14 @@ class WebGLArrayBuffer {
getUsage() {
return this.usage;
}
/**
* Will return 0 if the buffer is not initialized
* @return {number} Array size
*/
getSize() {
return this.array ? this.array.length : 0;
}
}
/**