-
Notifications
You must be signed in to change notification settings - Fork 154
/
index.html
51 lines (41 loc) · 1.68 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<head>
<style> body { margin: 0; } </style>
<script src="//unpkg.com/react/umd/react.production.min.js"></script>
<script src="//unpkg.com/react-dom/umd/react-dom.production.min.js"></script>
<script src="//unpkg.com/@babel/standalone"></script>
<script src="//unpkg.com/react-globe.gl"></script>
<!-- <script src="../../dist/react-globe.gl.js"></script>-->
</head>
<body>
<div id="globeViz"></div>
<script type="text/jsx" data-type="module">
import * as THREE from '//unpkg.com/three/build/three.module.js';
const { useEffect, useRef } = React;
// custom globe material
const globeMaterial = new THREE.MeshPhongMaterial();
globeMaterial.bumpScale = 10;
new THREE.TextureLoader().load('//unpkg.com/three-globe/example/img/earth-water.png', texture => {
globeMaterial.specularMap = texture;
globeMaterial.specular = new THREE.Color('grey');
globeMaterial.shininess = 15;
});
const World = () => {
const globeEl = useRef();
useEffect(() => {
const directionalLight = globeEl.current.lights().find(obj3d => obj3d.type === 'DirectionalLight');
directionalLight && directionalLight.position.set(1, 1, 1); // change light position to see the specularMap's effect
}, []);
return <Globe
ref={globeEl}
globeMaterial={globeMaterial}
globeImageUrl="//unpkg.com/three-globe/example/img/earth-blue-marble.jpg"
bumpImageUrl="//unpkg.com/three-globe/example/img/earth-topology.png"
backgroundImageUrl="//unpkg.com/three-globe/example/img/night-sky.png"
/>;
};
ReactDOM.render(
<World />,
document.getElementById('globeViz')
);
</script>
</body>