diff --git a/Cargo.toml b/Cargo.toml index 2339cf4..b9daf2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,6 @@ description = "A skybox from an image for bevyengine.org" version = "0.1.0" authors = ["Jonathan Lawn "] license = "MIT OR Apache-2.0" -publish = false readme = "README.md" edition = "2018" diff --git a/README.md b/README.md index 251ddc3..9ca607a 100644 --- a/README.md +++ b/README.md @@ -8,33 +8,33 @@ rectangle and filling most of its width and height. ## Usage -See `examples\board_flyover.rs` for an example of its usage. +The usage is documented in the module comment at the top of `src/lib.rs`. -## Build +To demonstrate this, `examples\board_flyover.rs` puts a skybox around a flat "board". Key/mouse camera movement is provided by `bevy_fly_camera`. -Build using `nightly` toolchain, e.g. +![Board Flyover example](docs/board_flyover.png) -``` -cargo +nightly run --release --example board_flyover -``` +Skybox images come from the following sources. + +* **sky1.png** - https://www.cleanpng.com/png-skybox-cube-mapping-texture-mapping-terragen-textu-1384141 +* **sky2.png** - https://www.cleanpng.com/png-skybox-texture-mapping-cube-mapping-sky-cloud-920475 (flipped) ## Image processing Many skybox are available as net images. `bevy_skybox` assumes that the image is a specific net of a cube. -The assumptions about the image are listed in `src/image.rs`. +The assumptions about the image are listed in `src/image.rs`, but the image is measured like this. -## Example +![Measuring the cube net](docs/measuring_the_net.png) -The example puts a skybox around a flat "board". Key/mouse camera movement is provided by `bevy_fly_camera`. - -![Board Flyover example](docs/board_flyover.png) +## Build -Skybox images come from the following sources. +Build using `nightly` toolchain, e.g. -* **sky1.png** - https://www.cleanpng.com/png-skybox-cube-mapping-texture-mapping-terragen-textu-1384141 -* **sky2.png** - https://www.cleanpng.com/png-skybox-texture-mapping-cube-mapping-sky-cloud-920475 (flipped) +``` +cargo +nightly run --release --example board_flyover +``` ## Futures @@ -45,3 +45,5 @@ So far, this is suitable for demos, not production. and the XZ plane may not be horizontal for all. * The `SkyboxBox` should have a different draw distance to the rest of the scene. * Multiple `SkyboxCamera` objects should be handled better, at least as an error. +* There may be a better interchange response structure from the `image` module than + `Mesh` that is more convenient for anyone using a pre-aligned skybox model. diff --git a/docs/measuring_the_net.drawio b/docs/measuring_the_net.drawio new file mode 100644 index 0000000..2c6dfe5 --- /dev/null +++ b/docs/measuring_the_net.drawio @@ -0,0 +1 @@ +7Zxbc9o4FMc/DY/NWJIv+LEkTdvpdLezmZ12Hx0swBODqRAB9tOvHMu3IwM2+LYxTB7QQZbtv345OudYMCL3y/1n5qwX3wOX+iOsufsReRhhjHSMR+Gf5h4ii2VKw5x5ruyUGp68f6k0atK69Vy6yXXkQeBzb503ToPVik55zuYwFuzy3WaBnz/r2plTxfA0dXzV+tNz+SKyjg0ttX+h3nwRnxlp8pOlE3eWhs3CcYNdxkQ+jcg9CwIevVvu76kfihfrEh33eOTT5MIYXfEyB/y9+4M8878+v/z88/e318Xrw/L3ywc5yqvjb+UNy4vlh1iB3cLj9GntTMP2TszyiEwWfOmLFhJvnc060n3m7ak41USOSBmn+6OXihIBBDk0WFLODqKLPADHIkpo8Fi2d5kpkKZFRv3Y5shJnycjp7qIN1KaCjLhfso07plMpJcyEbNnMum9lEnXeyaT0UuZFJq0jmUy/xcyJe2uZLIUmVxFJ3G7PC/NhrPghd4HfsCEZRWsRM/JzPN9YHJ8b74SzamQhwr7JBTPE2HER/nB0nPd8DSTorlgwXblhso/aA2pb6vqowL1cVPqj4ekvk56pr49JPWJbZz1PK2qH59smPLruGv51RxnQPIXRXHtyq/mTkOSvyA6bFd+Ndl4z/LDuAd1Lb+axLxj+WFBonv51eToPcuv9U3+QSddmHQt/7CyLmz0TP5BpV1K0tu184kHHob8Buqb/INKu3QLFB30ruUfVNoF5e8868Xqo7B3LD9BfZN/WFkv6pvzGVbWS/om/7CyXtI356NmvYr6eRXOPJ8tmINoruIdSaQeJRHOx5Co4MmJgQukJM1pqaawipZ05X4Md3qFSPrOZuNNT3E9wuTxURMv8YnQhR1+hZNwp5s4NvzzZkDjcWx42Mt5ilqHbOsHZZ641fD/IDLuPR6NqGlYtnMDinY6Xtg4ZBpwtOheqavsUQNTKvQItmxKS1DJHTan/GxHFZIsBAUMxDZGfYd7r/kLLuJCnuFH4IlbSSM5UMPSIVrRjcqjUrrUgQyQEFlgoEgIZaA3TJPbvoJcNftvhlxTrP51kotUcm10I/c8uSADTwoilcmFDzHgnpiGyY2vu3FyiTbOk0ss4zqfK0eMyb1Re55asOYnuwArU2sBau2WqS2xlfkKahPEDHIdYhn+5VAZz40v4n+A1IJic7LYV6YWPLFMwo+2qFXLdI1Qa9pmXdTKoa722gOkFuywThb6qtTCYj+CoUbT1JbY6F8HtfnlPAxMyWlyT8QW5mW+9RYlFCVTOkymSpN7Lr1rmtwS372oJUrQAbh297FoZ/CAfEaH+UzpxRrCA2PVpuEp8VWLehZrSI9ZmZ7cgq3X4goH6PZAdGjA6LAsuSZIjpJaQVvkNlFGFViaWhUwuppGFN/tsYJK2WlU9je2XZlpq6aoVMPHiFxTmfkQlsOzTi0Z8VaeOYmuiLxyxJmXlmcw2JhutFyeia+74bUzh5hxErDaYeqKEQOU8IyLGYH7h1sOzvVWSnioAiMZl2iZdt4l3mKocnSCUp1xaanOOBeMNU1nK6U61L9FsruwzbqzsZa+rNz860S7Q4advMbGZVwpVbm2vZ5aTPtOnc2W0aWYsM0Im364UeeZiXdznkxwLdSVZUVFIK48FuwQaY4I89gPnlSdc+vYT4KcmfN0oLhjMJttaDNcqKWqr6sZZYy61xNQQ+4mpXwL7cEGxG6pIMi+u9AXQC7KRkCtcqFWob661PFVR3GSE7mRLAOJ7zxTf+JMX+Zvu9PAjrPLQenIN1waBSu+obYqo2imP/cVdU9/NI18+g8= \ No newline at end of file diff --git a/docs/measuring_the_net.png b/docs/measuring_the_net.png new file mode 100644 index 0000000..d04bbae Binary files /dev/null and b/docs/measuring_the_net.png differ diff --git a/src/lib.rs b/src/lib.rs index 13d1116..3ccbd5f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,8 +56,8 @@ fn move_skybox( mut skybox_query: Query<(&mut Transform, &SkyboxBox)>, camera_query: Query<(&PerspectiveProjection, &Transform, &SkyboxCamera)>, ) { - if let Some((mut pbr_trans, _)) = skybox_query.iter_mut().next() { - for (cam_proj, cam_trans, _) in camera_query.iter() { + if let Some((cam_proj, cam_trans, _)) = camera_query.iter().next() { + for (mut pbr_trans, _) in skybox_query.iter_mut() { *pbr_trans = Transform { translation: cam_trans.translation, rotation: Quat::identity(), @@ -72,6 +72,9 @@ fn move_skybox( pub struct SkyboxCamera; /// The `SkyboxBox` tag attached to the skybox mesh entity. +/// +/// This can also be used to tag any other `Transform` that you want to translate with +/// the `SkyboxCamera`, e.g. a light source. pub struct SkyboxBox; /// The `SkyboxPlugin` object acts as both the plugin and the resource providing the image name.