Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ThinEngine.updateDynamicIndexBuffer #12564

Merged
merged 5 commits into from
May 25, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/dev/core/src/Engines/Extensions/engine.dynamicBuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ ThinEngine.prototype.updateDynamicIndexBuffer = function (this: ThinEngine, inde
this.bindIndexBuffer(indexBuffer);
let arrayBuffer;

if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
arrayBuffer = indices;
} else {
arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
if (indexBuffer.is32Bits) {
// anything else than Uint32Array needs to be converted to Uint32Array
arrayBuffer = indices instanceof Uint32Array ? indices : Uint32Array.from(indices)
}
else {
// anything else than Uint16Array needs to be converted to Uint16Array
arrayBuffer = indices instanceof Uint16Array ? indices : Uint16Array.from(indices)
barroij marked this conversation as resolved.
Show resolved Hide resolved
}

this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
Expand Down