1 line
11 KiB
Plaintext
1 line
11 KiB
Plaintext
|
|
{"version":3,"file":"ParticleContainer.mjs","sources":["../src/ParticleContainer.ts"],"sourcesContent":["import { BLEND_MODES, Color } from '@pixi/core';\nimport { Container } from '@pixi/display';\n\nimport type { BaseTexture, ColorSource, Renderer } from '@pixi/core';\nimport type { IDestroyOptions } from '@pixi/display';\nimport type { Sprite } from '@pixi/sprite';\nimport type { ParticleBuffer } from './ParticleBuffer';\n\nexport interface IParticleProperties\n{\n vertices?: boolean;\n position?: boolean;\n rotation?: boolean;\n uvs?: boolean;\n tint?: boolean;\n alpha?: boolean;\n scale?: boolean;\n}\n\n/**\n * The ParticleContainer class is a really fast version of the Container built solely for speed,\n * so use when you need a lot of sprites or particles.\n *\n * The tradeoff of the ParticleContainer is that most advanced functionality will not work.\n * ParticleContainer implements the basic object transform (position, scale, rotation)\n * and some advanced functionality like tint (as of v4.5.6).\n *\n * Other more advanced functionality like masking, children, filters, etc will not work on sprites in this batch.\n *\n * It's extremely easy to use. And here you have a hundred sprites that will be rendered at the speed of light.\n * @example\n * import { ParticleContainer, Sprite } from 'pixi.js';\n *\n * const container = new ParticleContainer();\n *\n * for (let i = 0; i < 100; ++i)\n * {\n * let sprite = Sprite.from('myImage.png');\n * container.addChild(sprite);\n * }\n * @memberof PIXI\n */\nexport class ParticleContainer<T extends Sprite = Sprite> extends Container<T>\n{\n /**\n * The blend mode to be applied to the sprite. Apply a value of `PIXI.BLEND_MODES.NORMAL`\n * to reset the blend mode.\n * @default PIXI.BLEND_MODES.NORMAL\n */\n public blendMode: BLEND_MODES;\n\n /**\n * If true, container allocates more batches in case there are more than `maxSize` particles.\n * @default false\n */\n public autoResize: boolean;\n\n /**\n * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation.\n * Advantages can include sharper image quality (like text) and faster rendering on canvas.\n * The main disadvantage is movement of objects may appear less smooth.\n * Default to true here as performance is usually the priority for particles.\n * @default true\n */\n public roundPixels: boolean;\n\n /**\n * The texture used to render the children.\n * @readonly\n */\n public baseTexture: BaseTexture;\n public tintRgb: Float32Array;\n\n /** @private */\n _maxSize: number;\n\n /** @private */\n _buffers: ParticleBuffer[];\n\n /** @private */\n _batchSize: number;\n\n /**\n * Set properties to be dynamic (true) / static (false).\n * @private\n */\n _properties: boolean[];\n\n /**\n * For every batch, stores _updateID corresponding to the last change in that batch.\n * @private\n */\n _bufferUpdateIDs: number[];\n\n /**\n * When child inserted, removed or changes position this number goes up.\n * @private\n */\n _updateID: number;\n\n /**\n * The tint applied to the container.\n * This is a hex value. A value of 0xFFFFFF will remove any tint effect.\n * @default 0xFFFFFF\n */\n private _tintColor: Color;\n\n /**\n * @param maxSize - The maximum number of particles that can be rendered by the container.\n * Affects size of allocated buffers.\n * @param properties - The properties of children that should be uploaded to the gpu and applied.\n * @param {boolean} [properties.vertices=false] - When true, vertices be uploaded and applied.\n * if sprite's ` scale/anchor/trim/frame/orig` is dynamic, please set `true`.\n * @param {boolean} [properties.position=true] - When true, position be uploaded and applied.\n * @param {boolean} [properties.rotation=false] - When true, rotation be uploaded and applied.\n * @param {boolean} [properties
|