add basic light component
This commit is contained in:
@@ -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
24
src/components/Light.tsx
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user