# Problems with axis

**URL:** <https://forum.babylonjs.com/t/problems-with-axis/39912>\
**Category:** Questions\
**Created:** [April 15, 2023, 12:18pm UTC](https://forum.babylonjs.com/t/problems-with-axis/39912 "2023-04-15T12:18:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darth\_Luis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/darth_luis/32/30595_2.png) [@Darth\_Luis](https://forum.babylonjs.com/u/Darth_Luis)\
**Post date:** [April 15, 2023, 12:18pm UTC](https://forum.babylonjs.com/t/problems-with-axis/39912/1 "2023-04-15T12:18:49Z")

</div>

I have created a mesh which is the son of another mesh. After that I need to rotate the first mesh to put it in the way I want to.  
The problem I find is that the y and z axis seem to have the same direction because when I gave it values It rotates in the same direction but in diferent sense.  
I can’t attach a playground because I’m writing the code in VSC and it too much conected with other files.  
Has someone had the same problem?

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [April 15, 2023, 12:22pm UTC](https://forum.babylonjs.com/t/problems-with-axis/39912/2 "2023-04-15T12:22:25Z")

</div>

I cannot say that I completely understand your problem. How do you rotate your mesh? With rotation or with rotationQuaternion?  
Even a simple PG would help a lot to help you, otherwise we’ll need to guess about your code.

---

<div class="post-metadata">

**Author:** ![Darth\_Luis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/darth_luis/32/30595_2.png) [@Darth\_Luis](https://forum.babylonjs.com/u/Darth_Luis)\
**Post date:** [April 15, 2023, 12:44pm UTC](https://forum.babylonjs.com/t/problems-with-axis/39912/3 "2023-04-15T12:44:21Z")

</div>

I’m using rotation. I attach some screenshot of my code

 ![Captura de pantalla 2023-04-15 143029](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/7/8/786bf05439871bc9487061a570753ca788486902.png)  
 ![Captura de pantalla 2023-04-15 143001](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/1/413c7faef73a3aa71aed9e3e40108241a60efe68.png)  
As you request I attach a playground with a recreation of my code (I’m having some problems with PI)

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

---

<div class="post-metadata">

**Author:** ![SkyOps117](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/skyops117/32/31300_2.png) [@SkyOps117](https://forum.babylonjs.com/u/SkyOps117)\
**Post date:** [April 15, 2023, 1:31pm UTC](https://forum.babylonjs.com/t/problems-with-axis/39912/4 "2023-04-15T13:31:37Z")

</div>

Check out this.  
`transform = new BABYLON.TransformNode("root");`

Thats how I attached things meshes togethers with the camera and player.  
Example:  
`playerCamera.parent = transform;`

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [April 16, 2023, 9:27am UTC](https://forum.babylonjs.com/t/problems-with-axis/39912/5 "2023-04-16T09:27:47Z")

</div>

> [@Darth\_Luis](#):
>
> (I’m having some problems with PI)

You need to remove ‘BABYLON’ from your declaration for this part when using the PG.

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

Same as @labris, I’m also not sure to understand your question and problem. Which part is it you want to rotate and what is it that is not working as you expect?

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [April 16, 2023, 10:11am UTC](https://forum.babylonjs.com/t/problems-with-axis/39912/6 "2023-04-16T10:11:04Z")

</div>

> [@Darth\_Luis](#):
>
> (I’m having some problems with PI)

Math.PI relates to radians.  
If you want to use degrees (which could be more convenient and readable) you may use

```auto
BABYLON.Tools.ToRadians(180)

```

(or any needed degree)

---

<div class="post-metadata">

**Author:** ![Darth\_Luis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/darth_luis/32/30595_2.png) [@Darth\_Luis](https://forum.babylonjs.com/u/Darth_Luis)\
**Post date:** [April 17, 2023, 7:27am UTC](https://forum.babylonjs.com/t/problems-with-axis/39912/7 "2023-04-17T07:27:43Z")

</div>

As I expected, when I do it in the PG it works as it was supposed. However, in VSC I still have the problem.  
I attach a few screenshots so you can understand my problem

 ![Caso 1](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/c/e/cea5cceaac97ad7ab0905c507980e1934188b68b.png)  
 ![Caso 2](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/b/4/b4e751fdf8261ff2e4f22694197d4c1b8398dfa0.png)  
As you can see in the first one I have put the excat same rotation vector 3 than in the PG. However, A different result appear. And when I try to rotate in the other direction it rotate in the same direction but with diferent rotation. So my problem is that I can’t rotate the blade in its longitudinal axis.

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [April 17, 2023, 8:30am UTC](https://forum.babylonjs.com/t/problems-with-axis/39912/8 "2023-04-17T08:30:50Z")

</div>

Not sure that I understood you completely, but could you try to make rotation as (values are just example):

```auto
mesh.rotation.x = Math.PI
mesh.rotation.y = 0
mesh.rotation.z = 0

```

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [April 17, 2023, 9:04am UTC](https://forum.babylonjs.com/t/problems-with-axis/39912/9 "2023-04-17T09:04:06Z")

</div>

Sorry, I’m also not sure to understand quite exactly. May be a matter of language, is it?  
You might be facing a left vs right-handed issue? Comparing your screenshots with the PG, it seems your ‘pala’ is offseted left from the ‘cabeza’ in the PG but offseted right from it in your screenshots.  
And when you say “rotate in the other direction”, do you mean that in the PG, a y-rotation makes it rotate ‘counterclock wise’ and in your project it would rotate ‘clockwise’, is that what it is?

Edit: Look at this PG below where I changed your scene to a ‘right-handed system’.  
Does this match what you have in your project?

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

Edit1: From the above PG you should **disregard the pala extrusion**. The extrusion must have been done to match your project coordinates (I believe). If, as I think, you are facing an issue with mixing left and right system coordinates, the extrusion in BJS needs to be done using the left-handed system OR if you choose to go with the right-handed system, the extrusion needs to use these coordinates. In the below PG, I translated the values just quickly for a check. Now, would you say that this PG matches what you have in project?

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