Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 62 additions & 2 deletions .github/workflows/deploy-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@ name: deploy-web
on:
push:
branches: [main]
pull_request: {}
workflow_dispatch: {}

permissions:
contents: read
deployments: write
pull-requests: write

# superseded preview builds get cancelled, main deploys never are
concurrency:
group: deploy-web-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
deploy:
runs-on: ubuntu-latest
# fork PRs have no access to the vercel secrets
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/checkout@v5
- uses: DeterminateSystems/determinate-nix-action@v3
Expand All @@ -31,13 +44,60 @@ jobs:
- name: install vercel CLI
run: npm install -g vercel@latest
- name: deploy to vercel
id: vercel
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
# the CLI logs to stderr and prints only the deployment URL to stdout
run: |
if [ "${{ github.event_name }}" = "push" ]; then
vercel deploy dist/public --prod --token="$VERCEL_TOKEN" --yes
url=$(vercel deploy dist/public --prod --token="$VERCEL_TOKEN" --yes)
echo "environment=Production" >> "$GITHUB_OUTPUT"
else
url=$(vercel deploy dist/public --token="$VERCEL_TOKEN" --yes)
echo "environment=Preview" >> "$GITHUB_OUTPUT"
fi
echo "url=$url" >> "$GITHUB_OUTPUT"
- name: record deployment on github
env:
GH_TOKEN: ${{ github.token }}
run: |
deployment_id=$(jq -n \
--arg ref "${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}" \
--arg env "${{ steps.vercel.outputs.environment }}" \
'{ref: $ref, environment: $env, auto_merge: false, required_contexts: [],
production_environment: ($env == "Production"),
transient_environment: ($env == "Preview")}' \
| gh api "repos/${{ github.repository }}/deployments" --input - --jq .id)
jq -n \
--arg url "${{ steps.vercel.outputs.url }}" \
--arg log "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
'{state: "success", environment_url: $url, log_url: $log, auto_inactive: true}' \
| gh api "repos/${{ github.repository }}/deployments/$deployment_id/statuses" --input -
- name: comment preview url on pr
if: github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ github.token }}
URL: ${{ steps.vercel.outputs.url }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.pull_request.number }}
# one sticky comment per PR, updated in place on each push
run: |
marker="<!-- deploy-web-preview -->"
body="$(cat <<EOF
$marker
### Preview deployment

| Commit | Preview | Deployed |
| --- | --- | --- |
| \`${HEAD_SHA:0:7}\` | [Visit preview]($URL) | $(date -u +'%b %-d, %Y %H:%M UTC') |
EOF
)"
comment_id=$(gh api "repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \
--paginate --jq "[.[] | select(.body | startswith(\"$marker\"))][0].id // empty")
if [ -n "$comment_id" ]; then
gh api -X PATCH "repos/${{ github.repository }}/issues/comments/$comment_id" -f body="$body"
else
vercel deploy dist/public --token="$VERCEL_TOKEN" --yes
gh api "repos/${{ github.repository }}/issues/$PR_NUMBER/comments" -f body="$body"
fi
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polyblade"
version = "0.3.4"
version = "0.4.0"
edition = "2024"
description = "Make shapes dance."
readme = "README.md"
Expand Down
24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@
</p>
</div>

## WARNING
This software is currently broken. Use the release published on crates.io or 0.1.0 while I fix it, which can be installed using the method below.
The main branch is not as functional as it once was, but this will be remedied soon post-refactor.

## Installation
```cargo install polyblade```
## Running

Note that the `webGPU` demo is available [here](https://polyblade.app). It runs just as smoothly as the native application.

Expand All @@ -54,11 +49,12 @@ Due to the recent refactor, we're not as far along on this roadmap as we once we
Rest assured that in due time we will conquer all shapes.

- [x] Ambo
- [ ] Kis
- [x] Kis
- [x] Truncate
- [ ] Ortho
- [x] Bevel
- [ ] Expand
- [x] Expand
- [x] Dual
- [ ] Snub
- [ ] Join
- [ ] Zip
Expand All @@ -74,14 +70,14 @@ Rest assured that in due time we will conquer all shapes.
- [ ] "Undo" button
- [ ] Save and load animations and cycles of `Transaction`s
- [x] Schlegel diagrams
- [x] Color pickers
- [ ] Color pickers
- [ ] Pokedex entries for polyhedra, point users to wikipedia or polytope wiki when they stumble onto a known entry
- [x] Basic functionality
- [ ] Basic functionality
- [ ] Switch from `RON` to `JSON`
- [ ] Expand pokedex to include more shapes and improve overlap on isomorphic conway strings
- [ ] Fix pokedex on WASM
- [ ] Create WASM deployment and add to website as git submodule
- [ ] Fix `time` on web for `dual` and related transitions
- [x] WebGL compat
- [ ] WebGPU compat
- [ ] Create WASM deployment
- [x] Fix `time` on web for `dual` and related transitions
- [ ] WebGL compat
- [x] WebGPU compat
- [x] Setup some basic CI integrations
10 changes: 10 additions & 0 deletions assets/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,10 @@ video {
}
}

.collapse {
visibility: collapse;
}

.static {
position: static;
}
Expand Down Expand Up @@ -630,6 +634,12 @@ video {
outline-style: solid;
}

.ring {
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
}

.filter {
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
}
30 changes: 28 additions & 2 deletions src/polyhedron/conway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ impl Polyhedron {
}

pub fn truncate(&mut self, d: usize) -> Vec<[VertexId; 2]> {
// Full truncation is built in one pass and recomputes once.
if d == 0 {
let (new_edges, parents) = self.shape.truncate();
self.render.rebuild_from_parents(&parents);
return new_edges;
}

// Selective truncation still uses the slow per-vertex path; perf is a follow-up.
let mut new_edges = Vec::default();
for v in self.shape.vertices().rev() {
if d == 0 || self.shape.degree(v) == d {
if self.shape.degree(v) == d {
new_edges.extend(self.split_vertex(v));
self.shape.recompute();
self.shape.recompute_metrics();
}
}
new_edges
Expand Down Expand Up @@ -49,4 +57,22 @@ impl Polyhedron {
pub fn chamfer(&mut self) {
self.shape.chamfer();
}

pub fn expand(&mut self) {
let (parents, _) = self.shape.expand();
self.render.rebuild_from_parents(&parents);
}

/// Expands, then returns the face-figure edges to contract for the dual.
/// The animated `Dual` transaction drives the contraction; call `dual` to apply it immediately.
pub fn begin_dual(&mut self) -> Vec<[VertexId; 2]> {
let (parents, face_edges) = self.shape.expand();
self.render.rebuild_from_parents(&parents);
face_edges
}

pub fn dual(&mut self) {
let edges = self.begin_dual();
self.contract(edges);
}
}
Loading