modern-canvas 0.4.15 → 0.4.17
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 +131 -177
- package/dist/index.d.cts +19 -34
- package/dist/index.d.mts +19 -34
- package/dist/index.d.ts +19 -34
- package/dist/index.js +38 -38
- package/dist/index.mjs +131 -177
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1295,6 +1295,7 @@ class Matrix extends EventEmitter {
|
|
|
1295
1295
|
}
|
|
1296
1296
|
}
|
|
1297
1297
|
_array = [];
|
|
1298
|
+
dirtyId = 0;
|
|
1298
1299
|
get length() {
|
|
1299
1300
|
return this.cols * this.rows;
|
|
1300
1301
|
}
|
|
@@ -1399,6 +1400,7 @@ class Matrix extends EventEmitter {
|
|
|
1399
1400
|
return this._operate("*", value, output);
|
|
1400
1401
|
}
|
|
1401
1402
|
_onUpdate(_array) {
|
|
1403
|
+
this.dirtyId++;
|
|
1402
1404
|
}
|
|
1403
1405
|
toArray(transpose = false) {
|
|
1404
1406
|
const { cols, rows, _array: array } = this;
|
|
@@ -1980,150 +1982,90 @@ class Rect2 {
|
|
|
1980
1982
|
}
|
|
1981
1983
|
|
|
1982
1984
|
class Transform2D extends Matrix3 {
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
this
|
|
1986
|
-
}
|
|
1987
|
-
_cx = 1;
|
|
1988
|
-
_sx = 0;
|
|
1989
|
-
_cy = 0;
|
|
1990
|
-
_sy = 1;
|
|
1991
|
-
_translateX = 0;
|
|
1992
|
-
_translateY = 0;
|
|
1993
|
-
_translateZ = 1;
|
|
1994
|
-
_scaleX = 1;
|
|
1995
|
-
_scaleY = 1;
|
|
1996
|
-
_skewX = 0;
|
|
1997
|
-
_skewY = 0;
|
|
1998
|
-
_rotate = 0;
|
|
1999
|
-
dirtyId = 0;
|
|
2000
|
-
_needsUpdateArray = false;
|
|
2001
|
-
_needsUpdateFields = false;
|
|
2002
|
-
_onUpdate(array) {
|
|
2003
|
-
super._onUpdate(array);
|
|
2004
|
-
this._requestUpdateFields();
|
|
2005
|
-
}
|
|
2006
|
-
_updateSkew() {
|
|
2007
|
-
this._cx = Math.cos(this._rotate + this._skewY);
|
|
2008
|
-
this._sx = Math.sin(this._rotate + this._skewY);
|
|
2009
|
-
this._cy = -Math.sin(this._rotate - this._skewX);
|
|
2010
|
-
this._sy = Math.cos(this._rotate - this._skewX);
|
|
2011
|
-
}
|
|
2012
|
-
_requestUpdateArray() {
|
|
2013
|
-
if (this.autoUpdate) {
|
|
2014
|
-
this._performUpdateArray();
|
|
2015
|
-
} else {
|
|
2016
|
-
this._needsUpdateArray = true;
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
_requestUpdateFields() {
|
|
2020
|
-
if (this.autoUpdate) {
|
|
2021
|
-
this._performUpdateFields();
|
|
2022
|
-
} else {
|
|
2023
|
-
this._needsUpdateFields = true;
|
|
2024
|
-
}
|
|
2025
|
-
}
|
|
2026
|
-
_performUpdateArray() {
|
|
2027
|
-
const a = this._cx * this._scaleX;
|
|
2028
|
-
const b = this._sx * this._scaleX;
|
|
2029
|
-
const c = this._cy * this._scaleY;
|
|
2030
|
-
const d = this._sy * this._scaleY;
|
|
2031
|
-
const tx = this._translateX;
|
|
2032
|
-
const ty = this._translateY;
|
|
2033
|
-
const tz = this._translateZ;
|
|
2034
|
-
const array = this._array;
|
|
2035
|
-
this._array = [
|
|
2036
|
-
a,
|
|
2037
|
-
c,
|
|
2038
|
-
tx,
|
|
2039
|
-
b,
|
|
2040
|
-
d,
|
|
2041
|
-
ty,
|
|
2042
|
-
array[6],
|
|
2043
|
-
array[7],
|
|
2044
|
-
tz
|
|
2045
|
-
];
|
|
2046
|
-
this.dirtyId++;
|
|
2047
|
-
}
|
|
2048
|
-
_performUpdateFields() {
|
|
2049
|
-
const {
|
|
2050
|
-
a,
|
|
2051
|
-
c,
|
|
2052
|
-
tx,
|
|
2053
|
-
b,
|
|
2054
|
-
d,
|
|
2055
|
-
ty,
|
|
2056
|
-
tz
|
|
2057
|
-
} = this.toObject();
|
|
2058
|
-
const skewX = -Math.atan2(-c, d);
|
|
2059
|
-
const skewY = Math.atan2(b, a);
|
|
2060
|
-
const delta = Math.abs(skewX + skewY);
|
|
2061
|
-
if (delta < 1e-5 || Math.abs(PI_2 - delta) < 1e-5) {
|
|
2062
|
-
this._rotate = skewY;
|
|
2063
|
-
this._skewX = this._skewY = 0;
|
|
2064
|
-
} else {
|
|
2065
|
-
this._rotate = 0;
|
|
2066
|
-
this._skewX = skewX;
|
|
2067
|
-
this._skewY = skewY;
|
|
2068
|
-
}
|
|
2069
|
-
this._scaleX = Math.sqrt(a * a + b * b);
|
|
2070
|
-
this._scaleY = Math.sqrt(c * c + d * d);
|
|
2071
|
-
this._translateX = tx;
|
|
2072
|
-
this._translateY = ty;
|
|
2073
|
-
this._translateZ = tz;
|
|
2074
|
-
this.dirtyId++;
|
|
2075
|
-
}
|
|
2076
|
-
skew(x, y) {
|
|
2077
|
-
this._skewX = x;
|
|
2078
|
-
this._skewY = y;
|
|
2079
|
-
this._updateSkew();
|
|
2080
|
-
this._requestUpdateArray();
|
|
2081
|
-
return this;
|
|
1985
|
+
static _t2d = /* @__PURE__ */ new Transform2D();
|
|
1986
|
+
premultiply(t2d) {
|
|
1987
|
+
return t2d.multiply(this, this);
|
|
2082
1988
|
}
|
|
2083
1989
|
skewX(x) {
|
|
2084
|
-
return this.skew(x,
|
|
1990
|
+
return this.skew(x, 1);
|
|
2085
1991
|
}
|
|
2086
1992
|
skewY(y) {
|
|
2087
|
-
return this.skew(
|
|
1993
|
+
return this.skew(1, y);
|
|
2088
1994
|
}
|
|
2089
|
-
|
|
2090
|
-
this.
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
1995
|
+
skew(x, y) {
|
|
1996
|
+
return this.premultiply(Transform2D._t2d.makeSkew(x, y));
|
|
1997
|
+
}
|
|
1998
|
+
makeSkew(x, y) {
|
|
1999
|
+
const cx = Math.cos(y);
|
|
2000
|
+
const sx = Math.sin(y);
|
|
2001
|
+
const cy = -Math.sin(-x);
|
|
2002
|
+
const sy = Math.cos(-x);
|
|
2003
|
+
this.set([
|
|
2004
|
+
cx,
|
|
2005
|
+
cy,
|
|
2006
|
+
0,
|
|
2007
|
+
sx,
|
|
2008
|
+
sy,
|
|
2009
|
+
0,
|
|
2010
|
+
0,
|
|
2011
|
+
0,
|
|
2012
|
+
1
|
|
2013
|
+
]);
|
|
2094
2014
|
return this;
|
|
2095
2015
|
}
|
|
2096
2016
|
translateX(x) {
|
|
2097
|
-
return this.translate(x,
|
|
2017
|
+
return this.translate(x, 0);
|
|
2098
2018
|
}
|
|
2099
2019
|
translateY(y) {
|
|
2100
|
-
return this.translate(
|
|
2020
|
+
return this.translate(0, y);
|
|
2101
2021
|
}
|
|
2102
2022
|
translateZ(z) {
|
|
2103
|
-
return this.translate(
|
|
2023
|
+
return this.translate(0, 0, z);
|
|
2104
2024
|
}
|
|
2105
2025
|
translate3d(x, y, z) {
|
|
2106
2026
|
return this.translate(x, y, z);
|
|
2107
2027
|
}
|
|
2108
|
-
|
|
2109
|
-
this.
|
|
2110
|
-
|
|
2111
|
-
|
|
2028
|
+
translate(x, y, z = 0) {
|
|
2029
|
+
return this.premultiply(Transform2D._t2d.makeTranslation(x, y, z));
|
|
2030
|
+
}
|
|
2031
|
+
makeTranslation(x, y, _z = 0) {
|
|
2032
|
+
this.set([
|
|
2033
|
+
1,
|
|
2034
|
+
0,
|
|
2035
|
+
x,
|
|
2036
|
+
0,
|
|
2037
|
+
1,
|
|
2038
|
+
y,
|
|
2039
|
+
0,
|
|
2040
|
+
0,
|
|
2041
|
+
1
|
|
2042
|
+
]);
|
|
2112
2043
|
return this;
|
|
2113
2044
|
}
|
|
2114
2045
|
scaleX(x) {
|
|
2115
|
-
return this.scale(x,
|
|
2046
|
+
return this.scale(x, 1);
|
|
2116
2047
|
}
|
|
2117
2048
|
scaleY(y) {
|
|
2118
|
-
return this.scale(
|
|
2049
|
+
return this.scale(1, y);
|
|
2119
2050
|
}
|
|
2120
|
-
scale3d(x, y, z) {
|
|
2051
|
+
scale3d(x, y, z = 1) {
|
|
2121
2052
|
return this.scale(x, y, z);
|
|
2122
2053
|
}
|
|
2123
|
-
|
|
2124
|
-
this.
|
|
2125
|
-
|
|
2126
|
-
|
|
2054
|
+
scale(x, y, z = 1) {
|
|
2055
|
+
return this.premultiply(Transform2D._t2d.makeScale(x, y, z));
|
|
2056
|
+
}
|
|
2057
|
+
makeScale(x, y, z = 1) {
|
|
2058
|
+
this.set([
|
|
2059
|
+
x,
|
|
2060
|
+
0,
|
|
2061
|
+
0,
|
|
2062
|
+
0,
|
|
2063
|
+
y,
|
|
2064
|
+
0,
|
|
2065
|
+
0,
|
|
2066
|
+
0,
|
|
2067
|
+
z
|
|
2068
|
+
]);
|
|
2127
2069
|
return this;
|
|
2128
2070
|
}
|
|
2129
2071
|
rotateX(x) {
|
|
@@ -2135,6 +2077,9 @@ class Transform2D extends Matrix3 {
|
|
|
2135
2077
|
rotateZ(z) {
|
|
2136
2078
|
return this.rotate(z);
|
|
2137
2079
|
}
|
|
2080
|
+
rotate(rad) {
|
|
2081
|
+
return this.premultiply(Transform2D._t2d.makeRotation(rad));
|
|
2082
|
+
}
|
|
2138
2083
|
rotate3d(x, y, z, rad) {
|
|
2139
2084
|
const [rx, ry, rz] = this._rotate3d(x, y, z, rad);
|
|
2140
2085
|
rx && this.rotateX(rx);
|
|
@@ -2168,6 +2113,22 @@ class Transform2D extends Matrix3 {
|
|
|
2168
2113
|
return [rotateX, rotateY, rotateZ];
|
|
2169
2114
|
}
|
|
2170
2115
|
}
|
|
2116
|
+
makeRotation(theta) {
|
|
2117
|
+
const c = Math.cos(theta);
|
|
2118
|
+
const s = Math.sin(theta);
|
|
2119
|
+
this.set([
|
|
2120
|
+
c,
|
|
2121
|
+
-s,
|
|
2122
|
+
0,
|
|
2123
|
+
s,
|
|
2124
|
+
c,
|
|
2125
|
+
0,
|
|
2126
|
+
0,
|
|
2127
|
+
0,
|
|
2128
|
+
1
|
|
2129
|
+
]);
|
|
2130
|
+
return this;
|
|
2131
|
+
}
|
|
2171
2132
|
applyToPoint(x, y) {
|
|
2172
2133
|
const { a, c, tx, b, d, ty } = this.toObject();
|
|
2173
2134
|
return [
|
|
@@ -2178,20 +2139,6 @@ class Transform2D extends Matrix3 {
|
|
|
2178
2139
|
inverse() {
|
|
2179
2140
|
return this.clone().invert();
|
|
2180
2141
|
}
|
|
2181
|
-
update() {
|
|
2182
|
-
let updated = false;
|
|
2183
|
-
if (this._needsUpdateArray) {
|
|
2184
|
-
this._needsUpdateArray = false;
|
|
2185
|
-
this._performUpdateArray();
|
|
2186
|
-
updated = true;
|
|
2187
|
-
}
|
|
2188
|
-
if (this._needsUpdateFields) {
|
|
2189
|
-
this._needsUpdateFields = false;
|
|
2190
|
-
this._performUpdateFields();
|
|
2191
|
-
updated = true;
|
|
2192
|
-
}
|
|
2193
|
-
return updated;
|
|
2194
|
-
}
|
|
2195
2142
|
isIdentity() {
|
|
2196
2143
|
const { a, b, c, d, tx, ty } = this.toObject();
|
|
2197
2144
|
return a === 1 && b === 0 && c === 0 && d === 1 && tx === 0 && ty === 0;
|
|
@@ -4389,58 +4336,56 @@ function parseCSSFilter(filter) {
|
|
|
4389
4336
|
return m;
|
|
4390
4337
|
}
|
|
4391
4338
|
|
|
4392
|
-
function parseCSSTransform(transform, width, height) {
|
|
4393
|
-
const t2d = new Transform2D(false);
|
|
4339
|
+
function parseCSSTransform(transform, width, height, output = new Transform2D()) {
|
|
4394
4340
|
transform = !transform || transform === "none" ? "" : transform;
|
|
4395
4341
|
parseCssFunctions(transform, { width, height }).forEach(({ name, args }) => {
|
|
4396
4342
|
const values = args.map((arg) => arg.normalizedIntValue);
|
|
4397
|
-
const _temp = new Transform2D();
|
|
4398
4343
|
switch (name) {
|
|
4399
4344
|
case "translate":
|
|
4400
|
-
|
|
4345
|
+
output.translate(values[0] * width, (values[1] ?? values[0]) * height);
|
|
4401
4346
|
break;
|
|
4402
4347
|
case "translateX":
|
|
4403
|
-
|
|
4348
|
+
output.translateX(values[0] * width);
|
|
4404
4349
|
break;
|
|
4405
4350
|
case "translateY":
|
|
4406
|
-
|
|
4351
|
+
output.translateY(values[0] * height);
|
|
4407
4352
|
break;
|
|
4408
4353
|
case "translateZ":
|
|
4409
|
-
|
|
4354
|
+
output.translateZ(values[0]);
|
|
4410
4355
|
break;
|
|
4411
4356
|
case "translate3d":
|
|
4412
|
-
|
|
4357
|
+
output.translate3d(
|
|
4413
4358
|
values[0] * width,
|
|
4414
4359
|
(values[1] ?? values[0]) * height,
|
|
4415
4360
|
values[2] ?? values[1] ?? values[0]
|
|
4416
4361
|
);
|
|
4417
4362
|
break;
|
|
4418
4363
|
case "scale":
|
|
4419
|
-
|
|
4364
|
+
output.scale(values[0], values[1] ?? values[0]);
|
|
4420
4365
|
break;
|
|
4421
4366
|
case "scaleX":
|
|
4422
|
-
|
|
4367
|
+
output.scaleX(values[0]);
|
|
4423
4368
|
break;
|
|
4424
4369
|
case "scaleY":
|
|
4425
|
-
|
|
4370
|
+
output.scaleY(values[0]);
|
|
4426
4371
|
break;
|
|
4427
4372
|
case "scale3d":
|
|
4428
|
-
|
|
4373
|
+
output.scale3d(values[0], values[1] ?? values[0], values[2] ?? values[1] ?? values[0]);
|
|
4429
4374
|
break;
|
|
4430
4375
|
case "rotate":
|
|
4431
|
-
|
|
4376
|
+
output.rotate(values[0] * PI_2);
|
|
4432
4377
|
break;
|
|
4433
4378
|
case "rotateX":
|
|
4434
|
-
|
|
4379
|
+
output.rotateX(values[0] * PI_2);
|
|
4435
4380
|
break;
|
|
4436
4381
|
case "rotateY":
|
|
4437
|
-
|
|
4382
|
+
output.rotateY(values[0] * PI_2);
|
|
4438
4383
|
break;
|
|
4439
4384
|
case "rotateZ":
|
|
4440
|
-
|
|
4385
|
+
output.rotateZ(values[0] * PI_2);
|
|
4441
4386
|
break;
|
|
4442
4387
|
case "rotate3d":
|
|
4443
|
-
|
|
4388
|
+
output.rotate3d(
|
|
4444
4389
|
values[0] * PI_2,
|
|
4445
4390
|
(values[1] ?? values[0]) * PI_2,
|
|
4446
4391
|
(values[2] ?? values[1] ?? values[0]) * PI_2,
|
|
@@ -4448,22 +4393,20 @@ function parseCSSTransform(transform, width, height) {
|
|
|
4448
4393
|
);
|
|
4449
4394
|
break;
|
|
4450
4395
|
case "skew":
|
|
4451
|
-
|
|
4396
|
+
output.skew(values[0], values[0] ?? values[1]);
|
|
4452
4397
|
break;
|
|
4453
4398
|
case "skewX":
|
|
4454
|
-
|
|
4399
|
+
output.skewX(values[0]);
|
|
4455
4400
|
break;
|
|
4456
4401
|
case "skewY":
|
|
4457
|
-
|
|
4402
|
+
output.skewY(values[0]);
|
|
4458
4403
|
break;
|
|
4459
4404
|
case "matrix":
|
|
4460
|
-
|
|
4405
|
+
output.set(values);
|
|
4461
4406
|
break;
|
|
4462
4407
|
}
|
|
4463
|
-
t2d.multiply(_temp);
|
|
4464
4408
|
});
|
|
4465
|
-
|
|
4466
|
-
return t2d;
|
|
4409
|
+
return output;
|
|
4467
4410
|
}
|
|
4468
4411
|
|
|
4469
4412
|
function parseCSSTransformOrigin(transformOrigin) {
|
|
@@ -5823,6 +5766,22 @@ exports.Node = class Node extends CoreObject {
|
|
|
5823
5766
|
const tree = this._tree;
|
|
5824
5767
|
const canRender = this.canRender();
|
|
5825
5768
|
const canProcess = this.canProcess();
|
|
5769
|
+
const childrenInBefore = [];
|
|
5770
|
+
const childrenInAfter = [];
|
|
5771
|
+
for (let len = this._children.length, i = 0; i < len; i++) {
|
|
5772
|
+
const child = this._children[i];
|
|
5773
|
+
switch (child.processSortMode) {
|
|
5774
|
+
case "default":
|
|
5775
|
+
childrenInAfter.push(child);
|
|
5776
|
+
break;
|
|
5777
|
+
case "parent_before":
|
|
5778
|
+
childrenInBefore.push(child);
|
|
5779
|
+
break;
|
|
5780
|
+
}
|
|
5781
|
+
}
|
|
5782
|
+
childrenInBefore.forEach((child) => {
|
|
5783
|
+
child.emit("process", delta);
|
|
5784
|
+
});
|
|
5826
5785
|
if (canProcess) {
|
|
5827
5786
|
tree?.emit("nodeProcessing", this);
|
|
5828
5787
|
this.emit("processing", delta);
|
|
@@ -5845,9 +5804,9 @@ exports.Node = class Node extends CoreObject {
|
|
|
5845
5804
|
this.removeChild(mask);
|
|
5846
5805
|
}
|
|
5847
5806
|
}
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
}
|
|
5807
|
+
childrenInAfter.forEach((child) => {
|
|
5808
|
+
child.emit("process", delta);
|
|
5809
|
+
});
|
|
5851
5810
|
if (canRender) {
|
|
5852
5811
|
tree.renderStack.currentCall = oldRenderCall;
|
|
5853
5812
|
}
|
|
@@ -6115,6 +6074,9 @@ __decorateClass$I([
|
|
|
6115
6074
|
__decorateClass$I([
|
|
6116
6075
|
property({ default: "inherit" })
|
|
6117
6076
|
], exports.Node.prototype, "processMode", 2);
|
|
6077
|
+
__decorateClass$I([
|
|
6078
|
+
property({ default: "default" })
|
|
6079
|
+
], exports.Node.prototype, "processSortMode", 2);
|
|
6118
6080
|
__decorateClass$I([
|
|
6119
6081
|
property({ default: "inherit" })
|
|
6120
6082
|
], exports.Node.prototype, "renderMode", 2);
|
|
@@ -8670,7 +8632,7 @@ exports.Node2D = class Node2D extends exports.CanvasItem {
|
|
|
8670
8632
|
rotation = 0;
|
|
8671
8633
|
scale = new Vector2(1, 1);
|
|
8672
8634
|
skew = new Vector2();
|
|
8673
|
-
transform = new Transform2D(
|
|
8635
|
+
transform = new Transform2D();
|
|
8674
8636
|
globalPosition = new Vector2();
|
|
8675
8637
|
globalRotation = 0;
|
|
8676
8638
|
globalScale = new Vector2();
|
|
@@ -8682,7 +8644,7 @@ exports.Node2D = class Node2D extends exports.CanvasItem {
|
|
|
8682
8644
|
this.setProperties(properties).append(nodes);
|
|
8683
8645
|
}
|
|
8684
8646
|
_updateTransform() {
|
|
8685
|
-
this.transform.identity().scale(this.scale.x, this.scale.y).skew(this.skew.x, this.skew.y).translate(this.position.x, this.position.y)
|
|
8647
|
+
this.transform.identity().scale(this.scale.x, this.scale.y).skew(this.skew.x, this.skew.y).rotate(this.rotation).translate(this.position.x, this.position.y);
|
|
8686
8648
|
}
|
|
8687
8649
|
_updateGlobalTransform() {
|
|
8688
8650
|
const parent = this.getParent();
|
|
@@ -8885,17 +8847,13 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
|
|
|
8885
8847
|
this.requestRedraw();
|
|
8886
8848
|
}
|
|
8887
8849
|
_updateTransform() {
|
|
8888
|
-
super._updateTransform();
|
|
8889
8850
|
const { width, height } = this.size;
|
|
8890
|
-
const cssTransform = parseCSSTransform(this.style.transform, width, height);
|
|
8891
|
-
cssTransform.multiply(this.transform, this.transform);
|
|
8892
|
-
const t3dT2dArr = this.transform.toArray();
|
|
8893
8851
|
const [originX, originY] = parseCSSTransformOrigin(this.style.transformOrigin);
|
|
8894
8852
|
const offsetX = originX * width;
|
|
8895
8853
|
const offsetY = originY * height;
|
|
8896
|
-
|
|
8897
|
-
|
|
8898
|
-
this.transform.
|
|
8854
|
+
this.transform.identity().translate(-offsetX, -offsetY).scale(this.scale.x, this.scale.y).skew(this.skew.x, this.skew.y).rotate(this.rotation);
|
|
8855
|
+
parseCSSTransform(this.style.transform, width, height, this.transform);
|
|
8856
|
+
this.transform.translate(offsetX + this.position.x, offsetY + this.position.y);
|
|
8899
8857
|
}
|
|
8900
8858
|
_updateGlobalTransform() {
|
|
8901
8859
|
super._updateGlobalTransform();
|
|
@@ -10176,19 +10134,14 @@ exports.Animation = class Animation extends exports.TimelineNode {
|
|
|
10176
10134
|
_stoped = false;
|
|
10177
10135
|
constructor(properties, children = []) {
|
|
10178
10136
|
super();
|
|
10179
|
-
this._process = this._process.bind(this);
|
|
10180
10137
|
this.setProperties(properties).append(children);
|
|
10181
10138
|
}
|
|
10182
|
-
_treeEnter(
|
|
10183
|
-
tree.timeline.on("updateCurrentTime", this._process);
|
|
10139
|
+
_treeEnter(_tree) {
|
|
10184
10140
|
this._updateCachedProps();
|
|
10185
10141
|
}
|
|
10186
|
-
_treeExit(
|
|
10187
|
-
oldTree.timeline.on("updateCurrentTime", this._process);
|
|
10142
|
+
_treeExit(_oldTree) {
|
|
10188
10143
|
this.cancel();
|
|
10189
10144
|
}
|
|
10190
|
-
_onProcess() {
|
|
10191
|
-
}
|
|
10192
10145
|
_process() {
|
|
10193
10146
|
if (this.canProcess()) {
|
|
10194
10147
|
this.commitStyles();
|
|
@@ -10447,6 +10400,7 @@ exports.Animation = __decorateClass$d([
|
|
|
10447
10400
|
customNode("Animation", {
|
|
10448
10401
|
renderMode: "disabled",
|
|
10449
10402
|
processMode: "pausable",
|
|
10403
|
+
processSortMode: "parent_before",
|
|
10450
10404
|
duration: 2e3
|
|
10451
10405
|
})
|
|
10452
10406
|
], exports.Animation);
|
package/dist/index.d.cts
CHANGED
|
@@ -356,6 +356,7 @@ declare abstract class Matrix extends EventEmitter {
|
|
|
356
356
|
readonly rows: number;
|
|
357
357
|
readonly cols: number;
|
|
358
358
|
protected _array: number[];
|
|
359
|
+
dirtyId: number;
|
|
359
360
|
get length(): number;
|
|
360
361
|
constructor(rows: number, cols: number, array?: number[]);
|
|
361
362
|
protected _operate(operator: string, target: MatrixLike | Vector, output?: MatrixOperateOutput): any;
|
|
@@ -509,51 +510,33 @@ interface Transform2DObject {
|
|
|
509
510
|
* | 0 | 0 | 1 |
|
|
510
511
|
*/
|
|
511
512
|
declare class Transform2D extends Matrix3 {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
protected _sx: number;
|
|
515
|
-
protected _cy: number;
|
|
516
|
-
protected _sy: number;
|
|
517
|
-
protected _translateX: number;
|
|
518
|
-
protected _translateY: number;
|
|
519
|
-
protected _translateZ: number;
|
|
520
|
-
protected _scaleX: number;
|
|
521
|
-
protected _scaleY: number;
|
|
522
|
-
protected _skewX: number;
|
|
523
|
-
protected _skewY: number;
|
|
524
|
-
protected _rotate: number;
|
|
525
|
-
dirtyId: number;
|
|
526
|
-
protected _needsUpdateArray: boolean;
|
|
527
|
-
protected _needsUpdateFields: boolean;
|
|
528
|
-
constructor(autoUpdate?: boolean);
|
|
529
|
-
protected _onUpdate(array: number[]): void;
|
|
530
|
-
protected _updateSkew(): void;
|
|
531
|
-
protected _requestUpdateArray(): void;
|
|
532
|
-
protected _requestUpdateFields(): void;
|
|
533
|
-
protected _performUpdateArray(): void;
|
|
534
|
-
protected _performUpdateFields(): void;
|
|
535
|
-
skew(x: number, y: number): this;
|
|
513
|
+
private static _t2d;
|
|
514
|
+
premultiply(t2d: Transform2D): this;
|
|
536
515
|
skewX(x: number): this;
|
|
537
516
|
skewY(y: number): this;
|
|
538
|
-
|
|
517
|
+
skew(x: number, y: number): this;
|
|
518
|
+
makeSkew(x: number, y: number): this;
|
|
539
519
|
translateX(x: number): this;
|
|
540
520
|
translateY(y: number): this;
|
|
541
521
|
translateZ(z: number): this;
|
|
542
522
|
translate3d(x: number, y: number, z: number): this;
|
|
543
|
-
|
|
523
|
+
translate(x: number, y: number, z?: number): this;
|
|
524
|
+
makeTranslation(x: number, y: number, _z?: number): this;
|
|
544
525
|
scaleX(x: number): this;
|
|
545
526
|
scaleY(y: number): this;
|
|
546
|
-
scale3d(x: number, y: number, z
|
|
547
|
-
|
|
527
|
+
scale3d(x: number, y: number, z?: number): this;
|
|
528
|
+
scale(x: number, y: number, z?: number): this;
|
|
529
|
+
makeScale(x: number, y: number, z?: number): this;
|
|
548
530
|
rotateX(x: number): this;
|
|
549
531
|
rotateY(y: number): this;
|
|
550
532
|
rotateZ(z: number): this;
|
|
533
|
+
rotate(rad: number): this;
|
|
551
534
|
rotate3d(x: number, y: number, z: number, rad: number): this;
|
|
552
535
|
protected _rotateToScale(rad: number): number;
|
|
553
536
|
protected _rotate3d(x: number, y: number, z: number, rad: number): number[];
|
|
537
|
+
makeRotation(theta: number): this;
|
|
554
538
|
applyToPoint(x: number, y: number): number[];
|
|
555
539
|
inverse(): this;
|
|
556
|
-
update(): boolean;
|
|
557
540
|
isIdentity(): boolean;
|
|
558
541
|
toObject(): Transform2DObject;
|
|
559
542
|
}
|
|
@@ -1611,11 +1594,13 @@ interface NodeEventMap extends CoreObjectEventMap, InputEventMap {
|
|
|
1611
1594
|
moveChild: (child: Node, newIndex: number, oldIndex: number) => void;
|
|
1612
1595
|
}
|
|
1613
1596
|
type ProcessMode = 'inherit' | 'pausable' | 'when_paused' | 'always' | 'disabled';
|
|
1597
|
+
type ProcessSortMode = 'default' | 'parent_before';
|
|
1614
1598
|
type RenderMode = 'inherit' | 'always' | 'disabled';
|
|
1615
1599
|
type InternalMode = 'default' | 'front' | 'back';
|
|
1616
1600
|
interface NodeProperties {
|
|
1617
1601
|
name: string;
|
|
1618
1602
|
processMode: ProcessMode;
|
|
1603
|
+
processSortMode: ProcessSortMode;
|
|
1619
1604
|
renderMode: RenderMode;
|
|
1620
1605
|
internalMode: InternalMode;
|
|
1621
1606
|
mask: Maskable;
|
|
@@ -1631,6 +1616,7 @@ declare class Node extends CoreObject {
|
|
|
1631
1616
|
name: string;
|
|
1632
1617
|
mask?: Maskable;
|
|
1633
1618
|
processMode: ProcessMode;
|
|
1619
|
+
processSortMode: ProcessSortMode;
|
|
1634
1620
|
renderMode: RenderMode;
|
|
1635
1621
|
internalMode: InternalMode;
|
|
1636
1622
|
protected _readyed: boolean;
|
|
@@ -2225,9 +2211,8 @@ declare class Animation extends TimelineNode {
|
|
|
2225
2211
|
protected _cachedProps: RawWeakMap<any, Map<string, any>>;
|
|
2226
2212
|
protected _stoped: boolean;
|
|
2227
2213
|
constructor(properties?: Partial<AnimationProperties>, children?: Node[]);
|
|
2228
|
-
protected _treeEnter(
|
|
2229
|
-
protected _treeExit(
|
|
2230
|
-
protected _onProcess(): void;
|
|
2214
|
+
protected _treeEnter(_tree: SceneTree): void;
|
|
2215
|
+
protected _treeExit(_oldTree: SceneTree): void;
|
|
2231
2216
|
protected _process(): void;
|
|
2232
2217
|
protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
|
|
2233
2218
|
protected _getTargets(): any[];
|
|
@@ -2913,7 +2898,7 @@ type CSSFilterKey = 'hue-rotate' | 'saturate' | 'brightness' | 'contrast' | 'inv
|
|
|
2913
2898
|
type CSSFilters = Record<CSSFilterKey, number>;
|
|
2914
2899
|
declare function parseCSSFilter(filter: string): ColorMatrix;
|
|
2915
2900
|
|
|
2916
|
-
declare function parseCSSTransform(transform: string, width: number, height: number): Transform2D;
|
|
2901
|
+
declare function parseCSSTransform(transform: string, width: number, height: number, output?: Transform2D): Transform2D;
|
|
2917
2902
|
|
|
2918
2903
|
declare function parseCSSTransformOrigin(transformOrigin: string): number[];
|
|
2919
2904
|
|
|
@@ -3017,4 +3002,4 @@ interface RenderOptions {
|
|
|
3017
3002
|
}
|
|
3018
3003
|
declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
|
|
3019
3004
|
|
|
3020
|
-
export { AnimatedTexture, Animation, type AnimationEffectMode, type AnimationProperties, type AssetHandler, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, type AudioWaveformProperties, BaseElement2D, type BaseElement2DEventMap, type BaseElement2DProperties, BaseElement2DStyle, type BaseElement2DStyleProperties, type Batchable2D, BlurEffect, type CSSFilterKey, type CSSFilters, type CanvasBatchable, CanvasContext, CanvasItem, CanvasItemEditor, type CanvasItemEventMap, type CanvasItemProperties, CanvasTexture, Color, ColorAdjustEffect, ColorFilterEffect, type ColorFilterEffectProperties, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, type ColorValue, type ComputedLayout, Control, type ControlEventMap, type ControlProperties, CoreObject, type CoreObjectEventMap, type CssFunction, type CssFunctionArg, type Cursor, DEG_TO_RAD, DEVICE_PIXEL_RATIO, type Easing, Effect, type EffectContext, EffectMaterial, type EffectMode, type EffectProperties, Element2D, type Element2DEventMap, type Element2DProperties, Element2DStyle, type Element2DStyleProperties, EmbossEffect, Engine, type EngineOptions, EventEmitter, type EventListener, type EventListenerOptions, type EventListenerValue, type FillDraw, type FlexBaseElement2DEventMap, FlexElement2D, type FlexElement2DProperties, FlexElement2DStyle, type FlexElement2DStyleProperties, FlexLayout, FontLoader, GIFLoader, Geometry, type GeometryOptions, GlitchEffect, GodrayEffect, Graphics2D, HTMLAudio, HTMLAudioContext, HTMLSound, type IAudioContext, type IAudioNode, IN_BROWSER, type IPlayOptions, Image2D, type Image2DProperties, type ImageFrame, ImageTexture, type ImageTextureOptions, IndexBuffer, type IndexBufferOptions, Input, InputEvent, type InputEventKey, type InputEventMap, type InternalMode, JSONLoader, KawaseTransition, type Keyframe, LeftEraseTransition, Loader, Lottie2D, type Lottie2DProperties, LottieLoader, MainLoop, type MainLoopEventMap, type MaskColor, type MaskData, MaskEffect, type MaskEffectProperties, type MaskObject, type MaskRect, type Maskable, Material, type MaterialOptions, Matrix, Matrix2, Matrix3, Matrix4, type MatrixLike, type MatrixOperateOutput, MouseInputEvent, Node, Node2D, type Node2DProperties, type NodeEventMap, type NodeProperties, type NormalizedKeyframe, PI, PI_2, PixelateEffect, PixelsTexture, type PlatformAudio, type PlatformSound, PointerInputEvent, type ProcessMode, Projection2D, type PropertyDeclaration, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, Range, type RangeProperties, RawWeakMap, Rect2, type Rectangulable, type RectangulableEventMap, RefCounted, type RefCountedEventMap, type RenderMode, type RenderOptions, type Renderable, Renderer, Resource, type ResourceEventMap, Ruler, type RulerProperties, SUPPORTS_AUDIO_CONTEXT, SUPPORTS_CLICK_EVENTS, SUPPORTS_CREATE_IMAGE_BITMAP, SUPPORTS_IMAGE_BITMAP, SUPPORTS_MOUSE_EVENTS, SUPPORTS_OFFLINE_AUDIO_CONTEXT, SUPPORTS_POINTER_EVENTS, SUPPORTS_RESIZE_OBSERVER, SUPPORTS_TOUCH_EVENTS, SUPPORTS_WEBGL2, SUPPORTS_WEBKIT_AUDIO_CONTEXT, SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT, SUPPORTS_WEB_AUDIO, SUPPORTS_WHEEL_EVENTS, Scaler, type ScalerEventMap, type ScalerProperties, SceneTree, type SceneTreeEventMap, ScrollBar, type ScrollBarProperties, ShadowEffect, type StrokeDraw, Text2D, type Text2DProperties, TextLoader, Texture2D, type Texture2DFilterMode, type Texture2DPixelsSource, type Texture2DSource, type Texture2DWrapMode, TextureLoader, TextureRect2D, type TextureRect2DProperties, Ticker, TiltShiftTransition, Timeline, type TimelineEventMap, TimelineNode, type TimelineNodeEventMap, type TimelineNodeProperties, type TimelineProperties, type TimingFunctions, Transform2D, type Transform2DObject, TransformRect2D, type TransformRect2DProperties, Transition, type TransitionProperties, TwistTransition, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, type VectorLike, type VectorOperateOutput, VertexAttribute, type VertexAttributeOptions, VertexBuffer, type VertexBufferOptions, Video2D, type Video2DProperties, VideoLoader, VideoTexture, type VideoTextureOptions, type VideoTextureSource, Viewport, type ViewportEventMap, type ViewportFramebuffer, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, type WebGLBufferMeta, WebGLBufferModule, type WebGLBufferOptions, type WebGLBufferTarget, type WebGLBufferUsage, type WebGLDrawMode, type WebGLDrawOptions, type WebGLExtensions, type WebGLFramebufferMeta, WebGLFramebufferModule, type WebGLFramebufferOptions, WebGLMaskModule, WebGLModule, type WebGLProgramMeta, WebGLProgramModule, type WebGLProgramOptions, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, type WebGLTarget, type WebGLTextureFilterMode, type WebGLTextureLocation, type WebGLTextureMeta, WebGLTextureModule, type WebGLTextureOptions, type WebGLTextureSource, type WebGLTextureTarget, type WebGLTextureWrapMode, WebGLVertexArrayModule, type WebGLVertexArrayObjectMeta, type WebGLVertexArrayObjectOptions, type WebGLVertexAttrib, type WebGLVertexAttribType, type WebGLViewport, WebGLViewportModule, WebSound, WheelInputEvent, XScrollBar, type XScrollBarProperties, YScrollBar, type YScrollBarProperties, ZoomBlurEffect, assets, clamp, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions, defineProperty, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, getDeclarations, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCSSFilter, parseCSSTransform, parseCSSTransformOrigin, parseCssFunctions, parseCssProperty, property, protectedProperty, render, timingFunctions, uid };
|
|
3005
|
+
export { AnimatedTexture, Animation, type AnimationEffectMode, type AnimationProperties, type AssetHandler, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, type AudioWaveformProperties, BaseElement2D, type BaseElement2DEventMap, type BaseElement2DProperties, BaseElement2DStyle, type BaseElement2DStyleProperties, type Batchable2D, BlurEffect, type CSSFilterKey, type CSSFilters, type CanvasBatchable, CanvasContext, CanvasItem, CanvasItemEditor, type CanvasItemEventMap, type CanvasItemProperties, CanvasTexture, Color, ColorAdjustEffect, ColorFilterEffect, type ColorFilterEffectProperties, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, type ColorValue, type ComputedLayout, Control, type ControlEventMap, type ControlProperties, CoreObject, type CoreObjectEventMap, type CssFunction, type CssFunctionArg, type Cursor, DEG_TO_RAD, DEVICE_PIXEL_RATIO, type Easing, Effect, type EffectContext, EffectMaterial, type EffectMode, type EffectProperties, Element2D, type Element2DEventMap, type Element2DProperties, Element2DStyle, type Element2DStyleProperties, EmbossEffect, Engine, type EngineOptions, EventEmitter, type EventListener, type EventListenerOptions, type EventListenerValue, type FillDraw, type FlexBaseElement2DEventMap, FlexElement2D, type FlexElement2DProperties, FlexElement2DStyle, type FlexElement2DStyleProperties, FlexLayout, FontLoader, GIFLoader, Geometry, type GeometryOptions, GlitchEffect, GodrayEffect, Graphics2D, HTMLAudio, HTMLAudioContext, HTMLSound, type IAudioContext, type IAudioNode, IN_BROWSER, type IPlayOptions, Image2D, type Image2DProperties, type ImageFrame, ImageTexture, type ImageTextureOptions, IndexBuffer, type IndexBufferOptions, Input, InputEvent, type InputEventKey, type InputEventMap, type InternalMode, JSONLoader, KawaseTransition, type Keyframe, LeftEraseTransition, Loader, Lottie2D, type Lottie2DProperties, LottieLoader, MainLoop, type MainLoopEventMap, type MaskColor, type MaskData, MaskEffect, type MaskEffectProperties, type MaskObject, type MaskRect, type Maskable, Material, type MaterialOptions, Matrix, Matrix2, Matrix3, Matrix4, type MatrixLike, type MatrixOperateOutput, MouseInputEvent, Node, Node2D, type Node2DProperties, type NodeEventMap, type NodeProperties, type NormalizedKeyframe, PI, PI_2, PixelateEffect, PixelsTexture, type PlatformAudio, type PlatformSound, PointerInputEvent, type ProcessMode, type ProcessSortMode, Projection2D, type PropertyDeclaration, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, Range, type RangeProperties, RawWeakMap, Rect2, type Rectangulable, type RectangulableEventMap, RefCounted, type RefCountedEventMap, type RenderMode, type RenderOptions, type Renderable, Renderer, Resource, type ResourceEventMap, Ruler, type RulerProperties, SUPPORTS_AUDIO_CONTEXT, SUPPORTS_CLICK_EVENTS, SUPPORTS_CREATE_IMAGE_BITMAP, SUPPORTS_IMAGE_BITMAP, SUPPORTS_MOUSE_EVENTS, SUPPORTS_OFFLINE_AUDIO_CONTEXT, SUPPORTS_POINTER_EVENTS, SUPPORTS_RESIZE_OBSERVER, SUPPORTS_TOUCH_EVENTS, SUPPORTS_WEBGL2, SUPPORTS_WEBKIT_AUDIO_CONTEXT, SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT, SUPPORTS_WEB_AUDIO, SUPPORTS_WHEEL_EVENTS, Scaler, type ScalerEventMap, type ScalerProperties, SceneTree, type SceneTreeEventMap, ScrollBar, type ScrollBarProperties, ShadowEffect, type StrokeDraw, Text2D, type Text2DProperties, TextLoader, Texture2D, type Texture2DFilterMode, type Texture2DPixelsSource, type Texture2DSource, type Texture2DWrapMode, TextureLoader, TextureRect2D, type TextureRect2DProperties, Ticker, TiltShiftTransition, Timeline, type TimelineEventMap, TimelineNode, type TimelineNodeEventMap, type TimelineNodeProperties, type TimelineProperties, type TimingFunctions, Transform2D, type Transform2DObject, TransformRect2D, type TransformRect2DProperties, Transition, type TransitionProperties, TwistTransition, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, type VectorLike, type VectorOperateOutput, VertexAttribute, type VertexAttributeOptions, VertexBuffer, type VertexBufferOptions, Video2D, type Video2DProperties, VideoLoader, VideoTexture, type VideoTextureOptions, type VideoTextureSource, Viewport, type ViewportEventMap, type ViewportFramebuffer, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, type WebGLBufferMeta, WebGLBufferModule, type WebGLBufferOptions, type WebGLBufferTarget, type WebGLBufferUsage, type WebGLDrawMode, type WebGLDrawOptions, type WebGLExtensions, type WebGLFramebufferMeta, WebGLFramebufferModule, type WebGLFramebufferOptions, WebGLMaskModule, WebGLModule, type WebGLProgramMeta, WebGLProgramModule, type WebGLProgramOptions, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, type WebGLTarget, type WebGLTextureFilterMode, type WebGLTextureLocation, type WebGLTextureMeta, WebGLTextureModule, type WebGLTextureOptions, type WebGLTextureSource, type WebGLTextureTarget, type WebGLTextureWrapMode, WebGLVertexArrayModule, type WebGLVertexArrayObjectMeta, type WebGLVertexArrayObjectOptions, type WebGLVertexAttrib, type WebGLVertexAttribType, type WebGLViewport, WebGLViewportModule, WebSound, WheelInputEvent, XScrollBar, type XScrollBarProperties, YScrollBar, type YScrollBarProperties, ZoomBlurEffect, assets, clamp, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions, defineProperty, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, getDeclarations, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCSSFilter, parseCSSTransform, parseCSSTransformOrigin, parseCssFunctions, parseCssProperty, property, protectedProperty, render, timingFunctions, uid };
|