@luceosports/play-rendering 1.17.0 → 1.18.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 +3 -3
- package/dist/play-rendering.js.map +1 -1
- package/package.json +1 -1
- package/src/layers/court/base/InternalCourtLayer.js +6 -0
- package/src/layers/court/layers/HOCKEY/constants.js +2 -2
- package/src/layers/court/layers/HOCKEY/courtTypes/HOCKEY_INTERNATIONAL/layers/GoaCreaseLayer.js +2 -2
- package/src/layers/court/layers/HOCKEY/courtTypes/HOCKEY_NHL/layers/GoaCreaseLayer.js +2 -2
- package/src/layers/court/layers/HOCKEY/layers/BorderRinkLayer.js +1 -1
- package/src/layers/court/layers/HOCKEY/layers/CenterCircleLayer.js +1 -1
- package/src/layers/court/layers/HOCKEY/layers/CenterLineLayer.js +1 -1
- package/src/layers/court/layers/HOCKEY/layers/CenterSpotLayer.js +1 -1
- package/src/layers/court/layers/HOCKEY/layers/EndZoneLayer.js +1 -2
- package/src/layers/court/layers/HOCKEY/layers/GoalLineLayer.js +1 -1
- package/src/layers/court/layers/HOCKEY/layers/NeutralZoneLayer.js +2 -2
- package/src/layers/court/layers/HOCKEY/layers/RefereeCreaseLayer.js +1 -1
- package/src/layers/line/base/InternalLineLayer.js +1 -0
- package/src/layers/line/layers/ShootLineLayer.js +56 -0
- package/src/models/Frame.js +1 -1
- package/src/traits/LineDrawOperationsTrait.js +7 -4
package/package.json
CHANGED
|
@@ -28,6 +28,12 @@ class InternalCourtLayer extends InternalBaseLayer {
|
|
|
28
28
|
this.ctx.scale(1, -1);
|
|
29
29
|
this.ctx.translate(0, -Math.abs(verticalTranslationDist));
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
setColor(color) {
|
|
33
|
+
const style = this.options.lineColor === 'transparent' ? 'transparent' : color;
|
|
34
|
+
this.ctx.strokeStyle = style;
|
|
35
|
+
this.ctx.fillStyle = style;
|
|
36
|
+
}
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
module.exports = InternalCourtLayer;
|
package/src/layers/court/layers/HOCKEY/courtTypes/HOCKEY_INTERNATIONAL/layers/GoaCreaseLayer.js
CHANGED
|
@@ -6,7 +6,7 @@ class GoaCreaseLayer extends InternalCourtLayer {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
drawLogic() {
|
|
9
|
-
this.
|
|
9
|
+
this.setColor(this.courtTypeConstants.LINE_COLOR_RED);
|
|
10
10
|
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
|
|
11
11
|
|
|
12
12
|
const goalLineY =
|
|
@@ -18,7 +18,7 @@ class GoaCreaseLayer extends InternalCourtLayer {
|
|
|
18
18
|
this.ctx.stroke();
|
|
19
19
|
|
|
20
20
|
// 2. Draw goal cage
|
|
21
|
-
this.
|
|
21
|
+
this.setColor('#000');
|
|
22
22
|
this.ctx.beginPath();
|
|
23
23
|
this.ctx.moveTo(this.courtCenter.x - this.courtTypeConstants.GOAL_CAGE_LENGTH / 2, goalLineY);
|
|
24
24
|
this.ctx.lineTo(
|
|
@@ -6,7 +6,7 @@ class GoaCreaseLayer extends InternalCourtLayer {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
drawLogic() {
|
|
9
|
-
this.
|
|
9
|
+
this.setColor(this.courtTypeConstants.LINE_COLOR_RED);
|
|
10
10
|
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
|
|
11
11
|
|
|
12
12
|
const goalLineY =
|
|
@@ -27,7 +27,7 @@ class GoaCreaseLayer extends InternalCourtLayer {
|
|
|
27
27
|
this.ctx.stroke();
|
|
28
28
|
|
|
29
29
|
// 2. Draw goal cage
|
|
30
|
-
this.
|
|
30
|
+
this.setColor('#000');
|
|
31
31
|
this.ctx.beginPath();
|
|
32
32
|
this.ctx.moveTo(this.courtCenter.x - this.courtTypeConstants.GOAL_CAGE_LENGTH / 2, goalLineY);
|
|
33
33
|
this.ctx.lineTo(
|
|
@@ -4,7 +4,7 @@ const CENTER_CIRCLE_RADIUS = 15;
|
|
|
4
4
|
|
|
5
5
|
class CenterCircleLayer extends InternalCourtLayer {
|
|
6
6
|
drawLogic() {
|
|
7
|
-
this.
|
|
7
|
+
this.setColor(this.courtTypeConstants.LINE_COLOR_BLUE);
|
|
8
8
|
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
|
|
9
9
|
|
|
10
10
|
this.ctx.beginPath();
|
|
@@ -2,7 +2,7 @@ const InternalCourtLayer = require('../../../base/InternalCourtLayer');
|
|
|
2
2
|
|
|
3
3
|
class CenterLineLayer extends InternalCourtLayer {
|
|
4
4
|
drawLogic() {
|
|
5
|
-
this.
|
|
5
|
+
this.setColor(this.courtTypeConstants.LINE_COLOR_RED);
|
|
6
6
|
this.ctx.setLineDash([2, 1]);
|
|
7
7
|
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 4;
|
|
8
8
|
|
|
@@ -3,7 +3,7 @@ const InternalCourtLayer = require('../../../base/InternalCourtLayer');
|
|
|
3
3
|
const CENTER_SPOT_RADIUS = 1;
|
|
4
4
|
class CenterSpotLayer extends InternalCourtLayer {
|
|
5
5
|
drawLogic() {
|
|
6
|
-
this.
|
|
6
|
+
this.setColor(this.courtTypeConstants.LINE_COLOR_BLUE);
|
|
7
7
|
|
|
8
8
|
this.ctx.beginPath();
|
|
9
9
|
this.ctx.arc(this.courtCenter.x, this.courtCenter.y, CENTER_SPOT_RADIUS, 0, Math.PI * 2, true);
|
|
@@ -8,8 +8,7 @@ class EndZoneLayer extends InternalCourtLayer {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
drawLogic() {
|
|
11
|
-
this.
|
|
12
|
-
this.ctx.strokeStyle = this.courtTypeConstants.LINE_COLOR_RED;
|
|
11
|
+
this.setColor(this.courtTypeConstants.LINE_COLOR_RED);
|
|
13
12
|
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
|
|
14
13
|
|
|
15
14
|
const faceOffOffset =
|
|
@@ -6,7 +6,7 @@ class GoalLineLayer extends InternalCourtLayer {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
drawLogic() {
|
|
9
|
-
this.
|
|
9
|
+
this.setColor(this.courtTypeConstants.LINE_COLOR_RED);
|
|
10
10
|
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
|
|
11
11
|
|
|
12
12
|
const goalLineY =
|
|
@@ -9,7 +9,7 @@ class NeutralZoneLayer extends InternalCourtLayer {
|
|
|
9
9
|
|
|
10
10
|
drawLogic() {
|
|
11
11
|
// 1. Draw blue line
|
|
12
|
-
this.
|
|
12
|
+
this.setColor(this.courtTypeConstants.LINE_COLOR_BLUE);
|
|
13
13
|
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 4;
|
|
14
14
|
|
|
15
15
|
const blueLineOrigin = { x: 0.0, y: this.courtCenter.y - this.courtTypeConstants.NEUTRAL_ZONE_LENGTH };
|
|
@@ -24,7 +24,7 @@ class NeutralZoneLayer extends InternalCourtLayer {
|
|
|
24
24
|
this.ctx.stroke();
|
|
25
25
|
|
|
26
26
|
// 2. Draw face off spots
|
|
27
|
-
this.
|
|
27
|
+
this.setColor(this.courtTypeConstants.LINE_COLOR_RED);
|
|
28
28
|
|
|
29
29
|
const faceOffOffset =
|
|
30
30
|
(this.courtTypeConstants.COURT_RECT_WIDTH - this.courtTypeConstants.FACE_OFF_SPOTS_DISTANCE) / 2;
|
|
@@ -4,7 +4,7 @@ const REFEREE_CREASE_RADIUS = 10;
|
|
|
4
4
|
|
|
5
5
|
class RefereeCreaseLayer extends InternalCourtLayer {
|
|
6
6
|
drawLogic() {
|
|
7
|
-
this.
|
|
7
|
+
this.setColor(this.courtTypeConstants.LINE_COLOR_RED);
|
|
8
8
|
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH * 2;
|
|
9
9
|
|
|
10
10
|
this.ctx.beginPath();
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const ActionLineLayer = require('../base/ActionLineLayer');
|
|
2
|
+
|
|
3
|
+
class ShootLineLayer extends ActionLineLayer {
|
|
4
|
+
drawLineCap() {
|
|
5
|
+
if (this.allowDrawLineCap()) {
|
|
6
|
+
const cp1 = this.line.firstLinePartControlPoint;
|
|
7
|
+
const cp2 = this.line.lastLinePartControlPoint;
|
|
8
|
+
|
|
9
|
+
// Make arrow tip point a bit longer by adding small vector
|
|
10
|
+
const addVector = { x: 0.6, y: 0 };
|
|
11
|
+
const alpha = this.angleBetweenTwoPoints(cp1, cp2);
|
|
12
|
+
const sameAngleAddVector = {
|
|
13
|
+
x: Math.cos(alpha) * addVector.x - Math.sin(alpha) * addVector.y,
|
|
14
|
+
y: Math.sin(alpha) * addVector.x - Math.cos(alpha) * addVector.y
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const courtArrowTipPoint = {
|
|
18
|
+
x: cp2.x + sameAngleAddVector.x,
|
|
19
|
+
y: cp2.y + sameAngleAddVector.y
|
|
20
|
+
};
|
|
21
|
+
this.drawArrowLineCap(courtArrowTipPoint);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
setLineOptions() {
|
|
26
|
+
this.ctx.lineWidth = this.lineWidth * 0.7;
|
|
27
|
+
|
|
28
|
+
const lineParts = [...this.line.getLineParts()];
|
|
29
|
+
|
|
30
|
+
this.line.setLinePartsAdjusted([]);
|
|
31
|
+
|
|
32
|
+
lineParts.forEach(lp => {
|
|
33
|
+
const cp = lp.controlPoints;
|
|
34
|
+
|
|
35
|
+
const offsets = [-0.3, 0.3];
|
|
36
|
+
offsets.forEach(offset => {
|
|
37
|
+
const [dx, dy] = [cp[0].x - cp[1].x, cp[0].y - cp[1].y];
|
|
38
|
+
const scale = offset / (dx * dx + dy * dy) ** 0.5;
|
|
39
|
+
const [ox, oy] = [-dy * scale, dx * scale];
|
|
40
|
+
|
|
41
|
+
this.ctx.moveTo(ox + cp[0].x, oy + cp[0].y);
|
|
42
|
+
this.ctx.lineTo(ox + cp[1].x, oy + cp[1].y);
|
|
43
|
+
|
|
44
|
+
this.line.addLinePartAdjusted({
|
|
45
|
+
...lp,
|
|
46
|
+
controlPoints: [
|
|
47
|
+
{ x: cp[0].x + ox, y: cp[0].y + oy },
|
|
48
|
+
{ x: cp[1].x + ox, y: cp[1].y + oy }
|
|
49
|
+
]
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = ShootLineLayer;
|
package/src/models/Frame.js
CHANGED
|
@@ -155,7 +155,7 @@ class Frame {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
get animationProgressPlayers() {
|
|
158
|
-
const passLines = this.prevAnimationLines.filter(l => ['PASS', 'HANDOFF'].includes(l.type));
|
|
158
|
+
const passLines = this.prevAnimationLines.filter(l => ['PASS', 'HANDOFF', 'SHOOT'].includes(l.type));
|
|
159
159
|
return this.play.playData.players.map(p => {
|
|
160
160
|
const player = new Player(p);
|
|
161
161
|
player.setPossession(passLines);
|
|
@@ -19,8 +19,7 @@ module.exports = {
|
|
|
19
19
|
this.ctx.moveTo(cp[0].x, cp[0].y);
|
|
20
20
|
|
|
21
21
|
if (cp.length === 2) {
|
|
22
|
-
//
|
|
23
|
-
if ((this.line || this.shape).type === 'DRIBBLE') this.ctx.lineCap = 'round'; // fix last straight line cap segment
|
|
22
|
+
this.ctx.lineCap = 'round'; // fix last straight line cap segment (needed for dribble lines)
|
|
24
23
|
this.ctx.lineTo(cp[1].x, cp[1].y);
|
|
25
24
|
}
|
|
26
25
|
if (cp.length === 3) {
|
|
@@ -38,12 +37,12 @@ module.exports = {
|
|
|
38
37
|
this.ctx.restore();
|
|
39
38
|
},
|
|
40
39
|
|
|
41
|
-
drawArrowLineCap() {
|
|
40
|
+
drawArrowLineCap(arrowTipPoint = this.arrowTipPoint()) {
|
|
42
41
|
this.ctx.save();
|
|
43
42
|
|
|
44
43
|
const arrowTipLength = 1.4;
|
|
45
44
|
const angle = this.angleBetweenLastTwoPoints();
|
|
46
|
-
const courtArrowTipPoint =
|
|
45
|
+
const courtArrowTipPoint = arrowTipPoint;
|
|
47
46
|
|
|
48
47
|
const courtLineEndPoint = { x: courtArrowTipPoint.x - arrowTipLength / 1.3, y: courtArrowTipPoint.y };
|
|
49
48
|
const courtArrowEdgePoint1 = {
|
|
@@ -137,6 +136,10 @@ module.exports = {
|
|
|
137
136
|
const cpTo = cp[cp.length - 1];
|
|
138
137
|
const cpFrom = cp[cp.length - 2];
|
|
139
138
|
|
|
139
|
+
return this.angleBetweenTwoPoints(cpFrom, cpTo);
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
angleBetweenTwoPoints(cpFrom, cpTo) {
|
|
140
143
|
const dx = cpTo.x - cpFrom.x;
|
|
141
144
|
const dy = cpTo.y - cpFrom.y;
|
|
142
145
|
return Math.atan2(dy, dx);
|