# Hit test transformation matrix in augmented reality

**URL:** <https://forum.babylonjs.com/t/hit-test-transformation-matrix-in-augmented-reality/11580>\
**Category:** Questions\
**Created:** [June 10, 2020, 1:20pm UTC](https://forum.babylonjs.com/t/hit-test-transformation-matrix-in-augmented-reality/11580 "2020-06-10T13:20:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Piyush\_Aggarwal](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/piyush_aggarwal/32/8645_2.png) [@Piyush\_Aggarwal](https://forum.babylonjs.com/u/Piyush_Aggarwal)\
**Post date:** [June 10, 2020, 1:21pm UTC](https://forum.babylonjs.com/t/hit-test-transformation-matrix-in-augmented-reality/11580/1 "2020-06-10T13:21:00Z")

</div>

Hi,

I am building my application on top of this playground example: [https://www.babylonjs-playground.com/#KVZI50#135](https://www.babylonjs-playground.com/#KVZI50#135)  
I want to move the 3D object on hit test location, but I don’t want to change my model’s scale value.  
I have scaled down my model in the beginning to 0.5.

But, during hit test in WebXR, I suppose the below line is increasing my model size to double.  
hitTest.transformationMatrix.decompose(b.scaling, b.rotationQuaternion, b.position);

So, is there any way by which I can get the translation, rotation and scale vectors from this transformation matrix and control my model as per my choice?

Below image shows my transformation matrix values:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/9/942a640799d041218858b1464880403f94e16b99.png)

---

<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:** [June 10, 2020, 1:41pm UTC](https://forum.babylonjs.com/t/hit-test-transformation-matrix-in-augmented-reality/11580/2 "2020-06-10T13:41:29Z")

</div>

@RaananW will definitely be able to help here 🙂

---

<div class="post-metadata">

**Author:** ![Piyush\_Aggarwal](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/piyush_aggarwal/32/8645_2.png) [@Piyush\_Aggarwal](https://forum.babylonjs.com/u/Piyush_Aggarwal)\
**Post date:** [June 10, 2020, 1:45pm UTC](https://forum.babylonjs.com/t/hit-test-transformation-matrix-in-augmented-reality/11580/3 "2020-06-10T13:45:18Z")

</div>

I have looked deeper into the issue and after extensive testing I can say that my model is scaled to 0.5 till hit test.

But when I tap on the screen, an anchor is created using the below code:  
anchors.onAnchorAddedObservable.add(anchor =\> {  
anchor.attachedNode = b.clone(“mensch”);  
});

Now, the cloned mesh has a scale of 1 instead of 0.5.

---

<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:** [June 10, 2020, 1:46pm UTC](https://forum.babylonjs.com/t/hit-test-transformation-matrix-in-augmented-reality/11580/4 "2020-06-10T13:46:16Z")

</div>

Are you using latest from [preview.babylonjs.com](http://preview.babylonjs.com) ?

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [June 10, 2020, 8:52pm UTC](https://forum.babylonjs.com/t/hit-test-transformation-matrix-in-augmented-reality/11580/5 "2020-06-10T20:52:25Z")

</div>

You don’t have to decompose the scaling. I just did it to show what’s possible. Set the first variable in the decompose function to undefined, it will start scaled as before
