mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 01:15:12 +03:00
Run the experiment on the web
This commit is contained in:
parent
0727619e18
commit
f57fb8f2f6
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -717,6 +717,7 @@ dependencies = [
|
|||||||
"map_model",
|
"map_model",
|
||||||
"rand",
|
"rand",
|
||||||
"rand_xorshift",
|
"rand_xorshift",
|
||||||
|
"wasm-bindgen",
|
||||||
"widgetry",
|
"widgetry",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -981,7 +982,6 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"sim",
|
"sim",
|
||||||
"svg_face",
|
"svg_face",
|
||||||
"walkdir",
|
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"widgetry",
|
"widgetry",
|
||||||
]
|
]
|
||||||
|
@ -4,8 +4,12 @@ version = "0.1.0"
|
|||||||
authors = ["Dustin Carlino <dabreegster@gmail.com>"]
|
authors = ["Dustin Carlino <dabreegster@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib", "lib"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["map_gui/native", "widgetry/native-backend"]
|
default = ["map_gui/native", "widgetry/native-backend"]
|
||||||
|
wasm = ["map_gui/wasm", "wasm-bindgen", "widgetry/wasm-backend"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
abstutil = { path = "../abstutil" }
|
abstutil = { path = "../abstutil" }
|
||||||
@ -15,4 +19,5 @@ map_gui = { path = "../map_gui" }
|
|||||||
map_model = { path = "../map_model" }
|
map_model = { path = "../map_model" }
|
||||||
rand = "0.7.0"
|
rand = "0.7.0"
|
||||||
rand_xorshift = "0.2.0"
|
rand_xorshift = "0.2.0"
|
||||||
|
wasm-bindgen = { version = "0.2.68", optional = true }
|
||||||
widgetry = { path = "../widgetry" }
|
widgetry = { path = "../widgetry" }
|
||||||
|
36
experiment/index.html
Normal file
36
experiment/index.html
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<style>
|
||||||
|
/*!
|
||||||
|
* Load Awesome v1.1.0 (http://github.danielcardoso.net/load-awesome/)
|
||||||
|
* Copyright 2015 Daniel Cardoso <@DanielCardoso>
|
||||||
|
* Licensed under MIT
|
||||||
|
*/
|
||||||
|
.la-ball-beat,.la-ball-beat>div{position:relative;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.la-ball-beat{display:block;font-size:0;color:#fff}.la-ball-beat.la-dark{color:#333}.la-ball-beat>div{display:inline-block;float:none;background-color:currentColor;border:0 solid currentColor}.la-ball-beat{width:54px;height:18px}.la-ball-beat>div{width:10px;height:10px;margin:4px;border-radius:100%;-webkit-animation:ball-beat 0.7s -0.15s infinite linear;-moz-animation:ball-beat 0.7s -0.15s infinite linear;-o-animation:ball-beat 0.7s -0.15s infinite linear;animation:ball-beat 0.7s -0.15s infinite linear}.la-ball-beat>div:nth-child(2n-1){-webkit-animation-delay:-.5s;-moz-animation-delay:-.5s;-o-animation-delay:-.5s;animation-delay:-.5s}.la-ball-beat.la-sm{width:26px;height:8px}.la-ball-beat.la-sm>div{width:4px;height:4px;margin:2px}.la-ball-beat.la-2x{width:108px;height:36px}.la-ball-beat.la-2x>div{width:20px;height:20px;margin:8px}.la-ball-beat.la-3x{width:162px;height:54px}.la-ball-beat.la-3x>div{width:30px;height:30px;margin:12px}@-webkit-keyframes ball-beat{50%{opacity:.2;-webkit-transform:scale(0.75);transform:scale(0.75)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@-moz-keyframes ball-beat{50%{opacity:.2;-moz-transform:scale(0.75);transform:scale(0.75)}100%{opacity:1;-moz-transform:scale(1);transform:scale(1)}}@-o-keyframes ball-beat{50%{opacity:.2;-o-transform:scale(0.75);transform:scale(0.75)}100%{opacity:1;-o-transform:scale(1);transform:scale(1)}}@keyframes ball-beat{50%{opacity:.2;-webkit-transform:scale(0.75);-moz-transform:scale(0.75);-o-transform:scale(0.75);transform:scale(0.75)}100%{opacity:1;-webkit-transform:scale(1);-moz-transform:scale(1);-o-transform:scale(1);transform:scale(1)}}
|
||||||
|
</style>
|
||||||
|
<script type="module">
|
||||||
|
import { default as init } from './experiment.js';
|
||||||
|
|
||||||
|
async function run() {
|
||||||
|
await init('./experiment_bg.wasm');
|
||||||
|
}
|
||||||
|
|
||||||
|
run();
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body style="background-color:black;">
|
||||||
|
<div id="loading" style="padding-top: 40px; color: white; text-align: center; font-family: arial; font-size: 200%;">
|
||||||
|
<h1>Loading 15 minute Santa...</h1>
|
||||||
|
<div style="margin: auto" class="la-ball-beat la-2x">
|
||||||
|
<div></div>
|
||||||
|
<div></div>
|
||||||
|
<div></div>
|
||||||
|
</div>
|
||||||
|
<h2>this may take up to 30 seconds</h2>
|
||||||
|
<p>If you think something has broken, check your browser's developer console (Ctrl+Shift+I or similar)</p>
|
||||||
|
<p>(your browser must support WebGL and WebAssembly)</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
<html>
|
1
experiment/pkg/index.html
Symbolic link
1
experiment/pkg/index.html
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../index.html
|
1
experiment/pkg/system
Symbolic link
1
experiment/pkg/system
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../data/system/
|
6
experiment/run_web.sh
Executable file
6
experiment/run_web.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
wasm-pack build --dev --target web -- --no-default-features --features wasm
|
||||||
|
cd pkg
|
||||||
|
python3 -m http.server 8000
|
25
experiment/src/lib.rs
Normal file
25
experiment/src/lib.rs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
mod animation;
|
||||||
|
mod controls;
|
||||||
|
mod game;
|
||||||
|
mod levels;
|
||||||
|
mod meters;
|
||||||
|
mod upzone;
|
||||||
|
|
||||||
|
pub fn main() {
|
||||||
|
widgetry::run(widgetry::Settings::new("experiment"), |ctx| {
|
||||||
|
let mut opts = map_gui::options::Options::default();
|
||||||
|
opts.color_scheme = map_gui::colors::ColorSchemeChoice::NightMode;
|
||||||
|
let app = map_gui::SimpleApp::new_with_opts(ctx, abstutil::CmdArgs::new(), opts);
|
||||||
|
let states = vec![levels::TitleScreen::new(ctx)];
|
||||||
|
(app, states)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
#[wasm_bindgen(start)]
|
||||||
|
pub fn run() {
|
||||||
|
main();
|
||||||
|
}
|
@ -1,16 +1,3 @@
|
|||||||
mod animation;
|
|
||||||
mod controls;
|
|
||||||
mod game;
|
|
||||||
mod levels;
|
|
||||||
mod meters;
|
|
||||||
mod upzone;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
widgetry::run(widgetry::Settings::new("experiment"), |ctx| {
|
experiment::main();
|
||||||
let mut opts = map_gui::options::Options::default();
|
|
||||||
opts.color_scheme = map_gui::colors::ColorSchemeChoice::NightMode;
|
|
||||||
let app = map_gui::SimpleApp::new_with_opts(ctx, abstutil::CmdArgs::new(), opts);
|
|
||||||
let states = vec![levels::TitleScreen::new(ctx)];
|
|
||||||
(app, states)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
@ -45,4 +45,3 @@ widgetry = { path = "../widgetry" }
|
|||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
built = "0.4.2"
|
built = "0.4.2"
|
||||||
walkdir = "2.2.7"
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
VERSION=dev
|
VERSION=dev
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Publish the game
|
||||||
cd game
|
cd game
|
||||||
wasm-pack build --release --target web -- --no-default-features --features wasm,map_gui/wasm_s3
|
wasm-pack build --release --target web -- --no-default-features --features wasm,map_gui/wasm_s3
|
||||||
cd pkg
|
cd pkg
|
||||||
@ -11,6 +13,19 @@ rm -f system
|
|||||||
aws s3 sync . s3://abstreet/$VERSION
|
aws s3 sync . s3://abstreet/$VERSION
|
||||||
# Undo that symlink hiding
|
# Undo that symlink hiding
|
||||||
git checkout system
|
git checkout system
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Publish the experiment
|
||||||
|
cd experiment
|
||||||
|
wasm-pack build --release --target web -- --no-default-features --features wasm,map_gui/wasm_s3
|
||||||
|
cd pkg
|
||||||
|
# Temporarily remove the symlink to the data directory; it's uploaded separately by the updater tool
|
||||||
|
rm -f system
|
||||||
|
aws s3 sync . s3://abstreet/$VERSION/experiment
|
||||||
|
# Undo that symlink hiding
|
||||||
|
git checkout system
|
||||||
|
cd ../..
|
||||||
|
|
||||||
# Set the content type for .wasm files, to speed up how browsers load them
|
# Set the content type for .wasm files, to speed up how browsers load them
|
||||||
aws s3 cp \
|
aws s3 cp \
|
||||||
s3://abstreet/$VERSION \
|
s3://abstreet/$VERSION \
|
||||||
|
Loading…
Reference in New Issue
Block a user