diff --git a/example/ionLunar.html b/example/ionLunar.html index eaa89f65..6f8afae1 100644 --- a/example/ionLunar.html +++ b/example/ionLunar.html @@ -44,8 +44,7 @@
- Paste the evaluation Cesium Ion token from the Cesium repository or your own token and asset id
into the fields and press "reload" to see the demo. See cesium.com for more information. -
+ Lunar data demo courtesy of Cesium Ion. API token required.
diff --git a/example/ionLunar.js b/example/ionLunar.js index f1c3224b..6a3eaf29 100644 --- a/example/ionLunar.js +++ b/example/ionLunar.js @@ -17,7 +17,7 @@ import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js'; let controls, scene, camera, renderer, tiles; -const apiKey = localStorage.getItem( 'ionApiKey' ) ?? 'put-your-api-key-here'; +const apiKey = localStorage.getItem( 'ionApiKey' ) ?? import.meta.env.VITE_ION_KEY ?? 'put-your-api-key-here'; const params = { apiKey: apiKey, @@ -82,6 +82,7 @@ function init() { gui.width = 300; gui.add( params, 'apiKey' ); gui.add( params, 'reload' ); + gui.close(); } diff --git a/vite.config.js b/vite.config.js index 0d0447ba..8282a20a 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,29 +1,36 @@ -import { searchForWorkspaceRoot } from 'vite'; +import { searchForWorkspaceRoot, loadEnv } from 'vite'; import fs from 'fs'; import react from '@vitejs/plugin-react'; -export default { +export default ( { mode } ) => { - root: './example/', - base: '', - build: { - outDir: './bundle/', - rollupOptions: { - input: [ - ...fs.readdirSync( './example/' ), - ...fs.readdirSync( './example/r3f/' ).map( name => 'r3f/' + name ), - ] - .filter( p => /\.html$/.test( p ) ) - .map( p => `./example/${ p }` ), + process.env = { ...process.env, ...loadEnv( mode, process.cwd() ) }; + + return { + + root: './example/', + envDir: '.', + base: '', + build: { + outDir: './bundle/', + rollupOptions: { + input: [ + ...fs.readdirSync( './example/' ), + ...fs.readdirSync( './example/r3f/' ).map( name => 'r3f/' + name ), + ] + .filter( p => /\.html$/.test( p ) ) + .map( p => `./example/${ p }` ), + }, }, - }, - server: { - fs: { - allow: [ - // search up for workspace root - searchForWorkspaceRoot( process.cwd() ), - ], + server: { + fs: { + allow: [ + // search up for workspace root + searchForWorkspaceRoot( process.cwd() ), + ], + }, }, - }, - plugins: [ react() ], + plugins: [ react() ], + } + };