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 3.11 kB
{"version":3,"file":"generateParticleUpdateFunction.mjs","sources":["../../../../../src/scene/particle-container/shared/utils/generateParticleUpdateFunction.ts"],"sourcesContent":["import {\n getAttributeInfoFromFormat\n} from '../../../../rendering/renderers/shared/geometry/utils/getAttributeInfoFromFormat';\n\nimport type { IParticle } from '../Particle';\nimport type { ParticleRendererProperty } from '../particleData';\n\n// TODO rename to update function\n/** @internal */\nexport type ParticleUpdateFunction = (ps: IParticle[], f32v: Float32Array, u32v: Uint32Array) => void;\n\n/**\n * @param properties\n * @internal\n */\nexport function generateParticleUpdateFunction(properties: Record<string, ParticleRendererProperty>)\n{\n return {\n dynamicUpdate: generateUpdateFunction(properties, true),\n staticUpdate: generateUpdateFunction(properties, false),\n };\n}\n\nfunction generateUpdateFunction(\n properties: Record<string, ParticleRendererProperty>,\n dynamic: boolean\n): ParticleUpdateFunction\n{\n const funcFragments: string[] = [];\n\n funcFragments.push(`\n\n var index = 0;\n\n for (let i = 0; i < ps.length; ++i)\n {\n const p = ps[i];\n\n `);\n\n let offset = 0;\n\n for (const i in properties)\n {\n const property = properties[i];\n\n if (dynamic !== property.dynamic) continue;\n\n funcFragments.push(`offset = index + ${offset}`);\n\n funcFragments.push(property.code);\n\n const attributeInfo = getAttributeInfoFromFormat(property.format);\n\n offset += attributeInfo.stride / 4;\n }\n\n funcFragments.push(`\n index += stride * 4;\n }\n `);\n\n // add to the front..\n funcFragments.unshift(`\n var stride = ${offset};\n `);\n\n const functionSource = funcFragments.join('\\n');\n\n // eslint-disable-next-line no-new-func\n return new Function('ps', 'f32v', 'u32v', functionSource) as ParticleUpdateFunction;\n}\n"],"names":[],"mappings":";;;AAeO,SAAS,+BAA+B,UAC/C,EAAA;AACI,EAAO,OAAA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