@luceosports/play-rendering 2.6.2 → 2.7.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/play-rendering.js +23 -23
- package/dist/play-rendering.js.map +1 -1
- package/dist/types/helpers/animation.d.ts +0 -2
- package/dist/types/models/PlayerModel.d.ts +1 -6
- package/dist/types/types/index.d.ts +8 -12
- package/package.json +1 -1
- package/src/assets/balls/baseball.svg +1 -1
- package/src/assets/balls/basketball.svg +1 -1
- package/src/assets/balls/football.svg +1 -1
- package/src/assets/balls/lacrosse.svg +3 -3
- package/src/assets/balls/soccer.svg +1 -1
- package/src/assets/balls/volleyball.svg +1 -1
- package/src/helpers/animation.ts +4 -33
- package/src/helpers/draw.ts +1 -2
- package/src/models/PlayerModel.ts +1 -26
- package/src/types/index.ts +9 -15
|
@@ -9,9 +9,7 @@ export declare const getEffectiveTimeline: (anim: HasKeyTimes, timeline: Timelin
|
|
|
9
9
|
export declare const keyTimesToChunks: (keyTimes: number[]) => [number, number][];
|
|
10
10
|
export declare const deriveLineChunksWithFallback: (params: {
|
|
11
11
|
timeline: TimelineKey;
|
|
12
|
-
playerAnimation: HasKeyTimes;
|
|
13
12
|
lineAnimation: HasKeyTimes;
|
|
14
13
|
lineType: LineType;
|
|
15
14
|
lineParts: LinePart[];
|
|
16
|
-
legacySupport?: boolean;
|
|
17
15
|
}) => [number, number][];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Color, CourtPoint, Line, Player,
|
|
1
|
+
import { Color, CourtPoint, Line, Player, Position, AnimationMode } from "../../play-rendering";
|
|
2
2
|
|
|
3
3
|
export class PlayerModel {
|
|
4
4
|
constructor(data: Player);
|
|
@@ -12,10 +12,5 @@ export class PlayerModel {
|
|
|
12
12
|
get position(): Position;
|
|
13
13
|
get location(): CourtPoint;
|
|
14
14
|
get color(): Color;
|
|
15
|
-
get animations(): PlayerAnimation[];
|
|
16
|
-
animationsByEndTime(mode: AnimationMode): number[];
|
|
17
|
-
lastAnimEndTime(mode: AnimationMode): number;
|
|
18
|
-
get lastAnimation(): PlayerAnimation;
|
|
19
|
-
get lastAnimationLastLinePartControlPoint(): CourtPoint;
|
|
20
15
|
setPossession(prevPassLines: Line[]): void;
|
|
21
16
|
}
|
|
@@ -59,16 +59,6 @@ export interface Court {
|
|
|
59
59
|
type: CourtType;
|
|
60
60
|
courtRect: CourtRect;
|
|
61
61
|
}
|
|
62
|
-
export type PlayerAnimationType = 'POSITION';
|
|
63
|
-
export interface Animation {
|
|
64
|
-
id: string;
|
|
65
|
-
keyTimes: number[];
|
|
66
|
-
keyTimesSeq?: number[];
|
|
67
|
-
}
|
|
68
|
-
export interface PlayerAnimation extends Animation {
|
|
69
|
-
type: PlayerAnimationType;
|
|
70
|
-
lineParts: LinePart[];
|
|
71
|
-
}
|
|
72
62
|
export interface Player {
|
|
73
63
|
id: string;
|
|
74
64
|
possession: boolean;
|
|
@@ -76,10 +66,16 @@ export interface Player {
|
|
|
76
66
|
position: Position;
|
|
77
67
|
location: CourtPoint;
|
|
78
68
|
textOverride?: string;
|
|
79
|
-
|
|
69
|
+
}
|
|
70
|
+
export interface Animation {
|
|
71
|
+
id: string;
|
|
72
|
+
keyTimes: number[];
|
|
80
73
|
}
|
|
81
74
|
export type LineAnimationType = 'LINESTROKE';
|
|
82
|
-
export interface LineAnimation
|
|
75
|
+
export interface LineAnimation {
|
|
76
|
+
id: string;
|
|
77
|
+
keyTimes: number[];
|
|
78
|
+
keyTimesSeq?: number[];
|
|
83
79
|
type: LineAnimationType;
|
|
84
80
|
strokeStartValues: [number, number, number];
|
|
85
81
|
}
|
package/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<svg fill="#
|
|
2
|
+
<svg fill="#FFFFFF" width="800px" height="800px" viewBox="-8 0 512 512" xmlns="http://www.w3.org/2000/svg"><path d="M368.5 363.9l28.8-13.9c11.1 22.9 26 43.2 44.1 60.9 34-42.5 54.5-96.3 54.5-154.9 0-58.5-20.4-112.2-54.2-154.6-17.8 17.3-32.6 37.1-43.6 59.5l-28.7-14.1c12.8-26 30-49 50.8-69C375.6 34.7 315 8 248 8 181.1 8 120.5 34.6 75.9 77.7c20.7 19.9 37.9 42.9 50.7 68.8l-28.7 14.1c-11-22.3-25.7-42.1-43.5-59.4C20.4 143.7 0 197.4 0 256c0 58.6 20.4 112.3 54.4 154.7 18.2-17.7 33.2-38 44.3-61l28.8 13.9c-12.9 26.7-30.3 50.3-51.5 70.7 44.5 43.1 105.1 69.7 172 69.7 66.8 0 127.3-26.5 171.9-69.5-21.1-20.4-38.5-43.9-51.4-70.6zm-228.3-32l-30.5-9.8c14.9-46.4 12.7-93.8-.6-134l30.4-10c15 45.6 18 99.9.7 153.8zm216.3-153.4l30.4 10c-13.2 40.1-15.5 87.5-.6 134l-30.5 9.8c-17.3-54-14.3-108.3.7-153.8z"/></svg>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<svg width="
|
|
2
|
+
<svg width="512px" height="512px" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path fill="#FF7A00" d="M248.37 41.094c-49.643 1.754-98.788 20.64-137.89 56.656L210.53 197.8c31.283-35.635 45.59-88.686 37.84-156.706zm18.126.107c7.646 71.205-7.793 129.56-43.223 169.345L256 243.27 401.52 97.75c-38.35-35.324-86.358-54.18-135.024-56.55zM97.75 110.48c-36.017 39.102-54.902 88.247-56.656 137.89 68.02 7.75 121.07-6.557 156.707-37.84L97.75 110.48zm316.5 0L268.73 256l32.71 32.71c33.815-30.112 81.05-45.78 138.183-45.11 10.088.118 20.49.753 31.176 1.9-2.37-48.665-21.227-96.672-56.55-135.02zM210.545 223.272c-39.785 35.43-98.14 50.87-169.344 43.223 2.37 48.666 21.226 96.675 56.55 135.025L243.27 256l-32.725-32.727zm225.002 38.27c-51.25.042-92.143 14.29-121.348 39.928l100.05 100.05c36.017-39.102 54.902-88.247 56.656-137.89-12.275-1.4-24.074-2.096-35.36-2.087zM256 268.73L110.48 414.25c38.35 35.324 86.358 54.18 135.024 56.55-7.646-71.205 7.793-129.56 43.223-169.345L256 268.73zm45.47 45.47c-31.283 35.635-45.59 88.686-37.84 156.706 49.643-1.754 98.788-20.64 137.89-56.656L301.47 314.2z"/></svg>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<svg fill="#
|
|
2
|
+
<svg fill="#8B4513" width="800px" height="800px" viewBox="-8 0 512 512" xmlns="http://www.w3.org/2000/svg"><path d="M481.5 60.3c-4.8-18.2-19.1-32.5-37.3-37.4C420.3 16.5 383 8.9 339.4 8L496 164.8c-.8-43.5-8.2-80.6-14.5-104.5zm-467 391.4c4.8 18.2 19.1 32.5 37.3 37.4 23.9 6.4 61.2 14 104.8 14.9L0 347.2c.8 43.5 8.2 80.6 14.5 104.5zM4.2 283.4L220.4 500c132.5-19.4 248.8-118.7 271.5-271.4L275.6 12C143.1 31.4 26.8 130.7 4.2 283.4zm317.3-123.6c3.1-3.1 8.2-3.1 11.3 0l11.3 11.3c3.1 3.1 3.1 8.2 0 11.3l-28.3 28.3 28.3 28.3c3.1 3.1 3.1 8.2 0 11.3l-11.3 11.3c-3.1 3.1-8.2 3.1-11.3 0l-28.3-28.3-22.6 22.7 28.3 28.3c3.1 3.1 3.1 8.2 0 11.3l-11.3 11.3c-3.1 3.1-8.2 3.1-11.3 0L248 278.6l-22.6 22.6 28.3 28.3c3.1 3.1 3.1 8.2 0 11.3l-11.3 11.3c-3.1 3.1-8.2 3.1-11.3 0l-28.3-28.3-28.3 28.3c-3.1 3.1-8.2 3.1-11.3 0l-11.3-11.3c-3.1-3.1-3.1-8.2 0-11.3l28.3-28.3-28.3-28.2c-3.1-3.1-3.1-8.2 0-11.3l11.3-11.3c3.1-3.1 8.2-3.1 11.3 0l28.3 28.3 22.6-22.6-28.3-28.3c-3.1-3.1-3.1-8.2 0-11.3l11.3-11.3c3.1-3.1 8.2-3.1 11.3 0l28.3 28.3 22.6-22.6-28.3-28.3c-3.1-3.1-3.1-8.2 0-11.3l11.3-11.3c3.1-3.1 8.2-3.1 11.3 0l28.3 28.3 28.3-28.5z"/></svg>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
2
|
<svg height="800px" width="800px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
3
3
|
viewBox="0 0 512 512" xml:space="preserve">
|
|
4
|
-
<path style="fill:#
|
|
5
|
-
<path style="fill:#
|
|
4
|
+
<path style="fill:#FFFFFF;" d="M512,256c0,141.384-114.616,256-256,256S0,397.384,0,256S114.616,0,256,0S512,114.616,512,256z"/>
|
|
5
|
+
<path style="fill:#FFFFFF;" d="M512,256c0,141.384-114.615,256-256,256C132.098,512,28.761,423.976,5.098,307.054
|
|
6
6
|
c39.175,56.575,104.53,93.641,178.554,93.641c119.87,0,217.043-97.174,217.043-217.043c0-74.024-37.067-139.38-93.641-178.554
|
|
7
7
|
C423.976,28.761,512,132.098,512,256z"/>
|
|
8
8
|
<path style="fill:#FFFFFF;" d="M464.696,256v0.493c-0.017,4.6-3.751,8.319-8.348,8.319c-0.01,0-0.02,0-0.03,0
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
c-4.548-0.767-8.854,2.292-9.623,6.837C429.629,380.833,350.019,448,256,448c-4.61,0-8.348,3.738-8.348,8.348
|
|
11
11
|
s3.738,8.348,8.348,8.348c49.603,0,97.675-17.703,135.363-49.849c37.264-31.784,62.264-75.739,70.396-123.767
|
|
12
12
|
C462.529,286.534,459.468,282.226,454.922,281.456z"/>
|
|
13
|
-
<path style="fill:#
|
|
13
|
+
<path style="fill:#FFFFFF;" d="M244.87,161.391c0,52.251-42.358,94.609-94.609,94.609s-94.609-42.358-94.609-94.609
|
|
14
14
|
s42.358-94.609,94.609-94.609S244.87,109.141,244.87,161.391z"/>
|
|
15
15
|
<path style="fill:#757575;" d="M166.957,244.862c0-10.725,7.637-19.959,18.187-21.889c20.537-3.757,44.826-5.929,70.856-5.929
|
|
16
16
|
s50.32,2.173,70.856,5.93c10.551,1.93,18.187,11.163,18.187,21.889v22.275c0,10.725-7.637,19.959-18.187,21.889
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
2
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
3
|
-
<svg fill="#
|
|
3
|
+
<svg fill="#FFFFFF" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
4
4
|
width="800px" height="800px" viewBox="0 0 72.371 72.372"
|
|
5
5
|
xml:space="preserve">
|
|
6
6
|
<g>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<svg height="800px" width="800px" version="1.1" id="_x32_" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
5
5
|
viewBox="0 0 512 512" xml:space="preserve">
|
|
6
6
|
<style type="text/css">
|
|
7
|
-
.st0{fill:#
|
|
7
|
+
.st0{fill:#FFFFFF;}
|
|
8
8
|
</style>
|
|
9
9
|
<g>
|
|
10
10
|
<path class="st0" d="M383.301,168.546c-6.107,8.825-12.711,17.27-19.676,25.413c-25.851,30.156-57.049,55.51-92.144,74.679
|
package/src/helpers/animation.ts
CHANGED
|
@@ -66,13 +66,11 @@ const splitChunkByPartDurations = (params: {
|
|
|
66
66
|
|
|
67
67
|
export const deriveLineChunksWithFallback = (params: {
|
|
68
68
|
timeline: TimelineKey;
|
|
69
|
-
playerAnimation: HasKeyTimes;
|
|
70
69
|
lineAnimation: HasKeyTimes;
|
|
71
70
|
lineType: LineType;
|
|
72
71
|
lineParts: LinePart[];
|
|
73
|
-
legacySupport?: boolean;
|
|
74
72
|
}): [number, number][] => {
|
|
75
|
-
const { timeline,
|
|
73
|
+
const { timeline, lineAnimation, lineType, lineParts } = params;
|
|
76
74
|
const linePartsCount = lineParts.length ?? 0;
|
|
77
75
|
|
|
78
76
|
const chunks = keyTimesToChunks(getEffectiveTimeline(lineAnimation, timeline));
|
|
@@ -81,32 +79,15 @@ export const deriveLineChunksWithFallback = (params: {
|
|
|
81
79
|
// If there are no chunks (bad/partial data), just return as-is.
|
|
82
80
|
if (!chunks.length) return chunks;
|
|
83
81
|
|
|
84
|
-
//
|
|
82
|
+
// Geometry-based splitting fallback.
|
|
85
83
|
// Typical legacy case: multi-part line stored as a single [start,end] chunk.
|
|
86
84
|
if (chunks.length === 1 && lineParts?.length) {
|
|
87
85
|
const [[start, end]] = chunks;
|
|
88
86
|
const split = splitChunkByPartDurations({ start, end, lineParts, lineType });
|
|
89
|
-
console.log('geometry based', { chunks, split, linePartsCount });
|
|
90
87
|
if (split.length === linePartsCount) return split;
|
|
91
88
|
}
|
|
92
89
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// If legacy support is disabled, do not attempt reconstruction from player timeline.
|
|
96
|
-
if (!legacySupport) return chunks;
|
|
97
|
-
|
|
98
|
-
// Backward compatibility:
|
|
99
|
-
// legacy multi-part lines stored only [start,end] in the line animation timeline,
|
|
100
|
-
// so reconstruct per-part timings from the player animation timeline slice.
|
|
101
|
-
const [[start, end]] = chunks;
|
|
102
|
-
const playerTimeline = getEffectiveTimeline(playerAnimation, timeline);
|
|
103
|
-
|
|
104
|
-
const startIndex = playerTimeline.indexOf(start);
|
|
105
|
-
const endIndex = playerTimeline.indexOf(end);
|
|
106
|
-
if (startIndex < 0 || endIndex < 0) return chunks;
|
|
107
|
-
|
|
108
|
-
const sliced = playerTimeline.slice(startIndex, endIndex + 1);
|
|
109
|
-
return keyTimesToChunks(sliced);
|
|
90
|
+
return chunks;
|
|
110
91
|
};
|
|
111
92
|
|
|
112
93
|
export const getLineAnimationChunks = (params: {
|
|
@@ -121,22 +102,12 @@ export const getLineAnimationChunks = (params: {
|
|
|
121
102
|
const lineAnimation = line.animations?.[0] as unknown as HasKeyTimes | undefined;
|
|
122
103
|
if (!lineAnimation) return [];
|
|
123
104
|
|
|
124
|
-
const linePlayer = players.find(p => p.position === line.playerPositionOrigin);
|
|
125
|
-
const playerAnimation = (linePlayer?.animations?.[0] as unknown as HasKeyTimes | undefined) ?? undefined;
|
|
126
|
-
|
|
127
|
-
// Fast path: no player timeline available, just chunk the line timeline as-is.
|
|
128
|
-
if (!playerAnimation) {
|
|
129
|
-
return keyTimesToChunks(getEffectiveTimeline(lineAnimation, timeline));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
105
|
// Full path: handle chunking + legacy reconstruction.
|
|
133
106
|
return deriveLineChunksWithFallback({
|
|
134
107
|
timeline,
|
|
135
|
-
playerAnimation,
|
|
136
108
|
lineAnimation,
|
|
137
109
|
lineType: line.type,
|
|
138
|
-
lineParts: line.lineParts
|
|
139
|
-
legacySupport: false
|
|
110
|
+
lineParts: line.lineParts
|
|
140
111
|
});
|
|
141
112
|
};
|
|
142
113
|
|
package/src/helpers/draw.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SPORT_TYPE_BASKETBALL } from '../constants';
|
|
2
1
|
import { SportType } from '../types';
|
|
3
2
|
|
|
4
3
|
type StaticDataWithBalls = {
|
|
@@ -26,7 +25,7 @@ export function drawBallObject(params: DrawBallObjectParams): boolean {
|
|
|
26
25
|
const ball = staticData?.balls?.find(b => b.key === sport);
|
|
27
26
|
if (!ball) return false;
|
|
28
27
|
|
|
29
|
-
const BALL_DIAMETER_TO_PUCK_DIAMETER_RATIO = 0.
|
|
28
|
+
const BALL_DIAMETER_TO_PUCK_DIAMETER_RATIO = 0.5;
|
|
30
29
|
const puckDiameter = puckRadius * 2;
|
|
31
30
|
const ballSize = puckDiameter * BALL_DIAMETER_TO_PUCK_DIAMETER_RATIO;
|
|
32
31
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
1
|
import Model from './Base/InternalFrameModel';
|
|
3
|
-
import {
|
|
2
|
+
import { Line, Player as PlayerData } from '../types';
|
|
4
3
|
|
|
5
4
|
export default class PlayerModel extends Model<PlayerData, PlayerData> {
|
|
6
5
|
get id() {
|
|
@@ -47,30 +46,6 @@ export default class PlayerModel extends Model<PlayerData, PlayerData> {
|
|
|
47
46
|
return this._getAttr('color');
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
get animations() {
|
|
51
|
-
return this._getAttr('animations');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private getAnimationKeyTimes(animation: PlayerAnimation, mode: AnimationMode) {
|
|
55
|
-
return mode === AnimationMode.SEQUENTIAL ? animation.keyTimesSeq || animation.keyTimes : animation.keyTimes;
|
|
56
|
-
}
|
|
57
|
-
|
|
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));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
get lastAnimation() {
|
|
67
|
-
return [...this.animations].pop();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
get lastAnimationLastLinePartControlPoint() {
|
|
71
|
-
return [...[...this.lastAnimation!.lineParts].pop()!.controlPoints].pop();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
49
|
setPossession(prevPassLines: Line[]) {
|
|
75
50
|
if (!prevPassLines.length) return;
|
|
76
51
|
let possessionCount = this.possession ? 1 : 0;
|
package/src/types/index.ts
CHANGED
|
@@ -133,19 +133,6 @@ export interface Court {
|
|
|
133
133
|
courtRect: CourtRect;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
export type PlayerAnimationType = 'POSITION';
|
|
137
|
-
|
|
138
|
-
export interface Animation {
|
|
139
|
-
id: string;
|
|
140
|
-
keyTimes: number[];
|
|
141
|
-
keyTimesSeq?: number[];
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export interface PlayerAnimation extends Animation {
|
|
145
|
-
type: PlayerAnimationType;
|
|
146
|
-
lineParts: LinePart[];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
136
|
export interface Player {
|
|
150
137
|
id: string;
|
|
151
138
|
possession: boolean;
|
|
@@ -153,12 +140,19 @@ export interface Player {
|
|
|
153
140
|
position: Position;
|
|
154
141
|
location: CourtPoint;
|
|
155
142
|
textOverride?: string;
|
|
156
|
-
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface Animation {
|
|
146
|
+
id: string;
|
|
147
|
+
keyTimes: number[];
|
|
157
148
|
}
|
|
158
149
|
|
|
159
150
|
export type LineAnimationType = 'LINESTROKE';
|
|
160
151
|
|
|
161
|
-
export interface LineAnimation
|
|
152
|
+
export interface LineAnimation {
|
|
153
|
+
id: string;
|
|
154
|
+
keyTimes: number[];
|
|
155
|
+
keyTimesSeq?: number[];
|
|
162
156
|
type: LineAnimationType;
|
|
163
157
|
strokeStartValues: [number, number, number];
|
|
164
158
|
}
|