add basic light component

This commit is contained in:
Max Tobias Weber
2026-03-27 11:29:21 +01:00
parent deaee6f669
commit 48a7912d41
2 changed files with 26 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ import {
import IconButton from "@mui/material/IconButton"; import IconButton from "@mui/material/IconButton";
import MenuIcon from "@mui/icons-material/Menu"; import MenuIcon from "@mui/icons-material/Menu";
import LayerTree from "./components/LayerTree"; import LayerTree from "./components/LayerTree";
import Light from "./components/Light";
function App() { function App() {
const [sidebarOpen, setSidebarOpen] = useState(true); const [sidebarOpen, setSidebarOpen] = useState(true);
@@ -35,6 +36,7 @@ function App() {
<Sidebar open={sidebarOpen} setOpen={setSidebarOpen}> <Sidebar open={sidebarOpen} setOpen={setSidebarOpen}>
<LayerTree /> <LayerTree />
</Sidebar> </Sidebar>
<Light />
</> </>
); );
} }

24
src/components/Light.tsx Normal file
View File

@@ -0,0 +1,24 @@
import { useEffect } from "react";
import { LightingEffect, AmbientLight, DirectionalLight } from "@deck.gl/core";
import { useDeckGl } from "@mapcomponents/deck-gl";
const effect = new LightingEffect({
ambientLight: new AmbientLight({ color: [255, 255, 255], intensity: 1.8 }),
sunLight: new DirectionalLight({
color: [255, 240, 200],
intensity: 2.0,
direction: [-2, -4, -3],
}),
});
export default function LightingSetup() {
const { addEffect, removeEffect } = useDeckGl();
useEffect(() => {
addEffect(effect);
return () => removeEffect(effect);
}, []);
return null;
}