# Is it possible apply mesh rotation to geometry?

**URL:** <https://discourse.threejs.org/t/is-it-possible-apply-mesh-rotation-to-geometry/43608>\
**Category:** Questions\
**Tags:** geometry\
**Created:** [October 14, 2022, 1:47am UTC](https://discourse.threejs.org/t/is-it-possible-apply-mesh-rotation-to-geometry/43608 "2022-10-14T01:47:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnConstantine](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@JohnConstantine](https://discourse.threejs.org/u/JohnConstantine)\
**Post date:** [October 14, 2022, 1:47am UTC](https://discourse.threejs.org/t/is-it-possible-apply-mesh-rotation-to-geometry/43608/1 "2022-10-14T01:47:04Z")

</div>

Hello guys!  
We did lots of mesh rotation ,after that we need to merge geometries.  
Is it possible apply mesh rotation to geometry?  
i.e.

```javascript
    if(e.isMesh){
	    e.geometry.rotateX(e.rotation.x) // rotate
	    e.geometry.rotateY(e.rotation.y) // rotate
	    e.geometry.rotateZ(e.rotation.z) //rotate
	    e.geometry.translate(e.position.x,e.position.y,e.position.z)
	}

```

---

<div class="post-metadata">

**Author:** ![Lawrence3DPK](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/lawrence3dpk/32/29184_2.png) [@Lawrence3DPK](https://discourse.threejs.org/u/Lawrence3DPK)\
**Post date:** [October 14, 2022, 8:27am UTC](https://discourse.threejs.org/t/is-it-possible-apply-mesh-rotation-to-geometry/43608/2 "2022-10-14T08:27:50Z")

</div>

You can use [applyMatrix4](https://threejs.org/docs/#api/en/core/Object3D.applyMatrix4) on geometries.

---

<div class="post-metadata">

**Author:** ![JohnConstantine](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@JohnConstantine](https://discourse.threejs.org/u/JohnConstantine)\
**Post date:** [October 14, 2022, 8:38am UTC](https://discourse.threejs.org/t/is-it-possible-apply-mesh-rotation-to-geometry/43608/3 "2022-10-14T08:38:35Z")

</div>

Yeah i tried this , can’t rotate the geometry.  
`e.geometry.applyMatrix4(e.matrix)`

---

<div class="post-metadata">

**Author:** ![Lawrence3DPK](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/lawrence3dpk/32/29184_2.png) [@Lawrence3DPK](https://discourse.threejs.org/u/Lawrence3DPK)\
**Post date:** [October 14, 2022, 8:54am UTC](https://discourse.threejs.org/t/is-it-possible-apply-mesh-rotation-to-geometry/43608/4 "2022-10-14T08:54:14Z")

</div>

It should apply all transforms, do you call updateMatrix() on the mesh you want to extract the transforms from before this?

---

<div class="post-metadata">

**Author:** ![JohnConstantine](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@JohnConstantine](https://discourse.threejs.org/u/JohnConstantine)\
**Post date:** [October 14, 2022, 11:25am UTC](https://discourse.threejs.org/t/is-it-possible-apply-mesh-rotation-to-geometry/43608/5 "2022-10-14T11:25:01Z")

</div>

No,I did not,ill try update

---

<div class="post-metadata">

**Author:** ![JohnConstantine](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@JohnConstantine](https://discourse.threejs.org/u/JohnConstantine)\
**Post date:** [October 14, 2022, 11:42am UTC](https://discourse.threejs.org/t/is-it-possible-apply-mesh-rotation-to-geometry/43608/6 "2022-10-14T11:42:32Z")

</div>

![图片](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/5/b/5b98ce214242a93a663305d784d18272f9146bd5.png)  
This is what it(THREE.Group) should be.  
After the transform

```javascript
    geometries = []
    group.traverse(e=>{
             if(e.isMesh){
	            e.updateMatrix()
                e.geometry.applyMatrix4(e.matrix)
                geometries.push(e.geometry)
	          }
    })
    const geometry = BufferGeometryUtils.mergeBufferGeometries(geometries)
    const mesh = new THREE.Mesh(geometry,material)

```

![图片](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/4/a/4ae9a2c8d02322fbd4ae382d7a025b5093d90625.png)  
It’s something but still not quit the right transform

---

<div class="post-metadata">

**Author:** ![JohnConstantine](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@JohnConstantine](https://discourse.threejs.org/u/JohnConstantine)\
**Post date:** [October 15, 2022, 3:48am UTC](https://discourse.threejs.org/t/is-it-possible-apply-mesh-rotation-to-geometry/43608/7 "2022-10-15T03:48:43Z")

</div>

This is the correct answer.Somethings wrong when perform `BufferGeometryUtils.mergeBufferGeometries()` I think

---

<div class="post-metadata">

**Author:** ![JohnConstantine](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@JohnConstantine](https://discourse.threejs.org/u/JohnConstantine)\
**Post date:** [October 15, 2022, 4:00am UTC](https://discourse.threejs.org/t/is-it-possible-apply-mesh-rotation-to-geometry/43608/8 "2022-10-15T04:00:20Z")

</div>

Not `BufferGeometryUtils.mergeBufferGeometries()`,it’s because we use `mesh.clone()`,two twins are messing with each other!
