Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[client] Add Minimap Component to Display Worldmap Overview #1718

Merged
merged 34 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9dadf29
feat: minimap dev start
r0man1337 Sep 24, 2024
c783c34
feat: minimap draw structures
r0man1337 Sep 24, 2024
a012a45
refactor
r0man1337 Sep 24, 2024
0350a58
camera frustrum
r0man1337 Sep 24, 2024
e9f58ed
feat: minimap click support
r0man1337 Sep 24, 2024
33f6ad5
feat: camera dragging
r0man1337 Sep 24, 2024
0dfc995
extract draw structures to function
r0man1337 Sep 26, 2024
7608301
draw biomes
r0man1337 Sep 26, 2024
556edad
draw armies
r0man1337 Sep 26, 2024
9f3801b
cache colors
r0man1337 Sep 26, 2024
1e33df2
throttle map update function
r0man1337 Sep 26, 2024
45494dc
minimap scaled coords optimization
r0man1337 Sep 26, 2024
0ea6200
minimap config
r0man1337 Sep 26, 2024
9cc9e74
move map range when click on border
r0man1337 Sep 26, 2024
cec73e4
minimap border width
r0man1337 Sep 26, 2024
fbb8d88
minimap code refactor
r0man1337 Sep 26, 2024
133aab5
center minimap on worldmap open
r0man1337 Sep 26, 2024
0982d1f
minimap size
r0man1337 Sep 26, 2024
f178350
hide minimap on scene switch
r0man1337 Sep 26, 2024
25ca968
minimap styling and propagation
r0man1337 Sep 26, 2024
d528691
fix: prettier errors
r0man1337 Sep 26, 2024
7c26d0d
little refactor
r0man1337 Sep 30, 2024
36286f1
feat: minimap zoom in and out
r0man1337 Sep 30, 2024
b67081d
feat: minimap coords improvements
r0man1337 Sep 30, 2024
6cbdeba
feat: map optimizations
r0man1337 Sep 30, 2024
db6eab5
fix: minimap bg
r0man1337 Sep 30, 2024
3666c6c
colors update
r0man1337 Sep 30, 2024
e3d6f1c
minimap legend
r0man1337 Sep 30, 2024
712a688
minimap colors, legend, z index
r0man1337 Sep 30, 2024
1cc61fb
fix: move canvas to react code
r0man1337 Oct 4, 2024
76f8c34
fix: lint
r0man1337 Oct 4, 2024
6b6ac4a
merge
ponderingdemocritus Oct 7, 2024
8d40181
merge and fix position
ponderingdemocritus Oct 7, 2024
f459088
prettier
ponderingdemocritus Oct 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions client/src/hooks/store/useUIStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import React from "react";
import { create } from "zustand";
import { subscribeWithSelector } from "zustand/middleware";
import { BuildModeStore, createBuildModeStoreSlice } from "./_buildModeStore";
import { createPopupsSlice, PopupsStore } from "./_popupsStore";
import { createThreeStoreSlice, ThreeStore } from "./_threeStore";
import { PopupsStore, createPopupsSlice } from "./_popupsStore";
import { ThreeStore, createThreeStoreSlice } from "./_threeStore";
import { BattleViewInfo } from "./types";
import { BlockchainStore, createBlockchainStore } from "./useBlockchainStore";
import { createRealmStoreSlice, RealmStore } from "./useRealmStore";
import { RealmStore, createRealmStoreSlice } from "./useRealmStore";

interface UIStore {
theme: string;
Expand Down Expand Up @@ -53,6 +53,8 @@ interface UIStore {
setLeftNavigationView: (view: LeftView) => void;
rightNavigationView: RightView;
setRightNavigationView: (view: RightView) => void;
showMinimap: boolean;
setShowMinimap: (show: boolean) => void;
selectedPlayer: ContractAddress | null;
setSelectedPlayer: (player: ContractAddress | null) => void;
tabs: Tab[];
Expand Down Expand Up @@ -112,6 +114,8 @@ const useUIStore = create(
setLeftNavigationView: (view: LeftView) => set({ leftNavigationView: view }),
rightNavigationView: RightView.None,
setRightNavigationView: (view: RightView) => set({ rightNavigationView: view }),
showMinimap: false,
setShowMinimap: (show: boolean) => set({ showMinimap: show }),
selectedPlayer: null,
setSelectedPlayer: (player: ContractAddress | null) => set({ selectedPlayer: player }),
tabs: [],
Expand Down
2 changes: 1 addition & 1 deletion client/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ h6 {

#root {
position: relative;
z-index: 2;
z-index: 3;
}

canvas {
Expand Down
2 changes: 1 addition & 1 deletion client/src/three/GameRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ export default class GameRenderer {
this.hudScene = new HUDScene(this.sceneManager, this.controls);

this.renderModels();

// Init animation
this.animate();
}
Expand Down Expand Up @@ -321,6 +320,7 @@ export default class GameRenderer {
this.renderer.render(this.hudScene.getScene(), this.hudScene.getCamera());
this.labelRenderer.render(this.hudScene.getScene(), this.hudScene.getCamera());

// Update the minimap
requestAnimationFrame(() => {
this.animate();
});
Expand Down
4 changes: 4 additions & 0 deletions client/src/three/SceneManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export class SceneManager {
switchScene(sceneName: SceneName) {
const scene = this.scenes.get(sceneName);
if (scene) {
const previousScene = this.scenes.get(this.currentScene!);
if (previousScene) {
previousScene.onSwitchOff();
}
this.transitionManager.fadeOut(() => {
this._updateCurrentScene(sceneName);
if (scene.setup) {
Expand Down
4 changes: 4 additions & 0 deletions client/src/three/components/ArmyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ export class ArmyManager {
this.cachedChunks.clear();
}

public getArmies() {
return Array.from(this.armies.values());
}

update(deltaTime: number) {
let needsBoundingUpdate = false;
const movementSpeed = 1.25; // Constant movement speed
Expand Down
Loading
Loading