Skip to content

Commit

Permalink
Make default demo a gyroid + sphere
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Jul 16, 2024
1 parent 94b5239 commit ded085f
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 2 deletions.
1 change: 1 addition & 0 deletions demos/web-editor/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "*.rhai";
2 changes: 1 addition & 1 deletion demos/web-editor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<span id="status">Loading...</span>
<select name="mode" id="mode">
<option value="bitmap">2D (bitmap)</option>
<option value="normals">3D (normals)</option>
<option value="normals" selected="selected">3D (normals)</option>
<option value="heightmap">3D (heightmap)</option>
</select>
</div>
Expand Down
2 changes: 1 addition & 1 deletion demos/web-editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {

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

const INITIAL_SCRIPT = "y + x*x";
import INITIAL_SCRIPT from "../../models/gyroid-sphere.rhai";

var fidget: any = null;

Expand Down
104 changes: 104 additions & 0 deletions demos/web-editor/package-lock.json

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

1 change: 1 addition & 0 deletions demos/web-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@wasm-tool/wasm-pack-plugin": "1.5.0",
"html-webpack-plugin": "^5.3.2",
"prettier": "3.2.5",
"raw-loader": "^4.0.2",
"ts-loader": "^9.5.1",
"typescript": "^5.4.5",
"webpack": "^5.49.0",
Expand Down
4 changes: 4 additions & 0 deletions demos/web-editor/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ module.exports = {
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.rhai$/i,
use: "raw-loader",
},
],
},
resolve: {
Expand Down
11 changes: 11 additions & 0 deletions models/gyroid-sphere.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let scale = 30;

let x = x * scale;
let y = y * scale;
let z = z * scale;

let gyroid = sin(x)*cos(y) + sin(y)*cos(z) + sin(z)*cos(x);
let fill = abs(gyroid) - 0.2;

let sphere = sqrt(square(x) + square(y) + square(z)) - 25;
draw(max(sphere, fill));

0 comments on commit ded085f

Please sign in to comment.