|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 4 | + |
| 5 | +<!-- Disable zooming: --> |
| 6 | +<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> |
| 7 | + |
| 8 | +<head> |
| 9 | + <title>Puffin Viewer</title> |
| 10 | + <style> |
| 11 | + html { |
| 12 | + /* Remove touch delay: */ |
| 13 | + touch-action: manipulation; |
| 14 | + } |
| 15 | + |
| 16 | + body { |
| 17 | + /* Background color for what is not covered by the egui canvas, |
| 18 | + or where the egui canvas is translucent. */ |
| 19 | + background: #404040; |
| 20 | + } |
| 21 | + |
| 22 | + /* Allow canvas to fill entire web page: */ |
| 23 | + html, |
| 24 | + body { |
| 25 | + overflow: hidden; |
| 26 | + margin: 0 !important; |
| 27 | + padding: 0 !important; |
| 28 | + } |
| 29 | + |
| 30 | + /* Position canvas in center-top: */ |
| 31 | + canvas { |
| 32 | + margin-right: auto; |
| 33 | + margin-left: auto; |
| 34 | + display: block; |
| 35 | + position: absolute; |
| 36 | + top: 0%; |
| 37 | + left: 50%; |
| 38 | + transform: translate(-50%, 0%); |
| 39 | + } |
| 40 | + </style> |
| 41 | + <link rel="manifest" href="./manifest.json"> |
| 42 | + <script> |
| 43 | + // register ServiceWorker |
| 44 | + window.onload = () => { |
| 45 | + 'use strict'; |
| 46 | + |
| 47 | + if ('serviceWorker' in navigator) { |
| 48 | + navigator.serviceWorker |
| 49 | + .register('./sw.js'); |
| 50 | + } |
| 51 | + } |
| 52 | + </script> |
| 53 | +</head> |
| 54 | + |
| 55 | +<body> |
| 56 | + <!-- The WASM code will resize this canvas to cover the entire screen --> |
| 57 | + <canvas id="the_canvas_id"></canvas> |
| 58 | + |
| 59 | + <script> |
| 60 | + // The `--no-modules`-generated JS from `wasm-bindgen` attempts to use |
| 61 | + // `WebAssembly.instantiateStreaming` to instantiate the wasm module, |
| 62 | + // but this doesn't work with `file://` urls. This example is frequently |
| 63 | + // viewed by simply opening `index.html` in a browser (with a `file://` |
| 64 | + // url), so it would fail if we were to call this function! |
| 65 | + // |
| 66 | + // Work around this for now by deleting the function to ensure that the |
| 67 | + // `no_modules.js` script doesn't have access to it. You won't need this |
| 68 | + // hack when deploying over HTTP. |
| 69 | + delete WebAssembly.instantiateStreaming; |
| 70 | + </script> |
| 71 | + |
| 72 | + <!-- This is the JS generated by the `wasm-bindgen` CLI tool --> |
| 73 | + <script src="puffin_viewer.js"></script> |
| 74 | + |
| 75 | + <script> |
| 76 | + // We'll defer our execution until the wasm is ready to go. |
| 77 | + // Here we tell bindgen the path to the wasm file so it can start |
| 78 | + // initialization and return to us a promise when it's done. |
| 79 | + wasm_bindgen("./puffin_viewer_bg.wasm") |
| 80 | + .then(on_wasm_loaded)["catch"](console.error); |
| 81 | + |
| 82 | + function on_wasm_loaded() { |
| 83 | + // This call installs a bunch of callbacks and then returns. |
| 84 | + wasm_bindgen.start("the_canvas_id"); |
| 85 | + } |
| 86 | + </script> |
| 87 | +</body> |
| 88 | + |
| 89 | +</html> |
| 90 | + |
| 91 | +<!-- Powered by egui: https://github.com/emilk/egui/ --> |
0 commit comments