Change scaling mode to FixedHorizontal (#4055)
# Objective - Fixes the issue with orthographic camera imported from glTF not displaying anything (mentioned in #4005). ## Solution - This was due to wrong scaling mode being used. This PR simply changes WindowSize scaling mode to FixedHorizontal. ## Important Note Currently, othographic scale in Blender, three.js, and possibly other software does not translate to Bevy (via glTF) because their developers have [misinterpreted the spec](https://github.com/KhronosGroup/glTF/issues/1663#issuecomment-618194015). The camera parameters have been clarified in glTF 2.0, which was released on October of 2021. In Blender 3.0.1 this issue has **not** been fixed yet. If you are importing orthographic cameras from Blender, you have to divide the scale by 2.
This commit is contained in:
parent
f23ae104bd
commit
3756181e23
@ -15,7 +15,8 @@ use bevy_pbr::{
|
|||||||
};
|
};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
camera::{
|
camera::{
|
||||||
Camera, Camera2d, Camera3d, CameraProjection, OrthographicProjection, PerspectiveProjection,
|
Camera, Camera3d, CameraProjection, OrthographicProjection, PerspectiveProjection,
|
||||||
|
ScalingMode,
|
||||||
},
|
},
|
||||||
color::Color,
|
color::Color,
|
||||||
mesh::{
|
mesh::{
|
||||||
@ -721,22 +722,22 @@ fn load_node(
|
|||||||
match camera.projection() {
|
match camera.projection() {
|
||||||
gltf::camera::Projection::Orthographic(orthographic) => {
|
gltf::camera::Projection::Orthographic(orthographic) => {
|
||||||
let xmag = orthographic.xmag();
|
let xmag = orthographic.xmag();
|
||||||
let ymag = orthographic.ymag();
|
|
||||||
let orthographic_projection: OrthographicProjection = OrthographicProjection {
|
let orthographic_projection: OrthographicProjection = OrthographicProjection {
|
||||||
left: -xmag,
|
|
||||||
right: xmag,
|
|
||||||
top: ymag,
|
|
||||||
bottom: -ymag,
|
|
||||||
far: orthographic.zfar(),
|
far: orthographic.zfar(),
|
||||||
near: orthographic.znear(),
|
near: orthographic.znear(),
|
||||||
|
scaling_mode: ScalingMode::FixedHorizontal,
|
||||||
|
scale: xmag / 2.0,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
node.insert(Camera {
|
node.insert(Camera {
|
||||||
projection_matrix: orthographic_projection.get_projection_matrix(),
|
projection_matrix: orthographic_projection.get_projection_matrix(),
|
||||||
|
near: orthographic_projection.near,
|
||||||
|
far: orthographic_projection.far,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
node.insert(orthographic_projection).insert(Camera2d);
|
node.insert(orthographic_projection);
|
||||||
|
node.insert(Camera3d);
|
||||||
}
|
}
|
||||||
gltf::camera::Projection::Perspective(perspective) => {
|
gltf::camera::Projection::Perspective(perspective) => {
|
||||||
let mut perspective_projection: PerspectiveProjection = PerspectiveProjection {
|
let mut perspective_projection: PerspectiveProjection = PerspectiveProjection {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user