mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-26 08:38:10 +00:00
material plugin for use in headless mode
This commit is contained in:
@@ -21,6 +21,7 @@ mod hierarchy;
|
|||||||
mod input;
|
mod input;
|
||||||
mod inspector;
|
mod inspector;
|
||||||
mod interaction;
|
mod interaction;
|
||||||
|
pub mod material;
|
||||||
pub mod math;
|
pub mod math;
|
||||||
mod mixamo;
|
mod mixamo;
|
||||||
mod path;
|
mod path;
|
||||||
@@ -51,6 +52,7 @@ pub use crate::{
|
|||||||
viewport::ViewportSize,
|
viewport::ViewportSize,
|
||||||
world_grid::WorldGridPlugin,
|
world_grid::WorldGridPlugin,
|
||||||
};
|
};
|
||||||
|
use crate::material::MaterialPlugin;
|
||||||
|
|
||||||
#[cfg(feature = "wasm")]
|
#[cfg(feature = "wasm")]
|
||||||
mod wasm;
|
mod wasm;
|
||||||
@@ -86,6 +88,7 @@ impl PluginGroup for CommonPlugins {
|
|||||||
.add(InspectorPlugin)
|
.add(InspectorPlugin)
|
||||||
.add(InterpolationPlugin)
|
.add(InterpolationPlugin)
|
||||||
.add(ScenePlugin)
|
.add(ScenePlugin)
|
||||||
|
.add(MaterialPlugin)
|
||||||
.add(SkyboxPlugin)
|
.add(SkyboxPlugin)
|
||||||
.add(StudioInputPlugin)
|
.add(StudioInputPlugin)
|
||||||
.add(UiLayerPlugin)
|
.add(UiLayerPlugin)
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
use bevy::app::{App, Plugin};
|
||||||
|
use space_editor::prelude::EditorRegistryExt;
|
||||||
|
use crate::material::short_material::ShortMaterial;
|
||||||
|
|
||||||
|
|
||||||
|
pub mod short_material;
|
||||||
|
|
||||||
|
pub struct MaterialPlugin;
|
||||||
|
impl Plugin for MaterialPlugin {
|
||||||
|
fn build(&self, app: &mut App) {
|
||||||
|
app.register_type::<ShortMaterial>()
|
||||||
|
.editor_registry::<ShortMaterial>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
use bevy::pbr::StandardMaterial;
|
||||||
|
use bevy::prelude::{Color, Component, Reflect};
|
||||||
|
|
||||||
|
use bevy::ecs::reflect::ReflectComponent;
|
||||||
|
use bevy::reflect::std_traits::ReflectDefault;
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Reflect, Default, Clone, Component)]
|
||||||
|
#[reflect(Default, Component)]
|
||||||
|
pub struct ShortMaterial {
|
||||||
|
pub base_color: Color,
|
||||||
|
pub perceptual_roughness: f32,
|
||||||
|
pub metallic: f32,
|
||||||
|
pub reflectance: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ShortMaterial {
|
||||||
|
pub fn new(material: &StandardMaterial) -> Self {
|
||||||
|
Self {
|
||||||
|
base_color: material.base_color,
|
||||||
|
perceptual_roughness: material.perceptual_roughness,
|
||||||
|
metallic: material.metallic,
|
||||||
|
reflectance: material.reflectance,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ use crate::{
|
|||||||
interaction::Selection,
|
interaction::Selection,
|
||||||
wasm::{self, StaticBuffer, WasmMessageBuffer},
|
wasm::{self, StaticBuffer, WasmMessageBuffer},
|
||||||
};
|
};
|
||||||
|
use crate::material::short_material::ShortMaterial;
|
||||||
|
|
||||||
pub struct InspectorPlugin;
|
pub struct InspectorPlugin;
|
||||||
|
|
||||||
@@ -591,25 +592,6 @@ fn auto_serialize_asset<T: Asset + Reflect + GetTypeRegistration>(
|
|||||||
ev_update_description.send(UpdateEntityDescription);
|
ev_update_description.send(UpdateEntityDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Reflect, Default, Clone, Component)]
|
|
||||||
#[reflect(Default, Component)]
|
|
||||||
struct ShortMaterial {
|
|
||||||
pub base_color: Color,
|
|
||||||
pub perceptual_roughness: f32,
|
|
||||||
pub metallic: f32,
|
|
||||||
pub reflectance: f32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ShortMaterial {
|
|
||||||
pub fn new(material: &StandardMaterial) -> Self {
|
|
||||||
Self {
|
|
||||||
base_color: material.base_color,
|
|
||||||
perceptual_roughness: material.perceptual_roughness,
|
|
||||||
metallic: material.metallic,
|
|
||||||
reflectance: material.reflectance,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn serialize_standart_materal(
|
fn serialize_standart_materal(
|
||||||
r_selection: Option<Res<Selection>>,
|
r_selection: Option<Res<Selection>>,
|
||||||
|
|||||||
Reference in New Issue
Block a user