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.27 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 an gaps. WE do this by looking at the extracted data from the shader and\n * making best guesses.\n *\n * Most of th etime 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, you can\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":";;;;AAkBgB,SAAA,gBAAA,CACZ,UACA,aAEJ,EAAA;AACI,EAAW,KAAA,MAAA,CAAA,IAAK,SAAS,UACzB,EAAA;AACI,IAAM,MAAA,SAAA,GAAY,QAAS,CAAA,UAAA,CAAW,CAAC,CAAA,CAAA;AACvC,IAAM,MAAA,aAAA,GAAgB,cAAc,CAAC,CAAA,CAAA;AAErC,IAAA,IAAI,aACJ,EAAA;AACI,MAAU,SAAA,CAAA,MAAA,KAAV,SAAU,CAAA,MAAA,GAAW,aAAc,CAAA,MAAA,CAAA,CAAA;AACnC,MAAU,SAAA,CAAA,MAAA,KAAV,SAAU,CAAA,MAAA,GAAW,aAAc,CAAA,MAAA,CAAA,CAAA;AACnC,MAAU,SAAA,CAAA,QAAA,KAAV,SAAU,CAAA,QAAA,GAAa,aAAc,CAAA,QAAA,CAAA,CAAA;AAAA,KAGzC,MAAA;AAEI,MAAK,IAAA,CAAA,CAAA,UAAA,EAAa,CAAC,CAAmG,iGAAA,CAAA,CAAA,CAAA;AAAA,KAC1H;AAAA,GACJ;AAEA,EAAA,oBAAA,CAAqB,QAAQ,CAAA,CAAA;AACjC,CAAA;AAEA,SAAS,qBAAqB,QAC9B,EAAA;AACI,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,QAAA,CAAA;AAEhC,EAAA,MAAM,aAAqC,EAAC,CAAA;AAC5C,EAAA,MAAM,YAAoC,EAAC,CAAA;AAE3C,EAAA,KAAA,MAAW,KAAK,OAChB,EAAA;AACI,IAAM,MAAA,MAAA,GAAS,QAAQ,CAAC,CAAA,CAAA;AAExB,IAAW,UAAA,CAAA,MAAA,CAAO,G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