This commit is contained in:
Akko
2025-08-04 18:57:35 +02:00
parent 8cf6e78a79
commit 9495868c2e
5030 changed files with 518594 additions and 17609 deletions

View File

@@ -0,0 +1,29 @@
import type { Matrix } from '../../maths/matrix/Matrix';
import type { Batch, Batcher } from '../../rendering/batcher/shared/Batcher';
import type { DefaultBatchableQuadElement } from '../../rendering/batcher/shared/DefaultBatcher';
import type { Texture } from '../../rendering/renderers/shared/texture/Texture';
import type { BoundsData } from '../container/bounds/Bounds';
import type { ViewContainer } from '../view/View';
/**
* A batchable sprite object.
* @ignore
*/
export declare class BatchableSprite implements DefaultBatchableQuadElement {
batcherName: string;
readonly attributeSize = 4;
readonly indexSize = 6;
readonly packAsQuad = true;
transform: Matrix;
renderable: ViewContainer;
texture: Texture;
bounds: BoundsData;
roundPixels: 0 | 1;
_indexStart: number;
_textureId: number;
_attributeStart: number;
_batcher: Batcher;
_batch: Batch;
get blendMode(): import("../..").BLEND_MODES;
get color(): number;
reset(): void;
}

View File

@@ -0,0 +1,33 @@
'use strict';
"use strict";
class BatchableSprite {
constructor() {
this.batcherName = "default";
// batch specific..
this.attributeSize = 4;
this.indexSize = 6;
this.packAsQuad = true;
this.roundPixels = 0;
this._attributeStart = 0;
// location in the buffer
this._batcher = null;
this._batch = null;
}
get blendMode() {
return this.renderable.groupBlendMode;
}
get color() {
return this.renderable.groupColorAlpha;
}
reset() {
this.renderable = null;
this.texture = null;
this._batcher = null;
this._batch = null;
this.bounds = null;
}
}
exports.BatchableSprite = BatchableSprite;
//# sourceMappingURL=BatchableSprite.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BatchableSprite.js","sources":["../../../src/scene/sprite/BatchableSprite.ts"],"sourcesContent":["import type { Matrix } from '../../maths/matrix/Matrix';\nimport type { Batch, Batcher } from '../../rendering/batcher/shared/Batcher';\nimport type { DefaultBatchableQuadElement } from '../../rendering/batcher/shared/DefaultBatcher';\nimport type { Texture } from '../../rendering/renderers/shared/texture/Texture';\nimport type { BoundsData } from '../container/bounds/Bounds';\nimport type { ViewContainer } from '../view/View';\n\n/**\n * A batchable sprite object.\n * @ignore\n */\nexport class BatchableSprite implements DefaultBatchableQuadElement\n{\n public batcherName = 'default';\n\n // batch specific..\n public readonly attributeSize = 4;\n public readonly indexSize = 6;\n public readonly packAsQuad = true;\n\n public transform: Matrix;\n\n public renderable: ViewContainer;\n public texture: Texture;\n public bounds: BoundsData;\n\n public roundPixels: 0 | 1 = 0;\n\n public _indexStart: number;\n public _textureId: number;\n public _attributeStart = 0; // location in the buffer\n public _batcher: Batcher = null;\n public _batch: Batch = null;\n\n get blendMode() { return this.renderable.groupBlendMode; }\n get color() { return this.renderable.groupColorAlpha; }\n\n public reset()\n {\n this.renderable = null;\n this.texture = null;\n this._batcher = null;\n this._batch = null;\n this.bounds = null;\n }\n}\n"],"names":[],"mappings":";;;AAWO,MAAM,eACb,CAAA;AAAA,EADO,WAAA,GAAA;AAEH,IAAA,IAAA,CAAO,WAAc,GAAA,SAAA,CAAA;AAGrB;AAAA,IAAA,IAAA,CAAgB,aAAgB,GAAA,CAAA,CAAA;AAChC,IAAA,IAAA,CAAgB,SAAY,GAAA,CAAA,CAAA;AAC5B,IAAA,IAAA,CAAgB,UAAa,GAAA,IAAA,CAAA;AAQ7B,IAAA,IAAA,CAAO,WAAqB,GAAA,CAAA,CAAA;AAI5B,IAAA,IAAA,CAAO,eAAkB,GAAA,CAAA,CAAA;AACzB;AAAA,IAAA,IAAA,CAAO,QAAoB,GAAA,IAAA,CAAA;AAC3B,IAAA,IAAA,CAAO,MAAgB,GAAA,IAAA,CAAA;AAAA,GAAA;AAAA,EAEvB,IAAI,SAAY,GAAA;AAAE,IAAA,OAAO,KAAK,UAAW,CAAA,cAAA,CAAA;AAAA,GAAgB;AAAA,EACzD,IAAI,KAAQ,GAAA;AAAE,IAAA,OAAO,KAAK,UAAW,CAAA,eAAA,CAAA;AAAA,GAAiB;AAAA,EAE/C,KACP,GAAA;AACI,IAAA,IAAA,CAAK,UAAa,GAAA,IAAA,CAAA;AAClB,IAAA,IAAA,CAAK,OAAU,GAAA,IAAA,CAAA;AACf,IAAA,IAAA,CAAK,QAAW,GAAA,IAAA,CAAA;AAChB,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAA;AACd,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAA;AAAA,GAClB;AACJ;;;;"}

View File

@@ -0,0 +1,31 @@
"use strict";
class BatchableSprite {
constructor() {
this.batcherName = "default";
// batch specific..
this.attributeSize = 4;
this.indexSize = 6;
this.packAsQuad = true;
this.roundPixels = 0;
this._attributeStart = 0;
// location in the buffer
this._batcher = null;
this._batch = null;
}
get blendMode() {
return this.renderable.groupBlendMode;
}
get color() {
return this.renderable.groupColorAlpha;
}
reset() {
this.renderable = null;
this.texture = null;
this._batcher = null;
this._batch = null;
this.bounds = null;
}
}
export { BatchableSprite };
//# sourceMappingURL=BatchableSprite.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BatchableSprite.mjs","sources":["../../../src/scene/sprite/BatchableSprite.ts"],"sourcesContent":["import type { Matrix } from '../../maths/matrix/Matrix';\nimport type { Batch, Batcher } from '../../rendering/batcher/shared/Batcher';\nimport type { DefaultBatchableQuadElement } from '../../rendering/batcher/shared/DefaultBatcher';\nimport type { Texture } from '../../rendering/renderers/shared/texture/Texture';\nimport type { BoundsData } from '../container/bounds/Bounds';\nimport type { ViewContainer } from '../view/View';\n\n/**\n * A batchable sprite object.\n * @ignore\n */\nexport class BatchableSprite implements DefaultBatchableQuadElement\n{\n public batcherName = 'default';\n\n // batch specific..\n public readonly attributeSize = 4;\n public readonly indexSize = 6;\n public readonly packAsQuad = true;\n\n public transform: Matrix;\n\n public renderable: ViewContainer;\n public texture: Texture;\n public bounds: BoundsData;\n\n public roundPixels: 0 | 1 = 0;\n\n public _indexStart: number;\n public _textureId: number;\n public _attributeStart = 0; // location in the buffer\n public _batcher: Batcher = null;\n public _batch: Batch = null;\n\n get blendMode() { return this.renderable.groupBlendMode; }\n get color() { return this.renderable.groupColorAlpha; }\n\n public reset()\n {\n this.renderable = null;\n this.texture = null;\n this._batcher = null;\n this._batch = null;\n this.bounds = null;\n }\n}\n"],"names":[],"mappings":";AAWO,MAAM,eACb,CAAA;AAAA,EADO,WAAA,GAAA;AAEH,IAAA,IAAA,CAAO,WAAc,GAAA,SAAA,CAAA;AAGrB;AAAA,IAAA,IAAA,CAAgB,aAAgB,GAAA,CAAA,CAAA;AAChC,IAAA,IAAA,CAAgB,SAAY,GAAA,CAAA,CAAA;AAC5B,IAAA,IAAA,CAAgB,UAAa,GAAA,IAAA,CAAA;AAQ7B,IAAA,IAAA,CAAO,WAAqB,GAAA,CAAA,CAAA;AAI5B,IAAA,IAAA,CAAO,eAAkB,GAAA,CAAA,CAAA;AACzB;AAAA,IAAA,IAAA,CAAO,QAAoB,GAAA,IAAA,CAAA;AAC3B,IAAA,IAAA,CAAO,MAAgB,GAAA,IAAA,CAAA;AAAA,GAAA;AAAA,EAEvB,IAAI,SAAY,GAAA;AAAE,IAAA,OAAO,KAAK,UAAW,CAAA,cAAA,CAAA;AAAA,GAAgB;AAAA,EACzD,IAAI,KAAQ,GAAA;AAAE,IAAA,OAAO,KAAK,UAAW,CAAA,eAAA,CAAA;AAAA,GAAiB;AAAA,EAE/C,KACP,GAAA;AACI,IAAA,IAAA,CAAK,UAAa,GAAA,IAAA,CAAA;AAClB,IAAA,IAAA,CAAK,OAAU,GAAA,IAAA,CAAA;AACf,IAAA,IAAA,CAAK,QAAW,GAAA,IAAA,CAAA;AAChB,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAA;AACd,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAA;AAAA,GAClB;AACJ;;;;"}

142
node_modules/pixi.js/lib/scene/sprite/Sprite.d.ts generated vendored Normal file
View File

@@ -0,0 +1,142 @@
import { ObservablePoint } from '../../maths/point/ObservablePoint';
import { Texture } from '../../rendering/renderers/shared/texture/Texture';
import { ViewContainer } from '../view/View';
import type { Size } from '../../maths/misc/Size';
import type { PointData } from '../../maths/point/PointData';
import type { TextureSourceLike } from '../../rendering/renderers/shared/texture/Texture';
import type { Bounds, BoundsData } from '../container/bounds/Bounds';
import type { ContainerOptions } from '../container/Container';
import type { Optional } from '../container/container-mixins/measureMixin';
import type { DestroyOptions } from '../container/destroyTypes';
/**
* Options for the {@link scene.Sprite} constructor.
* @memberof scene
*/
export interface SpriteOptions extends ContainerOptions {
/** The texture to use for the sprite. */
texture?: Texture;
/** The anchor point of the sprite. */
anchor?: PointData | number;
/** Whether or not to round the x/y position. */
roundPixels?: boolean;
}
/**
* The Sprite object is one of the most important objects in PixiJS. It is a
* drawing item that can be added to a scene and rendered to the screen.
*
* A sprite can be created directly from an image like this:
*
* ```js
* import { Sprite } from 'pixi.js';
*
* const sprite = Sprite.from('assets/image.png');
* ```
*
* The more efficient way to create sprites is using a {@link assets.Spritesheet},
* as swapping base textures when rendering to the screen is inefficient.
*
* ```js
* import { Assets, Sprite } from 'pixi.js';
*
* const sheet = await Assets.load('assets/spritesheet.json');
* const sprite = new Sprite(sheet.textures['image.png']);
* ```
* @memberof scene
* @extends scene.Container
*/
export declare class Sprite extends ViewContainer {
/**
* Helper function that creates a new sprite based on the source you provide.
* The source can be - frame id, image, video, canvas element, video element, texture
* @param source - Source to create texture from
* @param [skipCache] - Whether to skip the cache or not
* @returns The newly created sprite
*/
static from(source: Texture | TextureSourceLike, skipCache?: boolean): Sprite;
readonly renderPipeId: string;
batched: boolean;
readonly _anchor: ObservablePoint;
_texture: Texture;
_didSpriteUpdate: boolean;
private readonly _sourceBounds;
private _sourceBoundsDirty;
private _width;
private _height;
/**
* @param options - The options for creating the sprite.
*/
constructor(options?: SpriteOptions | Texture);
set texture(value: Texture);
/** The texture that the sprite is using. */
get texture(): Texture;
/**
* The local bounds of the sprite.
* @type {rendering.Bounds}
*/
get bounds(): Bounds;
/**
* The bounds of the sprite, taking the texture's trim into account.
* @type {rendering.Bounds}
*/
get sourceBounds(): BoundsData;
/**
* Checks if the object contains the given point.
* @param point - The point to check
*/
containsPoint(point: PointData): boolean;
/**
* Adds the bounds of this object to the bounds object.
* @param bounds - The output bounds object.
*/
addBounds(bounds: Bounds): void;
onViewUpdate(): void;
protected _updateBounds(): void;
private _updateSourceBounds;
/**
* Destroys this sprite renderable and optionally its texture.
* @param options - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [options.texture=false] - Should it destroy the current texture of the renderable as well
* @param {boolean} [options.textureSource=false] - Should it destroy the textureSource of the renderable as well
*/
destroy(options?: DestroyOptions): void;
/**
* The anchor sets the origin point of the sprite. The default value is taken from the {@link Texture}
* and passed to the constructor.
*
* The default is `(0,0)`, this means the sprite's origin is the top left.
*
* Setting the anchor to `(0.5,0.5)` means the sprite's origin is centered.
*
* Setting the anchor to `(1,1)` would mean the sprite's origin point will be the bottom right corner.
*
* If you pass only single parameter, it will set both x and y to the same value as shown in the example below.
* @example
* import { Sprite } from 'pixi.js';
*
* const sprite = new Sprite({texture: Texture.WHITE});
* sprite.anchor.set(0.5); // This will set the origin to center. (0.5) is same as (0.5, 0.5).
*/
get anchor(): ObservablePoint;
set anchor(value: PointData | number);
/** The width of the sprite, setting this will actually modify the scale to achieve the value set. */
get width(): number;
set width(value: number);
/** The height of the sprite, setting this will actually modify the scale to achieve the value set. */
get height(): number;
set height(value: number);
/**
* Retrieves the size of the Sprite as a [Size]{@link Size} object.
* This is faster than get the width and height separately.
* @param out - Optional object to store the size in.
* @returns - The size of the Sprite.
*/
getSize(out?: Size): Size;
/**
* Sets the size of the Sprite to the specified width and height.
* This is faster than setting the width and height separately.
* @param value - This can be either a number or a [Size]{@link Size} object.
* @param height - The height to set. Defaults to the value of `width` if not provided.
*/
setSize(value: number | Optional<Size, 'height'>, height?: number): void;
}

239
node_modules/pixi.js/lib/scene/sprite/Sprite.js generated vendored Normal file
View File

@@ -0,0 +1,239 @@
'use strict';
var ObservablePoint = require('../../maths/point/ObservablePoint.js');
var Texture = require('../../rendering/renderers/shared/texture/Texture.js');
var updateQuadBounds = require('../../utils/data/updateQuadBounds.js');
var View = require('../view/View.js');
"use strict";
class Sprite extends View.ViewContainer {
/**
* @param options - The options for creating the sprite.
*/
constructor(options = Texture.Texture.EMPTY) {
if (options instanceof Texture.Texture) {
options = { texture: options };
}
const { texture = Texture.Texture.EMPTY, anchor, roundPixels, width, height, ...rest } = options;
super({
label: "Sprite",
...rest
});
this.renderPipeId = "sprite";
this.batched = true;
this._didSpriteUpdate = false;
this._sourceBounds = { minX: 0, maxX: 1, minY: 0, maxY: 0 };
this._sourceBoundsDirty = true;
this._anchor = new ObservablePoint.ObservablePoint(
{
_onUpdate: () => {
this.onViewUpdate();
}
}
);
if (anchor) {
this.anchor = anchor;
} else if (texture.defaultAnchor) {
this.anchor = texture.defaultAnchor;
}
this.texture = texture;
this.allowChildren = false;
this.roundPixels = roundPixels ?? false;
if (width !== void 0)
this.width = width;
if (height !== void 0)
this.height = height;
}
/**
* Helper function that creates a new sprite based on the source you provide.
* The source can be - frame id, image, video, canvas element, video element, texture
* @param source - Source to create texture from
* @param [skipCache] - Whether to skip the cache or not
* @returns The newly created sprite
*/
static from(source, skipCache = false) {
if (source instanceof Texture.Texture) {
return new Sprite(source);
}
return new Sprite(Texture.Texture.from(source, skipCache));
}
set texture(value) {
value || (value = Texture.Texture.EMPTY);
const currentTexture = this._texture;
if (currentTexture === value)
return;
if (currentTexture && currentTexture.dynamic)
currentTexture.off("update", this.onViewUpdate, this);
if (value.dynamic)
value.on("update", this.onViewUpdate, this);
this._texture = value;
if (this._width) {
this._setWidth(this._width, this._texture.orig.width);
}
if (this._height) {
this._setHeight(this._height, this._texture.orig.height);
}
this.onViewUpdate();
}
/** The texture that the sprite is using. */
get texture() {
return this._texture;
}
/**
* The local bounds of the sprite.
* @type {rendering.Bounds}
*/
get bounds() {
if (this._boundsDirty) {
this._updateBounds();
this._boundsDirty = false;
}
return this._bounds;
}
/**
* The bounds of the sprite, taking the texture's trim into account.
* @type {rendering.Bounds}
*/
get sourceBounds() {
if (this._sourceBoundsDirty) {
this._updateSourceBounds();
this._sourceBoundsDirty = false;
}
return this._sourceBounds;
}
/**
* Checks if the object contains the given point.
* @param point - The point to check
*/
containsPoint(point) {
const bounds = this.sourceBounds;
if (point.x >= bounds.maxX && point.x <= bounds.minX) {
if (point.y >= bounds.maxY && point.y <= bounds.minY) {
return true;
}
}
return false;
}
/**
* Adds the bounds of this object to the bounds object.
* @param bounds - The output bounds object.
*/
addBounds(bounds) {
const _bounds = this._texture.trim ? this.sourceBounds : this.bounds;
bounds.addFrame(_bounds.minX, _bounds.minY, _bounds.maxX, _bounds.maxY);
}
onViewUpdate() {
this._didViewChangeTick++;
this._didSpriteUpdate = true;
this._sourceBoundsDirty = this._boundsDirty = true;
if (this.didViewUpdate)
return;
this.didViewUpdate = true;
const renderGroup = this.renderGroup || this.parentRenderGroup;
if (renderGroup) {
renderGroup.onChildViewUpdate(this);
}
}
_updateBounds() {
updateQuadBounds.updateQuadBounds(this._bounds, this._anchor, this._texture, 0);
}
_updateSourceBounds() {
const anchor = this._anchor;
const texture = this._texture;
const sourceBounds = this._sourceBounds;
const { width, height } = texture.orig;
sourceBounds.maxX = -anchor._x * width;
sourceBounds.minX = sourceBounds.maxX + width;
sourceBounds.maxY = -anchor._y * height;
sourceBounds.minY = sourceBounds.maxY + height;
}
/**
* Destroys this sprite renderable and optionally its texture.
* @param options - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [options.texture=false] - Should it destroy the current texture of the renderable as well
* @param {boolean} [options.textureSource=false] - Should it destroy the textureSource of the renderable as well
*/
destroy(options = false) {
super.destroy(options);
const destroyTexture = typeof options === "boolean" ? options : options?.texture;
if (destroyTexture) {
const destroyTextureSource = typeof options === "boolean" ? options : options?.textureSource;
this._texture.destroy(destroyTextureSource);
}
this._texture = null;
this._bounds = null;
this._sourceBounds = null;
this._anchor = null;
}
/**
* The anchor sets the origin point of the sprite. The default value is taken from the {@link Texture}
* and passed to the constructor.
*
* The default is `(0,0)`, this means the sprite's origin is the top left.
*
* Setting the anchor to `(0.5,0.5)` means the sprite's origin is centered.
*
* Setting the anchor to `(1,1)` would mean the sprite's origin point will be the bottom right corner.
*
* If you pass only single parameter, it will set both x and y to the same value as shown in the example below.
* @example
* import { Sprite } from 'pixi.js';
*
* const sprite = new Sprite({texture: Texture.WHITE});
* sprite.anchor.set(0.5); // This will set the origin to center. (0.5) is same as (0.5, 0.5).
*/
get anchor() {
return this._anchor;
}
set anchor(value) {
typeof value === "number" ? this._anchor.set(value) : this._anchor.copyFrom(value);
}
/** The width of the sprite, setting this will actually modify the scale to achieve the value set. */
get width() {
return Math.abs(this.scale.x) * this._texture.orig.width;
}
set width(value) {
this._setWidth(value, this._texture.orig.width);
this._width = value;
}
/** The height of the sprite, setting this will actually modify the scale to achieve the value set. */
get height() {
return Math.abs(this.scale.y) * this._texture.orig.height;
}
set height(value) {
this._setHeight(value, this._texture.orig.height);
this._height = value;
}
/**
* Retrieves the size of the Sprite as a [Size]{@link Size} object.
* This is faster than get the width and height separately.
* @param out - Optional object to store the size in.
* @returns - The size of the Sprite.
*/
getSize(out) {
out || (out = {});
out.width = Math.abs(this.scale.x) * this._texture.orig.width;
out.height = Math.abs(this.scale.y) * this._texture.orig.height;
return out;
}
/**
* Sets the size of the Sprite to the specified width and height.
* This is faster than setting the width and height separately.
* @param value - This can be either a number or a [Size]{@link Size} object.
* @param height - The height to set. Defaults to the value of `width` if not provided.
*/
setSize(value, height) {
if (typeof value === "object") {
height = value.height ?? value.width;
value = value.width;
} else {
height ?? (height = value);
}
value !== void 0 && this._setWidth(value, this._texture.orig.width);
height !== void 0 && this._setHeight(height, this._texture.orig.height);
}
}
exports.Sprite = Sprite;
//# sourceMappingURL=Sprite.js.map

1
node_modules/pixi.js/lib/scene/sprite/Sprite.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

237
node_modules/pixi.js/lib/scene/sprite/Sprite.mjs generated vendored Normal file
View File

@@ -0,0 +1,237 @@
import { ObservablePoint } from '../../maths/point/ObservablePoint.mjs';
import { Texture } from '../../rendering/renderers/shared/texture/Texture.mjs';
import { updateQuadBounds } from '../../utils/data/updateQuadBounds.mjs';
import { ViewContainer } from '../view/View.mjs';
"use strict";
class Sprite extends ViewContainer {
/**
* @param options - The options for creating the sprite.
*/
constructor(options = Texture.EMPTY) {
if (options instanceof Texture) {
options = { texture: options };
}
const { texture = Texture.EMPTY, anchor, roundPixels, width, height, ...rest } = options;
super({
label: "Sprite",
...rest
});
this.renderPipeId = "sprite";
this.batched = true;
this._didSpriteUpdate = false;
this._sourceBounds = { minX: 0, maxX: 1, minY: 0, maxY: 0 };
this._sourceBoundsDirty = true;
this._anchor = new ObservablePoint(
{
_onUpdate: () => {
this.onViewUpdate();
}
}
);
if (anchor) {
this.anchor = anchor;
} else if (texture.defaultAnchor) {
this.anchor = texture.defaultAnchor;
}
this.texture = texture;
this.allowChildren = false;
this.roundPixels = roundPixels ?? false;
if (width !== void 0)
this.width = width;
if (height !== void 0)
this.height = height;
}
/**
* Helper function that creates a new sprite based on the source you provide.
* The source can be - frame id, image, video, canvas element, video element, texture
* @param source - Source to create texture from
* @param [skipCache] - Whether to skip the cache or not
* @returns The newly created sprite
*/
static from(source, skipCache = false) {
if (source instanceof Texture) {
return new Sprite(source);
}
return new Sprite(Texture.from(source, skipCache));
}
set texture(value) {
value || (value = Texture.EMPTY);
const currentTexture = this._texture;
if (currentTexture === value)
return;
if (currentTexture && currentTexture.dynamic)
currentTexture.off("update", this.onViewUpdate, this);
if (value.dynamic)
value.on("update", this.onViewUpdate, this);
this._texture = value;
if (this._width) {
this._setWidth(this._width, this._texture.orig.width);
}
if (this._height) {
this._setHeight(this._height, this._texture.orig.height);
}
this.onViewUpdate();
}
/** The texture that the sprite is using. */
get texture() {
return this._texture;
}
/**
* The local bounds of the sprite.
* @type {rendering.Bounds}
*/
get bounds() {
if (this._boundsDirty) {
this._updateBounds();
this._boundsDirty = false;
}
return this._bounds;
}
/**
* The bounds of the sprite, taking the texture's trim into account.
* @type {rendering.Bounds}
*/
get sourceBounds() {
if (this._sourceBoundsDirty) {
this._updateSourceBounds();
this._sourceBoundsDirty = false;
}
return this._sourceBounds;
}
/**
* Checks if the object contains the given point.
* @param point - The point to check
*/
containsPoint(point) {
const bounds = this.sourceBounds;
if (point.x >= bounds.maxX && point.x <= bounds.minX) {
if (point.y >= bounds.maxY && point.y <= bounds.minY) {
return true;
}
}
return false;
}
/**
* Adds the bounds of this object to the bounds object.
* @param bounds - The output bounds object.
*/
addBounds(bounds) {
const _bounds = this._texture.trim ? this.sourceBounds : this.bounds;
bounds.addFrame(_bounds.minX, _bounds.minY, _bounds.maxX, _bounds.maxY);
}
onViewUpdate() {
this._didViewChangeTick++;
this._didSpriteUpdate = true;
this._sourceBoundsDirty = this._boundsDirty = true;
if (this.didViewUpdate)
return;
this.didViewUpdate = true;
const renderGroup = this.renderGroup || this.parentRenderGroup;
if (renderGroup) {
renderGroup.onChildViewUpdate(this);
}
}
_updateBounds() {
updateQuadBounds(this._bounds, this._anchor, this._texture, 0);
}
_updateSourceBounds() {
const anchor = this._anchor;
const texture = this._texture;
const sourceBounds = this._sourceBounds;
const { width, height } = texture.orig;
sourceBounds.maxX = -anchor._x * width;
sourceBounds.minX = sourceBounds.maxX + width;
sourceBounds.maxY = -anchor._y * height;
sourceBounds.minY = sourceBounds.maxY + height;
}
/**
* Destroys this sprite renderable and optionally its texture.
* @param options - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [options.texture=false] - Should it destroy the current texture of the renderable as well
* @param {boolean} [options.textureSource=false] - Should it destroy the textureSource of the renderable as well
*/
destroy(options = false) {
super.destroy(options);
const destroyTexture = typeof options === "boolean" ? options : options?.texture;
if (destroyTexture) {
const destroyTextureSource = typeof options === "boolean" ? options : options?.textureSource;
this._texture.destroy(destroyTextureSource);
}
this._texture = null;
this._bounds = null;
this._sourceBounds = null;
this._anchor = null;
}
/**
* The anchor sets the origin point of the sprite. The default value is taken from the {@link Texture}
* and passed to the constructor.
*
* The default is `(0,0)`, this means the sprite's origin is the top left.
*
* Setting the anchor to `(0.5,0.5)` means the sprite's origin is centered.
*
* Setting the anchor to `(1,1)` would mean the sprite's origin point will be the bottom right corner.
*
* If you pass only single parameter, it will set both x and y to the same value as shown in the example below.
* @example
* import { Sprite } from 'pixi.js';
*
* const sprite = new Sprite({texture: Texture.WHITE});
* sprite.anchor.set(0.5); // This will set the origin to center. (0.5) is same as (0.5, 0.5).
*/
get anchor() {
return this._anchor;
}
set anchor(value) {
typeof value === "number" ? this._anchor.set(value) : this._anchor.copyFrom(value);
}
/** The width of the sprite, setting this will actually modify the scale to achieve the value set. */
get width() {
return Math.abs(this.scale.x) * this._texture.orig.width;
}
set width(value) {
this._setWidth(value, this._texture.orig.width);
this._width = value;
}
/** The height of the sprite, setting this will actually modify the scale to achieve the value set. */
get height() {
return Math.abs(this.scale.y) * this._texture.orig.height;
}
set height(value) {
this._setHeight(value, this._texture.orig.height);
this._height = value;
}
/**
* Retrieves the size of the Sprite as a [Size]{@link Size} object.
* This is faster than get the width and height separately.
* @param out - Optional object to store the size in.
* @returns - The size of the Sprite.
*/
getSize(out) {
out || (out = {});
out.width = Math.abs(this.scale.x) * this._texture.orig.width;
out.height = Math.abs(this.scale.y) * this._texture.orig.height;
return out;
}
/**
* Sets the size of the Sprite to the specified width and height.
* This is faster than setting the width and height separately.
* @param value - This can be either a number or a [Size]{@link Size} object.
* @param height - The height to set. Defaults to the value of `width` if not provided.
*/
setSize(value, height) {
if (typeof value === "object") {
height = value.height ?? value.width;
value = value.width;
} else {
height ?? (height = value);
}
value !== void 0 && this._setWidth(value, this._texture.orig.width);
height !== void 0 && this._setHeight(height, this._texture.orig.height);
}
}
export { Sprite };
//# sourceMappingURL=Sprite.mjs.map

1
node_modules/pixi.js/lib/scene/sprite/Sprite.mjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

24
node_modules/pixi.js/lib/scene/sprite/SpritePipe.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import { ExtensionType } from '../../extensions/Extensions';
import type { InstructionSet } from '../../rendering/renderers/shared/instructions/InstructionSet';
import type { RenderPipe } from '../../rendering/renderers/shared/instructions/RenderPipe';
import type { Renderer } from '../../rendering/renderers/types';
import type { Sprite } from './Sprite';
export declare class SpritePipe implements RenderPipe<Sprite> {
/** @ignore */
static extension: {
readonly type: readonly [ExtensionType.WebGLPipes, ExtensionType.WebGPUPipes, ExtensionType.CanvasPipes];
readonly name: "sprite";
};
private _renderer;
private _gpuSpriteHash;
private readonly _destroyRenderableBound;
constructor(renderer: Renderer);
addRenderable(sprite: Sprite, instructionSet: InstructionSet): void;
updateRenderable(sprite: Sprite): void;
validateRenderable(sprite: Sprite): boolean;
destroyRenderable(sprite: Sprite): void;
private _updateBatchableSprite;
private _getGpuSprite;
private _initGPUSprite;
destroy(): void;
}

79
node_modules/pixi.js/lib/scene/sprite/SpritePipe.js generated vendored Normal file
View File

@@ -0,0 +1,79 @@
'use strict';
var Extensions = require('../../extensions/Extensions.js');
var PoolGroup = require('../../utils/pool/PoolGroup.js');
var BatchableSprite = require('./BatchableSprite.js');
"use strict";
class SpritePipe {
constructor(renderer) {
this._gpuSpriteHash = /* @__PURE__ */ Object.create(null);
this._destroyRenderableBound = this.destroyRenderable.bind(this);
this._renderer = renderer;
}
addRenderable(sprite, instructionSet) {
const gpuSprite = this._getGpuSprite(sprite);
if (sprite._didSpriteUpdate)
this._updateBatchableSprite(sprite, gpuSprite);
this._renderer.renderPipes.batch.addToBatch(gpuSprite, instructionSet);
}
updateRenderable(sprite) {
const gpuSprite = this._gpuSpriteHash[sprite.uid];
if (sprite._didSpriteUpdate)
this._updateBatchableSprite(sprite, gpuSprite);
gpuSprite._batcher.updateElement(gpuSprite);
}
validateRenderable(sprite) {
const texture = sprite._texture;
const gpuSprite = this._getGpuSprite(sprite);
if (gpuSprite.texture._source !== texture._source) {
return !gpuSprite._batcher.checkAndUpdateTexture(gpuSprite, texture);
}
return false;
}
destroyRenderable(sprite) {
const batchableSprite = this._gpuSpriteHash[sprite.uid];
PoolGroup.BigPool.return(batchableSprite);
this._gpuSpriteHash[sprite.uid] = null;
sprite.off("destroyed", this._destroyRenderableBound);
}
_updateBatchableSprite(sprite, batchableSprite) {
sprite._didSpriteUpdate = false;
batchableSprite.bounds = sprite.bounds;
batchableSprite.texture = sprite._texture;
}
_getGpuSprite(sprite) {
return this._gpuSpriteHash[sprite.uid] || this._initGPUSprite(sprite);
}
_initGPUSprite(sprite) {
const batchableSprite = PoolGroup.BigPool.get(BatchableSprite.BatchableSprite);
batchableSprite.renderable = sprite;
batchableSprite.transform = sprite.groupTransform;
batchableSprite.texture = sprite._texture;
batchableSprite.bounds = sprite.bounds;
batchableSprite.roundPixels = this._renderer._roundPixels | sprite._roundPixels;
this._gpuSpriteHash[sprite.uid] = batchableSprite;
sprite._didSpriteUpdate = false;
sprite.on("destroyed", this._destroyRenderableBound);
return batchableSprite;
}
destroy() {
for (const i in this._gpuSpriteHash) {
PoolGroup.BigPool.return(this._gpuSpriteHash[i]);
}
this._gpuSpriteHash = null;
this._renderer = null;
}
}
/** @ignore */
SpritePipe.extension = {
type: [
Extensions.ExtensionType.WebGLPipes,
Extensions.ExtensionType.WebGPUPipes,
Extensions.ExtensionType.CanvasPipes
],
name: "sprite"
};
exports.SpritePipe = SpritePipe;
//# sourceMappingURL=SpritePipe.js.map

File diff suppressed because one or more lines are too long

77
node_modules/pixi.js/lib/scene/sprite/SpritePipe.mjs generated vendored Normal file
View File

@@ -0,0 +1,77 @@
import { ExtensionType } from '../../extensions/Extensions.mjs';
import { BigPool } from '../../utils/pool/PoolGroup.mjs';
import { BatchableSprite } from './BatchableSprite.mjs';
"use strict";
class SpritePipe {
constructor(renderer) {
this._gpuSpriteHash = /* @__PURE__ */ Object.create(null);
this._destroyRenderableBound = this.destroyRenderable.bind(this);
this._renderer = renderer;
}
addRenderable(sprite, instructionSet) {
const gpuSprite = this._getGpuSprite(sprite);
if (sprite._didSpriteUpdate)
this._updateBatchableSprite(sprite, gpuSprite);
this._renderer.renderPipes.batch.addToBatch(gpuSprite, instructionSet);
}
updateRenderable(sprite) {
const gpuSprite = this._gpuSpriteHash[sprite.uid];
if (sprite._didSpriteUpdate)
this._updateBatchableSprite(sprite, gpuSprite);
gpuSprite._batcher.updateElement(gpuSprite);
}
validateRenderable(sprite) {
const texture = sprite._texture;
const gpuSprite = this._getGpuSprite(sprite);
if (gpuSprite.texture._source !== texture._source) {
return !gpuSprite._batcher.checkAndUpdateTexture(gpuSprite, texture);
}
return false;
}
destroyRenderable(sprite) {
const batchableSprite = this._gpuSpriteHash[sprite.uid];
BigPool.return(batchableSprite);
this._gpuSpriteHash[sprite.uid] = null;
sprite.off("destroyed", this._destroyRenderableBound);
}
_updateBatchableSprite(sprite, batchableSprite) {
sprite._didSpriteUpdate = false;
batchableSprite.bounds = sprite.bounds;
batchableSprite.texture = sprite._texture;
}
_getGpuSprite(sprite) {
return this._gpuSpriteHash[sprite.uid] || this._initGPUSprite(sprite);
}
_initGPUSprite(sprite) {
const batchableSprite = BigPool.get(BatchableSprite);
batchableSprite.renderable = sprite;
batchableSprite.transform = sprite.groupTransform;
batchableSprite.texture = sprite._texture;
batchableSprite.bounds = sprite.bounds;
batchableSprite.roundPixels = this._renderer._roundPixels | sprite._roundPixels;
this._gpuSpriteHash[sprite.uid] = batchableSprite;
sprite._didSpriteUpdate = false;
sprite.on("destroyed", this._destroyRenderableBound);
return batchableSprite;
}
destroy() {
for (const i in this._gpuSpriteHash) {
BigPool.return(this._gpuSpriteHash[i]);
}
this._gpuSpriteHash = null;
this._renderer = null;
}
}
/** @ignore */
SpritePipe.extension = {
type: [
ExtensionType.WebGLPipes,
ExtensionType.WebGPUPipes,
ExtensionType.CanvasPipes
],
name: "sprite"
};
export { SpritePipe };
//# sourceMappingURL=SpritePipe.mjs.map

File diff suppressed because one or more lines are too long