Skip to content

Commit

Permalink
Reorganize web demo into subfolders (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter authored Oct 6, 2024
1 parent eb5870e commit d00a346
Show file tree
Hide file tree
Showing 20 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wasm-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./demos/web-editor
working-directory: ./demos/web-editor/web
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [
"demos/viewer",
"workspace-hack",
]
exclude = ["demos/web-editor"]
exclude = ["demos/web-editor/crate"]

[profile.release]
debug = true
Expand Down
9 changes: 5 additions & 4 deletions demos/web-editor/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
pkg
dist
target
web/node_modules
web/dist
web/pkg
crate/pkg
crate/target
2 changes: 1 addition & 1 deletion demos/web-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ The `web-editor` subfolder embeds Fidget into a web application.
Building this demo requires [`wasm-pack`](https://rustwasm.github.io/wasm-pack/)
to be installed on the host system.

Run the editor demo with
Run the editor demo in the `web` subfolder with

```
npm install
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ bincode = "1.3.3"
wasm-bindgen = "0.2.92"
nalgebra = "0.33"

fidget = {path = "../../fidget", default-features = false, features = ["rhai", "mesh", "render"]}
fidget = {path = "../../../fidget", default-features = false, features = ["rhai", "mesh", "render"]}

# Take advantage of feature unification to turn on wasm-bindgen here
rhai = { version = "*", features = ["wasm-bindgen"] }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import { rhai } from "./rhai";

import { RENDER_SIZE, WORKERS_PER_SIDE, WORKER_COUNT } from "./constants";

import GYROID_SCRIPT from "../../models/gyroid-sphere.rhai";
import GYROID_SCRIPT from "../../../../models/gyroid-sphere.rhai";

var fidget: any = null;

async function setup() {
fidget = await import("./pkg")!;
fidget = await import("../../crate/pkg")!;
const app = new App();
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Worker {
}

async function run() {
fidget = await import("./pkg")!;
fidget = await import("../../crate/pkg")!;
let worker: null | Worker = null;
onmessage = function (e: any) {
let req = e.data as WorkerRequest;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const HtmlWebpackPlugin = require("html-webpack-plugin");
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");

module.exports = {
entry: "./index.ts",
entry: "./src/index.ts",
module: {
rules: [
{
Expand All @@ -30,18 +30,18 @@ module.exports = {
},
plugins: [
new HtmlWebpackPlugin({
template: "index.html",
template: "src/index.html",
}),
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, "."),
crateDirectory: path.resolve(__dirname, "../crate/"),
}),
],
mode: "development",
experiments: {
asyncWebAssembly: true,
},
devServer: {
watchFiles: ["./index.html", "./worker.ts"],
watchFiles: ["./src/index.html", "./src/worker.ts"],
hot: true,
},
};

0 comments on commit d00a346

Please sign in to comment.