@luceosports/play-rendering 2.5.7 → 2.6.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/play-rendering.d.ts +2 -1
- package/dist/play-rendering.js +23 -23
- package/dist/play-rendering.js.map +1 -1
- package/dist/types/helpers/animation.d.ts +16 -0
- package/dist/types/models/LineModel.d.ts +3 -5
- package/dist/types/models/PlayModel.d.ts +2 -1
- package/dist/types/models/PlayerModel.d.ts +3 -3
- package/dist/types/types/enums.d.ts +4 -0
- package/dist/types/types/index.d.ts +142 -142
- package/package.json +1 -1
- package/src/helpers/animation.ts +116 -32
- package/src/index.ts +5 -1
- package/src/layers/line/layers/DribbleLineLayer.ts +62 -50
- package/src/models/AnimationModel.ts +8 -2
- package/src/models/FrameModel.ts +536 -518
- package/src/models/LineModel.ts +8 -37
- package/src/models/Play/Options.ts +41 -39
- package/src/models/PlayModel.ts +2 -1
- package/src/models/PlayerModel.ts +9 -5
- package/src/types/enums.ts +4 -0
- package/src/types/index.ts +4 -3
|
@@ -1,50 +1,62 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
|
-
import { animationProgress } from '../../../helpers/common';
|
|
3
|
-
import ActionLineLayer from '../base/ActionLineLayer';
|
|
4
|
-
import DribbleLineTrait from '../../../traits/DribbleLineTrait';
|
|
5
|
-
import { LinePart } from '../../../types';
|
|
6
|
-
import { LinePartAdjusted } from '../../../models/LineModel';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import { animationProgress } from '../../../helpers/common';
|
|
3
|
+
import ActionLineLayer from '../base/ActionLineLayer';
|
|
4
|
+
import DribbleLineTrait from '../../../traits/DribbleLineTrait';
|
|
5
|
+
import { LinePart, AnimationMode } from '../../../types';
|
|
6
|
+
import { LinePartAdjusted } from '../../../models/LineModel';
|
|
7
|
+
import { getLineAnimationChunks } from '../../../helpers/animation';
|
|
8
|
+
|
|
9
|
+
export default class DribbleLineLayer extends ActionLineLayer {
|
|
10
|
+
// ================ DribbleLineTrait Methods ====================
|
|
11
|
+
private convertLinePartsToDribble(lineParts: LinePart[]): LinePartAdjusted[] {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
// ==============================================================
|
|
15
|
+
|
|
16
|
+
drawLineCap() {
|
|
17
|
+
if (this.allowDrawLineCap()) this.drawArrowLineCap();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
setLineOptions() {
|
|
21
|
+
const lineParts = [...this.line.getLineParts()];
|
|
22
|
+
const dribbleLineParts = this.convertLinePartsToDribble(lineParts);
|
|
23
|
+
|
|
24
|
+
const mode = this.options.animationMode ?? AnimationMode.SEQUENTIAL;
|
|
25
|
+
|
|
26
|
+
const chunks = getLineAnimationChunks({
|
|
27
|
+
mode,
|
|
28
|
+
line: this.line.originalData,
|
|
29
|
+
players: this.playData.players
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
this.line.setLinePartsAdjusted([]);
|
|
33
|
+
|
|
34
|
+
dribbleLineParts.forEach(lp => {
|
|
35
|
+
const { controlPoints, lpIndex } = lp;
|
|
36
|
+
const [firstPoint] = controlPoints;
|
|
37
|
+
|
|
38
|
+
let animationSegment: LinePartAdjusted['animationSegment'] | undefined = undefined;
|
|
39
|
+
|
|
40
|
+
if (this.options.animationGlobalProgress && lpIndex != null) {
|
|
41
|
+
const chunk = chunks[lpIndex];
|
|
42
|
+
if (chunk) {
|
|
43
|
+
const [start, end] = chunk;
|
|
44
|
+
|
|
45
|
+
if (_.inRange(this.options.animationGlobalProgress, start, end)) {
|
|
46
|
+
if (animationProgress(this.options.animationGlobalProgress, start, end) > firstPoint.time!) {
|
|
47
|
+
animationSegment = 'processed';
|
|
48
|
+
} else {
|
|
49
|
+
animationSegment = 'active';
|
|
50
|
+
}
|
|
51
|
+
} else if (this.options.animationGlobalProgress > end) {
|
|
52
|
+
animationSegment = 'processed';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.line.addLinePartAdjusted({ ...lp, controlPoints, animationSegment });
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Object.assign(DribbleLineLayer.prototype, DribbleLineTrait);
|
|
@@ -67,22 +67,28 @@ export default class AnimationModel {
|
|
|
67
67
|
|
|
68
68
|
get linesPhaseIntervals(): Record<number, { min: number; max: number }> {
|
|
69
69
|
const result: Record<number, { min: number; max: number }> = {};
|
|
70
|
+
const mode = this.play.options.animationMode;
|
|
71
|
+
|
|
70
72
|
this.play.playData.lines.forEach(line => {
|
|
71
73
|
if (!result[line.phase]) result[line.phase] = { min: 0, max: 0 };
|
|
72
|
-
line.animations.forEach(
|
|
74
|
+
line.animations.forEach(animation => {
|
|
75
|
+
const keyTimes = mode === 'SEQUENTIAL' ? animation.keyTimesSeq || [] : animation.keyTimes;
|
|
76
|
+
|
|
73
77
|
const [from] = keyTimes;
|
|
74
78
|
const to = [...keyTimes].pop()!;
|
|
75
79
|
if (from < result[line.phase].min || (!result[line.phase].min && line.phase > 1)) result[line.phase].min = from;
|
|
76
80
|
if (to > result[line.phase].max) result[line.phase].max = to;
|
|
77
81
|
});
|
|
78
82
|
});
|
|
83
|
+
|
|
79
84
|
return result;
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
get lastLineAnimationMax() {
|
|
88
|
+
const mode = this.play.options.animationMode;
|
|
83
89
|
return this.play.playData.lines.reduce<number>((result, line) => {
|
|
84
90
|
const lineModel = new LineModel(line);
|
|
85
|
-
return result > lineModel.lastAnimEndTime! ? result : lineModel.lastAnimEndTime!;
|
|
91
|
+
return result > lineModel.lastAnimEndTime(mode)! ? result : lineModel.lastAnimEndTime(mode)!;
|
|
86
92
|
}, 0);
|
|
87
93
|
}
|
|
88
94
|
|