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 5.09 kB
{"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,YAAe,GAAA;AAAA,EACxB,MAAQ,EAAA;AAAA,IACJ,aAAe,EAAA,SAAA;AAAA,IACf,MAAQ,EAAA,WAAA;AAAA,IACR,IAAM,EAAA,CAAA;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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,IAsCN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