feat: unset sky
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -2620,7 +2620,7 @@ checksum = "2f2b15926089e5526bb2dd738a2eb0e59034356e06eb71e1cd912358c0e62c4d"
|
||||
[[package]]
|
||||
name = "stardust-xr"
|
||||
version = "0.45.0"
|
||||
source = "git+https://github.com/StardustXR/core.git?branch=dev#752e34817e045997c7bdca53cda6bb8a0055e902"
|
||||
source = "git+https://github.com/StardustXR/core.git?branch=dev#8640276cc5b445fc486694f63f884323fc818860"
|
||||
dependencies = [
|
||||
"cluFlock",
|
||||
"color-eyre",
|
||||
@@ -2641,7 +2641,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "stardust-xr-schemas"
|
||||
version = "1.5.3"
|
||||
source = "git+https://github.com/StardustXR/core.git?branch=dev#752e34817e045997c7bdca53cda6bb8a0055e902"
|
||||
source = "git+https://github.com/StardustXR/core.git?branch=dev#8640276cc5b445fc486694f63f884323fc818860"
|
||||
dependencies = [
|
||||
"flatbuffers",
|
||||
"flexbuffers",
|
||||
|
||||
21
src/main.rs
21
src/main.rs
@@ -29,7 +29,7 @@ use stereokit_rust::sk::{
|
||||
use stereokit_rust::system::{Handed, Input, LogLevel, Renderer};
|
||||
use stereokit_rust::tex::{SHCubemap, Tex, TexFormat, TexType};
|
||||
use stereokit_rust::ui::Ui;
|
||||
use stereokit_rust::util::{Color128, Time};
|
||||
use stereokit_rust::util::{Color128, SphericalHarmonics, Time};
|
||||
use tokio::net::UnixListener;
|
||||
use tokio::sync::Notify;
|
||||
use tracing::metadata::LevelFilter;
|
||||
@@ -202,6 +202,9 @@ async fn main() {
|
||||
info!("Cleanly shut down Stardust");
|
||||
}
|
||||
|
||||
static DEFAULT_SKYTEX: OnceLock<Tex> = OnceLock::new();
|
||||
static DEFAULT_SKYLIGHT: OnceLock<SphericalHarmonics> = OnceLock::new();
|
||||
|
||||
fn stereokit_loop(
|
||||
sk_ready_notifier: Arc<Notify>,
|
||||
project_dirs: Option<ProjectDirs>,
|
||||
@@ -249,6 +252,14 @@ fn stereokit_loop(
|
||||
|
||||
// Skytex/light stuff
|
||||
{
|
||||
let _ = DEFAULT_SKYTEX.set(Tex::gen_color(
|
||||
Color128::BLACK,
|
||||
1,
|
||||
1,
|
||||
TexType::Cubemap,
|
||||
TexFormat::RGBA32,
|
||||
));
|
||||
let _ = DEFAULT_SKYLIGHT.set(Renderer::get_skylight());
|
||||
if let Some(sky) = project_dirs
|
||||
.as_ref()
|
||||
.map(|dirs| dirs.config_dir().join("skytex.hdr"))
|
||||
@@ -257,13 +268,7 @@ fn stereokit_loop(
|
||||
{
|
||||
sky.render_as_sky();
|
||||
} else {
|
||||
Renderer::skytex(Tex::gen_color(
|
||||
Color128::BLACK,
|
||||
1,
|
||||
1,
|
||||
TexType::Cubemap,
|
||||
TexFormat::RGBA32,
|
||||
));
|
||||
Renderer::skytex(DEFAULT_SKYTEX.get().unwrap());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,11 @@ use super::{
|
||||
Aspect, AspectIdentifier, Node,
|
||||
spatial::{Spatial, Transform},
|
||||
};
|
||||
use crate::core::{client::Client, error::Result, resource::get_resource_file};
|
||||
use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO;
|
||||
use crate::{DEFAULT_SKYLIGHT, nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO};
|
||||
use crate::{
|
||||
DEFAULT_SKYTEX,
|
||||
core::{client::Client, error::Result, resource::get_resource_file},
|
||||
};
|
||||
use color_eyre::eyre::eyre;
|
||||
use model::ModelPart;
|
||||
use parking_lot::Mutex;
|
||||
@@ -22,21 +25,32 @@ pub fn draw(token: &MainThreadToken) {
|
||||
lines::draw_all(token);
|
||||
model::draw_all(token);
|
||||
text::draw_all(token);
|
||||
|
||||
if let Some(skytex) = QUEUED_SKYTEX.lock().take() {
|
||||
if let Ok(skytex) = SHCubemap::from_cubemap(skytex, true, 100) {
|
||||
Renderer::skytex(skytex.tex);
|
||||
match QUEUED_SKYTEX.lock().take() {
|
||||
Some(Some(skytex)) => {
|
||||
if let Ok(skytex) = SHCubemap::from_cubemap(skytex, true, 100) {
|
||||
Renderer::skytex(skytex.tex);
|
||||
}
|
||||
}
|
||||
Some(None) => {
|
||||
Renderer::skytex(DEFAULT_SKYTEX.get().unwrap());
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
if let Some(skylight) = QUEUED_SKYLIGHT.lock().take() {
|
||||
if let Ok(skylight) = SHCubemap::from_cubemap(skylight, true, 100) {
|
||||
Renderer::skylight(skylight.sh);
|
||||
match QUEUED_SKYLIGHT.lock().take() {
|
||||
Some(Some(skylight)) => {
|
||||
if let Ok(skylight) = SHCubemap::from_cubemap(skylight, true, 100) {
|
||||
Renderer::skylight(skylight.sh);
|
||||
}
|
||||
}
|
||||
Some(None) => {
|
||||
Renderer::skylight(*DEFAULT_SKYLIGHT.get().unwrap());
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
||||
static QUEUED_SKYLIGHT: Mutex<Option<PathBuf>> = Mutex::new(None);
|
||||
static QUEUED_SKYTEX: Mutex<Option<PathBuf>> = Mutex::new(None);
|
||||
static QUEUED_SKYLIGHT: Mutex<Option<Option<PathBuf>>> = Mutex::new(None);
|
||||
static QUEUED_SKYTEX: Mutex<Option<Option<PathBuf>>> = Mutex::new(None);
|
||||
|
||||
stardust_xr_server_codegen::codegen_drawable_protocol!();
|
||||
|
||||
@@ -66,9 +80,17 @@ impl Aspect for Text {
|
||||
}
|
||||
|
||||
impl InterfaceAspect for Interface {
|
||||
fn set_sky_tex(_node: Arc<Node>, calling_client: Arc<Client>, tex: ResourceID) -> Result<()> {
|
||||
let resource_path = get_resource_file(&tex, &calling_client, &[OsStr::new("hdr")])
|
||||
.ok_or(eyre!("Could not find resource"))?;
|
||||
fn set_sky_tex(
|
||||
_node: Arc<Node>,
|
||||
calling_client: Arc<Client>,
|
||||
tex: Option<ResourceID>,
|
||||
) -> Result<()> {
|
||||
let resource_path = tex
|
||||
.map(|tex| {
|
||||
get_resource_file(&tex, &calling_client, &[OsStr::new("hdr")])
|
||||
.ok_or(eyre!("Could not find resource"))
|
||||
})
|
||||
.transpose()?;
|
||||
QUEUED_SKYTEX.lock().replace(resource_path);
|
||||
Ok(())
|
||||
}
|
||||
@@ -76,10 +98,14 @@ impl InterfaceAspect for Interface {
|
||||
fn set_sky_light(
|
||||
_node: Arc<Node>,
|
||||
calling_client: Arc<Client>,
|
||||
light: ResourceID,
|
||||
light: Option<ResourceID>,
|
||||
) -> Result<()> {
|
||||
let resource_path = get_resource_file(&light, &calling_client, &[OsStr::new("hdr")])
|
||||
.ok_or(eyre!("Could not find resource"))?;
|
||||
let resource_path = light
|
||||
.map(|light| {
|
||||
get_resource_file(&light, &calling_client, &[OsStr::new("hdr")])
|
||||
.ok_or(eyre!("Could not find resource"))
|
||||
})
|
||||
.transpose()?;
|
||||
QUEUED_SKYLIGHT.lock().replace(resource_path);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user