Skip to content

Commit

Permalink
Use ES modules for Three examples imports
Browse files Browse the repository at this point in the history
  • Loading branch information
vasturiano committed Dec 27, 2022
1 parent 7ad5451 commit 16b9934
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 32 deletions.
7 changes: 5 additions & 2 deletions example/basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
<style> body { margin: 0; } </style>

<script src="//unpkg.com/three"></script>
<script src="//unpkg.com/three/examples/js/controls/TrackballControls.js"></script>
<script src="//unpkg.com/three-globe"></script>
<!--<script src="../../dist/three-globe.js"></script>-->
</head>

<body>
<div id="globeViz"></div>

<script>
<script type="importmap">{ "imports": { "three": "https://unpkg.com/three/build/three.module.js" }}</script>
<script type="module">
import { TrackballControls } from '//unpkg.com/three/examples/jsm/controls/TrackballControls.js';
Object.assign(THREE , { TrackballControls });

// Gen random data
const N = 300;
const gData = [...Array(N).keys()].map(() => ({
Expand Down
7 changes: 5 additions & 2 deletions example/country-polygons/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
<style> body { margin: 0; } </style>

<script src="//unpkg.com/three"></script>
<script src="//unpkg.com/three/examples/js/controls/TrackballControls.js"></script>
<script src="//unpkg.com/three-globe"></script>
<!--<script src="../../dist/three-globe.js"></script>-->
</head>

<body>
<div id="globeViz"></div>

<script>
<script type="importmap">{ "imports": { "three": "https://unpkg.com/three/build/three.module.js" }}</script>
<script type="module">
import { TrackballControls } from '//unpkg.com/three/examples/jsm/controls/TrackballControls.js';
Object.assign(THREE , { TrackballControls });

fetch('./ne_110m_admin_0_countries.geojson').then(res => res.json()).then(countries =>
{
const Globe = new ThreeGlobe()
Expand Down
7 changes: 4 additions & 3 deletions example/custom-material/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
<style> body { margin: 0; } </style>

<script src="//unpkg.com/three"></script>
<script src="//unpkg.com/three/examples/js/controls/TrackballControls.js"></script>

<script src="//unpkg.com/three-globe"></script>
<!-- <script src="../../dist/three-globe.js"></script>-->
</head>

<body>
<div id="globeViz"></div>

<script>
<script type="importmap">{ "imports": { "three": "https://unpkg.com/three/build/three.module.js" }}</script>
<script type="module">
import { TrackballControls } from '//unpkg.com/three/examples/jsm/controls/TrackballControls.js';
Object.assign(THREE , { TrackballControls });

const Globe = new ThreeGlobe()
.globeImageUrl('//unpkg.com/three-globe/example/img/earth-blue-marble.jpg')
Expand Down
7 changes: 5 additions & 2 deletions example/custom/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
<style> body { margin: 0; } </style>

<script src="//unpkg.com/three"></script>
<script src="//unpkg.com/three/examples/js/controls/TrackballControls.js"></script>
<script src="//unpkg.com/three-globe"></script>
<!--<script src="../../dist/three-globe.js"></script>-->
</head>

<body>
<div id="globeViz"></div>

<script>
<script type="importmap">{ "imports": { "three": "https://unpkg.com/three/build/three.module.js" }}</script>
<script type="module">
import { TrackballControls } from '//unpkg.com/three/examples/jsm/controls/TrackballControls.js';
Object.assign(THREE , { TrackballControls });

// Gen random data
const N = 300;
const gData = [...Array(N).keys()].map(() => ({
Expand Down
7 changes: 5 additions & 2 deletions example/hexbin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
<style> body { margin: 0; } </style>

<script src="//unpkg.com/three"></script>
<script src="//unpkg.com/three/examples/js/controls/TrackballControls.js"></script>
<script src="//unpkg.com/three-globe"></script>
<!--<script src="../../dist/three-globe.js"></script>-->
</head>

<body>
<div id="globeViz"></div>

<script>
<script type="importmap">{ "imports": { "three": "https://unpkg.com/three/build/three.module.js" }}</script>
<script type="module">
import { TrackballControls } from '//unpkg.com/three/examples/jsm/controls/TrackballControls.js';
Object.assign(THREE , { TrackballControls });

// Gen random data
const N = 6000;
const gData = [...Array(N).keys()].map(() => ({
Expand Down
7 changes: 5 additions & 2 deletions example/hexed-polygons/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
<style> body { margin: 0; } </style>

<script src="//unpkg.com/three"></script>
<script src="//unpkg.com/three/examples/js/controls/TrackballControls.js"></script>
<script src="//unpkg.com/three-globe"></script>
<!--<script src="../../dist/three-globe.js"></script>-->
</head>

<body>
<div id="globeViz"></div>

<script>
<script type="importmap">{ "imports": { "three": "https://unpkg.com/three/build/three.module.js" }}</script>
<script type="module">
import { TrackballControls } from '//unpkg.com/three/examples/jsm/controls/TrackballControls.js';
Object.assign(THREE , { TrackballControls });

fetch('./ne_110m_admin_0_countries.geojson').then(res => res.json()).then(countries =>
{
const Globe = new ThreeGlobe()
Expand Down
12 changes: 7 additions & 5 deletions example/html-markers/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
<style> body { margin: 0; } </style>

<script src="//unpkg.com/three"></script>
<script src="//unpkg.com/three/examples/js/controls/TrackballControls.js"></script>
<script src="//unpkg.com/three/examples/js/renderers/CSS2DRenderer.js"></script>

<script src="//unpkg.com/three-globe"></script>
<script src="//unpkg.com/three-globe"></script>
<!-- <script src="../../dist/three-globe.js"></script>-->
</head>

<body>
<div id="globeViz"></div>

<script>
<script type="importmap">{ "imports": { "three": "https://unpkg.com/three/build/three.module.js" }}</script>
<script type="module">
import { TrackballControls } from '//unpkg.com/three/examples/jsm/controls/TrackballControls.js';
import { CSS2DRenderer } from '//unpkg.com/three/examples/jsm/renderers/CSS2DRenderer.js';
Object.assign(THREE , { TrackballControls, CSS2DRenderer });

const markerSvg = `<svg viewBox="-4 0 36 36">
<path fill="currentColor" d="M14,0 C21.732,0 28,5.641 28,12.6 C28,23.963 14,36 14,36 C14,36 0,24.064 0,12.6 C0,5.641 6.268,0 14,0 Z"></path>
<circle fill="black" cx="14" cy="14" r="7"></circle>
Expand Down
7 changes: 5 additions & 2 deletions example/labels/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
<style> body { margin: 0; } </style>

<script src="//unpkg.com/three"></script>
<script src="//unpkg.com/three/examples/js/controls/TrackballControls.js"></script>
<script src="//unpkg.com/three-globe"></script>
<!--<script src="../../dist/three-globe.js"></script>-->
</head>

<body>
<div id="globeViz"></div>

<script>
<script type="importmap">{ "imports": { "three": "https://unpkg.com/three/build/three.module.js" }}</script>
<script type="module">
import { TrackballControls } from '//unpkg.com/three/examples/jsm/controls/TrackballControls.js';
Object.assign(THREE , { TrackballControls });

// Gen random data
const N = 50;
const gData = [...Array(N).keys()].map(() => ({
Expand Down
7 changes: 5 additions & 2 deletions example/links/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
<style> body { margin: 0; } </style>

<script src="//unpkg.com/three"></script>
<script src="//unpkg.com/three/examples/js/controls/TrackballControls.js"></script>
<script src="//unpkg.com/three-globe"></script>
<!--<script src="../../dist/three-globe.js"></script>-->
</head>

<body>
<div id="globeViz"></div>

<script>
<script type="importmap">{ "imports": { "three": "https://unpkg.com/three/build/three.module.js" }}</script>
<script type="module">
import { TrackballControls } from '//unpkg.com/three/examples/jsm/controls/TrackballControls.js';
Object.assign(THREE , { TrackballControls });

// Gen random data
const N = 20;

Expand Down
7 changes: 5 additions & 2 deletions example/paths/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
<style> body { margin: 0; } </style>

<script src="//unpkg.com/three"></script>
<script src="//unpkg.com/three/examples/js/controls/TrackballControls.js"></script>
<script src="//unpkg.com/three-globe"></script>
<!--<script src="../../dist/three-globe.js"></script>-->
</head>

<body>
<div id="globeViz"></div>

<script>
<script type="importmap">{ "imports": { "three": "https://unpkg.com/three/build/three.module.js" }}</script>
<script type="module">
import { TrackballControls } from '//unpkg.com/three/examples/jsm/controls/TrackballControls.js';
Object.assign(THREE , { TrackballControls });

// Gen random paths
const N_PATHS = 10;
const MAX_POINTS_PER_LINE = 10000;
Expand Down
7 changes: 5 additions & 2 deletions example/ripples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
<style> body { margin: 0; } </style>

<script src="//unpkg.com/three"></script>
<script src="//unpkg.com/three/examples/js/controls/TrackballControls.js"></script>
<script src="//unpkg.com/three-globe"></script>
<!-- <script src="../../dist/three-globe.js"></script>-->
</head>

<body>
<div id="globeViz"></div>

<script>
<script type="importmap">{ "imports": { "three": "https://unpkg.com/three/build/three.module.js" }}</script>
<script type="module">
import { TrackballControls } from '//unpkg.com/three/examples/jsm/controls/TrackballControls.js';
Object.assign(THREE , { TrackballControls });

// Gen random data
const N = 10;
const gData = [...Array(N).keys()].map(() => ({
Expand Down
7 changes: 5 additions & 2 deletions example/satellites/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<script src="//unpkg.com/satellite.js/dist/satellite.min.js"></script>

<script src="//unpkg.com/three"></script>
<script src="//unpkg.com/three/examples/js/controls/TrackballControls.js"></script>
<script src="//unpkg.com/three-globe"></script>
<!-- <script src="../../dist/three-globe.js"></script>-->
</head>
Expand All @@ -27,7 +26,11 @@
<div id="globeViz"></div>
<div id="time-log"></div>

<script>
<script type="importmap">{ "imports": { "three": "https://unpkg.com/three/build/three.module.js" }}</script>
<script type="module">
import { TrackballControls } from '//unpkg.com/three/examples/jsm/controls/TrackballControls.js';
Object.assign(THREE , { TrackballControls });

const EARTH_RADIUS_KM = 6371; // km
const SAT_SIZE = 80; // km
const TIME_STEP = 3 * 1000; // per frame
Expand Down
7 changes: 5 additions & 2 deletions example/solar-terminator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
</style>

<script src="//unpkg.com/three"></script>
<script src="//unpkg.com/three/examples/js/controls/TrackballControls.js"></script>
<script src="//unpkg.com/three-globe"></script>
<!-- <script src="../../dist/three-globe.js"></script>-->

Expand All @@ -26,7 +25,11 @@

<div id="time"></div>

<script>
<script type="importmap">{ "imports": { "three": "https://unpkg.com/three/build/three.module.js" }}</script>
<script type="module">
import { TrackballControls } from '//unpkg.com/three/examples/jsm/controls/TrackballControls.js';
Object.assign(THREE , { TrackballControls });

const VELOCITY = 9; // minutes per frame

const sunPosAt = dt => {
Expand Down
7 changes: 5 additions & 2 deletions example/tiles/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
<style> body { margin: 0; } </style>

<script src="//unpkg.com/three"></script>
<script src="//unpkg.com/three/examples/js/controls/TrackballControls.js"></script>
<script src="//unpkg.com/three-globe"></script>
<!--<script src="../../dist/three-globe.js"></script>-->
</head>

<body>
<div id="globeViz"></div>

<script>
<script type="importmap">{ "imports": { "three": "https://unpkg.com/three/build/three.module.js" }}</script>
<script type="module">
import { TrackballControls } from '//unpkg.com/three/examples/jsm/controls/TrackballControls.js';
Object.assign(THREE , { TrackballControls });

const TILE_MARGIN = 0.35; // degrees

// Gen random data
Expand Down

0 comments on commit 16b9934

Please sign in to comment.