Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for env var ion key #917

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions example/ionLunar.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
<body>
<div id="info">
<div>
Paste the evaluation Cesium Ion token from the <a target="_blank" href="https://github.com/CesiumGS/cesium/blob/main/packages/engine/Source/Core/Ion.js#L6-L7">Cesium repository</a> or your own token and asset id <br/> into the fields and press "reload" to see the demo. See <a href="http://cesium.com">cesium.com</a> for more information.
<br/>
Lunar data demo courtesy of <a href="https://ion.cesium.com/">Cesium Ion</a>. API token required.
</div>
</div>
<script type="module" src="./ionLunar.js"></script>
Expand Down
3 changes: 2 additions & 1 deletion example/ionLunar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -82,6 +82,7 @@ function init() {
gui.width = 300;
gui.add( params, 'apiKey' );
gui.add( params, 'reload' );
gui.close();

}

Expand Down
51 changes: 29 additions & 22 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -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() ],
}

};
Loading