11import { 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' ;
33import {
44 Scene ,
55 WebGLRenderer ,
@@ -8,30 +8,18 @@ import {
88 MathUtils ,
99} from 'three' ;
1010import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js' ;
11- import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js' ;
1211import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js' ;
1312
1413let camera , controls , scene , renderer , tiles ;
1514
1615const raycaster = new Raycaster ( ) ;
1716raycaster . 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-
2818init ( ) ;
2919animate ( ) ;
3020
3121function 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
0 commit comments