Compare commits
1 Commits
0735c429ca
...
decals
| Author | SHA1 | Date | |
|---|---|---|---|
| 0107f6a520 |
@@ -1530,3 +1530,8 @@
|
|||||||
( 832 7360 -1568 ) ( 832 7360 -1567 ) ( 832 7361 -1568 ) water [ 0 1 0 0 ] [ 0 0 -1 -32 ] 270 1 1
|
( 832 7360 -1568 ) ( 832 7360 -1567 ) ( 832 7361 -1568 ) water [ 0 1 0 0 ] [ 0 0 -1 -32 ] 270 1 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// entity 40
|
||||||
|
{
|
||||||
|
"classname" "decal"
|
||||||
|
"origin" "56 -440 -232"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use avian3d::prelude::*;
|
use avian3d::prelude::*;
|
||||||
use bevy::prelude::*;
|
use bevy::{core_pipeline::prepass::DepthPrepass, prelude::*};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
GameState,
|
GameState,
|
||||||
@@ -59,6 +59,7 @@ pub fn plugin(app: &mut App) {
|
|||||||
fn startup(mut commands: Commands) {
|
fn startup(mut commands: Commands) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3d::default(),
|
Camera3d::default(),
|
||||||
|
DepthPrepass,
|
||||||
MainCamera::new(Vec3::new(0., 2.5, -13.)),
|
MainCamera::new(Vec3::new(0., 2.5, -13.)),
|
||||||
CameraRotationInput::default(),
|
CameraRotationInput::default(),
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use avian3d::prelude::*;
|
|||||||
use bevy::{
|
use bevy::{
|
||||||
ecs::{component::HookContext, world::DeferredWorld},
|
ecs::{component::HookContext, world::DeferredWorld},
|
||||||
math::*,
|
math::*,
|
||||||
|
pbr::decal::{ForwardDecal, ForwardDecalMaterial, ForwardDecalMaterialExt},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
use bevy_trenchbroom::prelude::*;
|
use bevy_trenchbroom::prelude::*;
|
||||||
@@ -64,6 +65,52 @@ pub struct NamedEntity {
|
|||||||
#[geometry(GeometryProvider::new().convex_collider())]
|
#[geometry(GeometryProvider::new().convex_collider())]
|
||||||
pub struct Platform;
|
pub struct Platform;
|
||||||
|
|
||||||
|
#[derive(PointClass, Component, Reflect, Default)]
|
||||||
|
#[reflect(Component)]
|
||||||
|
#[require(Transform)]
|
||||||
|
#[component(on_add = Self::on_add)]
|
||||||
|
pub struct Decal;
|
||||||
|
|
||||||
|
impl Decal {
|
||||||
|
fn on_add(mut world: DeferredWorld, HookContext { entity, .. }: HookContext) {
|
||||||
|
let Some(server) = world.get_resource::<AssetServer>() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
let fence = server.load("textures/fence.png");
|
||||||
|
|
||||||
|
let Some(mut decal_standard_materials) =
|
||||||
|
world.get_resource_mut::<Assets<ForwardDecalMaterial<StandardMaterial>>>()
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
let decal = decal_standard_materials.add(ForwardDecalMaterial {
|
||||||
|
base: StandardMaterial {
|
||||||
|
base_color_texture: Some(fence),
|
||||||
|
unlit: true,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
extension: ForwardDecalMaterialExt {
|
||||||
|
depth_fade_factor: 1.,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
let mut this_transform = *world
|
||||||
|
.get_entity(entity)
|
||||||
|
.unwrap()
|
||||||
|
.get::<Transform>()
|
||||||
|
.unwrap();
|
||||||
|
this_transform.scale = Vec3::splat(100.);
|
||||||
|
|
||||||
|
world.commands().entity(entity).insert((
|
||||||
|
this_transform,
|
||||||
|
ForwardDecal,
|
||||||
|
MeshMaterial3d(decal),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(PointClass, Component, Reflect, Default)]
|
#[derive(PointClass, Component, Reflect, Default)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component)]
|
||||||
#[require(Transform)]
|
#[require(Transform)]
|
||||||
|
|||||||
@@ -79,6 +79,10 @@
|
|||||||
[
|
[
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@PointClass base(transform) = decal
|
||||||
|
[
|
||||||
|
]
|
||||||
|
|
||||||
@PointClass base(transform) model({ "path": "models/alien_naked.glb" }) = enemy_spawn
|
@PointClass base(transform) model({ "path": "models/alien_naked.glb" }) = enemy_spawn
|
||||||
[
|
[
|
||||||
head(string) : "head" : "" : ""
|
head(string) : "head" : "" : ""
|
||||||
|
|||||||
Reference in New Issue
Block a user