initial commit
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
shadow$provide.module$node_modules$pixi_DOT_js$lib$scene$sprite$Sprite = function(global, require, module, exports) {
|
||||
var ObservablePoint = require("module$node_modules$pixi_DOT_js$lib$maths$point$ObservablePoint"), Texture = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$texture$Texture"), updateQuadBounds = require("module$node_modules$pixi_DOT_js$lib$utils$data$updateQuadBounds"), deprecation = require("module$node_modules$pixi_DOT_js$lib$utils$logging$deprecation");
|
||||
global = require("module$node_modules$pixi_DOT_js$lib$scene$view$ViewContainer");
|
||||
"use strict";
|
||||
class Sprite extends global.ViewContainer {
|
||||
constructor(options = Texture.Texture.EMPTY) {
|
||||
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 = !0;
|
||||
this._visualBounds = {minX:0, maxX:1, minY:0, maxY:0};
|
||||
this._anchor = new ObservablePoint.ObservablePoint({_onUpdate:() => {
|
||||
this.onViewUpdate();
|
||||
}});
|
||||
anchor ? this.anchor = anchor : texture.defaultAnchor && (this.anchor = texture.defaultAnchor);
|
||||
this.texture = texture;
|
||||
this.allowChildren = !1;
|
||||
this.roundPixels = roundPixels ?? !1;
|
||||
void 0 !== width && (this.width = width);
|
||||
void 0 !== height && (this.height = height);
|
||||
}
|
||||
static from(source, skipCache = !1) {
|
||||
return source instanceof Texture.Texture ? new Sprite(source) : new Sprite(Texture.Texture.from(source, skipCache));
|
||||
}
|
||||
set texture(value) {
|
||||
value || (value = Texture.Texture.EMPTY);
|
||||
const currentTexture = this._texture;
|
||||
if (currentTexture !== value) {
|
||||
currentTexture && currentTexture.dynamic && currentTexture.off("update", this.onViewUpdate, this);
|
||||
if (value.dynamic) {
|
||||
value.on("update", this.onViewUpdate, this);
|
||||
}
|
||||
this._texture = value;
|
||||
this._width && this._setWidth(this._width, this._texture.orig.width);
|
||||
this._height && this._setHeight(this._height, this._texture.orig.height);
|
||||
this.onViewUpdate();
|
||||
}
|
||||
}
|
||||
get texture() {
|
||||
return this._texture;
|
||||
}
|
||||
get visualBounds() {
|
||||
updateQuadBounds.updateQuadBounds(this._visualBounds, this._anchor, this._texture);
|
||||
return this._visualBounds;
|
||||
}
|
||||
get sourceBounds() {
|
||||
deprecation.deprecation("8.6.1", "Sprite.sourceBounds is deprecated, use visualBounds instead.");
|
||||
return this.visualBounds;
|
||||
}
|
||||
updateBounds() {
|
||||
const anchor = this._anchor, bounds = this._bounds, {width, height} = this._texture.orig;
|
||||
bounds.minX = -anchor._x * width;
|
||||
bounds.maxX = bounds.minX + width;
|
||||
bounds.minY = -anchor._y * height;
|
||||
bounds.maxY = bounds.minY + height;
|
||||
}
|
||||
destroy(options = !1) {
|
||||
super.destroy(options);
|
||||
("boolean" === typeof options ? options : options?.texture) && this._texture.destroy("boolean" === typeof options ? options : options?.textureSource);
|
||||
this._anchor = this._bounds = this._visualBounds = this._texture = null;
|
||||
}
|
||||
get anchor() {
|
||||
return this._anchor;
|
||||
}
|
||||
set anchor(value) {
|
||||
"number" === typeof value ? this._anchor.set(value) : this._anchor.copyFrom(value);
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
setSize(value, height) {
|
||||
"object" === typeof value ? (height = value.height ?? value.width, value = value.width) : height ?? (height = value);
|
||||
void 0 !== value && this._setWidth(value, this._texture.orig.width);
|
||||
void 0 !== height && this._setHeight(height, this._texture.orig.height);
|
||||
}
|
||||
}
|
||||
exports.Sprite = Sprite;
|
||||
};
|
||||
|
||||
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$scene$sprite$Sprite.js.map
|
||||
Reference in New Issue
Block a user