{"version":3,"file":"particleData.mjs","sources":["../../../../src/scene/particle-container/shared/particleData.ts"],"sourcesContent":["import type { VertexFormat } from '../../../rendering/renderers/shared/geometry/const';\nimport type { IParticle } from './Particle';\n\n/** @internal */\nexport interface ParticleRendererProperty\n{\n    attributeName: string;\n    format: VertexFormat;\n    code: string;\n    dynamic: boolean;\n    // optional update function if you have customized this stuff and need it to work with unsafe-eval\n    updateFunction?: (ps: IParticle[], f32v: Float32Array, u32v: Uint32Array, offset: number, stride: number) => void;\n}\n\n/** @internal */\nexport const particleData = {\n    vertex: {\n        attributeName: 'aVertex',\n        format: 'float32x2',\n        code: `\n            const texture = p.texture;\n            const sx = p.scaleX;\n            const sy = p.scaleY;\n            const ax = p.anchorX;\n            const ay = p.anchorY;\n            const trim = texture.trim;\n            const orig = texture.orig;\n\n            if (trim)\n            {\n                w1 = trim.x - (ax * orig.width);\n                w0 = w1 + trim.width;\n\n                h1 = trim.y - (ay * orig.height);\n                h0 = h1 + trim.height;\n            }\n            else\n            {\n                w1 = -ax * (orig.width);\n                w0 = w1 + orig.width;\n\n                h1 = -ay * (orig.height);\n                h0 = h1 + orig.height;\n            }\n\n            f32v[offset] = w1 * sx;\n            f32v[offset + 1] = h1 * sy;\n\n            f32v[offset + stride] = w0 * sx;\n            f32v[offset + stride + 1] = h1 * sy;\n\n            f32v[offset + (stride * 2)] = w0 * sx;\n            f32v[offset + (stride * 2) + 1] = h0 * sy;\n\n            f32v[offset + (stride * 3)] = w1 * sx;\n            f32v[offset + (stride * 3) + 1] = h0 * sy;\n        `,\n        dynamic: false,\n    },\n    // positionData\n    position: {\n        attributeName: 'aPosition',\n        format: 'float32x2',\n        code: `\n            var x = p.x;\n            var y = p.y;\n\n            f32v[offset] = x;\n            f32v[offset + 1] = y;\n\n            f32v[offset + stride] = x;\n            f32v[offset + stride + 1] = y;\n\n            f32v[offset + (stride * 2)] = x;\n            f32v[offset + (stride * 2) + 1] = y;\n\n            f32v[offset + (stride * 3)] = x;\n            f32v[offset + (stride * 3) + 1] = y;\n        `,\n        dynamic: true,\n    },\n    // rotationData\n    rotation: {\n        attributeName: 'aRotation',\n        format: 'float32',\n        code: `\n            var rotation = p.rotation;\n\n            f32v[offset] = rotation;\n            f32v[offset + stride] = rotation;\n            f32v[offset + (stride * 2)] = rotation;\n            f32v[offset + (stride * 3)] = rotation;\n        `,\n        dynamic: false,\n    },\n    // uvsData\n    uvs: {\n        attributeName: 'aUV',\n        format: 'float32x2',\n        code: `\n            var uvs = p.texture.uvs;\n\n            f32v[offset] = uvs.x0;\n            f32v[offset + 1] = uvs.y0;\n\n            f32v[offset + stride] = uvs.x1;\n            f32v[offset + stride + 1] = uvs.y1;\n\n            f32v[offset + (stride * 2)] = uvs.x2;\n            f32v[offset + (stride * 2) + 1] = uvs.y2;\n\n            f32v[offset + (stride * 3)] = uvs.x3;\n            f32v[offset + (stride * 3) + 1] = uvs.y3;\n        `,\n        dynamic: false,\n    },\n    // tintData\n    color: {\n        attributeName: 'aColor',\n        format: 'unorm8x4',\n        code: `\n            const c = p.color;\n\n            u32v[offset] = c;\n            u32v[offset + stride] = c;\n            u32v[offset + (stride * 2)] = c;\n            u32v[offset + (stride * 3)] = c;\n        `,\n        dynamic: false,\n    },\n} as Record<string, ParticleRendererProperty>;\n"],"names":[],"mappings":";AAeO,MAAM,YAAA,GAAe;AAAA,EACxB,MAAA,EAAQ;AAAA,IACJ,aAAA,EAAe,SAAA;AAAA,IACf,MAAA,EAAQ,WAAA;AAAA,IACR,IAAA,EAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,IAsCN,OAAA,EAAS;AAAA,GACb;AAAA;AAAA,EAEA,QAAA,EAAU;AAAA,IACN,aAAA,EAAe,WAAA;A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