modern-canvas 0.7.0 → 0.7.1
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/index.cjs +112 -88
- package/dist/index.d.cts +87 -72
- package/dist/index.d.mts +87 -72
- package/dist/index.d.ts +87 -72
- package/dist/index.js +36 -36
- package/dist/index.mjs +112 -88
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1075,7 +1075,7 @@ class Vector extends EventEmitter {
|
|
|
1075
1075
|
get length() {
|
|
1076
1076
|
return this.dim;
|
|
1077
1077
|
}
|
|
1078
|
-
|
|
1078
|
+
operate(operator, target, output) {
|
|
1079
1079
|
const { dim: length, _array: array } = this;
|
|
1080
1080
|
let targetArray;
|
|
1081
1081
|
if (typeof target === "number") {
|
|
@@ -1161,29 +1161,41 @@ class Vector extends EventEmitter {
|
|
|
1161
1161
|
}
|
|
1162
1162
|
return outputObject?.set(outputArray) ?? outputArray;
|
|
1163
1163
|
}
|
|
1164
|
-
add(value,
|
|
1165
|
-
|
|
1164
|
+
add(value, ...args) {
|
|
1165
|
+
if (args.length && typeof value === "number") {
|
|
1166
|
+
value = [value, ...args];
|
|
1167
|
+
}
|
|
1168
|
+
return this.operate("+", value);
|
|
1166
1169
|
}
|
|
1167
|
-
sub(value,
|
|
1168
|
-
|
|
1170
|
+
sub(value, ...args) {
|
|
1171
|
+
if (args.length && typeof value === "number") {
|
|
1172
|
+
value = [value, ...args];
|
|
1173
|
+
}
|
|
1174
|
+
return this.operate("-", value);
|
|
1169
1175
|
}
|
|
1170
|
-
multiply(value,
|
|
1171
|
-
|
|
1176
|
+
multiply(value, ...args) {
|
|
1177
|
+
if (args.length && typeof value === "number") {
|
|
1178
|
+
value = [value, ...args];
|
|
1179
|
+
}
|
|
1180
|
+
return this.operate("*", value);
|
|
1172
1181
|
}
|
|
1173
|
-
divide(value,
|
|
1174
|
-
|
|
1182
|
+
divide(value, ...args) {
|
|
1183
|
+
if (args.length && typeof value === "number") {
|
|
1184
|
+
value = [value, ...args];
|
|
1185
|
+
}
|
|
1186
|
+
return this.operate("/", value);
|
|
1175
1187
|
}
|
|
1176
1188
|
rotate(angle) {
|
|
1177
|
-
return this.
|
|
1189
|
+
return this.operate("rot", angle);
|
|
1178
1190
|
}
|
|
1179
1191
|
set(value, ...args) {
|
|
1180
1192
|
if (args.length && typeof value === "number") {
|
|
1181
1193
|
value = [value, ...args];
|
|
1182
1194
|
}
|
|
1183
|
-
return this.
|
|
1195
|
+
return this.operate("=", value);
|
|
1184
1196
|
}
|
|
1185
1197
|
equals(value) {
|
|
1186
|
-
return this.
|
|
1198
|
+
return this.operate("==", value);
|
|
1187
1199
|
}
|
|
1188
1200
|
copy(value) {
|
|
1189
1201
|
return this.set(value);
|
|
@@ -1195,11 +1207,14 @@ class Vector extends EventEmitter {
|
|
|
1195
1207
|
}
|
|
1196
1208
|
_onUpdate(_array) {
|
|
1197
1209
|
}
|
|
1210
|
+
toName() {
|
|
1211
|
+
return `Vector${this.dim}`;
|
|
1212
|
+
}
|
|
1198
1213
|
toArray() {
|
|
1199
1214
|
return this._array.slice();
|
|
1200
1215
|
}
|
|
1201
|
-
|
|
1202
|
-
return
|
|
1216
|
+
toJSON() {
|
|
1217
|
+
return this.toArray();
|
|
1203
1218
|
}
|
|
1204
1219
|
}
|
|
1205
1220
|
|
|
@@ -1219,7 +1234,7 @@ class Matrix extends EventEmitter {
|
|
|
1219
1234
|
get length() {
|
|
1220
1235
|
return this.cols * this.rows;
|
|
1221
1236
|
}
|
|
1222
|
-
|
|
1237
|
+
operate(operator, target, output) {
|
|
1223
1238
|
const { cols, rows, length, _array: array } = this;
|
|
1224
1239
|
let targetArray;
|
|
1225
1240
|
if (typeof target === "number") {
|
|
@@ -1306,7 +1321,7 @@ class Matrix extends EventEmitter {
|
|
|
1306
1321
|
return this.set(array);
|
|
1307
1322
|
}
|
|
1308
1323
|
set(value) {
|
|
1309
|
-
return this.
|
|
1324
|
+
return this.operate("=", value);
|
|
1310
1325
|
}
|
|
1311
1326
|
copy(value) {
|
|
1312
1327
|
return this.set(value);
|
|
@@ -1317,7 +1332,7 @@ class Matrix extends EventEmitter {
|
|
|
1317
1332
|
return cloned;
|
|
1318
1333
|
}
|
|
1319
1334
|
multiply(value, output) {
|
|
1320
|
-
return this.
|
|
1335
|
+
return this.operate("*", value, output);
|
|
1321
1336
|
}
|
|
1322
1337
|
_onUpdate(_array) {
|
|
1323
1338
|
this.dirtyId++;
|
|
@@ -1339,7 +1354,7 @@ class Matrix extends EventEmitter {
|
|
|
1339
1354
|
return `Matrix${this.rows}(${this.rows}x${this.cols})`;
|
|
1340
1355
|
}
|
|
1341
1356
|
toJSON() {
|
|
1342
|
-
return this._array;
|
|
1357
|
+
return this._array.slice();
|
|
1343
1358
|
}
|
|
1344
1359
|
}
|
|
1345
1360
|
|
|
@@ -1351,7 +1366,7 @@ class Matrix4 extends Matrix {
|
|
|
1351
1366
|
|
|
1352
1367
|
const DEG_TO_RAD = PI / 180;
|
|
1353
1368
|
const RAD_TO_DEG = 180 / PI;
|
|
1354
|
-
function clamp(
|
|
1369
|
+
function clamp(val, min, max) {
|
|
1355
1370
|
return Math.max(min, Math.min(val, max));
|
|
1356
1371
|
}
|
|
1357
1372
|
function lerp(a, b, weight) {
|
|
@@ -1380,7 +1395,7 @@ const curves = {
|
|
|
1380
1395
|
class Vector4 extends Vector {
|
|
1381
1396
|
constructor(x = 0, y = 0, z = 0, m = 0) {
|
|
1382
1397
|
super(4);
|
|
1383
|
-
this.set(
|
|
1398
|
+
this.set(x, y, z, m);
|
|
1384
1399
|
}
|
|
1385
1400
|
}
|
|
1386
1401
|
|
|
@@ -1521,7 +1536,7 @@ class ColorMatrix extends Matrix {
|
|
|
1521
1536
|
]);
|
|
1522
1537
|
}
|
|
1523
1538
|
sepia(amount = 1) {
|
|
1524
|
-
const v = clamp(
|
|
1539
|
+
const v = clamp(amount, 0, 1);
|
|
1525
1540
|
return this.multiply([
|
|
1526
1541
|
lerp(1, 0.393, v),
|
|
1527
1542
|
lerp(0, 0.7689999, v),
|
|
@@ -1570,7 +1585,7 @@ class ColorMatrix extends Matrix {
|
|
|
1570
1585
|
]);
|
|
1571
1586
|
}
|
|
1572
1587
|
grayscale(amount = 1) {
|
|
1573
|
-
const v = clamp(
|
|
1588
|
+
const v = clamp(amount, 0, 1);
|
|
1574
1589
|
const r = lerp(1, 0.3, v);
|
|
1575
1590
|
const rr = lerp(0, 0.3, v);
|
|
1576
1591
|
const g = lerp(1, 0.59, v);
|
|
@@ -1833,7 +1848,7 @@ class Vector2 extends Vector {
|
|
|
1833
1848
|
return this;
|
|
1834
1849
|
}
|
|
1835
1850
|
static lerp(a, b, t) {
|
|
1836
|
-
return new Vector2(b).clone().sub(
|
|
1851
|
+
return new Vector2(b).clone().sub(a).multiply(t).add(a);
|
|
1837
1852
|
}
|
|
1838
1853
|
}
|
|
1839
1854
|
|
|
@@ -2081,13 +2096,13 @@ class Vector3 extends Vector {
|
|
|
2081
2096
|
}
|
|
2082
2097
|
}
|
|
2083
2098
|
|
|
2084
|
-
var __defProp$
|
|
2099
|
+
var __defProp$P = Object.defineProperty;
|
|
2085
2100
|
var __decorateClass$Z = (decorators, target, key, kind) => {
|
|
2086
2101
|
var result = void 0 ;
|
|
2087
2102
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2088
2103
|
if (decorator = decorators[i])
|
|
2089
2104
|
result = (decorator(target, key, result) ) || result;
|
|
2090
|
-
if (result) __defProp$
|
|
2105
|
+
if (result) __defProp$P(target, key, result);
|
|
2091
2106
|
return result;
|
|
2092
2107
|
};
|
|
2093
2108
|
class MainLoop extends CoreObject {
|
|
@@ -4325,13 +4340,13 @@ class Geometry extends Resource {
|
|
|
4325
4340
|
}
|
|
4326
4341
|
}
|
|
4327
4342
|
|
|
4328
|
-
var __defProp$
|
|
4343
|
+
var __defProp$O = Object.defineProperty;
|
|
4329
4344
|
var __decorateClass$Y = (decorators, target, key, kind) => {
|
|
4330
4345
|
var result = void 0 ;
|
|
4331
4346
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
4332
4347
|
if (decorator = decorators[i])
|
|
4333
4348
|
result = (decorator(target, key, result) ) || result;
|
|
4334
|
-
if (result) __defProp$
|
|
4349
|
+
if (result) __defProp$O(target, key, result);
|
|
4335
4350
|
return result;
|
|
4336
4351
|
};
|
|
4337
4352
|
class IndexBuffer extends Resource {
|
|
@@ -4382,13 +4397,13 @@ __decorateClass$Y([
|
|
|
4382
4397
|
property({ protected: true, fallback: false })
|
|
4383
4398
|
], IndexBuffer.prototype, "dynamic");
|
|
4384
4399
|
|
|
4385
|
-
var __defProp$
|
|
4400
|
+
var __defProp$N = Object.defineProperty;
|
|
4386
4401
|
var __decorateClass$X = (decorators, target, key, kind) => {
|
|
4387
4402
|
var result = void 0 ;
|
|
4388
4403
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
4389
4404
|
if (decorator = decorators[i])
|
|
4390
4405
|
result = (decorator(target, key, result) ) || result;
|
|
4391
|
-
if (result) __defProp$
|
|
4406
|
+
if (result) __defProp$N(target, key, result);
|
|
4392
4407
|
return result;
|
|
4393
4408
|
};
|
|
4394
4409
|
class VertexBuffer extends Resource {
|
|
@@ -4439,13 +4454,13 @@ __decorateClass$X([
|
|
|
4439
4454
|
property({ protected: true, fallback: false })
|
|
4440
4455
|
], VertexBuffer.prototype, "dynamic");
|
|
4441
4456
|
|
|
4442
|
-
var __defProp$
|
|
4457
|
+
var __defProp$M = Object.defineProperty;
|
|
4443
4458
|
var __decorateClass$W = (decorators, target, key, kind) => {
|
|
4444
4459
|
var result = void 0 ;
|
|
4445
4460
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
4446
4461
|
if (decorator = decorators[i])
|
|
4447
4462
|
result = (decorator(target, key, result) ) || result;
|
|
4448
|
-
if (result) __defProp$
|
|
4463
|
+
if (result) __defProp$M(target, key, result);
|
|
4449
4464
|
return result;
|
|
4450
4465
|
};
|
|
4451
4466
|
class VertexAttribute extends Resource {
|
|
@@ -4741,13 +4756,13 @@ class UvGeometry extends Geometry {
|
|
|
4741
4756
|
}
|
|
4742
4757
|
}
|
|
4743
4758
|
|
|
4744
|
-
var __defProp$
|
|
4759
|
+
var __defProp$L = Object.defineProperty;
|
|
4745
4760
|
var __decorateClass$V = (decorators, target, key, kind) => {
|
|
4746
4761
|
var result = void 0 ;
|
|
4747
4762
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
4748
4763
|
if (decorator = decorators[i])
|
|
4749
4764
|
result = (decorator(target, key, result) ) || result;
|
|
4750
|
-
if (result) __defProp$
|
|
4765
|
+
if (result) __defProp$L(target, key, result);
|
|
4751
4766
|
return result;
|
|
4752
4767
|
};
|
|
4753
4768
|
class Texture2D extends Resource {
|
|
@@ -4918,13 +4933,13 @@ class AnimatedTexture extends Resource {
|
|
|
4918
4933
|
}
|
|
4919
4934
|
}
|
|
4920
4935
|
|
|
4921
|
-
var __defProp$
|
|
4936
|
+
var __defProp$K = Object.defineProperty;
|
|
4922
4937
|
var __decorateClass$U = (decorators, target, key, kind) => {
|
|
4923
4938
|
var result = void 0 ;
|
|
4924
4939
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
4925
4940
|
if (decorator = decorators[i])
|
|
4926
4941
|
result = (decorator(target, key, result) ) || result;
|
|
4927
|
-
if (result) __defProp$
|
|
4942
|
+
if (result) __defProp$K(target, key, result);
|
|
4928
4943
|
return result;
|
|
4929
4944
|
};
|
|
4930
4945
|
class CanvasTexture extends Texture2D {
|
|
@@ -5163,13 +5178,13 @@ class PixelsTexture extends Texture2D {
|
|
|
5163
5178
|
}
|
|
5164
5179
|
}
|
|
5165
5180
|
|
|
5166
|
-
var __defProp$
|
|
5181
|
+
var __defProp$J = Object.defineProperty;
|
|
5167
5182
|
var __decorateClass$T = (decorators, target, key, kind) => {
|
|
5168
5183
|
var result = void 0 ;
|
|
5169
5184
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
5170
5185
|
if (decorator = decorators[i])
|
|
5171
5186
|
result = (decorator(target, key, result) ) || result;
|
|
5172
|
-
if (result) __defProp$
|
|
5187
|
+
if (result) __defProp$J(target, key, result);
|
|
5173
5188
|
return result;
|
|
5174
5189
|
};
|
|
5175
5190
|
function resolveOptions(options) {
|
|
@@ -5646,14 +5661,14 @@ class Children extends Array {
|
|
|
5646
5661
|
}
|
|
5647
5662
|
}
|
|
5648
5663
|
|
|
5649
|
-
var __defProp$
|
|
5664
|
+
var __defProp$I = Object.defineProperty;
|
|
5650
5665
|
var __getOwnPropDesc$J = Object.getOwnPropertyDescriptor;
|
|
5651
5666
|
var __decorateClass$S = (decorators, target, key, kind) => {
|
|
5652
5667
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$J(target, key) : target;
|
|
5653
5668
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
5654
5669
|
if (decorator = decorators[i])
|
|
5655
5670
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
5656
|
-
if (kind && result) __defProp$
|
|
5671
|
+
if (kind && result) __defProp$I(target, key, result);
|
|
5657
5672
|
return result;
|
|
5658
5673
|
};
|
|
5659
5674
|
const iidMap = {};
|
|
@@ -6165,14 +6180,14 @@ Node = __decorateClass$S([
|
|
|
6165
6180
|
customNode("Node")
|
|
6166
6181
|
], Node);
|
|
6167
6182
|
|
|
6168
|
-
var __defProp$
|
|
6183
|
+
var __defProp$H = Object.defineProperty;
|
|
6169
6184
|
var __getOwnPropDesc$I = Object.getOwnPropertyDescriptor;
|
|
6170
6185
|
var __decorateClass$R = (decorators, target, key, kind) => {
|
|
6171
6186
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$I(target, key) : target;
|
|
6172
6187
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6173
6188
|
if (decorator = decorators[i])
|
|
6174
6189
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
6175
|
-
if (kind && result) __defProp$
|
|
6190
|
+
if (kind && result) __defProp$H(target, key, result);
|
|
6176
6191
|
return result;
|
|
6177
6192
|
};
|
|
6178
6193
|
let TimelineNode = class extends Node {
|
|
@@ -6194,7 +6209,7 @@ let TimelineNode = class extends Node {
|
|
|
6194
6209
|
return this._parent?.startTime ?? 0;
|
|
6195
6210
|
}
|
|
6196
6211
|
get currentTime() {
|
|
6197
|
-
return clamp(
|
|
6212
|
+
return clamp(this._currentTime, 0, this.computedDuration);
|
|
6198
6213
|
}
|
|
6199
6214
|
get startTime() {
|
|
6200
6215
|
return this._startTime;
|
|
@@ -6207,7 +6222,7 @@ let TimelineNode = class extends Node {
|
|
|
6207
6222
|
return this._startTime + this.computedDuration;
|
|
6208
6223
|
}
|
|
6209
6224
|
get currentTimeProgress() {
|
|
6210
|
-
return this.computedDuration ? clamp(
|
|
6225
|
+
return this.computedDuration ? clamp(this._currentTime / this.computedDuration, 0, 1) : 0;
|
|
6211
6226
|
}
|
|
6212
6227
|
isInsideTimeRange() {
|
|
6213
6228
|
const current = this._currentTime;
|
|
@@ -6248,14 +6263,14 @@ TimelineNode = __decorateClass$R([
|
|
|
6248
6263
|
customNode("TimelineNode")
|
|
6249
6264
|
], TimelineNode);
|
|
6250
6265
|
|
|
6251
|
-
var __defProp$
|
|
6266
|
+
var __defProp$G = Object.defineProperty;
|
|
6252
6267
|
var __getOwnPropDesc$H = Object.getOwnPropertyDescriptor;
|
|
6253
6268
|
var __decorateClass$Q = (decorators, target, key, kind) => {
|
|
6254
6269
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$H(target, key) : target;
|
|
6255
6270
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6256
6271
|
if (decorator = decorators[i])
|
|
6257
6272
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
6258
|
-
if (kind && result) __defProp$
|
|
6273
|
+
if (kind && result) __defProp$G(target, key, result);
|
|
6259
6274
|
return result;
|
|
6260
6275
|
};
|
|
6261
6276
|
let CanvasItem = class extends TimelineNode {
|
|
@@ -6329,7 +6344,7 @@ let CanvasItem = class extends TimelineNode {
|
|
|
6329
6344
|
}
|
|
6330
6345
|
_updateGlobalOpacity() {
|
|
6331
6346
|
this._parentGlobalOpacity = this.getParent()?.opacity;
|
|
6332
|
-
const globalOpacity = clamp(
|
|
6347
|
+
const globalOpacity = clamp(this.opacity, 0, 1) * (this._parentGlobalOpacity ?? 1);
|
|
6333
6348
|
if (this._globalOpacity !== globalOpacity) {
|
|
6334
6349
|
this._globalOpacity = globalOpacity;
|
|
6335
6350
|
this.requestRepaint();
|
|
@@ -6423,14 +6438,14 @@ CanvasItem = __decorateClass$Q([
|
|
|
6423
6438
|
customNode("CanvasItem")
|
|
6424
6439
|
], CanvasItem);
|
|
6425
6440
|
|
|
6426
|
-
var __defProp$
|
|
6441
|
+
var __defProp$F = Object.defineProperty;
|
|
6427
6442
|
var __getOwnPropDesc$G = Object.getOwnPropertyDescriptor;
|
|
6428
6443
|
var __decorateClass$P = (decorators, target, key, kind) => {
|
|
6429
6444
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$G(target, key) : target;
|
|
6430
6445
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6431
6446
|
if (decorator = decorators[i])
|
|
6432
6447
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
6433
|
-
if (kind && result) __defProp$
|
|
6448
|
+
if (kind && result) __defProp$F(target, key, result);
|
|
6434
6449
|
return result;
|
|
6435
6450
|
};
|
|
6436
6451
|
let Viewport = class extends Node {
|
|
@@ -6587,14 +6602,14 @@ Viewport = __decorateClass$P([
|
|
|
6587
6602
|
customNode("Viewport")
|
|
6588
6603
|
], Viewport);
|
|
6589
6604
|
|
|
6590
|
-
var __defProp$
|
|
6605
|
+
var __defProp$E = Object.defineProperty;
|
|
6591
6606
|
var __getOwnPropDesc$F = Object.getOwnPropertyDescriptor;
|
|
6592
6607
|
var __decorateClass$O = (decorators, target, key, kind) => {
|
|
6593
6608
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$F(target, key) : target;
|
|
6594
6609
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6595
6610
|
if (decorator = decorators[i])
|
|
6596
6611
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
6597
|
-
if (kind && result) __defProp$
|
|
6612
|
+
if (kind && result) __defProp$E(target, key, result);
|
|
6598
6613
|
return result;
|
|
6599
6614
|
};
|
|
6600
6615
|
let Effect = class extends TimelineNode {
|
|
@@ -6878,14 +6893,14 @@ class RenderStack {
|
|
|
6878
6893
|
}
|
|
6879
6894
|
}
|
|
6880
6895
|
|
|
6881
|
-
var __defProp$
|
|
6896
|
+
var __defProp$D = Object.defineProperty;
|
|
6882
6897
|
var __getOwnPropDesc$E = Object.getOwnPropertyDescriptor;
|
|
6883
6898
|
var __decorateClass$N = (decorators, target, key, kind) => {
|
|
6884
6899
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$E(target, key) : target;
|
|
6885
6900
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6886
6901
|
if (decorator = decorators[i])
|
|
6887
6902
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
6888
|
-
if (kind && result) __defProp$
|
|
6903
|
+
if (kind && result) __defProp$D(target, key, result);
|
|
6889
6904
|
return result;
|
|
6890
6905
|
};
|
|
6891
6906
|
let Timeline = class extends Node {
|
|
@@ -6920,7 +6935,7 @@ let Timeline = class extends Node {
|
|
|
6920
6935
|
if (this.loop && current > end) {
|
|
6921
6936
|
current = start + current % end;
|
|
6922
6937
|
}
|
|
6923
|
-
current = clamp(
|
|
6938
|
+
current = clamp(current, start, end);
|
|
6924
6939
|
this.currentTime = current;
|
|
6925
6940
|
this.emit("updateCurrentTime", current, delta);
|
|
6926
6941
|
return this;
|
|
@@ -6961,13 +6976,13 @@ Window = __decorateClass$M([
|
|
|
6961
6976
|
customNode("Window")
|
|
6962
6977
|
], Window);
|
|
6963
6978
|
|
|
6964
|
-
var __defProp$
|
|
6979
|
+
var __defProp$C = Object.defineProperty;
|
|
6965
6980
|
var __decorateClass$L = (decorators, target, key, kind) => {
|
|
6966
6981
|
var result = void 0 ;
|
|
6967
6982
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6968
6983
|
if (decorator = decorators[i])
|
|
6969
6984
|
result = (decorator(target, key, result) ) || result;
|
|
6970
|
-
if (result) __defProp$
|
|
6985
|
+
if (result) __defProp$C(target, key, result);
|
|
6971
6986
|
return result;
|
|
6972
6987
|
};
|
|
6973
6988
|
class SceneTree extends MainLoop {
|
|
@@ -7071,14 +7086,14 @@ Transition = __decorateClass$K([
|
|
|
7071
7086
|
})
|
|
7072
7087
|
], Transition);
|
|
7073
7088
|
|
|
7074
|
-
var __defProp$
|
|
7089
|
+
var __defProp$B = Object.defineProperty;
|
|
7075
7090
|
var __getOwnPropDesc$B = Object.getOwnPropertyDescriptor;
|
|
7076
7091
|
var __decorateClass$J = (decorators, target, key, kind) => {
|
|
7077
7092
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$B(target, key) : target;
|
|
7078
7093
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7079
7094
|
if (decorator = decorators[i])
|
|
7080
7095
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
7081
|
-
if (kind && result) __defProp$
|
|
7096
|
+
if (kind && result) __defProp$B(target, key, result);
|
|
7082
7097
|
return result;
|
|
7083
7098
|
};
|
|
7084
7099
|
let Node2D = class extends CanvasItem {
|
|
@@ -7191,22 +7206,36 @@ Node2D = __decorateClass$J([
|
|
|
7191
7206
|
customNode("Node2D")
|
|
7192
7207
|
], Node2D);
|
|
7193
7208
|
|
|
7194
|
-
var __defProp$B = Object.defineProperty;
|
|
7195
7209
|
var __getOwnPropDesc$A = Object.getOwnPropertyDescriptor;
|
|
7196
7210
|
var __decorateClass$I = (decorators, target, key, kind) => {
|
|
7197
7211
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$A(target, key) : target;
|
|
7198
7212
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7199
7213
|
if (decorator = decorators[i])
|
|
7200
|
-
result = (
|
|
7201
|
-
if (kind && result) __defProp$B(target, key, result);
|
|
7214
|
+
result = (decorator(result)) || result;
|
|
7202
7215
|
return result;
|
|
7203
7216
|
};
|
|
7204
7217
|
let Camera2D = class extends Node2D {
|
|
7205
7218
|
zoom = new Vector2(1, 1).on("update", () => this.updateCanvasTransform());
|
|
7219
|
+
maxZoom = new Vector2(6, 6);
|
|
7220
|
+
minZoom = new Vector2(0.1, 0.1);
|
|
7206
7221
|
constructor(properties, nodes = []) {
|
|
7207
7222
|
super();
|
|
7208
7223
|
this.setProperties(properties).append(nodes);
|
|
7209
7224
|
}
|
|
7225
|
+
addZoom(x, y = x) {
|
|
7226
|
+
this.zoom.set(
|
|
7227
|
+
clamp(this.zoom.x + x, this.minZoom.x, this.maxZoom.x),
|
|
7228
|
+
clamp(this.zoom.y + y, this.minZoom.y, this.maxZoom.y)
|
|
7229
|
+
);
|
|
7230
|
+
return this;
|
|
7231
|
+
}
|
|
7232
|
+
setZoom(x, y = x) {
|
|
7233
|
+
this.zoom.set(
|
|
7234
|
+
clamp(x, this.minZoom.x, this.maxZoom.x),
|
|
7235
|
+
clamp(y, this.minZoom.y, this.maxZoom.y)
|
|
7236
|
+
);
|
|
7237
|
+
return this;
|
|
7238
|
+
}
|
|
7210
7239
|
_input(event, key) {
|
|
7211
7240
|
super._input(event, key);
|
|
7212
7241
|
if (key === "wheel") {
|
|
@@ -7215,24 +7244,17 @@ let Camera2D = class extends Node2D {
|
|
|
7215
7244
|
const isTouchPad = e.wheelDeltaY ? Math.abs(Math.abs(e.wheelDeltaY) - Math.abs(3 * e.deltaY)) < 3 : e.deltaMode === 0;
|
|
7216
7245
|
if (!isTouchPad) {
|
|
7217
7246
|
e.preventDefault();
|
|
7218
|
-
const
|
|
7219
|
-
|
|
7220
|
-
const ratio = 1 -
|
|
7221
|
-
this.
|
|
7222
|
-
zoom,
|
|
7223
|
-
zoom
|
|
7224
|
-
]);
|
|
7225
|
-
this.position.add([
|
|
7247
|
+
const oldZoom = this.zoom.x;
|
|
7248
|
+
this.addZoom(e.deltaY * -0.015);
|
|
7249
|
+
const ratio = 1 - this.zoom.x / oldZoom;
|
|
7250
|
+
this.position.add(
|
|
7226
7251
|
(e.screenX - this.position.x) * ratio,
|
|
7227
7252
|
(e.screenY - this.position.y) * ratio
|
|
7228
|
-
|
|
7253
|
+
);
|
|
7229
7254
|
}
|
|
7230
7255
|
} else {
|
|
7231
7256
|
e.preventDefault();
|
|
7232
|
-
this.position.add(
|
|
7233
|
-
-e.deltaX,
|
|
7234
|
-
-e.deltaY
|
|
7235
|
-
]);
|
|
7257
|
+
this.position.add(-e.deltaX, -e.deltaY);
|
|
7236
7258
|
}
|
|
7237
7259
|
}
|
|
7238
7260
|
}
|
|
@@ -7245,16 +7267,14 @@ let Camera2D = class extends Node2D {
|
|
|
7245
7267
|
if (!viewport)
|
|
7246
7268
|
return;
|
|
7247
7269
|
viewport.canvasTransform.identity().scale(this.zoom.x, this.zoom.y).translate(this.position.x, this.position.y);
|
|
7270
|
+
this.emit("updateCanvasTransform");
|
|
7248
7271
|
}
|
|
7249
7272
|
};
|
|
7250
|
-
__decorateClass$I([
|
|
7251
|
-
property({ fallback: 6 })
|
|
7252
|
-
], Camera2D.prototype, "maxZoom", 2);
|
|
7253
|
-
__decorateClass$I([
|
|
7254
|
-
property({ fallback: 0.1 })
|
|
7255
|
-
], Camera2D.prototype, "minZoom", 2);
|
|
7256
7273
|
Camera2D = __decorateClass$I([
|
|
7257
|
-
customNode("Camera2D"
|
|
7274
|
+
customNode("Camera2D", {
|
|
7275
|
+
processMode: "disabled",
|
|
7276
|
+
renderMode: "disabled"
|
|
7277
|
+
})
|
|
7258
7278
|
], Camera2D);
|
|
7259
7279
|
|
|
7260
7280
|
const defaultFilters = {
|
|
@@ -9972,10 +9992,14 @@ let BaseElement2D = class extends Node2D {
|
|
|
9972
9992
|
case "pointermove":
|
|
9973
9993
|
case "pointerup": {
|
|
9974
9994
|
if (this.canPointerEvents()) {
|
|
9975
|
-
|
|
9995
|
+
let { screenX, screenY } = event;
|
|
9976
9996
|
if (screenX && screenY) {
|
|
9977
|
-
const
|
|
9978
|
-
if (
|
|
9997
|
+
const viewport = this.getViewport();
|
|
9998
|
+
if (viewport) {
|
|
9999
|
+
[screenX, screenY] = viewport.canvasTransform.inverse().applyToPoint(screenX, screenY);
|
|
10000
|
+
}
|
|
10001
|
+
[screenX, screenY] = this.globalTransform.inverse().applyToPoint(screenX, screenY);
|
|
10002
|
+
if (this._pointerInput({ x: screenX, y: screenY }, key)) {
|
|
9979
10003
|
if (!event.target) {
|
|
9980
10004
|
event.target = this;
|
|
9981
10005
|
}
|
|
@@ -10932,7 +10956,7 @@ let Animation = class extends TimelineNode {
|
|
|
10932
10956
|
const offset = 1 / targets.length;
|
|
10933
10957
|
const progress = this.currentTimeProgress;
|
|
10934
10958
|
targets.forEach((target, i) => {
|
|
10935
|
-
const tiem = offset === 1 ? progress : clamp(
|
|
10959
|
+
const tiem = offset === 1 ? progress : clamp(Math.max(0, progress - offset * i) / offset, 0, 1);
|
|
10936
10960
|
const startProps = this._cachedProps.get(target);
|
|
10937
10961
|
if (!startProps)
|
|
10938
10962
|
return;
|
|
@@ -11098,13 +11122,13 @@ let Animation = class extends TimelineNode {
|
|
|
11098
11122
|
}
|
|
11099
11123
|
};
|
|
11100
11124
|
__decorateClass$e([
|
|
11101
|
-
property()
|
|
11125
|
+
property({ fallback: "parent" })
|
|
11102
11126
|
], Animation.prototype, "effectMode", 2);
|
|
11103
11127
|
__decorateClass$e([
|
|
11104
|
-
property()
|
|
11128
|
+
property({ fallback: false })
|
|
11105
11129
|
], Animation.prototype, "loop", 2);
|
|
11106
11130
|
__decorateClass$e([
|
|
11107
|
-
property()
|
|
11131
|
+
property({ default: () => [] })
|
|
11108
11132
|
], Animation.prototype, "keyframes", 2);
|
|
11109
11133
|
__decorateClass$e([
|
|
11110
11134
|
property()
|
|
@@ -12764,7 +12788,7 @@ let Scaler = class extends Node {
|
|
|
12764
12788
|
case "scale":
|
|
12765
12789
|
case "min":
|
|
12766
12790
|
case "max": {
|
|
12767
|
-
this.scale = clamp(this.
|
|
12791
|
+
this.scale = clamp(this.scale, this.minScale, this.maxScale);
|
|
12768
12792
|
this._updateTarget();
|
|
12769
12793
|
break;
|
|
12770
12794
|
}
|