@@ -15,6 +15,14 @@ use bevy_render::{
15
15
pub const WIREFRAME_SHADER_HANDLE : Handle < Shader > = Handle :: weak_from_u128 ( 192598014480025766 ) ;
16
16
17
17
/// A [`Plugin`] that draws wireframes.
18
+ ///
19
+ /// Wireframes currently do not work when using webgl or webgpu.
20
+ /// Supported platforms:
21
+ /// - DX12
22
+ /// - Vulkan
23
+ /// - Metal
24
+ ///
25
+ /// This is a native only feature.
18
26
#[ derive( Debug , Default ) ]
19
27
pub struct WireframePlugin ;
20
28
@@ -31,8 +39,11 @@ impl Plugin for WireframePlugin {
31
39
. register_type :: < WireframeConfig > ( )
32
40
. init_resource :: < WireframeConfig > ( )
33
41
. add_plugins ( MaterialPlugin :: < WireframeMaterial > :: default ( ) )
34
- . add_systems ( Startup , setup)
35
- . add_systems ( Update , ( apply_global, apply_material) ) ;
42
+ . add_systems ( Startup , setup_global_wireframe_material)
43
+ . add_systems (
44
+ Update ,
45
+ ( apply_global_wireframe_material, apply_wireframe_material) ,
46
+ ) ;
36
47
}
37
48
}
38
49
@@ -58,15 +69,18 @@ struct GlobalWireframeMaterial {
58
69
handle : Handle < WireframeMaterial > ,
59
70
}
60
71
61
- fn setup ( mut commands : Commands , mut materials : ResMut < Assets < WireframeMaterial > > ) {
72
+ fn setup_global_wireframe_material (
73
+ mut commands : Commands ,
74
+ mut materials : ResMut < Assets < WireframeMaterial > > ,
75
+ ) {
62
76
// Create the handle used for the global material
63
77
commands. insert_resource ( GlobalWireframeMaterial {
64
78
handle : materials. add ( WireframeMaterial { } ) ,
65
79
} ) ;
66
80
}
67
81
68
- /// Applies the wireframe material to any mesh with a [`Wireframe`] component.
69
- fn apply_material (
82
+ /// Applies or remove the wireframe material to any mesh with a [`Wireframe`] component.
83
+ fn apply_wireframe_material (
70
84
mut commands : Commands ,
71
85
mut materials : ResMut < Assets < WireframeMaterial > > ,
72
86
wireframes : Query < Entity , ( With < Wireframe > , Without < Handle < WireframeMaterial > > ) > ,
@@ -87,7 +101,7 @@ fn apply_material(
87
101
88
102
/// Applies or removes a wireframe material on any mesh without a [`Wireframe`] component.
89
103
#[ allow( clippy:: type_complexity) ]
90
- fn apply_global (
104
+ fn apply_global_wireframe_material (
91
105
mut commands : Commands ,
92
106
config : Res < WireframeConfig > ,
93
107
meshes_without_material : Query <
0 commit comments