You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a sample which creates two circles of spheres: one in system startup, and one in a normal (?) system.
For each spawn call, I am creating a new material so you can see the order the spheres were constructed in.
The startup system successfully creates a nice range of colors for the spheres:
However once the spheres created by spawn_spheres start spawning, things go wonky and the colors change a bunch:
The colors mostly just swap around, but occasionally are duplicated.
My expectation is that spawning both in setup and spawn_spheres should behave the same.
I also was experiencing a panic with the code before I simplified (with a different component besides the material), though it seems to be triggered under the same condition, so not creating an issue for that as well.
use bevy::prelude::*;fnmain(){App::build().add_resource(R(0.0)).add_default_plugins().add_startup_system(setup.system()).add_system(spawn_spheres.system()).run();}fnsetup(mutcommands:Commands,mutmeshes:ResMut<Assets<Mesh>>,mutmaterials:ResMut<Assets<StandardMaterial>>,){
commands
.spawn(LightComponents{translation:Translation::new(4.0,8.0,4.0),
..Default::default()}).spawn(Camera3dComponents{transform:Transform::new_sync_disabled(Mat4::face_toward(Vec3::new(-3.0,5.0,8.0),Vec3::new(0.0,0.0,0.0),Vec3::new(0.0,1.0,0.0),)),
..Default::default()});letmut r = 0.0;while r < std::f32::consts::PI*2.0{let value = r / (std::f32::consts::PI*2.0);
commands.spawn(PbrComponents{mesh: meshes.add(Mesh::from(shape::Icosphere{subdivisions:4,radius:0.5,})),material: materials.add(Color::rgb(value, value, value).into()),translation:Translation::new(r.cos()*4.0,0.0, r.sin()*4.0),
..Default::default()});
r += std::f32::consts::PI / 10.0;}}structR(f32);fnspawn_spheres(mutcommands:Commands,mutmeshes:ResMut<Assets<Mesh>>,mutmaterials:ResMut<Assets<StandardMaterial>>,mutr:ResMut<R>,time:Res<Time>,){if r.0*5.0 + 5.0 < time.seconds_since_startupasf32{if r.0 < std::f32::consts::PI*2.0{let value = r.0 / (std::f32::consts::PI*2.0);
commands.spawn(PbrComponents{mesh: meshes.add(Mesh::from(shape::Icosphere{subdivisions:4,radius:0.5,})),material: materials.add(Color::rgb(value, value, value).into()),translation:Translation::new(r.0.cos()*4.0,2.0, r.0.sin()*4.0),
..Default::default()});}
r.0 += std::f32::consts::PI / 10.0;}}
The text was updated successfully, but these errors were encountered:
Moxinilian
added
C-Bug
An unexpected or incorrect behavior
A-ECS
Entities, components, systems, and events
A-Rendering
Drawing game state to the screen
and removed
A-ECS
Entities, components, systems, and events
labels
Sep 5, 2020
Thanks for reporting! I think this was fixed recently (similar to #328). With your code, I am able to recreate the issue with version 0.1.3, but with master branch 5f1fef3, it now behaves correctly.
I have a sample which creates two circles of spheres: one in system startup, and one in a normal (?) system.
For each spawn call, I am creating a new material so you can see the order the spheres were constructed in.
The startup system successfully creates a nice range of colors for the spheres:
However once the spheres created by spawn_spheres start spawning, things go wonky and the colors change a bunch:
The colors mostly just swap around, but occasionally are duplicated.
My expectation is that spawning both in setup and spawn_spheres should behave the same.
I also was experiencing a panic with the code before I simplified (with a different component besides the material), though it seems to be triggered under the same condition, so not creating an issue for that as well.
The text was updated successfully, but these errors were encountered: