2
$\begingroup$

I am using the GLTF exporter to use the result with Three.js. Within the Scene I have defined two cameras and set one as the »scenes' camera« within the Scene Properties panel (see image below):

Screenshot

The result of the export contains a list of all cameras, but how can I figure out which one is the one attached to the scene?

$\endgroup$

2 Answers 2

2
$\begingroup$

glTF and three.js do not have Blender's concept of a Scene Camera, so you'll need to use another way to identify which camera you want. Object names are exported with cameras, and Custom Properties are exported as well (if you enable this in the export options). Those would both be available in three.js as camera.name and camera.userData.

Note that the camera may be parented to an empty for export, so you may need to check both camera.name and camera.parent.name for the original name.

$\endgroup$
0
$\begingroup$

If anyone is wondering how to do it with react-three/drei

// Inside a react component
const { nodes, materials, cameras, userData } = useGLTF(
  '/objects/house_gltf/house.gltf'
) as unknown as GLTFResult;

// On a sidenode, I also use gltfjsx to convert gltf models into components
// https://github.com/pmndrs/gltfjsx

And this is what do check in Blender when exporting the file

enter image description here

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .