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

46 lines (39 loc) 1.34 kB
'use strict'; var getAttributeInfoFromFormat = require('../../../../rendering/renderers/shared/geometry/utils/getAttributeInfoFromFormat.js'); "use strict"; function generateParticleUpdateFunction(properties) { return { dynamicUpdate: generateUpdateFunction(properties, true), staticUpdate: generateUpdateFunction(properties, false) }; } function generateUpdateFunction(properties, dynamic) { const funcFragments = []; funcFragments.push(` var index = 0; for (let i = 0; i < ps.length; ++i) { const p = ps[i]; `); let offset = 0; for (const i in properties) { const property = properties[i]; if (dynamic !== property.dynamic) continue; funcFragments.push(`offset = index + ${offset}`); funcFragments.push(property.code); const attributeInfo = getAttributeInfoFromFormat.getAttributeInfoFromFormat(property.format); offset += attributeInfo.stride / 4; } funcFragments.push(` index += stride * 4; } `); funcFragments.unshift(` var stride = ${offset}; `); const functionSource = funcFragments.join("\n"); return new Function("ps", "f32v", "u32v", functionSource); } exports.generateParticleUpdateFunction = generateParticleUpdateFunction; //# sourceMappingURL=generateParticleUpdateFunction.js.map