338 lines
17 KiB
JavaScript
338 lines
17 KiB
JavaScript
shadow$provide.module$node_modules$pixi_DOT_js$lib$scene$container$Container = function(global, require, module, exports) {
|
|
global = require("module$node_modules$eventemitter3$index");
|
|
var Color = require("module$node_modules$pixi_DOT_js$lib$color$Color");
|
|
module = require("module$node_modules$pixi_DOT_js$lib$culling$cullingMixin");
|
|
var Extensions = require("module$node_modules$pixi_DOT_js$lib$extensions$Extensions"), Matrix = require("module$node_modules$pixi_DOT_js$lib$maths$matrix$Matrix"), _const = require("module$node_modules$pixi_DOT_js$lib$maths$misc$const"), ObservablePoint = require("module$node_modules$pixi_DOT_js$lib$maths$point$ObservablePoint"), uid = require("module$node_modules$pixi_DOT_js$lib$utils$data$uid"), deprecation = require("module$node_modules$pixi_DOT_js$lib$utils$logging$deprecation"), warn = require("module$node_modules$pixi_DOT_js$lib$utils$logging$warn"),
|
|
PoolGroup = require("module$node_modules$pixi_DOT_js$lib$utils$pool$PoolGroup"), cacheAsTextureMixin = require("module$node_modules$pixi_DOT_js$lib$scene$container$container_mixins$cacheAsTextureMixin"), childrenHelperMixin = require("module$node_modules$pixi_DOT_js$lib$scene$container$container_mixins$childrenHelperMixin"), collectRenderablesMixin = require("module$node_modules$pixi_DOT_js$lib$scene$container$container_mixins$collectRenderablesMixin"), effectsMixin = require("module$node_modules$pixi_DOT_js$lib$scene$container$container_mixins$effectsMixin"),
|
|
findMixin = require("module$node_modules$pixi_DOT_js$lib$scene$container$container_mixins$findMixin"), getFastGlobalBoundsMixin = require("module$node_modules$pixi_DOT_js$lib$scene$container$container_mixins$getFastGlobalBoundsMixin"), getGlobalMixin = require("module$node_modules$pixi_DOT_js$lib$scene$container$container_mixins$getGlobalMixin"), measureMixin = require("module$node_modules$pixi_DOT_js$lib$scene$container$container_mixins$measureMixin"), onRenderMixin = require("module$node_modules$pixi_DOT_js$lib$scene$container$container_mixins$onRenderMixin"),
|
|
sortMixin = require("module$node_modules$pixi_DOT_js$lib$scene$container$container_mixins$sortMixin"), toLocalGlobalMixin = require("module$node_modules$pixi_DOT_js$lib$scene$container$container_mixins$toLocalGlobalMixin"), RenderGroup = require("module$node_modules$pixi_DOT_js$lib$scene$container$RenderGroup"), assignWithIgnore = require("module$node_modules$pixi_DOT_js$lib$scene$container$utils$assignWithIgnore");
|
|
"use strict";
|
|
const defaultSkew = new ObservablePoint.ObservablePoint(null), defaultPivot = new ObservablePoint.ObservablePoint(null), defaultScale = new ObservablePoint.ObservablePoint(null, 1, 1), defaultOrigin = new ObservablePoint.ObservablePoint(null);
|
|
class Container extends global {
|
|
constructor(options = {}) {
|
|
super();
|
|
this.uid = uid.uid("renderable");
|
|
this._updateFlags = 15;
|
|
this.parentRenderGroup = this.renderGroup = null;
|
|
this.parentRenderGroupIndex = 0;
|
|
this.didViewUpdate = this.didChange = !1;
|
|
this.relativeRenderGroupDepth = 0;
|
|
this.children = [];
|
|
this.parent = null;
|
|
this.isSimple = this.measurable = this.includeInBuild = !0;
|
|
this.parentRenderLayer = null;
|
|
this.updateTick = -1;
|
|
this.localTransform = new Matrix.Matrix();
|
|
this.groupTransform = this.relativeGroupTransform = new Matrix.Matrix();
|
|
this.destroyed = !1;
|
|
this._position = new ObservablePoint.ObservablePoint(this, 0, 0);
|
|
this._scale = defaultScale;
|
|
this._pivot = defaultPivot;
|
|
this._origin = defaultOrigin;
|
|
this._skew = defaultSkew;
|
|
this._cx = 1;
|
|
this._cy = this._sx = 0;
|
|
this._sy = 1;
|
|
this._rotation = 0;
|
|
this.localColor = 16777215;
|
|
this.groupAlpha = this.localAlpha = 1;
|
|
this.groupColor = 16777215;
|
|
this.groupColorAlpha = 4294967295;
|
|
this.localBlendMode = "inherit";
|
|
this.groupBlendMode = "normal";
|
|
this.globalDisplayStatus = this.localDisplayStatus = 7;
|
|
this._didViewChangeTick = this._didContainerChangeTick = 0;
|
|
this._didLocalTransformChangeId = -1;
|
|
this.effects = [];
|
|
assignWithIgnore.assignWithIgnore(this, options, {children:!0, parent:!0, effects:!0});
|
|
options.children?.forEach(child => this.addChild(child));
|
|
options.parent?.addChild(this);
|
|
}
|
|
static mixin(source) {
|
|
deprecation.deprecation("8.8.0", "Container.mixin is deprecated, please use extensions.mixin instead.");
|
|
Extensions.extensions.mixin(Container, source);
|
|
}
|
|
set _didChangeId(value) {
|
|
this._didViewChangeTick = value >> 12 & 4095;
|
|
this._didContainerChangeTick = value & 4095;
|
|
}
|
|
get _didChangeId() {
|
|
return this._didContainerChangeTick & 4095 | (this._didViewChangeTick & 4095) << 12;
|
|
}
|
|
addChild(...children) {
|
|
this.allowChildren || deprecation.deprecation(deprecation.v8_0_0, "addChild: Only Containers will be allowed to add children in v8.0.0");
|
|
if (1 < children.length) {
|
|
for (var i = 0; i < children.length; i++) {
|
|
this.addChild(children[i]);
|
|
}
|
|
return children[0];
|
|
}
|
|
children = children[0];
|
|
i = this.renderGroup || this.parentRenderGroup;
|
|
if (children.parent === this) {
|
|
return this.children.splice(this.children.indexOf(children), 1), this.children.push(children), i && (i.structureDidChange = !0), children;
|
|
}
|
|
children.parent && children.parent.removeChild(children);
|
|
this.children.push(children);
|
|
this.sortableChildren && (this.sortDirty = !0);
|
|
children.parent = this;
|
|
children.didChange = !0;
|
|
children._updateFlags = 15;
|
|
i && i.addChild(children);
|
|
this.emit("childAdded", children, this, this.children.length - 1);
|
|
children.emit("added", this);
|
|
this._didViewChangeTick++;
|
|
0 !== children._zIndex && children.depthOfChildModified();
|
|
return children;
|
|
}
|
|
removeChild(...children) {
|
|
if (1 < children.length) {
|
|
for (var i = 0; i < children.length; i++) {
|
|
this.removeChild(children[i]);
|
|
}
|
|
return children[0];
|
|
}
|
|
children = children[0];
|
|
i = this.children.indexOf(children);
|
|
-1 < i && (this._didViewChangeTick++, this.children.splice(i, 1), this.renderGroup ? this.renderGroup.removeChild(children) : this.parentRenderGroup && this.parentRenderGroup.removeChild(children), children.parentRenderLayer && children.parentRenderLayer.detach(children), children.parent = null, this.emit("childRemoved", children, this, i), children.emit("removed", this));
|
|
return children;
|
|
}
|
|
_onUpdate(point) {
|
|
point && point === this._skew && this._updateSkew();
|
|
this._didContainerChangeTick++;
|
|
if (!this.didChange && (this.didChange = !0, this.parentRenderGroup)) {
|
|
this.parentRenderGroup.onChildUpdate(this);
|
|
}
|
|
}
|
|
set isRenderGroup(value) {
|
|
!!this.renderGroup !== value && (value ? this.enableRenderGroup() : this.disableRenderGroup());
|
|
}
|
|
get isRenderGroup() {
|
|
return !!this.renderGroup;
|
|
}
|
|
enableRenderGroup() {
|
|
if (!this.renderGroup) {
|
|
var parentRenderGroup = this.parentRenderGroup;
|
|
parentRenderGroup?.removeChild(this);
|
|
this.renderGroup = PoolGroup.BigPool.get(RenderGroup.RenderGroup, this);
|
|
this.groupTransform = Matrix.Matrix.IDENTITY;
|
|
parentRenderGroup?.addChild(this);
|
|
this._updateIsSimple();
|
|
}
|
|
}
|
|
disableRenderGroup() {
|
|
if (this.renderGroup) {
|
|
var parentRenderGroup = this.parentRenderGroup;
|
|
parentRenderGroup?.removeChild(this);
|
|
PoolGroup.BigPool.return(this.renderGroup);
|
|
this.renderGroup = null;
|
|
this.groupTransform = this.relativeGroupTransform;
|
|
parentRenderGroup?.addChild(this);
|
|
this._updateIsSimple();
|
|
}
|
|
}
|
|
_updateIsSimple() {
|
|
this.isSimple = !this.renderGroup && 0 === this.effects.length;
|
|
}
|
|
get worldTransform() {
|
|
this._worldTransform || (this._worldTransform = new Matrix.Matrix());
|
|
this.renderGroup ? this._worldTransform.copyFrom(this.renderGroup.worldTransform) : this.parentRenderGroup && this._worldTransform.appendFrom(this.relativeGroupTransform, this.parentRenderGroup.worldTransform);
|
|
return this._worldTransform;
|
|
}
|
|
get x() {
|
|
return this._position.x;
|
|
}
|
|
set x(value) {
|
|
this._position.x = value;
|
|
}
|
|
get y() {
|
|
return this._position.y;
|
|
}
|
|
set y(value) {
|
|
this._position.y = value;
|
|
}
|
|
get position() {
|
|
return this._position;
|
|
}
|
|
set position(value) {
|
|
this._position.copyFrom(value);
|
|
}
|
|
get rotation() {
|
|
return this._rotation;
|
|
}
|
|
set rotation(value) {
|
|
this._rotation !== value && (this._rotation = value, this._onUpdate(this._skew));
|
|
}
|
|
get angle() {
|
|
return this.rotation * _const.RAD_TO_DEG;
|
|
}
|
|
set angle(value) {
|
|
this.rotation = value * _const.DEG_TO_RAD;
|
|
}
|
|
get pivot() {
|
|
this._pivot === defaultPivot && (this._pivot = new ObservablePoint.ObservablePoint(this, 0, 0));
|
|
return this._pivot;
|
|
}
|
|
set pivot(value) {
|
|
this._pivot === defaultPivot && (this._pivot = new ObservablePoint.ObservablePoint(this, 0, 0), this._origin !== defaultOrigin && warn.warn("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully."));
|
|
"number" === typeof value ? this._pivot.set(value) : this._pivot.copyFrom(value);
|
|
}
|
|
get skew() {
|
|
this._skew === defaultSkew && (this._skew = new ObservablePoint.ObservablePoint(this, 0, 0));
|
|
return this._skew;
|
|
}
|
|
set skew(value) {
|
|
this._skew === defaultSkew && (this._skew = new ObservablePoint.ObservablePoint(this, 0, 0));
|
|
this._skew.copyFrom(value);
|
|
}
|
|
get scale() {
|
|
this._scale === defaultScale && (this._scale = new ObservablePoint.ObservablePoint(this, 1, 1));
|
|
return this._scale;
|
|
}
|
|
set scale(value) {
|
|
this._scale === defaultScale && (this._scale = new ObservablePoint.ObservablePoint(this, 0, 0));
|
|
"string" === typeof value && (value = parseFloat(value));
|
|
"number" === typeof value ? this._scale.set(value) : this._scale.copyFrom(value);
|
|
}
|
|
get origin() {
|
|
this._origin === defaultOrigin && (this._origin = new ObservablePoint.ObservablePoint(this, 0, 0));
|
|
return this._origin;
|
|
}
|
|
set origin(value) {
|
|
this._origin === defaultOrigin && (this._origin = new ObservablePoint.ObservablePoint(this, 0, 0), this._pivot !== defaultPivot && warn.warn("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully."));
|
|
"number" === typeof value ? this._origin.set(value) : this._origin.copyFrom(value);
|
|
}
|
|
get width() {
|
|
return Math.abs(this.scale.x * this.getLocalBounds().width);
|
|
}
|
|
set width(value) {
|
|
const localWidth = this.getLocalBounds().width;
|
|
this._setWidth(value, localWidth);
|
|
}
|
|
get height() {
|
|
return Math.abs(this.scale.y * this.getLocalBounds().height);
|
|
}
|
|
set height(value) {
|
|
const localHeight = this.getLocalBounds().height;
|
|
this._setHeight(value, localHeight);
|
|
}
|
|
getSize(out) {
|
|
out || (out = {});
|
|
const bounds = this.getLocalBounds();
|
|
out.width = Math.abs(this.scale.x * bounds.width);
|
|
out.height = Math.abs(this.scale.y * bounds.height);
|
|
return out;
|
|
}
|
|
setSize(value, height) {
|
|
const size = this.getLocalBounds();
|
|
"object" === typeof value ? (height = value.height ?? value.width, value = value.width) : height ?? (height = value);
|
|
void 0 !== value && this._setWidth(value, size.width);
|
|
void 0 !== height && this._setHeight(height, size.height);
|
|
}
|
|
_updateSkew() {
|
|
const rotation = this._rotation, skew = this._skew;
|
|
this._cx = Math.cos(rotation + skew._y);
|
|
this._sx = Math.sin(rotation + skew._y);
|
|
this._cy = -Math.sin(rotation - skew._x);
|
|
this._sy = Math.cos(rotation - skew._x);
|
|
}
|
|
updateTransform(opts) {
|
|
this.position.set("number" === typeof opts.x ? opts.x : this.position.x, "number" === typeof opts.y ? opts.y : this.position.y);
|
|
this.scale.set("number" === typeof opts.scaleX ? opts.scaleX : this.scale.x, "number" === typeof opts.scaleY ? opts.scaleY : this.scale.y);
|
|
this.rotation = "number" === typeof opts.rotation ? opts.rotation : this.rotation;
|
|
this.skew.set("number" === typeof opts.skewX ? opts.skewX : this.skew.x, "number" === typeof opts.skewY ? opts.skewY : this.skew.y);
|
|
this.pivot.set("number" === typeof opts.pivotX ? opts.pivotX : this.pivot.x, "number" === typeof opts.pivotY ? opts.pivotY : this.pivot.y);
|
|
this.origin.set("number" === typeof opts.originX ? opts.originX : this.origin.x, "number" === typeof opts.originY ? opts.originY : this.origin.y);
|
|
return this;
|
|
}
|
|
setFromMatrix(matrix) {
|
|
matrix.decompose(this);
|
|
}
|
|
updateLocalTransform() {
|
|
var localTransformChangeId = this._didContainerChangeTick;
|
|
if (this._didLocalTransformChangeId !== localTransformChangeId) {
|
|
this._didLocalTransformChangeId = localTransformChangeId;
|
|
localTransformChangeId = this.localTransform;
|
|
var scale = this._scale, pivot = this._pivot, origin = this._origin, position = this._position, sx = scale._x;
|
|
scale = scale._y;
|
|
var px = pivot._x;
|
|
pivot = pivot._y;
|
|
var ox = -origin._x;
|
|
origin = -origin._y;
|
|
localTransformChangeId.a = this._cx * sx;
|
|
localTransformChangeId.b = this._sx * sx;
|
|
localTransformChangeId.c = this._cy * scale;
|
|
localTransformChangeId.d = this._sy * scale;
|
|
localTransformChangeId.tx = position._x - (px * localTransformChangeId.a + pivot * localTransformChangeId.c) + (ox * localTransformChangeId.a + origin * localTransformChangeId.c) - ox;
|
|
localTransformChangeId.ty = position._y - (px * localTransformChangeId.b + pivot * localTransformChangeId.d) + (ox * localTransformChangeId.b + origin * localTransformChangeId.d) - origin;
|
|
}
|
|
}
|
|
set alpha(value) {
|
|
value !== this.localAlpha && (this.localAlpha = value, this._updateFlags |= 1, this._onUpdate());
|
|
}
|
|
get alpha() {
|
|
return this.localAlpha;
|
|
}
|
|
set tint(value) {
|
|
value = Color.Color.shared.setValue(value ?? 16777215).toBgrNumber();
|
|
value !== this.localColor && (this.localColor = value, this._updateFlags |= 1, this._onUpdate());
|
|
}
|
|
get tint() {
|
|
return getGlobalMixin.bgr2rgb(this.localColor);
|
|
}
|
|
set blendMode(value) {
|
|
this.localBlendMode !== value && (this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._updateFlags |= 2, this.localBlendMode = value, this._onUpdate());
|
|
}
|
|
get blendMode() {
|
|
return this.localBlendMode;
|
|
}
|
|
get visible() {
|
|
return !!(this.localDisplayStatus & 2);
|
|
}
|
|
set visible(value) {
|
|
(this.localDisplayStatus & 2) !== (value ? 2 : 0) && (this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._updateFlags |= 4, this.localDisplayStatus ^= 2, this._onUpdate(), this.emit("visibleChanged", value));
|
|
}
|
|
get culled() {
|
|
return !(this.localDisplayStatus & 4);
|
|
}
|
|
set culled(value) {
|
|
(this.localDisplayStatus & 4) !== (value ? 0 : 4) && (this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._updateFlags |= 4, this.localDisplayStatus ^= 4, this._onUpdate());
|
|
}
|
|
get renderable() {
|
|
return !!(this.localDisplayStatus & 1);
|
|
}
|
|
set renderable(value) {
|
|
(this.localDisplayStatus & 1) !== (value ? 1 : 0) && (this._updateFlags |= 4, this.localDisplayStatus ^= 1, this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._onUpdate());
|
|
}
|
|
get isRenderable() {
|
|
return 7 === this.localDisplayStatus && 0 < this.groupAlpha;
|
|
}
|
|
destroy(options = !1) {
|
|
if (!this.destroyed) {
|
|
this.destroyed = !0;
|
|
var oldChildren;
|
|
this.children.length && (oldChildren = this.removeChildren(0, this.children.length));
|
|
this.removeFromParent();
|
|
this._skew = this._origin = this._pivot = this._scale = this._position = this.effects = this._filterEffect = this._maskEffect = this.parent = null;
|
|
this.emit("destroyed", this);
|
|
this.removeAllListeners();
|
|
if (("boolean" === typeof options ? options : options?.children) && oldChildren) {
|
|
for (let i = 0; i < oldChildren.length; ++i) {
|
|
oldChildren[i].destroy(options);
|
|
}
|
|
}
|
|
this.renderGroup?.destroy();
|
|
this.renderGroup = null;
|
|
}
|
|
}
|
|
}
|
|
Extensions.extensions.mixin(Container, childrenHelperMixin.childrenHelperMixin, getFastGlobalBoundsMixin.getFastGlobalBoundsMixin, toLocalGlobalMixin.toLocalGlobalMixin, onRenderMixin.onRenderMixin, measureMixin.measureMixin, effectsMixin.effectsMixin, findMixin.findMixin, sortMixin.sortMixin, module.cullingMixin, cacheAsTextureMixin.cacheAsTextureMixin, getGlobalMixin.getGlobalMixin, collectRenderablesMixin.collectRenderablesMixin);
|
|
exports.Container = Container;
|
|
exports.UPDATE_BLEND = 2;
|
|
exports.UPDATE_COLOR = 1;
|
|
exports.UPDATE_TRANSFORM = 8;
|
|
exports.UPDATE_VISIBLE = 4;
|
|
};
|
|
|
|
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$scene$container$Container.js.map
|