#GLTF Faces Render Based on Distance

8 messages · Page 1 of 1 (latest)

winged stump
#

I'm having trouble getting these faces in my GLTF to render regardless of the camera distance. The farther away I go, the more faces render and the closer I get the less render...

The model is loaded using bevy_asset_loader like so:

pub struct LoadingPlugin;

impl Plugin for LoadingPlugin {
    fn build(&self, app: &mut App) {
        app.add_state::<GameState>()
            .add_loading_state(
                LoadingState::new(GameState::Loading).continue_to_state(GameState::Playing),
            )
            .add_collection_to_loading_state::<_, ModelAssets>(GameState::Loading)
            .add_collection_to_loading_state::<_, AnimationAssets>(GameState::Loading);
    }
}

#[derive(AssetCollection, Resource)]
pub struct ModelAssets {
    #[asset(path = "models/player.glb#Scene0")]
    pub player_model: Handle<Scene>,
}

And the player is spawned like so:

fn spawn_player(mut commands: Commands, models: Res<ModelAssets>) {
    commands
        .spawn(SceneBundle {
            scene: models.player_model.clone(),
            transform: Transform::from_xyz(10.0, 0.04, 10.0)
                .with_rotation(Quat::from_rotation_y(std::f32::consts::PI * 1.5)),
            ..Default::default()
        })
        .insert(Name::new("Player"))
        .insert(Player {});
}
dark schooner
#

Hmm do you maybe have a blend or glb file you can share?

#

And maybe the code where you spawn the camera

winged stump
#
fn spawn_camera(mut commands: Commands) {
    commands
        .spawn(Camera3dBundle::default())
        .insert(OrbitCameraBundle::new(
            OrbitCameraController::default(),
            Vec3::new(-2.0, 10.0, 5.0),
            Vec3::new(10.0, 1.0, 10.0),
            Vec3::Y,
        ))
        .insert(RaycastPickTarget::default())
        .insert(Name::new("Camera"))
        .insert(Camera);
}
winged stump
# dark schooner And maybe the code where you spawn the camera

The OrbitCameraController comes from smooth_bevy_cameras:

use smooth_bevy_cameras::{
    controllers::orbit::{
        ControlEvent, OrbitCameraBundle, OrbitCameraController, OrbitCameraPlugin,
    },
    LookTransform, LookTransformPlugin,
};

I've used code very similar to this in the past without issue so I can't really see why it would be going wrong

dark schooner
#

There seems to be something cursed with the 3d model but I'm not sure how to troubleshoot it. It does feel like Bevy should be able to handle it so maybe open up an issue if no one else shows up here

#

You're adding Camera twice btw, once directly and once through Camera3dBundle. Not that it matters in this case, but good to be aware