leafer-game 0.0.1 → 1.0.8

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/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # leafer-game
2
2
 
3
- 未来适用于 **在线游戏** 场景的 [leafer-ui](https://github.com/leaferjs/ui) 版本
3
+ **leafer-game** [leafer-ui](https://github.com/leaferjs/leafer-ui) 的基础上,集成了 Robot、状态、 动画、运动路径插件,适用于小游戏场景。
package/dist/web.cjs ADDED
@@ -0,0 +1,678 @@
1
+ 'use strict';
2
+
3
+ var leaferUi = require('leafer-ui');
4
+ var robot = require('@leafer-in/robot');
5
+ var draw = require('@leafer-ui/draw');
6
+ var core = require('@leafer-ui/core');
7
+ var animate = require('@leafer-in/animate');
8
+
9
+ function stateType(defaultValue, styleName) {
10
+ return draw.decorateLeafAttr(defaultValue, (key) => draw.attr({
11
+ set(value) {
12
+ this.__setAttr(key, value);
13
+ this.waitLeafer(() => styleName ? draw.State.setStyleName(this, styleName, value) : draw.State.set(this, value));
14
+ }
15
+ }));
16
+ }
17
+ function stateStyleType(defaultValue) {
18
+ return draw.decorateLeafAttr(defaultValue, (key) => draw.attr({
19
+ set(value) {
20
+ this.__setAttr(key, value);
21
+ this.__layout.stateStyleChanged = true;
22
+ }
23
+ }));
24
+ }
25
+
26
+ function findParentButton(leaf, button) {
27
+ if (button && button !== true)
28
+ return button;
29
+ if (!leaf.button) {
30
+ let { parent } = leaf;
31
+ for (let i = 0; i < 2; i++) {
32
+ if (parent) {
33
+ if (parent.button)
34
+ return parent;
35
+ parent = parent.parent;
36
+ }
37
+ }
38
+ }
39
+ return null;
40
+ }
41
+
42
+ function setStyle(leaf, style) {
43
+ if (typeof style !== 'object')
44
+ style = undefined;
45
+ updateStyle(leaf, style, 'in');
46
+ }
47
+ function unsetStyle(leaf, style) {
48
+ const { normalStyle } = leaf;
49
+ if (typeof style !== 'object')
50
+ style = undefined;
51
+ if (normalStyle) {
52
+ if (!style)
53
+ style = normalStyle;
54
+ updateStyle(leaf, style, 'out');
55
+ }
56
+ }
57
+ const emprtyStyle = {};
58
+ function updateStyle(leaf, style, type) {
59
+ const { normalStyle } = leaf;
60
+ if (!style)
61
+ style = emprtyStyle;
62
+ if (style.scale) {
63
+ core.MathHelper.assignScale(style, style.scale);
64
+ delete style.scale;
65
+ }
66
+ if (style === emprtyStyle || !core.State.canAnimate)
67
+ type = null;
68
+ let transition = type ? getTransition(type, style, leaf) : false;
69
+ const fromStyle = transition ? getFromStyle(leaf, style) : undefined;
70
+ leaf.killAnimate('transition');
71
+ if (normalStyle)
72
+ leaf.set(normalStyle, true);
73
+ const statesStyle = getStyle(leaf);
74
+ if (statesStyle) {
75
+ const { animation } = statesStyle;
76
+ if (animation) {
77
+ const animate = leaf.animate(animation, undefined, 'animation', true);
78
+ Object.assign(statesStyle, animate.endingStyle);
79
+ if (type !== 'in' || style.animation !== animation)
80
+ animate.kill();
81
+ else
82
+ transition = false;
83
+ delete statesStyle.animation;
84
+ }
85
+ leaf.normalStyle = filterStyle(statesStyle, leaf);
86
+ leaf.set(statesStyle, true);
87
+ }
88
+ else {
89
+ leaf.normalStyle = undefined;
90
+ }
91
+ if (transition) {
92
+ const toStyle = filterStyle(fromStyle, leaf);
93
+ leaf.set(fromStyle, true);
94
+ leaf.animate([fromStyle, toStyle], transition, 'transition', true);
95
+ }
96
+ leaf.__layout.stateStyleChanged = false;
97
+ }
98
+ function getStyle(leaf) {
99
+ let exist;
100
+ const style = {}, { state } = leaf, button = findParentButton(leaf);
101
+ const stateStyle = state && leaf.states[state];
102
+ if (stateStyle && core.State.isState(state, leaf, button))
103
+ exist = assign(style, stateStyle);
104
+ const selectedStyle = style.selectedStyle || leaf.selectedStyle;
105
+ if (selectedStyle && core.State.isSelected(leaf, button))
106
+ exist = assign(style, selectedStyle);
107
+ if (core.State.isDisabled(leaf, button)) {
108
+ const disabledStyle = style.disabledStyle || leaf.disabledStyle;
109
+ if (disabledStyle)
110
+ exist = assign(style, disabledStyle);
111
+ }
112
+ else {
113
+ const focusStyle = style.focusStyle || leaf.focusStyle;
114
+ if (focusStyle && core.State.isFocus(leaf, button))
115
+ exist = assign(style, focusStyle);
116
+ const hoverStyle = style.hoverStyle || leaf.hoverStyle;
117
+ if (hoverStyle && core.State.isHover(leaf, button))
118
+ exist = assign(style, hoverStyle);
119
+ const pressStyle = style.pressStyle || leaf.pressStyle;
120
+ if (pressStyle && core.State.isPress(leaf, button))
121
+ exist = assign(style, pressStyle);
122
+ }
123
+ return exist ? style : undefined;
124
+ }
125
+ function filterStyle(style, data, addStyle, useAnimateExcludes) {
126
+ const to = addStyle ? style : {}, forStyle = addStyle || style;
127
+ for (let key in forStyle) {
128
+ if (useAnimateExcludes) {
129
+ if (!core.State.animateExcludes[key])
130
+ to[key] = data[key];
131
+ }
132
+ else
133
+ to[key] = data[key];
134
+ }
135
+ return to;
136
+ }
137
+ function filterAnimateStyle(style, data, addStyle) {
138
+ return filterStyle(style, data, addStyle, true);
139
+ }
140
+ function getFromStyle(leaf, style) {
141
+ const fromStyle = filterAnimateStyle(style, leaf), animate = leaf.animate();
142
+ if (animate)
143
+ filterAnimateStyle(fromStyle, leaf, animate.fromStyle);
144
+ return fromStyle;
145
+ }
146
+ function getTransition(type, style, data) {
147
+ let name = type === 'in' ? 'transition' : 'transitionOut';
148
+ if (type === 'out' && core.isNull(data[name]) && core.isNull(style[name]))
149
+ name = 'transition';
150
+ return core.isNull(style[name]) ? data[name] : style[name];
151
+ }
152
+ function assign(style, stateStyle) {
153
+ Object.assign(style, stateStyle);
154
+ return true;
155
+ }
156
+
157
+ function setPointerState(leaf, stateName) {
158
+ const style = leaf[stateName];
159
+ if (style)
160
+ setStyle(leaf, style);
161
+ if (leaf.button)
162
+ setChildrenState(leaf.children, stateName);
163
+ }
164
+ function setState(leaf, stateName, stateStyle) {
165
+ if (!stateStyle)
166
+ stateStyle = leaf.states[stateName];
167
+ setStyle(leaf, stateStyle);
168
+ if (leaf.button)
169
+ setChildrenState(leaf.children, null, stateName);
170
+ }
171
+ function setChildrenState(children, stateType, state) {
172
+ if (!children)
173
+ return;
174
+ let leaf, update;
175
+ for (let i = 0, len = children.length; i < len; i++) {
176
+ leaf = children[i];
177
+ if (stateType) {
178
+ update = true;
179
+ switch (stateType) {
180
+ case 'hoverStyle':
181
+ if (core.State.isHover(leaf))
182
+ update = false;
183
+ break;
184
+ case 'pressStyle':
185
+ if (core.State.isPress(leaf))
186
+ update = false;
187
+ break;
188
+ case 'focusStyle':
189
+ if (core.State.isFocus(leaf))
190
+ update = false;
191
+ }
192
+ if (update)
193
+ setPointerState(leaf, stateType);
194
+ }
195
+ else if (state)
196
+ setState(leaf, state);
197
+ if (leaf.isBranch)
198
+ setChildrenState(leaf.children, stateType, state);
199
+ }
200
+ }
201
+
202
+ function unsetPointerState(leaf, stateName) {
203
+ const style = leaf[stateName];
204
+ if (style)
205
+ unsetStyle(leaf, style);
206
+ if (leaf.button)
207
+ unsetChildrenState(leaf.children, stateName);
208
+ }
209
+ function unsetState(leaf, stateName, stateStyle) {
210
+ unsetStyle(leaf, stateStyle);
211
+ if (leaf.button)
212
+ unsetChildrenState(leaf.children, null, stateName);
213
+ }
214
+ function unsetChildrenState(children, stateType, state) {
215
+ if (!children)
216
+ return;
217
+ let leaf;
218
+ for (let i = 0, len = children.length; i < len; i++) {
219
+ leaf = children[i];
220
+ if (stateType)
221
+ unsetPointerState(leaf, stateType);
222
+ else if (state)
223
+ unsetState(leaf, state);
224
+ if (leaf.isBranch)
225
+ unsetChildrenState(leaf.children, stateType, state);
226
+ }
227
+ }
228
+
229
+ function updateEventStyle(leaf, eventType) {
230
+ switch (eventType) {
231
+ case core.PointerEvent.ENTER:
232
+ setPointerState(leaf, 'hoverStyle');
233
+ break;
234
+ case core.PointerEvent.LEAVE:
235
+ unsetPointerState(leaf, 'hoverStyle');
236
+ break;
237
+ case core.PointerEvent.DOWN:
238
+ setPointerState(leaf, 'pressStyle');
239
+ break;
240
+ case core.PointerEvent.UP:
241
+ unsetPointerState(leaf, 'pressStyle');
242
+ break;
243
+ }
244
+ }
245
+
246
+ function checkPointerState(fnName, leaf, button) {
247
+ let find;
248
+ const interaction = leaf.leafer ? leaf.leafer.interaction : null;
249
+ if (interaction) {
250
+ find = interaction[fnName](leaf);
251
+ if (!find && button) {
252
+ const parentButton = findParentButton(leaf, button);
253
+ if (parentButton)
254
+ find = interaction[fnName](parentButton);
255
+ }
256
+ }
257
+ return find;
258
+ }
259
+ function checkFixedState(attrName, leaf, button) {
260
+ let find = leaf[attrName];
261
+ if (!find && button) {
262
+ const parentButton = findParentButton(leaf, button);
263
+ if (parentButton)
264
+ find = parentButton[attrName];
265
+ }
266
+ return find;
267
+ }
268
+ function checkState(stateName, leaf, button) {
269
+ let find = leaf.states[stateName];
270
+ if (!find && button) {
271
+ const parentButton = findParentButton(leaf, button);
272
+ if (parentButton)
273
+ find = parentButton.states[stateName];
274
+ }
275
+ return !!find;
276
+ }
277
+
278
+ core.State.animateExcludes = {
279
+ animation: 1,
280
+ animationOut: 1,
281
+ transition: 1,
282
+ transitionOut: 1,
283
+ states: 1,
284
+ state: 1,
285
+ normalStyle: 1,
286
+ hoverStyle: 1,
287
+ pressStyle: 1,
288
+ focusStyle: 1,
289
+ selectedStyle: 1,
290
+ disabledStyle: 1
291
+ };
292
+ core.State.isState = function (state, leaf, button) { return checkState(state, leaf, button); };
293
+ core.State.isSelected = function (leaf, button) { return checkFixedState('selected', leaf, button); };
294
+ core.State.isDisabled = function (leaf, button) { return checkFixedState('disabled', leaf, button); };
295
+ core.State.isFocus = function (leaf, button) { return checkPointerState('isFocus', leaf, button); };
296
+ core.State.isHover = function (leaf, button) { return checkPointerState('isHover', leaf, button); };
297
+ core.State.isPress = function (leaf, button) { return checkPointerState('isPress', leaf, button); };
298
+ core.State.isDrag = function (leaf, button) { return checkPointerState('isDrag', leaf, button); };
299
+ core.State.setStyleName = function (leaf, stateType, value) { value ? setState(leaf, stateType, leaf[stateType]) : unsetState(leaf, stateType, leaf[stateType]); };
300
+ core.State.set = function (leaf, stateName) { const style = leaf.states[stateName]; style ? setState(leaf, stateName, style) : unsetState(leaf, stateName, style); };
301
+ core.State.getStyle = getStyle;
302
+ core.State.updateStyle = updateStyle;
303
+ core.State.updateEventStyle = updateEventStyle;
304
+ const ui$1 = core.UI.prototype;
305
+ stateType(false, 'selectedStyle')(ui$1, 'selected');
306
+ stateType(false, 'disabledStyle')(ui$1, 'disabled');
307
+ stateStyleType({})(ui$1, 'states');
308
+ stateType('')(ui$1, 'state');
309
+ core.dataType()(ui$1, 'normalStyle');
310
+ stateStyleType()(ui$1, 'hoverStyle');
311
+ stateStyleType()(ui$1, 'pressStyle');
312
+ stateStyleType()(ui$1, 'focusStyle');
313
+ stateStyleType()(ui$1, 'selectedStyle');
314
+ stateStyleType()(ui$1, 'disabledStyle');
315
+ core.dataType(false)(ui$1, 'button');
316
+ ui$1.focus = function (value = true) {
317
+ this.waitLeafer(() => {
318
+ let { focusData } = this.app.interaction;
319
+ if (value) {
320
+ if (focusData)
321
+ focusData.focus(false);
322
+ focusData = this;
323
+ }
324
+ else
325
+ focusData = null;
326
+ this.app.interaction.focusData = focusData;
327
+ value ? setPointerState(this, 'focusStyle') : unsetPointerState(this, 'focusStyle');
328
+ });
329
+ };
330
+ ui$1.updateState = function () {
331
+ core.State.updateStyle(this, undefined, 'in');
332
+ };
333
+
334
+ const gaussNodes = [0.1488743389, 0.4333953941, 0.6794095682, 0.8650633666, 0.9739065285];
335
+ const gaussWeights = [0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443];
336
+ const { sqrt } = Math;
337
+ const HighBezierHelper = {
338
+ getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY) {
339
+ let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y;
340
+ for (let i = 0; i < gaussNodes.length; i++) {
341
+ t1 = 0.5 * (1 + gaussNodes[i]);
342
+ t2 = 0.5 * (1 - gaussNodes[i]);
343
+ d1X = getDerivative(t1, fromX, x1, x2, toX);
344
+ d1Y = getDerivative(t1, fromY, y1, y2, toY);
345
+ d2X = getDerivative(t2, fromX, x1, x2, toX);
346
+ d2Y = getDerivative(t2, fromY, y1, y2, toY);
347
+ distance += gaussWeights[i] * (sqrt(d1X * d1X + d1Y * d1Y) + sqrt(d2X * d2X + d2Y * d2Y));
348
+ }
349
+ return distance * 0.5;
350
+ },
351
+ getDerivative(t, fromV, v1, v2, toV) {
352
+ const o = 1 - t;
353
+ return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
354
+ },
355
+ cut(data, t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
356
+ const o = 1 - t;
357
+ const ax = o * fromX + t * x1, ay = o * fromY + t * y1;
358
+ const mbx = o * x1 + t * x2, mby = o * y1 + t * y2;
359
+ const mcx = o * x2 + t * toX, mcy = o * y2 + t * toY;
360
+ const bx = o * ax + t * mbx, by = o * ay + t * mby;
361
+ const mbcx = o * mbx + t * mcx, mbcy = o * mby + t * mcy;
362
+ const cx = o * bx + t * mbcx, cy = o * by + t * mbcy;
363
+ data.push(draw.PathCommandMap.C, ax, ay, bx, by, cx, cy);
364
+ }
365
+ };
366
+ const { getDerivative } = HighBezierHelper;
367
+
368
+ const { M, L, C, Z } = draw.PathCommandMap;
369
+ const tempPoint = {}, tempFrom = {};
370
+ const HighCurveHelper = {
371
+ transform(data, matrix) {
372
+ let i = 0, command;
373
+ const len = data.length;
374
+ while (i < len) {
375
+ command = data[i];
376
+ switch (command) {
377
+ case M:
378
+ case L:
379
+ HighCurveHelper.transformPoints(data, matrix, i, 1);
380
+ i += 3;
381
+ break;
382
+ case C:
383
+ HighCurveHelper.transformPoints(data, matrix, i, 3);
384
+ i += 7;
385
+ break;
386
+ case Z:
387
+ i += 1;
388
+ }
389
+ }
390
+ },
391
+ transformPoints(data, matrix, start, pointCount) {
392
+ for (let i = start + 1, end = i + pointCount * 2; i < end; i += 2) {
393
+ tempPoint.x = data[i];
394
+ tempPoint.y = data[i + 1];
395
+ draw.MatrixHelper.toOuterPoint(matrix, tempPoint);
396
+ data[i] = tempPoint.x;
397
+ data[i + 1] = tempPoint.y;
398
+ }
399
+ },
400
+ getMotionPathData(data) {
401
+ let total = 0, distance, segments = [];
402
+ let i = 0, x = 0, y = 0, toX, toY, command;
403
+ const len = data.length;
404
+ while (i < len) {
405
+ command = data[i];
406
+ switch (command) {
407
+ case M:
408
+ case L:
409
+ toX = data[i + 1];
410
+ toY = data[i + 2];
411
+ distance = (command === L && i > 0) ? draw.PointHelper.getDistanceFrom(x, y, toX, toY) : 0;
412
+ x = toX;
413
+ y = toY;
414
+ i += 3;
415
+ break;
416
+ case C:
417
+ toX = data[i + 5];
418
+ toY = data[i + 6];
419
+ distance = HighBezierHelper.getDistance(x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], toX, toY);
420
+ x = toX;
421
+ y = toY;
422
+ i += 7;
423
+ break;
424
+ case Z:
425
+ i += 1;
426
+ default:
427
+ distance = 0;
428
+ }
429
+ segments.push(distance);
430
+ total += distance;
431
+ }
432
+ return { total, segments, data };
433
+ },
434
+ getDistancePoint(distanceData, motionDistance) {
435
+ const { segments, data } = distanceData;
436
+ motionDistance = draw.UnitConvert.number(motionDistance, distanceData.total);
437
+ let total = 0, distance, to = {};
438
+ let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
439
+ const len = data.length;
440
+ while (i < len) {
441
+ command = data[i];
442
+ switch (command) {
443
+ case M:
444
+ case L:
445
+ toX = data[i + 1];
446
+ toY = data[i + 2];
447
+ distance = segments[index];
448
+ if (total + distance > motionDistance || !distanceData.total) {
449
+ if (!i)
450
+ x = toX, y = toY;
451
+ tempFrom.x = x;
452
+ tempFrom.y = y;
453
+ to.x = toX;
454
+ to.y = toY;
455
+ draw.PointHelper.getDistancePoint(tempFrom, to, motionDistance - total, true);
456
+ to.rotation = draw.PointHelper.getAngle(tempFrom, to);
457
+ return to;
458
+ }
459
+ x = toX;
460
+ y = toY;
461
+ i += 3;
462
+ break;
463
+ case C:
464
+ toX = data[i + 5];
465
+ toY = data[i + 6];
466
+ distance = segments[index];
467
+ if (total + distance > motionDistance) {
468
+ const x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
469
+ motionDistance -= total;
470
+ draw.BezierHelper.getPointAndSet(motionDistance / distance, x, y, x1, y1, x2, y2, toX, toY, to);
471
+ draw.BezierHelper.getPointAndSet(Math.max(0, motionDistance - 0.1) / distance, x, y, x1, y1, x2, y2, toX, toY, tempFrom);
472
+ to.rotation = draw.PointHelper.getAngle(tempFrom, to);
473
+ return to;
474
+ }
475
+ x = toX;
476
+ y = toY;
477
+ i += 7;
478
+ break;
479
+ case Z:
480
+ i += 1;
481
+ default:
482
+ distance = 0;
483
+ }
484
+ index++;
485
+ total += distance;
486
+ }
487
+ return to;
488
+ },
489
+ getDistancePath(distanceData, motionDistance) {
490
+ const { segments, data } = distanceData, path = [];
491
+ motionDistance = draw.UnitConvert.number(motionDistance, distanceData.total);
492
+ let total = 0, distance, to = {};
493
+ let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
494
+ const len = data.length;
495
+ while (i < len) {
496
+ command = data[i];
497
+ switch (command) {
498
+ case M:
499
+ case L:
500
+ toX = data[i + 1];
501
+ toY = data[i + 2];
502
+ distance = segments[index];
503
+ if (total + distance > motionDistance || !distanceData.total) {
504
+ if (!i)
505
+ x = toX, y = toY;
506
+ tempFrom.x = x;
507
+ tempFrom.y = y;
508
+ to.x = toX;
509
+ to.y = toY;
510
+ draw.PointHelper.getDistancePoint(tempFrom, to, motionDistance - total, true);
511
+ path.push(command, to.x, to.y);
512
+ return path;
513
+ }
514
+ x = toX;
515
+ y = toY;
516
+ i += 3;
517
+ path.push(command, x, y);
518
+ break;
519
+ case C:
520
+ const x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
521
+ toX = data[i + 5];
522
+ toY = data[i + 6];
523
+ distance = segments[index];
524
+ if (total + distance > motionDistance) {
525
+ HighBezierHelper.cut(path, (motionDistance - total) / distance, x, y, x1, y1, x2, y2, toX, toY);
526
+ return path;
527
+ }
528
+ x = toX;
529
+ y = toY;
530
+ i += 7;
531
+ path.push(command, x1, y1, x2, y2, toX, toY);
532
+ break;
533
+ case Z:
534
+ i += 1;
535
+ path.push(command);
536
+ default:
537
+ distance = 0;
538
+ }
539
+ index++;
540
+ total += distance;
541
+ }
542
+ return path;
543
+ }
544
+ };
545
+
546
+ function motionPathType(defaultValue) {
547
+ return draw.decorateLeafAttr(defaultValue, (key) => draw.attr({
548
+ set(value) {
549
+ this.__setAttr(key, value);
550
+ this.__hasMotionPath = this.motionPath || !draw.isNull(this.motion);
551
+ this.__layout.matrixChanged || this.__layout.matrixChange();
552
+ }
553
+ }));
554
+ }
555
+
556
+ draw.Transition.register('motion', function (from, to, t, target) {
557
+ if (!from)
558
+ from = 0;
559
+ else if (typeof from === 'object')
560
+ from = draw.UnitConvert.number(from, target.getMotionTotal());
561
+ if (!to)
562
+ to = 0;
563
+ else if (typeof to === 'object')
564
+ to = draw.UnitConvert.number(to, target.getMotionTotal());
565
+ return draw.Transition.number(from, to, t);
566
+ });
567
+ draw.Transition.register('motionRotation', function (from, to, t) {
568
+ return draw.Transition.number(from, to, t);
569
+ });
570
+ const ui = draw.UI.prototype;
571
+ const { updateMatrix, updateAllMatrix } = draw.LeafHelper;
572
+ const { updateBounds } = draw.BranchHelper;
573
+ motionPathType()(ui, 'motionPath');
574
+ motionPathType()(ui, 'motion');
575
+ motionPathType(true)(ui, 'motionRotation');
576
+ ui.getMotionPathData = function () {
577
+ return getMotionPathData(getMotionPath(this));
578
+ };
579
+ ui.getMotionPoint = function (motionDistance) {
580
+ const path = getMotionPath(this);
581
+ const data = getMotionPathData(path);
582
+ if (!data.total)
583
+ return {};
584
+ const point = HighCurveHelper.getDistancePoint(data, motionDistance);
585
+ draw.MatrixHelper.toOuterPoint(path.localTransform, point);
586
+ const { motionRotation } = this;
587
+ if (motionRotation === false)
588
+ delete point.rotation;
589
+ else if (typeof motionRotation === 'number')
590
+ point.rotation += motionRotation;
591
+ return point;
592
+ };
593
+ ui.getMotionTotal = function () {
594
+ return this.getMotionPathData().total;
595
+ };
596
+ ui.__updateMotionPath = function () {
597
+ const data = this.__;
598
+ if (this.__layout.resized && data.__pathForMotion)
599
+ data.__pathForMotion = undefined;
600
+ if (this.motionPath) {
601
+ let child;
602
+ const { children } = this.parent, { leaferIsReady } = this;
603
+ for (let i = 0; i < children.length; i++) {
604
+ child = children[i];
605
+ if (!draw.isNull(child.motion) && !child.__layout.matrixChanged) {
606
+ if (leaferIsReady && child !== this)
607
+ this.leafer.layouter.addExtra(child);
608
+ updateMotion(child);
609
+ }
610
+ }
611
+ }
612
+ else
613
+ updateMotion(this);
614
+ };
615
+ function updateMotion(leaf) {
616
+ const { motion, leaferIsCreated } = leaf;
617
+ if (draw.isNull(motion))
618
+ return;
619
+ if (leaferIsCreated)
620
+ leaf.leafer.created = false;
621
+ if (leaf.motionPath) {
622
+ const data = getMotionPathData(leaf);
623
+ if (data.total)
624
+ leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion);
625
+ }
626
+ else {
627
+ leaf.set(leaf.getMotionPoint(motion));
628
+ if (!leaf.__hasAutoLayout) {
629
+ if (leaf.isBranch)
630
+ updateAllMatrix(leaf), updateBounds(leaf, leaf);
631
+ else
632
+ updateMatrix(leaf);
633
+ }
634
+ }
635
+ if (leaferIsCreated)
636
+ leaf.leafer.created = true;
637
+ }
638
+ function getMotionPath(leaf) {
639
+ const { parent } = leaf;
640
+ if (!leaf.motionPath && parent) {
641
+ const { children } = parent;
642
+ for (let i = 0; i < children.length; i++) {
643
+ if (children[i].motionPath)
644
+ return children[i];
645
+ }
646
+ }
647
+ return leaf;
648
+ }
649
+ function getMotionPathData(leaf) {
650
+ const data = leaf.__;
651
+ if (data.__pathForMotion)
652
+ return data.__pathForMotion;
653
+ return data.__pathForMotion = HighCurveHelper.getMotionPathData(leaf.getPath(true, true));
654
+ }
655
+
656
+ exports.HighBezierHelper = HighBezierHelper;
657
+ exports.HighCurveHelper = HighCurveHelper;
658
+ exports.motionPathType = motionPathType;
659
+ exports.stateStyleType = stateStyleType;
660
+ exports.stateType = stateType;
661
+ Object.keys(leaferUi).forEach(function (k) {
662
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
663
+ enumerable: true,
664
+ get: function () { return leaferUi[k]; }
665
+ });
666
+ });
667
+ Object.keys(robot).forEach(function (k) {
668
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
669
+ enumerable: true,
670
+ get: function () { return robot[k]; }
671
+ });
672
+ });
673
+ Object.keys(animate).forEach(function (k) {
674
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
675
+ enumerable: true,
676
+ get: function () { return animate[k]; }
677
+ });
678
+ });