Skip to content

Commit 1afc9bb

Browse files
committed
Use ion key
1 parent 80bb820 commit 1afc9bb

File tree

2 files changed

+4
-29
lines changed

2 files changed

+4
-29
lines changed

example/googleMapsAerial.js

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { GeoUtils, WGS84_ELLIPSOID, TilesRenderer } from '3d-tiles-renderer';
2-
import { GoogleCloudAuthPlugin, TilesFadePlugin, TileCompressionPlugin, GLTFExtensionsPlugin } from '3d-tiles-renderer/plugins';
2+
import { TilesFadePlugin, TileCompressionPlugin, GLTFExtensionsPlugin, CesiumIonAuthPlugin } from '3d-tiles-renderer/plugins';
33
import {
44
Scene,
55
WebGLRenderer,
@@ -8,30 +8,18 @@ import {
88
MathUtils,
99
} from 'three';
1010
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
11-
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';
1211
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
1312

1413
let camera, controls, scene, renderer, tiles;
1514

1615
const raycaster = new Raycaster();
1716
raycaster.firstHitOnly = true;
1817

19-
const apiKey = localStorage.getItem( 'googleApiKey' ) ?? 'put-your-api-key-here';
20-
21-
const params = {
22-
23-
'apiKey': apiKey,
24-
'reload': reinstantiateTiles,
25-
26-
};
27-
2818
init();
2919
animate();
3020

3121
function reinstantiateTiles() {
3222

33-
localStorage.setItem( 'googleApiKey', params.apiKey );
34-
3523
if ( tiles ) {
3624

3725
scene.remove( tiles.group );
@@ -41,7 +29,7 @@ function reinstantiateTiles() {
4129
}
4230

4331
tiles = new TilesRenderer();
44-
tiles.registerPlugin( new GoogleCloudAuthPlugin( { apiToken: params.apiKey } ) );
32+
tiles.registerPlugin( new CesiumIonAuthPlugin( { apiToken: import.meta.env.VITE_ION_KEY, assetId: '2275207', autoRefreshToken: true } ) );
4533
tiles.registerPlugin( new TileCompressionPlugin() );
4634
tiles.registerPlugin( new TilesFadePlugin() );
4735
tiles.registerPlugin( new GLTFExtensionsPlugin( {
@@ -96,13 +84,6 @@ function init() {
9684
window.addEventListener( 'resize', onWindowResize, false );
9785
window.addEventListener( 'hashchange', initFromHash );
9886

99-
// GUI
100-
const gui = new GUI();
101-
gui.width = 300;
102-
gui.add( params, 'apiKey' );
103-
gui.add( params, 'reload' );
104-
gui.open();
105-
10687
// run hash functions
10788
initFromHash();
10889

example/googleMapsExample.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import {
77
TilesRenderer,
88
} from '3d-tiles-renderer';
99
import {
10-
GoogleCloudAuthPlugin,
1110
TilesFadePlugin,
1211
UpdateOnChangePlugin,
1312
TileCompressionPlugin,
1413
UnloadTilesPlugin,
1514
GLTFExtensionsPlugin,
1615
BatchedTilesPlugin,
16+
CesiumIonAuthPlugin,
1717
} from '3d-tiles-renderer/plugins';
1818
import {
1919
Scene,
@@ -29,15 +29,12 @@ import Stats from 'three/examples/jsm/libs/stats.module.js';
2929
let controls, scene, renderer, tiles, transition;
3030
let statsContainer, stats;
3131

32-
const apiKey = localStorage.getItem( 'googleApiKey' ) ?? 'put-your-api-key-here';
33-
3432
const params = {
3533

3634
orthographic: false,
3735

3836
enableCacheDisplay: false,
3937
enableRendererStats: false,
40-
apiKey: apiKey,
4138
useBatchedMesh: Boolean( new URLSearchParams( window.location.hash.replace( /^#/, '' ) ).get( 'batched' ) ),
4239
errorTarget: 40,
4340

@@ -58,10 +55,8 @@ function reinstantiateTiles() {
5855

5956
}
6057

61-
localStorage.setItem( 'googleApiKey', params.apiKey );
62-
6358
tiles = new TilesRenderer();
64-
tiles.registerPlugin( new GoogleCloudAuthPlugin( { apiToken: params.apiKey, autoRefreshToken: true } ) );
59+
tiles.registerPlugin( new CesiumIonAuthPlugin( { apiToken: import.meta.env.VITE_ION_KEY, assetId: '2275207', autoRefreshToken: true } ) );
6560
tiles.registerPlugin( new TileCompressionPlugin() );
6661
tiles.registerPlugin( new UpdateOnChangePlugin() );
6762
tiles.registerPlugin( new UnloadTilesPlugin() );
@@ -152,7 +147,6 @@ function init() {
152147
} );
153148

154149
const mapsOptions = gui.addFolder( 'Google Photorealistic Tiles' );
155-
mapsOptions.add( params, 'apiKey' );
156150
mapsOptions.add( params, 'useBatchedMesh' ).listen();
157151
mapsOptions.add( params, 'reload' );
158152

0 commit comments

Comments
 (0)