@luceosports/play-rendering 1.11.10 → 1.11.13
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 +3 -3
- package/dist/play-rendering.js.map +1 -1
- package/package.json +1 -1
- package/src/layers/base/InternalBaseLayer.js +2 -0
- package/src/layers/court/base/InternalCourtLayer.js +0 -5
- package/src/layers/line/base/ActionLineLayer.js +10 -0
- package/src/layers/line/base/InternalLineLayer.js +3 -10
- package/src/layers/line/layers/CutLineLayer.js +3 -4
- package/src/layers/line/layers/DribbleLineLayer.js +3 -11
- package/src/layers/line/layers/ScreenLineLayer.js +3 -4
- package/src/layers/shape/base/InternalShapeLayer.js +0 -2
- package/src/models/Animation.js +1 -0
- package/src/models/Frame.js +19 -10
- package/src/models/Play.js +2 -0
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
class InternalBaseLayer {
|
|
2
2
|
constructor(parentLayer) {
|
|
3
3
|
this.ctx = parentLayer.ctx;
|
|
4
|
+
this.playData = parentLayer.playData;
|
|
4
5
|
this.options = parentLayer.options ? parentLayer.options : {};
|
|
6
|
+
this.courtTypeConstants = parentLayer.courtTypeConstants;
|
|
5
7
|
}
|
|
6
8
|
|
|
7
9
|
apply() {
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
const InternalBaseLayer = require('../../base/InternalBaseLayer');
|
|
2
2
|
|
|
3
3
|
class InternalCourtLayer extends InternalBaseLayer {
|
|
4
|
-
constructor(parentLayer) {
|
|
5
|
-
super(parentLayer);
|
|
6
|
-
this.courtTypeConstants = parentLayer.courtTypeConstants;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
4
|
apply() {
|
|
10
5
|
super.apply();
|
|
11
6
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const InternalLineLayer = require('./InternalLineLayer');
|
|
2
|
+
|
|
3
|
+
class ActionLineLayer extends InternalLineLayer {
|
|
4
|
+
allowDrawLineCap() {
|
|
5
|
+
if (this.line.hideLineTip) return false;
|
|
6
|
+
return !(this.options.magnetMode && !this.options.animationGlobalProgress);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = ActionLineLayer;
|
|
@@ -2,14 +2,12 @@ const InternalBaseLayer = require('../../base/InternalBaseLayer');
|
|
|
2
2
|
const LineDrawingMath = require('../../../math/LineDrawingMath');
|
|
3
3
|
|
|
4
4
|
class InternalLineLayer extends InternalBaseLayer {
|
|
5
|
-
constructor(
|
|
6
|
-
super(
|
|
5
|
+
constructor(parentLayer, line) {
|
|
6
|
+
super(parentLayer);
|
|
7
7
|
this.line = line;
|
|
8
|
-
this.playData = parentLineLayer.playData;
|
|
9
8
|
this.debugMasking = false;
|
|
10
9
|
this.startMaskSettings = null;
|
|
11
10
|
this.endMaskSettings = null;
|
|
12
|
-
this.courtTypeConstants = parentLineLayer.courtTypeConstants;
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
drawLogic() {
|
|
@@ -57,12 +55,6 @@ class InternalLineLayer extends InternalBaseLayer {
|
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
setColor(alphaOverride = null) {
|
|
60
|
-
// if (this.options.lineColor) {
|
|
61
|
-
// this.ctx.fillStyle = this.options.lineColor;
|
|
62
|
-
// this.ctx.strokeStyle = this.options.lineColor;
|
|
63
|
-
// return;
|
|
64
|
-
// }
|
|
65
|
-
|
|
66
58
|
let lineForPlayerInPosition = false;
|
|
67
59
|
if (this.options.position) {
|
|
68
60
|
const { playerPositionOrigin, playerPositionTerminus } = this.line.originalData;
|
|
@@ -103,6 +95,7 @@ class InternalLineLayer extends InternalBaseLayer {
|
|
|
103
95
|
this.ctx.moveTo(cp[0].x, cp[0].y);
|
|
104
96
|
|
|
105
97
|
if (cp.length === 2) {
|
|
98
|
+
if (this.line.type === 'DRIBBLE') this.ctx.lineCap = 'round'; // fix last straight line cap segment
|
|
106
99
|
this.ctx.lineTo(cp[1].x, cp[1].y);
|
|
107
100
|
}
|
|
108
101
|
if (cp.length === 3) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ActionLineLayer = require('../base/ActionLineLayer');
|
|
2
2
|
|
|
3
|
-
class CutLineLayer extends
|
|
3
|
+
class CutLineLayer extends ActionLineLayer {
|
|
4
4
|
drawLineCap() {
|
|
5
|
-
if (this.
|
|
6
|
-
this.drawArrowLineCap();
|
|
5
|
+
if (this.allowDrawLineCap()) this.drawArrowLineCap();
|
|
7
6
|
}
|
|
8
7
|
}
|
|
9
8
|
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
const _ = require('lodash');
|
|
2
2
|
const common = require('../../../helpers/common');
|
|
3
|
-
const
|
|
3
|
+
const ActionLineLayer = require('../base/ActionLineLayer');
|
|
4
4
|
const Bezier = require('../../../math/Bezier');
|
|
5
5
|
|
|
6
|
-
class DribbleLineLayer extends
|
|
6
|
+
class DribbleLineLayer extends ActionLineLayer {
|
|
7
7
|
drawLineCap() {
|
|
8
|
-
if (this.
|
|
9
|
-
this.drawArrowLineCap();
|
|
8
|
+
if (this.allowDrawLineCap()) this.drawArrowLineCap();
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
// arrowTipPoint() {
|
|
13
|
-
// const lineParts = this.options.animationGlobalProgress ? this.line.baseLineParts() : this.line.getLineParts();
|
|
14
|
-
// const lastLinePart = [...lineParts].pop();
|
|
15
|
-
// const cp = lastLinePart.controlPoints;
|
|
16
|
-
// return cp[cp.length - 1];
|
|
17
|
-
// }
|
|
18
|
-
|
|
19
11
|
setLineOptions() {
|
|
20
12
|
const lineParts = [...this.line.getLineParts()];
|
|
21
13
|
this.line.setLinePartsAdjusted([]);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ActionLineLayer = require('../base/ActionLineLayer');
|
|
2
2
|
|
|
3
|
-
class ScreenLineLayer extends
|
|
3
|
+
class ScreenLineLayer extends ActionLineLayer {
|
|
4
4
|
drawLineCap() {
|
|
5
|
-
if (this.
|
|
6
|
-
this.drawPerpendicularLineCap();
|
|
5
|
+
if (this.allowDrawLineCap()) this.drawPerpendicularLineCap();
|
|
7
6
|
}
|
|
8
7
|
}
|
|
9
8
|
|
package/src/models/Animation.js
CHANGED
|
@@ -107,6 +107,7 @@ class Animation {
|
|
|
107
107
|
if (!this.running) return;
|
|
108
108
|
|
|
109
109
|
if (this.globalProgress >= this.linePhaseIntervalMaxRounded) {
|
|
110
|
+
progressCallback(this.linePhaseIntervalMaxRounded);
|
|
110
111
|
this.reset();
|
|
111
112
|
cancelAnimationFrame(this.loopId);
|
|
112
113
|
setTimeout(() => {
|
package/src/models/Frame.js
CHANGED
|
@@ -88,22 +88,32 @@ class Frame {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
get currentPhasePlayers() {
|
|
91
|
-
const lines = this.play.options.huddleMode ? this.playDataLines : this.prevPhaseLines;
|
|
92
91
|
const { currentPhaseLines } = this;
|
|
93
|
-
const
|
|
94
|
-
|
|
92
|
+
const { huddleMode, magnetMode } = this.play.options;
|
|
93
|
+
|
|
94
|
+
const lines = huddleMode || magnetMode ? this.playDataLines : this.prevPhaseLines;
|
|
95
|
+
|
|
96
|
+
const passLines = lines.filter(l => ['PASS', 'HANDOFF'].includes(l.type));
|
|
97
|
+
|
|
98
|
+
return this.play.playData.players.map(p => {
|
|
95
99
|
const player = new Player(p);
|
|
96
100
|
player.setPossession(passLines);
|
|
97
101
|
|
|
98
102
|
const playerPrevLines = lines
|
|
99
103
|
.filter(l => {
|
|
100
|
-
if (!
|
|
104
|
+
if (!huddleMode) return true;
|
|
101
105
|
if (this.phase < l.phase) return false;
|
|
102
106
|
return !currentPhaseLines.find(item => item.id === l.id); // exclude last 2 lines in huddle mode
|
|
103
107
|
})
|
|
104
108
|
.filter(l => l.playerPositionOrigin === player.position && l.playerPositionTerminus === player.position);
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
|
|
110
|
+
const playerCurrentPhaseLines = currentPhaseLines.filter(
|
|
111
|
+
l => magnetMode && l.playerPositionOrigin === player.position && l.playerPositionTerminus === player.position
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
const playerLines = playerCurrentPhaseLines.length ? playerCurrentPhaseLines : playerPrevLines;
|
|
115
|
+
if (playerLines.length) {
|
|
116
|
+
const maxLine = _.maxBy(playerLines, l => l.lastAnimEndTime);
|
|
107
117
|
if (maxLine) {
|
|
108
118
|
const lastPoint = maxLine.lastLinePartControlPoint;
|
|
109
119
|
if (lastPoint) {
|
|
@@ -113,7 +123,6 @@ class Frame {
|
|
|
113
123
|
}
|
|
114
124
|
return player;
|
|
115
125
|
});
|
|
116
|
-
return players;
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
get currentPhaseLines() {
|
|
@@ -130,10 +139,10 @@ class Frame {
|
|
|
130
139
|
const passLines = this.prevAnimationLines.filter(l => ['PASS', 'HANDOFF'].includes(l.type));
|
|
131
140
|
return this.play.playData.players.map(p => {
|
|
132
141
|
const player = new Player(p);
|
|
133
|
-
if (!player.animations.length) return player;
|
|
134
|
-
|
|
135
142
|
player.setPossession(passLines);
|
|
136
143
|
|
|
144
|
+
if (!player.animations.length) return player;
|
|
145
|
+
|
|
137
146
|
player.animations.forEach(animation => {
|
|
138
147
|
const keyTimesChunks = [];
|
|
139
148
|
animation.keyTimes.forEach((value, index) => {
|
|
@@ -222,7 +231,7 @@ class Frame {
|
|
|
222
231
|
}
|
|
223
232
|
|
|
224
233
|
get prevAnimationLines() {
|
|
225
|
-
return this.playDataLines.filter(l => this.animationGlobalProgress
|
|
234
|
+
return this.playDataLines.filter(l => this.animationGlobalProgress >= l.lastAnimEndTime);
|
|
226
235
|
}
|
|
227
236
|
|
|
228
237
|
draw() {
|
package/src/models/Play.js
CHANGED
|
@@ -26,6 +26,7 @@ class Play {
|
|
|
26
26
|
position = null,
|
|
27
27
|
big3 = false,
|
|
28
28
|
huddleMode = false,
|
|
29
|
+
magnetMode = false,
|
|
29
30
|
flipPlayerLabels = false
|
|
30
31
|
} = {}
|
|
31
32
|
) {
|
|
@@ -47,6 +48,7 @@ class Play {
|
|
|
47
48
|
position,
|
|
48
49
|
big3,
|
|
49
50
|
huddleMode,
|
|
51
|
+
magnetMode,
|
|
50
52
|
flipPlayerLabels
|
|
51
53
|
};
|
|
52
54
|
this.setPlayData(data.playData);
|