1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00

Update three d (#1793)

* Update three-d to 0.12

* Fix Z fighting in three-d example

Closes https://github.com/emilk/egui/issues/1744

* cargo deny: ignore three-d (only used in examples)
This commit is contained in:
Emil Ernerfeldt
2022-07-03 18:29:12 +02:00
committed by GitHub
parent 9739009f20
commit bd2cab2f0e
4 changed files with 113 additions and 19 deletions

View File

@@ -12,4 +12,4 @@ publish = false
eframe = { path = "../../eframe", features = ["glow"] }
egui_glow = { path = "../../egui_glow" }
glow = "0.11"
three-d = { git = "https://github.com/asny/three-d.git", rev = "43f210668197e8b1dc50ea9f074d2b8426ecb0f2", default-features = false } # 2022-05-22
three-d = { version = "0.12", default-features = false } # 2022-05-22

View File

@@ -84,6 +84,17 @@ fn with_three_d_context<R>(
pub static THREE_D: RefCell<Option<three_d::Context>> = RefCell::new(None);
}
// If you are using the depth buffer you need to do this:
#[allow(unsafe_code)]
unsafe {
use glow::HasContext as _;
gl.enable(glow::DEPTH_TEST);
if !cfg!(target_arch = "wasm32") {
gl.disable(glow::FRAMEBUFFER_SRGB);
}
gl.clear(glow::DEPTH_BUFFER_BIT);
}
THREE_D.with(|three_d| {
let mut three_d = three_d.borrow_mut();
let three_d =
@@ -143,7 +154,10 @@ fn paint_with_three_d(three_d: &three_d::Context, info: &egui::PaintCallbackInfo
..Default::default()
};
let mut model = Model::new(three_d, &cpu_mesh).unwrap();
let mut model = Gm::new(
Mesh::new(three_d, &cpu_mesh).unwrap(),
ColorMaterial::default(),
);
// Set the current transformation of the triangle
model.set_transformation(Mat4::from_angle_y(radians(angle)));