Files
Foundry-VTT-Docker/resources/app/node_modules/@pixi/particle-container/lib/ParticleRenderer.mjs.map

1 line
20 KiB
Plaintext
Raw Normal View History

2025-01-04 00:34:03 +01:00
{"version":3,"file":"ParticleRenderer.mjs","sources":["../src/ParticleRenderer.ts"],"sourcesContent":["import { Color, extensions, ExtensionType, Matrix, ObjectRenderer, Shader, State, TYPES, utils } from '@pixi/core';\nimport { ParticleBuffer } from './ParticleBuffer';\nimport fragment from './particles.frag';\nimport vertex from './particles.vert';\n\nimport type { ExtensionMetadata, Renderer } from '@pixi/core';\nimport type { Sprite } from '@pixi/sprite';\nimport type { ParticleContainer } from './ParticleContainer';\n\nexport interface IParticleRendererProperty\n{\n attributeName: string;\n size: number;\n type?: TYPES;\n uploadFunction: (...params: any[]) => any;\n offset: number;\n}\n\n/*\n * @author Mat Groves\n *\n * Big thanks to the very clever Matt DesLauriers <mattdesl> https://github.com/mattdesl/\n * for creating the original PixiJS version!\n * Also a thanks to https://github.com/bchevalier for tweaking the tint and alpha so that they now\n * share 4 bytes on the vertex buffer\n *\n * Heavily inspired by LibGDX's ParticleRenderer:\n * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/ParticleRenderer.java\n */\n\n/**\n * Renderer for Particles that is designer for speed over feature set.\n * @memberof PIXI\n */\nexport class ParticleRenderer extends ObjectRenderer\n{\n /** @ignore */\n static extension: ExtensionMetadata = {\n name: 'particle',\n type: ExtensionType.RendererPlugin,\n };\n\n /** The WebGL state in which this renderer will work. */\n public readonly state: State;\n\n /** The default shader that is used if a sprite doesn't have a more specific one. */\n public shader: Shader;\n public tempMatrix: Matrix;\n public properties: IParticleRendererProperty[];\n\n /**\n * @param renderer - The renderer this sprite batch works for.\n */\n constructor(renderer: Renderer)\n {\n super(renderer);\n\n // 65535 is max vertex index in the index buffer (see ParticleRenderer)\n // so max number of particles is 65536 / 4 = 16384\n // and max number of element in the index buffer is 16384 * 6 = 98304\n // Creating a full index buffer, overhead is 98304 * 2 = 196Ko\n // let numIndices = 98304;\n\n this.shader = null;\n\n this.properties = null;\n\n this.tempMatrix = new Matrix();\n\n this.properties = [\n // verticesData\n {\n attributeName: 'aVertexPosition',\n size: 2,\n uploadFunction: this.uploadVertices,\n offset: 0,\n },\n // positionData\n {\n attributeName: 'aPositionCoord',\n size: 2,\n uploadFunction: this.uploadPosition,\n offset: 0,\n },\n // rotationData\n {\n attributeName: 'aRotation',\n size: 1,\n uploadFunction: this.uploadRotation,\n offset: 0,\n },\n // uvsData\n {\n attributeName: 'aTextureCoord',\n size: 2,\n uploadFunction: this.uploadUvs,\n offset: 0,\n },\n // tintData\n {\n attributeName: 'aColor',\n size: 1,\n type: TYPES.UNSIGNED_BYTE,\n uploadFunction: this.uploadTint,\n offset: 0,\n },\n ];\n\n this.shader = Shader.from(vertex, fragment, {});\n this.state = State.for2d();\n }\n\n /**\n * Renders the particle container object.\n * @param container - The container to render using this ParticleRenderer.\n */\n public render(container: ParticleContainer): void\n {\n const children = container.children;\n const maxSize = container._maxSize;\n const batchSize = container._batchSize;\n const renderer = this.renderer;\n let totalChildren = children.length;\n\n