File tree 1 file changed +9
-4
lines changed
crates/bevy_render/src/mesh/shape 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: mesh:: { Indices , Mesh } ;
2
+ use bevy_math:: Vec3 ;
2
3
use wgpu:: PrimitiveTopology ;
3
4
4
5
/// A cone which stands on the XZ plane.
@@ -28,10 +29,10 @@ impl Default for Cone {
28
29
fn default ( ) -> Self {
29
30
Self {
30
31
top_radius : 0.0 ,
31
- bottom_radius : 1.0 ,
32
+ bottom_radius : 0.5 ,
32
33
height : 1.0 ,
33
- resolution : 16 ,
34
- segments : 1 ,
34
+ resolution : 64 ,
35
+ segments : 4 ,
35
36
}
36
37
}
37
38
}
@@ -70,7 +71,11 @@ impl From<Cone> for Mesh {
70
71
let ( sin, cos) = theta. sin_cos ( ) ;
71
72
72
73
positions. push ( [ radius * cos, y, radius * sin] ) ;
73
- normals. push ( [ cos, 0. , sin] ) ;
74
+ normals. push (
75
+ Vec3 :: new ( cos, ( c. bottom_radius - c. top_radius ) / c. height , sin)
76
+ . normalize ( )
77
+ . to_array ( ) ,
78
+ ) ;
74
79
uvs. push ( [
75
80
segment as f32 / c. resolution as f32 ,
76
81
ring as f32 / c. segments as f32 ,
You can’t perform that action at this time.
0 commit comments