BibliothecaDAO / eternum

onchain eternal game
https://alpha-eternum.realms.world
MIT License
36 stars 30 forks source link

[client] labels, bug fixes, light #974

Closed r0man1337 closed 2 weeks ago

r0man1337 commented 2 weeks ago

User description

  1. Disabled brightness/contrast postprocessing filter, changed lights settings
  2. Improved army hitbox, raycast settings
  3. Added worldmap settings - armies, castles, hyperstructures, shard mines

PR Type

Enhancement, Bug fix


Description


Changes walkthrough πŸ“

Relevant files
Enhancement
InstancedCastles.tsx
Add textures and color coding for castles                               

client/src/ui/components/models/buildings/worldmap/InstancedCastles.tsx
  • Added new textures and materials for map labels.
  • Implemented color coding for castles based on ownership.
  • Integrated Points for better visualization.
  • +35/-2   
    ShardsMines.tsx
    Add billboard with shard label texture                                     

    client/src/ui/components/models/buildings/worldmap/ShardsMines.tsx
  • Added billboard with shard label texture.
  • Enhanced shard mine model display.
  • +16/-2   
    Structures.tsx
    Add billboard with hyperstructure label texture                   

    client/src/ui/components/models/buildings/worldmap/Structures.tsx
  • Added billboard with hyperstructure label texture.
  • Enhanced built structure display.
  • +12/-1   
    Army.tsx
    Add billboard with army label texture                                       

    client/src/ui/components/worldmap/armies/Army.tsx
  • Added billboard with army label texture.
  • Enhanced army model display.
  • +11/-0   
    HexceptionViewScene.tsx
    Increase light intensity settings                                               

    client/src/ui/modules/scenes/HexceptionViewScene.tsx - Increased light intensity settings.
    +1/-1     
    MainScene.tsx
    Adjust ambient light and raycaster settings                           

    client/src/ui/modules/scenes/MainScene.tsx
  • Adjusted ambient light intensity settings.
  • Updated raycaster thresholds.
  • Disabled brightness/contrast postprocessing filter.
  • +10/-9   
    WorldMapScene.tsx
    Increase light intensity settings                                               

    client/src/ui/modules/scenes/WorldMapScene.tsx - Increased light intensity settings.
    +2/-2     
    Bug fix
    ArmyHitBox.tsx
    Adjust army hitbox position and size                                         

    client/src/ui/components/worldmap/armies/ArmyHitBox.tsx - Adjusted army hitbox position and size.
    +2/-2     

    πŸ’‘ PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    vercel[bot] commented 2 weeks ago

    The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

    Name Status Preview Comments Updated (UTC)
    eternum βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Jun 21, 2024 9:28am
    github-actions[bot] commented 2 weeks ago

    PR Reviewer Guide πŸ”

    ⏱️ Estimated effort to review [1-5] 4
    πŸ§ͺ Relevant tests No
    πŸ”’ Security concerns No
    ⚑ Key issues to review Performance Concerns:
    The addition of new textures, materials, and billboards could potentially impact performance, especially on lower-end devices. It's crucial to ensure that these additions do not degrade the user experience by causing frame rate drops or increased load times.
    Code Consistency:
    The use of hardcoded values (e.g., positions, colors) in several components might lead to inconsistencies and difficulties in maintenance. Consider using a centralized configuration or constants file.
    Possible Bug:
    The use of Float32Array for positions and colors in InstancedCastles.tsx assumes that all castles have valid positions and ownership data. This could lead to errors if the data is incomplete or incorrect.
    github-actions[bot] commented 2 weeks ago

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Performance
    Combine position and color data into a single buffer to enhance rendering performance ___ **To improve performance, consider using a single buffer for both positions and colors in
    the instanced meshes. This can reduce the number of buffer bindings during rendering.** [client/src/ui/components/models/buildings/worldmap/InstancedCastles.tsx [56-57]](https://github.com/BibliothecaDAO/eternum/pull/974/files#diff-5247f68e32ced43fc3431aef5a0ab60aa86291a0169ba2ee5ba33e6843270a75R56-R57) ```diff -const positionsBuffer = new Float32Array(castles.length * 3); -const colorsBuffer = new Float32Array(castles.length * 3); +const buffer = new Float32Array(castles.length * 6); +let offset = 0; +for (let i = 0; i < castles.length; i++) { + buffer.set([x, 8, -y, myColor.r, neutralColor.g, neutralColor.b], offset); + offset += 6; +} ```
    Suggestion importance[1-10]: 8 Why: Combining position and color data into a single buffer can significantly improve rendering performance by reducing the number of buffer bindings. This is a valuable optimization.
    8
    Maintainability
    Use a constant for the texture path to improve maintainability ___ **Consider using a constant for the texture path to ensure consistency and maintainability.
    This will help avoid typos and make it easier to update the path in the future if needed.** [client/src/ui/components/models/buildings/worldmap/InstancedCastles.tsx [28-32]](https://github.com/BibliothecaDAO/eternum/pull/974/files#diff-5247f68e32ced43fc3431aef5a0ab60aa86291a0169ba2ee5ba33e6843270a75R28-R32) ```diff -const mapLabel = useTexture("/textures/realm_label.png", (texture) => { +const TEXTURE_PATH = "/textures/realm_label.png"; +const mapLabel = useTexture(TEXTURE_PATH, (texture) => { texture.colorSpace = THREE.SRGBColorSpace; texture.magFilter = THREE.LinearFilter; texture.minFilter = THREE.LinearFilter; }); ```
    Suggestion importance[1-10]: 7 Why: Using a constant for the texture path can improve maintainability by reducing the risk of typos and making future updates easier. However, this change is not critical for functionality.
    7
    Refactor color assignment to a function to improve readability and reusability ___ **Refactor the color assignment logic to a function to enhance code readability and
    potential reusability.** [client/src/ui/components/models/buildings/worldmap/InstancedCastles.tsx [68-70]](https://github.com/BibliothecaDAO/eternum/pull/974/files#diff-5247f68e32ced43fc3431aef5a0ab60aa86291a0169ba2ee5ba33e6843270a75R68-R70) ```diff -if (castle.isMine) { - colorsBuffer.set([myColor.r, neutralColor.g, neutralColor.b], idx * 3); -} else { - colorsBuffer.set([neutralColor.r, neutralColor.g, neutralColor.b], idx * 3); +function getColor(castle) { + return castle.isMine ? [myColor.r, neutralColor.g, neutralColor.b] : [neutralColor.r, neutralColor.g, neutralColor.b]; } +colorsBuffer.set(getColor(castle), idx * 3); ```
    Suggestion importance[1-10]: 6 Why: Refactoring the color assignment logic into a function enhances code readability and reusability. This is a good practice for maintainability, though it does not impact functionality.
    6
    Possible issue
    Increase the precision of alphaTest to avoid rendering issues ___ **To avoid potential issues with floating-point precision in WebGL, consider using a higher
    precision for alphaTest in the material settings.** [client/src/ui/components/models/buildings/worldmap/InstancedCastles.tsx [39]](https://github.com/BibliothecaDAO/eternum/pull/974/files#diff-5247f68e32ced43fc3431aef5a0ab60aa86291a0169ba2ee5ba33e6843270a75R39-R39) ```diff -particlesMaterial.alphaTest = 0.001; +particlesMaterial.alphaTest = 0.01; ```
    Suggestion importance[1-10]: 5 Why: Increasing the precision of `alphaTest` can help avoid potential rendering issues due to floating-point precision in WebGL. This is a minor improvement but can be beneficial in specific scenarios.
    5