# GLTF Bug: FreeCamera animation not being exported

**URL:** <https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259>\
**Category:** Bugs\
**Created:** [June 11, 2022, 3:15pm UTC](https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259 "2022-06-11T15:15:24Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrlooi](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mrlooi/32/18406_2.png) [@mrlooi](https://forum.babylonjs.com/u/mrlooi)\
**Post date:** [June 11, 2022, 3:15pm UTC](https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259/1 "2022-06-11T15:15:24Z")

</div>

The FreeCamera node animation is not being exported in GLTF

Here is a PG [https://playground.babylonjs.com/#HZBCXR#98](https://playground.babylonjs.com/#HZBCXR#98)

@Drigax @sebavan @bghgary

**Blender**  
In Blender, the green box is animated as normal, but the freecamera does not have any animation

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/3/43bad130fe68d09afff8ff134404b4c16fc5487e.png)

---

<div class="post-metadata">

**Author:** ![mrlooi](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mrlooi/32/18406_2.png) [@mrlooi](https://forum.babylonjs.com/u/mrlooi)\
**Post date:** [June 12, 2022, 3:57am UTC](https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259/2 "2022-06-12T03:57:27Z")

</div>

I noticed the reason

Why are we limiting GLTF exports to transformnodes? Why not make it available for other nodes e.g. freecamera/lights? I don’t see a reason for this

> <https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/serializers/src/glTF/2.0/glTFAnimation.ts#L254>

---

<div class="post-metadata">

**Author:** ![mrlooi](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mrlooi/32/18406_2.png) [@mrlooi](https://forum.babylonjs.com/u/mrlooi)\
**Post date:** [June 12, 2022, 3:24pm UTC](https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259/3 "2022-06-12T15:24:01Z")

</div>

I’m working around this by parenting the camera to a Tnode, and then exporting both the Tnode and camera.  
But then I found this bug [GLTF Export Bug: FreeCamera rotation has wrong offset](https://forum.babylonjs.com/t/gltf-export-bug-freecamera-rotation-has-wrong-offset/31278)

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 13, 2022, 1:06pm UTC](https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259/4 "2022-06-13T13:06:10Z")

</div>

cc @Guillaume_Pelletier and @bghgary

---

<div class="post-metadata">

**Author:** ![Guillaume\_Pelletier](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/guillaume_pelletier/32/3695_2.png) [@Guillaume\_Pelletier](https://forum.babylonjs.com/u/Guillaume_Pelletier)\
**Post date:** [June 14, 2022, 9:26am UTC](https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259/5 "2022-06-14T09:26:38Z")

</div>

Exported nodes are defined with

```auto
const nodes: Node[] = [...babylonScene.transformNodes, ...babylonScene.meshes, ...babylonScene.lights, ...babylonScene.cameras];

```

along the export process.  
While camera is part of the GLTF specification and linked to a node it might be animated, I beleive this is a bug, where we should have something like

```auto
if (babylonNode instanceof TransformNode || babylonNode instanceof Camera) {

```

It’s might be also the same for the Light with the support of the [KHR\_lights\_punctual](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_lights_punctual/README.md) extension.

@bghgary ??

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [June 14, 2022, 4:03pm UTC](https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259/6 "2022-06-14T16:03:14Z")

</div>

Camera export was added recently. We seemed to have missed the animation part. Seems like an oversight. Also seems likely lights will be in the same boat.

---

<div class="post-metadata">

**Author:** ![mrlooi](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mrlooi/32/18406_2.png) [@mrlooi](https://forum.babylonjs.com/u/mrlooi)\
**Post date:** [June 16, 2022, 8:15am UTC](https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259/7 "2022-06-16T08:15:27Z")

</div>

Yea, I think this bug [GLTF Export Bug: FreeCamera rotation has wrong offset - #9 by Guillaume\_Pelletier](https://forum.babylonjs.com/t/gltf-export-bug-freecamera-rotation-has-wrong-offset/31278/9) would have to be patched prior to this animation part, since that affects the rotations (and hence animations) regardless

---

<div class="post-metadata">

**Author:** ![Guillaume\_Pelletier](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/guillaume_pelletier/32/3695_2.png) [@Guillaume\_Pelletier](https://forum.babylonjs.com/u/Guillaume_Pelletier)\
**Post date:** [June 28, 2022, 8:30am UTC](https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259/8 "2022-06-28T08:30:57Z")

</div>

This is fixed, few more tests and i will publish a PR this afternoon (my time CET).

---

<div class="post-metadata">

**Author:** ![feuerstein](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/feuerstein/32/26127_2.png) [@feuerstein](https://forum.babylonjs.com/u/feuerstein)\
**Post date:** [August 4, 2022, 5:46pm UTC](https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259/9 "2022-08-04T17:46:20Z")

</div>

hey @Guillaume_Pelletier !  
thanks a lot for the fix! any idea where we can use it ?  
i.e. which beta version… because I was on the playground and the bug still occurs (with the following error codes when importing the file to blender)

 ![Screen Shot 2022-08-04 at 7.56.39 PM](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/5/5/557b275aa88f4fa063ee1b3254f5ae217f86edec.png)

---

<div class="post-metadata">

**Author:** ![Guillaume\_Pelletier](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/guillaume_pelletier/32/3695_2.png) [@Guillaume\_Pelletier](https://forum.babylonjs.com/u/Guillaume_Pelletier)\
**Post date:** [August 4, 2022, 8:12pm UTC](https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259/10 "2022-08-04T20:12:42Z")

</div>

This was included into [this PR](https://github.com/BabylonJS/Babylon.js/pull/12686)

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [August 4, 2022, 8:29pm UTC](https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259/11 "2022-08-04T20:29:04Z")

</div>

If you are using the playground, it should be on the latest already, which probably means this is a different problem. Do you have a repro?

---

<div class="post-metadata">

**Author:** ![feuerstein](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/feuerstein/32/26127_2.png) [@feuerstein](https://forum.babylonjs.com/u/feuerstein)\
**Post date:** [August 5, 2022, 10:19am UTC](https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259/12 "2022-08-05T10:19:13Z")

</div>

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/6/16be16be03c7152adb3a133a607e1943bbdfcfbc.png)  
here’s a picture of the bug in blender, and here’s the playground.  
Basically used the xSlide and rotate demos, assigned the camera as target in an animation group, exported, and found nothing on blender (when I say found nothing on blender, all I do is: open blender, delete the cube, import the glb file, play the animation track, nothing happens).  
Yet, the animation seems to be working in the sandbox (a bit different though… it doesn’t match the playground).  
(FYI, I am aware of the differences in the default camera and the one packed in the gltf)

> **[Babylon.js Playground](https://playground.babylonjs.com/#AVYEFX%234)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![feuerstein](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/feuerstein/32/26127_2.png) [@feuerstein](https://forum.babylonjs.com/u/feuerstein)\
**Post date:** [August 5, 2022, 2:35pm UTC](https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259/13 "2022-08-05T14:35:49Z")

</div>

Update:

> **[Babylon.js Playground](https://playground.babylonjs.com/#2JKA91%23447)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

playing with the camera type seemed to fix one aspect of the export. Now, the resulting gltf file works fine in the sandbox (problem seems to be the coordinate system getting inverted in the freeCamera, so switched to a UniversalCamera).  
so, to fix the first part, I had to:

1. switch to a universalCamera
2. create a tranformNode as parent to the Cam
3. animate the transformNode instead

The problem remains in blender though, animation cannot be found on blender

---

<div class="post-metadata">

**Author:** ![feuerstein](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/feuerstein/32/26127_2.png) [@feuerstein](https://forum.babylonjs.com/u/feuerstein)\
**Post date:** [August 5, 2022, 3:04pm UTC](https://forum.babylonjs.com/t/gltf-bug-freecamera-animation-not-being-exported/31259/14 "2022-08-05T15:04:15Z")

</div>

final update, @MeshSlayer looked into the animation data that was causing the issue, and found the “final” bug.

when creating the rotation animation, the target property was “rotation.y” (a float), @MeshSlayer had the idea to change that to "rotation (a Vector3) and it worked like a charm.

the animation works perfectly on blender now.

here’s the final playground:

> **[Babylon.js Playground](https://playground.babylonjs.com/#2JKA91%23449)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes
