UNPKG

globe.gl

Version:

UI component for Globe Data Visualization using ThreeJS/WebGL

31 lines (25 loc) 1.23 kB
<head> <style> body { margin: 0; } </style> <script src="//cdn.jsdelivr.net/npm/globe.gl"></script> <!-- <script src="../../dist/globe.gl.js"></script>--> </head> <body> <div id="globeViz"></div> <script type="module"> import * as THREE from 'https://esm.sh/three'; const world = new Globe(document.getElementById('globeViz')) .globeImageUrl('//cdn.jsdelivr.net/npm/three-globe/example/img/earth-blue-marble.jpg') .bumpImageUrl('//cdn.jsdelivr.net/npm/three-globe/example/img/earth-topology.png') .backgroundImageUrl('//cdn.jsdelivr.net/npm/three-globe/example/img/night-sky.png'); // custom globe material const globeMaterial = world.globeMaterial(); globeMaterial.bumpScale = 10; new THREE.TextureLoader().load('//cdn.jsdelivr.net/npm/three-globe/example/img/earth-water.png', texture => { globeMaterial.specularMap = texture; globeMaterial.specular = new THREE.Color('grey'); globeMaterial.shininess = 15; }); const directionalLight = world.lights().find(light => light.type === 'DirectionalLight'); directionalLight && directionalLight.position.set(1, 1, 1); // change light position to see the specularMap's effect </script> </body>