Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/facett

facett-model3d/examples/skull_demo.rs

//! `cargo run -p facett-model3d --example skull_demo`
//!
//! A spinning skull whose eyes fade green→yellow→red as you drag the **status**
//! slider. Drag the model to rotate it by hand (pauses the auto-spin).
//!
//! Pure egui on the **glow** backend (no wgpu / no custom shader).

use eframe::egui;
use facett_core::Facet;
use facett_model3d::Model3D;

struct App {
    skull: Model3D,
    status: f32,
}

impl Default for App {
    fn default() -> Self {
        Self { status: 0.7, skull: Model3D::skull("skull3d").with_status(0.7) }
    }
}

impl eframe::App for App {
    fn ui(&mut self, root: &mut egui::Ui, _frame: &mut eframe::Frame) {
        egui::Panel::top("ctl").show(root, |ui| {
            ui.horizontal(|ui| {
                ui.label("status (1 = healthy/green, 0 = critical/red):");
                if ui.add(egui::Slider::new(&mut self.status, 0.0..=1.0)).changed() {
                    self.skull.set_status(self.status);
                }
            });
        });
        egui::CentralPanel::default().show(root, |ui| {
            self.skull.ui(ui);
        });
    }
}

fn main() -> eframe::Result {
    let options = eframe::NativeOptions {
        viewport: egui::ViewportBuilder::default().with_inner_size(egui::Vec2::new(720.0, 640.0)),
        ..Default::default()
    };
    eframe::run_native("facett · skull_demo", options, Box::new(|_cc| Ok(Box::<App>::default())))
}