Skip to content

Commit

Permalink
Merge pull request #206 from open-pv/169-tiles-caching
Browse files Browse the repository at this point in the history
Terrain toggle now only hides terrain tiles instead of destroying them
  • Loading branch information
khdlr authored Aug 22, 2024
2 parents 54bb877 + 31edae5 commit 7febe65
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/ThreeViewer/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const Scene = ({
setPVPoints={setPVPoints}
/>

{simulationMesh != undefined && showTerrain && <Terrain />}
{simulationMesh != undefined && <Terrain visible={showTerrain}/>}
</Canvas>
)
}
Expand Down
8 changes: 6 additions & 2 deletions src/components/ThreeViewer/Terrain.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const TerrainTile = (props) => {
return mesh
}

const Terrain = () => {
const Terrain = ({visible}) => {
const [x, y] = coordinatesXY15
let tiles = []
const tx = Math.floor(x * 16)
Expand All @@ -127,7 +127,11 @@ const Terrain = () => {
tiles.push(<TerrainTile key={key} x={tx + dx} y={ty + dy} zoom={19} />)
}

return <>{tiles}</>
console.log(`Terrain visible:`)
console.log(visible);
return <group visible={visible}>
{tiles}
</group>
}

export default Terrain

0 comments on commit 7febe65

Please sign in to comment.