@@ -30,31 +30,30 @@ fn main() {
30
30
}
31
31
32
32
fn setup ( mut commands : Commands , mut meshes : ResMut < Assets < Mesh > > ) {
33
- commands. spawn ( ) . insert_bundle ( (
34
- meshes. add ( Mesh :: from ( shape:: Cube { size : 0.5 } ) ) ,
35
- Transform :: from_xyz ( 0.0 , 0.0 , 0.0 ) ,
36
- GlobalTransform :: default ( ) ,
37
- InstanceMaterialData (
38
- ( 1 ..=10 )
39
- . flat_map ( |x| ( 1 ..=10 ) . map ( move |y| ( x as f32 / 10.0 , y as f32 / 10.0 ) ) )
40
- . map ( |( x, y) | InstanceData {
41
- position : Vec3 :: new ( x * 10.0 - 5.0 , y * 10.0 - 5.0 , 0.0 ) ,
42
- scale : 1.0 ,
43
- color : Color :: hsla ( x * 360. , y, 0.5 , 1.0 ) . as_rgba_f32 ( ) ,
44
- } )
45
- . collect ( ) ,
46
- ) ,
47
- Visibility :: default ( ) ,
48
- ComputedVisibility :: default ( ) ,
49
- // NOTE: Frustum culling is done based on the Aabb of the Mesh and the GlobalTransform.
50
- // As the cube is at the origin, if its Aabb moves outside the view frustum, all the
51
- // instanced cubes will be culled.
52
- // The InstanceMaterialData contains the 'GlobalTransform' information for this custom
53
- // instancing, and that is not taken into account with the built-in frustum culling.
54
- // We must disable the built-in frustum culling by adding the `NoFrustumCulling` marker
55
- // component to avoid incorrect culling.
56
- NoFrustumCulling ,
57
- ) ) ;
33
+ commands
34
+ . spawn ( )
35
+ . insert_bundle ( SpatialBundle :: from ( Transform :: from_xyz ( 0.0 , 0.0 , 0.0 ) ) )
36
+ . insert_bundle ( (
37
+ meshes. add ( Mesh :: from ( shape:: Cube { size : 0.5 } ) ) ,
38
+ InstanceMaterialData (
39
+ ( 1 ..=10 )
40
+ . flat_map ( |x| ( 1 ..=10 ) . map ( move |y| ( x as f32 / 10.0 , y as f32 / 10.0 ) ) )
41
+ . map ( |( x, y) | InstanceData {
42
+ position : Vec3 :: new ( x * 10.0 - 5.0 , y * 10.0 - 5.0 , 0.0 ) ,
43
+ scale : 1.0 ,
44
+ color : Color :: hsla ( x * 360. , y, 0.5 , 1.0 ) . as_rgba_f32 ( ) ,
45
+ } )
46
+ . collect ( ) ,
47
+ ) ,
48
+ // NOTE: Frustum culling is done based on the Aabb of the Mesh and the GlobalTransform.
49
+ // As the cube is at the origin, if its Aabb moves outside the view frustum, all the
50
+ // instanced cubes will be culled.
51
+ // The InstanceMaterialData contains the 'GlobalTransform' information for this custom
52
+ // instancing, and that is not taken into account with the built-in frustum culling.
53
+ // We must disable the built-in frustum culling by adding the `NoFrustumCulling` marker
54
+ // component to avoid incorrect culling.
55
+ NoFrustumCulling ,
56
+ ) ) ;
58
57
59
58
// camera
60
59
commands. spawn_bundle ( Camera3dBundle {
0 commit comments