Skip to content

Wasm webapp#15

Merged
hmeyer merged 10 commits intomainfrom
wasm-webapp
Mar 16, 2026
Merged

Wasm webapp#15
hmeyer merged 10 commits intomainfrom
wasm-webapp

Conversation

@hmeyer
Copy link
Owner

@hmeyer hmeyer commented Mar 16, 2026

No description provided.

hmeyer and others added 10 commits March 16, 2026 07:03
- Delete all GTK source files (window, editor, menu, mesh_view,
  object_widget, settings, main) and kiss3ddeps subcrate
- Remove all non-WASM deps (gtk, gdk, glib, cairo-rs, sourceview4,
  kiss3d, rayon, dirs, pollster, serde, toml, num-traits, bencher)
- Replace rayon par_iter with iter in render.rs (no threads in WASM)
- Set crate-type to [cdylib, rlib] for WASM + test builds
- Remaining deps: implicit3d, nalgebra, piccolo, stl_io, tessellation

All 31 tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Exposes the core Rust logic to JavaScript via wasm-bindgen:
- eval(code) → {output, error} — runs Lua, stores resulting object
- render(w, h) → Uint8ClampedArray — ray-march to putImageData-ready buffer
- rotate(dx, dy) / pan(dx, dy) — mutate renderer transform
- tessellate() → Uint8Array — binary STL bytes for Three.js mesh view and export

Also adds ObjectAdaptor bridging implicit3d::Object to tessellation::ImplicitFunction,
and thread_local AppState holding the Renderer and current object.

All 31 tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
getrandom 0.2.x needs the "js" feature and 0.3.x (pulled in via
piccolo → ahash) needs both the "wasm_js" feature and the
getrandom_backend cfg flag. Fix by:
- .cargo/config.toml: set rustflags for wasm32-unknown-unknown
- Cargo.toml: explicit wasm32 target deps for both getrandom versions
- Add pkg/ to .gitignore (wasm-pack build output)

`wasm-pack build --target web` now succeeds, producing a 732K .wasm
and JS bindings in pkg/. All 31 native tests still pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- web/index.html: two-panel layout (editor + canvas), tab toggle
  between ray-march preview and Three.js mesh view
- web/main.js: vanilla JS wiring CM6 editor, WASM calls, drag
  rotate/pan, Mesh button (STLLoader + OrbitControls), STL export
- web/main.css: dark IDE-style theme using CSS Grid
- package.json + build.mjs: esbuild bundle + wasm-pack output → dist/
- Fix render.rs alpha channel (was 0, must be 255 for putImageData)
- .gitignore: add node_modules/ and dist/

`node build.mjs` produces a working dist/ (1.7M bundled JS + 732K WASM).
31 Rust tests still pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Uses esbuild's context/watch/serve APIs to:
- Copy static assets (index.html, main.css, WASM files) to dist/ once
- Watch web/ for JS/CSS changes and rebuild automatically
- Serve dist/ at http://localhost:8080

Usage:
  wasm-pack build --target web   # once, or after Rust changes
  npm run serve                  # starts dev server

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the minimal placeholder with full documentation:
- App usage (Run/Mesh/Export, drag controls)
- Complete Lua API reference (primitives, booleans, transforms, deformations)
- Development setup (wasm-pack, npm install, serve, tests)
- Architecture overview

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- main: add grid-template-rows: 1fr so the grid row fills the
  available height instead of auto-sizing to content
- .cm-editor: add min-height: 0 so the flex item can shrink
  below its content height within the column flex container

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
wasm-bindgen silently renames `eval` to `_eval` in the JS glue
because `eval` is reserved in JavaScript. The import
`import { eval as wasmEval }` caused a module linking error in
the browser, preventing the entire script (including the CM6
editor) from executing.

Rename the #[wasm_bindgen] function to `run_script` and update
main.js accordingly. Also rebuild pkg/ with the new name.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- .github/workflows/deploy.yml: build WASM + bundle JS on push to
  main, deploy dist/ to GitHub Pages via actions/deploy-pages
- .github/workflows/ci.yml: remove GTK system deps (no longer needed)
- README.md: add live app link and deploy badge

Live at: https://hmeyer.github.io/truescad/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PLAN.md was removed from main (it lives here on the dev branch).
Keep our updated version with all phase statuses.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hmeyer hmeyer merged commit 3b030f5 into main Mar 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant