diff --git a/Cargo.lock b/Cargo.lock index 125dd4a..48ebfb2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,7 +175,7 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bevy" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_internal", ] @@ -183,7 +183,7 @@ dependencies = [ [[package]] name = "bevy-crevice-derive" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_macro_utils", "proc-macro2", @@ -194,7 +194,7 @@ dependencies = [ [[package]] name = "bevy_animation" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_app", "bevy_asset", @@ -210,7 +210,7 @@ dependencies = [ [[package]] name = "bevy_app" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_derive", "bevy_ecs", @@ -223,7 +223,7 @@ dependencies = [ [[package]] name = "bevy_asset" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "anyhow", "bevy_app", @@ -250,7 +250,7 @@ dependencies = [ [[package]] name = "bevy_audio" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "anyhow", "bevy_app", @@ -265,7 +265,7 @@ dependencies = [ [[package]] name = "bevy_core" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_app", "bevy_derive", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "bevy_core_pipeline" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_app", "bevy_asset", @@ -293,7 +293,7 @@ dependencies = [ [[package]] name = "bevy_crevice" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy-crevice-derive", "bytemuck", @@ -304,7 +304,7 @@ dependencies = [ [[package]] name = "bevy_derive" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_macro_utils", "quote", @@ -314,7 +314,7 @@ dependencies = [ [[package]] name = "bevy_diagnostic" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_app", "bevy_core", @@ -326,7 +326,7 @@ dependencies = [ [[package]] name = "bevy_ecs" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "async-channel", "bevy_ecs_macros", @@ -343,7 +343,7 @@ dependencies = [ [[package]] name = "bevy_ecs_macros" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_macro_utils", "proc-macro2", @@ -354,7 +354,7 @@ dependencies = [ [[package]] name = "bevy_gilrs" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_app", "bevy_ecs", @@ -366,7 +366,7 @@ dependencies = [ [[package]] name = "bevy_gltf" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "anyhow", "base64", @@ -392,7 +392,7 @@ dependencies = [ [[package]] name = "bevy_hierarchy" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_app", "bevy_ecs", @@ -404,7 +404,7 @@ dependencies = [ [[package]] name = "bevy_input" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_app", "bevy_ecs", @@ -415,7 +415,7 @@ dependencies = [ [[package]] name = "bevy_internal" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_animation", "bevy_app", @@ -450,7 +450,7 @@ dependencies = [ [[package]] name = "bevy_log" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "android_log-sys", "bevy_app", @@ -466,7 +466,7 @@ dependencies = [ [[package]] name = "bevy_macro_utils" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "cargo-manifest", "quote", @@ -476,7 +476,7 @@ dependencies = [ [[package]] name = "bevy_math" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_reflect", "glam", @@ -485,7 +485,7 @@ dependencies = [ [[package]] name = "bevy_pbr" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_app", "bevy_asset", @@ -505,7 +505,7 @@ dependencies = [ [[package]] name = "bevy_reflect" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_reflect_derive", "bevy_utils", @@ -521,7 +521,7 @@ dependencies = [ [[package]] name = "bevy_reflect_derive" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_macro_utils", "proc-macro2", @@ -533,7 +533,7 @@ dependencies = [ [[package]] name = "bevy_render" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "anyhow", "bevy_app", @@ -568,7 +568,7 @@ dependencies = [ [[package]] name = "bevy_scene" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "anyhow", "bevy_app", @@ -586,7 +586,7 @@ dependencies = [ [[package]] name = "bevy_sprite" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_app", "bevy_asset", @@ -611,7 +611,7 @@ dependencies = [ [[package]] name = "bevy_tasks" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "async-channel", "async-executor", @@ -624,7 +624,7 @@ dependencies = [ [[package]] name = "bevy_text" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "ab_glyph", "anyhow", @@ -647,7 +647,7 @@ dependencies = [ [[package]] name = "bevy_transform" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_app", "bevy_ecs", @@ -659,7 +659,7 @@ dependencies = [ [[package]] name = "bevy_ui" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_app", "bevy_asset", @@ -687,7 +687,7 @@ dependencies = [ [[package]] name = "bevy_utils" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "ahash", "bevy_derive", @@ -701,7 +701,7 @@ dependencies = [ [[package]] name = "bevy_window" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "bevy_app", "bevy_ecs", @@ -714,7 +714,7 @@ dependencies = [ [[package]] name = "bevy_winit" version = "0.7.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#6f16580b8a23a14704627f28164c2b06f80422df" +source = "git+https://github.com/bevyengine/bevy?rev=6f16580b8#6f16580b8a23a14704627f28164c2b06f80422df" dependencies = [ "approx", "bevy_app", @@ -1747,7 +1747,6 @@ checksum = "488dfa92203650a0c2b702166141312f372e87a00183e2ea825ad7da7471f7c6" dependencies = [ "byteorder", "chrono", - "laz", "log", "num-traits", "thiserror", @@ -3046,7 +3045,7 @@ version = "0.1.0" dependencies = [ "bevy", "bytemuck", - "las", + "copc-rs", ] [[package]] diff --git a/viewer/Cargo.toml b/viewer/Cargo.toml index 785ffd2..e1e9217 100644 --- a/viewer/Cargo.toml +++ b/viewer/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" trace_tracy = ["bevy/trace_tracy"] [dependencies] -bevy = { version = "0.7.0-dev", git = "https://github.com/bevyengine/bevy", branch = "main" } -las = { version = "0.7.4", features = ["laz"] } +bevy = { version = "0.7.0-dev", git = "https://github.com/bevyengine/bevy", rev = "6f16580b8" } +copc-rs = { path = ".." } bytemuck = "1.9.1" diff --git a/viewer/src/main.rs b/viewer/src/main.rs index 107935b..7a71d7a 100644 --- a/viewer/src/main.rs +++ b/viewer/src/main.rs @@ -36,7 +36,9 @@ use bevy::{ }; use bytemuck::{cast_slice, Pod, Zeroable}; -use las::{Read as LasRead, Reader}; +use copc_rs::reader::{CopcReader, LodSelection}; +use std::fs::File; +use std::io::BufReader; // Viewer based on https://github.com/superdump/bevy-vertex-pulling fn main() { @@ -77,7 +79,7 @@ struct Quads { fn setup(mut commands: Commands) { let laz = std::env::args().nth(1).expect("COPC file required"); - let quads = read_laz(&laz); + let quads = read_copc(&laz); commands .spawn_bundle(PerspectiveCameraBundle { transform: Transform::from_translation(Vec3::new(30.0, 30.0, 30.0)) @@ -89,35 +91,38 @@ fn setup(mut commands: Commands) { commands.spawn_bundle((quads,)); } -fn read_laz(laz_file: &str) -> Quads { - let mut reader = Reader::from_path(laz_file).unwrap(); +fn read_copc(lazfn: &str) -> Quads { + let laz_file = BufReader::new(File::open(lazfn).unwrap()); + let mut reader = CopcReader::open(laz_file).unwrap(); let mut quads = Quads::default(); let mut bboxmin = Vec3::new(f32::MAX, f32::MAX, f32::MAX); let mut bboxmax = Vec3::new(f32::MIN, f32::MIN, f32::MIN); - reader.points().for_each(|wrapped_point| { - let point = wrapped_point.unwrap(); - // dbg!(&point); - let center = Vec3::new(point.x as f32, point.z as f32, point.y as f32); - bboxmin = bboxmin.min(center); - bboxmax = bboxmax.max(center); - let color = point - .color - .map(|col| { - Color::rgb( - col.red as f32 / 255.0, - col.green as f32 / 255.0, - col.blue as f32 / 255.0, - ) - }) - .unwrap_or(Color::WHITE); - let quad = Quad { - color, - center, - half_extents: 0.1 * Vec3::ONE, - }; - quads.data.push(quad); - }); + reader + .points(LodSelection::Level(0), None) + .unwrap() + .for_each(|point| { + // dbg!(&point); + let center = Vec3::new(point.x as f32, point.z as f32, point.y as f32); + bboxmin = bboxmin.min(center); + bboxmax = bboxmax.max(center); + let color = point + .color + .map(|col| { + Color::rgb( + col.red as f32 / 255.0, + col.green as f32 / 255.0, + col.blue as f32 / 255.0, + ) + }) + .unwrap_or(Color::WHITE); + let quad = Quad { + color, + center, + half_extents: 0.1 * Vec3::ONE, + }; + quads.data.push(quad); + }); quads.bbox = Aabb::from_min_max(bboxmin, bboxmax); quads