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 • 4.17 kB
Source Map (JSON)
{"version":3,"file":"ensureAttributes.mjs","sources":["../../../../../../src/rendering/renderers/gl/shader/program/ensureAttributes.ts"],"sourcesContent":["import { warn } from '../../../../../utils/logging/warn';\nimport { getAttributeInfoFromFormat } from '../../../shared/geometry/utils/getAttributeInfoFromFormat';\n\nimport type { Geometry } from '../../../shared/geometry/Geometry';\nimport type { ExtractedAttributeData } from './extractAttributesFromGlProgram';\n\n/**\n * This function looks at the attribute information provided to the geometry and attempts\n * to fill in any gaps. We do this by looking at the extracted data from the shader and\n * making best guesses.\n *\n * Most of the time users don't need to provide all the attribute info beyond the data itself, so we\n * can fill in the gaps for them. If you are using attributes in a more advanced way,\n * don't forget to add all the info at creation!\n * @param geometry - the geometry to ensure attributes for\n * @param extractedData - the extracted data from the shader\n * @internal\n */\nexport function ensureAttributes(\n geometry: Geometry,\n extractedData: Record<string, ExtractedAttributeData>\n): void\n{\n for (const i in geometry.attributes)\n {\n const attribute = geometry.attributes[i];\n const attributeData = extractedData[i];\n\n if (attributeData)\n {\n attribute.format ??= attributeData.format;\n attribute.offset ??= attributeData.offset;\n attribute.instance ??= attributeData.instance;\n }\n else\n {\n // eslint-disable-next-line max-len\n warn(`Attribute ${i} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`);\n }\n }\n\n ensureStartAndStride(geometry);\n}\n\nfunction ensureStartAndStride(geometry: Geometry): void\n{\n const { buffers, attributes } = geometry;\n\n const tempStride: Record<string, number> = {};\n const tempStart: Record<string, number> = {};\n\n for (const j in buffers)\n {\n const buffer = buffers[j];\n\n tempStride[buffer.uid] = 0;\n tempStart[buffer.uid] = 0;\n }\n\n for (const j in attributes)\n {\n const attribute = attributes[j];\n\n tempStride[attribute.buffer.uid] += getAttributeInfoFromFormat(attribute.format).stride;\n }\n\n for (const j in attributes)\n {\n const attribute = attributes[j];\n\n attribute.stride ??= tempStride[attribute.buffer.uid];\n\n attribute.start ??= tempStart[attribute.buffer.uid];\n\n tempStart[attribute.buffer.uid] += getAttributeInfoFromFormat(attribute.format).stride;\n }\n}\n"],"names":[],"mappings":";;;;AAkBO,SAAS,gBAAA,CACZ,UACA,aAAA,EAEJ;AACI,EAAA,KAAA,MAAW,CAAA,IAAK,SAAS,UAAA,EACzB;AACI,IAAA,MAAM,SAAA,GAAY,QAAA,CAAS,UAAA,CAAW,CAAC,CAAA;AACvC,IAAA,MAAM,aAAA,GAAgB,cAAc,CAAC,CAAA;AAErC,IAAA,IAAI,aAAA,EACJ;AACI,MAAA,SAAA,CAAU,MAAA,KAAV,SAAA,CAAU,MAAA,GAAW,aAAA,CAAc,MAAA,CAAA;AACnC,MAAA,SAAA,CAAU,MAAA,KAAV,SAAA,CAAU,MAAA,GAAW,aAAA,CAAc,MAAA,CAAA;AACnC,MAAA,SAAA,CAAU,QAAA,KAAV,SAAA,CAAU,QAAA,GAAa,aAAA,CAAc,QAAA,CAAA;AAAA,IACzC,CAAA,MAEA;AAEI,MAAA,IAAA,CAAK,CAAA,UAAA,EAAa,CAAC,CAAA,iGAAA,CAAmG,CAAA;AAAA,IAC1H;AAAA,EACJ;AAEA,EAAA,oBAAA,CAAqB,QAAQ,CAAA;AACjC;AAEA,SAAS,qBAAqB,QAAA,EAC9B;AACI,EAAA,MAAM,EAAE,OAAA,EAAS,UAAA,EAAW,GAAI,QAAA;AAEhC,EAAA,MAAM,aAAqC,EAAC;AAC5C,EAAA,MAAM,YAAoC,EAAC;AAE3C,EAAA,KAAA,MAAW,KAAK,OAAA,EAChB;AACI,IAAA,MAAM,MAAA,GAAS,QAAQ,CAAC,CAAA;AAExB,IAAA,UAAA,CAAW,MAAA,CAAO,GAAG,CAAA,GAAI,CAAA;AACzB,IAAA,SAAA,CAAU,MAAA,CAAO,GAAG,CAAA,GA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