feat: implement audio! thats all nodes!
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -155,7 +155,10 @@ fn build_line_mesh(
|
||||
match lines.entity.get() {
|
||||
Some(e) => cmds.entity(**e),
|
||||
None => {
|
||||
let e = cmds.spawn(SpatialNode(Arc::downgrade(&lines.spatial)));
|
||||
let e = cmds.spawn((
|
||||
Name::new("LinesNode"),
|
||||
SpatialNode(Arc::downgrade(&lines.spatial)),
|
||||
));
|
||||
_ = lines.entity.set(e.id().into());
|
||||
e
|
||||
}
|
||||
@@ -223,7 +226,6 @@ impl Lines {
|
||||
.unwrap_or_default()
|
||||
});
|
||||
|
||||
info!("line::add_to");
|
||||
let lines = LINES_REGISTRY.add(Lines {
|
||||
spatial: node.get_aspect::<Spatial>()?.clone(),
|
||||
data: Mutex::new(lines),
|
||||
@@ -238,7 +240,6 @@ impl Lines {
|
||||
}
|
||||
impl LinesAspect for Lines {
|
||||
fn set_lines(node: Arc<Node>, _calling_client: Arc<Client>, lines: Vec<Line>) -> Result<()> {
|
||||
info!("set_lines");
|
||||
let lines_aspect = node.get_aspect::<Lines>()?;
|
||||
*lines_aspect.data.lock() = lines;
|
||||
lines_aspect.gen_mesh.store(true, Ordering::Relaxed);
|
||||
|
||||
@@ -68,6 +68,7 @@ fn load_models(
|
||||
let handle = asset_server.load(GltfAssetLabel::Scene(0).from_asset(path));
|
||||
let entity = cmds
|
||||
.spawn((
|
||||
Name::new("ModelNode"),
|
||||
SceneRoot(handle),
|
||||
ModelNode(Arc::downgrade(&model)),
|
||||
SpatialNode(Arc::downgrade(&model.spatial)),
|
||||
@@ -394,7 +395,6 @@ impl MaterialParameter {
|
||||
else {
|
||||
return;
|
||||
};
|
||||
info!(texture_param = parameter_name, path = ?texture_path);
|
||||
let handle = asset_server.load(texture_path);
|
||||
match parameter_name {
|
||||
"diffuse" => mat.diffuse_texture = Some(handle),
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
use crate::{
|
||||
core::{
|
||||
bevy_channel::{BevyChannel, BevyChannelReader}, client::Client, color::ColorConvert, entity_handle::EntityHandle, error::Result, registry::Registry, resource::get_resource_file
|
||||
bevy_channel::{BevyChannel, BevyChannelReader},
|
||||
client::Client,
|
||||
color::ColorConvert,
|
||||
entity_handle::EntityHandle,
|
||||
error::Result,
|
||||
registry::Registry,
|
||||
resource::get_resource_file,
|
||||
},
|
||||
nodes::{
|
||||
drawable::XAlign, spatial::{Spatial, SpatialNode}, Node
|
||||
Node,
|
||||
drawable::XAlign,
|
||||
spatial::{Spatial, SpatialNode},
|
||||
},
|
||||
};
|
||||
use bevy::{platform::collections::HashMap, prelude::*};
|
||||
@@ -95,9 +103,8 @@ fn spawn_text(
|
||||
);
|
||||
let max_width = style.bounds.as_ref().map(|v| v.bounds.x);
|
||||
let max_height = style.bounds.as_ref().map(|v| v.bounds.x);
|
||||
let (width, height) =
|
||||
let (width, _height) =
|
||||
text_glyphs.measure(max_width, max_height, &mut font_settings.font_system);
|
||||
info!(width, height, ?style.text_align_x);
|
||||
let meshes = generate_meshes(
|
||||
bevy_mesh_text_3d::InputText::Simple {
|
||||
text: text_string,
|
||||
@@ -134,9 +141,9 @@ fn spawn_text(
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let dist = meshes.iter().fold(f32::MAX, |dist, v| {
|
||||
dist.min(v.transform.translation.x)
|
||||
});
|
||||
let dist = meshes
|
||||
.iter()
|
||||
.fold(f32::MAX, |dist, v| dist.min(v.transform.translation.x));
|
||||
// TODO: text align
|
||||
let letters = meshes
|
||||
.into_iter()
|
||||
@@ -162,7 +169,10 @@ fn spawn_text(
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let entity = cmds
|
||||
.spawn((SpatialNode(Arc::downgrade(&text.spatial)),))
|
||||
.spawn((
|
||||
Name::new("TextNode"),
|
||||
SpatialNode(Arc::downgrade(&text.spatial)),
|
||||
))
|
||||
.add_children(&letters)
|
||||
.id();
|
||||
text.entity.lock().replace(EntityHandle(entity));
|
||||
|
||||
Reference in New Issue
Block a user