Skip to content

Commit

Permalink
Merge branch 'main' into erl/feat/fitted_weights
Browse files Browse the repository at this point in the history
  • Loading branch information
erlewa authored Aug 1, 2024
2 parents 12bae36 + 2ddb622 commit ba118d5
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 11 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Rust

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

jobs:
check:
name: cargo clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cargo Target
run: rustup target add wasm32-unknown-unknown
- name: Cargo Toolchain
run: rustup toolchain add nightly
- name: Cargo Clippy
run: cargo clippy
formatting:
name: cargo fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Ensure rustfmt is installed and setup problem matcher
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- name: Rustfmt Check
uses: actions-rust-lang/rustfmt@v1
52 changes: 48 additions & 4 deletions heatmap-client/src/canvas/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl CameraContext {
width: config.width as f64,
height: config.height as f64,
position: (0.0, 0.0).into(),
zoom: 10.0,
zoom: 1.0,
};

let mut camera_uniform = CameraUniform::new();
Expand Down Expand Up @@ -112,16 +112,60 @@ impl CameraContext {
self.camera.aspect = aspect;
}

CameraEvent::Zoom(zoom, mut pos) => {
CameraEvent::Zoom(mut zoom, mut pos) => {
let camera_size =
cgmath::Vector2::<f64>::new(self.camera.width, self.camera.height)
/ (self.camera.zoom + zoom);

if camera_size.x > 360.0 {
zoom = self.camera.width / 360.0 - self.camera.zoom;
}

if camera_size.y > 170.0 {
zoom = zoom.max(self.camera.height / 170.0 - self.camera.zoom);
}

if self.camera.zoom + zoom < 0.0 {
zoom = -self.camera.zoom + 0.001;
}

let scale_factor = (self.camera.zoom + zoom) / self.camera.zoom;

self.camera.zoom += zoom;

pos = self.mouse_coordinate_convert(pos);
self.update_camera(CameraEvent::Translate(pos - pos * scale_factor));
}

CameraEvent::Translate(pos) => {
CameraEvent::Translate(mut pos) => {
let camera_upper_bounds: cgmath::Vector2<f64> = self.camera.position
+ pos
+ cgmath::Vector2::<f64>::new(
self.camera.width / self.camera.zoom,
-self.camera.height / self.camera.zoom,
);

let camera_lower_bounds: cgmath::Vector2<f64> = self.camera.position + pos;

if camera_upper_bounds.x > 180.0 {
pos.x = 0.0;
self.camera.position.x = 180.0 - self.camera.width / self.camera.zoom;
}

if camera_upper_bounds.y < -90.0 {
pos.y = 0.0;
self.camera.position.y = -90.0 + self.camera.height / self.camera.zoom;
}

if camera_lower_bounds.y > 80.0 {
pos.y = 0.0;
self.camera.position.y = 80.0;
}

if camera_lower_bounds.x < -180.0 {
pos.x = 0.0;
self.camera.position.x = -180.0;
}

self.camera.position += pos;
}

Expand Down
13 changes: 9 additions & 4 deletions heatmap-client/src/canvas/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ impl<'a> State<'a> {

if new_size.height > render_context.limits.max_texture_dimension_2d {
new_size.height = render_context.limits.max_texture_dimension_2d;
}
}match zoom {
15.0..30.0 => {
active_outline_layer = &geometry.outline_layers[1];
}
0.0..15.0 => {
active_outline_layer = &geometry.outline_layers[2];
}

render_context.size = new_size;

Expand Down Expand Up @@ -232,7 +238,6 @@ impl<'a> State<'a> {
0,
0..1,
);
}

render_context
.queue
Expand Down Expand Up @@ -309,10 +314,10 @@ impl<'a> State<'a> {
let zoom = render_context.camera_context.camera.zoom;
let mut active_outline_layer = &geometry.outline_layers[0];
match zoom {
6.0..7.5 => {
15.0..30.0 => {
active_outline_layer = &geometry.outline_layers[1];
}
0.0..6.0 => {
0.0..15.0 => {
active_outline_layer = &geometry.outline_layers[2];
}
_ => (),
Expand Down
4 changes: 2 additions & 2 deletions heatmap-client/src/ingest/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn mesh_data(data_exterior: Data) -> Vec<BufferStorage> {
.collect();

let mut level = 0.0;
while level <= 1.0 {
while level <= 0.4 {
let mut weights = VecDeque::from(weights.clone());
let mut total_vertices: Vec<BlendVertex> = Vec::new();
let mut indices: Vec<u32> = Vec::new();
Expand Down Expand Up @@ -148,7 +148,7 @@ fn mesh_data(data_exterior: Data) -> Vec<BufferStorage> {
num_indices,
});

level += 0.5;
level += 0.2;
}
lods
}
2 changes: 1 addition & 1 deletion heatmap-service/Assets/outline.geojson

Large diffs are not rendered by default.

0 comments on commit ba118d5

Please sign in to comment.