# Gltf Import: Camera usage

**URL:** <https://discourse.threejs.org/t/gltf-import-camera-usage/24623>\
**Category:** Questions\
**Tags:** perspective-camera, loaders, camera\
**Created:** [March 22, 2021, 11:24am UTC](https://discourse.threejs.org/t/gltf-import-camera-usage/24623 "2021-03-22T11:24:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roland\_Schuller](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/roland_schuller/32/17224_2.png) [@Roland\_Schuller](https://discourse.threejs.org/u/Roland_Schuller)\
**Post date:** [March 22, 2021, 11:24am UTC](https://discourse.threejs.org/t/gltf-import-camera-usage/24623/1 "2021-03-22T11:24:19Z")

</div>

Hi! I Loaded a glb File from Blender with an Camera. So I wanted to use this camera in the Three.js viewer and add some OrbitControls.  
The Camera is not moving. But when I use my own Perspective Cam everything is ok. But I cant get this cam to the Position if the one in the glb.

When I use  
this.camera=gltf.cameras[0];  
in the loader.load then I see the correct Object but cant move.

When I use  
this.camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );  
this.scene.add(this.camera);

And In the Loader.load  
this.camera.position.set(gltf.cameras[0].position);  
or this.camera.copy(gltf.cameras[0]);  
I get a moving Camera which is completly wrong. Position of the gltf.cameras[0] is (0,0,0).

---

<div class="post-metadata">

**Author:** ![Roland\_Schuller](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/roland_schuller/32/17224_2.png) [@Roland\_Schuller](https://discourse.threejs.org/u/Roland_Schuller)\
**Post date:** [March 22, 2021, 12:34pm UTC](https://discourse.threejs.org/t/gltf-import-camera-usage/24623/2 "2021-03-22T12:34:12Z")

</div>

I found the Bug. And it was in Blender. Blender uses an Object and parents the camera to it. So the Camera will always have 0,0,0 because it is on the same place as the Object. Found the Solution when I was browsing the scene in the Javascript browser of chrome. The Camera had a parent and this had all needed Information.

Now with  
this.camera.position.copy(gltf.cameras[0].parent.position);  
this.camera.quaternion.copy(gltf.cameras[0].parent.quaternion);  
this.camera.scale.copy(gltf.cameras[0].parent.scale);  
Everything works. copy of the Object does not work, because the parent is no Camera

Hope someone else will need this Info in the Future!

---

<div class="post-metadata">

**Author:** ![lizehua-cn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/lizehua-cn/32/22529_2.png) [@lizehua-cn](https://discourse.threejs.org/u/lizehua-cn)\
**Post date:** [May 20, 2022, 7:03am UTC](https://discourse.threejs.org/t/gltf-import-camera-usage/24623/3 "2022-05-20T07:03:08Z")

</div>

If the camera has rotation, still need to get the product of two quaternion  
`const newQuaternion = camera.parent.quaternion.multiply(camera.quaternion)`  
and then send to camera quaternion  
`this.camera.quaternion.copy(newQuaternion);`

---

<div class="post-metadata">

**Author:** ![yvesguillo](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/yvesguillo/32/39285_2.png) [@yvesguillo](https://discourse.threejs.org/u/yvesguillo)\
**Post date:** [August 23, 2023, 7:12am UTC](https://discourse.threejs.org/t/gltf-import-camera-usage/24623/4 "2023-08-23T07:12:11Z")

</div>

A bit late, and maybe not as professional as it should, but using the “attach” function would help you to place the camera under the scene direct children in the global position and rotation, then you could use the orbit controller as usual.

[https://threejs.org/docs/#api/en/core/Object3D.attach](https://threejs.org/docs/#api/en/core/Object3D.attach)  
should look like this:

scene.attach(gltf.scene.camera);
