UNPKG

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">

1 lines 2.52 kB
{"version":3,"file":"createIndicesForQuads.mjs","sources":["../../../../../src/scene/particle-container/shared/utils/createIndicesForQuads.ts"],"sourcesContent":["/**\n * Generic Mask Stack data structure\n * @function createIndicesForQuads\n * @param {number} size - Number of quads\n * @param {Uint16Array|Uint32Array} [outBuffer] - Buffer for output, length has to be `6 * size`\n * @returns {Uint16Array|Uint32Array} - Resulting index buffer\n * @internal\n */\nexport function createIndicesForQuads(\n size: number,\n outBuffer: Uint16Array | Uint32Array | null = null\n): Uint16Array | Uint32Array\n{\n // the total number of indices in our array, there are 6 points per quad.\n const totalIndices = size * 6;\n\n // Check if we need to use Uint32Array\n if (totalIndices > 65535)\n {\n outBuffer ||= new Uint32Array(totalIndices); // Use Uint32Array if needed\n }\n else\n {\n outBuffer ||= new Uint16Array(totalIndices);\n }\n\n if (outBuffer.length !== totalIndices)\n {\n throw new Error(`Out buffer length is incorrect, got ${outBuffer.length} and expected ${totalIndices}`);\n }\n\n // fill the indices with the quads to draw\n for (let i = 0, j = 0; i < totalIndices; i += 6, j += 4)\n {\n outBuffer[i + 0] = j + 0;\n outBuffer[i + 1] = j + 1;\n outBuffer[i + 2] = j + 2;\n outBuffer[i + 3] = j + 0;\n outBuffer[i + 4] = j + 2;\n outBuffer[i + 5] = j + 3;\n }\n\n return outBuffer;\n}\n"],"names":[],"mappings":";AAQgB,SAAA,qBAAA,CACZ,IACA,EAAA,SAAA,GAA8C,IAElD,EAAA;AAEI,EAAA,MAAM,eAAe,IAAO,GAAA,CAAA,CAAA;AAG5B,EAAA,IAAI,eAAe,KACnB,EAAA;AACI,IAAc,SAAA,KAAA,SAAA,GAAA,IAAI,YAAY,YAAY,CAAA,CAAA,CAAA;AAAA,GAG9C,MAAA;AACI,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