Skip to content

Commit

Permalink
trivial updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Jan 12, 2025
1 parent 83b76d3 commit b248498
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 21 deletions.
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ URL params:

- `tab` content to draw, options(defaults to last one):

- `quat-curve`
- `hyper-cube`
- `hyper-cube-grid`
- `fly-city`
- `lamp-tree`
- `quat-tree`
- `quat-product`
- `prime-walk`
- `sphere-tess`
- `cubic-array`
- `quat-curve` a curve
- `hyper-cube` hyper cube
- `hyper-cube-grid` a grid of hyper cubes
- `fly-city` quternion fractal
- `lamp-tree` quternion fractal
- `quat-tree` quaternion tree
- `quat-product` quaternion product curve
- `prime-walk` some walk path
- `sphere-tess` sphere tessellation folded to 2 dimensions
- `cubic-array` array and grid in cubic space

- `read` to read from storage, options(defaults to `true`):

Expand All @@ -30,6 +30,18 @@ URL params:

### Development

Watch build MoonBit:

```bash
moon build --target js --debug --watch
```

Watch serve page:

```bash
yarn vite
```

### Licence

Apache 2.0
2 changes: 1 addition & 1 deletion src/lib/vertex.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn PolylineVertex::attrs() -> Array[CaterfoilAttribute] {
}

///|
pub(all) type! BuilderError String
pub(all) type! BuilderError String derive(Show)

///| turn a chunk of vertices into triangles data
pub fn create_vertex_data(
Expand Down
2 changes: 1 addition & 1 deletion src/main/container.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn Tab::from_string(s : String) -> Tab {
"quat-product" => QuatProduct
"prime-walk" => PrimeWalk
"sphere-tess" => SphereTessellation
"cubic-grid" => CubicArray
"cubic-array" => CubicArray
_ => {
println("Unknown tab: " + s)
Tab::default()
Expand Down
5 changes: 4 additions & 1 deletion src/main/main.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ pub let store : @caterfoil.Atom[Store] = @caterfoil.Atom::with_value(

///|
fn dispatch() -> Unit {
render_app?().unwrap()
match render_app?() {
Ok(_) => ()
Err(e) => println("\{e}")
}
}

///|
Expand Down
8 changes: 4 additions & 4 deletions src/main/shader-triangle.mbt

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

8 changes: 4 additions & 4 deletions src/main/shader/triangle.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ fn transform_perspective(p: vec4f) -> PointResult {
/// it is tricky since we don't know the real sight in 4D space
let look_direction = (forward + w_direction) / sqrt2;

let r: f32 = ga4_vec4f_inner(moved_point, look_direction) / look_distance;
let distanceRatio: f32 = ga4_vec4f_inner(moved_point, look_direction) / look_distance;

// if dz < (s * -0.9) || dw < (s * -0.9) {
// // make it disappear with depth test since it's probably behind the camera
// return PointResult(vec3(0.0, 0.0, 10000.), r, s);
// }

let screen_scale: f32 = (s + 1.0) / (r + s);
let screen_scale: f32 = (s + 1.0) / (distanceRatio + s);
let y_next: f32 = ga4_vec4f_inner(moved_point, upward) * screen_scale;
let x_next: f32 = ga4_vec4f_inner(moved_point, rightward) * screen_scale;
let z_next: f32 = r + 0.4; // negtive value is behind the camera and will be clipped
let z_next: f32 = distanceRatio + 0.4; // negtive value is behind the camera and will be clipped

return PointResult(
vec3(x_next, y_next / uniforms.viewport_ratio, z_next) * uniforms.scale,
r, s
distanceRatio, s
);
}

Expand Down

0 comments on commit b248498

Please sign in to comment.