Jump to content

How to use gltf built-in camera?


cx20
 Share

Recommended Posts

Hello!

I am trying glTF Loader now.

VC.gltf (Virtual City) sample contains 15 cameras.

I understood how to switch cameras using Three.js + glTF Loader.

However, I do not know how to switch it with Babylon.js + glTF Loader.

Three.js + glTF Loader + VC.gltf (working) -> http://jsdo.it/cx20/ErGZ

Babylon.js + glTF Loader + VC.gltf (not work) -> http://jsdo.it/cx20/eyjr

Can anyone tell me how to switch embedded cameras with Babylon.js + glTF Loader?

Thanks.

Link to comment
Share on other sites

Hi @cx20,

The glTF  loader loades two types of cameras (perspective and orthographic) from the file and adds them as a free camera to the scene with the name defined in the glTF file.

To switch between camera, babylon itself offers a few ways:

1) setting the scene.activeCamera manually 

2) using the scene.setActiveCameraByID or setActiveCameraByName functions

3) Disposing the unneeded camera (that was probably initially created). Or better yet - don't create any camera before loading the file, babylon should be setting the first camera added to the the active camera.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...