# Rotation property animation for a GLB Model doesn't work

**URL:** <https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725>\
**Category:** Questions\
**Created:** [July 25, 2019, 3:21pm UTC](https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725 "2019-07-25T15:21:34Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Smak\_Dev](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/smak_dev/32/3597_2.png) [@Smak\_Dev](https://forum.babylonjs.com/u/Smak_Dev)\
**Post date:** [July 25, 2019, 3:21pm UTC](https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725/1 "2019-07-25T15:21:35Z")

</div>

The Animation works perfectly for mesh created using MeshBuilder.CreateBox. but  
the rotation animations just don’t work for the GLB mesh.

var animationTurnRight = new BABYLON.Animation(“MyAnimationMove”, “rotation.y”, frameRate,  
BABYLON.Animation.ANIMATIONTYPE\_FLOAT,  
BABYLON.Animation.ANIMATIONLOOPMODE\_CONSTANT);  
var turnRightKeys = [  
{  
frame: 0,  
value: 0  
},  
{  
frame: 4\*frameRate,  
value: 0.5  
},  
];  
scene.beginDirectAnimation(anim\_model, [animationTurnRight], 0, 5 \* frameRate, false,1);

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [July 25, 2019, 4:12pm UTC](https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725/2 "2019-07-25T16:12:35Z")

</div>

Hey!  
are you sure you are animating the right model? gltf models offer more than one mesh in the hierarchy

you can use `scene.debugLayer.show()` to see how it looks like

---

<div class="post-metadata">

**Author:** ![poetoem](https://avatars.discourse-cdn.com/v4/letter/p/3be4f8/32.png) [@poetoem](https://forum.babylonjs.com/u/poetoem)\
**Post date:** [November 17, 2021, 11:32am UTC](https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725/3 "2021-11-17T11:32:53Z")

</div>

Sorry to pick up this ages old Thread, but the problem seems to fit:

We have a custom setup, but maybe someone has any idea:  
If I change the targetProperty to “scaling.x” or “postion.x” this works flawlessly, using any rotation component will play an Animation in the Inspector, but rotation values will not change in the Inspector, nor will the model animate.  
Using scaling and position I see the values change in the Inspector and the animation.

Any ideas?

here is my function:

```javascript
createRotationAnimation(name, targetMesh, startValue, endValue){
        console.log("Creating Animation.")
        const frameRate = 30
        const rotationAnimation = new Animation(name, "rotation.y", frameRate, Animation.ANIMATIONTYPE_FLOAT, Animation.ANIMATIONLOOPMODE_CYCLE);
        const keyFrames = [];

        keyFrames.push({
            frame: 0,
            value: startValue,
        });

        keyFrames.push({
            frame: frameRate * 3,
            value: Math.PI * 2,
        });

        rotationAnimation.setKeys(keyFrames);
        const object = this.scene.getMeshByID(targetMesh);
        object.animations = []
        object.animations.push(rotationAnimation);
        this.scene.beginAnimation(object, 0, 90, true);
        console.log(endValue)

    }

```

---

<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:** [November 17, 2021, 11:39am UTC](https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725/4 "2021-11-17T11:39:47Z")

</div>

gltf models are using rotationQuaternions and not rotation by default. So you either need to animate the quaternion or you need to setup the mesh.rotationQuaternion to null before playing with the euler rotation.

---

<div class="post-metadata">

**Author:** ![poetoem](https://avatars.discourse-cdn.com/v4/letter/p/3be4f8/32.png) [@poetoem](https://forum.babylonjs.com/u/poetoem)\
**Post date:** [November 17, 2021, 11:52am UTC](https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725/5 "2021-11-17T11:52:40Z")

</div>

Wow! That was quick! I’ll look into it!  
Thanks!

---

<div class="post-metadata">

**Author:** ![arcman7](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/arcman7/32/20249_2.png) [@arcman7](https://forum.babylonjs.com/u/arcman7)\
**Post date:** [December 2, 2021, 2:53am UTC](https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725/6 "2021-12-02T02:53:32Z")

</div>

I’ve spent two days trying to figure out why my rotation animations don’t work. I finally found this thread, which then allowed to find this sentence in the [docs](https://doc.babylonjs.com/start/chap1/first_import)

> 1. Some software saves all meshes with a rotationQuaternion set and you cannot then use the _rotation_ methods unless you first add  
> myMesh.rotationQuaternion = null; //Any version of Babylon.js

That is just so random.

Guys… surely we can do better at surfacing user usage errors. May I suggest throwing an error when attempting to use Euler angle rotations while a quaternion vector is set on the mesh/model?

Or… even better, just provide methods on all rotatable objects that can take Euler angles but do them using quaternions under the hood. Meaning, all rotations are always done as quaternion computations, but a user can get and set the rotation values as Euler angles with new API methods.

---

<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:** [December 2, 2021, 12:43pm UTC](https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725/7 "2021-12-02T12:43:40Z")

</div>

Adding @PirateJC for the doc

---

<div class="post-metadata">

**Author:** ![PirateJC](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/piratejc/32/1003_2.png) [@PirateJC](https://forum.babylonjs.com/u/PirateJC)\
**Post date:** [December 2, 2021, 4:10pm UTC](https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725/8 "2021-12-02T16:10:27Z")

</div>

@arcman7, first and foremost, welcome to the Babylon family! It’s great to have you here.

Secondly, great suggestion. Sorry this was hard one to figure out. I’ve run into similar frustration in the past myself trying to navigate the difference between rotationQuaternion and Euler angles.

One thing we could do is add some more examples in the docs, but it doesn’t sound like you’re suggesting a doc update here, but rather better error handling OR perhaps some new methods that are a bit intelligent under the hood, allowing the developers to not have to worry about mentally managing this difference themselves?

I like this last idea a lot. @sebavan - Not sure how technically possible this would be but it’s definitely worth exploring and talking about.

Let me know if there’s a specific doc update that we think would be helpful in the meantime.

Cheers!

---

<div class="post-metadata">

**Author:** ![arcman7](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/arcman7/32/20249_2.png) [@arcman7](https://forum.babylonjs.com/u/arcman7)\
**Post date:** [December 2, 2021, 6:59pm UTC](https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725/9 "2021-12-02T18:59:57Z")

</div>

Hi PirateJC, thanks for the warm welcome 😄 Overall I do appreciate Babylon JS, I’ve gotta say my tiny project is coming along thanks to this library. There have been a number obstacles I’ve encountered throughout my adoption period however, and I’d be happy to elaborate on what those have been for me personally in another thread (where ever appropriate).

I am suggesting either throwing an error when the operation the user is attempting to do is blocked by the existence of the rotationQuaternion property or a bigger change that accomplishes:

> OR perhaps some new methods that are a bit intelligent under the hood, allowing the developers to not have to worry about mentally managing this difference themselves?

I figure since I’m going to be using this library so much I’d be happy to try making a pull request for the smaller change of throwing an error, just to start with, but I’d definitely need someone to pair up with to get my dev environment set up and to show me where to even make those changes.

---

<div class="post-metadata">

**Author:** ![PirateJC](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/piratejc/32/1003_2.png) [@PirateJC](https://forum.babylonjs.com/u/PirateJC)\
**Post date:** [December 2, 2021, 9:42pm UTC](https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725/10 "2021-12-02T21:42:37Z")

</div>

Awesome! We are always THRILLED to have people contribute to Babylon!

Here’s a good doc to review to get started contributing:

> **[Start Contributing to Babylon.js | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/developWithBjs/howToStart)**
>
> Learn how to start contributing to Babylon.js.

If you get stuck along the way, feel free to use the forum for help. You’ll hopefully discover that this is a VERY friendly and helpful community of people. 🙂

Looking forward to seeing your first PR!

---

<div class="post-metadata">

**Author:** ![arcman7](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/arcman7/32/20249_2.png) [@arcman7](https://forum.babylonjs.com/u/arcman7)\
**Post date:** [December 2, 2021, 9:55pm UTC](https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725/11 "2021-12-02T21:55:58Z")

</div>

Cool, I’ll start here and take a look. Btw, do you guys have a discord channel?

---

<div class="post-metadata">

**Author:** ![PirateJC](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/piratejc/32/1003_2.png) [@PirateJC](https://forum.babylonjs.com/u/PirateJC)\
**Post date:** [December 2, 2021, 9:58pm UTC](https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725/12 "2021-12-02T21:58:28Z")

</div>

Nope. It’s something we’ve thought about but the forum and twitter are our main touchpoints.

Also YouTube, but that’s mostly outbound comms.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [December 29, 2021, 2:30pm UTC](https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725/13 "2021-12-29T14:30:50Z")

</div>

@arcman7 hi, just checking in! Were you able to set up the environment to contribute, are you having any difficulties? 😄

---

<div class="post-metadata">

**Author:** ![arcman7](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/arcman7/32/20249_2.png) [@arcman7](https://forum.babylonjs.com/u/arcman7)\
**Post date:** [July 25, 2023, 7:12pm UTC](https://forum.babylonjs.com/t/rotation-property-animation-for-a-glb-model-doesnt-work/4725/14 "2023-07-25T19:12:59Z")

</div>

Hi @carolhmj I’ll have to try setting up the environment again sometime in the near future. If I have any problems I will let you know. Thanks for asking!
