Wire live serial data into matrix renderer

This commit is contained in:
lennlouisgeek
2026-05-20 01:23:02 +08:00
parent a7b617419d
commit d2c9fad556
18 changed files with 874 additions and 63 deletions

View File

@@ -84,9 +84,9 @@ pub fn glyph_world_position(
rows: u32,
cols: u32,
layout: &MatrixLayout,
time: f32,
pressure: f32,
) -> ([f32; 4], f32) {
let normalized = demo_pressure(row, col, time);
let normalized = pressure.clamp(0.0, 1.0);
let height = BASE_HEIGHT + normalized.powf(0.9) * HEIGHT_SCALE;
let x = (col as f32 - cols as f32 / 2.0 + 0.5) * layout.cell_spacing;
let z = (row as f32 - rows as f32 / 2.0 + 0.5) * layout.cell_spacing;
@@ -102,14 +102,6 @@ pub fn glyph_world_position(
)
}
fn demo_pressure(row: u32, col: u32, time: f32) -> f32 {
let seed = ((row * 17 + col * 31) as f32).sin() * 43_758.547;
let phase = seed.fract() * std::f32::consts::TAU;
let slow = 0.5 + 0.5 * (time * 1.35 + phase).sin();
let row_wave = 0.5 + 0.5 * (time * 0.82 + row as f32 * 0.54 + col as f32 * 0.19).sin();
(slow * row_wave).powf(0.72).clamp(0.0, 1.0)
}
fn fit_camera_distance(board_width: f32, board_depth: f32, board_padding: f32, aspect: f32) -> f32 {
let padded_width = board_width + board_padding * 2.0;
let padded_depth = board_depth + board_padding * 2.0;