KhronosGroup / glTF

glTF – Runtime 3D Asset Delivery
Other
7.19k stars 1.14k forks source link

Question: incorrect camera positions. #2202

Open prajwalshelar opened 2 years ago

prajwalshelar commented 2 years ago

Hello, I am exporting camera views in glTF from my application. But I don't get the expected views in the viewer (https://gltf-viewer.donmccurdy.com/). I have added added a single orthographic camera in it (set xmag, ymag, zfar and znear as obtained from camera in my application). For the camera 'positioning', I have added the 'translation' property in the node which references the camera. These are actually the coordinates of the 'eye' of the camera obtained from my application. Is this the correct way? or Am I missing something here? I get these type of views for almost any values for orthographic camera I export. Attached gltf file, expected and result views. Thanks, Prajwal ChairCamView.zip

donmccurdy commented 2 years ago

It appears that you've set a translation on the camera, but no rotation. The 'expected' image in your folder (below) certainly has some non-default rotation, the default camera rotation will otherwise look down the -Z axis.

Chair_expected_view

If your application is some third-party software you may need to report a bug or share details about it to get help. If it is your own custom software, be sure to set the rotation of the node in addition to its translation.

prajwalshelar commented 2 years ago

Hi, Thanks for the reply! I tried writing the orientation matrix for the camera node instead of using translation and rotation. In the attached file, I have also referenced the camera node in the animation. Now in the viewer (https://gltf-viewer.donmccurdy.com/) when I change the camera to my camera (Cam1) while animation is playing it shows correct view. But when I stop playing the animation the view is distorted. Can you please clarify on this? Thanks. ChairMat4.zip

donmccurdy commented 2 years ago

If you run this model through the validator (or open the errors shown in the bottom left of the viewer) you'll see errors:

Screen Shot 2022-09-15 at 2 01 21 PM