Compare commits
25
Commits
abcdfc8b00
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b060ced878 | ||
|
|
463fac575a | ||
|
|
bc231a8e91 | ||
|
|
5f864a86f8 | ||
|
|
930b896d58 | ||
|
|
c3e6ea7b88 | ||
|
|
61ca20a5e1 | ||
|
|
6ee793765b | ||
|
|
0d04ed5f12 | ||
|
|
9d942b1ea5 | ||
|
|
b05af111ad | ||
|
|
96e8169707 | ||
|
|
5d462f9963 | ||
|
|
96d6e69b3a | ||
|
|
ba06b988af | ||
|
|
855d67b1fa | ||
|
|
4e7260ff92 | ||
|
|
0630e77b17 | ||
|
|
a26c829f58 | ||
|
|
38fe7b38bd | ||
|
|
a8c01e6ad7 | ||
|
|
61dc5cc9c3 | ||
|
|
26a9a9b8d0 | ||
|
|
db021cb24b | ||
|
|
fbd8c9f990 |
@@ -21,3 +21,5 @@ target/
|
|||||||
# Added by cargo
|
# Added by cargo
|
||||||
|
|
||||||
/target
|
/target
|
||||||
|
|
||||||
|
pkg/
|
||||||
|
|||||||
Generated
+172
@@ -0,0 +1,172 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.20.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "double-pendulum-wasm"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-core"
|
||||||
|
version = "0.3.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-task"
|
||||||
|
version = "0.3.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-util"
|
||||||
|
version = "0.3.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-task",
|
||||||
|
"pin-project-lite",
|
||||||
|
"slab",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.105"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ce57d20d1ea864ce2ac172ab472d409214f4fd359f0b2a2775abdf522e2af99e"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"futures-util",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.21.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-project-lite"
|
||||||
|
version = "0.2.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.107"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.47"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.23"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "slab"
|
||||||
|
version = "0.4.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "3.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen"
|
||||||
|
version = "0.2.128"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "aecb87a33d3b0c5e3b7aa46336eaf486cffafbd281b195e4c8b80d50df2351bf"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"once_cell",
|
||||||
|
"rustversion",
|
||||||
|
"wasm-bindgen-macro",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.128"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a690d511e3c1a8b3a55e33511e3c2c00c78415cd23650f32b808627f5696b9ed"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.128"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "411e4887f0071ef2d2164a9d5fdf2d20efbef78fccd3a78b0c10a1dc5295e48a"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.128"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "81941cd78d0c92026c33e5e01312845a4cb1e9af3407f9134b100dd03144103e"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "web-sys"
|
||||||
|
version = "0.3.105"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9fbddc4a036f00ec4f18c83445bd3115cb306a91da554919a099d9222fe4a7f8"
|
||||||
|
dependencies = [
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
+10
-1
@@ -1,6 +1,15 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "double-pendulum"
|
authors = ["Philippe Zwietering"]
|
||||||
|
name = "double-pendulum-wasm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.128"
|
||||||
|
|
||||||
|
[dependencies.web-sys]
|
||||||
|
version = "0.3.105"
|
||||||
|
features = ['Document', 'Element', 'HtmlElement', 'Node', 'Window']
|
||||||
|
|||||||
Vendored
+33
-1
@@ -2,9 +2,41 @@ pipeline {
|
|||||||
agent any
|
agent any
|
||||||
stages {
|
stages {
|
||||||
stage('Check') {
|
stage('Check') {
|
||||||
sh 'cargo check'
|
steps {
|
||||||
|
sh 'cargo check -r --target wasm32-unknown-unknown'
|
||||||
|
sh 'cargo tree -e features --target wasm32-unknown-unknown'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage('Build') {
|
||||||
|
steps {
|
||||||
|
sh 'wasm-pack build --target web'
|
||||||
|
archiveArtifacts artifacts: 'pkg/'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build docs') {
|
||||||
|
steps {
|
||||||
|
sh 'cargo doc -r'
|
||||||
|
archiveArtifacts artifacts: 'target/doc/'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Deploy') {
|
||||||
|
steps {
|
||||||
|
sh 'rm -r /var/www/zwietering.eu/projects/double-pendulum'
|
||||||
|
sh 'mkdir /var/www/zwietering.eu/projects/double-pendulum'
|
||||||
|
sh 'cp -r ./pkg/* /var/www/zwietering.eu/projects/double-pendulum'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Deploy docs') {
|
||||||
|
steps {
|
||||||
|
sh 'cp -r ./target/doc/ /var/www/zwietering.eu/projects/double-pendulum'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
cleanup {
|
cleanup {
|
||||||
cleanWs()
|
cleanWs()
|
||||||
|
|||||||
@@ -1,3 +1,32 @@
|
|||||||
# double-pendulum
|
# double-pendulum
|
||||||
|
|
||||||
Double Pendulum chaotic sim in rust + webassembly
|
[Docs](https://zwietering.eu/projects/double-pendulum/doc/double_pendulum_wasm)
|
||||||
|
|
||||||
|
<!--toc:start-->
|
||||||
|
|
||||||
|
- [double-pendulum](#double-pendulum)
|
||||||
|
- [Prereqs](#prereqs)
|
||||||
|
- [Build](#build)
|
||||||
|
|
||||||
|
<!--toc:end-->
|
||||||
|
|
||||||
|
Double Pendulum chaotic sim in rust + webassembly (WIP)
|
||||||
|
|
||||||
|
## Prereqs
|
||||||
|
|
||||||
|
- Rust toolchain (`rustup`, `cargo`, `rustc`)
|
||||||
|
- Install [`wasm-pack`](https://github.com/wasm-bindgen/wasm-pack)
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
Package can be built using:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wasm-pack build --target web
|
||||||
|
```
|
||||||
|
|
||||||
|
Result can be viewed by hosting the directory, e.g. using:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd pkg && python -m http.server 8080
|
||||||
|
```
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
use std::fs;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("cargo:rerun-if-changed=index.html");
|
||||||
|
|
||||||
|
let _ = fs::create_dir_all("pkg");
|
||||||
|
|
||||||
|
if let Err(e) = fs::copy("index.html", "pkg/index.html") {
|
||||||
|
eprintln!("Error: Couldn't copy index.html: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script type="module">
|
||||||
|
import init from './double_pendulum_wasm.js';
|
||||||
|
|
||||||
|
async function run() {
|
||||||
|
await init();
|
||||||
|
}
|
||||||
|
|
||||||
|
run();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[toolchain]
|
||||||
|
channel = "1.94.0"
|
||||||
|
targets = ["wasm32-unknown-unknown"]
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
//! WASM implementation of a double pendulum simulation
|
||||||
|
//!
|
||||||
|
//! See README.md for installation / build instructions.
|
||||||
|
//! This implementation is just a stub for now.
|
||||||
|
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
|
#[wasm_bindgen(start)]
|
||||||
|
fn main() -> Result<(), JsValue> {
|
||||||
|
let window = web_sys::window().expect("No global `window` exists");
|
||||||
|
let document = window.document().expect("No `document` on `window`");
|
||||||
|
let body = document.body().expect("Document should have a body");
|
||||||
|
|
||||||
|
let content = document.create_element("p")?;
|
||||||
|
content.set_inner_html("Hoi vanuit rust!");
|
||||||
|
|
||||||
|
body.append_child(&content)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
fn main() {
|
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user