pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
25 lines (23 loc) • 782 B
JavaScript
;
function createIndicesForQuads(size, outBuffer = null) {
const totalIndices = size * 6;
if (totalIndices > 65535) {
outBuffer || (outBuffer = new Uint32Array(totalIndices));
} else {
outBuffer || (outBuffer = new Uint16Array(totalIndices));
}
if (outBuffer.length !== totalIndices) {
throw new Error(`Out buffer length is incorrect, got ${outBuffer.length} and expected ${totalIndices}`);
}
for (let i = 0, j = 0; i < totalIndices; i += 6, j += 4) {
outBuffer[i + 0] = j + 0;
outBuffer[i + 1] = j + 1;
outBuffer[i + 2] = j + 2;
outBuffer[i + 3] = j + 0;
outBuffer[i + 4] = j + 2;
outBuffer[i + 5] = j + 3;
}
return outBuffer;
}
export { createIndicesForQuads };
//# sourceMappingURL=createIndicesForQuads.mjs.map