Skip to content

Commit f78acbc

Browse files
committed
update athlete labels in body types
1 parent db38b7f commit f78acbc

2 files changed

Lines changed: 25 additions & 12 deletions

File tree

website/js/body-types.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -433,14 +433,14 @@ import { AthleteRenderer } from "./AthleteRenderer.js";
433433
wrapper.appendChild(canvasWrap);
434434

435435
const width = canvasWrap.clientWidth || 1180;
436-
const height = 670;
436+
const height = 720;
437437

438438
const scene = new THREE.Scene();
439439
scene.background = null;
440440

441441
const camera = new THREE.PerspectiveCamera(42, width / height, 0.1, 200);
442-
camera.position.set(0, 10, 36);
443-
camera.lookAt(0, 6, 0);
442+
camera.position.set(0, 12, 36);
443+
camera.lookAt(0, 8, 0);
444444

445445
const renderer = new THREE.WebGLRenderer({
446446
antialias: true,
@@ -543,16 +543,27 @@ import { AthleteRenderer } from "./AthleteRenderer.js";
543543
<div class="bodytype-athlete-stats">${heightStr}&nbsp;·&nbsp;${weightStr}</div>
544544
`;
545545

546-
// Project approximate head position to screen coordinates
547-
const v = new THREE.Vector3(pos.x, pos.podiumHeight + 14, 0);
546+
/*
547+
The label used to be fixed at podiumHeight + 14.
548+
That made short athletes have labels too high above them.
549+
Now the label anchor depends on the athlete's real height.
550+
*/
551+
const athleteCm = athlete.height || 170;
552+
const normalizedHeight = athleteCm / 170;
553+
554+
const estimatedBodyHeight = 11.2 * normalizedHeight;
555+
const labelWorldY = pos.podiumHeight + estimatedBodyHeight + 0.9;
556+
557+
const v = new THREE.Vector3(pos.x, labelWorldY, 0);
548558
v.project(camera);
559+
549560
const sx = (v.x + 1) / 2 * canvasW;
550561
const sy = (1 - (v.y + 1) / 2) * canvasH;
551562

552-
div.style.left = `${sx}px`;
553-
div.style.top = `${Math.max(6, sy - 4)}px`;
563+
div.style.left = `${sx}px`;
564+
div.style.top = `${Math.max(8, sy)}px`;
554565
div.style.transform = "translateX(-50%) translateY(-100%)";
555-
div.style.width = "220px";
566+
div.style.width = "230px";
556567

557568
container.appendChild(div);
558569
}

website/styles.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -795,14 +795,16 @@ p {
795795
position: absolute;
796796
color: white;
797797
text-align: center;
798-
line-height: 1.35;
799-
text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
798+
line-height: 1.25;
799+
text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
800800
pointer-events: none;
801+
max-width: 230px;
802+
white-space: normal;
801803
}
802804

803805
.bodytype-athlete-name {
804-
font-size: 17px;
805-
font-weight: 600;
806+
font-size: 16px;
807+
font-weight: 700;
806808
}
807809

808810
.bodytype-athlete-meta {

0 commit comments

Comments
 (0)