Skip to content

Commit

Permalink
improved GeometryBuffer index handling
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Deubler <[email protected]>
  • Loading branch information
TerminalTim committed Oct 23, 2024
1 parent 2c0434d commit 2a32637
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions packages/display/src/displays/webgl/buffer/GeometryBuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,31 +213,23 @@ class GeometryBuffer {
}

private createIndex(index: number[] | Uint16Array | Uint32Array, i32?: boolean): IndexGrp {
const data = Array.isArray(index) ?
i32 ? new Uint32Array(index) : new Uint16Array(index)
: index;
// let i = index.length;
// while (i--) {
// if (index[i] > 0xffff) {
// i32 = true;
// break;
// }
// }
return {
index: i32 ? {
data: isTypedArray(index) ? (<Uint32Array>index) : new Uint32Array(index),
type: GL_UNSIGNED_INT,
length: index.length
} : {
data: isTypedArray(index) ? (<Uint16Array>index) : new Uint16Array(index),
type: GL_UNSIGNED_SHORT,
length: index.length
index: {
type: data.constructor == Uint32Array ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT,
length: index.length,
data
}
};


// return {
// index: i32 ? {
// data: new Uint32Array(3),
// // data: isTypedArray(index) ? (<Uint16Array | Uint32Array>index) : new Uint32Array(index),
// type: GL_UNSIGNED_INT,
// length: index.length
// } : {
// data: isTypedArray(index) ? index : new Uint16Array(index),
// type: GL_UNSIGNED_SHORT,
// length: index.length
// }
// };
}

private createArrays(arrays: ArrayData) {
Expand Down

0 comments on commit 2a32637

Please sign in to comment.