@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
package/src/models/LineModel.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import Model from './Base/InternalFrameModel';
|
|
3
|
-
import { Line as LineData, LinePart
|
|
3
|
+
import { AnimationMode, Line as LineData, LinePart } from '../types';
|
|
4
4
|
|
|
5
5
|
export type CourtPointAdjusted = { x: number; y: number; time?: number };
|
|
6
|
-
export type LineAdjusted = LineData
|
|
6
|
+
export type LineAdjusted = LineData;
|
|
7
7
|
export type LinePartAdjusted = {
|
|
8
8
|
controlPoints:
|
|
9
9
|
| [CourtPointAdjusted, CourtPointAdjusted]
|
|
@@ -54,29 +54,6 @@ export default class LineModel extends Model<LineData, LineAdjusted> {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
setAnimationKeyTimesChunked(linePlayer: Player) {
|
|
58
|
-
let keyTimesChunks: [number, number][] = [];
|
|
59
|
-
this.animations[0].keyTimes.forEach((value, index) => {
|
|
60
|
-
if (index) keyTimesChunks.push([this.animations[0].keyTimes[index - 1], value]);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
if (keyTimesChunks.length !== this.getLineParts().length) {
|
|
64
|
-
const [[start, end]] = keyTimesChunks;
|
|
65
|
-
const [animation] = linePlayer.animations;
|
|
66
|
-
const playerAnimStartIndex = animation.keyTimes.indexOf(start);
|
|
67
|
-
const playerAnimEndIndex = animation.keyTimes.indexOf(end);
|
|
68
|
-
if (playerAnimStartIndex >= 0 && playerAnimEndIndex >= 0) {
|
|
69
|
-
const lineKeyTimes = animation.keyTimes.slice(playerAnimStartIndex, playerAnimEndIndex + 1);
|
|
70
|
-
keyTimesChunks = [];
|
|
71
|
-
lineKeyTimes.forEach((value, index) => {
|
|
72
|
-
if (index) keyTimesChunks.push([lineKeyTimes[index - 1], value]);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
this.animationKeyTimeChunks = keyTimesChunks;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
57
|
addLinePartAdjusted(data: LinePartAdjusted) {
|
|
81
58
|
this.linePartsAdjusted.push(data);
|
|
82
59
|
}
|
|
@@ -132,20 +109,14 @@ export default class LineModel extends Model<LineData, LineAdjusted> {
|
|
|
132
109
|
return this._getAttr('animations');
|
|
133
110
|
}
|
|
134
111
|
|
|
135
|
-
|
|
136
|
-
return this._getAttr('animations').map(a =>
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
get animationKeyTimeChunks() {
|
|
140
|
-
return this._getAttr('animationKeyTimeChunks') || [];
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
set animationKeyTimeChunks(value) {
|
|
144
|
-
this._setAttr('animationKeyTimeChunks', value);
|
|
112
|
+
animationsByEndTime(mode: AnimationMode) {
|
|
113
|
+
return this._getAttr('animations').map(a =>
|
|
114
|
+
_.last(mode === AnimationMode.SEQUENTIAL ? a.keyTimesSeq || a.keyTimes : a.keyTimes)
|
|
115
|
+
);
|
|
145
116
|
}
|
|
146
117
|
|
|
147
|
-
|
|
148
|
-
return _.max(this.animationsByEndTime);
|
|
118
|
+
lastAnimEndTime(mode: AnimationMode) {
|
|
119
|
+
return _.max(this.animationsByEndTime(mode));
|
|
149
120
|
}
|
|
150
121
|
|
|
151
122
|
get firstLinePartControlPoint() {
|
|
@@ -1,39 +1,41 @@
|
|
|
1
|
-
import { PlayModelOptions } from '../PlayModel';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
1
|
+
import { PlayModelOptions } from '../PlayModel';
|
|
2
|
+
import { AnimationMode } from '../../types';
|
|
3
|
+
|
|
4
|
+
export function useDefaults(options?: Partial<PlayModelOptions>): PlayModelOptions {
|
|
5
|
+
const defaults = {
|
|
6
|
+
width: 300,
|
|
7
|
+
lineColor: '#fff', // courtBorderColor
|
|
8
|
+
linesDisplay: 'VISIBLE' as const,
|
|
9
|
+
linesDisplayOnMoveOnly: true,
|
|
10
|
+
linesHiddenIds: [],
|
|
11
|
+
linesHighlightedIds: [],
|
|
12
|
+
linesSelectedIds: [],
|
|
13
|
+
shapeSelectedId: null,
|
|
14
|
+
noteSelectedId: null,
|
|
15
|
+
playersHiddenPositions: [],
|
|
16
|
+
background: '',
|
|
17
|
+
watermark: null,
|
|
18
|
+
mirror: false,
|
|
19
|
+
speed: 1,
|
|
20
|
+
position: null,
|
|
21
|
+
huddleMode: false,
|
|
22
|
+
magnetMode: false,
|
|
23
|
+
flipPlayerLabels: false,
|
|
24
|
+
legacyPrintStyle: false,
|
|
25
|
+
playerTokenScale: 1,
|
|
26
|
+
animationMode: AnimationMode.PREDICTIVE,
|
|
27
|
+
showBallMode: false,
|
|
28
|
+
// showBallMode sub-options (defaults match current behavior)
|
|
29
|
+
highlightPlayerPuck: true,
|
|
30
|
+
showPassLinesDuringPlayback: true,
|
|
31
|
+
// TODO: refactor NBA court type constants below
|
|
32
|
+
showHalfCourtCircle: true,
|
|
33
|
+
playersMap: [],
|
|
34
|
+
labelsOverrideType: null,
|
|
35
|
+
inDrawingState: false
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
...defaults,
|
|
39
|
+
...(options || {})
|
|
40
|
+
};
|
|
41
|
+
}
|
package/src/models/PlayModel.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
SPORT_TYPE_VOLLEYBALL
|
|
18
18
|
} from '../constants';
|
|
19
19
|
|
|
20
|
-
import { PlayConstructData, PlayData, Position, SportType } from '../types';
|
|
20
|
+
import { AnimationMode, PlayConstructData, PlayData, Position, SportType } from '../types';
|
|
21
21
|
|
|
22
22
|
import hardwoodImageData from '../assets/wood_bg.png';
|
|
23
23
|
import grassImageData from '../assets/grass_bg.png';
|
|
@@ -96,6 +96,7 @@ export type PlayModelOptions = {
|
|
|
96
96
|
// sub-options for showBallMode
|
|
97
97
|
highlightPlayerPuck: boolean;
|
|
98
98
|
showPassLinesDuringPlayback: boolean;
|
|
99
|
+
animationMode: AnimationMode;
|
|
99
100
|
};
|
|
100
101
|
|
|
101
102
|
export default class PlayModel {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import Model from './Base/InternalFrameModel';
|
|
3
|
-
import { Line, Player as PlayerData } from '../types';
|
|
3
|
+
import { AnimationMode, Line, Player as PlayerData, PlayerAnimation } from '../types';
|
|
4
4
|
|
|
5
5
|
export default class PlayerModel extends Model<PlayerData, PlayerData> {
|
|
6
6
|
get id() {
|
|
@@ -51,12 +51,16 @@ export default class PlayerModel extends Model<PlayerData, PlayerData> {
|
|
|
51
51
|
return this._getAttr('animations');
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
return
|
|
54
|
+
private getAnimationKeyTimes(animation: PlayerAnimation, mode: AnimationMode) {
|
|
55
|
+
return mode === AnimationMode.SEQUENTIAL ? animation.keyTimesSeq || animation.keyTimes : animation.keyTimes;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
return _.
|
|
58
|
+
animationsByEndTime(mode: AnimationMode) {
|
|
59
|
+
return this._getAttr('animations').map(a => _.last(this.getAnimationKeyTimes(a, mode)));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
lastAnimEndTime(mode: AnimationMode) {
|
|
63
|
+
return _.max(this.animationsByEndTime(mode));
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
get lastAnimation() {
|
package/src/types/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { AnimationMode } from './enums';
|
|
2
|
+
|
|
1
3
|
export type PlayerPosition = `${number}`;
|
|
2
4
|
|
|
3
5
|
export type DefenderPosition = `x${number}`;
|
|
@@ -136,6 +138,7 @@ export type PlayerAnimationType = 'POSITION';
|
|
|
136
138
|
export interface Animation {
|
|
137
139
|
id: string;
|
|
138
140
|
keyTimes: number[];
|
|
141
|
+
keyTimesSeq?: number[];
|
|
139
142
|
}
|
|
140
143
|
|
|
141
144
|
export interface PlayerAnimation extends Animation {
|
|
@@ -155,10 +158,8 @@ export interface Player {
|
|
|
155
158
|
|
|
156
159
|
export type LineAnimationType = 'LINESTROKE';
|
|
157
160
|
|
|
158
|
-
export interface LineAnimation {
|
|
159
|
-
id: string;
|
|
161
|
+
export interface LineAnimation extends Animation {
|
|
160
162
|
type: LineAnimationType;
|
|
161
|
-
keyTimes: number[];
|
|
162
163
|
strokeStartValues: [number, number, number];
|
|
163
164
|
}
|
|
164
165
|
|