Skip to content

Commit 5162646

Browse files
authored
fix #95 fix stories
1 parent eb9e9b7 commit 5162646

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

stories/src/canvas/maplibre.stories.tsx

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,49 @@ import { FC, useRef, useState } from "react";
44
import Map from 'react-map-gl/maplibre';
55
import { Mesh } from "three";
66
import { Canvas } from "react-three-map/maplibre";
7+
import { Leva } from "leva";
78

8-
export default {title: 'Canvas'}
9+
export default { title: 'Canvas' }
910

1011
export function Maplibre() {
11-
return <div style={{ height: '100vh' }}>
12-
<Map
13-
antialias
14-
initialViewState={{
15-
latitude: 51,
16-
longitude: 0,
17-
zoom: 13,
18-
pitch: 60,
19-
}}
20-
mapStyle="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"
21-
>
22-
<Canvas latitude={51} longitude={0}>
23-
<hemisphereLight
24-
args={["#ffffff", "#60666C"]}
25-
position={[1, 4.5, 3]}
26-
intensity={Math.PI}
27-
/>
28-
<object3D scale={500}>
29-
<Box position={[-1.2, 1, 0]} />
30-
<Box position={[1.2, 1, 0]} />
31-
</object3D>
32-
</Canvas>
33-
</Map>
34-
</div>
12+
return <>
13+
<Leva theme={{ sizes: { rootWidth: '340px', controlWidth: '150px' } }} />
14+
<div style={{ height: '100vh' }}>
15+
<Map
16+
antialias
17+
initialViewState={{
18+
latitude: 51,
19+
longitude: 0,
20+
zoom: 13,
21+
pitch: 60,
22+
}}
23+
mapStyle="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"
24+
>
25+
<Canvas latitude={51} longitude={0}>
26+
<hemisphereLight
27+
args={["#ffffff", "#60666C"]}
28+
position={[1, 4.5, 3]}
29+
intensity={Math.PI}
30+
/>
31+
<object3D scale={500}>
32+
<Box position={[-1.2, 1, 0]} />
33+
<Box position={[1.2, 1, 0]} />
34+
</object3D>
35+
</Canvas>
36+
</Map>
37+
</div>
38+
</>
3539
}
3640

37-
const Box : FC<{position: Vector3}> = (props) => {
41+
const Box: FC<{ position: Vector3 }> = (props) => {
3842
// This reference gives us direct access to the THREE.Mesh object
3943
const ref = useRef<Mesh>(null)
4044
// Hold state for hovered and clicked events
4145
const [hovered, hover] = useState(false)
4246
const [clicked, click] = useState(false)
4347
// Subscribe this component to the render-loop, rotate the mesh every frame
4448
useFrame((_state, delta) => {
45-
if(!ref.current) return;
49+
if (!ref.current) return;
4650
ref.current.rotation.x += delta;
4751
ref.current.rotation.z -= delta;
4852
})

0 commit comments

Comments
 (0)