-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overhauled rendering internals and introduced a new workflow
- Loading branch information
1 parent
e5cdd01
commit b4d07bb
Showing
5 changed files
with
111 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
rm -r dist | ||
mkdir dist | ||
cp src/index.html dist/index.html | ||
cp -r lib/pkg/* dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,68 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Atomica</title> | ||
</head> | ||
<body> | ||
<canvas id="canvas"></canvas> | ||
<script type="module"> | ||
import init from './src.js'; | ||
init().then(() => { | ||
console.log("Wasm module initialized"); | ||
}); | ||
</script> | ||
</body> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Atomica</title> | ||
<style> | ||
body { | ||
margin: 0; | ||
overflow: hidden; | ||
} | ||
#canvas { | ||
display: block; | ||
width: 100vw; | ||
height: 100vh; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<canvas id="canvas"></canvas> | ||
<script type="module"> | ||
import init, * as wasm_bindgen from './src.js'; | ||
|
||
function jsInit() { | ||
console.log("Wasm module initialized"); | ||
|
||
if (typeof window.resize_callback === 'undefined' && typeof wasm_bindgen.resize_callback !== 'undefined') { | ||
console.log("Setting resize callback"); | ||
window.resize_callback = wasm_bindgen.resize_callback; | ||
} | ||
|
||
const canvas = document.getElementById('canvas'); | ||
|
||
function resizeCanvas() { | ||
const canvas = document.getElementById('canvas'); | ||
const width = window.innerWidth; | ||
const height = window.innerHeight; | ||
canvas.width = width; | ||
canvas.height = height; | ||
|
||
if (typeof window.resize_callback === 'function') { | ||
window.resize_callback(width, height); | ||
} | ||
} | ||
|
||
window.addEventListener('resize', resizeCanvas); | ||
window.addEventListener('load', resizeCanvas); | ||
} | ||
init().then(() => { | ||
jsInit(); | ||
}).catch(err => { | ||
if (err.message.includes("Using exceptions for control flow")) { | ||
console.warn("Ignoring expected Wasm initialization exception and proceeding."); | ||
try { | ||
jsInit(); | ||
} catch (err) { | ||
console.error("Error in continuing initialisation:", err); | ||
throw err; | ||
} | ||
} else { | ||
console.error("Error initializing wasm module:", err); | ||
throw err; | ||
} | ||
}); | ||
console.log("Wasm module initialization call made"); | ||
</script> | ||
</body> | ||
</html> |