-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Small demo for constraint solving (#134)
- Loading branch information
Showing
9 changed files
with
469 additions
and
0 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,28 @@ | ||
name: constraints build | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./constraints | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: Swatinem/rust-cache@v2 | ||
- name: Install wasm target | ||
run: rustup target add wasm32-unknown-unknown | ||
- name: Install trunk | ||
run: | | ||
wget -qO- https://github.com/trunk-rs/trunk/releases/download/v0.20.2/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf- | ||
- name: Build wasm-demo | ||
run: ./trunk build --release | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
resolver = "2" | ||
members = [ | ||
"fidget", | ||
"constraints", | ||
"demo", | ||
"viewer", | ||
"workspace-hack", | ||
|
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 @@ | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "constraints" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
anyhow = "1.0" | ||
eframe = { version = "0.27", default-features = false, features = [ | ||
"default_fonts", # Embed the default egui fonts. | ||
"glow", # Use the glow rendering backend. Alternative: "wgpu". | ||
] } | ||
|
||
fidget = { path = "../fidget", default-features = false, features = ["solver"] } | ||
log = "0.4" | ||
workspace-hack = { version = "0.1", path = "../workspace-hack" } | ||
|
||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] | ||
env_logger = "0.10.0" | ||
|
||
[target.'cfg(target_arch = "wasm32")'.dependencies] | ||
wasm-bindgen-futures = "0.4" |
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,29 @@ | ||
# Demo of constraint solving | ||
## WebAssembly | ||
### Setup | ||
``` | ||
cargon install +locked trunk # installs the `trunk` bundler | ||
``` | ||
### Developing | ||
In this folder, run | ||
``` | ||
trunk serve | ||
``` | ||
`trunk` will serve the webpage at `127.0.0.1:8080` | ||
|
||
### Deploying | ||
In this folder, run | ||
``` | ||
trunk build --release | ||
``` | ||
`trunk` will populate the `dist/` subfolder with assets. | ||
|
||
If the site will be hosted at a non-root URL, then add `--public-url`, e.g. | ||
``` | ||
trunk build --release --public-url=/projects/fidget/constraints/ | ||
``` | ||
|
||
## Native | ||
``` | ||
cargo run -pconstraints | ||
``` |
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,57 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
|
||
<!-- Disable zooming: --> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> | ||
|
||
<head> | ||
<title>Fidget constraint demo</title> | ||
|
||
<link data-trunk rel="rust" data-wasm-opt="2" /> | ||
<base data-trunk-public-url /> | ||
|
||
<style> | ||
html { | ||
/* Remove touch delay: */ | ||
touch-action: manipulation; | ||
} | ||
|
||
html, | ||
body { | ||
overflow: hidden; | ||
margin: 0 !important; | ||
padding: 0 !important; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
div.box { | ||
outline: 1px solid #bbb; | ||
margin: 20px; | ||
} | ||
|
||
/* Position canvas in center-top: */ | ||
canvas { | ||
display: block; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<!-- | ||
canvas-in-div is required because egui will float the canvas to the | ||
top of its container; see https://github.com/emilk/egui/discussions/746 | ||
--> | ||
<div class="box" style="position: relative; width: 300px; height: 300px"> | ||
<canvas id="the_canvas_id"></canvas> | ||
</div> | ||
|
||
<!-- | ||
<div class="box" style="position: relative; width: 300px; height: 300px"> | ||
<canvas id="the_other_canvas_id"></canvas> | ||
</div> | ||
--> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.