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,199 @@
import { ObservablePoint } from '../../maths/point/ObservablePoint';
import { Texture } from '../../rendering/renderers/shared/texture/Texture';
import { Transform } from '../../utils/misc/Transform';
import { ViewContainer } from '../view/View';
import type { Size } from '../../maths/misc/Size';
import type { PointData } from '../../maths/point/PointData';
import type { Instruction } from '../../rendering/renderers/shared/instructions/Instruction';
import type { View } from '../../rendering/renderers/shared/view/View';
import type { Bounds } from '../container/bounds/Bounds';
import type { ContainerOptions } from '../container/Container';
import type { Optional } from '../container/container-mixins/measureMixin';
import type { DestroyOptions } from '../container/destroyTypes';
/**
* Constructor options used for `TilingSprite` instances. Extends {@link scene.TilingSpriteViewOptions}
* ```js
* const tilingSprite = new TilingSprite({
* texture: Texture.from('assets/image.png'),
* width: 100,
* height: 100,
* tilePosition: { x: 100, y: 100 },
* tileScale: { x: 2, y: 2 },
* });
* ```
* @see {@link scene.TilingSprite}
* @see {@link scene.TilingSpriteViewOptions}
* @memberof scene
*/
export interface TilingSpriteOptions extends ContainerOptions {
/**
* The anchor point of the sprite
* @default {x: 0, y: 0}
*/
anchor?: PointData;
/**
* The offset of the image that is being tiled.
* @default {x: 0, y: 0}
*/
tilePosition?: PointData;
/**
* Scaling of the image that is being tiled.
* @default {x: 1, y: 1}
*/
tileScale?: PointData;
/**
* The rotation of the image that is being tiled.
* @default 0
*/
tileRotation?: number;
/**
* The texture to use for the sprite.
* @default Texture.WHITE
*/
texture?: Texture;
/**
* The width of the tiling sprite. #
* @default 256
*/
width?: number;
/**
* The height of the tiling sprite.
* @default 256
*/
height?: number;
/**
* @todo
* @default false
*/
applyAnchorToTexture?: boolean;
/** Whether or not to round the x/y position. */
roundPixels?: boolean;
}
/**
* A tiling sprite is a fast way of rendering a tiling image.
* @example
* const tilingSprite = new TilingSprite({
* texture: Texture.from('assets/image.png'),
* width: 100,
* height: 100,
* });
*
* tilingSprite.tilePosition.x = 100;
* tilingSprite.tilePosition.y = 100;
*
* app.stage.addChild(tilingSprite);
* @memberof scene
* @extends scene.Container
*/
export declare class TilingSprite extends ViewContainer implements View, Instruction {
/**
* Creates a new tiling sprite.
* @param source - The source to create the texture from.
* @param options - The options for creating the tiling sprite.
* @returns A new tiling sprite.
*/
static from(source: Texture | string, options?: TilingSpriteOptions): TilingSprite;
/** default options for the TilingSprite */
static defaultOptions: TilingSpriteOptions;
readonly renderPipeId: string;
readonly batched = true;
_anchor: ObservablePoint;
_tileTransform: Transform;
_texture: Texture;
_applyAnchorToTexture: boolean;
_didTilingSpriteUpdate: boolean;
private _width;
private _height;
/**
* @param {rendering.Texture | scene.TilingSpriteOptions} options - The options for creating the tiling sprite.
*/
constructor(options?: Texture | TilingSpriteOptions);
/** @deprecated since 8.0.0 */
constructor(texture: Texture, width: number, height: number);
/**
* Changes frame clamping in corresponding textureMatrix
* Change to -0.5 to add a pixel to the edge, recommended for transparent trimmed textures in atlas
* @default 0.5
* @member {number}
*/
get clampMargin(): number;
set clampMargin(value: number);
/**
* 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 { TilingSprite } from 'pixi.js';
*
* const sprite = new TilingSprite({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 offset of the image that is being tiled. */
get tilePosition(): ObservablePoint;
set tilePosition(value: PointData);
/** The scaling of the image that is being tiled. */
get tileScale(): ObservablePoint;
set tileScale(value: PointData | number);
set tileRotation(value: number);
/** The rotation of the image that is being tiled. */
get tileRotation(): number;
/** The transform of the image that is being tiled. */
get tileTransform(): Transform;
/**
* The local bounds of the sprite.
* @type {rendering.Bounds}
*/
get bounds(): Bounds;
set texture(value: Texture);
/** The texture that the sprite is using. */
get texture(): Texture;
/** The width of the tiling area. */
set width(value: number);
get width(): number;
set height(value: number);
/** The height of the tiling area. */
get height(): number;
/**
* Sets the size of the TilingSprite 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;
/**
* Retrieves the size of the TilingSprite 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 TilingSprite.
*/
getSize(out?: Size): Size;
protected _updateBounds(): void;
/**
* Adds the bounds of this object to the bounds object.
* @param bounds - The output bounds object.
*/
addBounds(bounds: Bounds): void;
/**
* Checks if the object contains the given point.
* @param point - The point to check
*/
containsPoint(point: PointData): boolean;
onViewUpdate(): void;
/**
* 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;
}

View File

@@ -0,0 +1,302 @@
'use strict';
var Cache = require('../../assets/cache/Cache.js');
var ObservablePoint = require('../../maths/point/ObservablePoint.js');
var Texture = require('../../rendering/renderers/shared/texture/Texture.js');
var deprecation = require('../../utils/logging/deprecation.js');
var Transform = require('../../utils/misc/Transform.js');
var View = require('../view/View.js');
"use strict";
const _TilingSprite = class _TilingSprite extends View.ViewContainer {
constructor(...args) {
let options = args[0] || {};
if (options instanceof Texture.Texture) {
options = { texture: options };
}
if (args.length > 1) {
deprecation.deprecation(deprecation.v8_0_0, "use new TilingSprite({ texture, width:100, height:100 }) instead");
options.width = args[1];
options.height = args[2];
}
options = { ..._TilingSprite.defaultOptions, ...options };
const {
texture,
anchor,
tilePosition,
tileScale,
tileRotation,
width,
height,
applyAnchorToTexture,
roundPixels,
...rest
} = options ?? {};
super({
label: "TilingSprite",
...rest
});
this.renderPipeId = "tilingSprite";
this.batched = true;
this.allowChildren = false;
this._anchor = new ObservablePoint.ObservablePoint(
{
_onUpdate: () => {
this.onViewUpdate();
}
}
);
this._applyAnchorToTexture = applyAnchorToTexture;
this.texture = texture;
this._width = width ?? texture.width;
this._height = height ?? texture.height;
this._tileTransform = new Transform.Transform({
observer: {
_onUpdate: () => this.onViewUpdate()
}
});
if (anchor)
this.anchor = anchor;
this.tilePosition = tilePosition;
this.tileScale = tileScale;
this.tileRotation = tileRotation;
this.roundPixels = roundPixels ?? false;
}
/**
* Creates a new tiling sprite.
* @param source - The source to create the texture from.
* @param options - The options for creating the tiling sprite.
* @returns A new tiling sprite.
*/
static from(source, options = {}) {
if (typeof source === "string") {
return new _TilingSprite({
texture: Cache.Cache.get(source),
...options
});
}
return new _TilingSprite({
texture: source,
...options
});
}
/**
* Changes frame clamping in corresponding textureMatrix
* Change to -0.5 to add a pixel to the edge, recommended for transparent trimmed textures in atlas
* @default 0.5
* @member {number}
*/
get clampMargin() {
return this._texture.textureMatrix.clampMargin;
}
set clampMargin(value) {
this._texture.textureMatrix.clampMargin = value;
}
/**
* 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 { TilingSprite } from 'pixi.js';
*
* const sprite = new TilingSprite({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 offset of the image that is being tiled. */
get tilePosition() {
return this._tileTransform.position;
}
set tilePosition(value) {
this._tileTransform.position.copyFrom(value);
}
/** The scaling of the image that is being tiled. */
get tileScale() {
return this._tileTransform.scale;
}
set tileScale(value) {
typeof value === "number" ? this._tileTransform.scale.set(value) : this._tileTransform.scale.copyFrom(value);
}
set tileRotation(value) {
this._tileTransform.rotation = value;
}
/** The rotation of the image that is being tiled. */
get tileRotation() {
return this._tileTransform.rotation;
}
/** The transform of the image that is being tiled. */
get tileTransform() {
return this._tileTransform;
}
/**
* The local bounds of the sprite.
* @type {rendering.Bounds}
*/
get bounds() {
if (this._boundsDirty) {
this._updateBounds();
this._boundsDirty = false;
}
return this._bounds;
}
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;
this.onViewUpdate();
}
/** The texture that the sprite is using. */
get texture() {
return this._texture;
}
/** The width of the tiling area. */
set width(value) {
this._width = value;
this.onViewUpdate();
}
get width() {
return this._width;
}
set height(value) {
this._height = value;
this.onViewUpdate();
}
/** The height of the tiling area. */
get height() {
return this._height;
}
/**
* Sets the size of the TilingSprite 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;
}
this._width = value;
this._height = height ?? value;
this.onViewUpdate();
}
/**
* Retrieves the size of the TilingSprite 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 TilingSprite.
*/
getSize(out) {
out || (out = {});
out.width = this._width;
out.height = this._height;
return out;
}
_updateBounds() {
const bounds = this._bounds;
const anchor = this._anchor;
const width = this._width;
const height = this._height;
bounds.maxX = -anchor._x * width;
bounds.minX = bounds.maxX + width;
bounds.maxY = -anchor._y * height;
bounds.minY = bounds.maxY + height;
}
/**
* Adds the bounds of this object to the bounds object.
* @param bounds - The output bounds object.
*/
addBounds(bounds) {
const _bounds = this.bounds;
bounds.addFrame(
_bounds.minX,
_bounds.minY,
_bounds.maxX,
_bounds.maxY
);
}
/**
* Checks if the object contains the given point.
* @param point - The point to check
*/
containsPoint(point) {
const width = this._width;
const height = this._height;
const x1 = -width * this._anchor._x;
let y1 = 0;
if (point.x >= x1 && point.x <= x1 + width) {
y1 = -height * this._anchor._y;
if (point.y >= y1 && point.y <= y1 + height)
return true;
}
return false;
}
onViewUpdate() {
this._boundsDirty = true;
this._didTilingSpriteUpdate = true;
this._didViewChangeTick++;
if (this.didViewUpdate)
return;
this.didViewUpdate = true;
const renderGroup = this.renderGroup || this.parentRenderGroup;
if (renderGroup) {
renderGroup.onChildViewUpdate(this);
}
}
/**
* 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);
this._anchor = null;
this._tileTransform = null;
this._bounds = null;
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;
}
};
/** default options for the TilingSprite */
_TilingSprite.defaultOptions = {
/** The texture to use for the sprite. */
texture: Texture.Texture.EMPTY,
/** The anchor point of the sprite */
anchor: { x: 0, y: 0 },
/** The offset of the image that is being tiled. */
tilePosition: { x: 0, y: 0 },
/** Scaling of the image that is being tiled. */
tileScale: { x: 1, y: 1 },
/** The rotation of the image that is being tiled. */
tileRotation: 0,
/** TODO */
applyAnchorToTexture: false
};
let TilingSprite = _TilingSprite;
exports.TilingSprite = TilingSprite;
//# sourceMappingURL=TilingSprite.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,300 @@
import { Cache } from '../../assets/cache/Cache.mjs';
import { ObservablePoint } from '../../maths/point/ObservablePoint.mjs';
import { Texture } from '../../rendering/renderers/shared/texture/Texture.mjs';
import { deprecation, v8_0_0 } from '../../utils/logging/deprecation.mjs';
import { Transform } from '../../utils/misc/Transform.mjs';
import { ViewContainer } from '../view/View.mjs';
"use strict";
const _TilingSprite = class _TilingSprite extends ViewContainer {
constructor(...args) {
let options = args[0] || {};
if (options instanceof Texture) {
options = { texture: options };
}
if (args.length > 1) {
deprecation(v8_0_0, "use new TilingSprite({ texture, width:100, height:100 }) instead");
options.width = args[1];
options.height = args[2];
}
options = { ..._TilingSprite.defaultOptions, ...options };
const {
texture,
anchor,
tilePosition,
tileScale,
tileRotation,
width,
height,
applyAnchorToTexture,
roundPixels,
...rest
} = options ?? {};
super({
label: "TilingSprite",
...rest
});
this.renderPipeId = "tilingSprite";
this.batched = true;
this.allowChildren = false;
this._anchor = new ObservablePoint(
{
_onUpdate: () => {
this.onViewUpdate();
}
}
);
this._applyAnchorToTexture = applyAnchorToTexture;
this.texture = texture;
this._width = width ?? texture.width;
this._height = height ?? texture.height;
this._tileTransform = new Transform({
observer: {
_onUpdate: () => this.onViewUpdate()
}
});
if (anchor)
this.anchor = anchor;
this.tilePosition = tilePosition;
this.tileScale = tileScale;
this.tileRotation = tileRotation;
this.roundPixels = roundPixels ?? false;
}
/**
* Creates a new tiling sprite.
* @param source - The source to create the texture from.
* @param options - The options for creating the tiling sprite.
* @returns A new tiling sprite.
*/
static from(source, options = {}) {
if (typeof source === "string") {
return new _TilingSprite({
texture: Cache.get(source),
...options
});
}
return new _TilingSprite({
texture: source,
...options
});
}
/**
* Changes frame clamping in corresponding textureMatrix
* Change to -0.5 to add a pixel to the edge, recommended for transparent trimmed textures in atlas
* @default 0.5
* @member {number}
*/
get clampMargin() {
return this._texture.textureMatrix.clampMargin;
}
set clampMargin(value) {
this._texture.textureMatrix.clampMargin = value;
}
/**
* 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 { TilingSprite } from 'pixi.js';
*
* const sprite = new TilingSprite({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 offset of the image that is being tiled. */
get tilePosition() {
return this._tileTransform.position;
}
set tilePosition(value) {
this._tileTransform.position.copyFrom(value);
}
/** The scaling of the image that is being tiled. */
get tileScale() {
return this._tileTransform.scale;
}
set tileScale(value) {
typeof value === "number" ? this._tileTransform.scale.set(value) : this._tileTransform.scale.copyFrom(value);
}
set tileRotation(value) {
this._tileTransform.rotation = value;
}
/** The rotation of the image that is being tiled. */
get tileRotation() {
return this._tileTransform.rotation;
}
/** The transform of the image that is being tiled. */
get tileTransform() {
return this._tileTransform;
}
/**
* The local bounds of the sprite.
* @type {rendering.Bounds}
*/
get bounds() {
if (this._boundsDirty) {
this._updateBounds();
this._boundsDirty = false;
}
return this._bounds;
}
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;
this.onViewUpdate();
}
/** The texture that the sprite is using. */
get texture() {
return this._texture;
}
/** The width of the tiling area. */
set width(value) {
this._width = value;
this.onViewUpdate();
}
get width() {
return this._width;
}
set height(value) {
this._height = value;
this.onViewUpdate();
}
/** The height of the tiling area. */
get height() {
return this._height;
}
/**
* Sets the size of the TilingSprite 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;
}
this._width = value;
this._height = height ?? value;
this.onViewUpdate();
}
/**
* Retrieves the size of the TilingSprite 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 TilingSprite.
*/
getSize(out) {
out || (out = {});
out.width = this._width;
out.height = this._height;
return out;
}
_updateBounds() {
const bounds = this._bounds;
const anchor = this._anchor;
const width = this._width;
const height = this._height;
bounds.maxX = -anchor._x * width;
bounds.minX = bounds.maxX + width;
bounds.maxY = -anchor._y * height;
bounds.minY = bounds.maxY + height;
}
/**
* Adds the bounds of this object to the bounds object.
* @param bounds - The output bounds object.
*/
addBounds(bounds) {
const _bounds = this.bounds;
bounds.addFrame(
_bounds.minX,
_bounds.minY,
_bounds.maxX,
_bounds.maxY
);
}
/**
* Checks if the object contains the given point.
* @param point - The point to check
*/
containsPoint(point) {
const width = this._width;
const height = this._height;
const x1 = -width * this._anchor._x;
let y1 = 0;
if (point.x >= x1 && point.x <= x1 + width) {
y1 = -height * this._anchor._y;
if (point.y >= y1 && point.y <= y1 + height)
return true;
}
return false;
}
onViewUpdate() {
this._boundsDirty = true;
this._didTilingSpriteUpdate = true;
this._didViewChangeTick++;
if (this.didViewUpdate)
return;
this.didViewUpdate = true;
const renderGroup = this.renderGroup || this.parentRenderGroup;
if (renderGroup) {
renderGroup.onChildViewUpdate(this);
}
}
/**
* 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);
this._anchor = null;
this._tileTransform = null;
this._bounds = null;
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;
}
};
/** default options for the TilingSprite */
_TilingSprite.defaultOptions = {
/** The texture to use for the sprite. */
texture: Texture.EMPTY,
/** The anchor point of the sprite */
anchor: { x: 0, y: 0 },
/** The offset of the image that is being tiled. */
tilePosition: { x: 0, y: 0 },
/** Scaling of the image that is being tiled. */
tileScale: { x: 1, y: 1 },
/** The rotation of the image that is being tiled. */
tileRotation: 0,
/** TODO */
applyAnchorToTexture: false
};
let TilingSprite = _TilingSprite;
export { TilingSprite };
//# sourceMappingURL=TilingSprite.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,12 @@
declare global
{
namespace PixiMixins
{
interface RendererPipes
{
tilingSprite: import('./TilingSpritePipe').TilingSpritePipe;
}
}
}
export {};

View File

@@ -0,0 +1,27 @@
import { ExtensionType } from '../../extensions/Extensions';
import { type Renderer } from '../../rendering/renderers/types';
import type { InstructionSet } from '../../rendering/renderers/shared/instructions/InstructionSet';
import type { RenderPipe } from '../../rendering/renderers/shared/instructions/RenderPipe';
import type { TilingSprite } from './TilingSprite';
export declare class TilingSpritePipe implements RenderPipe<TilingSprite> {
/** @ignore */
static extension: {
readonly type: readonly [ExtensionType.WebGLPipes, ExtensionType.WebGPUPipes, ExtensionType.CanvasPipes];
readonly name: "tilingSprite";
};
private _renderer;
private readonly _state;
private readonly _tilingSpriteDataHash;
private readonly _destroyRenderableBound;
constructor(renderer: Renderer);
validateRenderable(renderable: TilingSprite): boolean;
addRenderable(tilingSprite: TilingSprite, instructionSet: InstructionSet): void;
execute(tilingSprite: TilingSprite): void;
updateRenderable(tilingSprite: TilingSprite): void;
destroyRenderable(tilingSprite: TilingSprite): void;
private _getTilingSpriteData;
private _initTilingSpriteData;
private _updateBatchableMesh;
destroy(): void;
private _updateCanBatch;
}

View File

@@ -0,0 +1,165 @@
'use strict';
var Extensions = require('../../extensions/Extensions.js');
var getAdjustedBlendModeBlend = require('../../rendering/renderers/shared/state/getAdjustedBlendModeBlend.js');
var State = require('../../rendering/renderers/shared/state/State.js');
var types = require('../../rendering/renderers/types.js');
var colorToUniform = require('../graphics/gpu/colorToUniform.js');
var BatchableMesh = require('../mesh/shared/BatchableMesh.js');
var MeshGeometry = require('../mesh/shared/MeshGeometry.js');
var TilingSpriteShader = require('./shader/TilingSpriteShader.js');
var QuadGeometry = require('./utils/QuadGeometry.js');
var setPositions = require('./utils/setPositions.js');
var setUvs = require('./utils/setUvs.js');
"use strict";
const sharedQuad = new QuadGeometry.QuadGeometry();
class TilingSpritePipe {
constructor(renderer) {
this._state = State.State.default2d;
this._tilingSpriteDataHash = /* @__PURE__ */ Object.create(null);
this._destroyRenderableBound = this.destroyRenderable.bind(this);
this._renderer = renderer;
}
validateRenderable(renderable) {
const tilingSpriteData = this._getTilingSpriteData(renderable);
const couldBatch = tilingSpriteData.canBatch;
this._updateCanBatch(renderable);
const canBatch = tilingSpriteData.canBatch;
if (canBatch && canBatch === couldBatch) {
const { batchableMesh } = tilingSpriteData;
if (batchableMesh && batchableMesh.texture._source !== renderable.texture._source) {
return !batchableMesh._batcher.checkAndUpdateTexture(batchableMesh, renderable.texture);
}
}
return couldBatch !== canBatch;
}
addRenderable(tilingSprite, instructionSet) {
const batcher = this._renderer.renderPipes.batch;
this._updateCanBatch(tilingSprite);
const tilingSpriteData = this._getTilingSpriteData(tilingSprite);
const { geometry, canBatch } = tilingSpriteData;
if (canBatch) {
tilingSpriteData.batchableMesh || (tilingSpriteData.batchableMesh = new BatchableMesh.BatchableMesh());
const batchableMesh = tilingSpriteData.batchableMesh;
if (tilingSprite._didTilingSpriteUpdate) {
tilingSprite._didTilingSpriteUpdate = false;
this._updateBatchableMesh(tilingSprite);
batchableMesh.geometry = geometry;
batchableMesh.renderable = tilingSprite;
batchableMesh.transform = tilingSprite.groupTransform;
batchableMesh.texture = tilingSprite._texture;
}
batchableMesh.roundPixels = this._renderer._roundPixels | tilingSprite._roundPixels;
batcher.addToBatch(batchableMesh, instructionSet);
} else {
batcher.break(instructionSet);
tilingSpriteData.shader || (tilingSpriteData.shader = new TilingSpriteShader.TilingSpriteShader());
this.updateRenderable(tilingSprite);
instructionSet.add(tilingSprite);
}
}
execute(tilingSprite) {
const { shader } = this._tilingSpriteDataHash[tilingSprite.uid];
shader.groups[0] = this._renderer.globalUniforms.bindGroup;
const localUniforms = shader.resources.localUniforms.uniforms;
localUniforms.uTransformMatrix = tilingSprite.groupTransform;
localUniforms.uRound = this._renderer._roundPixels | tilingSprite._roundPixels;
colorToUniform.color32BitToUniform(
tilingSprite.groupColorAlpha,
localUniforms.uColor,
0
);
this._state.blendMode = getAdjustedBlendModeBlend.getAdjustedBlendModeBlend(tilingSprite.groupBlendMode, tilingSprite.texture._source);
this._renderer.encoder.draw({
geometry: sharedQuad,
shader,
state: this._state
});
}
updateRenderable(tilingSprite) {
const tilingSpriteData = this._getTilingSpriteData(tilingSprite);
const { canBatch } = tilingSpriteData;
if (canBatch) {
const { batchableMesh } = tilingSpriteData;
if (tilingSprite._didTilingSpriteUpdate)
this._updateBatchableMesh(tilingSprite);
batchableMesh._batcher.updateElement(batchableMesh);
} else if (tilingSprite._didTilingSpriteUpdate) {
const { shader } = tilingSpriteData;
shader.updateUniforms(
tilingSprite.width,
tilingSprite.height,
tilingSprite._tileTransform.matrix,
tilingSprite.anchor.x,
tilingSprite.anchor.y,
tilingSprite.texture
);
}
tilingSprite._didTilingSpriteUpdate = false;
}
destroyRenderable(tilingSprite) {
const tilingSpriteData = this._getTilingSpriteData(tilingSprite);
tilingSpriteData.batchableMesh = null;
tilingSpriteData.shader?.destroy();
this._tilingSpriteDataHash[tilingSprite.uid] = null;
tilingSprite.off("destroyed", this._destroyRenderableBound);
}
_getTilingSpriteData(renderable) {
return this._tilingSpriteDataHash[renderable.uid] || this._initTilingSpriteData(renderable);
}
_initTilingSpriteData(tilingSprite) {
const geometry = new MeshGeometry.MeshGeometry({
indices: sharedQuad.indices,
positions: sharedQuad.positions.slice(),
uvs: sharedQuad.uvs.slice()
});
this._tilingSpriteDataHash[tilingSprite.uid] = {
canBatch: true,
renderable: tilingSprite,
geometry
};
tilingSprite.on("destroyed", this._destroyRenderableBound);
return this._tilingSpriteDataHash[tilingSprite.uid];
}
_updateBatchableMesh(tilingSprite) {
const renderableData = this._getTilingSpriteData(tilingSprite);
const { geometry } = renderableData;
const style = tilingSprite.texture.source.style;
if (style.addressMode !== "repeat") {
style.addressMode = "repeat";
style.update();
}
setUvs.setUvs(tilingSprite, geometry.uvs);
setPositions.setPositions(tilingSprite, geometry.positions);
}
destroy() {
for (const i in this._tilingSpriteDataHash) {
this.destroyRenderable(this._tilingSpriteDataHash[i].renderable);
}
this._tilingSpriteDataHash = null;
this._renderer = null;
}
_updateCanBatch(tilingSprite) {
const renderableData = this._getTilingSpriteData(tilingSprite);
const texture = tilingSprite.texture;
let _nonPowOf2wrapping = true;
if (this._renderer.type === types.RendererType.WEBGL) {
_nonPowOf2wrapping = this._renderer.context.supports.nonPowOf2wrapping;
}
renderableData.canBatch = texture.textureMatrix.isSimple && (_nonPowOf2wrapping || texture.source.isPowerOfTwo);
return renderableData.canBatch;
}
}
/** @ignore */
TilingSpritePipe.extension = {
type: [
Extensions.ExtensionType.WebGLPipes,
Extensions.ExtensionType.WebGPUPipes,
Extensions.ExtensionType.CanvasPipes
],
name: "tilingSprite"
};
exports.TilingSpritePipe = TilingSpritePipe;
//# sourceMappingURL=TilingSpritePipe.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,163 @@
import { ExtensionType } from '../../extensions/Extensions.mjs';
import { getAdjustedBlendModeBlend } from '../../rendering/renderers/shared/state/getAdjustedBlendModeBlend.mjs';
import { State } from '../../rendering/renderers/shared/state/State.mjs';
import { RendererType } from '../../rendering/renderers/types.mjs';
import { color32BitToUniform } from '../graphics/gpu/colorToUniform.mjs';
import { BatchableMesh } from '../mesh/shared/BatchableMesh.mjs';
import { MeshGeometry } from '../mesh/shared/MeshGeometry.mjs';
import { TilingSpriteShader } from './shader/TilingSpriteShader.mjs';
import { QuadGeometry } from './utils/QuadGeometry.mjs';
import { setPositions } from './utils/setPositions.mjs';
import { setUvs } from './utils/setUvs.mjs';
"use strict";
const sharedQuad = new QuadGeometry();
class TilingSpritePipe {
constructor(renderer) {
this._state = State.default2d;
this._tilingSpriteDataHash = /* @__PURE__ */ Object.create(null);
this._destroyRenderableBound = this.destroyRenderable.bind(this);
this._renderer = renderer;
}
validateRenderable(renderable) {
const tilingSpriteData = this._getTilingSpriteData(renderable);
const couldBatch = tilingSpriteData.canBatch;
this._updateCanBatch(renderable);
const canBatch = tilingSpriteData.canBatch;
if (canBatch && canBatch === couldBatch) {
const { batchableMesh } = tilingSpriteData;
if (batchableMesh && batchableMesh.texture._source !== renderable.texture._source) {
return !batchableMesh._batcher.checkAndUpdateTexture(batchableMesh, renderable.texture);
}
}
return couldBatch !== canBatch;
}
addRenderable(tilingSprite, instructionSet) {
const batcher = this._renderer.renderPipes.batch;
this._updateCanBatch(tilingSprite);
const tilingSpriteData = this._getTilingSpriteData(tilingSprite);
const { geometry, canBatch } = tilingSpriteData;
if (canBatch) {
tilingSpriteData.batchableMesh || (tilingSpriteData.batchableMesh = new BatchableMesh());
const batchableMesh = tilingSpriteData.batchableMesh;
if (tilingSprite._didTilingSpriteUpdate) {
tilingSprite._didTilingSpriteUpdate = false;
this._updateBatchableMesh(tilingSprite);
batchableMesh.geometry = geometry;
batchableMesh.renderable = tilingSprite;
batchableMesh.transform = tilingSprite.groupTransform;
batchableMesh.texture = tilingSprite._texture;
}
batchableMesh.roundPixels = this._renderer._roundPixels | tilingSprite._roundPixels;
batcher.addToBatch(batchableMesh, instructionSet);
} else {
batcher.break(instructionSet);
tilingSpriteData.shader || (tilingSpriteData.shader = new TilingSpriteShader());
this.updateRenderable(tilingSprite);
instructionSet.add(tilingSprite);
}
}
execute(tilingSprite) {
const { shader } = this._tilingSpriteDataHash[tilingSprite.uid];
shader.groups[0] = this._renderer.globalUniforms.bindGroup;
const localUniforms = shader.resources.localUniforms.uniforms;
localUniforms.uTransformMatrix = tilingSprite.groupTransform;
localUniforms.uRound = this._renderer._roundPixels | tilingSprite._roundPixels;
color32BitToUniform(
tilingSprite.groupColorAlpha,
localUniforms.uColor,
0
);
this._state.blendMode = getAdjustedBlendModeBlend(tilingSprite.groupBlendMode, tilingSprite.texture._source);
this._renderer.encoder.draw({
geometry: sharedQuad,
shader,
state: this._state
});
}
updateRenderable(tilingSprite) {
const tilingSpriteData = this._getTilingSpriteData(tilingSprite);
const { canBatch } = tilingSpriteData;
if (canBatch) {
const { batchableMesh } = tilingSpriteData;
if (tilingSprite._didTilingSpriteUpdate)
this._updateBatchableMesh(tilingSprite);
batchableMesh._batcher.updateElement(batchableMesh);
} else if (tilingSprite._didTilingSpriteUpdate) {
const { shader } = tilingSpriteData;
shader.updateUniforms(
tilingSprite.width,
tilingSprite.height,
tilingSprite._tileTransform.matrix,
tilingSprite.anchor.x,
tilingSprite.anchor.y,
tilingSprite.texture
);
}
tilingSprite._didTilingSpriteUpdate = false;
}
destroyRenderable(tilingSprite) {
const tilingSpriteData = this._getTilingSpriteData(tilingSprite);
tilingSpriteData.batchableMesh = null;
tilingSpriteData.shader?.destroy();
this._tilingSpriteDataHash[tilingSprite.uid] = null;
tilingSprite.off("destroyed", this._destroyRenderableBound);
}
_getTilingSpriteData(renderable) {
return this._tilingSpriteDataHash[renderable.uid] || this._initTilingSpriteData(renderable);
}
_initTilingSpriteData(tilingSprite) {
const geometry = new MeshGeometry({
indices: sharedQuad.indices,
positions: sharedQuad.positions.slice(),
uvs: sharedQuad.uvs.slice()
});
this._tilingSpriteDataHash[tilingSprite.uid] = {
canBatch: true,
renderable: tilingSprite,
geometry
};
tilingSprite.on("destroyed", this._destroyRenderableBound);
return this._tilingSpriteDataHash[tilingSprite.uid];
}
_updateBatchableMesh(tilingSprite) {
const renderableData = this._getTilingSpriteData(tilingSprite);
const { geometry } = renderableData;
const style = tilingSprite.texture.source.style;
if (style.addressMode !== "repeat") {
style.addressMode = "repeat";
style.update();
}
setUvs(tilingSprite, geometry.uvs);
setPositions(tilingSprite, geometry.positions);
}
destroy() {
for (const i in this._tilingSpriteDataHash) {
this.destroyRenderable(this._tilingSpriteDataHash[i].renderable);
}
this._tilingSpriteDataHash = null;
this._renderer = null;
}
_updateCanBatch(tilingSprite) {
const renderableData = this._getTilingSpriteData(tilingSprite);
const texture = tilingSprite.texture;
let _nonPowOf2wrapping = true;
if (this._renderer.type === RendererType.WEBGL) {
_nonPowOf2wrapping = this._renderer.context.supports.nonPowOf2wrapping;
}
renderableData.canBatch = texture.textureMatrix.isSimple && (_nonPowOf2wrapping || texture.source.isPowerOfTwo);
return renderableData.canBatch;
}
}
/** @ignore */
TilingSpritePipe.extension = {
type: [
ExtensionType.WebGLPipes,
ExtensionType.WebGPUPipes,
ExtensionType.CanvasPipes
],
name: "tilingSprite"
};
export { TilingSpritePipe };
//# sourceMappingURL=TilingSpritePipe.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
export {};

8
node_modules/pixi.js/lib/scene/sprite-tiling/init.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
'use strict';
var Extensions = require('../../extensions/Extensions.js');
var TilingSpritePipe = require('./TilingSpritePipe.js');
"use strict";
Extensions.extensions.add(TilingSpritePipe.TilingSpritePipe);
//# sourceMappingURL=init.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"init.js","sources":["../../../src/scene/sprite-tiling/init.ts"],"sourcesContent":["import { extensions } from '../../extensions/Extensions';\nimport { TilingSpritePipe } from './TilingSpritePipe';\n\nextensions.add(TilingSpritePipe);\n"],"names":["extensions","TilingSpritePipe"],"mappings":";;;;;;AAGAA,qBAAA,CAAW,IAAIC,iCAAgB,CAAA;;"}

View File

@@ -0,0 +1,6 @@
import { extensions } from '../../extensions/Extensions.mjs';
import { TilingSpritePipe } from './TilingSpritePipe.mjs';
"use strict";
extensions.add(TilingSpritePipe);
//# sourceMappingURL=init.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"init.mjs","sources":["../../../src/scene/sprite-tiling/init.ts"],"sourcesContent":["import { extensions } from '../../extensions/Extensions';\nimport { TilingSpritePipe } from './TilingSpritePipe';\n\nextensions.add(TilingSpritePipe);\n"],"names":[],"mappings":";;;;AAGA,UAAA,CAAW,IAAI,gBAAgB,CAAA"}

View File

@@ -0,0 +1,7 @@
import { Matrix } from '../../../maths/matrix/Matrix';
import { Shader } from '../../../rendering/renderers/shared/shader/Shader';
import { Texture } from '../../../rendering/renderers/shared/texture/Texture';
export declare class TilingSpriteShader extends Shader {
constructor();
updateUniforms(width: number, height: number, matrix: Matrix, anchorX: number, anchorY: number, texture: Texture): void;
}

View File

@@ -0,0 +1,86 @@
'use strict';
var Matrix = require('../../../maths/matrix/Matrix.js');
var compileHighShaderToProgram = require('../../../rendering/high-shader/compileHighShaderToProgram.js');
var localUniformBit = require('../../../rendering/high-shader/shader-bits/localUniformBit.js');
var roundPixelsBit = require('../../../rendering/high-shader/shader-bits/roundPixelsBit.js');
var Shader = require('../../../rendering/renderers/shared/shader/Shader.js');
var UniformGroup = require('../../../rendering/renderers/shared/shader/UniformGroup.js');
var Texture = require('../../../rendering/renderers/shared/texture/Texture.js');
var tilingBit = require('./tilingBit.js');
"use strict";
let gpuProgram;
let glProgram;
class TilingSpriteShader extends Shader.Shader {
constructor() {
gpuProgram ?? (gpuProgram = compileHighShaderToProgram.compileHighShaderGpuProgram({
name: "tiling-sprite-shader",
bits: [
localUniformBit.localUniformBit,
tilingBit.tilingBit,
roundPixelsBit.roundPixelsBit
]
}));
glProgram ?? (glProgram = compileHighShaderToProgram.compileHighShaderGlProgram({
name: "tiling-sprite-shader",
bits: [
localUniformBit.localUniformBitGl,
tilingBit.tilingBitGl,
roundPixelsBit.roundPixelsBitGl
]
}));
const tilingUniforms = new UniformGroup.UniformGroup({
uMapCoord: { value: new Matrix.Matrix(), type: "mat3x3<f32>" },
uClampFrame: { value: new Float32Array([0, 0, 1, 1]), type: "vec4<f32>" },
uClampOffset: { value: new Float32Array([0, 0]), type: "vec2<f32>" },
uTextureTransform: { value: new Matrix.Matrix(), type: "mat3x3<f32>" },
uSizeAnchor: { value: new Float32Array([100, 100, 0.5, 0.5]), type: "vec4<f32>" }
});
super({
glProgram,
gpuProgram,
resources: {
localUniforms: new UniformGroup.UniformGroup({
uTransformMatrix: { value: new Matrix.Matrix(), type: "mat3x3<f32>" },
uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
uRound: { value: 0, type: "f32" }
}),
tilingUniforms,
uTexture: Texture.Texture.EMPTY.source,
uSampler: Texture.Texture.EMPTY.source.style
}
});
}
updateUniforms(width, height, matrix, anchorX, anchorY, texture) {
const tilingUniforms = this.resources.tilingUniforms;
const textureWidth = texture.width;
const textureHeight = texture.height;
const textureMatrix = texture.textureMatrix;
const uTextureTransform = tilingUniforms.uniforms.uTextureTransform;
uTextureTransform.set(
matrix.a * textureWidth / width,
matrix.b * textureWidth / height,
matrix.c * textureHeight / width,
matrix.d * textureHeight / height,
matrix.tx / width,
matrix.ty / height
);
uTextureTransform.invert();
tilingUniforms.uniforms.uMapCoord = textureMatrix.mapCoord;
tilingUniforms.uniforms.uClampFrame = textureMatrix.uClampFrame;
tilingUniforms.uniforms.uClampOffset = textureMatrix.uClampOffset;
tilingUniforms.uniforms.uTextureTransform = uTextureTransform;
tilingUniforms.uniforms.uSizeAnchor[0] = width;
tilingUniforms.uniforms.uSizeAnchor[1] = height;
tilingUniforms.uniforms.uSizeAnchor[2] = anchorX;
tilingUniforms.uniforms.uSizeAnchor[3] = anchorY;
if (texture) {
this.resources.uTexture = texture.source;
this.resources.uSampler = texture.source.style;
}
}
}
exports.TilingSpriteShader = TilingSpriteShader;
//# sourceMappingURL=TilingSpriteShader.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,84 @@
import { Matrix } from '../../../maths/matrix/Matrix.mjs';
import { compileHighShaderGpuProgram, compileHighShaderGlProgram } from '../../../rendering/high-shader/compileHighShaderToProgram.mjs';
import { localUniformBit, localUniformBitGl } from '../../../rendering/high-shader/shader-bits/localUniformBit.mjs';
import { roundPixelsBit, roundPixelsBitGl } from '../../../rendering/high-shader/shader-bits/roundPixelsBit.mjs';
import { Shader } from '../../../rendering/renderers/shared/shader/Shader.mjs';
import { UniformGroup } from '../../../rendering/renderers/shared/shader/UniformGroup.mjs';
import { Texture } from '../../../rendering/renderers/shared/texture/Texture.mjs';
import { tilingBit, tilingBitGl } from './tilingBit.mjs';
"use strict";
let gpuProgram;
let glProgram;
class TilingSpriteShader extends Shader {
constructor() {
gpuProgram ?? (gpuProgram = compileHighShaderGpuProgram({
name: "tiling-sprite-shader",
bits: [
localUniformBit,
tilingBit,
roundPixelsBit
]
}));
glProgram ?? (glProgram = compileHighShaderGlProgram({
name: "tiling-sprite-shader",
bits: [
localUniformBitGl,
tilingBitGl,
roundPixelsBitGl
]
}));
const tilingUniforms = new UniformGroup({
uMapCoord: { value: new Matrix(), type: "mat3x3<f32>" },
uClampFrame: { value: new Float32Array([0, 0, 1, 1]), type: "vec4<f32>" },
uClampOffset: { value: new Float32Array([0, 0]), type: "vec2<f32>" },
uTextureTransform: { value: new Matrix(), type: "mat3x3<f32>" },
uSizeAnchor: { value: new Float32Array([100, 100, 0.5, 0.5]), type: "vec4<f32>" }
});
super({
glProgram,
gpuProgram,
resources: {
localUniforms: new UniformGroup({
uTransformMatrix: { value: new Matrix(), type: "mat3x3<f32>" },
uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
uRound: { value: 0, type: "f32" }
}),
tilingUniforms,
uTexture: Texture.EMPTY.source,
uSampler: Texture.EMPTY.source.style
}
});
}
updateUniforms(width, height, matrix, anchorX, anchorY, texture) {
const tilingUniforms = this.resources.tilingUniforms;
const textureWidth = texture.width;
const textureHeight = texture.height;
const textureMatrix = texture.textureMatrix;
const uTextureTransform = tilingUniforms.uniforms.uTextureTransform;
uTextureTransform.set(
matrix.a * textureWidth / width,
matrix.b * textureWidth / height,
matrix.c * textureHeight / width,
matrix.d * textureHeight / height,
matrix.tx / width,
matrix.ty / height
);
uTextureTransform.invert();
tilingUniforms.uniforms.uMapCoord = textureMatrix.mapCoord;
tilingUniforms.uniforms.uClampFrame = textureMatrix.uClampFrame;
tilingUniforms.uniforms.uClampOffset = textureMatrix.uClampOffset;
tilingUniforms.uniforms.uTextureTransform = uTextureTransform;
tilingUniforms.uniforms.uSizeAnchor[0] = width;
tilingUniforms.uniforms.uSizeAnchor[1] = height;
tilingUniforms.uniforms.uSizeAnchor[2] = anchorX;
tilingUniforms.uniforms.uSizeAnchor[3] = anchorY;
if (texture) {
this.resources.uTexture = texture.source;
this.resources.uSampler = texture.source.style;
}
}
}
export { TilingSpriteShader };
//# sourceMappingURL=TilingSpriteShader.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,22 @@
export declare const tilingBit: {
name: string;
vertex: {
header: string;
main: string;
};
fragment: {
header: string;
main: string;
};
};
export declare const tilingBitGl: {
name: string;
vertex: {
header: string;
main: string;
};
fragment: {
header: string;
main: string;
};
};

View File

@@ -0,0 +1,118 @@
'use strict';
"use strict";
const tilingBit = {
name: "tiling-bit",
vertex: {
header: (
/* wgsl */
`
struct TilingUniforms {
uMapCoord:mat3x3<f32>,
uClampFrame:vec4<f32>,
uClampOffset:vec2<f32>,
uTextureTransform:mat3x3<f32>,
uSizeAnchor:vec4<f32>
};
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
@group(2) @binding(1) var uTexture: texture_2d<f32>;
@group(2) @binding(2) var uSampler: sampler;
`
),
main: (
/* wgsl */
`
uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;
position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
`
)
},
fragment: {
header: (
/* wgsl */
`
struct TilingUniforms {
uMapCoord:mat3x3<f32>,
uClampFrame:vec4<f32>,
uClampOffset:vec2<f32>,
uTextureTransform:mat3x3<f32>,
uSizeAnchor:vec4<f32>
};
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
@group(2) @binding(1) var uTexture: texture_2d<f32>;
@group(2) @binding(2) var uSampler: sampler;
`
),
main: (
/* wgsl */
`
var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
var unclamped = coord;
coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);
var bias = 0.;
if(unclamped.x == coord.x && unclamped.y == coord.y)
{
bias = -32.;
}
outColor = textureSampleBias(uTexture, uSampler, coord, bias);
`
)
}
};
const tilingBitGl = {
name: "tiling-bit",
vertex: {
header: (
/* glsl */
`
uniform mat3 uTextureTransform;
uniform vec4 uSizeAnchor;
`
),
main: (
/* glsl */
`
uv = (uTextureTransform * vec3(aUV, 1.0)).xy;
position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;
`
)
},
fragment: {
header: (
/* glsl */
`
uniform sampler2D uTexture;
uniform mat3 uMapCoord;
uniform vec4 uClampFrame;
uniform vec2 uClampOffset;
`
),
main: (
/* glsl */
`
vec2 coord = vUV + ceil(uClampOffset - vUV);
coord = (uMapCoord * vec3(coord, 1.0)).xy;
vec2 unclamped = coord;
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
`
)
}
};
exports.tilingBit = tilingBit;
exports.tilingBitGl = tilingBitGl;
//# sourceMappingURL=tilingBit.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"tilingBit.js","sources":["../../../../src/scene/sprite-tiling/shader/tilingBit.ts"],"sourcesContent":["export const tilingBit = {\n name: 'tiling-bit',\n vertex: {\n header: /* wgsl */`\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n `,\n main: /* wgsl */`\n uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;\n\n position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;\n `\n\n },\n fragment: {\n header: /* wgsl */`\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n `,\n main: /* wgsl */`\n\n var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);\n coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;\n var unclamped = coord;\n coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);\n\n var bias = 0.;\n\n if(unclamped.x == coord.x && unclamped.y == coord.y)\n {\n bias = -32.;\n } \n\n outColor = textureSampleBias(uTexture, uSampler, coord, bias);\n `\n }\n\n};\n\nexport const tilingBitGl = {\n name: 'tiling-bit',\n vertex: {\n header: /* glsl */`\n uniform mat3 uTextureTransform;\n uniform vec4 uSizeAnchor;\n \n `,\n main: /* glsl */`\n uv = (uTextureTransform * vec3(aUV, 1.0)).xy;\n\n position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;\n `\n\n },\n fragment: {\n header: /* glsl */`\n uniform sampler2D uTexture;\n uniform mat3 uMapCoord;\n uniform vec4 uClampFrame;\n uniform vec2 uClampOffset;\n `,\n main: /* glsl */`\n\n vec2 coord = vUV + ceil(uClampOffset - vUV);\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n vec2 unclamped = coord;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n \n outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0\n \n `\n }\n\n};\n"],"names":[],"mappings":";;;AAAO,MAAM,SAAY,GAAA;AAAA,EACrB,IAAM,EAAA,YAAA;AAAA,EACN,MAAQ,EAAA;AAAA,IACJ,MAAA;AAAA;AAAA,MAAkB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,IAalB,IAAA;AAAA;AAAA,MAAgB,CAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,GAMpB;AAAA,EACA,QAAU,EAAA;AAAA,IACN,MAAA;AAAA;AAAA,MAAkB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,IAalB,IAAA;AAAA;AAAA,MAAgB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,GAgBpB;AAEJ,EAAA;AAEO,MAAM,WAAc,GAAA;AAAA,EACvB,IAAM,EAAA,YAAA;AAAA,EACN,MAAQ,EAAA;AAAA,IACJ,MAAA;AAAA;AAAA,MAAkB,CAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,IAKlB,IAAA;AAAA;AAAA,MAAgB,CAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,GAMpB;AAAA,EACA,QAAU,EAAA;AAAA,IACN,MAAA;AAAA;AAAA,MAAkB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,IAMlB,IAAA;AAAA;AAAA,MAAgB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,GAUpB;AAEJ;;;;;"}

View File

@@ -0,0 +1,115 @@
"use strict";
const tilingBit = {
name: "tiling-bit",
vertex: {
header: (
/* wgsl */
`
struct TilingUniforms {
uMapCoord:mat3x3<f32>,
uClampFrame:vec4<f32>,
uClampOffset:vec2<f32>,
uTextureTransform:mat3x3<f32>,
uSizeAnchor:vec4<f32>
};
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
@group(2) @binding(1) var uTexture: texture_2d<f32>;
@group(2) @binding(2) var uSampler: sampler;
`
),
main: (
/* wgsl */
`
uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;
position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
`
)
},
fragment: {
header: (
/* wgsl */
`
struct TilingUniforms {
uMapCoord:mat3x3<f32>,
uClampFrame:vec4<f32>,
uClampOffset:vec2<f32>,
uTextureTransform:mat3x3<f32>,
uSizeAnchor:vec4<f32>
};
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
@group(2) @binding(1) var uTexture: texture_2d<f32>;
@group(2) @binding(2) var uSampler: sampler;
`
),
main: (
/* wgsl */
`
var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
var unclamped = coord;
coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);
var bias = 0.;
if(unclamped.x == coord.x && unclamped.y == coord.y)
{
bias = -32.;
}
outColor = textureSampleBias(uTexture, uSampler, coord, bias);
`
)
}
};
const tilingBitGl = {
name: "tiling-bit",
vertex: {
header: (
/* glsl */
`
uniform mat3 uTextureTransform;
uniform vec4 uSizeAnchor;
`
),
main: (
/* glsl */
`
uv = (uTextureTransform * vec3(aUV, 1.0)).xy;
position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;
`
)
},
fragment: {
header: (
/* glsl */
`
uniform sampler2D uTexture;
uniform mat3 uMapCoord;
uniform vec4 uClampFrame;
uniform vec2 uClampOffset;
`
),
main: (
/* glsl */
`
vec2 coord = vUV + ceil(uClampOffset - vUV);
coord = (uMapCoord * vec3(coord, 1.0)).xy;
vec2 unclamped = coord;
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
`
)
}
};
export { tilingBit, tilingBitGl };
//# sourceMappingURL=tilingBit.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"tilingBit.mjs","sources":["../../../../src/scene/sprite-tiling/shader/tilingBit.ts"],"sourcesContent":["export const tilingBit = {\n name: 'tiling-bit',\n vertex: {\n header: /* wgsl */`\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n `,\n main: /* wgsl */`\n uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;\n\n position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;\n `\n\n },\n fragment: {\n header: /* wgsl */`\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n `,\n main: /* wgsl */`\n\n var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);\n coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;\n var unclamped = coord;\n coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);\n\n var bias = 0.;\n\n if(unclamped.x == coord.x && unclamped.y == coord.y)\n {\n bias = -32.;\n } \n\n outColor = textureSampleBias(uTexture, uSampler, coord, bias);\n `\n }\n\n};\n\nexport const tilingBitGl = {\n name: 'tiling-bit',\n vertex: {\n header: /* glsl */`\n uniform mat3 uTextureTransform;\n uniform vec4 uSizeAnchor;\n \n `,\n main: /* glsl */`\n uv = (uTextureTransform * vec3(aUV, 1.0)).xy;\n\n position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;\n `\n\n },\n fragment: {\n header: /* glsl */`\n uniform sampler2D uTexture;\n uniform mat3 uMapCoord;\n uniform vec4 uClampFrame;\n uniform vec2 uClampOffset;\n `,\n main: /* glsl */`\n\n vec2 coord = vUV + ceil(uClampOffset - vUV);\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n vec2 unclamped = coord;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n \n outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0\n \n `\n }\n\n};\n"],"names":[],"mappings":";AAAO,MAAM,SAAY,GAAA;AAAA,EACrB,IAAM,EAAA,YAAA;AAAA,EACN,MAAQ,EAAA;AAAA,IACJ,MAAA;AAAA;AAAA,MAAkB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,IAalB,IAAA;AAAA;AAAA,MAAgB,CAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,GAMpB;AAAA,EACA,QAAU,EAAA;AAAA,IACN,MAAA;AAAA;AAAA,MAAkB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,IAalB,IAAA;AAAA;AAAA,MAAgB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,GAgBpB;AAEJ,EAAA;AAEO,MAAM,WAAc,GAAA;AAAA,EACvB,IAAM,EAAA,YAAA;AAAA,EACN,MAAQ,EAAA;AAAA,IACJ,MAAA;AAAA;AAAA,MAAkB,CAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,IAKlB,IAAA;AAAA;AAAA,MAAgB,CAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,GAMpB;AAAA,EACA,QAAU,EAAA;AAAA,IACN,MAAA;AAAA;AAAA,MAAkB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,IAMlB,IAAA;AAAA;AAAA,MAAgB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAA,CAAA;AAAA,KAAA;AAAA,GAUpB;AAEJ;;;;"}

View File

@@ -0,0 +1,4 @@
import { MeshGeometry } from '../../mesh/shared/MeshGeometry';
export declare class QuadGeometry extends MeshGeometry {
constructor();
}

View File

@@ -0,0 +1,17 @@
'use strict';
var MeshGeometry = require('../../mesh/shared/MeshGeometry.js');
"use strict";
class QuadGeometry extends MeshGeometry.MeshGeometry {
constructor() {
super({
positions: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),
uvs: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),
indices: new Uint32Array([0, 1, 2, 0, 2, 3])
});
}
}
exports.QuadGeometry = QuadGeometry;
//# sourceMappingURL=QuadGeometry.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"QuadGeometry.js","sources":["../../../../src/scene/sprite-tiling/utils/QuadGeometry.ts"],"sourcesContent":["import { MeshGeometry } from '../../mesh/shared/MeshGeometry';\n\nexport class QuadGeometry extends MeshGeometry\n{\n constructor()\n {\n super({\n positions: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),\n uvs: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),\n indices: new Uint32Array([0, 1, 2, 0, 2, 3]),\n });\n }\n}\n"],"names":["MeshGeometry"],"mappings":";;;;;AAEO,MAAM,qBAAqBA,yBAClC,CAAA;AAAA,EACI,WACA,GAAA;AACI,IAAM,KAAA,CAAA;AAAA,MACF,SAAW,EAAA,IAAI,YAAa,CAAA,CAAC,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAC,CAAC,CAAA;AAAA,MACpD,GAAK,EAAA,IAAI,YAAa,CAAA,CAAC,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAC,CAAC,CAAA;AAAA,MAC9C,OAAA,EAAS,IAAI,WAAA,CAAY,CAAC,CAAA,EAAG,GAAG,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAC,CAAC,CAAA;AAAA,KAC9C,CAAA,CAAA;AAAA,GACL;AACJ;;;;"}

View File

@@ -0,0 +1,15 @@
import { MeshGeometry } from '../../mesh/shared/MeshGeometry.mjs';
"use strict";
class QuadGeometry extends MeshGeometry {
constructor() {
super({
positions: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),
uvs: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),
indices: new Uint32Array([0, 1, 2, 0, 2, 3])
});
}
}
export { QuadGeometry };
//# sourceMappingURL=QuadGeometry.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"QuadGeometry.mjs","sources":["../../../../src/scene/sprite-tiling/utils/QuadGeometry.ts"],"sourcesContent":["import { MeshGeometry } from '../../mesh/shared/MeshGeometry';\n\nexport class QuadGeometry extends MeshGeometry\n{\n constructor()\n {\n super({\n positions: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),\n uvs: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),\n indices: new Uint32Array([0, 1, 2, 0, 2, 3]),\n });\n }\n}\n"],"names":[],"mappings":";;;AAEO,MAAM,qBAAqB,YAClC,CAAA;AAAA,EACI,WACA,GAAA;AACI,IAAM,KAAA,CAAA;AAAA,MACF,SAAW,EAAA,IAAI,YAAa,CAAA,CAAC,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAC,CAAC,CAAA;AAAA,MACpD,GAAK,EAAA,IAAI,YAAa,CAAA,CAAC,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAC,CAAC,CAAA;AAAA,MAC9C,OAAA,EAAS,IAAI,WAAA,CAAY,CAAC,CAAA,EAAG,GAAG,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAC,CAAC,CAAA;AAAA,KAC9C,CAAA,CAAA;AAAA,GACL;AACJ;;;;"}

View File

@@ -0,0 +1,3 @@
import type { Matrix } from '../../../maths/matrix/Matrix';
import type { TypedArray } from '../../../rendering/renderers/shared/buffer/Buffer';
export declare function applyMatrix(array: TypedArray, stride: number, offset: number, matrix: Matrix): void;

View File

@@ -0,0 +1,25 @@
'use strict';
"use strict";
function applyMatrix(array, stride, offset, matrix) {
let index = 0;
const size = array.length / (stride || 2);
const a = matrix.a;
const b = matrix.b;
const c = matrix.c;
const d = matrix.d;
const tx = matrix.tx;
const ty = matrix.ty;
offset *= stride;
while (index < size) {
const x = array[offset];
const y = array[offset + 1];
array[offset] = a * x + c * y + tx;
array[offset + 1] = b * x + d * y + ty;
offset += stride;
index++;
}
}
exports.applyMatrix = applyMatrix;
//# sourceMappingURL=applyMatrix.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"applyMatrix.js","sources":["../../../../src/scene/sprite-tiling/utils/applyMatrix.ts"],"sourcesContent":["import type { Matrix } from '../../../maths/matrix/Matrix';\nimport type { TypedArray } from '../../../rendering/renderers/shared/buffer/Buffer';\n\nexport function applyMatrix(array: TypedArray, stride: number, offset: number, matrix: Matrix)\n{\n let index = 0;\n const size = array.length / (stride || 2);\n\n const a = matrix.a;\n const b = matrix.b;\n const c = matrix.c;\n const d = matrix.d;\n const tx = matrix.tx;\n const ty = matrix.ty;\n\n offset *= stride;\n\n while (index < size)\n {\n const x = array[offset];\n const y = array[offset + 1];\n\n array[offset] = (a * x) + (c * y) + tx;\n array[offset + 1] = (b * x) + (d * y) + ty;\n\n offset += stride;\n\n index++;\n }\n}\n"],"names":[],"mappings":";;;AAGO,SAAS,WAAY,CAAA,KAAA,EAAmB,MAAgB,EAAA,MAAA,EAAgB,MAC/E,EAAA;AACI,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AACZ,EAAM,MAAA,IAAA,GAAO,KAAM,CAAA,MAAA,IAAU,MAAU,IAAA,CAAA,CAAA,CAAA;AAEvC,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,KAAK,MAAO,CAAA,EAAA,CAAA;AAClB,EAAA,MAAM,KAAK,MAAO,CAAA,EAAA,CAAA;AAElB,EAAU,MAAA,IAAA,MAAA,CAAA;AAEV,EAAA,OAAO,QAAQ,IACf,EAAA;AACI,IAAM,MAAA,CAAA,GAAI,MAAM,MAAM,CAAA,CAAA;AACtB,IAAM,MAAA,CAAA,GAAI,KAAM,CAAA,MAAA,GAAS,CAAC,CAAA,CAAA;AAE1B,IAAA,KAAA,CAAM,MAAM,CAAA,GAAK,CAAI,GAAA,CAAA,GAAM,IAAI,CAAK,GAAA,EAAA,CAAA;AACpC,IAAA,KAAA,CAAM,SAAS,CAAC,CAAA,GAAK,CAAI,GAAA,CAAA,GAAM,IAAI,CAAK,GAAA,EAAA,CAAA;AAExC,IAAU,MAAA,IAAA,MAAA,CAAA;AAEV,IAAA,KAAA,EAAA,CAAA;AAAA,GACJ;AACJ;;;;"}

View File

@@ -0,0 +1,23 @@
"use strict";
function applyMatrix(array, stride, offset, matrix) {
let index = 0;
const size = array.length / (stride || 2);
const a = matrix.a;
const b = matrix.b;
const c = matrix.c;
const d = matrix.d;
const tx = matrix.tx;
const ty = matrix.ty;
offset *= stride;
while (index < size) {
const x = array[offset];
const y = array[offset + 1];
array[offset] = a * x + c * y + tx;
array[offset + 1] = b * x + d * y + ty;
offset += stride;
index++;
}
}
export { applyMatrix };
//# sourceMappingURL=applyMatrix.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"applyMatrix.mjs","sources":["../../../../src/scene/sprite-tiling/utils/applyMatrix.ts"],"sourcesContent":["import type { Matrix } from '../../../maths/matrix/Matrix';\nimport type { TypedArray } from '../../../rendering/renderers/shared/buffer/Buffer';\n\nexport function applyMatrix(array: TypedArray, stride: number, offset: number, matrix: Matrix)\n{\n let index = 0;\n const size = array.length / (stride || 2);\n\n const a = matrix.a;\n const b = matrix.b;\n const c = matrix.c;\n const d = matrix.d;\n const tx = matrix.tx;\n const ty = matrix.ty;\n\n offset *= stride;\n\n while (index < size)\n {\n const x = array[offset];\n const y = array[offset + 1];\n\n array[offset] = (a * x) + (c * y) + tx;\n array[offset + 1] = (b * x) + (d * y) + ty;\n\n offset += stride;\n\n index++;\n }\n}\n"],"names":[],"mappings":";AAGO,SAAS,WAAY,CAAA,KAAA,EAAmB,MAAgB,EAAA,MAAA,EAAgB,MAC/E,EAAA;AACI,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AACZ,EAAM,MAAA,IAAA,GAAO,KAAM,CAAA,MAAA,IAAU,MAAU,IAAA,CAAA,CAAA,CAAA;AAEvC,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,KAAK,MAAO,CAAA,EAAA,CAAA;AAClB,EAAA,MAAM,KAAK,MAAO,CAAA,EAAA,CAAA;AAElB,EAAU,MAAA,IAAA,MAAA,CAAA;AAEV,EAAA,OAAO,QAAQ,IACf,EAAA;AACI,IAAM,MAAA,CAAA,GAAI,MAAM,MAAM,CAAA,CAAA;AACtB,IAAM,MAAA,CAAA,GAAI,KAAM,CAAA,MAAA,GAAS,CAAC,CAAA,CAAA;AAE1B,IAAA,KAAA,CAAM,MAAM,CAAA,GAAK,CAAI,GAAA,CAAA,GAAM,IAAI,CAAK,GAAA,EAAA,CAAA;AACpC,IAAA,KAAA,CAAM,SAAS,CAAC,CAAA,GAAK,CAAI,GAAA,CAAA,GAAM,IAAI,CAAK,GAAA,EAAA,CAAA;AAExC,IAAU,MAAA,IAAA,MAAA,CAAA;AAEV,IAAA,KAAA,EAAA,CAAA;AAAA,GACJ;AACJ;;;;"}

View File

@@ -0,0 +1,2 @@
import type { TilingSprite } from '../TilingSprite';
export declare function setPositions(tilingSprite: TilingSprite, positions: Float32Array): void;

View File

@@ -0,0 +1,18 @@
'use strict';
"use strict";
function setPositions(tilingSprite, positions) {
const anchorX = tilingSprite.anchor.x;
const anchorY = tilingSprite.anchor.y;
positions[0] = -anchorX * tilingSprite.width;
positions[1] = -anchorY * tilingSprite.height;
positions[2] = (1 - anchorX) * tilingSprite.width;
positions[3] = -anchorY * tilingSprite.height;
positions[4] = (1 - anchorX) * tilingSprite.width;
positions[5] = (1 - anchorY) * tilingSprite.height;
positions[6] = -anchorX * tilingSprite.width;
positions[7] = (1 - anchorY) * tilingSprite.height;
}
exports.setPositions = setPositions;
//# sourceMappingURL=setPositions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"setPositions.js","sources":["../../../../src/scene/sprite-tiling/utils/setPositions.ts"],"sourcesContent":["import type { TilingSprite } from '../TilingSprite';\n\nexport function setPositions(tilingSprite: TilingSprite, positions: Float32Array)\n{\n const anchorX = tilingSprite.anchor.x;\n const anchorY = tilingSprite.anchor.y;\n\n positions[0] = -anchorX * tilingSprite.width;\n positions[1] = -anchorY * tilingSprite.height;\n positions[2] = (1 - anchorX) * tilingSprite.width;\n positions[3] = -anchorY * tilingSprite.height;\n positions[4] = (1 - anchorX) * tilingSprite.width;\n positions[5] = (1 - anchorY) * tilingSprite.height;\n positions[6] = -anchorX * tilingSprite.width;\n positions[7] = (1 - anchorY) * tilingSprite.height;\n}\n"],"names":[],"mappings":";;;AAEgB,SAAA,YAAA,CAAa,cAA4B,SACzD,EAAA;AACI,EAAM,MAAA,OAAA,GAAU,aAAa,MAAO,CAAA,CAAA,CAAA;AACpC,EAAM,MAAA,OAAA,GAAU,aAAa,MAAO,CAAA,CAAA,CAAA;AAEpC,EAAA,SAAA,CAAU,CAAC,CAAA,GAAI,CAAC,OAAA,GAAU,YAAa,CAAA,KAAA,CAAA;AACvC,EAAA,SAAA,CAAU,CAAC,CAAA,GAAI,CAAC,OAAA,GAAU,YAAa,CAAA,MAAA,CAAA;AACvC,EAAA,SAAA,CAAU,CAAC,CAAA,GAAA,CAAK,CAAI,GAAA,OAAA,IAAW,YAAa,CAAA,KAAA,CAAA;AAC5C,EAAA,SAAA,CAAU,CAAC,CAAA,GAAI,CAAC,OAAA,GAAU,YAAa,CAAA,MAAA,CAAA;AACvC,EAAA,SAAA,CAAU,CAAC,CAAA,GAAA,CAAK,CAAI,GAAA,OAAA,IAAW,YAAa,CAAA,KAAA,CAAA;AAC5C,EAAA,SAAA,CAAU,CAAC,CAAA,GAAA,CAAK,CAAI,GAAA,OAAA,IAAW,YAAa,CAAA,MAAA,CAAA;AAC5C,EAAA,SAAA,CAAU,CAAC,CAAA,GAAI,CAAC,OAAA,GAAU,YAAa,CAAA,KAAA,CAAA;AACvC,EAAA,SAAA,CAAU,CAAC,CAAA,GAAA,CAAK,CAAI,GAAA,OAAA,IAAW,YAAa,CAAA,MAAA,CAAA;AAChD;;;;"}

View File

@@ -0,0 +1,16 @@
"use strict";
function setPositions(tilingSprite, positions) {
const anchorX = tilingSprite.anchor.x;
const anchorY = tilingSprite.anchor.y;
positions[0] = -anchorX * tilingSprite.width;
positions[1] = -anchorY * tilingSprite.height;
positions[2] = (1 - anchorX) * tilingSprite.width;
positions[3] = -anchorY * tilingSprite.height;
positions[4] = (1 - anchorX) * tilingSprite.width;
positions[5] = (1 - anchorY) * tilingSprite.height;
positions[6] = -anchorX * tilingSprite.width;
positions[7] = (1 - anchorY) * tilingSprite.height;
}
export { setPositions };
//# sourceMappingURL=setPositions.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"setPositions.mjs","sources":["../../../../src/scene/sprite-tiling/utils/setPositions.ts"],"sourcesContent":["import type { TilingSprite } from '../TilingSprite';\n\nexport function setPositions(tilingSprite: TilingSprite, positions: Float32Array)\n{\n const anchorX = tilingSprite.anchor.x;\n const anchorY = tilingSprite.anchor.y;\n\n positions[0] = -anchorX * tilingSprite.width;\n positions[1] = -anchorY * tilingSprite.height;\n positions[2] = (1 - anchorX) * tilingSprite.width;\n positions[3] = -anchorY * tilingSprite.height;\n positions[4] = (1 - anchorX) * tilingSprite.width;\n positions[5] = (1 - anchorY) * tilingSprite.height;\n positions[6] = -anchorX * tilingSprite.width;\n positions[7] = (1 - anchorY) * tilingSprite.height;\n}\n"],"names":[],"mappings":";AAEgB,SAAA,YAAA,CAAa,cAA4B,SACzD,EAAA;AACI,EAAM,MAAA,OAAA,GAAU,aAAa,MAAO,CAAA,CAAA,CAAA;AACpC,EAAM,MAAA,OAAA,GAAU,aAAa,MAAO,CAAA,CAAA,CAAA;AAEpC,EAAA,SAAA,CAAU,CAAC,CAAA,GAAI,CAAC,OAAA,GAAU,YAAa,CAAA,KAAA,CAAA;AACvC,EAAA,SAAA,CAAU,CAAC,CAAA,GAAI,CAAC,OAAA,GAAU,YAAa,CAAA,MAAA,CAAA;AACvC,EAAA,SAAA,CAAU,CAAC,CAAA,GAAA,CAAK,CAAI,GAAA,OAAA,IAAW,YAAa,CAAA,KAAA,CAAA;AAC5C,EAAA,SAAA,CAAU,CAAC,CAAA,GAAI,CAAC,OAAA,GAAU,YAAa,CAAA,MAAA,CAAA;AACvC,EAAA,SAAA,CAAU,CAAC,CAAA,GAAA,CAAK,CAAI,GAAA,OAAA,IAAW,YAAa,CAAA,KAAA,CAAA;AAC5C,EAAA,SAAA,CAAU,CAAC,CAAA,GAAA,CAAK,CAAI,GAAA,OAAA,IAAW,YAAa,CAAA,MAAA,CAAA;AAC5C,EAAA,SAAA,CAAU,CAAC,CAAA,GAAI,CAAC,OAAA,GAAU,YAAa,CAAA,KAAA,CAAA;AACvC,EAAA,SAAA,CAAU,CAAC,CAAA,GAAA,CAAK,CAAI,GAAA,OAAA,IAAW,YAAa,CAAA,MAAA,CAAA;AAChD;;;;"}

View File

@@ -0,0 +1,2 @@
import type { TilingSprite } from '../TilingSprite';
export declare function setUvs(tilingSprite: TilingSprite, uvs: Float32Array): void;

View File

@@ -0,0 +1,31 @@
'use strict';
var Matrix = require('../../../maths/matrix/Matrix.js');
var applyMatrix = require('./applyMatrix.js');
"use strict";
function setUvs(tilingSprite, uvs) {
const texture = tilingSprite.texture;
const width = texture.frame.width;
const height = texture.frame.height;
let anchorX = 0;
let anchorY = 0;
if (tilingSprite._applyAnchorToTexture) {
anchorX = tilingSprite.anchor.x;
anchorY = tilingSprite.anchor.y;
}
uvs[0] = uvs[6] = -anchorX;
uvs[2] = uvs[4] = 1 - anchorX;
uvs[1] = uvs[3] = -anchorY;
uvs[5] = uvs[7] = 1 - anchorY;
const textureMatrix = Matrix.Matrix.shared;
textureMatrix.copyFrom(tilingSprite._tileTransform.matrix);
textureMatrix.tx /= tilingSprite.width;
textureMatrix.ty /= tilingSprite.height;
textureMatrix.invert();
textureMatrix.scale(tilingSprite.width / width, tilingSprite.height / height);
applyMatrix.applyMatrix(uvs, 2, 0, textureMatrix);
}
exports.setUvs = setUvs;
//# sourceMappingURL=setUvs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"setUvs.js","sources":["../../../../src/scene/sprite-tiling/utils/setUvs.ts"],"sourcesContent":["import { Matrix } from '../../../maths/matrix/Matrix';\nimport { applyMatrix } from './applyMatrix';\n\nimport type { TilingSprite } from '../TilingSprite';\n\nexport function setUvs(tilingSprite: TilingSprite, uvs: Float32Array)\n{\n const texture = tilingSprite.texture;\n\n const width = texture.frame.width;\n const height = texture.frame.height;\n\n let anchorX = 0;\n let anchorY = 0;\n\n if (tilingSprite._applyAnchorToTexture)\n {\n anchorX = tilingSprite.anchor.x;\n anchorY = tilingSprite.anchor.y;\n }\n\n uvs[0] = uvs[6] = -anchorX;\n uvs[2] = uvs[4] = 1 - anchorX;\n uvs[1] = uvs[3] = -anchorY;\n uvs[5] = uvs[7] = 1 - anchorY;\n\n const textureMatrix = Matrix.shared;\n\n textureMatrix.copyFrom(tilingSprite._tileTransform.matrix);\n\n textureMatrix.tx /= tilingSprite.width;\n textureMatrix.ty /= tilingSprite.height;\n\n textureMatrix.invert();\n\n textureMatrix.scale(tilingSprite.width / width, tilingSprite.height / height);\n\n applyMatrix(uvs, 2, 0, textureMatrix);\n}\n"],"names":["Matrix","applyMatrix"],"mappings":";;;;;;AAKgB,SAAA,MAAA,CAAO,cAA4B,GACnD,EAAA;AACI,EAAA,MAAM,UAAU,YAAa,CAAA,OAAA,CAAA;AAE7B,EAAM,MAAA,KAAA,GAAQ,QAAQ,KAAM,CAAA,KAAA,CAAA;AAC5B,EAAM,MAAA,MAAA,GAAS,QAAQ,KAAM,CAAA,MAAA,CAAA;AAE7B,EAAA,IAAI,OAAU,GAAA,CAAA,CAAA;AACd,EAAA,IAAI,OAAU,GAAA,CAAA,CAAA;AAEd,EAAA,IAAI,aAAa,qBACjB,EAAA;AACI,IAAA,OAAA,GAAU,aAAa,MAAO,CAAA,CAAA,CAAA;AAC9B,IAAA,OAAA,GAAU,aAAa,MAAO,CAAA,CAAA,CAAA;AAAA,GAClC;AAEA,EAAA,GAAA,CAAI,CAAC,CAAA,GAAI,GAAI,CAAA,CAAC,IAAI,CAAC,OAAA,CAAA;AACnB,EAAA,GAAA,CAAI,CAAC,CAAA,GAAI,GAAI,CAAA,CAAC,IAAI,CAAI,GAAA,OAAA,CAAA;AACtB,EAAA,GAAA,CAAI,CAAC,CAAA,GAAI,GAAI,CAAA,CAAC,IAAI,CAAC,OAAA,CAAA;AACnB,EAAA,GAAA,CAAI,CAAC,CAAA,GAAI,GAAI,CAAA,CAAC,IAAI,CAAI,GAAA,OAAA,CAAA;AAEtB,EAAA,MAAM,gBAAgBA,aAAO,CAAA,MAAA,CAAA;AAE7B,EAAc,aAAA,CAAA,QAAA,CAAS,YAAa,CAAA,cAAA,CAAe,MAAM,CAAA,CAAA;AAEzD,EAAA,aAAA,CAAc,MAAM,YAAa,CAAA,KAAA,CAAA;AACjC,EAAA,aAAA,CAAc,MAAM,YAAa,CAAA,MAAA,CAAA;AAEjC,EAAA,aAAA,CAAc,MAAO,EAAA,CAAA;AAErB,EAAA,aAAA,CAAc,MAAM,YAAa,CAAA,KAAA,GAAQ,KAAO,EAAA,YAAA,CAAa,SAAS,MAAM,CAAA,CAAA;AAE5E,EAAYC,uBAAA,CAAA,GAAA,EAAK,CAAG,EAAA,CAAA,EAAG,aAAa,CAAA,CAAA;AACxC;;;;"}

View File

@@ -0,0 +1,29 @@
import { Matrix } from '../../../maths/matrix/Matrix.mjs';
import { applyMatrix } from './applyMatrix.mjs';
"use strict";
function setUvs(tilingSprite, uvs) {
const texture = tilingSprite.texture;
const width = texture.frame.width;
const height = texture.frame.height;
let anchorX = 0;
let anchorY = 0;
if (tilingSprite._applyAnchorToTexture) {
anchorX = tilingSprite.anchor.x;
anchorY = tilingSprite.anchor.y;
}
uvs[0] = uvs[6] = -anchorX;
uvs[2] = uvs[4] = 1 - anchorX;
uvs[1] = uvs[3] = -anchorY;
uvs[5] = uvs[7] = 1 - anchorY;
const textureMatrix = Matrix.shared;
textureMatrix.copyFrom(tilingSprite._tileTransform.matrix);
textureMatrix.tx /= tilingSprite.width;
textureMatrix.ty /= tilingSprite.height;
textureMatrix.invert();
textureMatrix.scale(tilingSprite.width / width, tilingSprite.height / height);
applyMatrix(uvs, 2, 0, textureMatrix);
}
export { setUvs };
//# sourceMappingURL=setUvs.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"setUvs.mjs","sources":["../../../../src/scene/sprite-tiling/utils/setUvs.ts"],"sourcesContent":["import { Matrix } from '../../../maths/matrix/Matrix';\nimport { applyMatrix } from './applyMatrix';\n\nimport type { TilingSprite } from '../TilingSprite';\n\nexport function setUvs(tilingSprite: TilingSprite, uvs: Float32Array)\n{\n const texture = tilingSprite.texture;\n\n const width = texture.frame.width;\n const height = texture.frame.height;\n\n let anchorX = 0;\n let anchorY = 0;\n\n if (tilingSprite._applyAnchorToTexture)\n {\n anchorX = tilingSprite.anchor.x;\n anchorY = tilingSprite.anchor.y;\n }\n\n uvs[0] = uvs[6] = -anchorX;\n uvs[2] = uvs[4] = 1 - anchorX;\n uvs[1] = uvs[3] = -anchorY;\n uvs[5] = uvs[7] = 1 - anchorY;\n\n const textureMatrix = Matrix.shared;\n\n textureMatrix.copyFrom(tilingSprite._tileTransform.matrix);\n\n textureMatrix.tx /= tilingSprite.width;\n textureMatrix.ty /= tilingSprite.height;\n\n textureMatrix.invert();\n\n textureMatrix.scale(tilingSprite.width / width, tilingSprite.height / height);\n\n applyMatrix(uvs, 2, 0, textureMatrix);\n}\n"],"names":[],"mappings":";;;;AAKgB,SAAA,MAAA,CAAO,cAA4B,GACnD,EAAA;AACI,EAAA,MAAM,UAAU,YAAa,CAAA,OAAA,CAAA;AAE7B,EAAM,MAAA,KAAA,GAAQ,QAAQ,KAAM,CAAA,KAAA,CAAA;AAC5B,EAAM,MAAA,MAAA,GAAS,QAAQ,KAAM,CAAA,MAAA,CAAA;AAE7B,EAAA,IAAI,OAAU,GAAA,CAAA,CAAA;AACd,EAAA,IAAI,OAAU,GAAA,CAAA,CAAA;AAEd,EAAA,IAAI,aAAa,qBACjB,EAAA;AACI,IAAA,OAAA,GAAU,aAAa,MAAO,CAAA,CAAA,CAAA;AAC9B,IAAA,OAAA,GAAU,aAAa,MAAO,CAAA,CAAA,CAAA;AAAA,GAClC;AAEA,EAAA,GAAA,CAAI,CAAC,CAAA,GAAI,GAAI,CAAA,CAAC,IAAI,CAAC,OAAA,CAAA;AACnB,EAAA,GAAA,CAAI,CAAC,CAAA,GAAI,GAAI,CAAA,CAAC,IAAI,CAAI,GAAA,OAAA,CAAA;AACtB,EAAA,GAAA,CAAI,CAAC,CAAA,GAAI,GAAI,CAAA,CAAC,IAAI,CAAC,OAAA,CAAA;AACnB,EAAA,GAAA,CAAI,CAAC,CAAA,GAAI,GAAI,CAAA,CAAC,IAAI,CAAI,GAAA,OAAA,CAAA;AAEtB,EAAA,MAAM,gBAAgB,MAAO,CAAA,MAAA,CAAA;AAE7B,EAAc,aAAA,CAAA,QAAA,CAAS,YAAa,CAAA,cAAA,CAAe,MAAM,CAAA,CAAA;AAEzD,EAAA,aAAA,CAAc,MAAM,YAAa,CAAA,KAAA,CAAA;AACjC,EAAA,aAAA,CAAc,MAAM,YAAa,CAAA,MAAA,CAAA;AAEjC,EAAA,aAAA,CAAc,MAAO,EAAA,CAAA;AAErB,EAAA,aAAA,CAAc,MAAM,YAAa,CAAA,KAAA,GAAQ,KAAO,EAAA,YAAA,CAAa,SAAS,MAAM,CAAA,CAAA;AAE5E,EAAY,WAAA,CAAA,GAAA,EAAK,CAAG,EAAA,CAAA,EAAG,aAAa,CAAA,CAAA;AACxC;;;;"}