@luceosports/play-rendering 2.6.0 → 2.6.2

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.
@@ -1,9 +1,10 @@
1
1
  import _ from 'lodash';
2
2
  import Model from './Base/InternalFrameModel';
3
- import { AnimationMode, Line as LineData, LinePart, Player } from '../types';
3
+ import { AnimationMode, Line as LineData, LinePart } from '../types';
4
+ import { isBallTransferLineType } from '../helpers/common';
4
5
 
5
6
  export type CourtPointAdjusted = { x: number; y: number; time?: number };
6
- export type LineAdjusted = LineData & { animationKeyTimeChunks: [number, number][] };
7
+ export type LineAdjusted = LineData;
7
8
  export type LinePartAdjusted = {
8
9
  controlPoints:
9
10
  | [CourtPointAdjusted, CourtPointAdjusted]
@@ -54,36 +55,6 @@ export default class LineModel extends Model<LineData, LineAdjusted> {
54
55
  }
55
56
  }
56
57
 
57
- setAnimationKeyTimesChunked(linePlayer: Player, mode: AnimationMode) {
58
- let keyTimesChunks: [number, number][] = [];
59
- const lineKeyTimes = this.getLineAnimationKeyTimes(mode);
60
-
61
- lineKeyTimes.forEach((value, index) => {
62
- if (index) keyTimesChunks.push([lineKeyTimes[index - 1], value]);
63
- });
64
-
65
- if (keyTimesChunks.length !== this.getLineParts().length) {
66
- const [[start, end]] = keyTimesChunks;
67
- const [animation] = linePlayer.animations;
68
-
69
- const playerKeyTimes =
70
- mode === AnimationMode.SEQUENTIAL ? animation.keyTimesSeq || animation.keyTimes : animation.keyTimes;
71
-
72
- const playerAnimStartIndex = playerKeyTimes.indexOf(start);
73
- const playerAnimEndIndex = playerKeyTimes.indexOf(end);
74
-
75
- if (playerAnimStartIndex >= 0 && playerAnimEndIndex >= 0) {
76
- const derivedLineKeyTimes = playerKeyTimes.slice(playerAnimStartIndex, playerAnimEndIndex + 1);
77
- keyTimesChunks = [];
78
- derivedLineKeyTimes.forEach((value, index) => {
79
- if (index) keyTimesChunks.push([derivedLineKeyTimes[index - 1], value]);
80
- });
81
- }
82
- }
83
-
84
- this.animationKeyTimeChunks = keyTimesChunks;
85
- }
86
-
87
58
  addLinePartAdjusted(data: LinePartAdjusted) {
88
59
  this.linePartsAdjusted.push(data);
89
60
  }
@@ -112,7 +83,7 @@ export default class LineModel extends Model<LineData, LineAdjusted> {
112
83
  }
113
84
 
114
85
  get isBallTransferLine() {
115
- return ['PASS', 'HANDOFF', 'SHOT'].includes(this.type);
86
+ return isBallTransferLineType(this.type);
116
87
  }
117
88
 
118
89
  get phase() {
@@ -139,25 +110,12 @@ export default class LineModel extends Model<LineData, LineAdjusted> {
139
110
  return this._getAttr('animations');
140
111
  }
141
112
 
142
- private getLineAnimationKeyTimes(mode: AnimationMode) {
143
- const a = this.animations[0];
144
- return mode === AnimationMode.SEQUENTIAL ? a.keyTimesSeq || a.keyTimes : a.keyTimes;
145
- }
146
-
147
113
  animationsByEndTime(mode: AnimationMode) {
148
114
  return this._getAttr('animations').map(a =>
149
115
  _.last(mode === AnimationMode.SEQUENTIAL ? a.keyTimesSeq || a.keyTimes : a.keyTimes)
150
116
  );
151
117
  }
152
118
 
153
- get animationKeyTimeChunks() {
154
- return this._getAttr('animationKeyTimeChunks') || [];
155
- }
156
-
157
- set animationKeyTimeChunks(value) {
158
- this._setAttr('animationKeyTimeChunks', value);
159
- }
160
-
161
119
  lastAnimEndTime(mode: AnimationMode) {
162
120
  return _.max(this.animationsByEndTime(mode));
163
121
  }