# Rotating entity

**URL:** https://community.cesium.com/t/rotating-entity/23067
**Category:** CesiumJS
**Created:** [March 25, 2023, 12:53am UTC](https://community.cesium.com/t/rotating-entity/23067 "2023-03-25T00:53:36Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Aikiman](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/aikiman/32/13754_2.png) [@Aikiman](https://community.cesium.com/u/Aikiman)
#### Post date: [March 25, 2023, 12:53am UTC](https://community.cesium.com/t/rotating-entity/23067/1 "2023-03-25T00:53:37Z")

</div>

Hi,  
Ive imported a model using the javascript API and it seems to sit correctly with the Y as the up axis as shown below…

 ![Screen Shot 2023-03-25 at 1.43.35 PM](https://global.discourse-cdn.com/cesium/original/2X/6/6eb33ff0c1fedcf2b39955e509ba76afaac06d32.jpeg)

I want to now rotate the model around the Y axis to fit it into place correctly and I found this snippet of code to assist me with this- I have commented it out so you can see the code im referencing…

 ![Screen Shot 2023-03-25 at 1.43.48 PM](https://global.discourse-cdn.com/cesium/original/2X/8/8359e43047cf201c8cd6b6688b2c46bcca7f174d.png)

However after running the code my model doesnt rotate as expected in fact rotating around any of the axis doesnt work as expected, it feels very unintuitive using this method. What am I doing wrong or is there a better way to do this?

 ![Screen Shot 2023-03-25 at 1.43.18 PM](https://global.discourse-cdn.com/cesium/original/2X/c/c195a1886a2e4c46623a90e7e92a2a3ee8f2248e.jpeg)

---

<div class="post-metadata">

### Author: ![DanRiess](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/danriess/32/12429_2.png) [@DanRiess](https://community.cesium.com/u/DanRiess)
#### Post date: [March 25, 2023, 3:05pm UTC](https://community.cesium.com/t/rotating-entity/23067/2 "2023-03-25T15:05:30Z")

</div>

I believe that is because you’re rotating in world space. Your rotation axis should be the normal on the ellipsoid at your model’s position. Try doing the following

const axis = viewer.scene.globe.ellipsoid.getGeodeticSurfaceNormal(entity.position, new Cesium.Cartesian3())

I didn’t test this, but it’s how I rotate things.

---

<div class="post-metadata">

### Author: ![Aikiman](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/aikiman/32/13754_2.png) [@Aikiman](https://community.cesium.com/u/Aikiman)
#### Post date: [March 25, 2023, 9:47pm UTC](https://community.cesium.com/t/rotating-entity/23067/3 "2023-03-25T21:47:38Z")

</div>

Hey Dan,

Thanks for chiming in man. Your answer was interesting way to tackle the problem, certainly makes sense what you are trying to achieve but apparently however getGeodeticSurfaceNormal() isnt a valid function. Not sure why Im getting that, maybe the API has been updated?

After doing a little bit more digging around I have found a solution. Im using the orientation attribute to set the orientation on creation like so:

```auto
const orientation = Cesium.Transforms.headingPitchRollQuaternion(position, new Cesium.HeadingPitchRoll(305, 0, 0));

```

This is exactly what I am after.  
Thanks
