-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
44 lines (36 loc) · 1.35 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
<head>
<style> body { margin: 0; } </style>
<script src="//unpkg.com/aframe"></script>
<script src="//unpkg.com/@ar-js-org/ar.js"></script>
<script src="//unpkg.com/globe-ar"></script>
<!--<script src="../../dist/globe-ar.js"></script>-->
</head>
<body>
<div id="globeViz"></div>
<script type="module">
import * as THREE from 'https://esm.sh/three';
const TILE_MARGIN = 0.35; // degrees
// Gen random data
const GRID_SIZE = [60, 20];
const COLORS = ['red', 'green', 'yellow', 'blue', 'orange', 'pink', 'brown', 'purple', 'magenta'];
const materials = COLORS.map(color => new THREE.MeshLambertMaterial({ color, opacity: 0.6, transparent: true }));
const tileWidth = 360 / GRID_SIZE[0];
const tileHeight = 180 / GRID_SIZE[1];
const tilesData = [];
[...Array(GRID_SIZE[0]).keys()].forEach(lngIdx =>
[...Array(GRID_SIZE[1]).keys()].forEach(latIdx =>
tilesData.push({
lng: -180 + lngIdx * tileWidth,
lat: -90 + (latIdx + 0.5) * tileHeight,
material: materials[Math.floor(Math.random() * materials.length)]
})
)
);
new GlobeAR(document.getElementById('globeViz'))
.tilesData(tilesData)
.tileWidth(tileWidth - TILE_MARGIN)
.tileHeight(tileHeight - TILE_MARGIN)
.tileAltitude(0.02)
.tileMaterial('material');
</script>
</body>