@leafer-game/worker 1.0.10 → 1.1.0
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/worker.cjs +40 -20
- package/dist/worker.esm.js +41 -21
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +119 -71
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +119 -71
- package/dist/worker.module.min.js +1 -1
- package/package.json +4 -4
package/dist/worker.module.js
CHANGED
|
@@ -108,7 +108,7 @@ const MathHelper = {
|
|
|
108
108
|
return rotation - oldRotation;
|
|
109
109
|
},
|
|
110
110
|
float(num, maxLength) {
|
|
111
|
-
const a = maxLength ? pow$2(10, maxLength) : 1000000000000;
|
|
111
|
+
const a = maxLength !== undefined ? pow$2(10, maxLength) : 1000000000000;
|
|
112
112
|
num = round$3(num * a) / a;
|
|
113
113
|
return num === -0 ? 0 : num;
|
|
114
114
|
},
|
|
@@ -4165,20 +4165,17 @@ const LeafHelper = {
|
|
|
4165
4165
|
}
|
|
4166
4166
|
return true;
|
|
4167
4167
|
},
|
|
4168
|
-
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4168
|
+
moveWorld(t, x, y = 0, isInnerPoint, transition) {
|
|
4169
4169
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4170
4170
|
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4171
|
-
L$1.moveLocal(t, local.x, local.y);
|
|
4171
|
+
L$1.moveLocal(t, local.x, local.y, transition);
|
|
4172
4172
|
},
|
|
4173
|
-
moveLocal(t, x, y = 0) {
|
|
4174
|
-
if (typeof x === 'object')
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
t.x += x;
|
|
4180
|
-
t.y += y;
|
|
4181
|
-
}
|
|
4173
|
+
moveLocal(t, x, y = 0, transition) {
|
|
4174
|
+
if (typeof x === 'object')
|
|
4175
|
+
y = x.y, x = x.x;
|
|
4176
|
+
x += t.x;
|
|
4177
|
+
y += t.y;
|
|
4178
|
+
transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
|
|
4182
4179
|
},
|
|
4183
4180
|
zoomOfWorld(t, origin, scaleX, scaleY, resize) {
|
|
4184
4181
|
L$1.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
|
|
@@ -5558,11 +5555,11 @@ let Leaf = class Leaf {
|
|
|
5558
5555
|
transform(matrix, resize) {
|
|
5559
5556
|
transform(this, matrix, resize);
|
|
5560
5557
|
}
|
|
5561
|
-
move(x, y) {
|
|
5562
|
-
moveLocal(this, x, y);
|
|
5558
|
+
move(x, y, transition) {
|
|
5559
|
+
moveLocal(this, x, y, transition);
|
|
5563
5560
|
}
|
|
5564
|
-
moveInner(x, y) {
|
|
5565
|
-
moveWorld(this, x, y, true);
|
|
5561
|
+
moveInner(x, y, transition) {
|
|
5562
|
+
moveWorld(this, x, y, true, transition);
|
|
5566
5563
|
}
|
|
5567
5564
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5568
5565
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
@@ -5576,8 +5573,8 @@ let Leaf = class Leaf {
|
|
|
5576
5573
|
transformWorld(worldTransform, resize) {
|
|
5577
5574
|
transformWorld(this, worldTransform, resize);
|
|
5578
5575
|
}
|
|
5579
|
-
moveWorld(x, y) {
|
|
5580
|
-
moveWorld(this, x, y);
|
|
5576
|
+
moveWorld(x, y, transition) {
|
|
5577
|
+
moveWorld(this, x, y, false, transition);
|
|
5581
5578
|
}
|
|
5582
5579
|
scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
|
|
5583
5580
|
zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
|
|
@@ -5975,7 +5972,7 @@ class LeafLevelList {
|
|
|
5975
5972
|
}
|
|
5976
5973
|
}
|
|
5977
5974
|
|
|
5978
|
-
const version = "1.0
|
|
5975
|
+
const version = "1.1.0";
|
|
5979
5976
|
|
|
5980
5977
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5981
5978
|
get allowBackgroundColor() { return true; }
|
|
@@ -7405,11 +7402,15 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7405
7402
|
super(data);
|
|
7406
7403
|
}
|
|
7407
7404
|
reset(_data) { }
|
|
7408
|
-
set(data,
|
|
7409
|
-
if (
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7405
|
+
set(data, transition) {
|
|
7406
|
+
if (transition) {
|
|
7407
|
+
if (transition === 'temp') {
|
|
7408
|
+
this.lockNormalStyle = true;
|
|
7409
|
+
Object.assign(this, data);
|
|
7410
|
+
this.lockNormalStyle = false;
|
|
7411
|
+
}
|
|
7412
|
+
else
|
|
7413
|
+
this.animate(data, transition);
|
|
7413
7414
|
}
|
|
7414
7415
|
else
|
|
7415
7416
|
Object.assign(this, data);
|
|
@@ -7719,17 +7720,17 @@ let Group = class Group extends UI {
|
|
|
7719
7720
|
if (!this.children)
|
|
7720
7721
|
this.children = [];
|
|
7721
7722
|
}
|
|
7722
|
-
set(data,
|
|
7723
|
+
set(data, transition) {
|
|
7723
7724
|
if (data.children) {
|
|
7724
7725
|
const { children } = data;
|
|
7725
7726
|
delete data.children;
|
|
7726
7727
|
this.children ? this.clear() : this.__setBranch();
|
|
7727
|
-
super.set(data,
|
|
7728
|
+
super.set(data, transition);
|
|
7728
7729
|
children.forEach(child => this.add(child));
|
|
7729
7730
|
data.children = children;
|
|
7730
7731
|
}
|
|
7731
7732
|
else
|
|
7732
|
-
super.set(data,
|
|
7733
|
+
super.set(data, transition);
|
|
7733
7734
|
}
|
|
7734
7735
|
toJSON(options) {
|
|
7735
7736
|
const data = super.toJSON(options);
|
|
@@ -7842,8 +7843,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7842
7843
|
}
|
|
7843
7844
|
onInit() { }
|
|
7844
7845
|
initType(_type) { }
|
|
7845
|
-
set(data) {
|
|
7846
|
-
this.waitInit(() => { super.set(data); });
|
|
7846
|
+
set(data, transition) {
|
|
7847
|
+
this.waitInit(() => { super.set(data, transition); });
|
|
7847
7848
|
}
|
|
7848
7849
|
start() {
|
|
7849
7850
|
clearTimeout(this.__startTimer);
|
|
@@ -8333,7 +8334,7 @@ Ellipse = __decorate([
|
|
|
8333
8334
|
], Ellipse);
|
|
8334
8335
|
|
|
8335
8336
|
const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
|
|
8336
|
-
const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$
|
|
8337
|
+
const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$3, defaultPoint } = PointHelper;
|
|
8337
8338
|
const { toBounds: toBounds$1 } = PathBounds;
|
|
8338
8339
|
let Line = class Line extends UI {
|
|
8339
8340
|
get __tag() { return 'Line'; }
|
|
@@ -8347,7 +8348,7 @@ let Line = class Line extends UI {
|
|
|
8347
8348
|
return to;
|
|
8348
8349
|
}
|
|
8349
8350
|
set toPoint(value) {
|
|
8350
|
-
this.width = getDistance$
|
|
8351
|
+
this.width = getDistance$3(defaultPoint, value);
|
|
8351
8352
|
this.rotation = getAngle$1(defaultPoint, value);
|
|
8352
8353
|
if (this.height)
|
|
8353
8354
|
this.height = 0;
|
|
@@ -9032,10 +9033,8 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9032
9033
|
this.data = data;
|
|
9033
9034
|
}
|
|
9034
9035
|
static getValidMove(leaf, start, total) {
|
|
9035
|
-
const { draggable, dragBounds
|
|
9036
|
-
|
|
9037
|
-
move.x += start.x - x;
|
|
9038
|
-
move.y += start.y - y;
|
|
9036
|
+
const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
|
|
9037
|
+
PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
|
|
9039
9038
|
if (dragBounds)
|
|
9040
9039
|
this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
|
|
9041
9040
|
if (draggable === 'x')
|
|
@@ -9045,8 +9044,7 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9045
9044
|
return move;
|
|
9046
9045
|
}
|
|
9047
9046
|
static getMoveInDragBounds(childBox, dragBounds, move, change) {
|
|
9048
|
-
const x = childBox.x + move.x, y = childBox.y + move.y;
|
|
9049
|
-
const right = x + childBox.width, bottom = y + childBox.height;
|
|
9047
|
+
const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
|
|
9050
9048
|
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
9051
9049
|
if (!change)
|
|
9052
9050
|
move = Object.assign({}, move);
|
|
@@ -9098,9 +9096,7 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9098
9096
|
return this.getLocalMove(relative, true);
|
|
9099
9097
|
}
|
|
9100
9098
|
getPageBounds() {
|
|
9101
|
-
const total = this.getPageTotal();
|
|
9102
|
-
const start = this.getPagePoint();
|
|
9103
|
-
const bounds = {};
|
|
9099
|
+
const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
|
|
9104
9100
|
BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
|
|
9105
9101
|
BoundsHelper.unsign(bounds);
|
|
9106
9102
|
return bounds;
|
|
@@ -10488,6 +10484,8 @@ function stroke(stroke, ui, canvas) {
|
|
|
10488
10484
|
case 'center':
|
|
10489
10485
|
canvas.setStroke(stroke, __strokeWidth, options);
|
|
10490
10486
|
canvas.stroke();
|
|
10487
|
+
if (options.__useArrow)
|
|
10488
|
+
strokeArrow(ui, canvas);
|
|
10491
10489
|
break;
|
|
10492
10490
|
case 'inside':
|
|
10493
10491
|
canvas.save();
|
|
@@ -10525,6 +10523,8 @@ function strokes(strokes, ui, canvas) {
|
|
|
10525
10523
|
case 'center':
|
|
10526
10524
|
canvas.setStroke(undefined, __strokeWidth, options);
|
|
10527
10525
|
drawStrokesStyle(strokes, false, ui, canvas);
|
|
10526
|
+
if (options.__useArrow)
|
|
10527
|
+
strokeArrow(ui, canvas);
|
|
10528
10528
|
break;
|
|
10529
10529
|
case 'inside':
|
|
10530
10530
|
canvas.save();
|
|
@@ -10550,6 +10550,14 @@ function strokes(strokes, ui, canvas) {
|
|
|
10550
10550
|
}
|
|
10551
10551
|
}
|
|
10552
10552
|
}
|
|
10553
|
+
function strokeArrow(ui, canvas) {
|
|
10554
|
+
if (ui.__.dashPattern) {
|
|
10555
|
+
canvas.beginPath();
|
|
10556
|
+
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
10557
|
+
canvas.dashPattern = null;
|
|
10558
|
+
canvas.stroke();
|
|
10559
|
+
}
|
|
10560
|
+
}
|
|
10553
10561
|
|
|
10554
10562
|
const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
|
|
10555
10563
|
function shape(ui, current, options) {
|
|
@@ -11052,7 +11060,7 @@ function applyStops(gradient, stops, opacity) {
|
|
|
11052
11060
|
}
|
|
11053
11061
|
}
|
|
11054
11062
|
|
|
11055
|
-
const { getAngle, getDistance: getDistance$
|
|
11063
|
+
const { getAngle, getDistance: getDistance$2 } = PointHelper;
|
|
11056
11064
|
const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
|
|
11057
11065
|
const { toPoint: toPoint$1 } = AroundHelper;
|
|
11058
11066
|
const realFrom$1 = {};
|
|
@@ -11061,7 +11069,7 @@ function radialGradient(paint, box) {
|
|
|
11061
11069
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
11062
11070
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
11063
11071
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
11064
|
-
const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$
|
|
11072
|
+
const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$2(realFrom$1, realTo$1));
|
|
11065
11073
|
applyStops(style, paint.stops, opacity);
|
|
11066
11074
|
const data = { type, style };
|
|
11067
11075
|
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
@@ -11089,7 +11097,7 @@ function getTransform(box, from, to, stretch, rotate90) {
|
|
|
11089
11097
|
return transform;
|
|
11090
11098
|
}
|
|
11091
11099
|
|
|
11092
|
-
const { getDistance } = PointHelper;
|
|
11100
|
+
const { getDistance: getDistance$1 } = PointHelper;
|
|
11093
11101
|
const { toPoint } = AroundHelper;
|
|
11094
11102
|
const realFrom = {};
|
|
11095
11103
|
const realTo = {};
|
|
@@ -11097,7 +11105,7 @@ function conicGradient(paint, box) {
|
|
|
11097
11105
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
11098
11106
|
toPoint(from || 'center', box, realFrom);
|
|
11099
11107
|
toPoint(to || 'bottom', box, realTo);
|
|
11100
|
-
const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
|
|
11108
|
+
const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance$1(realFrom, realTo));
|
|
11101
11109
|
applyStops(style, paint.stops, opacity);
|
|
11102
11110
|
const data = { type, style };
|
|
11103
11111
|
const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
|
|
@@ -12076,15 +12084,18 @@ let Robot = class Robot extends UI {
|
|
|
12076
12084
|
if (typeof action === 'number') {
|
|
12077
12085
|
this.now = action;
|
|
12078
12086
|
}
|
|
12079
|
-
else if (action
|
|
12080
|
-
const
|
|
12087
|
+
else if (typeof action === 'object') {
|
|
12088
|
+
const isArray = action instanceof Array;
|
|
12089
|
+
const keyframes = isArray ? action : action.keyframes;
|
|
12090
|
+
this.__action = isArray ? undefined : action;
|
|
12091
|
+
const { length } = keyframes;
|
|
12081
12092
|
if (length > 1) {
|
|
12082
|
-
const start = this.now =
|
|
12093
|
+
const start = this.now = keyframes[0], end = keyframes[keyframes.length - 1];
|
|
12083
12094
|
this.play();
|
|
12084
12095
|
this.__runAction(start, end);
|
|
12085
12096
|
}
|
|
12086
12097
|
else if (length)
|
|
12087
|
-
this.now =
|
|
12098
|
+
this.now = keyframes[0];
|
|
12088
12099
|
}
|
|
12089
12100
|
}
|
|
12090
12101
|
__loadRobot(frame, start, end) {
|
|
@@ -12112,16 +12123,26 @@ let Robot = class Robot extends UI {
|
|
|
12112
12123
|
this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
|
|
12113
12124
|
}
|
|
12114
12125
|
__runAction(start, end) {
|
|
12126
|
+
let { FPS, loop, __action: a } = this;
|
|
12127
|
+
if (a) {
|
|
12128
|
+
if (a.FPS)
|
|
12129
|
+
FPS = a.FPS;
|
|
12130
|
+
if (a.loop !== undefined)
|
|
12131
|
+
loop = a.loop;
|
|
12132
|
+
}
|
|
12115
12133
|
this.__timer = setTimeout(() => {
|
|
12116
12134
|
if (this.running) {
|
|
12117
|
-
if (this.now === end)
|
|
12135
|
+
if (this.now === end) {
|
|
12136
|
+
if (!loop)
|
|
12137
|
+
return this.stop();
|
|
12118
12138
|
this.now = start;
|
|
12139
|
+
}
|
|
12119
12140
|
else
|
|
12120
12141
|
this.now++;
|
|
12121
12142
|
this.__updateRobotBounds();
|
|
12122
12143
|
}
|
|
12123
12144
|
this.__runAction(start, end);
|
|
12124
|
-
}, 1000 /
|
|
12145
|
+
}, 1000 / FPS);
|
|
12125
12146
|
}
|
|
12126
12147
|
__updateRobotBounds() {
|
|
12127
12148
|
const { nowFrame } = this;
|
|
@@ -12234,7 +12255,7 @@ function updateStyle(leaf, style, type) {
|
|
|
12234
12255
|
const fromStyle = transition ? getFromStyle(leaf, style) : undefined;
|
|
12235
12256
|
leaf.killAnimate('transition');
|
|
12236
12257
|
if (normalStyle)
|
|
12237
|
-
leaf.set(normalStyle,
|
|
12258
|
+
leaf.set(normalStyle, 'temp');
|
|
12238
12259
|
const statesStyle = getStyle(leaf);
|
|
12239
12260
|
if (statesStyle) {
|
|
12240
12261
|
const { animation } = statesStyle;
|
|
@@ -12248,14 +12269,14 @@ function updateStyle(leaf, style, type) {
|
|
|
12248
12269
|
delete statesStyle.animation;
|
|
12249
12270
|
}
|
|
12250
12271
|
leaf.normalStyle = filterStyle(statesStyle, leaf);
|
|
12251
|
-
leaf.set(statesStyle,
|
|
12272
|
+
leaf.set(statesStyle, 'temp');
|
|
12252
12273
|
}
|
|
12253
12274
|
else {
|
|
12254
12275
|
leaf.normalStyle = undefined;
|
|
12255
12276
|
}
|
|
12256
12277
|
if (transition) {
|
|
12257
12278
|
const toStyle = filterStyle(fromStyle, leaf);
|
|
12258
|
-
leaf.set(fromStyle,
|
|
12279
|
+
leaf.set(fromStyle, 'temp');
|
|
12259
12280
|
leaf.animate([fromStyle, toStyle], transition, 'transition', true);
|
|
12260
12281
|
}
|
|
12261
12282
|
leaf.__layout.stateStyleChanged = false;
|
|
@@ -12953,7 +12974,7 @@ let Animate = class Animate extends Eventer {
|
|
|
12953
12974
|
this.emit(AnimateEvent.UPDATE, this);
|
|
12954
12975
|
}
|
|
12955
12976
|
setStyle(style) {
|
|
12956
|
-
this.target.set(style, this.isTemp);
|
|
12977
|
+
this.target.set(style, this.isTemp ? 'temp' : false);
|
|
12957
12978
|
}
|
|
12958
12979
|
clearTimer(fn) {
|
|
12959
12980
|
if (this.timer) {
|
|
@@ -13329,6 +13350,9 @@ const TransitionList = {
|
|
|
13329
13350
|
from = fourNumber(from), to = fourNumber(to);
|
|
13330
13351
|
return from.map((f, i) => number(f, to[i], t));
|
|
13331
13352
|
},
|
|
13353
|
+
text(from, to, t) {
|
|
13354
|
+
return (typeof from === 'number' || typeof to === 'number') ? MathHelper.float(number(from, to, t), Math.max(getDecimalLen(from), getDecimalLen(to))) : to;
|
|
13355
|
+
},
|
|
13332
13356
|
shadow,
|
|
13333
13357
|
innerShadow: shadow
|
|
13334
13358
|
};
|
|
@@ -13337,6 +13361,10 @@ const TransitionModule = {
|
|
|
13337
13361
|
number,
|
|
13338
13362
|
color
|
|
13339
13363
|
};
|
|
13364
|
+
function getDecimalLen(num) {
|
|
13365
|
+
const decimal = String(num).split('.')[1];
|
|
13366
|
+
return decimal ? decimal.length : 0;
|
|
13367
|
+
}
|
|
13340
13368
|
function value(from, to, t) {
|
|
13341
13369
|
return (typeof from === 'number' && typeof to === 'number') ? from + (to - from) * t : to;
|
|
13342
13370
|
}
|
|
@@ -13405,23 +13433,40 @@ const gaussNodes = [0.1488743389, 0.4333953941, 0.6794095682, 0.8650633666, 0.97
|
|
|
13405
13433
|
const gaussWeights = [0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443];
|
|
13406
13434
|
const { sqrt } = Math;
|
|
13407
13435
|
const HighBezierHelper = {
|
|
13408
|
-
getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY) {
|
|
13409
|
-
let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y;
|
|
13436
|
+
getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, t = 1) {
|
|
13437
|
+
let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y, half = t / 2;
|
|
13410
13438
|
for (let i = 0; i < gaussNodes.length; i++) {
|
|
13411
|
-
t1 =
|
|
13412
|
-
t2 =
|
|
13439
|
+
t1 = half * (1 + gaussNodes[i]);
|
|
13440
|
+
t2 = half * (1 - gaussNodes[i]);
|
|
13413
13441
|
d1X = getDerivative(t1, fromX, x1, x2, toX);
|
|
13414
13442
|
d1Y = getDerivative(t1, fromY, y1, y2, toY);
|
|
13415
13443
|
d2X = getDerivative(t2, fromX, x1, x2, toX);
|
|
13416
13444
|
d2Y = getDerivative(t2, fromY, y1, y2, toY);
|
|
13417
13445
|
distance += gaussWeights[i] * (sqrt(d1X * d1X + d1Y * d1Y) + sqrt(d2X * d2X + d2Y * d2Y));
|
|
13418
13446
|
}
|
|
13419
|
-
return distance *
|
|
13447
|
+
return distance * half;
|
|
13420
13448
|
},
|
|
13421
13449
|
getDerivative(t, fromV, v1, v2, toV) {
|
|
13422
13450
|
const o = 1 - t;
|
|
13423
13451
|
return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
|
|
13424
13452
|
},
|
|
13453
|
+
getRotation(t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
|
|
13454
|
+
const dx = getDerivative(t, fromX, x1, x2, toX);
|
|
13455
|
+
const dy = getDerivative(t, fromY, y1, y2, toY);
|
|
13456
|
+
return Math.atan2(dy, dx) / OneRadian;
|
|
13457
|
+
},
|
|
13458
|
+
getT(distance, totalDistance, fromX, fromY, x1, y1, x2, y2, toX, toY, precision = 1) {
|
|
13459
|
+
let low = 0, high = 1, middle = distance / totalDistance, realPrecision = precision / totalDistance / 3;
|
|
13460
|
+
if (middle >= 1)
|
|
13461
|
+
return 1;
|
|
13462
|
+
if (middle <= 0)
|
|
13463
|
+
return 0;
|
|
13464
|
+
while (high - low > realPrecision) {
|
|
13465
|
+
getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, middle) < distance ? low = middle : high = middle;
|
|
13466
|
+
middle = (low + high) / 2;
|
|
13467
|
+
}
|
|
13468
|
+
return middle;
|
|
13469
|
+
},
|
|
13425
13470
|
cut(data, t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
|
|
13426
13471
|
const o = 1 - t;
|
|
13427
13472
|
const ax = o * fromX + t * x1, ay = o * fromY + t * y1;
|
|
@@ -13433,7 +13478,7 @@ const HighBezierHelper = {
|
|
|
13433
13478
|
data.push(PathCommandMap.C, ax, ay, bx, by, cx, cy);
|
|
13434
13479
|
}
|
|
13435
13480
|
};
|
|
13436
|
-
const { getDerivative } = HighBezierHelper;
|
|
13481
|
+
const { getDerivative, getDistance } = HighBezierHelper;
|
|
13437
13482
|
|
|
13438
13483
|
const { M, L, C, Z } = PathCommandMap;
|
|
13439
13484
|
const tempPoint = {}, tempFrom = {};
|
|
@@ -13501,11 +13546,12 @@ const HighCurveHelper = {
|
|
|
13501
13546
|
}
|
|
13502
13547
|
return { total, segments, data };
|
|
13503
13548
|
},
|
|
13504
|
-
getDistancePoint(distanceData, motionDistance) {
|
|
13549
|
+
getDistancePoint(distanceData, motionDistance, motionPrecision) {
|
|
13505
13550
|
const { segments, data } = distanceData;
|
|
13506
13551
|
motionDistance = UnitConvert.number(motionDistance, distanceData.total);
|
|
13507
13552
|
let total = 0, distance, to = {};
|
|
13508
13553
|
let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
|
|
13554
|
+
let x1, y1, x2, y2, t;
|
|
13509
13555
|
const len = data.length;
|
|
13510
13556
|
while (i < len) {
|
|
13511
13557
|
command = data[i];
|
|
@@ -13535,11 +13581,10 @@ const HighCurveHelper = {
|
|
|
13535
13581
|
toY = data[i + 6];
|
|
13536
13582
|
distance = segments[index];
|
|
13537
13583
|
if (total + distance > motionDistance) {
|
|
13538
|
-
|
|
13539
|
-
motionDistance
|
|
13540
|
-
BezierHelper.getPointAndSet(
|
|
13541
|
-
|
|
13542
|
-
to.rotation = PointHelper.getAngle(tempFrom, to);
|
|
13584
|
+
x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
|
|
13585
|
+
t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
|
|
13586
|
+
BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to);
|
|
13587
|
+
to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY);
|
|
13543
13588
|
return to;
|
|
13544
13589
|
}
|
|
13545
13590
|
x = toX;
|
|
@@ -13556,11 +13601,12 @@ const HighCurveHelper = {
|
|
|
13556
13601
|
}
|
|
13557
13602
|
return to;
|
|
13558
13603
|
},
|
|
13559
|
-
getDistancePath(distanceData, motionDistance) {
|
|
13604
|
+
getDistancePath(distanceData, motionDistance, motionPrecision) {
|
|
13560
13605
|
const { segments, data } = distanceData, path = [];
|
|
13561
13606
|
motionDistance = UnitConvert.number(motionDistance, distanceData.total);
|
|
13562
13607
|
let total = 0, distance, to = {};
|
|
13563
13608
|
let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
|
|
13609
|
+
let x1, y1, x2, y2, t;
|
|
13564
13610
|
const len = data.length;
|
|
13565
13611
|
while (i < len) {
|
|
13566
13612
|
command = data[i];
|
|
@@ -13587,12 +13633,13 @@ const HighCurveHelper = {
|
|
|
13587
13633
|
path.push(command, x, y);
|
|
13588
13634
|
break;
|
|
13589
13635
|
case C:
|
|
13590
|
-
|
|
13636
|
+
x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
|
|
13591
13637
|
toX = data[i + 5];
|
|
13592
13638
|
toY = data[i + 6];
|
|
13593
13639
|
distance = segments[index];
|
|
13594
13640
|
if (total + distance > motionDistance) {
|
|
13595
|
-
HighBezierHelper.
|
|
13641
|
+
t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
|
|
13642
|
+
HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY);
|
|
13596
13643
|
return path;
|
|
13597
13644
|
}
|
|
13598
13645
|
x = toX;
|
|
@@ -13641,6 +13688,7 @@ const ui = UI.prototype;
|
|
|
13641
13688
|
const { updateMatrix, updateAllMatrix } = LeafHelper;
|
|
13642
13689
|
const { updateBounds } = BranchHelper;
|
|
13643
13690
|
motionPathType()(ui, 'motionPath');
|
|
13691
|
+
motionPathType(1)(ui, 'motionPrecision');
|
|
13644
13692
|
motionPathType()(ui, 'motion');
|
|
13645
13693
|
motionPathType(true)(ui, 'motionRotation');
|
|
13646
13694
|
ui.getMotionPathData = function () {
|
|
@@ -13651,7 +13699,7 @@ ui.getMotionPoint = function (motionDistance) {
|
|
|
13651
13699
|
const data = getMotionPathData(path);
|
|
13652
13700
|
if (!data.total)
|
|
13653
13701
|
return {};
|
|
13654
|
-
const point = HighCurveHelper.getDistancePoint(data, motionDistance);
|
|
13702
|
+
const point = HighCurveHelper.getDistancePoint(data, motionDistance, path.motionPrecision);
|
|
13655
13703
|
MatrixHelper.toOuterPoint(path.localTransform, point);
|
|
13656
13704
|
const { motionRotation } = this;
|
|
13657
13705
|
if (motionRotation === false)
|
|
@@ -13691,7 +13739,7 @@ function updateMotion(leaf) {
|
|
|
13691
13739
|
if (leaf.motionPath) {
|
|
13692
13740
|
const data = getMotionPathData(leaf);
|
|
13693
13741
|
if (data.total)
|
|
13694
|
-
leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion);
|
|
13742
|
+
leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision);
|
|
13695
13743
|
}
|
|
13696
13744
|
else {
|
|
13697
13745
|
leaf.set(leaf.getMotionPoint(motion));
|