mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-14 23:53:14 +00:00
material plugin for use in headless mode
This commit is contained in:
@@ -21,6 +21,7 @@ mod hierarchy;
|
||||
mod input;
|
||||
mod inspector;
|
||||
mod interaction;
|
||||
pub mod material;
|
||||
pub mod math;
|
||||
mod mixamo;
|
||||
mod path;
|
||||
@@ -51,6 +52,7 @@ pub use crate::{
|
||||
viewport::ViewportSize,
|
||||
world_grid::WorldGridPlugin,
|
||||
};
|
||||
use crate::material::MaterialPlugin;
|
||||
|
||||
#[cfg(feature = "wasm")]
|
||||
mod wasm;
|
||||
@@ -86,6 +88,7 @@ impl PluginGroup for CommonPlugins {
|
||||
.add(InspectorPlugin)
|
||||
.add(InterpolationPlugin)
|
||||
.add(ScenePlugin)
|
||||
.add(MaterialPlugin)
|
||||
.add(SkyboxPlugin)
|
||||
.add(StudioInputPlugin)
|
||||
.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,
|
||||
wasm::{self, StaticBuffer, WasmMessageBuffer},
|
||||
};
|
||||
use crate::material::short_material::ShortMaterial;
|
||||
|
||||
pub struct InspectorPlugin;
|
||||
|
||||
@@ -591,25 +592,6 @@ fn auto_serialize_asset<T: Asset + Reflect + GetTypeRegistration>(
|
||||
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(
|
||||
r_selection: Option<Res<Selection>>,
|
||||
|
||||
Reference in New Issue
Block a user