wip: fetching atomic data
This commit is contained in:
parent
35d121ccd5
commit
208a3f8a6b
|
@ -333,6 +333,24 @@ version = "1.1.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||
|
||||
[[package]]
|
||||
name = "atomic_lib"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18b7c1e31847f76a1dd3aae20313129a360000200cd4d7e8eb41ab6dfd5eb9df"
|
||||
dependencies = [
|
||||
"base64 0.21.5",
|
||||
"rand",
|
||||
"regex",
|
||||
"ring",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tracing",
|
||||
"ureq",
|
||||
"url",
|
||||
"urlencoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
|
@ -3199,6 +3217,12 @@ dependencies = [
|
|||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "1.3.1"
|
||||
|
@ -3239,6 +3263,36 @@ version = "0.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17fd96390ed3feda12e1dfe2645ed587e0bea749e319333f104a33ff62f77a0b"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "range-alloc"
|
||||
version = "0.1.3"
|
||||
|
@ -3364,6 +3418,20 @@ dependencies = [
|
|||
"windows 0.37.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.17.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"getrandom",
|
||||
"libc",
|
||||
"spin",
|
||||
"untrusted",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rodio"
|
||||
version = "0.17.3"
|
||||
|
@ -3398,6 +3466,28 @@ version = "1.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.21.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba"
|
||||
dependencies = [
|
||||
"log",
|
||||
"ring",
|
||||
"rustls-webpki",
|
||||
"sct",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
version = "0.101.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.14"
|
||||
|
@ -3436,6 +3526,16 @@ version = "1.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "sct"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.193"
|
||||
|
@ -3543,6 +3643,12 @@ dependencies = [
|
|||
"bevy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||
|
||||
[[package]]
|
||||
name = "spirv"
|
||||
version = "0.2.0+1.5.4"
|
||||
|
@ -3939,6 +4045,28 @@ version = "0.2.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
|
||||
|
||||
[[package]]
|
||||
name = "untrusted"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
||||
|
||||
[[package]]
|
||||
name = "ureq"
|
||||
version = "2.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8cdd25c339e200129fe4de81451814e5228c9b771d57378817d6117cc2b3f97"
|
||||
dependencies = [
|
||||
"base64 0.21.5",
|
||||
"flate2",
|
||||
"log",
|
||||
"once_cell",
|
||||
"rustls",
|
||||
"rustls-webpki",
|
||||
"url",
|
||||
"webpki-roots",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.5.0"
|
||||
|
@ -3950,6 +4078,12 @@ dependencies = [
|
|||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "urlencoding"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.6.1"
|
||||
|
@ -3995,6 +4129,7 @@ name = "voxel-level-editor"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-channel 1.9.0",
|
||||
"atomic_lib",
|
||||
"bevy",
|
||||
"bevy_egui",
|
||||
"block-mesh",
|
||||
|
@ -4134,6 +4269,12 @@ dependencies = [
|
|||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "0.25.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10"
|
||||
|
||||
[[package]]
|
||||
name = "weezl"
|
||||
version = "0.1.7"
|
||||
|
|
|
@ -19,3 +19,5 @@ itertools = "0.10"
|
|||
rfd = "0.8"
|
||||
async-channel = "1.6.1"
|
||||
enum-map = "2.4" # syntax_highlighting dep, possibly redundant with strum?
|
||||
|
||||
atomic_lib = "0.36.1"
|
||||
|
|
|
@ -17,7 +17,7 @@ use smooth_bevy_cameras::controllers::orbit::{
|
|||
OrbitCameraBundle, OrbitCameraController, OrbitCameraPlugin,
|
||||
};
|
||||
use smooth_bevy_cameras::{LookTransform, LookTransformPlugin};
|
||||
use systems::{generic_command_queue::CommandQueue, layer_spawner::LayerSpawnerCommand, ui::ui_spawner::{UiSpawnerCommand, UiSpawnerState}};
|
||||
use systems::{generic_command_queue::CommandQueue, layer_spawner::LayerSpawnerCommand, ui::ui_spawner::{UiSpawnerCommand, UiSpawnerState}, atomic_data::atomic_data_voxels};
|
||||
use voxels::bool_voxel::BoolVoxel;
|
||||
use voxels::mesh::into_domain;
|
||||
mod components;
|
||||
|
@ -38,6 +38,7 @@ fn main() {
|
|||
// ..Default::default()
|
||||
// })
|
||||
.insert_resource(Msaa::Sample4)
|
||||
.insert_resource(systems::atomic_data::create_store_resource())
|
||||
.insert_resource(CommandQueue::<LayerSpawnerCommand>::default())
|
||||
.insert_resource(CommandQueue::<UiSpawnerCommand>::default())
|
||||
.insert_resource(UiSpawnerState::default())
|
||||
|
@ -76,6 +77,7 @@ fn main() {
|
|||
.add_systems(Update, systems::layer_spawner::layer_spawner)
|
||||
.add_systems(Update, systems::ui::ui_spawner::ui_spawner)
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(Startup, atomic_data_voxels)
|
||||
.run();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
use atomic_lib::{Storelike, agents::ForAgent, Store, storelike::PathReturn, Resource, Value};
|
||||
use bevy::prelude::ResMut;
|
||||
use bevy::ecs::system::Commands;
|
||||
use block_mesh::Voxel;
|
||||
use common::space::three_dimensional::{traits::{DefaultVoxel, DefaultVoxelKinds, VoxelContainer}, hash_map_container::VoxelHashMapLayer, vec3generic:Vec3Generic};
|
||||
|
||||
#[derive(bevy::prelude::Resource)]
|
||||
pub struct AtomicLib {
|
||||
pub store: Store,
|
||||
}
|
||||
|
||||
pub fn create_store_resource() -> AtomicLib
|
||||
{
|
||||
let store = atomic_lib::Store::init().unwrap();
|
||||
store.populate().unwrap();
|
||||
AtomicLib{store}
|
||||
}
|
||||
|
||||
pub fn atomic_data_voxels(
|
||||
mut atomic: ResMut<AtomicLib>,
|
||||
layer_spawner_commands: ResMut<CommandQueue<LayerSpawnerCommand>>,
|
||||
) {
|
||||
// fetch
|
||||
let result = atomic.store.get_path("https://atomic.s.vvn.space/collection/dev-world", None, &ForAgent::Public);
|
||||
match result {
|
||||
Ok(PathReturn::Atom(a)) => println!("atom: {:?}", a),
|
||||
Ok(PathReturn::Subject(s)) => {
|
||||
println!("subject: {:?}", s);
|
||||
match atomic.store.fetch_resource(&s) {
|
||||
Ok(r) => {
|
||||
println!("resource: {:?}", r);
|
||||
|
||||
match r.get_children(&atomic.store){
|
||||
Ok(children) => {
|
||||
for c in children {
|
||||
println!("child: {:?}", c);
|
||||
match atomic.resource_to_component(c) {
|
||||
Ok(resource_component) => {
|
||||
println!("successfully converted resource to component");
|
||||
// TODO: queue a command for the layer spawner that hands
|
||||
// off the resource component data, and spawns it alongside
|
||||
// an empty hashmaplayer. so that the other system in this
|
||||
// file can update it.
|
||||
},
|
||||
Err(e) => println!("couldn't convert resource to component: {:?}", e),
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(e) => println!("err fetching children: {:?}", e),
|
||||
}
|
||||
},
|
||||
Err(e) => println!("err fetching resource: {:?}", e),
|
||||
}
|
||||
|
||||
},
|
||||
Err(e) => println!("error: {:?}", e),
|
||||
}
|
||||
}
|
||||
|
||||
impl AtomicLib {
|
||||
fn resource_to_component(&self, r: Resource) -> Result<AtomicDataResource, ()>{
|
||||
match r.get_classes(&self.store) {
|
||||
Ok(classes) => {
|
||||
for c in classes {
|
||||
println!("class: {:?}", c);
|
||||
if c.subject == "https://atomic.s.vvn.space/ontology/world/class/voxel" {
|
||||
return match r.check_required_props(&self.store) {
|
||||
Ok(_) => Ok(AtomicDataResource{
|
||||
resource: r,
|
||||
current: false,
|
||||
}),
|
||||
Err(e) => {
|
||||
println!("error checking required props: {:?}", e);
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Err(());
|
||||
},
|
||||
Err(e) => {
|
||||
println!("error getting classes: {:?}", e);
|
||||
Err(())
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, bevy::prelude::Component)]
|
||||
pub struct AtomicDataResource {
|
||||
pub resource: Resource,
|
||||
pub current: bool,
|
||||
}
|
||||
|
||||
pub fn update_atomicdata_voxel_system(
|
||||
mut query: bevy::prelude::Query<(&mut AtomicDataResource, &mut VoxelHashMapLayer<bool>)>,
|
||||
){
|
||||
for (mut ad, mut layer) in query.iter_mut() {
|
||||
if !ad.current {
|
||||
match (
|
||||
ad.resource.get("https://atomic.s.vvn.space/ontology/world/property/x"),
|
||||
ad.resource.get("https://atomic.s.vvn.space/ontology/world/property/y"),
|
||||
ad.resource.get("https://atomic.s.vvn.space/ontology/world/property/z")) {
|
||||
(Ok(Value::Integer(x)), Ok(Value::Integer(y)), Ok(Value::Integer(z))) => {
|
||||
layer.voxels.clear();
|
||||
layer.voxels.insert(
|
||||
Vec3Generic {
|
||||
x: i32::try_from(*x).unwrap(),
|
||||
y: i32::try_from(*y).unwrap(),
|
||||
z: i32::try_from(*z).unwrap(),
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
},
|
||||
_ => println!("failed to get coordinates")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ use std::collections::VecDeque;
|
|||
use bevy::{prelude::*, tasks::{TaskPool, AsyncComputeTaskPool}};
|
||||
use common::space::two_dimensional::depth_tiles::Direction;
|
||||
|
||||
use super::{generic_command_queue::CommandQueue, ui::ui_spawner::{UiSpawnerCommand, build_message_box_command, build_command, EditorPopup}};
|
||||
use super::{generic_command_queue::CommandQueue, ui::ui_spawner::{UiSpawnerCommand, build_message_box_command, build_command, EditorPopup}, atomic_data::AtomicDataResource};
|
||||
|
||||
pub fn layer_spawner(
|
||||
mut spawner_commands: ResMut<CommandQueue<LayerSpawnerCommand>>,
|
||||
|
@ -124,5 +124,6 @@ pub enum LayerSpawnerCommand {
|
|||
ExportProjectedTilesToml {
|
||||
name: String,
|
||||
source_layer: Entity,
|
||||
}
|
||||
},
|
||||
FromAtomicDataResource(AtomicDataResource),
|
||||
}
|
||||
|
|
|
@ -2,3 +2,4 @@ pub mod layer_spawner;
|
|||
pub mod mutable_mesh_refresher;
|
||||
pub mod ui;
|
||||
pub mod generic_command_queue;
|
||||
pub mod atomic_data;
|
||||
|
|
Loading…
Reference in New Issue