mirror of
https://github.com/storytold/AniCraft.git
synced 2026-11-19 09:01:29 +01:00
src/web.rs starts the editor on a page canvas with eframe's WebRunner (WebGL2 via glow) and provides the browser's services; platform.rs decides when: picked files go to the engine's in-memory store and the command runs, saves and exports leave as downloads, preferences and recovery copies live in localStorage, Web Locks tell open tabs from crashed ones, and leaving with unsaved work asks first. The GPU stage and sound output become build cfgs that are off on wasm. Video export and plug-in installs are dimmed in the browser with the reason. scripts/build-web.sh and .ps1 build web/ with the wasm-bindgen CLI pinned to Cargo.lock's version, from packaging/web/index.html. The web profile (opt-level s, stripped, renderer and geometry at opt-level 3) gives an 8973 KB module, 3278 KB gzipped, in 41 s. crates/engine/tests/wasm.rs runs the engine inside WebAssembly in Node (3 tests, 0.6 s).
35 lines
1.5 KiB
HTML
35 lines
1.5 KiB
HTML
<!doctype html>
|
|
<!-- The page the web editor runs in (ADR 0036, docs/web.md). scripts/build-web.sh copies it into
|
|
web/ beside the generated anicraft.js and anicraft_bg.wasm; src/web.rs looks for the two ids
|
|
below. Colours are the Graphite theme's chrome and dim text (src/theme.rs). -->
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="color-scheme" content="dark">
|
|
<title>AniCraft</title>
|
|
<link rel="icon" href="anicraft.png">
|
|
<style>
|
|
html, body { margin: 0; height: 100%; overflow: hidden; background: #131316; }
|
|
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
|
|
#anicraft_loading {
|
|
position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
|
|
padding: 2em; text-align: center; color: #b0b0b8; font: 15px/1.5 system-ui, sans-serif;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<canvas id="anicraft_canvas"></canvas>
|
|
<div id="anicraft_loading">Loading AniCraft…</div>
|
|
<noscript>AniCraft needs JavaScript and WebAssembly.</noscript>
|
|
<script type="module">
|
|
import init from "./anicraft.js";
|
|
// init() loads anicraft_bg.wasm and runs the program's main, which starts the editor.
|
|
init().catch((e) => {
|
|
console.error(e);
|
|
document.getElementById("anicraft_loading").textContent = "AniCraft could not start in this browser: " + e;
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|