# Position been changed when try to rotate primitive

**URL:** <https://community.cesium.com/t/position-been-changed-when-try-to-rotate-primitive/13694>\
**Category:** CesiumJS\
**Created:** [May 19, 2021, 2:02am UTC](https://community.cesium.com/t/position-been-changed-when-try-to-rotate-primitive/13694 "2021-05-19T02:02:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![QianWu184](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/qianwu184/32/5037_2.png) [@QianWu184](https://community.cesium.com/u/QianWu184)\
**Post date:** [May 19, 2021, 2:02am UTC](https://community.cesium.com/t/position-been-changed-when-try-to-rotate-primitive/13694/1 "2021-05-19T02:02:17Z")

</div>

I try to rotate a primitive（The primitive has 1000 rectangles, each with its own location）, but when i use code like this, i find position be changed at same time.how could i do to make it right. can any one help me?（the oldModelMatrix is default modelMatrix）  
let matrix3=Matrix3.fromRotationY(Math.toRadians(angle));  
let rz = Matrix4.fromRotationTranslation(matrix3);  
let result = Matrix4.multiply(oldModelMatrix, rz, oldModelMatrix);

---

<div class="post-metadata">

**Author:** ![Eli](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/eli/32/4980_2.png) [@Eli](https://community.cesium.com/u/Eli)\
**Post date:** [May 20, 2021, 8:13pm UTC](https://community.cesium.com/t/position-been-changed-when-try-to-rotate-primitive/13694/2 "2021-05-20T20:13:24Z")

</div>

Hi,

Welcome to the community! Could you please share a [Sandcastle](https://sandcastle.cesium.com/index.html) showing how you’re constructing the primitive and updating its matrix?

Thanks,  
Eli

---

<div class="post-metadata">

**Author:** ![QianWu184](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/qianwu184/32/5037_2.png) [@QianWu184](https://community.cesium.com/u/QianWu184)\
**Post date:** [May 21, 2021, 1:42am UTC](https://community.cesium.com/t/position-been-changed-when-try-to-rotate-primitive/13694/3 "2021-05-21T01:42:33Z")

</div>

i got a primitve with 1000 rectangle by

let myprimitive = new Primitive({  
geometryInstances: [myGeometrys],  
appearance: new PerInstanceColorAppearance()  
})

and the **myGeometrys** is an Array of rectangle geometryInstance, like:

let myGeomInstance = new GeometryInstance({  
geometry: new RectangleGeometry({  
rectangle: Rectangle.fromDegrees(  
west,  
south,  
east,  
north  
),  
}),  
attributes: {  
color: ColorGeometryInstanceAttribute.fromColor(Color.RED),  
},  
})

and after added it to **Viewer** , i try to rotate the primitive by **modeMatrix** , i use:

let matrix3=Matrix3.fromRotationY(Math.toRadians(angle));  
let rz = Matrix4.fromRotationTranslation(matrix3);  
let result = Matrix4.multiply(myprimitive.modelMatrix, rz, new Matrix4());

It’s work, but primitive’s position has been changed at same time.Then i try to get center of primitive position to reset the primitive rotate origin point

let center = Transforms.eastNorthUpToFixedFrame(centerPosition);

And primitive fly to another position(have a height that i never set).  
I’m confused by the rotation of ModeMatrix. Is there anything I haven’t noticed?
