Skip to content

Commit bd4fed7

Browse files
committed
wip
1 parent 2a782d1 commit bd4fed7

File tree

3 files changed

+20
-37
lines changed

3 files changed

+20
-37
lines changed

src/app/(main)/community/events/map/engine.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,6 @@ class MapEngine implements MapHandle {
184184
: null
185185
this.loop()
186186
}
187-
setActiveMarker(id: string | null): void {
188-
throw new Error("Method not implemented.")
189-
}
190-
191187
dispose() {
192188
if (this.destroyed) return
193189
this.destroyed = true
@@ -207,7 +203,8 @@ class MapEngine implements MapHandle {
207203
}
208204

209205
setActiveMarker(id: string | null) {
210-
const nextIndex = typeof id === "string" ? this.markerIndexById.get(id) ?? -1 : -1
206+
const nextIndex =
207+
typeof id === "string" ? (this.markerIndexById.get(id) ?? -1) : -1
211208
if (nextIndex === this.activeMarkerIndex) return
212209
if (this.activeMarkerIndex >= 0) {
213210
const prevBase = this.activeMarkerIndex * 4

src/app/(main)/community/events/map/shaders.ts

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ uniform vec3 uLandColor;
3030
uniform vec4 uMarkers[${MARKER_CAPACITY}];
3131
uniform int uMarkerCount;
3232
uniform vec3 uMarkerColor;
33-
uniform vec3 uHubMarkerColor;
34-
uniform int uPointerActive;
35-
uniform vec2 uPointerCenter;
3633
uniform int uPointerTrailCount;
3734
uniform vec4 uPointerTrail[8];
3835
@@ -86,9 +83,8 @@ void main() {
8683
discard;
8784
}
8885
float markerType = markerTypeAtCellCenterPx(center);
89-
float pointerHalo = 0.0;
9086
float pointerTrail = 0.0;
91-
const float trailDecay = 1.2;
87+
const float trailDecay = 2.2;
9288
for (int i = 0; i < 8; i++) {
9389
if (i >= uPointerTrailCount) {
9490
break;
@@ -98,50 +94,40 @@ void main() {
9894
float age = clamp(entry.z, 0.0, 1.0);
9995
float fade = exp(-trailDecay * age);
10096
float centerDist = length(center - trailPos);
101-
float centerInfluence = clamp(1.0 - centerDist / (uCell * 8.0), 0.0, 1.0);
97+
float centerInfluence = exp(-centerDist / (uCell * 3.2));
10298
pointerTrail += fade * centerInfluence;
103-
if (markerType > 0.5) {
104-
float haloRadius = 0.5 * uSquare + 1.5 * uCell;
105-
float haloDist = length(fragPx - trailPos);
106-
float haloInfluence = clamp(1.0 - haloDist / haloRadius, 0.0, 1.0);
107-
pointerHalo = max(pointerHalo, fade * haloInfluence * haloInfluence * 0.35);
108-
}
109-
}
110-
if (uPointerActive > 0 && markerType > 0.5) {
111-
float haloRadius = 0.5 * uSquare + 2.5 * uCell;
112-
float haloDist = length(fragPx - uPointerCenter);
113-
float haloFactor = clamp(1.0 - haloDist / haloRadius, 0.0, 1.0);
114-
pointerHalo = max(pointerHalo, haloFactor * 0.6);
11599
}
100+
pointerTrail = clamp(pointerTrail, 0.0, 1.0);
116101
vec2 landUV = vec2(uv.x, 1.0 - uv.y);
117102
float seaCoverage = sampleCoverage(landUV);
118103
float landCoverage = 1.0 - seaCoverage;
119104
if (markerType <= 0.5 && landCoverage < 0.5) {
120105
discard;
121106
}
122107
vec3 color = uLandColor;
123-
if (markerType > 1.5) {
124-
color = uHubMarkerColor;
125-
} else if (markerType > 0.5) {
108+
if (markerType > 0.5) {
126109
color = uMarkerColor;
127110
}
128-
pointerTrail = clamp(pointerTrail, 0.0, 1.0);
129111
float halfSquare = 0.5 * uSquare;
130112
if (pointerTrail > 0.0 && markerType <= 0.5) {
131-
float shrink = clamp(1.0 - pointerTrail * 0.12, 0.9, 1.0);
113+
float shrink = clamp(1.0 - pointerTrail * 0.4, 0.55, 1.0);
132114
halfSquare *= shrink;
133115
}
116+
float activeHalo = 0.0;
117+
if (markerType > 1.5) {
118+
float haloRadius = 0.5 * uSquare + 1.5 * uCell;
119+
float haloDist = length(fragPx - center);
120+
float haloFactor = clamp(1.0 - haloDist / haloRadius, 0.0, 1.0);
121+
activeHalo = haloFactor * haloFactor;
122+
halfSquare *= clamp(1.0 - activeHalo * 0.3, 0.7, 1.0);
123+
}
134124
vec2 delta = abs(fragPx - center);
135125
if (delta.x > halfSquare || delta.y > halfSquare) {
136126
discard;
137127
}
138-
float alpha = 1.0;
139-
if (pointerTrail > 0.0 && markerType <= 0.5) {
140-
alpha = clamp(1.0 - pointerTrail * 0.08, 0.7, 1.0);
141-
}
142-
if (pointerHalo > 0.0) {
143-
color = mix(color, vec3(1.0), pointerHalo * 0.7);
128+
if (activeHalo > 0.0) {
129+
color = mix(color, vec3(1.0), activeHalo * 0.5);
144130
}
145-
outColor = vec4(color, alpha);
131+
outColor = vec4(color, 1.0);
146132
}
147133
`

src/app/(main)/community/events/meetups-map.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ export function MeetupsMap() {
4444
}, [themeColors])
4545

4646
useEffect(() => {
47-
if (!handleRef.current) return
47+
if (status !== "ready" || !handleRef.current) return
4848
handleRef.current.setActiveMarker(activeMeetupId)
49-
}, [activeMeetupId])
49+
}, [status, activeMeetupId])
5050

5151
useEffect(() => {
5252
const canvas = canvasRef.current

0 commit comments

Comments
 (0)