mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
Change the glTF loader to use Camera3dBundle
(#7890)
# Objective - Fixes #7889. ## Solution - Change the glTF loader to insert a `Camera3dBundle` instead of a manually constructed bundle. This might prevent future issues when new components are required for a 3D Camera to work correctly. - Register the `ColorGrading` type because `bevy_scene` was complaining about it.
This commit is contained in:
parent
2a7000a738
commit
30b29deaa9
2 changed files with 11 additions and 18 deletions
|
@ -3,7 +3,7 @@ use bevy_asset::{
|
|||
AssetIoError, AssetLoader, AssetPath, BoxedFuture, Handle, LoadContext, LoadedAsset,
|
||||
};
|
||||
use bevy_core::Name;
|
||||
use bevy_core_pipeline::prelude::Camera3d;
|
||||
use bevy_core_pipeline::prelude::Camera3dBundle;
|
||||
use bevy_ecs::{entity::Entity, prelude::FromWorld, world::World};
|
||||
use bevy_hierarchy::{BuildWorldChildren, WorldChildBuilder};
|
||||
use bevy_log::warn;
|
||||
|
@ -13,21 +13,17 @@ use bevy_pbr::{
|
|||
SpotLight, SpotLightBundle, StandardMaterial,
|
||||
};
|
||||
use bevy_render::{
|
||||
camera::{
|
||||
Camera, CameraRenderGraph, OrthographicProjection, PerspectiveProjection, Projection,
|
||||
ScalingMode,
|
||||
},
|
||||
camera::{Camera, OrthographicProjection, PerspectiveProjection, Projection, ScalingMode},
|
||||
color::Color,
|
||||
mesh::{
|
||||
skinning::{SkinnedMesh, SkinnedMeshInverseBindposes},
|
||||
Indices, Mesh, VertexAttributeValues,
|
||||
},
|
||||
prelude::SpatialBundle,
|
||||
primitives::{Aabb, Frustum},
|
||||
primitives::Aabb,
|
||||
render_resource::{AddressMode, Face, FilterMode, PrimitiveTopology, SamplerDescriptor},
|
||||
renderer::RenderDevice,
|
||||
texture::{CompressedImageFormats, Image, ImageSampler, ImageType, TextureError},
|
||||
view::VisibleEntities,
|
||||
};
|
||||
use bevy_scene::Scene;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
|
@ -714,9 +710,8 @@ fn load_node(
|
|||
) -> Result<(), GltfError> {
|
||||
let transform = gltf_node.transform();
|
||||
let mut gltf_error = None;
|
||||
let mut node = world_builder.spawn(SpatialBundle::from(Transform::from_matrix(
|
||||
Mat4::from_cols_array_2d(&transform.matrix()),
|
||||
)));
|
||||
let transform = Transform::from_matrix(Mat4::from_cols_array_2d(&transform.matrix()));
|
||||
let mut node = world_builder.spawn(SpatialBundle::from(transform));
|
||||
|
||||
node.insert(node_name(gltf_node));
|
||||
|
||||
|
@ -756,18 +751,15 @@ fn load_node(
|
|||
Projection::Perspective(perspective_projection)
|
||||
}
|
||||
};
|
||||
|
||||
node.insert((
|
||||
node.insert(Camera3dBundle {
|
||||
projection,
|
||||
Camera {
|
||||
transform,
|
||||
camera: Camera {
|
||||
is_active: !*active_camera_found,
|
||||
..Default::default()
|
||||
},
|
||||
VisibleEntities::default(),
|
||||
Frustum::default(),
|
||||
Camera3d::default(),
|
||||
CameraRenderGraph::new(bevy_core_pipeline::core_3d::graph::NAME),
|
||||
));
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
*active_camera_found = true;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ impl Plugin for ViewPlugin {
|
|||
.register_type::<RenderLayers>()
|
||||
.register_type::<Visibility>()
|
||||
.register_type::<VisibleEntities>()
|
||||
.register_type::<ColorGrading>()
|
||||
.init_resource::<Msaa>()
|
||||
// NOTE: windows.is_changed() handles cases where a window was resized
|
||||
.add_plugin(ExtractResourcePlugin::<Msaa>::default())
|
||||
|
|
Loading…
Reference in a new issue