feat: implement SkyTex and SkyLight

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2025-08-26 15:11:54 +02:00
parent 51de346f6b
commit 1c6b42e69a
6 changed files with 68 additions and 36 deletions

View File

@@ -9,6 +9,7 @@ pub mod tracking_offset;
#[cfg(feature = "wayland")]
mod wayland;
use crate::nodes::drawable::sky::SkyPlugin;
use crate::nodes::input;
use bevy::MinimalPlugins;
@@ -379,6 +380,7 @@ fn bevy_loop(
);
app.add_plugins(bevy_sk::hand::HandPlugin);
app.add_plugins(bevy_equirect::EquirectangularPlugin);
// app.add_plugins(HandGizmosPlugin);
app.world_mut().resource_mut::<AmbientLight>().brightness = 1000.0;
if let Some(priority) = args.overlay_priority {
@@ -415,6 +417,8 @@ fn bevy_loop(
TextNodePlugin,
LinesNodePlugin,
AudioNodePlugin,
// not really a node ig? at least for now
SkyPlugin,
));
// object plugins
app.add_plugins((PlaySpacePlugin, HandPlugin, ControllerPlugin, HmdPlugin));

View File

@@ -78,11 +78,11 @@ fn build_line_mesh(
let mut peekable = line.points.iter().peekable();
while let Some(curr) = peekable.next() {
// Skip this point if it has the same position as the previous point
if let Some(prev) = last {
if Vec3::from(prev.point) == Vec3::from(curr.point) {
last = Some(curr);
continue;
}
if let Some(prev) = last
&& Vec3::from(prev.point) == Vec3::from(curr.point)
{
last = Some(curr);
continue;
}
let mut end = false;
@@ -127,6 +127,9 @@ fn build_line_mesh(
(Some(last), None) => last,
(Some(last), Some(next)) => last.lerp(next, 0.5),
};
if !quat.is_finite() {
panic!("non finite quat: next: {next:?}, last: {last:?}, curr: {curr:?},");
}
let normals = [
Vec3::X,
Vec3::new(1., 0., 1.).normalize(),

View File

@@ -1,5 +1,6 @@
pub mod lines;
pub mod model;
pub mod sky;
pub mod text;
use self::{lines::Lines, model::Model, text::Text};
@@ -13,6 +14,7 @@ use color_eyre::eyre::eyre;
use model::ModelPart;
use parking_lot::Mutex;
use stardust_xr::values::ResourceID;
use tracing::info;
use std::{ffi::OsStr, path::PathBuf, sync::Arc};
static QUEUED_SKYLIGHT: Mutex<Option<Option<PathBuf>>> = Mutex::new(None);
@@ -51,6 +53,7 @@ impl InterfaceAspect for Interface {
calling_client: Arc<Client>,
tex: Option<ResourceID>,
) -> Result<()> {
info!("setting sky tex");
let resource_path = tex
.map(|tex| {
get_resource_file(&tex, &calling_client, &[OsStr::new("hdr")])
@@ -66,6 +69,7 @@ impl InterfaceAspect for Interface {
calling_client: Arc<Client>,
light: Option<ResourceID>,
) -> Result<()> {
info!("setting sky light");
let resource_path = light
.map(|light| {
get_resource_file(&light, &calling_client, &[OsStr::new("hdr")])