@sepveneto/dao 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/Application.d.ts +1 -1
- package/dist/assets/Assets.d.ts +24 -1
- package/dist/assets/__tests__/Assets.test.d.ts +1 -0
- package/dist/assets/loader/Loader.d.ts +43 -0
- package/dist/assets/loader/__tests__/Loader.test.d.ts +1 -0
- package/dist/dao.cjs +1 -1
- package/dist/dao.cjs.map +1 -1
- package/dist/dao.js +1512 -1382
- package/dist/dao.js.map +1 -1
- package/dist/main.d.ts +1 -2
- package/dist/renderer/texture/Texture.d.ts +3 -1
- package/dist/renderer/texture/TextureSource.d.ts +2 -0
- package/dist/scene/container/Container.d.ts +9 -2
- package/dist/ticker/Ticker.d.ts +2 -0
- package/dist/utils/type.d.ts +1 -0
- package/package.json +4 -2
- package/dist/Loader.d.ts +0 -18
- package/dist/ResourceManager.d.ts +0 -19
package/dist/dao.js
CHANGED
|
@@ -71,288 +71,298 @@ var Matrix = class n {
|
|
|
71
71
|
function nextPow2(n) {
|
|
72
72
|
return n += n === 0 ? 1 : 0, --n, n |= n >>> 1, n |= n >>> 2, n |= n >>> 4, n |= n >>> 8, n |= n >>> 16, n + 1;
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
constructor() {
|
|
76
|
-
this.
|
|
74
|
+
var FederatedEvent = class {
|
|
75
|
+
constructor(n) {
|
|
76
|
+
this.system = n;
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this._canvasPool[F] || (this._canvasPool[F] = []);
|
|
81
|
-
let I = this._canvasPool[F].pop();
|
|
82
|
-
if (I) return I;
|
|
83
|
-
{
|
|
84
|
-
let n = document.createElement("canvas");
|
|
85
|
-
return n.width = N, n.height = P, {
|
|
86
|
-
canvas: n,
|
|
87
|
-
context: n.getContext("2d")
|
|
88
|
-
};
|
|
89
|
-
}
|
|
78
|
+
getLocalPosition(n, j) {
|
|
79
|
+
return n.worldTransform.applyInverse(j || this.global);
|
|
90
80
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
function uid(n = "default") {
|
|
94
|
-
return uidCache[n] === void 0 && (uidCache[n] = -1), ++uidCache[n];
|
|
95
|
-
}
|
|
96
|
-
var _TextStyle, TextStyle = class n {
|
|
97
|
-
constructor(j) {
|
|
98
|
-
this.uid = uid("textStyle"), this._tick = 0;
|
|
99
|
-
let M = {
|
|
100
|
-
...n.defaultStyle,
|
|
101
|
-
...j
|
|
102
|
-
};
|
|
103
|
-
for (let n in M) {
|
|
104
|
-
let j = n;
|
|
105
|
-
this[j] = M[n];
|
|
106
|
-
}
|
|
81
|
+
composedPath() {
|
|
82
|
+
return (!this.path || this.path[this.path.length - 1] !== this.target) && (this.path = this.target ? this.system.propagationPath(this.target) : []), this.path;
|
|
107
83
|
}
|
|
108
|
-
|
|
109
|
-
|
|
84
|
+
}, _EventSystem, PROPAGATION_LIMIT = 2048, EventSystem = class {
|
|
85
|
+
constructor(n) {
|
|
86
|
+
this.domElement = null, this.rootTarget = null, this.resolution = 1, this._allInteractiveElements = [], this._hitElements = [], this._isPointerMoveEvent = !1, this.mappingState = { trackingData: {} }, this.renderer = n, this.resolution = n.resolution, this._onPointerDown = this._onPointerDown.bind(this), this._onPointerMove = this._onPointerMove.bind(this), this._onPointerUp = this._onPointerUp.bind(this), this._onPointerOverOut = this._onPointerOverOut.bind(this), this.init();
|
|
110
87
|
}
|
|
111
|
-
|
|
112
|
-
return this.
|
|
88
|
+
trackingData(n) {
|
|
89
|
+
return this.mappingState.trackingData[n] || (this.mappingState.trackingData[n] = {
|
|
90
|
+
pressTargetsByButton: {},
|
|
91
|
+
clicksByButton: {},
|
|
92
|
+
overTargets: null
|
|
93
|
+
}), this.mappingState.trackingData[n];
|
|
113
94
|
}
|
|
114
|
-
|
|
115
|
-
|
|
95
|
+
init() {
|
|
96
|
+
let n = this.renderer.canvas;
|
|
97
|
+
this.setTargetElement(n);
|
|
116
98
|
}
|
|
117
|
-
|
|
118
|
-
|
|
99
|
+
setTargetElement(n) {
|
|
100
|
+
this._removeEvents(), this.domElement = n, this._addEvents();
|
|
119
101
|
}
|
|
120
|
-
|
|
121
|
-
|
|
102
|
+
dispatchEvent(n, j) {
|
|
103
|
+
if (!n.target) return;
|
|
104
|
+
let M = n.composedPath();
|
|
105
|
+
for (let N = 0; N < M.length - 1; ++N) n.currentTarget = M[N], this._notifyTarget(n, j);
|
|
106
|
+
n.currentTarget = n.target, this._notifyTarget(n, j);
|
|
122
107
|
}
|
|
123
|
-
|
|
124
|
-
|
|
108
|
+
_notifyTarget(n, j) {
|
|
109
|
+
j != null || (j = n.type);
|
|
110
|
+
let M = n.currentTarget._events[j];
|
|
111
|
+
if (M) if ("fn" in M) M.once && n.target.removeListener(j, M.fn, void 0, !0), M.fn.call(M.context, n);
|
|
112
|
+
else for (let N = 0; N < M.length; ++N) {
|
|
113
|
+
let P = M[N];
|
|
114
|
+
P.once && n.target.removeListener(j, P.fn, void 0, !0), P.fn.call(P.context, n);
|
|
115
|
+
}
|
|
125
116
|
}
|
|
126
|
-
|
|
127
|
-
|
|
117
|
+
propagationPath(n) {
|
|
118
|
+
let j = [n];
|
|
119
|
+
for (let M = 0; M < PROPAGATION_LIMIT && (n !== this.rootTarget || n.parent); ++M) {
|
|
120
|
+
if (!n.parent) throw Error("Cannot find propagation path to disconnected target");
|
|
121
|
+
j.push(n.parent), n = n.parent;
|
|
122
|
+
}
|
|
123
|
+
return j.reverse(), j;
|
|
128
124
|
}
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
_removeEvents() {
|
|
126
|
+
let n = this.domElement;
|
|
127
|
+
n && (globalThis.document.removeEventListener("pointermove", this._onPointerMove, !0), n.removeEventListener("pointerdown", this._onPointerDown, !0), n.removeEventListener("pointerleave", this._onPointerOverOut, !0), n.removeEventListener("pointerover", this._onPointerOverOut, !0), globalThis.document.removeEventListener("pointerup", this._onPointerUp, !0));
|
|
131
128
|
}
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
_addEvents() {
|
|
130
|
+
let n = this.domElement;
|
|
131
|
+
if (!n) return;
|
|
132
|
+
let j = n.style;
|
|
133
|
+
j && (j.touchAction = "none"), globalThis.document.addEventListener("pointermove", this._onPointerMove, !0), n.addEventListener("pointerdown", this._onPointerDown, !0), n.addEventListener("pointerleave", this._onPointerOverOut, !0), n.addEventListener("pointerover", this._onPointerOverOut, !0), globalThis.document.addEventListener("pointerup", this._onPointerUp, !0);
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
_onPointerMove(n) {
|
|
136
|
+
var j;
|
|
137
|
+
if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
|
|
138
|
+
this._isPointerMoveEvent = !0, this._allInteractiveElements.length = 0, this._hitElements.length = 0;
|
|
139
|
+
let M = this.createPointEvent(n);
|
|
140
|
+
this._isPointerMoveEvent = !1;
|
|
141
|
+
let N = this.trackingData(n.pointerId), P = findMountedTarget(N.overTargets);
|
|
142
|
+
if (((j = N.overTargets) == null ? void 0 : j.length) > 0 && P !== M.target) {
|
|
143
|
+
let j = this.createPointEvent(n, "pointerout", P);
|
|
144
|
+
this.dispatchEvent(j, "pointerout");
|
|
145
|
+
let N = M.composedPath();
|
|
146
|
+
if (!N.includes(P)) {
|
|
147
|
+
let j = this.createPointEvent(n, "pointerleave", P);
|
|
148
|
+
for (; j.target && !N.includes(j.target);) j.currentTarget = j.target, this._notifyTarget(j), j.target = j.target.parent;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (P !== M.target) {
|
|
152
|
+
let n = "pointerover", j = this.clonePointEvent(M, n);
|
|
153
|
+
this.dispatchEvent(j, n);
|
|
154
|
+
let N = P == null ? void 0 : P.parent;
|
|
155
|
+
for (; N && N !== this.rootTarget.parent && N !== M.target;) N = N.parent;
|
|
156
|
+
if (!N || N === this.rootTarget.parent) {
|
|
157
|
+
let n = this.clonePointEvent(M, "pointerenter");
|
|
158
|
+
for (; n.target && n.target !== P && n.target !== this.rootTarget.parent;) n.currentTarget = n.target, this._notifyTarget(n), n.target = n.target.parent;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
this.dispatchEvent(M, "pointermove");
|
|
162
|
+
let F = this._allInteractiveElements;
|
|
163
|
+
for (let n = F.length - 1; n >= 0; --n) M.currentTarget = F[n], this._notifyTarget(M, "globalpointermove");
|
|
164
|
+
this._allInteractiveElements.length = 0, this._hitElements.length = 0, N.overTargets = M.composedPath();
|
|
137
165
|
}
|
|
138
|
-
|
|
139
|
-
|
|
166
|
+
_onPointerDown(n) {
|
|
167
|
+
if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
|
|
168
|
+
let j = this.createPointEvent(n);
|
|
169
|
+
this.dispatchEvent(j, "pointerdown");
|
|
170
|
+
let M = this.trackingData(n.pointerId);
|
|
171
|
+
M.pressTargetsByButton[n.button] = j.composedPath();
|
|
140
172
|
}
|
|
141
|
-
|
|
142
|
-
|
|
173
|
+
_onPointerOverOut(n) {
|
|
174
|
+
if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
|
|
175
|
+
let j = this.createPointEvent(n);
|
|
176
|
+
this.dispatchEvent(j, "pointerout");
|
|
143
177
|
}
|
|
144
|
-
|
|
145
|
-
|
|
178
|
+
_onPointerUp(n) {
|
|
179
|
+
if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
|
|
180
|
+
let j = n.target;
|
|
181
|
+
n.composedPath && n.composedPath().length > 1 && (j = n.composedPath()[0]);
|
|
182
|
+
let M = j === this.domElement ? "" : "outside", N = this.createPointEvent(n);
|
|
183
|
+
this.dispatchEvent(N, `pointerup${M}`);
|
|
146
184
|
}
|
|
147
|
-
|
|
148
|
-
return
|
|
185
|
+
_isInteractive(n) {
|
|
186
|
+
return n === "static";
|
|
149
187
|
}
|
|
150
|
-
|
|
151
|
-
|
|
188
|
+
createPointEvent(n, j, M) {
|
|
189
|
+
var N;
|
|
190
|
+
let P = this.mapPositionToPoint(n.clientX, n.clientY);
|
|
191
|
+
n.type === "pointerleave" && (j = "pointerout");
|
|
192
|
+
let F = new FederatedEvent(this);
|
|
193
|
+
return F.type = j, F.nativeEvent = n, F.target = (N = M == null ? this.hitTest(P.x, P.y) : M) == null ? this._hitElements[0] : N, F.global = P, F;
|
|
152
194
|
}
|
|
153
|
-
|
|
154
|
-
|
|
195
|
+
clonePointEvent(n, j) {
|
|
196
|
+
let M = new FederatedEvent(this);
|
|
197
|
+
return M.nativeEvent = n.nativeEvent, M.global = n.global, M.type = j == null ? n.type : j, M.path = n.composedPath().slice(), M.target = n.target, M;
|
|
155
198
|
}
|
|
156
|
-
|
|
157
|
-
this.
|
|
199
|
+
mapPositionToPoint(n, j) {
|
|
200
|
+
let M = this.domElement, N = M.isConnected ? M.getBoundingClientRect() : {
|
|
201
|
+
x: 0,
|
|
202
|
+
y: 0,
|
|
203
|
+
width: M.width,
|
|
204
|
+
height: M.height,
|
|
205
|
+
left: 0,
|
|
206
|
+
top: 0
|
|
207
|
+
}, P = 1 / this.resolution, F = new Vector2();
|
|
208
|
+
return F.x = (n - N.left) * (M.width / N.width) * P, F.y = (j - N.top) * (M.height / N.height) * P, F;
|
|
158
209
|
}
|
|
159
|
-
|
|
160
|
-
|
|
210
|
+
hitTest(n, j) {
|
|
211
|
+
let M = this._isPointerMoveEvent, N = this[M ? "hitTestMoveRecursive" : "hitTestRecursive"](this.rootTarget, this.rootTarget.eventMode, new Vector2(n, j));
|
|
212
|
+
return N && N[0];
|
|
161
213
|
}
|
|
162
|
-
|
|
163
|
-
|
|
214
|
+
_interactivePrune(n) {
|
|
215
|
+
return !n || !n.visible || n.eventMode === "none";
|
|
164
216
|
}
|
|
165
|
-
|
|
166
|
-
|
|
217
|
+
hitTestMoveRecursive(n, j, M) {
|
|
218
|
+
let N = !1;
|
|
219
|
+
if (this._interactivePrune(n)) return;
|
|
220
|
+
let P = n.children;
|
|
221
|
+
if (P && P.length > 0) for (let F = P.length - 1; F >= 0; --F) {
|
|
222
|
+
let I = P[F], L = this.hitTestMoveRecursive(I, this._isInteractive(j) ? j : I.eventMode, M);
|
|
223
|
+
if (L) {
|
|
224
|
+
if (L.length > 0 && !L[L.length - 1].parent) continue;
|
|
225
|
+
let j = this._isInteractive(n.eventMode);
|
|
226
|
+
(L.length > 0 || j) && (j && this._allInteractiveElements.push(n), L.push(n)), this._hitElements.length === 0 && (this._hitElements = L), N = !0;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
let F = this._isInteractive(j), I = this._isInteractive(n.eventMode);
|
|
230
|
+
if (I && this._allInteractiveElements.push(n), !(this._hitElements.length > 0)) {
|
|
231
|
+
if (N) return this._hitElements;
|
|
232
|
+
if (F && this.hitTestFn(n, M)) return I ? [n] : [];
|
|
233
|
+
}
|
|
167
234
|
}
|
|
168
|
-
|
|
169
|
-
|
|
235
|
+
hitTestRecursive(n, j, M) {
|
|
236
|
+
let N = n.children;
|
|
237
|
+
for (let P = N.length - 1; P >= 0; P--) {
|
|
238
|
+
let F = N[P], I = this.hitTestRecursive(F, this._isInteractive(j) ? j : F.eventMode, M);
|
|
239
|
+
if (I) {
|
|
240
|
+
let j = this._isInteractive(n.eventMode);
|
|
241
|
+
return (I.length > 0 || j) && I.push(n), I;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
let P = this._isInteractive(j), F = this._isInteractive(n.eventMode);
|
|
245
|
+
return P && this.hitTestFn(n, M) ? F ? [n] : [] : null;
|
|
170
246
|
}
|
|
171
|
-
|
|
172
|
-
return
|
|
247
|
+
hitTestFn(n, j) {
|
|
248
|
+
if (n.hitArea) return !0;
|
|
249
|
+
if (n.containsPoint) {
|
|
250
|
+
let M = n.worldTransform.applyInverse(j);
|
|
251
|
+
return n.containsPoint(M);
|
|
252
|
+
}
|
|
253
|
+
return !1;
|
|
173
254
|
}
|
|
174
|
-
|
|
175
|
-
|
|
255
|
+
};
|
|
256
|
+
_EventSystem = EventSystem, _EventSystem.desc = { name: "events" };
|
|
257
|
+
function findMountedTarget(n) {
|
|
258
|
+
if (!n) return;
|
|
259
|
+
let j = n[0];
|
|
260
|
+
for (let M = 1; M < n.length && n[M].parent === j; ++M) j = n[M];
|
|
261
|
+
return j;
|
|
262
|
+
}
|
|
263
|
+
function clearList(n, j) {
|
|
264
|
+
j || (j = 0);
|
|
265
|
+
for (let M = j; M < n.length && n[M]; ++M) n[M] = null;
|
|
266
|
+
}
|
|
267
|
+
function assignWithIgnore(n, j, M = {}) {
|
|
268
|
+
for (let N in j) !M[N] && j[N] !== void 0 && (n[N] = j[N]);
|
|
269
|
+
}
|
|
270
|
+
var InstructionSet = class {
|
|
271
|
+
constructor() {
|
|
272
|
+
this.instructions = [], this.instructionSize = 0;
|
|
176
273
|
}
|
|
177
|
-
|
|
178
|
-
|
|
274
|
+
reset() {
|
|
275
|
+
this.instructionSize = 0;
|
|
179
276
|
}
|
|
180
|
-
|
|
181
|
-
this.
|
|
182
|
-
}
|
|
183
|
-
get _fontString() {
|
|
184
|
-
return this._cachedFontString === null && (this._cachedFontString = fontStringFromTextStyle(this)), this._cachedFontString;
|
|
185
|
-
}
|
|
186
|
-
update() {
|
|
187
|
-
this._tick++, this._cachedFontString = null;
|
|
277
|
+
add(n) {
|
|
278
|
+
this.instructions[this.instructionSize++] = n;
|
|
188
279
|
}
|
|
189
|
-
|
|
190
|
-
|
|
280
|
+
}, RenderGroup = class {
|
|
281
|
+
constructor(n) {
|
|
282
|
+
this.worldTransform = new Matrix(), this.localTransform = new Matrix(), this.root = null, this.instructionSet = new InstructionSet(), this.structureDidChange = !0, this.renderGroupParent = null, this.renderGroupChildren = [], this.childrenToUpdate = Object.create(null), this.childrenRenderablesToUpdate = {
|
|
283
|
+
list: [],
|
|
284
|
+
index: 0
|
|
285
|
+
}, this.init(n);
|
|
191
286
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
dropShadow: null,
|
|
197
|
-
fill: "black",
|
|
198
|
-
fontFamily: "Arial",
|
|
199
|
-
fontSize: 26,
|
|
200
|
-
fontStyle: "normal",
|
|
201
|
-
fontVariant: "normal",
|
|
202
|
-
fontWeight: "normal",
|
|
203
|
-
leading: 0,
|
|
204
|
-
letterSpacing: 0,
|
|
205
|
-
lineHeight: 0,
|
|
206
|
-
padding: 0,
|
|
207
|
-
stroke: null,
|
|
208
|
-
textBaseline: "alphabetic",
|
|
209
|
-
trim: !1,
|
|
210
|
-
whiteSpace: "pre",
|
|
211
|
-
wordWrap: !1,
|
|
212
|
-
wordWrapWidth: 100
|
|
213
|
-
};
|
|
214
|
-
var genericFontFamilies = [
|
|
215
|
-
"serif",
|
|
216
|
-
"sans-serif",
|
|
217
|
-
"monospace",
|
|
218
|
-
"cursive",
|
|
219
|
-
"fantasy",
|
|
220
|
-
"system-ui"
|
|
221
|
-
];
|
|
222
|
-
function fontStringFromTextStyle(n) {
|
|
223
|
-
let j = typeof n.fontSize == "number" ? `${n.fontSize}px` : n.fontSize, M = n.fontFamily;
|
|
224
|
-
Array.isArray(n.fontFamily) || (M = n.fontFamily.split(","));
|
|
225
|
-
for (let n = M.length - 1; n >= 0; n--) {
|
|
226
|
-
let j = M[n].trim();
|
|
227
|
-
!/([\"\'])[^\'\"]+\1/.test(j) && !genericFontFamilies.includes(j) && (j = `"${j}"`), M[n] = j;
|
|
287
|
+
init(n) {
|
|
288
|
+
this.root = n;
|
|
289
|
+
let j = n.children;
|
|
290
|
+
for (let n = 0; n < j.length; ++n) this.addChild(j[n]);
|
|
228
291
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
var TextMetrics = class n {
|
|
234
|
-
constructor(n, j, M, N, P, F, I, L, R) {
|
|
235
|
-
this.text = n, this.style = j, this.width = M, this.height = N, this.lines = P, this.lineWidths = F, this.lineHeight = I, this.maxLineWidth = L, this.fontProperties = R;
|
|
292
|
+
addChild(n) {
|
|
293
|
+
this.structureDidChange = !0, n.parentRenderGroup = this, n.parent === this.root ? n.relativeRenderGroupDepth = 1 : n.relativeRenderGroupDepth = n.parent.relativeRenderGroupDepth + 1, n.didChange = !0, this.onChildUpdate(n);
|
|
294
|
+
let j = n.children;
|
|
295
|
+
for (let n = 0; n < j.length; ++n) this.addChild(j[n]);
|
|
236
296
|
}
|
|
237
|
-
|
|
238
|
-
if (!n.
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
let M = new OffscreenCanvas(0, 0);
|
|
242
|
-
if (M.getContext("2d", { willReadFrequently: !0 }).measureText) return n._canvas = M, M;
|
|
243
|
-
j = createCanvas(10, 10);
|
|
244
|
-
} catch (n) {
|
|
245
|
-
j = createCanvas(10, 10);
|
|
246
|
-
}
|
|
247
|
-
n._canvas = j;
|
|
297
|
+
removeChild(n) {
|
|
298
|
+
if (this.structureDidChange = !0, n.parentRenderGroup = null, n.renderGroup) {
|
|
299
|
+
this._removeRenderGroupChild(n.renderGroup);
|
|
300
|
+
return;
|
|
248
301
|
}
|
|
249
|
-
|
|
302
|
+
let j = n.children;
|
|
303
|
+
for (let n = 0; n < j.length; ++n) this.removeChild(j[n]);
|
|
250
304
|
}
|
|
251
|
-
|
|
252
|
-
|
|
305
|
+
removeChildren(n) {
|
|
306
|
+
for (let j = 0; j < n.length; ++j) this.removeChild(n[j]);
|
|
253
307
|
}
|
|
254
|
-
|
|
255
|
-
let
|
|
256
|
-
|
|
257
|
-
let P = M._fontString, F = n.measureFont(P);
|
|
258
|
-
F.fontSize === 0 && (F.fontSize = M.fontSize, F.ascent = M.fontSize, F.descent = 0);
|
|
259
|
-
let I = n.context;
|
|
260
|
-
I.font = P;
|
|
261
|
-
let L = j.split(NEWLINE_MATCH_REGEX), R = Array(L.length), z = 0;
|
|
262
|
-
for (let j = 0; j < L.length; ++j) {
|
|
263
|
-
let N = n._measureText(L[j], M.letterSpacing);
|
|
264
|
-
R[j] = N, z = Math.max(z, N);
|
|
265
|
-
}
|
|
266
|
-
let B = M.lineHeight || F.fontSize, V = new n(j, M, z, Math.max(B, F.fontSize + (L.length - 1) * (B + M.leading)), L, R, B, z, F);
|
|
267
|
-
return n._measurementCache.set(N, V), V;
|
|
308
|
+
_removeRenderGroupChild(n) {
|
|
309
|
+
let j = this.renderGroupChildren.indexOf(n);
|
|
310
|
+
j > -1 && this.renderGroupChildren.splice(j, 1), n.renderGroupParent = null;
|
|
268
311
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
let F = n.context;
|
|
272
|
-
F.letterSpacing = "0px", F.textLetterSpacing = M;
|
|
273
|
-
let I = F.measureText(j), L = I.width, R = 0;
|
|
274
|
-
L > 0 && (R = (n.graphemeSegmenter(j).length - 1) * M, L += R);
|
|
275
|
-
let z = -((N = I.actualBoundingBoxLeft) == null ? 0 : N), B = ((P = I.actualBoundingBoxRight) == null ? 0 : P) - z;
|
|
276
|
-
return I.width > 0 && (B += R), Math.max(L, B);
|
|
312
|
+
onChildViewUpdate(n) {
|
|
313
|
+
this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++] = n;
|
|
277
314
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
ascent: I,
|
|
285
|
-
descent: L,
|
|
286
|
-
fontSize: I + L
|
|
287
|
-
};
|
|
288
|
-
return n._fonts[j] = R, R;
|
|
315
|
+
onChildUpdate(n) {
|
|
316
|
+
let j = this.childrenToUpdate[n.relativeRenderGroupDepth];
|
|
317
|
+
j || (j = this.childrenToUpdate[n.relativeRenderGroupDepth] = {
|
|
318
|
+
index: 0,
|
|
319
|
+
list: []
|
|
320
|
+
}), j.list[j.index++] = n;
|
|
289
321
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
var n;
|
|
293
|
-
if (typeof ((n = Intl) == null ? void 0 : n.Segmenter) == "function") {
|
|
294
|
-
let n = new Intl.Segmenter();
|
|
295
|
-
return (j) => {
|
|
296
|
-
let M = n.segment(j), N = [], P = 0;
|
|
297
|
-
for (let n of M) N[P++] = n.segment;
|
|
298
|
-
return N;
|
|
299
|
-
};
|
|
322
|
+
updateRenderable(n) {
|
|
323
|
+
n.globalDisplayStatus < 7 || (this.instructionSet.renderPipes[n.renderPipeId].updateRenderable(n), n.didViewUpdate = !1);
|
|
300
324
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
function createCanvas(n, j) {
|
|
304
|
-
let M = document.createElement("canvas");
|
|
305
|
-
return M.width = n, M.height = j, M;
|
|
306
|
-
}
|
|
307
|
-
function generateTextTexture(n) {
|
|
308
|
-
let { text: j, style: M, resolution: N = 1, padding: P = 0 } = n, F = TextMetrics.measureText(j, M), I = Math.ceil(Math.ceil(Math.max(1, F.width) + P * 2) * N), L = Math.ceil(Math.ceil(Math.max(1, F.height) + P * 2) * N), R = CanvasPool.getOptimalCanvasAndContext(I, L);
|
|
309
|
-
return renderTextToCanvas(M, N, P, R, F), {
|
|
310
|
-
canvasAndContext: R,
|
|
311
|
-
frame: new Rectangle(0, 0, I, L)
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
function renderTextToCanvas(n, j, M, N, P) {
|
|
315
|
-
let { context: F } = N, I = fontStringFromTextStyle(n), { lines: L, lineHeight: R, lineWidths: z, maxLineWidth: B, fontProperties: V } = P;
|
|
316
|
-
F.resetTransform(), F.scale(j, j), F.textBaseline = n.textBaseline, F.font = I;
|
|
317
|
-
let H = Math.min(0, (R - V.fontSize) / 2);
|
|
318
|
-
F.fillStyle = n.fill;
|
|
319
|
-
for (let j = 0; j < L.length; ++j) {
|
|
320
|
-
let P = getAlignmentOffset(z[j], B, n.align), F = j * R + V.ascent + H, I = 0;
|
|
321
|
-
if (n.align === "justify" && n.wordWrap && j < L.length - 1) {
|
|
322
|
-
let n = countSpaces(L[j]);
|
|
323
|
-
n > 0 && (I = (B - z[j]) / n);
|
|
324
|
-
}
|
|
325
|
-
drawLetterSpacing(L[j], n, N, P + M, F + M, !1, I);
|
|
325
|
+
destroy() {
|
|
326
|
+
this.root = null, this.childrenRenderablesToUpdate = null, this.childrenToUpdate = null, this.renderGroupChildren = null, this.instructionSet = null;
|
|
326
327
|
}
|
|
328
|
+
}, uidCache = { default: -1 };
|
|
329
|
+
function uid(n = "default") {
|
|
330
|
+
return uidCache[n] === void 0 && (uidCache[n] = -1), ++uidCache[n];
|
|
327
331
|
}
|
|
328
|
-
function
|
|
329
|
-
|
|
332
|
+
function updateBounds(n, j, M) {
|
|
333
|
+
let { width: N, height: P } = M.orig;
|
|
334
|
+
n.minX = -j.x * N, n.minY = -j.y * P, n.maxX = n.minX + N, n.maxY = n.minY + P;
|
|
330
335
|
}
|
|
331
|
-
function
|
|
332
|
-
let j
|
|
333
|
-
for (let M = 0; M < n.length; M++) n.charCodeAt(M) === 32 && j++;
|
|
334
|
-
return j;
|
|
336
|
+
function applyMixins(n, ...j) {
|
|
337
|
+
for (let M of j) Object.defineProperties(n.prototype, Object.getOwnPropertyDescriptors(M));
|
|
335
338
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
L.fillText(n, N, P);
|
|
340
|
-
return;
|
|
339
|
+
var ObservablePoint = class {
|
|
340
|
+
constructor(n, j, M) {
|
|
341
|
+
this._x = j || 0, this._y = M || 0, this._observer = n;
|
|
341
342
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
for (let n = 0; n < j.length; ++n) L.fillText(j[n], M, P), M += L.measureText(j[n]).width + F + I;
|
|
345
|
-
return;
|
|
343
|
+
set(n = 0, j = n) {
|
|
344
|
+
return (this._x !== n || this._y !== j) && (this._x = n, this._y = j, this._observer._onUpdate(this)), this;
|
|
346
345
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
let j = B[n];
|
|
350
|
-
L.fillText(j, z, P);
|
|
351
|
-
let M = "";
|
|
352
|
-
for (let j = n + 1; j < B.length; ++j) M += B[j];
|
|
353
|
-
H = L.measureText(M).width, z += V - H + R, j === "" && (z += I), V = H;
|
|
346
|
+
get x() {
|
|
347
|
+
return this._x;
|
|
354
348
|
}
|
|
355
|
-
|
|
349
|
+
set x(n) {
|
|
350
|
+
this._x !== n && (this._x = n, this._observer._onUpdate(this));
|
|
351
|
+
}
|
|
352
|
+
get y() {
|
|
353
|
+
return this._y;
|
|
354
|
+
}
|
|
355
|
+
set y(n) {
|
|
356
|
+
this._y !== n && (this._y = n, this._observer._onUpdate(this));
|
|
357
|
+
}
|
|
358
|
+
copyFrom(n) {
|
|
359
|
+
return (this.x !== n.x || this.y !== n.y) && (this._x = n.x, this._y = n.y, this._observer._onUpdate(this)), this;
|
|
360
|
+
}
|
|
361
|
+
toVector2() {
|
|
362
|
+
return new Vector2(this.x, this.y);
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
const RAD_TO_DEG = 180 / Math.PI, DEG_TO_RAD = Math.PI / 180;
|
|
356
366
|
var eventemitter3_default = (/* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((n, j) => {
|
|
357
367
|
var M = Object.prototype.hasOwnProperty, N = "~";
|
|
358
368
|
function P() {}
|
|
@@ -440,945 +450,523 @@ var eventemitter3_default = (/* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJS
|
|
|
440
450
|
var j;
|
|
441
451
|
return n ? (j = N ? N + n : n, this._events[j] && L(this, j)) : (this._events = new P(), this._eventsCount = 0), this;
|
|
442
452
|
}, R.prototype.off = R.prototype.removeListener, R.prototype.addListener = R.prototype.on, R.prefixed = N, R.EventEmitter = R, j !== void 0 && (j.exports = R);
|
|
443
|
-
})))(), 1)).default,
|
|
444
|
-
constructor(j) {
|
|
445
|
-
|
|
446
|
-
let M = {
|
|
447
|
-
...n.defaultOptions,
|
|
448
|
-
...j
|
|
449
|
-
};
|
|
450
|
-
this.label = j.label, this.resource = M.resource, this._resolution = M.resolution, M.width ? this.pixelWidth = j.width * this._resolution : this.pixelWidth = this.resource && this.resourceWidth || 1, M.height ? this.pixelHeight = j.height * this._resolution : this.pixelHeight = this.resource && this.resourceHeight || 1, this.width = this.pixelWidth / this._resolution, this.height = this.pixelHeight / this._resolution;
|
|
453
|
+
})))(), 1)).default, Bounds = class n {
|
|
454
|
+
constructor(n = Infinity, j = Infinity, M = -Infinity, N = -Infinity) {
|
|
455
|
+
this.minX = Infinity, this.minY = Infinity, this.maxX = -Infinity, this.maxY = -Infinity, this.matrix = new Matrix(), this.minX = n, this.minY = j, this.maxX = M, this.maxY = N;
|
|
451
456
|
}
|
|
452
|
-
|
|
453
|
-
return this.
|
|
457
|
+
clone() {
|
|
458
|
+
return new n(this.minX, this.minY, this.maxX, this.maxY);
|
|
454
459
|
}
|
|
455
|
-
|
|
456
|
-
|
|
460
|
+
isEmpty() {
|
|
461
|
+
return this.minX >= this.maxX || this.minY >= this.maxY;
|
|
457
462
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
return n.naturalWidth || n.width;
|
|
463
|
+
clear() {
|
|
464
|
+
this.minX = Infinity, this.minY = Infinity, this.maxX = -Infinity, this.maxY = -Infinity;
|
|
461
465
|
}
|
|
462
|
-
get
|
|
463
|
-
|
|
464
|
-
return n.naturalHeight || n.height;
|
|
466
|
+
get width() {
|
|
467
|
+
return this.maxX - this.minX;
|
|
465
468
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
let N = Math.round(n * M), P = Math.round(j * M);
|
|
469
|
-
return this.width = N / M, this.height = P / M, this._resolution = M, this.pixelWidth === N && this.pixelHeight === P ? !1 : (this.pixelWidth = N, this.pixelHeight = P, this.emit("resize", this), !0);
|
|
469
|
+
set width(n) {
|
|
470
|
+
this.maxX = this.minX + n;
|
|
470
471
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
var CanvasSource = class extends TextureSource {
|
|
474
|
-
constructor(n) {
|
|
475
|
-
n.resource || (n.resource = createCanvas()), n.width || (n.width = n.resource.width, n.autoDensity || (n.width /= n.resolution)), n.height || (n.height = n.resource.height, n.autoDensity || (n.height /= n.resolution)), super(n), this.autoDensity = n.autoDensity, this.resizeCanvas();
|
|
472
|
+
get height() {
|
|
473
|
+
return this.maxY - this.minY;
|
|
476
474
|
}
|
|
477
|
-
|
|
478
|
-
this.
|
|
475
|
+
set height(n) {
|
|
476
|
+
this.maxY = this.minY + n;
|
|
479
477
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
return N && this.resizeCanvas(), N;
|
|
478
|
+
get left() {
|
|
479
|
+
return this.minX;
|
|
483
480
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
if (this.frame = new Rectangle(), this.noFrame = !1, this.label = j, this.source = n, M) this.frame.copyFrom(M);
|
|
487
|
-
else {
|
|
488
|
-
this.noFrame = !0;
|
|
489
|
-
let { width: j, height: M } = n;
|
|
490
|
-
this.frame.width = j, this.frame.height = M;
|
|
491
|
-
}
|
|
492
|
-
this.orig = N || this.frame, this.rotate = P == null ? 0 : P, this.destroyed = !1;
|
|
481
|
+
get right() {
|
|
482
|
+
return this.maxX;
|
|
493
483
|
}
|
|
494
|
-
get
|
|
495
|
-
return this.
|
|
484
|
+
get top() {
|
|
485
|
+
return this.minY;
|
|
496
486
|
}
|
|
497
|
-
|
|
498
|
-
|
|
487
|
+
get bottom() {
|
|
488
|
+
return this.maxY;
|
|
499
489
|
}
|
|
500
|
-
get
|
|
501
|
-
return this.
|
|
490
|
+
get isValid() {
|
|
491
|
+
return this.minX + this.minY !== Infinity;
|
|
502
492
|
}
|
|
503
|
-
|
|
504
|
-
|
|
493
|
+
set(n, j, M, N) {
|
|
494
|
+
this.minX = n, this.minY = j, this.maxX = M, this.maxY = N;
|
|
505
495
|
}
|
|
506
|
-
|
|
507
|
-
this.
|
|
496
|
+
addBounds(n, j) {
|
|
497
|
+
this.addFrame(n.minX, n.minY, n.maxX, n.maxY, j);
|
|
508
498
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
label: "EMPTY",
|
|
512
|
-
source: new TextureSource({ label: "EMPTY" })
|
|
513
|
-
});
|
|
514
|
-
var File = class {
|
|
515
|
-
constructor(n, j) {
|
|
516
|
-
this.key = n, this.url = j;
|
|
517
|
-
}
|
|
518
|
-
}, ImageFile = class extends File {
|
|
519
|
-
load() {
|
|
520
|
-
return new Promise((n, j) => {
|
|
521
|
-
let M = new Image();
|
|
522
|
-
M.onload = () => n(M), M.onerror = () => j(/* @__PURE__ */ Error(`Failed to load ${this.url}`)), M.src = this.url;
|
|
523
|
-
});
|
|
499
|
+
addRect(n, j) {
|
|
500
|
+
this.addFrame(n.x, n.y, n.width + n.x, n.height + n.y, j);
|
|
524
501
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
502
|
+
addFrame(n, j, M, N, P) {
|
|
503
|
+
P || (P = this.matrix);
|
|
504
|
+
let F = P.a, I = P.b, L = P.c, R = P.d, z = P.tx, B = P.ty;
|
|
505
|
+
updateMinMax(F * n + L * j + z, I * n + R * j + B, this), updateMinMax(F * M + L * j + z, I * M + R * j + B, this), updateMinMax(F * n + L * N + z, I * n + R * N + B, this), updateMinMax(F * M + L * N + z, I * M + R * N + B, this);
|
|
528
506
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
507
|
+
get rectangle() {
|
|
508
|
+
this._rectangle || (this._rectangle = new Rectangle());
|
|
509
|
+
let n = this._rectangle;
|
|
510
|
+
return n.x = this.minX, n.y = this.minY, n.width = this.maxX - this.minX, n.height = this.maxY - this.minY, n;
|
|
532
511
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
n instanceof ImageFile && this.textures.add(n.key, j);
|
|
536
|
-
}));
|
|
537
|
-
this.queue.length = 0, await Promise.all(n);
|
|
512
|
+
addBoundsMask(n) {
|
|
513
|
+
this.minX = this.minX > n.minX ? this.minX : n.minX, this.minY = this.minY > n.minY ? this.minY : n.minY, this.maxX = this.maxX < n.maxX ? this.maxX : n.maxX, this.maxY = this.maxY < n.maxY ? this.maxY : n.maxY;
|
|
538
514
|
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
|
|
515
|
+
};
|
|
516
|
+
function updateMinMax(n, j, M) {
|
|
517
|
+
n < M.minX && (M.minX = n), n > M.maxX && (M.maxX = n), j < M.minY && (M.minY = j), j > M.maxY && (M.maxY = j);
|
|
518
|
+
}
|
|
519
|
+
function getLocalBounds(n, j, M) {
|
|
520
|
+
return j.clear(), M || (M = new Matrix()), _getLocalBounds(n, j, M, n, !0), j.isValid || j.set(0, 0, 0, 0), j;
|
|
521
|
+
}
|
|
522
|
+
function _getLocalBounds(n, j, M, N, P) {
|
|
523
|
+
let F = new Matrix();
|
|
524
|
+
if (P) F.copyFrom(M);
|
|
525
|
+
else {
|
|
526
|
+
if (!n.visible || !n.measurable) return;
|
|
527
|
+
n.updateLocalTransform(), F.appendFrom(n.localTransform, M);
|
|
542
528
|
}
|
|
543
|
-
|
|
544
|
-
|
|
529
|
+
let I = j, L = !!n.effects.length;
|
|
530
|
+
if (L && (j = new Bounds()), n.boundsArea) j.addRect(n.boundsArea, F);
|
|
531
|
+
else {
|
|
532
|
+
n.renderPipeId && (j.matrix = F, j.addBounds(n.bounds));
|
|
533
|
+
let M = n.children;
|
|
534
|
+
for (let n = 0; n < M.length; n++) _getLocalBounds(M[n], j, F, N, !1);
|
|
535
|
+
if (L) {
|
|
536
|
+
for (let M = 0; M < n.effects.length; ++M) {
|
|
537
|
+
var R, z;
|
|
538
|
+
(R = (z = n.effects[M]).addLocalBounds) == null || R.call(z, j, N);
|
|
539
|
+
}
|
|
540
|
+
I.addBounds(j, new Matrix());
|
|
541
|
+
}
|
|
545
542
|
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
543
|
+
return j;
|
|
544
|
+
}
|
|
545
|
+
var StencilMask = class {
|
|
546
|
+
constructor(n) {
|
|
547
|
+
this.pipe = "stencilMask", this.mask = n, n.includeInBuild = !1, n.measurable = !1;
|
|
550
548
|
}
|
|
551
|
-
|
|
552
|
-
|
|
549
|
+
addLocalBounds(n, j) {
|
|
550
|
+
let M = new Bounds();
|
|
551
|
+
this.mask.measurable = !0;
|
|
552
|
+
let N = getMatrixRelativeToParent(this.mask, j);
|
|
553
|
+
getLocalBounds(this.mask, M, N), this.mask.measurable = !1, n.addBoundsMask(M);
|
|
553
554
|
}
|
|
554
|
-
|
|
555
|
-
|
|
555
|
+
};
|
|
556
|
+
function getMatrixRelativeToParent(n, j, M) {
|
|
557
|
+
return M || (M = new Matrix()), n === j ? M : (M = getMatrixRelativeToParent(n.parent, j, M), n.updateLocalTransform(), Matrix.append(M, n.localTransform));
|
|
558
|
+
}
|
|
559
|
+
const effectMixin = {
|
|
560
|
+
effects: [],
|
|
561
|
+
_maskEffect: null,
|
|
562
|
+
addEffect(n) {
|
|
563
|
+
this.effects.push(n), this._updateIsSimple();
|
|
564
|
+
},
|
|
565
|
+
removeEffect(n) {
|
|
566
|
+
let j = this.effects.indexOf(n);
|
|
567
|
+
j === -1 && this.effects.splice(j, 1), this._updateIsSimple();
|
|
568
|
+
},
|
|
569
|
+
set mask(n) {
|
|
570
|
+
let j = this._maskEffect;
|
|
571
|
+
n !== (j == null ? void 0 : j.mask) && (j && (this.removeEffect(j), this._maskEffect = null), n != null && (this._maskEffect = new StencilMask(n), this.addEffect(this._maskEffect)));
|
|
572
|
+
},
|
|
573
|
+
get mask() {
|
|
574
|
+
var n;
|
|
575
|
+
return (n = this._maskEffect) == null ? void 0 : n.mask;
|
|
556
576
|
}
|
|
557
|
-
|
|
558
|
-
|
|
577
|
+
}, sortMixin = {
|
|
578
|
+
_zIndex: 0,
|
|
579
|
+
sortableChildren: !1,
|
|
580
|
+
sortDirty: !1
|
|
581
|
+
}, measureMixin = {
|
|
582
|
+
_localBoundsCacheData: null,
|
|
583
|
+
_localBounds: null,
|
|
584
|
+
_setWidth(n, j) {
|
|
585
|
+
let M = Math.sign(this.scale.x) || 1;
|
|
586
|
+
j === 0 ? this.scale.x = M : this.scale.x = n / j * M;
|
|
587
|
+
},
|
|
588
|
+
_setHeight(n, j) {
|
|
589
|
+
let M = Math.sign(this.scale.y) || 1;
|
|
590
|
+
j === 0 ? this.scale.y = M : this.scale.y = n / j * M;
|
|
591
|
+
},
|
|
592
|
+
getLocalBounds() {
|
|
593
|
+
return this._localBounds || (this._localBounds = new Bounds()), getLocalBounds(this, this._localBounds), this._localBounds;
|
|
559
594
|
}
|
|
560
|
-
},
|
|
561
|
-
|
|
562
|
-
|
|
595
|
+
}, childrenHelperMixin = { removeChildren(n = 0, j) {
|
|
596
|
+
let M = j == null ? this.children.length : j, N = M - n, P = [];
|
|
597
|
+
if (N > 0 && N <= M) {
|
|
598
|
+
for (let j = M - 1; j >= n; --j) {
|
|
599
|
+
let n = this.children[j];
|
|
600
|
+
n && (P.push(n), n.parent = null);
|
|
601
|
+
}
|
|
602
|
+
removeItems(this.children, n, M);
|
|
603
|
+
let j = this.renderGroup || this.parentRenderGroup;
|
|
604
|
+
return j && j.removeChildren(P), P;
|
|
605
|
+
} else if (N === 0 && this.children.length === 0) return P;
|
|
606
|
+
throw Error("removeChildren: numeric values are outside the acceptable range.");
|
|
607
|
+
} };
|
|
608
|
+
function removeItems(n, j, M) {
|
|
609
|
+
let N = n.length, P;
|
|
610
|
+
if (j >= N || M === 0) return;
|
|
611
|
+
M = j + M > N ? N - j : M;
|
|
612
|
+
let F = N - M;
|
|
613
|
+
for (P = j; P < F; ++P) n[P] = n[P + M];
|
|
614
|
+
n.length = F;
|
|
615
|
+
}
|
|
616
|
+
const UPDATE_COLOR = 1, UPDATE_BLEND = 2, UPDATE_VISIBLE = 4, UPDATE_TRANSFORM = 8;
|
|
617
|
+
var defaultSkew = new ObservablePoint(null), defaultOrigin = new ObservablePoint(null), defaultScale = new ObservablePoint(null, 1, 1), defaultPivot = new ObservablePoint(null), Container = class extends eventemitter3_default {
|
|
618
|
+
constructor(n = {}) {
|
|
619
|
+
super(), this.destroyed = !1, this.renderGroup = null, this.parentRenderGroup = null, this.parent = null, this.eventMode = "passive", this.hitArea = null, this._position = new ObservablePoint(this, 0, 0), this.includeInBuild = !0, this.didChange = !1, this.didViewUpdate = !1, this.isSimple = !0, this.measurable = !0, this.relativeRenderGroupDepth = 0, this._attrUpdateTick = 0, this._localTransformUpdateTick = 0, this._updateFlags = 15, this.localDisplayStatus = 7, this.globalDisplayStatus = 7, this.children = [], this.localTransform = new Matrix(), this.relativeGroupTransform = new Matrix(), this.groupTransform = this.relativeGroupTransform, this._rotation = 0, this._cx = 1, this._sx = 0, this._cy = 0, this._sy = 1, this._skew = defaultSkew, this._scale = defaultScale, this._origin = defaultOrigin, this._pivot = defaultPivot, this.localAlpha = 1, this.groupColor = 16777215, this.localColor = 16777215, this.groupAlpha = 1, this.groupColorAlpha = 4294967295, assignWithIgnore(this, n, {
|
|
620
|
+
children: !0,
|
|
621
|
+
parent: !0,
|
|
622
|
+
effects: !0
|
|
623
|
+
}), this.effects = [];
|
|
563
624
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
let j = await this.loader.image(n.alias, n.src);
|
|
567
|
-
return {
|
|
568
|
-
key: n.alias,
|
|
569
|
-
value: j
|
|
570
|
-
};
|
|
571
|
-
});
|
|
572
|
-
return (await Promise.all(j)).reduce((n, j) => (n[j.key] = j.value, n), {});
|
|
625
|
+
get renderable() {
|
|
626
|
+
return !!(this.localDisplayStatus & 1);
|
|
573
627
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
constructor(n) {
|
|
578
|
-
this.system = n;
|
|
628
|
+
set renderable(n) {
|
|
629
|
+
let j = n ? 1 : 0;
|
|
630
|
+
(this.localDisplayStatus & 1) !== j && (this._updateFlags |= 4, this.localDisplayStatus ^= 1, this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._onUpdate());
|
|
579
631
|
}
|
|
580
|
-
|
|
581
|
-
return
|
|
632
|
+
get visible() {
|
|
633
|
+
return !!(this.localDisplayStatus & 2);
|
|
582
634
|
}
|
|
583
|
-
|
|
584
|
-
|
|
635
|
+
set visible(n) {
|
|
636
|
+
let j = n ? 2 : 0;
|
|
637
|
+
(this.localDisplayStatus & 2) !== j && (this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._updateFlags |= 4, this.localDisplayStatus ^= 2, this._onUpdate());
|
|
585
638
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
this.domElement = null, this.rootTarget = null, this.resolution = 1, this._allInteractiveElements = [], this._hitElements = [], this._isPointerMoveEvent = !1, this.mappingState = { trackingData: {} }, this.renderer = n, this.resolution = n.resolution, this._onPointerDown = this._onPointerDown.bind(this), this._onPointerMove = this._onPointerMove.bind(this), this._onPointerUp = this._onPointerUp.bind(this), this._onPointerOverOut = this._onPointerOverOut.bind(this), this.init();
|
|
639
|
+
get isRenderGroup() {
|
|
640
|
+
return !!this.renderGroup;
|
|
589
641
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
pressTargetsByButton: {},
|
|
593
|
-
clicksByButton: {},
|
|
594
|
-
overTargets: null
|
|
595
|
-
}), this.mappingState.trackingData[n];
|
|
642
|
+
set isRenderGroup(n) {
|
|
643
|
+
!!this.renderGroup !== n && (n ? this.enableRenderGroup() : this.disableRenderGroup());
|
|
596
644
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
this.setTargetElement(n);
|
|
645
|
+
get zIndex() {
|
|
646
|
+
return this._zIndex;
|
|
600
647
|
}
|
|
601
|
-
|
|
602
|
-
this.
|
|
648
|
+
set zIndex(n) {
|
|
649
|
+
n !== this._zIndex && (this._zIndex = n, this.depthOfChildModified());
|
|
603
650
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
let M = n.composedPath();
|
|
607
|
-
for (let N = 0; N < M.length - 1; ++N) n.currentTarget = M[N], this._notifyTarget(n, j);
|
|
608
|
-
n.currentTarget = n.target, this._notifyTarget(n, j);
|
|
651
|
+
_updateIsSimple() {
|
|
652
|
+
this.isSimple = !this.renderGroup && this.effects.length == 0;
|
|
609
653
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
let M = n.currentTarget._events[j];
|
|
613
|
-
if (M) if ("fn" in M) M.once && n.target.removeListener(j, M.fn, void 0, !0), M.fn.call(M.context, n);
|
|
614
|
-
else for (let N = 0; N < M.length; ++N) {
|
|
615
|
-
let P = M[N];
|
|
616
|
-
P.once && n.target.removeListener(j, P.fn, void 0, !0), P.fn.call(P.context, n);
|
|
617
|
-
}
|
|
654
|
+
sortChildren() {
|
|
655
|
+
this.sortDirty && (this.sortDirty = !1, this.children.sort(sortChildren));
|
|
618
656
|
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
for (let M = 0; M < PROPAGATION_LIMIT && (n !== this.rootTarget || n.parent); ++M) {
|
|
622
|
-
if (!n.parent) throw Error("Cannot find propagation path to disconnected target");
|
|
623
|
-
j.push(n.parent), n = n.parent;
|
|
624
|
-
}
|
|
625
|
-
return j.reverse(), j;
|
|
657
|
+
depthOfChildModified() {
|
|
658
|
+
this.parent && (this.parent.sortableChildren = !0, this.parent.sortDirty = !0), this.parentRenderGroup;
|
|
626
659
|
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
n && (globalThis.document.removeEventListener("pointermove", this._onPointerMove, !0), n.removeEventListener("pointerdown", this._onPointerDown, !0), n.removeEventListener("pointerleave", this._onPointerOverOut, !0), n.removeEventListener("pointerover", this._onPointerOverOut, !0), globalThis.document.removeEventListener("pointerup", this._onPointerUp, !0));
|
|
660
|
+
enableRenderGroup() {
|
|
661
|
+
this.renderGroup || (this.renderGroup = new RenderGroup(this), this.groupTransform = new Matrix(), this._updateIsSimple());
|
|
630
662
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
j && (j.touchAction = "none"), globalThis.document.addEventListener("pointermove", this._onPointerMove, !0), n.addEventListener("pointerdown", this._onPointerDown, !0), n.addEventListener("pointerleave", this._onPointerOverOut, !0), n.addEventListener("pointerover", this._onPointerOverOut, !0), globalThis.document.addEventListener("pointerup", this._onPointerUp, !0);
|
|
663
|
+
disableRenderGroup() {
|
|
664
|
+
if (!this.renderGroup) return;
|
|
665
|
+
let n = this.parentRenderGroup;
|
|
666
|
+
n == null || n.removeChild(this), this.renderGroup = null, this.groupTransform = this.relativeGroupTransform, n == null || n.addChild(this), this._updateIsSimple();
|
|
636
667
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
let M = this.
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
if (((j = N.overTargets) == null ? void 0 : j.length) > 0 && P !== M.target) {
|
|
645
|
-
let j = this.createPointEvent(n, "pointerout", P);
|
|
646
|
-
this.dispatchEvent(j, "pointerout");
|
|
647
|
-
let N = M.composedPath();
|
|
648
|
-
if (!N.includes(P)) {
|
|
649
|
-
let j = this.createPointEvent(n, "pointerleave", P);
|
|
650
|
-
for (; j.target && !N.includes(j.target);) j.currentTarget = j.target, this._notifyTarget(j), j.target = j.target.parent;
|
|
651
|
-
}
|
|
668
|
+
collectRenderables(n, j) {
|
|
669
|
+
this.globalDisplayStatus < 7 || !this.includeInBuild || (this.sortableChildren && this.sortChildren(), this.isSimple ? this.collectRenderableSimple(n, j) : this.renderGroup || this.collectRenderablesWithEffects(n, j));
|
|
670
|
+
}
|
|
671
|
+
collectRenderablesWithEffects(n, j) {
|
|
672
|
+
for (let M = 0; M < this.effects.length; ++M) {
|
|
673
|
+
let N = this.effects[M];
|
|
674
|
+
n[N.pipe].push(N, j);
|
|
652
675
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
this.
|
|
656
|
-
|
|
657
|
-
for (; N && N !== this.rootTarget.parent && N !== M.target;) N = N.parent;
|
|
658
|
-
if (!N || N === this.rootTarget.parent) {
|
|
659
|
-
let n = this.clonePointEvent(M, "pointerenter");
|
|
660
|
-
for (; n.target && n.target !== P && n.target !== this.rootTarget.parent;) n.currentTarget = n.target, this._notifyTarget(n), n.target = n.target.parent;
|
|
661
|
-
}
|
|
676
|
+
this.collectRenderableSimple(n, j);
|
|
677
|
+
for (let M = 0; M < this.effects.length; ++M) {
|
|
678
|
+
let N = this.effects[M];
|
|
679
|
+
n[N.pipe].pop(N, j);
|
|
662
680
|
}
|
|
663
|
-
this.dispatchEvent(M, "pointermove");
|
|
664
|
-
let F = this._allInteractiveElements;
|
|
665
|
-
for (let n = F.length - 1; n >= 0; --n) M.currentTarget = F[n], this._notifyTarget(M, "globalpointermove");
|
|
666
|
-
this._allInteractiveElements.length = 0, this._hitElements.length = 0, N.overTargets = M.composedPath();
|
|
667
681
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
let
|
|
671
|
-
this.dispatchEvent(j, "pointerdown");
|
|
672
|
-
let M = this.trackingData(n.pointerId);
|
|
673
|
-
M.pressTargetsByButton[n.button] = j.composedPath();
|
|
682
|
+
collectRenderableSimple(n, j) {
|
|
683
|
+
let M = this.children;
|
|
684
|
+
for (let N = 0; N < M.length; ++N) M[N].collectRenderables(n, j);
|
|
674
685
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
let j = this.createPointEvent(n);
|
|
678
|
-
this.dispatchEvent(j, "pointerout");
|
|
686
|
+
setFromMatrix(n) {
|
|
687
|
+
n.decompose(this);
|
|
679
688
|
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
n.composedPath && n.composedPath().length > 1 && (j = n.composedPath()[0]);
|
|
684
|
-
let M = j === this.domElement ? "" : "outside", N = this.createPointEvent(n);
|
|
685
|
-
this.dispatchEvent(N, `pointerup${M}`);
|
|
689
|
+
_updateSkew() {
|
|
690
|
+
let n = this.rotation, j = this.skew;
|
|
691
|
+
this._cx = Math.cos(n + j.y), this._sx = Math.sin(n + j.y), this._cy = -Math.sin(n - j.x), this._sy = Math.cos(n - j.x);
|
|
686
692
|
}
|
|
687
|
-
|
|
688
|
-
|
|
693
|
+
updateLocalTransform() {
|
|
694
|
+
let n = this._attrUpdateTick;
|
|
695
|
+
if (this._localTransformUpdateTick === n) return;
|
|
696
|
+
this._localTransformUpdateTick = n, this._updateSkew();
|
|
697
|
+
let j = this.position, M = this.localTransform, N = this._scale.x, P = this._scale.y, F = -this._origin.x, I = -this._origin.y, L = this._pivot.x, R = this._pivot.y;
|
|
698
|
+
M.a = this._cx * N, M.b = this._sx * N, M.c = this._cy * P, M.d = this._sy * P, M.tx = j.x - (L * M.a + R * M.c) + (F * M.a + I * M.c) - F, M.ty = j.y - (L * M.b + R * M.d) + (F * M.b + I * M.d) - I;
|
|
689
699
|
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
let P = this.mapPositionToPoint(n.clientX, n.clientY);
|
|
693
|
-
n.type === "pointerleave" && (j = "pointerout");
|
|
694
|
-
let F = new FederatedEvent(this);
|
|
695
|
-
return F.type = j, F.nativeEvent = n, F.target = (N = M == null ? this.hitTest(P.x, P.y) : M) == null ? this._hitElements[0] : N, F.global = P, F;
|
|
700
|
+
get alpha() {
|
|
701
|
+
return this.localAlpha;
|
|
696
702
|
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
return M.nativeEvent = n.nativeEvent, M.global = n.global, M.type = j == null ? n.type : j, M.path = n.composedPath().slice(), M.target = n.target, M;
|
|
703
|
+
set alpha(n) {
|
|
704
|
+
n !== this.localAlpha && (this.localAlpha = n, this._updateFlags |= 1, this._onUpdate());
|
|
700
705
|
}
|
|
701
|
-
|
|
702
|
-
let
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
width: M.width,
|
|
706
|
-
height: M.height,
|
|
707
|
-
left: 0,
|
|
708
|
-
top: 0
|
|
709
|
-
}, P = 1 / this.resolution, F = new Vector2();
|
|
710
|
-
return F.x = (n - N.left) * (M.width / N.width) * P, F.y = (j - N.top) * (M.height / N.height) * P, F;
|
|
706
|
+
get root() {
|
|
707
|
+
let n = this.parent, j = this.parent;
|
|
708
|
+
for (; n;) n.parent || (j = n), n = n.parent;
|
|
709
|
+
return j;
|
|
711
710
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
return N && N[0];
|
|
711
|
+
get worldTransform() {
|
|
712
|
+
return this._worldTransform || (this._worldTransform = new Matrix()), this.renderGroup ? this._worldTransform.copyFrom(this.renderGroup.worldTransform) : this.parentRenderGroup && this._worldTransform.appendFrom(this.relativeGroupTransform, this.parentRenderGroup.worldTransform), this._worldTransform;
|
|
715
713
|
}
|
|
716
|
-
|
|
717
|
-
return
|
|
714
|
+
get x() {
|
|
715
|
+
return this._position.x;
|
|
718
716
|
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
if (this._interactivePrune(n)) return;
|
|
722
|
-
let P = n.children;
|
|
723
|
-
if (P && P.length > 0) for (let F = P.length - 1; F >= 0; --F) {
|
|
724
|
-
let I = P[F], L = this.hitTestMoveRecursive(I, this._isInteractive(j) ? j : I.eventMode, M);
|
|
725
|
-
if (L) {
|
|
726
|
-
if (L.length > 0 && !L[L.length - 1].parent) continue;
|
|
727
|
-
let j = this._isInteractive(n.eventMode);
|
|
728
|
-
(L.length > 0 || j) && (j && this._allInteractiveElements.push(n), L.push(n)), this._hitElements.length === 0 && (this._hitElements = L), N = !0;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
let F = this._isInteractive(j), I = this._isInteractive(n.eventMode);
|
|
732
|
-
if (I && this._allInteractiveElements.push(n), !(this._hitElements.length > 0)) {
|
|
733
|
-
if (N) return this._hitElements;
|
|
734
|
-
if (F && this.hitTestFn(n, M)) return I ? [n] : [];
|
|
735
|
-
}
|
|
717
|
+
set x(n) {
|
|
718
|
+
this._position.x = n;
|
|
736
719
|
}
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
for (let P = N.length - 1; P >= 0; P--) {
|
|
740
|
-
let F = N[P], I = this.hitTestRecursive(F, this._isInteractive(j) ? j : F.eventMode, M);
|
|
741
|
-
if (I) {
|
|
742
|
-
let j = this._isInteractive(n.eventMode);
|
|
743
|
-
return (I.length > 0 || j) && I.push(n), I;
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
let P = this._isInteractive(j), F = this._isInteractive(n.eventMode);
|
|
747
|
-
return P && this.hitTestFn(n, M) ? F ? [n] : [] : null;
|
|
720
|
+
get position() {
|
|
721
|
+
return this._position;
|
|
748
722
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
if (n.containsPoint) {
|
|
752
|
-
let M = n.worldTransform.applyInverse(j);
|
|
753
|
-
return n.containsPoint(M);
|
|
754
|
-
}
|
|
755
|
-
return !1;
|
|
723
|
+
set position(n) {
|
|
724
|
+
this._position.copyFrom(n);
|
|
756
725
|
}
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
function findMountedTarget(n) {
|
|
760
|
-
if (!n) return;
|
|
761
|
-
let j = n[0];
|
|
762
|
-
for (let M = 1; M < n.length && n[M].parent === j; ++M) j = n[M];
|
|
763
|
-
return j;
|
|
764
|
-
}
|
|
765
|
-
function clearList(n, j) {
|
|
766
|
-
j || (j = 0);
|
|
767
|
-
for (let M = j; M < n.length && n[M]; ++M) n[M] = null;
|
|
768
|
-
}
|
|
769
|
-
function assignWithIgnore(n, j, M = {}) {
|
|
770
|
-
for (let N in j) !M[N] && j[N] !== void 0 && (n[N] = j[N]);
|
|
771
|
-
}
|
|
772
|
-
var InstructionSet = class {
|
|
773
|
-
constructor() {
|
|
774
|
-
this.instructions = [], this.instructionSize = 0;
|
|
726
|
+
get y() {
|
|
727
|
+
return this._position.y;
|
|
775
728
|
}
|
|
776
|
-
|
|
777
|
-
this.
|
|
729
|
+
set y(n) {
|
|
730
|
+
this._position.y = n;
|
|
778
731
|
}
|
|
779
|
-
|
|
780
|
-
this.
|
|
732
|
+
get rotation() {
|
|
733
|
+
return this._rotation;
|
|
781
734
|
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
this.worldTransform = new Matrix(), this.localTransform = new Matrix(), this.root = null, this.instructionSet = new InstructionSet(), this.structureDidChange = !0, this.renderGroupParent = null, this.renderGroupChildren = [], this.childrenToUpdate = Object.create(null), this.childrenRenderablesToUpdate = {
|
|
785
|
-
list: [],
|
|
786
|
-
index: 0
|
|
787
|
-
}, this.init(n);
|
|
735
|
+
set rotation(n) {
|
|
736
|
+
this._rotation !== n && (this._rotation = n, this._onUpdate(this._skew));
|
|
788
737
|
}
|
|
789
|
-
|
|
790
|
-
this.
|
|
791
|
-
let j = n.children;
|
|
792
|
-
for (let n = 0; n < j.length; ++n) this.addChild(j[n]);
|
|
738
|
+
get angle() {
|
|
739
|
+
return this.rotation * RAD_TO_DEG;
|
|
793
740
|
}
|
|
794
|
-
|
|
795
|
-
this.
|
|
796
|
-
let j = n.children;
|
|
797
|
-
for (let n = 0; n < j.length; ++n) this.addChild(j[n]);
|
|
741
|
+
set angle(n) {
|
|
742
|
+
this.rotation = n * DEG_TO_RAD;
|
|
798
743
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
this._removeRenderGroupChild(n.renderGroup);
|
|
802
|
-
return;
|
|
803
|
-
}
|
|
804
|
-
let j = n.children;
|
|
805
|
-
for (let n = 0; n < j.length; ++n) this.removeChild(j[n]);
|
|
744
|
+
get skew() {
|
|
745
|
+
return this._skew === defaultSkew && (this._skew = new ObservablePoint(this, 0, 0)), this._skew;
|
|
806
746
|
}
|
|
807
|
-
|
|
808
|
-
|
|
747
|
+
set skew(n) {
|
|
748
|
+
this._skew === defaultSkew && (this._skew = new ObservablePoint(this, 0, 0)), this._skew.copyFrom(n);
|
|
809
749
|
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
j > -1 && this.renderGroupChildren.splice(j, 1), n.renderGroupParent = null;
|
|
750
|
+
get scale() {
|
|
751
|
+
return this._scale === defaultScale && (this._scale = new ObservablePoint(this, 1, 1)), this._scale;
|
|
813
752
|
}
|
|
814
|
-
|
|
815
|
-
this.
|
|
753
|
+
set scale(n) {
|
|
754
|
+
this._scale === defaultScale && (this._scale = new ObservablePoint(this, 1, 1)), this._scale.copyFrom(n);
|
|
816
755
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
j || (j = this.childrenToUpdate[n.relativeRenderGroupDepth] = {
|
|
820
|
-
index: 0,
|
|
821
|
-
list: []
|
|
822
|
-
}), j.list[j.index++] = n;
|
|
756
|
+
get pivot() {
|
|
757
|
+
return this._pivot === defaultPivot && (this._pivot = new ObservablePoint(this, 0, 0)), this._pivot;
|
|
823
758
|
}
|
|
824
|
-
|
|
825
|
-
|
|
759
|
+
set pivot(n) {
|
|
760
|
+
this._pivot === defaultPivot && (this._pivot = new ObservablePoint(this, 0, 0)), this._pivot.copyFrom(n);
|
|
826
761
|
}
|
|
827
|
-
|
|
828
|
-
this.
|
|
762
|
+
get origin() {
|
|
763
|
+
return this._origin === defaultOrigin && (this._origin = new ObservablePoint(this, 0, 0)), this._origin;
|
|
829
764
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
let { width: N, height: P } = M.orig;
|
|
833
|
-
n.minX = -j.x * N, n.minY = -j.y * P, n.maxX = n.minX + N, n.maxY = n.minY + P;
|
|
834
|
-
}
|
|
835
|
-
function applyMixins(n, ...j) {
|
|
836
|
-
for (let M of j) Object.defineProperties(n.prototype, Object.getOwnPropertyDescriptors(M));
|
|
837
|
-
}
|
|
838
|
-
var ObservablePoint = class {
|
|
839
|
-
constructor(n, j, M) {
|
|
840
|
-
this._x = j || 0, this._y = M || 0, this._observer = n;
|
|
765
|
+
set origin(n) {
|
|
766
|
+
this._origin === defaultOrigin && (this._origin = new ObservablePoint(this, 0, 0)), this._origin.copyFrom(n);
|
|
841
767
|
}
|
|
842
|
-
|
|
843
|
-
return
|
|
768
|
+
get width() {
|
|
769
|
+
return Math.abs(this.scale.x * this.getLocalBounds().width);
|
|
844
770
|
}
|
|
845
|
-
|
|
846
|
-
|
|
771
|
+
set width(n) {}
|
|
772
|
+
get height() {
|
|
773
|
+
return Math.abs(this.scale.y * this.getLocalBounds().height);
|
|
847
774
|
}
|
|
848
|
-
set
|
|
849
|
-
|
|
775
|
+
set height(n) {}
|
|
776
|
+
addChild(...n) {
|
|
777
|
+
if (n.length > 1) {
|
|
778
|
+
for (let j = 0; j < n.length; ++j) this.addChild(n[j]);
|
|
779
|
+
return n[0];
|
|
780
|
+
}
|
|
781
|
+
let j = n[0], M = this.renderGroup || this.parentRenderGroup;
|
|
782
|
+
return j.parent === this ? (this.children.splice(this.children.indexOf(j), 1), this.children.push(j), M && (M.structureDidChange = !0), j) : (this.sortableChildren && (this.sortDirty = !0), j.parent && j.parent.removeChild(j), this.children.push(j), this.sortableChildren && (this.sortDirty = !0), j.parent = this, j.didChange = !0, j._updateFlags = 7, M && M.addChild(j), j._zIndex != 0 && j.depthOfChildModified(), j);
|
|
850
783
|
}
|
|
851
|
-
|
|
852
|
-
|
|
784
|
+
removeChild(...n) {
|
|
785
|
+
if (n.length > 1) {
|
|
786
|
+
for (let j = 0; j < n.length; ++j) this.removeChild(n[j]);
|
|
787
|
+
return n[0];
|
|
788
|
+
}
|
|
789
|
+
let j = n[0];
|
|
790
|
+
if (!j) return j;
|
|
791
|
+
let M = this.children.indexOf(j);
|
|
792
|
+
return M > -1 && (this.children.splice(M, 1), j.parent = null), j;
|
|
853
793
|
}
|
|
854
|
-
|
|
855
|
-
this.
|
|
794
|
+
_onUpdate(n) {
|
|
795
|
+
n && n === this._skew && this._updateSkew(), this._attrUpdateTick++, !this.didChange && (this.didChange = !0, this.parentRenderGroup && this.parentRenderGroup.onChildUpdate(this));
|
|
856
796
|
}
|
|
857
|
-
|
|
858
|
-
return
|
|
797
|
+
toGlobal(n, j) {
|
|
798
|
+
return this.getGlobalTransform(j).apply(n);
|
|
859
799
|
}
|
|
860
|
-
|
|
861
|
-
|
|
800
|
+
toLocal(n, j, M) {
|
|
801
|
+
let N;
|
|
802
|
+
return j && (N = j.toGlobal(n)), N = this.getGlobalTransform(M).applyInverse(n), N;
|
|
803
|
+
}
|
|
804
|
+
getGlobalTransform(n = !1) {
|
|
805
|
+
if (n) return this.worldTransform.clone();
|
|
806
|
+
this.updateLocalTransform();
|
|
807
|
+
let j = new Matrix(), M = updateTransformBackwards(this, j);
|
|
808
|
+
return j.appendFrom(this.localTransform, M), j;
|
|
809
|
+
}
|
|
810
|
+
getGlobalPosition(n = !1) {
|
|
811
|
+
return this.parent ? this.parent.toGlobal(this._position, n) : this._position.toVector2();
|
|
812
|
+
}
|
|
813
|
+
destroy(n = !1) {
|
|
814
|
+
var j, M;
|
|
815
|
+
if (this.destroyed) return;
|
|
816
|
+
this.destroyed = !0;
|
|
817
|
+
let N;
|
|
818
|
+
if (this.children.length && (N = this.removeChildren(0, this.children.length)), (j = this.parent) == null || j.removeChild(this), this.parent = null, this._maskEffect = null, this.effects = null, this._position = null, this._scale = null, this._pivot = null, this._origin = null, this._skew = null, (typeof n == "boolean" ? n : n != null && n.children) && N) for (let j = 0; j < N.length; ++j) N[j].destroy(n);
|
|
819
|
+
(M = this.renderGroup) == null || M.destroy(), this.renderGroup = null;
|
|
862
820
|
}
|
|
863
821
|
};
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
822
|
+
function updateTransformBackwards(n, j) {
|
|
823
|
+
let M = n.parent;
|
|
824
|
+
if (M) {
|
|
825
|
+
updateTransformBackwards(M, j), M.updateLocalTransform();
|
|
826
|
+
let n = Matrix.append(j, M.localTransform);
|
|
827
|
+
j.copyFrom(n);
|
|
868
828
|
}
|
|
869
|
-
|
|
870
|
-
|
|
829
|
+
return j;
|
|
830
|
+
}
|
|
831
|
+
function sortChildren(n, j) {
|
|
832
|
+
return n._zIndex - j._zIndex;
|
|
833
|
+
}
|
|
834
|
+
applyMixins(Container, sortMixin, effectMixin, measureMixin, childrenHelperMixin);
|
|
835
|
+
var UPDATE_BLEND_COLOR_VISIBLE = 7;
|
|
836
|
+
function updateRenderGroupTransform(n, j = !1) {
|
|
837
|
+
let M = n.root;
|
|
838
|
+
n.worldTransform.copyFrom(M.localTransform);
|
|
839
|
+
let N = n.childrenToUpdate;
|
|
840
|
+
for (let j in N) {
|
|
841
|
+
let M = Number(j), P = N[M], F = P.list, I = P.index;
|
|
842
|
+
for (let j = 0; j < I; ++j) {
|
|
843
|
+
let N = F[j];
|
|
844
|
+
N.parentRenderGroup === n && N.relativeRenderGroupDepth === M && updateTransform(N, 0);
|
|
845
|
+
}
|
|
846
|
+
clearList(F, I), P.index = 0;
|
|
871
847
|
}
|
|
872
|
-
|
|
873
|
-
|
|
848
|
+
if (j) for (let M = 0; M < n.renderGroupChildren.length; ++M) updateRenderGroupTransform(n.renderGroupChildren[M], j);
|
|
849
|
+
}
|
|
850
|
+
function updateTransform(n, j) {
|
|
851
|
+
n.didChange = !1;
|
|
852
|
+
let M = n.parent, N = n.localTransform;
|
|
853
|
+
n.updateLocalTransform(), M && (j |= n._updateFlags, n.relativeGroupTransform.appendFrom(N, M.relativeGroupTransform), j & UPDATE_BLEND_COLOR_VISIBLE && updateBlendColorVisible(n, M, j));
|
|
854
|
+
let P = n.children;
|
|
855
|
+
for (let n = 0; n < P.length; n++) updateTransform(P[n], j);
|
|
856
|
+
}
|
|
857
|
+
function updateBlendColorVisible(n, j, M) {
|
|
858
|
+
if (M & 1) {
|
|
859
|
+
n.groupColor = j.groupColor;
|
|
860
|
+
let M = n.localAlpha * j.groupAlpha;
|
|
861
|
+
M = M < 0 ? 0 : M > 1 ? 1 : M, n.groupAlpha = M, n.groupColorAlpha = n.groupColor + ((M * 255 | 0) << 24);
|
|
874
862
|
}
|
|
875
|
-
|
|
876
|
-
|
|
863
|
+
M & 4 && (n.globalDisplayStatus = n.localDisplayStatus & j.globalDisplayStatus), n._updateFlags = 0;
|
|
864
|
+
}
|
|
865
|
+
function validateRenderables(n, j) {
|
|
866
|
+
let { list: M, index: N } = n.childrenRenderablesToUpdate, P = !1;
|
|
867
|
+
for (let n = 0; n < N; ++n) {
|
|
868
|
+
let N = M[n];
|
|
869
|
+
if (P = j[N.renderPipeId].validateRenderable(N), P) break;
|
|
877
870
|
}
|
|
878
|
-
|
|
879
|
-
|
|
871
|
+
return n.structureDidChange = P, P;
|
|
872
|
+
}
|
|
873
|
+
var _RenderGroupSystem, RenderGroupSystem = class {
|
|
874
|
+
constructor(n) {
|
|
875
|
+
this.renderer = n;
|
|
880
876
|
}
|
|
881
|
-
|
|
882
|
-
|
|
877
|
+
_updateRenderGroup(n) {
|
|
878
|
+
let j = this.renderer, M = j.renderPipes;
|
|
879
|
+
n.instructionSet.renderPipes = M, n.structureDidChange ? clearList(n.childrenRenderablesToUpdate.list, 0) : validateRenderables(n, M), updateRenderGroupTransform(n), n.structureDidChange && (n.structureDidChange = !1, this._buildInstructions(n, j)), n.childrenRenderablesToUpdate.index = 0;
|
|
883
880
|
}
|
|
884
|
-
|
|
885
|
-
|
|
881
|
+
render({ container: n, transform: j }) {
|
|
882
|
+
let M = this.renderer;
|
|
883
|
+
j && n.renderGroup.localTransform.copyFrom(j), M.canvasContext.globalTransform = j ? n.renderGroup.localTransform : n.renderGroup.worldTransform, this._updateRenderGroup(n.renderGroup), executeInstructions(n.renderGroup, M.renderPipes);
|
|
886
884
|
}
|
|
887
|
-
|
|
888
|
-
|
|
885
|
+
_buildInstructions(n, j) {
|
|
886
|
+
let M = j.renderPipes, N = n.root;
|
|
887
|
+
n.instructionSet.reset(), N.sortableChildren && N.sortChildren(), M.batch.buildStart(), N.collectRenderablesWithEffects(M, n.instructionSet), M.batch.buildEnd(n.instructionSet);
|
|
889
888
|
}
|
|
890
|
-
|
|
891
|
-
|
|
889
|
+
};
|
|
890
|
+
_RenderGroupSystem = RenderGroupSystem, _RenderGroupSystem.desc = { name: "renderGroup" };
|
|
891
|
+
function executeInstructions(n, j) {
|
|
892
|
+
let { instructionSet: M } = n, N = M.instructions;
|
|
893
|
+
for (let n = 0; n < M.instructionSize; n++) {
|
|
894
|
+
let M = N[n];
|
|
895
|
+
j[M.renderPipeId].execute(M);
|
|
892
896
|
}
|
|
893
|
-
|
|
894
|
-
|
|
897
|
+
}
|
|
898
|
+
var _SpritePipe, SpritePipe = class {
|
|
899
|
+
constructor(n) {
|
|
900
|
+
this._renderer = n;
|
|
895
901
|
}
|
|
896
|
-
|
|
897
|
-
|
|
902
|
+
addRenderable(n, j) {
|
|
903
|
+
this._renderer.renderPipes.batch.addToBatch({
|
|
904
|
+
renderable: n,
|
|
905
|
+
texture: n.texture,
|
|
906
|
+
transform: n.relativeGroupTransform,
|
|
907
|
+
bounds: n.bounds,
|
|
908
|
+
roundPixels: this._renderer._roundPixels | n._roundPixels
|
|
909
|
+
}, j);
|
|
898
910
|
}
|
|
899
|
-
|
|
900
|
-
|
|
911
|
+
destroy() {
|
|
912
|
+
this._renderer = null;
|
|
901
913
|
}
|
|
902
|
-
|
|
903
|
-
|
|
914
|
+
};
|
|
915
|
+
_SpritePipe = SpritePipe, _SpritePipe.desc = { name: "sprite" };
|
|
916
|
+
var _TextPipe, TextPipe = class {
|
|
917
|
+
constructor(n) {
|
|
918
|
+
this._renderer = n;
|
|
904
919
|
}
|
|
905
|
-
|
|
906
|
-
|
|
920
|
+
addRenderable(n, j) {
|
|
921
|
+
let M = this._getRuntimeText(n);
|
|
922
|
+
if (n._didTextUpdate) {
|
|
923
|
+
let j = n._autoResolution ? this._renderer.resolution : n.resolution;
|
|
924
|
+
(M.currentKey !== n.styleKey || n._resolution !== j) && this._updateRuntimeText(n), n._didTextUpdate = !1, updateBounds(M.bounds, n._anchor, M.texture);
|
|
925
|
+
}
|
|
926
|
+
this._renderer.renderPipes.batch.addToBatch(M, j);
|
|
907
927
|
}
|
|
908
|
-
|
|
909
|
-
this.
|
|
928
|
+
validateRenderable(n) {
|
|
929
|
+
let j = this._getRuntimeText(n), M = n.styleKey;
|
|
930
|
+
return j.currentKey === M ? n._didTextUpdate : !0;
|
|
910
931
|
}
|
|
911
|
-
|
|
912
|
-
|
|
932
|
+
initCacheText(n) {
|
|
933
|
+
let j = {
|
|
934
|
+
currentKey: "--",
|
|
935
|
+
transform: n.relativeGroupTransform,
|
|
936
|
+
bounds: n.bounds,
|
|
937
|
+
roundPixels: this._renderer._roundPixels | n._roundPixels,
|
|
938
|
+
renderable: n,
|
|
939
|
+
texture: null,
|
|
940
|
+
destroy: function() {
|
|
941
|
+
this.renderable = null, this.texture = null, this.bounds = null;
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
return n._runtimeData[this._renderer.uid] = j, j;
|
|
913
945
|
}
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
let F = P.a, I = P.b, L = P.c, R = P.d, z = P.tx, B = P.ty;
|
|
917
|
-
updateMinMax(F * n + L * j + z, I * n + R * j + B, this), updateMinMax(F * M + L * j + z, I * M + R * j + B, this), updateMinMax(F * n + L * N + z, I * n + R * N + B, this), updateMinMax(F * M + L * N + z, I * M + R * N + B, this);
|
|
946
|
+
_getRuntimeText(n) {
|
|
947
|
+
return n._runtimeData[this._renderer.uid] || this.initCacheText(n);
|
|
918
948
|
}
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
return n.x = this.minX, n.y = this.minY, n.width = this.maxX - this.minX, n.height = this.maxY - this.minY, n;
|
|
949
|
+
_updateRuntimeText(n) {
|
|
950
|
+
let j = this._getRuntimeText(n);
|
|
951
|
+
j.texture, n._resolution = n._autoResolution ? this._renderer.resolution : n.resolution, j.texture = this._renderer.text.getManagedTexture(n), j.currentKey = n.styleKey;
|
|
923
952
|
}
|
|
924
|
-
|
|
925
|
-
this.
|
|
953
|
+
destroy() {
|
|
954
|
+
this._renderer = null;
|
|
926
955
|
}
|
|
927
956
|
};
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
return j.clear(), M || (M = new Matrix()), _getLocalBounds(n, j, M, n, !0), j.isValid || j.set(0, 0, 0, 0), j;
|
|
933
|
-
}
|
|
934
|
-
function _getLocalBounds(n, j, M, N, P) {
|
|
935
|
-
let F = new Matrix();
|
|
936
|
-
if (P) F.copyFrom(M);
|
|
937
|
-
else {
|
|
938
|
-
if (!n.visible || !n.measurable) return;
|
|
939
|
-
n.updateLocalTransform(), F.appendFrom(n.localTransform, M);
|
|
957
|
+
_TextPipe = TextPipe, _TextPipe.desc = { name: "text" };
|
|
958
|
+
var ViewContainer = class extends Container {
|
|
959
|
+
constructor(...n) {
|
|
960
|
+
super(...n), this._runtimeData = Object.create(null), this._roundPixels = 0, this._bounds = new Bounds(0, 1, 0, 0);
|
|
940
961
|
}
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
else {
|
|
944
|
-
n.renderPipeId && (j.matrix = F, j.addBounds(n.bounds));
|
|
945
|
-
let M = n.children;
|
|
946
|
-
for (let n = 0; n < M.length; n++) _getLocalBounds(M[n], j, F, N, !1);
|
|
947
|
-
if (L) {
|
|
948
|
-
for (let M = 0; M < n.effects.length; ++M) {
|
|
949
|
-
var R, z;
|
|
950
|
-
(R = (z = n.effects[M]).addLocalBounds) == null || R.call(z, j, N);
|
|
951
|
-
}
|
|
952
|
-
I.addBounds(j, new Matrix());
|
|
953
|
-
}
|
|
962
|
+
get bounds() {
|
|
963
|
+
return this.updateBounds(), this._bounds;
|
|
954
964
|
}
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
}
|
|
961
|
-
addLocalBounds(n, j) {
|
|
962
|
-
let M = new Bounds();
|
|
963
|
-
this.mask.measurable = !0;
|
|
964
|
-
let N = getMatrixRelativeToParent(this.mask, j);
|
|
965
|
-
getLocalBounds(this.mask, M, N), this.mask.measurable = !1, n.addBoundsMask(M);
|
|
966
|
-
}
|
|
967
|
-
};
|
|
968
|
-
function getMatrixRelativeToParent(n, j, M) {
|
|
969
|
-
return M || (M = new Matrix()), n === j ? M : (M = getMatrixRelativeToParent(n.parent, j, M), n.updateLocalTransform(), Matrix.append(M, n.localTransform));
|
|
970
|
-
}
|
|
971
|
-
const effectMixin = {
|
|
972
|
-
effects: [],
|
|
973
|
-
_maskEffect: null,
|
|
974
|
-
addEffect(n) {
|
|
975
|
-
this.effects.push(n), this._updateIsSimple();
|
|
976
|
-
},
|
|
977
|
-
removeEffect(n) {
|
|
978
|
-
let j = this.effects.indexOf(n);
|
|
979
|
-
j === -1 && this.effects.splice(j, 1), this._updateIsSimple();
|
|
980
|
-
},
|
|
981
|
-
set mask(n) {
|
|
982
|
-
let j = this._maskEffect;
|
|
983
|
-
n !== (j == null ? void 0 : j.mask) && (j && (this.removeEffect(j), this._maskEffect = null), n != null && (this._maskEffect = new StencilMask(n), this.addEffect(this._maskEffect)));
|
|
984
|
-
},
|
|
985
|
-
get mask() {
|
|
986
|
-
var n;
|
|
987
|
-
return (n = this._maskEffect) == null ? void 0 : n.mask;
|
|
988
|
-
}
|
|
989
|
-
}, sortMixin = {
|
|
990
|
-
_zIndex: 0,
|
|
991
|
-
sortableChildren: !1,
|
|
992
|
-
sortDirty: !1
|
|
993
|
-
}, measureMixin = {
|
|
994
|
-
_localBoundsCacheData: null,
|
|
995
|
-
_localBounds: null,
|
|
996
|
-
_setWidth(n, j) {
|
|
997
|
-
let M = Math.sign(this.scale.x) || 1;
|
|
998
|
-
j === 0 ? this.scale.x = M : this.scale.x = n / j * M;
|
|
999
|
-
},
|
|
1000
|
-
_setHeight(n, j) {
|
|
1001
|
-
let M = Math.sign(this.scale.y) || 1;
|
|
1002
|
-
j === 0 ? this.scale.y = M : this.scale.y = n / j * M;
|
|
1003
|
-
},
|
|
1004
|
-
getLocalBounds() {
|
|
1005
|
-
return this._localBounds || (this._localBounds = new Bounds()), getLocalBounds(this, this._localBounds), this._localBounds;
|
|
1006
|
-
}
|
|
1007
|
-
}, childrenHelperMixin = { removeChildren(n = 0, j) {
|
|
1008
|
-
let M = j == null ? this.children.length : j, N = M - n, P = [];
|
|
1009
|
-
if (N > 0 && N <= M) {
|
|
1010
|
-
for (let j = M - 1; j >= n; --j) {
|
|
1011
|
-
let n = this.children[j];
|
|
1012
|
-
n && (P.push(n), n.parent = null);
|
|
1013
|
-
}
|
|
1014
|
-
removeItems(this.children, n, M);
|
|
1015
|
-
let j = this.renderGroup || this.parentRenderGroup;
|
|
1016
|
-
return j && j.removeChildren(P), P;
|
|
1017
|
-
} else if (N === 0 && this.children.length === 0) return P;
|
|
1018
|
-
throw Error("removeChildren: numeric values are outside the acceptable range.");
|
|
1019
|
-
} };
|
|
1020
|
-
function removeItems(n, j, M) {
|
|
1021
|
-
let N = n.length, P;
|
|
1022
|
-
if (j >= N || M === 0) return;
|
|
1023
|
-
M = j + M > N ? N - j : M;
|
|
1024
|
-
let F = N - M;
|
|
1025
|
-
for (P = j; P < F; ++P) n[P] = n[P + M];
|
|
1026
|
-
n.length = F;
|
|
1027
|
-
}
|
|
1028
|
-
const UPDATE_COLOR = 1, UPDATE_BLEND = 2, UPDATE_VISIBLE = 4, UPDATE_TRANSFORM = 8;
|
|
1029
|
-
var defaultSkew = new ObservablePoint(null), defaultOrigin = new ObservablePoint(null), defaultScale = new ObservablePoint(null, 1, 1), defaultPivot = new ObservablePoint(null), Container = class extends eventemitter3_default {
|
|
1030
|
-
constructor(n = {}) {
|
|
1031
|
-
super(), this.destroyed = !1, this.renderGroup = null, this.parentRenderGroup = null, this.parent = null, this.eventMode = "passive", this.hitArea = null, this._position = new ObservablePoint(this, 0, 0), this.includeInBuild = !0, this.didChange = !1, this.didViewUpdate = !1, this.isSimple = !0, this.measurable = !0, this.relativeRenderGroupDepth = 0, this._attrUpdateTick = 0, this._localTransformUpdateTick = 0, this._updateFlags = 15, this.localDisplayStatus = 7, this.globalDisplayStatus = 7, this.children = [], this.localTransform = new Matrix(), this.relativeGroupTransform = new Matrix(), this.groupTransform = this.relativeGroupTransform, this._rotation = 0, this._cx = 1, this._sx = 0, this._cy = 0, this._sy = 1, this._skew = defaultSkew, this._scale = defaultScale, this._origin = defaultOrigin, this._pivot = defaultPivot, this.localAlpha = 1, this.groupColor = 16777215, this.localColor = 16777215, this.groupAlpha = 1, this.groupColorAlpha = 4294967295, assignWithIgnore(this, n, {
|
|
1032
|
-
children: !0,
|
|
1033
|
-
parent: !0,
|
|
1034
|
-
effects: !0
|
|
1035
|
-
}), this.effects = [];
|
|
1036
|
-
}
|
|
1037
|
-
get renderable() {
|
|
1038
|
-
return !!(this.localDisplayStatus & 1);
|
|
1039
|
-
}
|
|
1040
|
-
set renderable(n) {
|
|
1041
|
-
let j = n ? 1 : 0;
|
|
1042
|
-
(this.localDisplayStatus & 1) !== j && (this._updateFlags |= 4, this.localDisplayStatus ^= 1, this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._onUpdate());
|
|
1043
|
-
}
|
|
1044
|
-
get visible() {
|
|
1045
|
-
return !!(this.localDisplayStatus & 2);
|
|
1046
|
-
}
|
|
1047
|
-
set visible(n) {
|
|
1048
|
-
let j = n ? 2 : 0;
|
|
1049
|
-
(this.localDisplayStatus & 2) !== j && (this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._updateFlags |= 4, this.localDisplayStatus ^= 2, this._onUpdate());
|
|
1050
|
-
}
|
|
1051
|
-
get isRenderGroup() {
|
|
1052
|
-
return !!this.renderGroup;
|
|
1053
|
-
}
|
|
1054
|
-
set isRenderGroup(n) {
|
|
1055
|
-
!!this.renderGroup !== n && (n ? this.enableRenderGroup() : this.disableRenderGroup());
|
|
1056
|
-
}
|
|
1057
|
-
get zIndex() {
|
|
1058
|
-
return this._zIndex;
|
|
1059
|
-
}
|
|
1060
|
-
set zIndex(n) {
|
|
1061
|
-
n !== this._zIndex && (this._zIndex = n, this.depthOfChildModified());
|
|
1062
|
-
}
|
|
1063
|
-
_updateIsSimple() {
|
|
1064
|
-
this.isSimple = !this.renderGroup && this.effects.length == 0;
|
|
1065
|
-
}
|
|
1066
|
-
sortChildren() {
|
|
1067
|
-
this.sortDirty && (this.sortDirty = !1, this.children.sort(sortChildren));
|
|
1068
|
-
}
|
|
1069
|
-
depthOfChildModified() {
|
|
1070
|
-
this.parent && (this.parent.sortableChildren = !0, this.parent.sortDirty = !0), this.parentRenderGroup;
|
|
1071
|
-
}
|
|
1072
|
-
enableRenderGroup() {
|
|
1073
|
-
this.renderGroup || (this.renderGroup = new RenderGroup(this), this.groupTransform = new Matrix(), this._updateIsSimple());
|
|
1074
|
-
}
|
|
1075
|
-
disableRenderGroup() {
|
|
1076
|
-
if (!this.renderGroup) return;
|
|
1077
|
-
let n = this.parentRenderGroup;
|
|
1078
|
-
n == null || n.removeChild(this), this.renderGroup = null, this.groupTransform = this.relativeGroupTransform, n == null || n.addChild(this), this._updateIsSimple();
|
|
1079
|
-
}
|
|
1080
|
-
collectRenderables(n, j) {
|
|
1081
|
-
this.globalDisplayStatus < 7 || !this.includeInBuild || (this.sortableChildren && this.sortChildren(), this.isSimple ? this.collectRenderableSimple(n, j) : this.renderGroup || this.collectRenderablesWithEffects(n, j));
|
|
1082
|
-
}
|
|
1083
|
-
collectRenderablesWithEffects(n, j) {
|
|
1084
|
-
for (let M = 0; M < this.effects.length; ++M) {
|
|
1085
|
-
let N = this.effects[M];
|
|
1086
|
-
n[N.pipe].push(N, j);
|
|
1087
|
-
}
|
|
1088
|
-
this.collectRenderableSimple(n, j);
|
|
1089
|
-
for (let M = 0; M < this.effects.length; ++M) {
|
|
1090
|
-
let N = this.effects[M];
|
|
1091
|
-
n[N.pipe].pop(N, j);
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
collectRenderableSimple(n, j) {
|
|
1095
|
-
let M = this.children;
|
|
1096
|
-
for (let N = 0; N < M.length; ++N) M[N].collectRenderables(n, j);
|
|
1097
|
-
}
|
|
1098
|
-
setFromMatrix(n) {
|
|
1099
|
-
n.decompose(this);
|
|
1100
|
-
}
|
|
1101
|
-
_updateSkew() {
|
|
1102
|
-
let n = this.rotation, j = this.skew;
|
|
1103
|
-
this._cx = Math.cos(n + j.y), this._sx = Math.sin(n + j.y), this._cy = -Math.sin(n - j.x), this._sy = Math.cos(n - j.x);
|
|
1104
|
-
}
|
|
1105
|
-
updateLocalTransform() {
|
|
1106
|
-
let n = this._attrUpdateTick;
|
|
1107
|
-
if (this._localTransformUpdateTick === n) return;
|
|
1108
|
-
this._localTransformUpdateTick = n, this._updateSkew();
|
|
1109
|
-
let j = this.position, M = this.localTransform, N = this._scale.x, P = this._scale.y, F = -this._origin.x, I = -this._origin.y, L = this._pivot.x, R = this._pivot.y;
|
|
1110
|
-
M.a = this._cx * N, M.b = this._sx * N, M.c = this._cy * P, M.d = this._sy * P, M.tx = j.x - (L * M.a + R * M.c) + (F * M.a + I * M.c) - F, M.ty = j.y - (L * M.b + R * M.d) + (F * M.b + I * M.d) - I;
|
|
1111
|
-
}
|
|
1112
|
-
get alpha() {
|
|
1113
|
-
return this.localAlpha;
|
|
1114
|
-
}
|
|
1115
|
-
set alpha(n) {
|
|
1116
|
-
n !== this.localAlpha && (this.localAlpha = n, this._updateFlags |= 1, this._onUpdate());
|
|
1117
|
-
}
|
|
1118
|
-
get root() {
|
|
1119
|
-
let n = this.parent, j = this.parent;
|
|
1120
|
-
for (; n;) n.parent || (j = n), n = n.parent;
|
|
1121
|
-
return j;
|
|
1122
|
-
}
|
|
1123
|
-
get worldTransform() {
|
|
1124
|
-
return this._worldTransform || (this._worldTransform = new Matrix()), this.renderGroup ? this._worldTransform.copyFrom(this.renderGroup.worldTransform) : this.parentRenderGroup && this._worldTransform.appendFrom(this.relativeGroupTransform, this.parentRenderGroup.worldTransform), this._worldTransform;
|
|
1125
|
-
}
|
|
1126
|
-
get x() {
|
|
1127
|
-
return this._position.x;
|
|
1128
|
-
}
|
|
1129
|
-
set x(n) {
|
|
1130
|
-
this._position.x = n;
|
|
1131
|
-
}
|
|
1132
|
-
get position() {
|
|
1133
|
-
return this._position;
|
|
1134
|
-
}
|
|
1135
|
-
set position(n) {
|
|
1136
|
-
this._position.copyFrom(n);
|
|
1137
|
-
}
|
|
1138
|
-
get y() {
|
|
1139
|
-
return this._position.y;
|
|
1140
|
-
}
|
|
1141
|
-
set y(n) {
|
|
1142
|
-
this._position.y = n;
|
|
1143
|
-
}
|
|
1144
|
-
get rotation() {
|
|
1145
|
-
return this._rotation;
|
|
1146
|
-
}
|
|
1147
|
-
set rotation(n) {
|
|
1148
|
-
this._rotation !== n && (this._rotation = n, this._onUpdate(this._skew));
|
|
1149
|
-
}
|
|
1150
|
-
get angle() {
|
|
1151
|
-
return this.rotation * RAD_TO_DEG;
|
|
1152
|
-
}
|
|
1153
|
-
set angle(n) {
|
|
1154
|
-
this.rotation = n * DEG_TO_RAD;
|
|
1155
|
-
}
|
|
1156
|
-
get skew() {
|
|
1157
|
-
return this._skew === defaultSkew && (this._skew = new ObservablePoint(this, 0, 0)), this._skew;
|
|
1158
|
-
}
|
|
1159
|
-
set skew(n) {
|
|
1160
|
-
this._skew === defaultSkew && (this._skew = new ObservablePoint(this, 0, 0)), this._skew.copyFrom(n);
|
|
1161
|
-
}
|
|
1162
|
-
get scale() {
|
|
1163
|
-
return this._scale === defaultScale && (this._scale = new ObservablePoint(this, 1, 1)), this._scale;
|
|
1164
|
-
}
|
|
1165
|
-
set scale(n) {
|
|
1166
|
-
this._scale === defaultScale && (this._scale = new ObservablePoint(this, 1, 1)), this._scale.copyFrom(n);
|
|
1167
|
-
}
|
|
1168
|
-
get pivot() {
|
|
1169
|
-
return this._pivot === defaultPivot && (this._pivot = new ObservablePoint(this, 0, 0)), this._pivot;
|
|
1170
|
-
}
|
|
1171
|
-
set pivot(n) {
|
|
1172
|
-
this._pivot === defaultPivot && (this._pivot = new ObservablePoint(this, 0, 0)), this._pivot.copyFrom(n);
|
|
1173
|
-
}
|
|
1174
|
-
get origin() {
|
|
1175
|
-
return this._origin === defaultOrigin && (this._origin = new ObservablePoint(this, 0, 0)), this._origin;
|
|
1176
|
-
}
|
|
1177
|
-
set origin(n) {
|
|
1178
|
-
this._origin === defaultOrigin && (this._origin = new ObservablePoint(this, 0, 0)), this._origin.copyFrom(n);
|
|
1179
|
-
}
|
|
1180
|
-
get width() {
|
|
1181
|
-
return Math.abs(this.scale.x * this.getLocalBounds().width);
|
|
1182
|
-
}
|
|
1183
|
-
set width(n) {}
|
|
1184
|
-
get height() {
|
|
1185
|
-
return Math.abs(this.scale.y * this.getLocalBounds().height);
|
|
1186
|
-
}
|
|
1187
|
-
set height(n) {}
|
|
1188
|
-
addChild(...n) {
|
|
1189
|
-
if (n.length > 1) {
|
|
1190
|
-
for (let j = 0; j < n.length; ++j) this.addChild(n[j]);
|
|
1191
|
-
return n[0];
|
|
1192
|
-
}
|
|
1193
|
-
let j = n[0], M = this.renderGroup || this.parentRenderGroup;
|
|
1194
|
-
return j.parent === this ? (this.children.splice(this.children.indexOf(j), 1), this.children.push(j), M && (M.structureDidChange = !0), j) : (this.sortableChildren && (this.sortDirty = !0), j.parent && j.parent.removeChild(j), this.children.push(j), this.sortableChildren && (this.sortDirty = !0), j.parent = this, j.didChange = !0, j._updateFlags = 7, M && M.addChild(j), j._zIndex != 0 && j.depthOfChildModified(), j);
|
|
1195
|
-
}
|
|
1196
|
-
removeChild(...n) {
|
|
1197
|
-
if (n.length > 1) {
|
|
1198
|
-
for (let j = 0; j < n.length; ++j) this.removeChild(n[j]);
|
|
1199
|
-
return n[0];
|
|
1200
|
-
}
|
|
1201
|
-
let j = n[0];
|
|
1202
|
-
if (!j) return j;
|
|
1203
|
-
let M = this.children.indexOf(j);
|
|
1204
|
-
return M > -1 && (this.children.splice(M, 1), j.parent = null), j;
|
|
1205
|
-
}
|
|
1206
|
-
_onUpdate(n) {
|
|
1207
|
-
n && n === this._skew && this._updateSkew(), this._attrUpdateTick++, !this.didChange && (this.didChange = !0, this.parentRenderGroup && this.parentRenderGroup.onChildUpdate(this));
|
|
1208
|
-
}
|
|
1209
|
-
toGlobal(n, j) {
|
|
1210
|
-
return this.getGlobalTransform(j).apply(n);
|
|
1211
|
-
}
|
|
1212
|
-
toLocal(n, j, M) {
|
|
1213
|
-
let N;
|
|
1214
|
-
return j && (N = j.toGlobal(n)), N = this.getGlobalTransform(M).applyInverse(n), N;
|
|
1215
|
-
}
|
|
1216
|
-
getGlobalTransform(n = !1) {
|
|
1217
|
-
if (n) return this.worldTransform.clone();
|
|
1218
|
-
this.updateLocalTransform();
|
|
1219
|
-
let j = new Matrix(), M = updateTransformBackwards(this, j);
|
|
1220
|
-
return j.appendFrom(this.localTransform, M), j;
|
|
1221
|
-
}
|
|
1222
|
-
getGlobalPosition(n = !1) {
|
|
1223
|
-
return this.parent ? this.parent.toGlobal(this._position, n) : this._position.toVector2();
|
|
1224
|
-
}
|
|
1225
|
-
destroy(n = !1) {
|
|
1226
|
-
var j, M;
|
|
1227
|
-
if (this.destroyed) return;
|
|
1228
|
-
this.destroyed = !0;
|
|
1229
|
-
let N;
|
|
1230
|
-
if (this.children.length && (N = this.removeChildren(0, this.children.length)), (j = this.parent) == null || j.removeChild(this), this.parent = null, this._maskEffect = null, this.effects = null, this._position = null, this._scale = null, this._pivot = null, this._origin = null, this._skew = null, (typeof n == "boolean" ? n : n != null && n.children) && N) for (let j = 0; j < N.length; ++j) N[j].destroy(n);
|
|
1231
|
-
(M = this.renderGroup) == null || M.destroy(), this.renderGroup = null;
|
|
1232
|
-
}
|
|
1233
|
-
};
|
|
1234
|
-
function updateTransformBackwards(n, j) {
|
|
1235
|
-
let M = n.parent;
|
|
1236
|
-
if (M) {
|
|
1237
|
-
updateTransformBackwards(M, j), M.updateLocalTransform();
|
|
1238
|
-
let n = Matrix.append(j, M.localTransform);
|
|
1239
|
-
j.copyFrom(n);
|
|
1240
|
-
}
|
|
1241
|
-
return j;
|
|
1242
|
-
}
|
|
1243
|
-
function sortChildren(n, j) {
|
|
1244
|
-
return n._zIndex - j._zIndex;
|
|
1245
|
-
}
|
|
1246
|
-
applyMixins(Container, sortMixin, effectMixin, measureMixin, childrenHelperMixin);
|
|
1247
|
-
var UPDATE_BLEND_COLOR_VISIBLE = 7;
|
|
1248
|
-
function updateRenderGroupTransform(n, j = !1) {
|
|
1249
|
-
let M = n.root;
|
|
1250
|
-
n.worldTransform.copyFrom(M.localTransform);
|
|
1251
|
-
let N = n.childrenToUpdate;
|
|
1252
|
-
for (let j in N) {
|
|
1253
|
-
let M = Number(j), P = N[M], F = P.list, I = P.index;
|
|
1254
|
-
for (let j = 0; j < I; ++j) {
|
|
1255
|
-
let N = F[j];
|
|
1256
|
-
N.parentRenderGroup === n && N.relativeRenderGroupDepth === M && updateTransform(N, 0);
|
|
1257
|
-
}
|
|
1258
|
-
clearList(F, I), P.index = 0;
|
|
1259
|
-
}
|
|
1260
|
-
if (j) for (let M = 0; M < n.renderGroupChildren.length; ++M) updateRenderGroupTransform(n.renderGroupChildren[M], j);
|
|
1261
|
-
}
|
|
1262
|
-
function updateTransform(n, j) {
|
|
1263
|
-
n.didChange = !1;
|
|
1264
|
-
let M = n.parent, N = n.localTransform;
|
|
1265
|
-
n.updateLocalTransform(), M && (j |= n._updateFlags, n.relativeGroupTransform.appendFrom(N, M.relativeGroupTransform), j & UPDATE_BLEND_COLOR_VISIBLE && updateBlendColorVisible(n, M, j));
|
|
1266
|
-
let P = n.children;
|
|
1267
|
-
for (let n = 0; n < P.length; n++) updateTransform(P[n], j);
|
|
1268
|
-
}
|
|
1269
|
-
function updateBlendColorVisible(n, j, M) {
|
|
1270
|
-
if (M & 1) {
|
|
1271
|
-
n.groupColor = j.groupColor;
|
|
1272
|
-
let M = n.localAlpha * j.groupAlpha;
|
|
1273
|
-
M = M < 0 ? 0 : M > 1 ? 1 : M, n.groupAlpha = M, n.groupColorAlpha = n.groupColor + ((M * 255 | 0) << 24);
|
|
1274
|
-
}
|
|
1275
|
-
M & 4 && (n.globalDisplayStatus = n.localDisplayStatus & j.globalDisplayStatus), n._updateFlags = 0;
|
|
1276
|
-
}
|
|
1277
|
-
function validateRenderables(n, j) {
|
|
1278
|
-
let { list: M, index: N } = n.childrenRenderablesToUpdate, P = !1;
|
|
1279
|
-
for (let n = 0; n < N; ++n) {
|
|
1280
|
-
let N = M[n];
|
|
1281
|
-
if (P = j[N.renderPipeId].validateRenderable(N), P) break;
|
|
1282
|
-
}
|
|
1283
|
-
return n.structureDidChange = P, P;
|
|
1284
|
-
}
|
|
1285
|
-
var _RenderGroupSystem, RenderGroupSystem = class {
|
|
1286
|
-
constructor(n) {
|
|
1287
|
-
this.renderer = n;
|
|
1288
|
-
}
|
|
1289
|
-
_updateRenderGroup(n) {
|
|
1290
|
-
let j = this.renderer, M = j.renderPipes;
|
|
1291
|
-
n.instructionSet.renderPipes = M, n.structureDidChange ? clearList(n.childrenRenderablesToUpdate.list, 0) : validateRenderables(n, M), updateRenderGroupTransform(n), n.structureDidChange && (n.structureDidChange = !1, this._buildInstructions(n, j)), n.childrenRenderablesToUpdate.index = 0;
|
|
1292
|
-
}
|
|
1293
|
-
render({ container: n, transform: j }) {
|
|
1294
|
-
let M = this.renderer;
|
|
1295
|
-
j && n.renderGroup.localTransform.copyFrom(j), M.canvasContext.globalTransform = j ? n.renderGroup.localTransform : n.renderGroup.worldTransform, this._updateRenderGroup(n.renderGroup), executeInstructions(n.renderGroup, M.renderPipes);
|
|
1296
|
-
}
|
|
1297
|
-
_buildInstructions(n, j) {
|
|
1298
|
-
let M = j.renderPipes, N = n.root;
|
|
1299
|
-
n.instructionSet.reset(), N.sortableChildren && N.sortChildren(), M.batch.buildStart(), N.collectRenderablesWithEffects(M, n.instructionSet), M.batch.buildEnd(n.instructionSet);
|
|
1300
|
-
}
|
|
1301
|
-
};
|
|
1302
|
-
_RenderGroupSystem = RenderGroupSystem, _RenderGroupSystem.desc = { name: "renderGroup" };
|
|
1303
|
-
function executeInstructions(n, j) {
|
|
1304
|
-
let { instructionSet: M } = n, N = M.instructions;
|
|
1305
|
-
for (let n = 0; n < M.instructionSize; n++) {
|
|
1306
|
-
let M = N[n];
|
|
1307
|
-
j[M.renderPipeId].execute(M);
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
var _SpritePipe, SpritePipe = class {
|
|
1311
|
-
constructor(n) {
|
|
1312
|
-
this._renderer = n;
|
|
1313
|
-
}
|
|
1314
|
-
addRenderable(n, j) {
|
|
1315
|
-
this._renderer.renderPipes.batch.addToBatch({
|
|
1316
|
-
renderable: n,
|
|
1317
|
-
texture: n.texture,
|
|
1318
|
-
transform: n.relativeGroupTransform,
|
|
1319
|
-
bounds: n.bounds,
|
|
1320
|
-
roundPixels: this._renderer._roundPixels | n._roundPixels
|
|
1321
|
-
}, j);
|
|
1322
|
-
}
|
|
1323
|
-
destroy() {
|
|
1324
|
-
this._renderer = null;
|
|
1325
|
-
}
|
|
1326
|
-
};
|
|
1327
|
-
_SpritePipe = SpritePipe, _SpritePipe.desc = { name: "sprite" };
|
|
1328
|
-
var _TextPipe, TextPipe = class {
|
|
1329
|
-
constructor(n) {
|
|
1330
|
-
this._renderer = n;
|
|
1331
|
-
}
|
|
1332
|
-
addRenderable(n, j) {
|
|
1333
|
-
let M = this._getRuntimeText(n);
|
|
1334
|
-
if (n._didTextUpdate) {
|
|
1335
|
-
let j = n._autoResolution ? this._renderer.resolution : n.resolution;
|
|
1336
|
-
(M.currentKey !== n.styleKey || n._resolution !== j) && this._updateRuntimeText(n), n._didTextUpdate = !1, updateBounds(M.bounds, n._anchor, M.texture);
|
|
1337
|
-
}
|
|
1338
|
-
this._renderer.renderPipes.batch.addToBatch(M, j);
|
|
1339
|
-
}
|
|
1340
|
-
validateRenderable(n) {
|
|
1341
|
-
let j = this._getRuntimeText(n), M = n.styleKey;
|
|
1342
|
-
return j.currentKey === M ? n._didTextUpdate : !0;
|
|
1343
|
-
}
|
|
1344
|
-
initCacheText(n) {
|
|
1345
|
-
let j = {
|
|
1346
|
-
currentKey: "--",
|
|
1347
|
-
transform: n.relativeGroupTransform,
|
|
1348
|
-
bounds: n.bounds,
|
|
1349
|
-
roundPixels: this._renderer._roundPixels | n._roundPixels,
|
|
1350
|
-
renderable: n,
|
|
1351
|
-
texture: null,
|
|
1352
|
-
destroy: function() {
|
|
1353
|
-
this.renderable = null, this.texture = null, this.bounds = null;
|
|
1354
|
-
}
|
|
1355
|
-
};
|
|
1356
|
-
return n._runtimeData[this._renderer.uid] = j, j;
|
|
1357
|
-
}
|
|
1358
|
-
_getRuntimeText(n) {
|
|
1359
|
-
return n._runtimeData[this._renderer.uid] || this.initCacheText(n);
|
|
1360
|
-
}
|
|
1361
|
-
_updateRuntimeText(n) {
|
|
1362
|
-
let j = this._getRuntimeText(n);
|
|
1363
|
-
j.texture, n._resolution = n._autoResolution ? this._renderer.resolution : n.resolution, j.texture = this._renderer.text.getManagedTexture(n), j.currentKey = n.styleKey;
|
|
1364
|
-
}
|
|
1365
|
-
destroy() {
|
|
1366
|
-
this._renderer = null;
|
|
1367
|
-
}
|
|
1368
|
-
};
|
|
1369
|
-
_TextPipe = TextPipe, _TextPipe.desc = { name: "text" };
|
|
1370
|
-
var ViewContainer = class extends Container {
|
|
1371
|
-
constructor(...n) {
|
|
1372
|
-
super(...n), this._runtimeData = Object.create(null), this._roundPixels = 0, this._bounds = new Bounds(0, 1, 0, 0);
|
|
1373
|
-
}
|
|
1374
|
-
get bounds() {
|
|
1375
|
-
return this.updateBounds(), this._bounds;
|
|
1376
|
-
}
|
|
1377
|
-
onViewUpdate() {
|
|
1378
|
-
if (this.didViewUpdate) return;
|
|
1379
|
-
this.didViewUpdate = !0;
|
|
1380
|
-
let n = this.renderGroup || this.parentRenderGroup;
|
|
1381
|
-
n && n.onChildViewUpdate(this);
|
|
965
|
+
onViewUpdate() {
|
|
966
|
+
if (this.didViewUpdate) return;
|
|
967
|
+
this.didViewUpdate = !0;
|
|
968
|
+
let n = this.renderGroup || this.parentRenderGroup;
|
|
969
|
+
n && n.onChildViewUpdate(this);
|
|
1382
970
|
}
|
|
1383
971
|
collectRenderableSimple(n, j) {
|
|
1384
972
|
let M = n[this.renderPipeId];
|
|
@@ -1484,380 +1072,736 @@ function recursive(n, j, M, N, P, F, I, L, R, z, B) {
|
|
|
1484
1072
|
return;
|
|
1485
1073
|
}
|
|
1486
1074
|
}
|
|
1487
|
-
} else if (B = Q - (n + I) / 2, H = $ - (j + L) / 2, B * B + H * H <= z) {
|
|
1488
|
-
R.push(Q, $);
|
|
1489
|
-
return;
|
|
1075
|
+
} else if (B = Q - (n + I) / 2, H = $ - (j + L) / 2, B * B + H * H <= z) {
|
|
1076
|
+
R.push(Q, $);
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
recursive(n, j, H, U, J, Y, Q, $, R, z, B + 1), recursive(Q, $, X, Z, K, q, I, L, R, z, B + 1);
|
|
1081
|
+
}
|
|
1082
|
+
var ShapePath = class {
|
|
1083
|
+
constructor(n) {
|
|
1084
|
+
this.shapePrimitives = [], this._bounds = new Bounds(), this._graphicsPath = n;
|
|
1085
|
+
}
|
|
1086
|
+
_ensurePoly(n = !0) {
|
|
1087
|
+
this._currentPoly || (this._currentPoly = new Polygon(), n && this._currentPoly.points.push(0, 0));
|
|
1088
|
+
}
|
|
1089
|
+
lineTo(n, j) {
|
|
1090
|
+
this._ensurePoly();
|
|
1091
|
+
let M = this._currentPoly.points, N = M[M.length - 2], P = M[M.length - 1];
|
|
1092
|
+
return (N !== n || P !== j) && M.push(n, j), this;
|
|
1093
|
+
}
|
|
1094
|
+
rect(n, j, M, N) {
|
|
1095
|
+
return this.drawShape(new Rectangle(n, j, M, N)), this;
|
|
1096
|
+
}
|
|
1097
|
+
drawShape(n) {
|
|
1098
|
+
return this.endPloy(), this.shapePrimitives.push({ shape: n }), this;
|
|
1099
|
+
}
|
|
1100
|
+
moveTo(n, j) {
|
|
1101
|
+
return this.startPoly(n, j), this;
|
|
1102
|
+
}
|
|
1103
|
+
bezierCurveTo(n, j, M, N, P, F, I) {
|
|
1104
|
+
this._ensurePoly();
|
|
1105
|
+
let L = this._currentPoly.points;
|
|
1106
|
+
return buildAdaptiveBezier(L, this._currentPoly.lastX, this._currentPoly.lastY, n, j, M, N, P, F, I), this;
|
|
1107
|
+
}
|
|
1108
|
+
startPoly(n, j) {
|
|
1109
|
+
return this._currentPoly && this.endPloy(), this._currentPoly = new Polygon(), this._currentPoly.points.push(n, j), this;
|
|
1110
|
+
}
|
|
1111
|
+
endPloy(n = !1) {
|
|
1112
|
+
let j = this._currentPoly;
|
|
1113
|
+
j && j.points.length > 2 && (j.closePath = n, this.shapePrimitives.push({ shape: j })), this._currentPoly = null;
|
|
1114
|
+
}
|
|
1115
|
+
closePath() {
|
|
1116
|
+
return this.endPloy(!0), this;
|
|
1117
|
+
}
|
|
1118
|
+
buildPath() {
|
|
1119
|
+
let n = this._graphicsPath;
|
|
1120
|
+
for (let j = 0; j < n.instructions.length; ++j) {
|
|
1121
|
+
let M = n.instructions[j];
|
|
1122
|
+
this[M.action](...M.data);
|
|
1123
|
+
}
|
|
1124
|
+
return this;
|
|
1125
|
+
}
|
|
1126
|
+
get bounds() {
|
|
1127
|
+
let n = this._bounds;
|
|
1128
|
+
n.clear();
|
|
1129
|
+
let j = this.shapePrimitives;
|
|
1130
|
+
for (let M = 0; M < j.length; ++M) {
|
|
1131
|
+
let N = j[M].shape.getBounds();
|
|
1132
|
+
n.addRect(N);
|
|
1133
|
+
}
|
|
1134
|
+
return n;
|
|
1135
|
+
}
|
|
1136
|
+
}, GraphicsPath = class n {
|
|
1137
|
+
constructor() {
|
|
1138
|
+
this.instructions = [], this._dirty = !0;
|
|
1139
|
+
}
|
|
1140
|
+
rect(n, j, M, N) {
|
|
1141
|
+
return this.instructions.push({
|
|
1142
|
+
action: "rect",
|
|
1143
|
+
data: [
|
|
1144
|
+
n,
|
|
1145
|
+
j,
|
|
1146
|
+
M,
|
|
1147
|
+
N
|
|
1148
|
+
]
|
|
1149
|
+
}), this._dirty = !0, this;
|
|
1150
|
+
}
|
|
1151
|
+
lineTo(...n) {
|
|
1152
|
+
return this.instructions.push({
|
|
1153
|
+
action: "lineTo",
|
|
1154
|
+
data: n
|
|
1155
|
+
}), this._dirty = !0, this;
|
|
1156
|
+
}
|
|
1157
|
+
bezierCurveTo(...n) {
|
|
1158
|
+
return this.instructions.push({
|
|
1159
|
+
action: "bezierCurveTo",
|
|
1160
|
+
data: n
|
|
1161
|
+
}), this;
|
|
1162
|
+
}
|
|
1163
|
+
moveTo(...n) {
|
|
1164
|
+
return this.instructions.push({
|
|
1165
|
+
action: "moveTo",
|
|
1166
|
+
data: n
|
|
1167
|
+
}), this;
|
|
1168
|
+
}
|
|
1169
|
+
closePath() {
|
|
1170
|
+
return this.instructions.push({
|
|
1171
|
+
action: "closePath",
|
|
1172
|
+
data: []
|
|
1173
|
+
}), this._dirty = !0, this;
|
|
1174
|
+
}
|
|
1175
|
+
get shapePath() {
|
|
1176
|
+
return this._shapePath || (this._shapePath = new ShapePath(this)), this._dirty && (this._dirty = !1, this._shapePath.buildPath()), this._shapePath;
|
|
1177
|
+
}
|
|
1178
|
+
get bounds() {
|
|
1179
|
+
return this.shapePath.bounds;
|
|
1180
|
+
}
|
|
1181
|
+
getLastPoint() {
|
|
1182
|
+
let n = this.instructions.length - 1, j = this.instructions[n];
|
|
1183
|
+
if (!j) return {
|
|
1184
|
+
x: 0,
|
|
1185
|
+
y: 0
|
|
1186
|
+
};
|
|
1187
|
+
switch (j.action) {
|
|
1188
|
+
case "moveTo":
|
|
1189
|
+
case "lineTo": return {
|
|
1190
|
+
x: j.data[0],
|
|
1191
|
+
y: j.data[1]
|
|
1192
|
+
};
|
|
1193
|
+
}
|
|
1194
|
+
return {
|
|
1195
|
+
x: 0,
|
|
1196
|
+
y: 0
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
clear() {
|
|
1200
|
+
this.instructions.length = 0, this._dirty = !0;
|
|
1201
|
+
}
|
|
1202
|
+
clone() {
|
|
1203
|
+
let j = new n();
|
|
1204
|
+
return j.instructions = this.instructions.slice(), j;
|
|
1205
|
+
}
|
|
1206
|
+
}, _GraphicsContext, GraphicsContext = class n {
|
|
1207
|
+
constructor() {
|
|
1208
|
+
this._activePath = new GraphicsPath(), this._bounds = new Bounds(), this.instructions = [];
|
|
1209
|
+
}
|
|
1210
|
+
setStrokeStyle(j) {
|
|
1211
|
+
this._strokeStyle = toStrokeStyle(j, n.defaultStrokeStyle);
|
|
1212
|
+
}
|
|
1213
|
+
moveTo(n, j) {
|
|
1214
|
+
return this._activePath.moveTo(n, j), this;
|
|
1215
|
+
}
|
|
1216
|
+
lineTo(n, j) {
|
|
1217
|
+
return this._activePath.lineTo(n, j), this;
|
|
1218
|
+
}
|
|
1219
|
+
bezierCurveTo(n, j, M, N, P, F, I) {
|
|
1220
|
+
return this._activePath.bezierCurveTo(n, j, M, N, P, F, I), this;
|
|
1221
|
+
}
|
|
1222
|
+
rect(n, j, M, N) {
|
|
1223
|
+
return this._activePath.rect(n, j, M, N), this;
|
|
1224
|
+
}
|
|
1225
|
+
beginPath() {
|
|
1226
|
+
return this._activePath = new GraphicsPath(), this;
|
|
1227
|
+
}
|
|
1228
|
+
closePath() {
|
|
1229
|
+
return this._activePath.closePath(), this;
|
|
1230
|
+
}
|
|
1231
|
+
fill(j) {
|
|
1232
|
+
let M = {
|
|
1233
|
+
...n.defaultStrokeStyle,
|
|
1234
|
+
color: j
|
|
1235
|
+
};
|
|
1236
|
+
return this.instructions.push({
|
|
1237
|
+
action: "fill",
|
|
1238
|
+
data: {
|
|
1239
|
+
style: M,
|
|
1240
|
+
path: this._activePath.clone()
|
|
1241
|
+
}
|
|
1242
|
+
}), this;
|
|
1243
|
+
}
|
|
1244
|
+
stroke() {
|
|
1245
|
+
this.instructions.push({
|
|
1246
|
+
action: "stroke",
|
|
1247
|
+
data: {
|
|
1248
|
+
style: this._strokeStyle,
|
|
1249
|
+
path: this._activePath.clone()
|
|
1250
|
+
}
|
|
1251
|
+
}), this._initNextPathLocation();
|
|
1252
|
+
}
|
|
1253
|
+
_initNextPathLocation() {
|
|
1254
|
+
let { x: n, y: j } = this._activePath.getLastPoint();
|
|
1255
|
+
this._activePath.clear(), this._activePath.moveTo(n, j);
|
|
1256
|
+
}
|
|
1257
|
+
get bounds() {
|
|
1258
|
+
let n = this._bounds;
|
|
1259
|
+
n.clear();
|
|
1260
|
+
for (let j = 0; j < this.instructions.length; ++j) {
|
|
1261
|
+
let M = this.instructions[j], N = M.action;
|
|
1262
|
+
if (N === "fill") {
|
|
1263
|
+
let j = M.data;
|
|
1264
|
+
n.addBounds(j.path.bounds);
|
|
1265
|
+
} else if (N === "stroke") {
|
|
1266
|
+
let j = M.data, N = j.style.alignment, P = j.style.width * (1 - N);
|
|
1267
|
+
j.style.join;
|
|
1268
|
+
let F = j.path.bounds;
|
|
1269
|
+
n.addFrame(F.minX - P, F.minY - P, F.maxX + P, F.maxY + P);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
return n;
|
|
1273
|
+
}
|
|
1274
|
+
clone() {
|
|
1275
|
+
let j = new n();
|
|
1276
|
+
return j.instructions = this.instructions.slice(), j._activePath = this._activePath.clone(), j._bounds = this._bounds.clone(), j._strokeStyle = { ...this._strokeStyle }, j;
|
|
1277
|
+
}
|
|
1278
|
+
};
|
|
1279
|
+
_GraphicsContext = GraphicsContext, _GraphicsContext.defaultStrokeStyle = {
|
|
1280
|
+
width: 1,
|
|
1281
|
+
color: "#ffffff",
|
|
1282
|
+
alignment: .5,
|
|
1283
|
+
miterLimit: 10,
|
|
1284
|
+
cap: "butt",
|
|
1285
|
+
join: "miter",
|
|
1286
|
+
pixelLine: !1,
|
|
1287
|
+
alpha: 1
|
|
1288
|
+
};
|
|
1289
|
+
function toStrokeStyle(n, j) {
|
|
1290
|
+
return {
|
|
1291
|
+
...j,
|
|
1292
|
+
...n
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
var Graphics = class extends ViewContainer {
|
|
1296
|
+
constructor(n) {
|
|
1297
|
+
super(), this.renderPipeId = "graphics", n instanceof GraphicsContext ? this.context = n : this.context = new GraphicsContext();
|
|
1298
|
+
}
|
|
1299
|
+
setStrokeStyle(...n) {
|
|
1300
|
+
return this._callContextMethod("setStrokeStyle", n);
|
|
1301
|
+
}
|
|
1302
|
+
rect(...n) {
|
|
1303
|
+
return this._callContextMethod("rect", n);
|
|
1304
|
+
}
|
|
1305
|
+
bezierCurveTo(...n) {
|
|
1306
|
+
return this._callContextMethod("bezierCurveTo", n);
|
|
1307
|
+
}
|
|
1308
|
+
lineTo(...n) {
|
|
1309
|
+
return this._callContextMethod("lineTo", n);
|
|
1310
|
+
}
|
|
1311
|
+
moveTo(...n) {
|
|
1312
|
+
return this._callContextMethod("moveTo", n);
|
|
1313
|
+
}
|
|
1314
|
+
stroke(...n) {
|
|
1315
|
+
return this._callContextMethod("stroke", n);
|
|
1316
|
+
}
|
|
1317
|
+
beginPath() {
|
|
1318
|
+
return this._callContextMethod("beginPath", []);
|
|
1319
|
+
}
|
|
1320
|
+
closePath() {
|
|
1321
|
+
return this._callContextMethod("closePath", []);
|
|
1322
|
+
}
|
|
1323
|
+
fill(n) {
|
|
1324
|
+
return this._callContextMethod("fill", [n]);
|
|
1325
|
+
}
|
|
1326
|
+
_callContextMethod(n, j) {
|
|
1327
|
+
return this.context[n](...j), this;
|
|
1328
|
+
}
|
|
1329
|
+
updateBounds() {}
|
|
1330
|
+
get bounds() {
|
|
1331
|
+
return this.context.bounds;
|
|
1332
|
+
}
|
|
1333
|
+
}, _GraphicsPipe, GraphicsPipe = class {
|
|
1334
|
+
constructor(n) {
|
|
1335
|
+
this._renderer = n;
|
|
1336
|
+
}
|
|
1337
|
+
addRenderable(n, j) {
|
|
1338
|
+
this._renderer.renderPipes.batch.break(j), j.add(n);
|
|
1339
|
+
}
|
|
1340
|
+
execute(n) {
|
|
1341
|
+
let j = this._renderer, M = j.canvasContext, N = M.activeConext, P = j.roundPixels, F = (n.groupColorAlpha >>> 24 & 255) / 255;
|
|
1342
|
+
if (!(F <= 0)) {
|
|
1343
|
+
N.save(), M.setContextTransform(n.relativeGroupTransform, P);
|
|
1344
|
+
for (let j = 0; j < n.context.instructions.length; ++j) {
|
|
1345
|
+
let M = n.context.instructions[j], P = M.data.style, I = P.alpha * F;
|
|
1346
|
+
if (I <= 0) continue;
|
|
1347
|
+
N.globalAlpha = I;
|
|
1348
|
+
let L = M.action === "stroke";
|
|
1349
|
+
if (L) {
|
|
1350
|
+
let n = P.color;
|
|
1351
|
+
N.lineWidth = P.width, N.lineCap = P.cap, N.lineJoin = P.join, N.miterLimit = P.miterLimit, N.strokeStyle = n;
|
|
1352
|
+
} else N.fillStyle = M.data.style.color;
|
|
1353
|
+
let R = M.data.path.shapePath.shapePrimitives;
|
|
1354
|
+
for (let n = 0; n < R.length; ++n) {
|
|
1355
|
+
let j = R[n];
|
|
1356
|
+
j.shape && (N.beginPath(), buildShapePath(N, j.shape), L ? N.stroke() : N.fill());
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
N.restore();
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
destroy() {
|
|
1363
|
+
this._renderer = null;
|
|
1364
|
+
}
|
|
1365
|
+
};
|
|
1366
|
+
_GraphicsPipe = GraphicsPipe, _GraphicsPipe.desc = { name: "graphics" };
|
|
1367
|
+
function buildShapePath(n, j) {
|
|
1368
|
+
switch (j.type) {
|
|
1369
|
+
case "rectangle": {
|
|
1370
|
+
let M = j;
|
|
1371
|
+
n.rect(M.x, M.y, M.width, M.height);
|
|
1372
|
+
break;
|
|
1373
|
+
}
|
|
1374
|
+
case "polygon": {
|
|
1375
|
+
let M = j, N = M.points;
|
|
1376
|
+
if (!N.length) return;
|
|
1377
|
+
n.moveTo(N[0], N[1]);
|
|
1378
|
+
for (let j = 2; j < N.length; j += 2) n.lineTo(N[j], N[j + 1]);
|
|
1379
|
+
M.closePath && n.closePath();
|
|
1380
|
+
break;
|
|
1490
1381
|
}
|
|
1491
1382
|
}
|
|
1492
|
-
recursive(n, j, H, U, J, Y, Q, $, R, z, B + 1), recursive(Q, $, X, Z, K, q, I, L, R, z, B + 1);
|
|
1493
1383
|
}
|
|
1494
|
-
var
|
|
1384
|
+
var _BatchPipe, Batch = class {
|
|
1385
|
+
constructor() {
|
|
1386
|
+
this.renderPipeId = "batch", this.elements = [];
|
|
1387
|
+
}
|
|
1388
|
+
}, BatchPipe = class {
|
|
1495
1389
|
constructor(n) {
|
|
1496
|
-
this.
|
|
1390
|
+
this._renderer = n;
|
|
1497
1391
|
}
|
|
1498
|
-
|
|
1499
|
-
|
|
1392
|
+
get batch() {
|
|
1393
|
+
return this._activeBatch;
|
|
1500
1394
|
}
|
|
1501
|
-
|
|
1502
|
-
this.
|
|
1503
|
-
let M = this._currentPoly.points, N = M[M.length - 2], P = M[M.length - 1];
|
|
1504
|
-
return (N !== n || P !== j) && M.push(n, j), this;
|
|
1395
|
+
buildStart() {
|
|
1396
|
+
this._activeBatch = new Batcher();
|
|
1505
1397
|
}
|
|
1506
|
-
|
|
1507
|
-
|
|
1398
|
+
buildEnd(n) {
|
|
1399
|
+
this.break(n);
|
|
1508
1400
|
}
|
|
1509
|
-
|
|
1510
|
-
|
|
1401
|
+
break(n) {
|
|
1402
|
+
this._activeBatch.build(n);
|
|
1511
1403
|
}
|
|
1512
|
-
|
|
1513
|
-
|
|
1404
|
+
addToBatch(n, j) {
|
|
1405
|
+
this._activeBatch.add({
|
|
1406
|
+
...n,
|
|
1407
|
+
getColor: () => n.renderable.groupColorAlpha
|
|
1408
|
+
});
|
|
1514
1409
|
}
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1410
|
+
execute(n) {
|
|
1411
|
+
let j = n.elements;
|
|
1412
|
+
if (!j || !j.length) return;
|
|
1413
|
+
let M = this._renderer.canvasContext, N = M.activeConext;
|
|
1414
|
+
for (let n = 0; n < j.length; n++) {
|
|
1415
|
+
let P = j[n], F = P.roundPixels, I = (P.getColor() >>> 24 & 255) / 255;
|
|
1416
|
+
if (I <= 0) continue;
|
|
1417
|
+
N.globalAlpha = I, M.setContextTransform(P.transform, F === 1);
|
|
1418
|
+
let L = P.bounds, R = P.texture, z = R.frame, B = R.source._resolution || 1, V = z.x * B, H = z.y * B, U = z.width * B, W = z.height * B, G = L.minX, K = L.minY, q = L.maxX - L.minX, J = L.maxY - L.minY, Y = G, X = K, Z = q, Q = J;
|
|
1419
|
+
N.drawImage(R.source.resource, V, H, U, W, Y, X, Z, Q);
|
|
1420
|
+
}
|
|
1519
1421
|
}
|
|
1520
|
-
|
|
1521
|
-
|
|
1422
|
+
destroy() {
|
|
1423
|
+
var n;
|
|
1424
|
+
this._renderer = null, (n = this._activeBatch) == null || n.destroy(), this._activeBatch = null;
|
|
1522
1425
|
}
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1426
|
+
};
|
|
1427
|
+
_BatchPipe = BatchPipe, _BatchPipe.desc = { name: "batch" };
|
|
1428
|
+
var Batcher = class {
|
|
1429
|
+
constructor() {
|
|
1430
|
+
this.renderPipeId = "batch", this.elements = [], this.elementSize = 0;
|
|
1526
1431
|
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1432
|
+
add(n) {
|
|
1433
|
+
this.elements[this.elementSize++] = n;
|
|
1529
1434
|
}
|
|
1530
|
-
|
|
1531
|
-
let
|
|
1532
|
-
|
|
1533
|
-
let
|
|
1534
|
-
|
|
1435
|
+
build(n) {
|
|
1436
|
+
let j = new Batch(), M = this.elements;
|
|
1437
|
+
if (M[0]) {
|
|
1438
|
+
for (let n = 0; n < M.length; n++) {
|
|
1439
|
+
let N = M[n];
|
|
1440
|
+
this.elements[n] = null, j.elements.push(N);
|
|
1441
|
+
}
|
|
1442
|
+
n.add(j);
|
|
1535
1443
|
}
|
|
1536
|
-
return this;
|
|
1537
1444
|
}
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
n.clear();
|
|
1541
|
-
let j = this.shapePrimitives;
|
|
1542
|
-
for (let M = 0; M < j.length; ++M) {
|
|
1543
|
-
let N = j[M].shape.getBounds();
|
|
1544
|
-
n.addRect(N);
|
|
1545
|
-
}
|
|
1546
|
-
return n;
|
|
1445
|
+
destroy() {
|
|
1446
|
+
this.elements = null;
|
|
1547
1447
|
}
|
|
1548
|
-
}
|
|
1448
|
+
};
|
|
1449
|
+
const CanvasPool = new class {
|
|
1549
1450
|
constructor() {
|
|
1550
|
-
this.
|
|
1451
|
+
this._canvasPool = Object.create(null);
|
|
1551
1452
|
}
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1453
|
+
getOptimalCanvasAndContext(n, j, M = 1) {
|
|
1454
|
+
let N = nextPow2(n * M - 1e-6), P = nextPow2(j * M - 1e-6), F = N << 17 + P << 1;
|
|
1455
|
+
this._canvasPool[F] || (this._canvasPool[F] = []);
|
|
1456
|
+
let I = this._canvasPool[F].pop();
|
|
1457
|
+
if (I) return I;
|
|
1458
|
+
{
|
|
1459
|
+
let n = document.createElement("canvas");
|
|
1460
|
+
return n.width = N, n.height = P, {
|
|
1461
|
+
canvas: n,
|
|
1462
|
+
context: n.getContext("2d")
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1562
1465
|
}
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1466
|
+
}();
|
|
1467
|
+
var _TextStyle, TextStyle = class n {
|
|
1468
|
+
constructor(j) {
|
|
1469
|
+
this.uid = uid("textStyle"), this._tick = 0;
|
|
1470
|
+
let M = {
|
|
1471
|
+
...n.defaultStyle,
|
|
1472
|
+
...j
|
|
1473
|
+
};
|
|
1474
|
+
for (let n in M) {
|
|
1475
|
+
let j = n;
|
|
1476
|
+
this[j] = M[n];
|
|
1477
|
+
}
|
|
1568
1478
|
}
|
|
1569
|
-
|
|
1570
|
-
return this.
|
|
1571
|
-
action: "bezierCurveTo",
|
|
1572
|
-
data: n
|
|
1573
|
-
}), this;
|
|
1479
|
+
get styleKey() {
|
|
1480
|
+
return `${this.uid}-${this._tick}`;
|
|
1574
1481
|
}
|
|
1575
|
-
|
|
1576
|
-
return this.
|
|
1577
|
-
action: "moveTo",
|
|
1578
|
-
data: n
|
|
1579
|
-
}), this;
|
|
1482
|
+
get fontSize() {
|
|
1483
|
+
return this._fontSize;
|
|
1580
1484
|
}
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
action: "closePath",
|
|
1584
|
-
data: []
|
|
1585
|
-
}), this._dirty = !0, this;
|
|
1485
|
+
set fontSize(n) {
|
|
1486
|
+
this._fontSize !== n && (this._fontSize = n, this.update());
|
|
1586
1487
|
}
|
|
1587
|
-
get
|
|
1588
|
-
return this.
|
|
1488
|
+
get fill() {
|
|
1489
|
+
return this._fill;
|
|
1589
1490
|
}
|
|
1590
|
-
|
|
1591
|
-
|
|
1491
|
+
set fill(n) {
|
|
1492
|
+
this._fill !== n && (this._fill = n, this.update());
|
|
1592
1493
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
case "lineTo": return {
|
|
1602
|
-
x: j.data[0],
|
|
1603
|
-
y: j.data[1]
|
|
1604
|
-
};
|
|
1605
|
-
}
|
|
1606
|
-
return {
|
|
1607
|
-
x: 0,
|
|
1608
|
-
y: 0
|
|
1609
|
-
};
|
|
1494
|
+
get align() {
|
|
1495
|
+
return this._align;
|
|
1496
|
+
}
|
|
1497
|
+
set align(n) {
|
|
1498
|
+
this._align !== n && (this._align = n, this.update());
|
|
1499
|
+
}
|
|
1500
|
+
get wordWarp() {
|
|
1501
|
+
return this._wordWrap;
|
|
1610
1502
|
}
|
|
1611
|
-
|
|
1612
|
-
this.
|
|
1503
|
+
set wordWrap(n) {
|
|
1504
|
+
this._wordWrap !== n && (this._wordWrap = n, this.update());
|
|
1613
1505
|
}
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
return j.instructions = this.instructions.slice(), j;
|
|
1506
|
+
get fontFamily() {
|
|
1507
|
+
return this._fontFamily;
|
|
1617
1508
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
this._activePath = new GraphicsPath(), this._bounds = new Bounds(), this.instructions = [];
|
|
1509
|
+
set fontFamily(n) {
|
|
1510
|
+
this._fontFamily !== n && (this._fontFamily = n, this.update());
|
|
1621
1511
|
}
|
|
1622
|
-
|
|
1623
|
-
this.
|
|
1512
|
+
get leading() {
|
|
1513
|
+
return this._leading;
|
|
1624
1514
|
}
|
|
1625
|
-
|
|
1626
|
-
|
|
1515
|
+
set leading(n) {
|
|
1516
|
+
this._leading !== n && (this._leading = n, this.update());
|
|
1627
1517
|
}
|
|
1628
|
-
|
|
1629
|
-
return this.
|
|
1518
|
+
get fontStyle() {
|
|
1519
|
+
return this._fontStyle;
|
|
1630
1520
|
}
|
|
1631
|
-
|
|
1632
|
-
|
|
1521
|
+
set fontStyle(n) {
|
|
1522
|
+
this._fontStyle !== n && (this._fontStyle = n.toLowerCase(), this.update());
|
|
1633
1523
|
}
|
|
1634
|
-
|
|
1635
|
-
return this.
|
|
1524
|
+
get textBaseline() {
|
|
1525
|
+
return this._textBaseline;
|
|
1636
1526
|
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1527
|
+
set textBaseline(n) {
|
|
1528
|
+
this._textBaseline = n, this.update();
|
|
1639
1529
|
}
|
|
1640
|
-
|
|
1641
|
-
return this.
|
|
1530
|
+
get lineHeight() {
|
|
1531
|
+
return this._lineHeight;
|
|
1642
1532
|
}
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
...n.defaultStrokeStyle,
|
|
1646
|
-
color: j
|
|
1647
|
-
};
|
|
1648
|
-
return this.instructions.push({
|
|
1649
|
-
action: "fill",
|
|
1650
|
-
data: {
|
|
1651
|
-
style: M,
|
|
1652
|
-
path: this._activePath.clone()
|
|
1653
|
-
}
|
|
1654
|
-
}), this;
|
|
1533
|
+
set lineHeight(n) {
|
|
1534
|
+
this._lineHeight !== n && (this._lineHeight = n, this.update());
|
|
1655
1535
|
}
|
|
1656
|
-
|
|
1657
|
-
this.
|
|
1658
|
-
action: "stroke",
|
|
1659
|
-
data: {
|
|
1660
|
-
style: this._strokeStyle,
|
|
1661
|
-
path: this._activePath.clone()
|
|
1662
|
-
}
|
|
1663
|
-
}), this._initNextPathLocation();
|
|
1536
|
+
get letterSpacing() {
|
|
1537
|
+
return this._letterSpacing;
|
|
1664
1538
|
}
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
this._activePath.clear(), this._activePath.moveTo(n, j);
|
|
1539
|
+
set letterSpacing(n) {
|
|
1540
|
+
this._letterSpacing !== n && (this._letterSpacing = n, this.update());
|
|
1668
1541
|
}
|
|
1669
|
-
get
|
|
1670
|
-
|
|
1671
|
-
n.clear();
|
|
1672
|
-
for (let j = 0; j < this.instructions.length; ++j) {
|
|
1673
|
-
let M = this.instructions[j], N = M.action;
|
|
1674
|
-
if (N === "fill") {
|
|
1675
|
-
let j = M.data;
|
|
1676
|
-
n.addBounds(j.path.bounds);
|
|
1677
|
-
} else if (N === "stroke") {
|
|
1678
|
-
let j = M.data, N = j.style.alignment, P = j.style.width * (1 - N);
|
|
1679
|
-
j.style.join;
|
|
1680
|
-
let F = j.path.bounds;
|
|
1681
|
-
n.addFrame(F.minX - P, F.minY - P, F.maxX + P, F.maxY + P);
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
return n;
|
|
1542
|
+
get fontVariant() {
|
|
1543
|
+
return this._fontVariant;
|
|
1685
1544
|
}
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1545
|
+
set fontVariant(n) {
|
|
1546
|
+
this._fontVariant !== n && (this._fontVariant = n, this.update());
|
|
1547
|
+
}
|
|
1548
|
+
get fontWeight() {
|
|
1549
|
+
return this._fontWeight;
|
|
1550
|
+
}
|
|
1551
|
+
set fontWeight(n) {
|
|
1552
|
+
this._fontWeight !== n && (this._fontWeight = n, this.update());
|
|
1553
|
+
}
|
|
1554
|
+
get _fontString() {
|
|
1555
|
+
return this._cachedFontString === null && (this._cachedFontString = fontStringFromTextStyle(this)), this._cachedFontString;
|
|
1556
|
+
}
|
|
1557
|
+
update() {
|
|
1558
|
+
this._tick++, this._cachedFontString = null;
|
|
1559
|
+
}
|
|
1560
|
+
destroy(n = !1) {
|
|
1561
|
+
this._fill = null;
|
|
1689
1562
|
}
|
|
1690
1563
|
};
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1564
|
+
_TextStyle = TextStyle, _TextStyle.defaultStyle = {
|
|
1565
|
+
align: "left",
|
|
1566
|
+
breakWords: !1,
|
|
1567
|
+
dropShadow: null,
|
|
1568
|
+
fill: "black",
|
|
1569
|
+
fontFamily: "Arial",
|
|
1570
|
+
fontSize: 26,
|
|
1571
|
+
fontStyle: "normal",
|
|
1572
|
+
fontVariant: "normal",
|
|
1573
|
+
fontWeight: "normal",
|
|
1574
|
+
leading: 0,
|
|
1575
|
+
letterSpacing: 0,
|
|
1576
|
+
lineHeight: 0,
|
|
1577
|
+
padding: 0,
|
|
1578
|
+
stroke: null,
|
|
1579
|
+
textBaseline: "alphabetic",
|
|
1580
|
+
trim: !1,
|
|
1581
|
+
whiteSpace: "pre",
|
|
1582
|
+
wordWrap: !1,
|
|
1583
|
+
wordWrapWidth: 100
|
|
1700
1584
|
};
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1585
|
+
var genericFontFamilies = [
|
|
1586
|
+
"serif",
|
|
1587
|
+
"sans-serif",
|
|
1588
|
+
"monospace",
|
|
1589
|
+
"cursive",
|
|
1590
|
+
"fantasy",
|
|
1591
|
+
"system-ui"
|
|
1592
|
+
];
|
|
1593
|
+
function fontStringFromTextStyle(n) {
|
|
1594
|
+
let j = typeof n.fontSize == "number" ? `${n.fontSize}px` : n.fontSize, M = n.fontFamily;
|
|
1595
|
+
Array.isArray(n.fontFamily) || (M = n.fontFamily.split(","));
|
|
1596
|
+
for (let n = M.length - 1; n >= 0; n--) {
|
|
1597
|
+
let j = M[n].trim();
|
|
1598
|
+
!/([\"\'])[^\'\"]+\1/.test(j) && !genericFontFamilies.includes(j) && (j = `"${j}"`), M[n] = j;
|
|
1599
|
+
}
|
|
1600
|
+
return `${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${j} ${M.join(",")}`;
|
|
1706
1601
|
}
|
|
1707
|
-
var
|
|
1708
|
-
|
|
1709
|
-
|
|
1602
|
+
var _TextMetrics;
|
|
1603
|
+
const NEWLINE_MATCH_REGEX = /(?:\r\n|\r|\n)/;
|
|
1604
|
+
var TextMetrics = class n {
|
|
1605
|
+
constructor(n, j, M, N, P, F, I, L, R) {
|
|
1606
|
+
this.text = n, this.style = j, this.width = M, this.height = N, this.lines = P, this.lineWidths = F, this.lineHeight = I, this.maxLineWidth = L, this.fontProperties = R;
|
|
1710
1607
|
}
|
|
1711
|
-
|
|
1712
|
-
|
|
1608
|
+
static get canvas() {
|
|
1609
|
+
if (!n._canvas) {
|
|
1610
|
+
let j;
|
|
1611
|
+
try {
|
|
1612
|
+
let M = new OffscreenCanvas(0, 0);
|
|
1613
|
+
if (M.getContext("2d", { willReadFrequently: !0 }).measureText) return n._canvas = M, M;
|
|
1614
|
+
j = createCanvas(10, 10);
|
|
1615
|
+
} catch (n) {
|
|
1616
|
+
j = createCanvas(10, 10);
|
|
1617
|
+
}
|
|
1618
|
+
n._canvas = j;
|
|
1619
|
+
}
|
|
1620
|
+
return n._canvas;
|
|
1713
1621
|
}
|
|
1714
|
-
|
|
1715
|
-
return
|
|
1622
|
+
static get context() {
|
|
1623
|
+
return n._context || (n._context = n.canvas.getContext("2d", { willReadFrequently: !0 })), n._context;
|
|
1716
1624
|
}
|
|
1717
|
-
|
|
1718
|
-
|
|
1625
|
+
static measureText(j, M) {
|
|
1626
|
+
let N = `${j}-${M.styleKey}`;
|
|
1627
|
+
if (n._measurementCache.has(N)) return n._measurementCache.get(N);
|
|
1628
|
+
let P = M._fontString, F = n.measureFont(P);
|
|
1629
|
+
F.fontSize === 0 && (F.fontSize = M.fontSize, F.ascent = M.fontSize, F.descent = 0);
|
|
1630
|
+
let I = n.context;
|
|
1631
|
+
I.font = P;
|
|
1632
|
+
let L = j.split(NEWLINE_MATCH_REGEX), R = Array(L.length), z = 0;
|
|
1633
|
+
for (let j = 0; j < L.length; ++j) {
|
|
1634
|
+
let N = n._measureText(L[j], M.letterSpacing);
|
|
1635
|
+
R[j] = N, z = Math.max(z, N);
|
|
1636
|
+
}
|
|
1637
|
+
let B = M.lineHeight || F.fontSize, V = new n(j, M, z, Math.max(B, F.fontSize + (L.length - 1) * (B + M.leading)), L, R, B, z, F);
|
|
1638
|
+
return n._measurementCache.set(N, V), V;
|
|
1719
1639
|
}
|
|
1720
|
-
|
|
1721
|
-
|
|
1640
|
+
static _measureText(j, M) {
|
|
1641
|
+
var N, P;
|
|
1642
|
+
let F = n.context;
|
|
1643
|
+
F.letterSpacing = "0px", F.textLetterSpacing = M;
|
|
1644
|
+
let I = F.measureText(j), L = I.width, R = 0;
|
|
1645
|
+
L > 0 && (R = (n.graphemeSegmenter(j).length - 1) * M, L += R);
|
|
1646
|
+
let z = -((N = I.actualBoundingBoxLeft) == null ? 0 : N), B = ((P = I.actualBoundingBoxRight) == null ? 0 : P) - z;
|
|
1647
|
+
return I.width > 0 && (B += R), Math.max(L, B);
|
|
1722
1648
|
}
|
|
1723
|
-
|
|
1724
|
-
|
|
1649
|
+
static measureFont(j) {
|
|
1650
|
+
var M, N;
|
|
1651
|
+
if (n._fonts[j]) return n._fonts[j];
|
|
1652
|
+
let P = n.context;
|
|
1653
|
+
P.font = j;
|
|
1654
|
+
let F = P.measureText(n.METRICS_STRING + n.BASELINE_SYMBOL), I = (M = F.actualBoundingBoxAscent) == null ? 0 : M, L = (N = F.actualBoundingBoxDescent) == null ? 0 : N, R = {
|
|
1655
|
+
ascent: I,
|
|
1656
|
+
descent: L,
|
|
1657
|
+
fontSize: I + L
|
|
1658
|
+
};
|
|
1659
|
+
return n._fonts[j] = R, R;
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
_TextMetrics = TextMetrics, _TextMetrics.METRICS_STRING = "|ÉqÅ", _TextMetrics.BASELINE_SYMBOL = "M", _TextMetrics._measurementCache = /* @__PURE__ */ new Map(), _TextMetrics._fonts = {}, _TextMetrics.graphemeSegmenter = (() => {
|
|
1663
|
+
var n;
|
|
1664
|
+
if (typeof ((n = Intl) == null ? void 0 : n.Segmenter) == "function") {
|
|
1665
|
+
let n = new Intl.Segmenter();
|
|
1666
|
+
return (j) => {
|
|
1667
|
+
let M = n.segment(j), N = [], P = 0;
|
|
1668
|
+
for (let n of M) N[P++] = n.segment;
|
|
1669
|
+
return N;
|
|
1670
|
+
};
|
|
1671
|
+
}
|
|
1672
|
+
return (n) => [...n];
|
|
1673
|
+
})();
|
|
1674
|
+
function createCanvas(n, j) {
|
|
1675
|
+
let M = document.createElement("canvas");
|
|
1676
|
+
return M.width = n, M.height = j, M;
|
|
1677
|
+
}
|
|
1678
|
+
function generateTextTexture(n) {
|
|
1679
|
+
let { text: j, style: M, resolution: N = 1, padding: P = 0 } = n, F = TextMetrics.measureText(j, M), I = Math.ceil(Math.ceil(Math.max(1, F.width) + P * 2) * N), L = Math.ceil(Math.ceil(Math.max(1, F.height) + P * 2) * N), R = CanvasPool.getOptimalCanvasAndContext(I, L);
|
|
1680
|
+
return renderTextToCanvas(M, N, P, R, F), {
|
|
1681
|
+
canvasAndContext: R,
|
|
1682
|
+
frame: new Rectangle(0, 0, I, L)
|
|
1683
|
+
};
|
|
1684
|
+
}
|
|
1685
|
+
function renderTextToCanvas(n, j, M, N, P) {
|
|
1686
|
+
let { context: F } = N, I = fontStringFromTextStyle(n), { lines: L, lineHeight: R, lineWidths: z, maxLineWidth: B, fontProperties: V } = P;
|
|
1687
|
+
F.resetTransform(), F.scale(j, j), F.textBaseline = n.textBaseline, F.font = I;
|
|
1688
|
+
let H = Math.min(0, (R - V.fontSize) / 2);
|
|
1689
|
+
F.fillStyle = n.fill;
|
|
1690
|
+
for (let j = 0; j < L.length; ++j) {
|
|
1691
|
+
let P = getAlignmentOffset(z[j], B, n.align), F = j * R + V.ascent + H, I = 0;
|
|
1692
|
+
if (n.align === "justify" && n.wordWrap && j < L.length - 1) {
|
|
1693
|
+
let n = countSpaces(L[j]);
|
|
1694
|
+
n > 0 && (I = (B - z[j]) / n);
|
|
1695
|
+
}
|
|
1696
|
+
drawLetterSpacing(L[j], n, N, P + M, F + M, !1, I);
|
|
1725
1697
|
}
|
|
1726
|
-
|
|
1727
|
-
|
|
1698
|
+
}
|
|
1699
|
+
function getAlignmentOffset(n, j, M) {
|
|
1700
|
+
return M === "right" ? j - n : M === "center" ? (j - n) / 2 : 0;
|
|
1701
|
+
}
|
|
1702
|
+
function countSpaces(n) {
|
|
1703
|
+
let j = 0;
|
|
1704
|
+
for (let M = 0; M < n.length; M++) n.charCodeAt(M) === 32 && j++;
|
|
1705
|
+
return j;
|
|
1706
|
+
}
|
|
1707
|
+
function drawLetterSpacing(n, j, M, N, P, F = !1, I = 0) {
|
|
1708
|
+
let L = M.context, R = j.letterSpacing;
|
|
1709
|
+
if (R === 0 && I === 0) {
|
|
1710
|
+
L.fillText(n, N, P);
|
|
1711
|
+
return;
|
|
1728
1712
|
}
|
|
1729
|
-
|
|
1730
|
-
|
|
1713
|
+
if (I !== 0 && R === 0) {
|
|
1714
|
+
let j = n.split(" "), M = N, F = L.measureText(" ").width;
|
|
1715
|
+
for (let n = 0; n < j.length; ++n) L.fillText(j[n], M, P), M += L.measureText(j[n]).width + F + I;
|
|
1716
|
+
return;
|
|
1731
1717
|
}
|
|
1732
|
-
|
|
1733
|
-
|
|
1718
|
+
let z = N, B = TextMetrics.graphemeSegmenter(n), V = L.measureText(n).width, H = 0;
|
|
1719
|
+
for (let n = 0; n < B.length; ++n) {
|
|
1720
|
+
let j = B[n];
|
|
1721
|
+
L.fillText(j, z, P);
|
|
1722
|
+
let M = "";
|
|
1723
|
+
for (let j = n + 1; j < B.length; ++j) M += B[j];
|
|
1724
|
+
H = L.measureText(M).width, z += V - H + R, j === "" && (z += I), V = H;
|
|
1734
1725
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1726
|
+
}
|
|
1727
|
+
var _TextureSource, TextureSource = class n extends eventemitter3_default {
|
|
1728
|
+
constructor(j) {
|
|
1729
|
+
super(), this._resolution = 1, this.pixelWidth = 1, this.pixelHeight = 1, this.width = 1, this.height = 1;
|
|
1730
|
+
let M = {
|
|
1731
|
+
...n.defaultOptions,
|
|
1732
|
+
...j
|
|
1733
|
+
};
|
|
1734
|
+
this.label = j.label, this.resource = M.resource, this._resolution = M.resolution, M.width ? this.pixelWidth = j.width * this._resolution : this.pixelWidth = this.resource && this.resourceWidth || 1, M.height ? this.pixelHeight = j.height * this._resolution : this.pixelHeight = this.resource && this.resourceHeight || 1, this.width = this.pixelWidth / this._resolution, this.height = this.pixelHeight / this._resolution, this.destroyed = !1;
|
|
1737
1735
|
}
|
|
1738
|
-
|
|
1739
|
-
return this.
|
|
1736
|
+
get resolution() {
|
|
1737
|
+
return this._resolution;
|
|
1740
1738
|
}
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
return this.context.bounds;
|
|
1739
|
+
set resolution(n) {
|
|
1740
|
+
this._resolution !== n && (this._resolution = n, this.width = this.pixelWidth / n, this.height = this.pixelHeight / n);
|
|
1744
1741
|
}
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1742
|
+
get resourceWidth() {
|
|
1743
|
+
let n = this.resource;
|
|
1744
|
+
return n.naturalWidth || n.width;
|
|
1748
1745
|
}
|
|
1749
|
-
|
|
1750
|
-
this.
|
|
1746
|
+
get resourceHeight() {
|
|
1747
|
+
let n = this.resource;
|
|
1748
|
+
return n.naturalHeight || n.height;
|
|
1751
1749
|
}
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
for (let j = 0; j < n.context.instructions.length; ++j) {
|
|
1757
|
-
let M = n.context.instructions[j], P = M.data.style, I = P.alpha * F;
|
|
1758
|
-
if (I <= 0) continue;
|
|
1759
|
-
N.globalAlpha = I;
|
|
1760
|
-
let L = M.action === "stroke";
|
|
1761
|
-
if (L) {
|
|
1762
|
-
let n = P.color;
|
|
1763
|
-
N.lineWidth = P.width, N.lineCap = P.cap, N.lineJoin = P.join, N.miterLimit = P.miterLimit, N.strokeStyle = n;
|
|
1764
|
-
} else N.fillStyle = M.data.style.color;
|
|
1765
|
-
let R = M.data.path.shapePath.shapePrimitives;
|
|
1766
|
-
for (let n = 0; n < R.length; ++n) {
|
|
1767
|
-
let j = R[n];
|
|
1768
|
-
j.shape && (N.beginPath(), buildShapePath(N, j.shape), L ? N.stroke() : N.fill());
|
|
1769
|
-
}
|
|
1770
|
-
}
|
|
1771
|
-
N.restore();
|
|
1772
|
-
}
|
|
1750
|
+
resize(n, j, M) {
|
|
1751
|
+
M || (M = this._resolution), n || (n = this.width), j || (j = this.height);
|
|
1752
|
+
let N = Math.round(n * M), P = Math.round(j * M);
|
|
1753
|
+
return this.width = N / M, this.height = P / M, this._resolution = M, this.pixelWidth === N && this.pixelHeight === P ? !1 : (this.pixelWidth = N, this.pixelHeight = P, this.emit("resize", this), !0);
|
|
1773
1754
|
}
|
|
1774
1755
|
destroy() {
|
|
1775
|
-
this.
|
|
1756
|
+
this.destroyed = !0, this.resource = null, this.emit("destroy", this), this.removeAllListeners();
|
|
1776
1757
|
}
|
|
1777
1758
|
};
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
switch (j.type) {
|
|
1781
|
-
case "rectangle": {
|
|
1782
|
-
let M = j;
|
|
1783
|
-
n.rect(M.x, M.y, M.width, M.height);
|
|
1784
|
-
break;
|
|
1785
|
-
}
|
|
1786
|
-
case "polygon": {
|
|
1787
|
-
let M = j, N = M.points;
|
|
1788
|
-
if (!N.length) return;
|
|
1789
|
-
n.moveTo(N[0], N[1]);
|
|
1790
|
-
for (let j = 2; j < N.length; j += 2) n.lineTo(N[j], N[j + 1]);
|
|
1791
|
-
M.closePath && n.closePath();
|
|
1792
|
-
break;
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
var _BatchPipe, Batch = class {
|
|
1797
|
-
constructor() {
|
|
1798
|
-
this.renderPipeId = "batch", this.elements = [];
|
|
1799
|
-
}
|
|
1800
|
-
}, BatchPipe = class {
|
|
1759
|
+
_TextureSource = TextureSource, _TextureSource.defaultOptions = { resolution: 1 };
|
|
1760
|
+
var CanvasSource = class extends TextureSource {
|
|
1801
1761
|
constructor(n) {
|
|
1802
|
-
this.
|
|
1803
|
-
}
|
|
1804
|
-
get batch() {
|
|
1805
|
-
return this._activeBatch;
|
|
1806
|
-
}
|
|
1807
|
-
buildStart() {
|
|
1808
|
-
this._activeBatch = new Batcher();
|
|
1809
|
-
}
|
|
1810
|
-
buildEnd(n) {
|
|
1811
|
-
this.break(n);
|
|
1762
|
+
n.resource || (n.resource = createCanvas()), n.width || (n.width = n.resource.width, n.autoDensity || (n.width /= n.resolution)), n.height || (n.height = n.resource.height, n.autoDensity || (n.height /= n.resolution)), super(n), this.autoDensity = n.autoDensity, this.resizeCanvas();
|
|
1812
1763
|
}
|
|
1813
|
-
|
|
1814
|
-
this.
|
|
1764
|
+
resizeCanvas() {
|
|
1765
|
+
this.autoDensity && (this.resource.style.width = `${this.width}px`, this.resource.style.height = `${this.height}px`), (this.resource.width !== this.pixelWidth || this.resource.height !== this.pixelHeight) && (this.resource.width = this.pixelWidth, this.resource.height = this.pixelHeight);
|
|
1815
1766
|
}
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
getColor: () => n.renderable.groupColorAlpha
|
|
1820
|
-
});
|
|
1767
|
+
resize(n = this.width, j = this.height, M = this._resolution) {
|
|
1768
|
+
let N = super.resize(n, j, M);
|
|
1769
|
+
return N && this.resizeCanvas(), N;
|
|
1821
1770
|
}
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
if (!
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
let
|
|
1828
|
-
|
|
1829
|
-
N.globalAlpha = I, M.setContextTransform(P.transform, F === 1);
|
|
1830
|
-
let L = P.bounds, R = P.texture, z = R.frame, B = R.source._resolution || 1, V = z.x * B, H = z.y * B, U = z.width * B, W = z.height * B, G = L.minX, K = L.minY, q = L.maxX - L.minX, J = L.maxY - L.minY, Y = G, X = K, Z = q, Q = J;
|
|
1831
|
-
N.drawImage(R.source.resource, V, H, U, W, Y, X, Z, Q);
|
|
1771
|
+
}, Texture = class extends eventemitter3_default {
|
|
1772
|
+
constructor({ source: n, label: j, frame: M, orig: N, rotate: P } = {}) {
|
|
1773
|
+
if (super(), this.frame = new Rectangle(), this.noFrame = !1, this.label = j, this.source = n, M) this.frame.copyFrom(M);
|
|
1774
|
+
else {
|
|
1775
|
+
this.noFrame = !0;
|
|
1776
|
+
let { width: j, height: M } = n;
|
|
1777
|
+
this.frame.width = j, this.frame.height = M;
|
|
1832
1778
|
}
|
|
1779
|
+
this.orig = N || this.frame, this.rotate = P == null ? 0 : P, this.destroyed = !1;
|
|
1833
1780
|
}
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
this._renderer = null, (n = this._activeBatch) == null || n.destroy(), this._activeBatch = null;
|
|
1781
|
+
get source() {
|
|
1782
|
+
return this._source;
|
|
1837
1783
|
}
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
var Batcher = class {
|
|
1841
|
-
constructor() {
|
|
1842
|
-
this.renderPipeId = "batch", this.elements = [], this.elementSize = 0;
|
|
1784
|
+
set source(n) {
|
|
1785
|
+
this._source && this._source.off("resize", this.update, this), this._source = n, n.on("resize", this.update, this);
|
|
1843
1786
|
}
|
|
1844
|
-
|
|
1845
|
-
this.
|
|
1787
|
+
get width() {
|
|
1788
|
+
return this.orig.width;
|
|
1846
1789
|
}
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
if (M[0]) {
|
|
1850
|
-
for (let n = 0; n < M.length; n++) {
|
|
1851
|
-
let N = M[n];
|
|
1852
|
-
this.elements[n] = null, j.elements.push(N);
|
|
1853
|
-
}
|
|
1854
|
-
n.add(j);
|
|
1855
|
-
}
|
|
1790
|
+
get height() {
|
|
1791
|
+
return this.orig.height;
|
|
1856
1792
|
}
|
|
1857
|
-
|
|
1858
|
-
this.
|
|
1793
|
+
update() {
|
|
1794
|
+
this.noFrame && (this.frame.width = this._source.width, this.frame.height = this._source.height);
|
|
1859
1795
|
}
|
|
1860
|
-
|
|
1796
|
+
destroy(n = !1) {
|
|
1797
|
+
this._source && (this._source.off("resize", this.update, this), n && (this._source.destroy(), this._source = null)), this.destroyed = !0, this.emit("destroy", this), this.removeAllListeners();
|
|
1798
|
+
}
|
|
1799
|
+
};
|
|
1800
|
+
Texture.EMPTY = new Texture({
|
|
1801
|
+
label: "EMPTY",
|
|
1802
|
+
source: new TextureSource({ label: "EMPTY" })
|
|
1803
|
+
});
|
|
1804
|
+
var _TextSystem, TextSystem = class {
|
|
1861
1805
|
constructor(n) {
|
|
1862
1806
|
this._activeTexture = {}, this.renderer = n;
|
|
1863
1807
|
}
|
|
@@ -2234,6 +2178,9 @@ var TickerListener = class {
|
|
|
2234
2178
|
start() {
|
|
2235
2179
|
this.started || (this.started = !0, this._requestIfNeeded());
|
|
2236
2180
|
}
|
|
2181
|
+
stop() {
|
|
2182
|
+
this.started && (this.started = !1, this._cancelIfNeeded());
|
|
2183
|
+
}
|
|
2237
2184
|
remove(n, j) {
|
|
2238
2185
|
let M = this._head.next;
|
|
2239
2186
|
for (; M;) M = M.match(n, j) ? M.destroy() : M.next;
|
|
@@ -2248,6 +2195,12 @@ var TickerListener = class {
|
|
|
2248
2195
|
_cancelIfNeeded() {
|
|
2249
2196
|
this._requestId !== null && (cancelAnimationFrame(this._requestId), this._requestId = null);
|
|
2250
2197
|
}
|
|
2198
|
+
destroy() {
|
|
2199
|
+
this.stop();
|
|
2200
|
+
let n = this._head.next;
|
|
2201
|
+
for (; n;) n = n.destroy(!0);
|
|
2202
|
+
this._head.destroy(), this._head = null;
|
|
2203
|
+
}
|
|
2251
2204
|
};
|
|
2252
2205
|
_Ticker = Ticker, _Ticker.targetFPMS = .06;
|
|
2253
2206
|
var plugins = [class {
|
|
@@ -2283,7 +2236,7 @@ var plugins = [class {
|
|
|
2283
2236
|
constructor() {
|
|
2284
2237
|
this.stage = new Container();
|
|
2285
2238
|
}
|
|
2286
|
-
async init(n) {
|
|
2239
|
+
async init(n = {}) {
|
|
2287
2240
|
n = { ...n }, this.stage || (this.stage = new Container()), this.renderer = new CanvasRenderer(), await this.renderer.init(n), plugins.forEach((j) => {
|
|
2288
2241
|
j.init.call(this, n);
|
|
2289
2242
|
}), this.ticker = new Ticker(), (n.autoStart || n.autoStart == null) && this._ticker.start();
|
|
@@ -2305,11 +2258,188 @@ var plugins = [class {
|
|
|
2305
2258
|
}
|
|
2306
2259
|
destroy() {
|
|
2307
2260
|
let n = plugins.slice(0);
|
|
2308
|
-
n.reverse(), n.forEach((n) => {
|
|
2261
|
+
if (n.reverse(), n.forEach((n) => {
|
|
2309
2262
|
n.destroy.call(this);
|
|
2310
|
-
}), this.stage.destroy(), this.stage = null, this.renderer.destroy(), this.renderer = null
|
|
2263
|
+
}), this.stage.destroy(), this.stage = null, this.renderer.destroy(), this.renderer = null, this._ticker) {
|
|
2264
|
+
let n = this._ticker;
|
|
2265
|
+
this._ticker = null, n.destroy();
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
};
|
|
2269
|
+
const Cache = new class {
|
|
2270
|
+
constructor() {
|
|
2271
|
+
this._cache = /* @__PURE__ */ new Map(), this._cacheMap = /* @__PURE__ */ new Map();
|
|
2272
|
+
}
|
|
2273
|
+
reset() {
|
|
2274
|
+
this._cache.clear(), this._cacheMap.clear();
|
|
2275
|
+
}
|
|
2276
|
+
has(n) {
|
|
2277
|
+
return this._cache.has(n);
|
|
2278
|
+
}
|
|
2279
|
+
get(n) {
|
|
2280
|
+
let j = this._cache.get(n);
|
|
2281
|
+
if (!j) throw Error(`Asset ${n} not found`);
|
|
2282
|
+
return j;
|
|
2283
|
+
}
|
|
2284
|
+
set(n, j) {
|
|
2285
|
+
let M = Array.isArray(n) ? n : [n], N = /* @__PURE__ */ new Map();
|
|
2286
|
+
M.forEach((n) => {
|
|
2287
|
+
N.set(n, j);
|
|
2288
|
+
});
|
|
2289
|
+
let P = [...N.keys()], F = {
|
|
2290
|
+
cacheKeys: P,
|
|
2291
|
+
keys: M
|
|
2292
|
+
};
|
|
2293
|
+
M.forEach((n) => {
|
|
2294
|
+
this._cacheMap.set(n, F);
|
|
2295
|
+
}), P.forEach((n) => {
|
|
2296
|
+
this._cache.has(n) && this._cache.has(n), this._cache.set(n, N.get(n));
|
|
2297
|
+
});
|
|
2298
|
+
}
|
|
2299
|
+
remove(n) {
|
|
2300
|
+
if (!this._cacheMap.has(n)) return;
|
|
2301
|
+
let j = this._cacheMap.get(n);
|
|
2302
|
+
((j == null ? void 0 : j.cacheKeys) || []).forEach((n) => {
|
|
2303
|
+
this._cache.delete(n);
|
|
2304
|
+
}), j == null || j.keys.forEach((n) => {
|
|
2305
|
+
this._cacheMap.delete(n);
|
|
2306
|
+
});
|
|
2307
|
+
}
|
|
2308
|
+
}();
|
|
2309
|
+
var _Loader, Loader = class n {
|
|
2310
|
+
constructor() {
|
|
2311
|
+
this.promiseCache = {}, this.loadOptions = { ...n.defaultOptions };
|
|
2312
|
+
}
|
|
2313
|
+
getAlias(n) {
|
|
2314
|
+
let { alias: j, src: M } = n, N = j || M;
|
|
2315
|
+
return (Array.isArray(N) ? N : [N]).map((n) => typeof n == "string" ? n : Array.isArray(n) ? n.map((n) => {
|
|
2316
|
+
var j;
|
|
2317
|
+
return (j = n.src) == null ? n : j;
|
|
2318
|
+
}) : n != null && n.src ? n.src : n);
|
|
2319
|
+
}
|
|
2320
|
+
async load(j, M) {
|
|
2321
|
+
let { onProgress: N, onError: P, strategy: F, retryCount: I, retryDelay: L } = typeof M == "function" ? {
|
|
2322
|
+
...n.defaultOptions,
|
|
2323
|
+
...this.loadOptions,
|
|
2324
|
+
onProgress: M
|
|
2325
|
+
} : {
|
|
2326
|
+
...n.defaultOptions,
|
|
2327
|
+
...this.loadOptions,
|
|
2328
|
+
...M || {}
|
|
2329
|
+
}, R = 0, z = {}, B = j.reduce((n, j) => n + (j.progressSize || 1), 0), V = j.map(async (n) => {
|
|
2330
|
+
if (z[n.src]) return;
|
|
2331
|
+
let j = n.src;
|
|
2332
|
+
await this._loadAssetWithRetry(j, n, {
|
|
2333
|
+
onProgress: N,
|
|
2334
|
+
onError: P,
|
|
2335
|
+
strategy: F,
|
|
2336
|
+
retryCount: I,
|
|
2337
|
+
retryDelay: L
|
|
2338
|
+
}, z), R += n.progressSize || 1, N && N(R / B);
|
|
2339
|
+
});
|
|
2340
|
+
return await Promise.all(V), z;
|
|
2341
|
+
}
|
|
2342
|
+
async unload(n) {
|
|
2343
|
+
let j = n.map(async (n) => {
|
|
2344
|
+
let j = n.src, M = this.promiseCache[j];
|
|
2345
|
+
if (M) {
|
|
2346
|
+
let n = await M;
|
|
2347
|
+
delete this.promiseCache[j], n.destroy(!0);
|
|
2348
|
+
}
|
|
2349
|
+
});
|
|
2350
|
+
await Promise.all(j);
|
|
2351
|
+
}
|
|
2352
|
+
_getLoadPromise(n, j) {
|
|
2353
|
+
return (async () => await loadTextures(n, j, this))();
|
|
2354
|
+
}
|
|
2355
|
+
async _loadAssetWithRetry(n, j, M, N) {
|
|
2356
|
+
let P = 0, { onError: F, strategy: I, retryCount: L, retryDelay: R } = M, z = (n) => new Promise((j) => setTimeout(j, n));
|
|
2357
|
+
for (;;) try {
|
|
2358
|
+
this.promiseCache[n] || (this.promiseCache[n] = this._getLoadPromise(n, j)), N[j.src] = await this.promiseCache[n];
|
|
2359
|
+
return;
|
|
2360
|
+
} catch (M) {
|
|
2361
|
+
if (delete this.promiseCache[n], delete N[j.src], P++, I === "retry" && !(I !== "retry" || P > L)) {
|
|
2362
|
+
F && F(M, j.src), await z(R);
|
|
2363
|
+
continue;
|
|
2364
|
+
}
|
|
2365
|
+
if (I === "skip") {
|
|
2366
|
+
F && F(M, j.src);
|
|
2367
|
+
return;
|
|
2368
|
+
}
|
|
2369
|
+
F && F(M, j.src);
|
|
2370
|
+
let B = /* @__PURE__ */ Error(`[Loader.load] Failed to load ${n}.\n${M}`);
|
|
2371
|
+
throw M instanceof Error && M.stack && (B.stack = M.stack), B;
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
reset() {
|
|
2375
|
+
this.promiseCache = {};
|
|
2376
|
+
}
|
|
2377
|
+
};
|
|
2378
|
+
_Loader = Loader, _Loader.defaultOptions = {
|
|
2379
|
+
strategy: "throw",
|
|
2380
|
+
retryCount: 3,
|
|
2381
|
+
retryDelay: 250
|
|
2382
|
+
};
|
|
2383
|
+
async function loadTextures(n, j, M) {
|
|
2384
|
+
let N = null;
|
|
2385
|
+
return N = globalThis.createImageBitmap ? await loadImageBitmap(n) : await new Promise((j, M) => {
|
|
2386
|
+
N = new Image(), N.crossOrigin = "anonymous", N.src = n, N.complete ? j(N) : (N.onload = () => {
|
|
2387
|
+
j(N);
|
|
2388
|
+
}, N.onerror = M);
|
|
2389
|
+
}), createTexture(new TextureSource({ resource: N }), M, n);
|
|
2390
|
+
}
|
|
2391
|
+
async function loadImageBitmap(n) {
|
|
2392
|
+
let j = await window.fetch(n);
|
|
2393
|
+
if (j.headers.get("content-type") === "text/html" || !j.ok) throw Error(`[loadImageBitmap] Failed to fetch ${n}: ${j.status} ${j.statusText}`);
|
|
2394
|
+
let M = await j.blob();
|
|
2395
|
+
return window.createImageBitmap(M);
|
|
2396
|
+
}
|
|
2397
|
+
function createTexture(n, j, M) {
|
|
2398
|
+
n.label = M;
|
|
2399
|
+
let N = new Texture({
|
|
2400
|
+
source: n,
|
|
2401
|
+
label: M
|
|
2402
|
+
}), P = () => {
|
|
2403
|
+
delete j.promiseCache[M], Cache.has(M) && Cache.remove(M);
|
|
2404
|
+
};
|
|
2405
|
+
return N.source.on("destroy", () => {
|
|
2406
|
+
j.promiseCache[M] && P();
|
|
2407
|
+
}), N.on("destroy", () => {
|
|
2408
|
+
n.destroyed || P();
|
|
2409
|
+
}), N;
|
|
2410
|
+
}
|
|
2411
|
+
var AssetsClass = class {
|
|
2412
|
+
constructor() {
|
|
2413
|
+
this._initialized = !1, this.loader = new Loader(), this.cache = Cache;
|
|
2414
|
+
}
|
|
2415
|
+
init(n = {}) {
|
|
2416
|
+
this._initialized || (this._initialized = !0, n.basePath && (this.basePath = n.basePath), n.loadOptions && (this.loader.loadOptions = {
|
|
2417
|
+
...this.loader.loadOptions,
|
|
2418
|
+
...n.loadOptions
|
|
2419
|
+
}));
|
|
2420
|
+
}
|
|
2421
|
+
async load(n, j) {
|
|
2422
|
+
this._initialized || this.init();
|
|
2423
|
+
let M = n.map((n) => ({
|
|
2424
|
+
...n,
|
|
2425
|
+
src: this.basePath ? `${this.basePath}/${n.src}` : n.src
|
|
2426
|
+
}));
|
|
2427
|
+
return await this._mapLoadToResolve(M, j);
|
|
2428
|
+
}
|
|
2429
|
+
async _mapLoadToResolve(n, j) {
|
|
2430
|
+
let M = Object.values(n), N = await this.loader.load(M, j), P = {};
|
|
2431
|
+
return M.forEach((n) => {
|
|
2432
|
+
let j = N[n.src], M = Array.isArray(n.alias) ? n.alias : [n.alias], F = [n.src, ...M];
|
|
2433
|
+
F.forEach((n) => {
|
|
2434
|
+
P[n] = j;
|
|
2435
|
+
}), Cache.set(F, j);
|
|
2436
|
+
}), P;
|
|
2437
|
+
}
|
|
2438
|
+
reset() {
|
|
2439
|
+
this._initialized = !1, this.cache.reset(), this.loader.reset();
|
|
2311
2440
|
}
|
|
2312
2441
|
};
|
|
2313
|
-
|
|
2442
|
+
const Assets = new AssetsClass();
|
|
2443
|
+
export { Application, Assets, AssetsClass, CanvasRenderer, Container, Graphics, GraphicsContext, GraphicsPipe, Matrix, PI_2, Rectangle, RenderGroup, Sprite, Text, TextPipe, Texture, Ticker, TickerListener, UPDATE_BLEND, UPDATE_COLOR, UPDATE_TRANSFORM, UPDATE_VISIBLE, Vector2, ViewContainer, buildShapePath, nextPow2 };
|
|
2314
2444
|
|
|
2315
2445
|
//# sourceMappingURL=dao.js.map
|