# Top view draggable orthographic Camera

**URL:** <https://forum.babylonjs.com/t/top-view-draggable-orthographic-camera/4309>\
**Category:** Questions\
**Created:** [July 5, 2019, 3:34pm UTC](https://forum.babylonjs.com/t/top-view-draggable-orthographic-camera/4309 "2019-07-05T15:34:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![constantinos](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/constantinos/32/3227_2.png) [@constantinos](https://forum.babylonjs.com/u/constantinos)\
**Post date:** [July 5, 2019, 3:34pm UTC](https://forum.babylonjs.com/t/top-view-draggable-orthographic-camera/4309/1 "2019-07-05T15:34:18Z")

</div>

Hello,

New with BJS and programming in general.

I am trying to create an interior design app so I need the app to have a top-down view initially for the floor plan. This is what I have right now [Babylon.js Playground](https://playground.babylonjs.com/#A7AX75)

Then I need to be able to drag the camera (left, right, up, down) around with the mouse by clicking anywhere. I am stuck here.

Am I on the right path?

I am familiar with events but not sure how exactly this should work.

---

<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:** [July 5, 2019, 4:24pm UTC](https://forum.babylonjs.com/t/top-view-draggable-orthographic-camera/4309/2 "2019-07-05T16:24:30Z")

</div>

Hello and welcome to the forum !!!

Maybe you could use a transition to animate from one position to another one a bit like in this thread:

> [@Smooth Target Transition with a Smooth Move to target](https://forum.babylonjs.com/t/smooth-target-transition-with-a-smooth-move-to-target/4295/8):
>
> hahaha! you made it better! Slick! I do love this community.

---

<div class="post-metadata">

**Author:** ![constantinos](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/constantinos/32/3227_2.png) [@constantinos](https://forum.babylonjs.com/u/constantinos)\
**Post date:** [July 8, 2019, 8:36am UTC](https://forum.babylonjs.com/t/top-view-draggable-orthographic-camera/4309/3 "2019-07-08T08:36:11Z")

</div>

I dont think thats what I am looking for.

Here is how it sould work exactly:

1. if Mouse down and move mouse 10 to the left
2. then I want the camera position to move 10 to the left also.

So if I understand how this should work, I need:

- the starting Vector position when I click the mouse down
- the end Vector position when mouse is moved
- the distance between the two == end - start
- subtract/add (?) the difference from the current camera position

And this should work in real time as I hold the mouse down.

Ideally this will work with touch also and at any direction on the x, z axis.

---

<div class="post-metadata">

**Author:** ![constantinos](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/constantinos/32/3227_2.png) [@constantinos](https://forum.babylonjs.com/u/constantinos)\
**Post date:** [July 8, 2019, 8:46am UTC](https://forum.babylonjs.com/t/top-view-draggable-orthographic-camera/4309/4 "2019-07-08T08:46:45Z")

</div>

I think this is what I was looking for [https://playground.babylonjs.com/#K9MWF6#3](https://playground.babylonjs.com/#K9MWF6#3)

Now I am a bit confused on if I should be using [ORTHOGRAPHIC\_CAMERA] property or not. Because in the playground example its not used. What is the difference?

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [July 8, 2019, 9:07am UTC](https://forum.babylonjs.com/t/top-view-draggable-orthographic-camera/4309/5 "2019-07-08T09:07:34Z")

</div>

Hi. There are multiple ways to do this. You can use ArcRotateCamera, FreeCamera, with or without orthographic mode, or you can you the [new drag system](https://playground.babylonjs.com/#QCGY56), maybe more 🙂 it depends.  
Related to ortho and perspective camera, the main difference, I think, is that ortho doesn’t have depth, but you can ‘simulate’ this with a normal camera with perspective view as well.

---

<div class="post-metadata">

**Author:** ![constantinos](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/constantinos/32/3227_2.png) [@constantinos](https://forum.babylonjs.com/u/constantinos)\
**Post date:** [July 8, 2019, 1:34pm UTC](https://forum.babylonjs.com/t/top-view-draggable-orthographic-camera/4309/6 "2019-07-08T13:34:52Z")

</div>

I have some problems [https://playground.babylonjs.com/#K9MWF6#13](https://playground.babylonjs.com/#K9MWF6#13)

Why does panning on the Z axis not work?

Why is Zoom in/out broken after enabling the orthographic mode?

Do I need to call the attachControl() method 2 times on the camera? In [https://playground.babylonjs.com/#K9MWF6#3](https://playground.babylonjs.com/#K9MWF6#3) its called twice.

This is supposed to be the top view so the Y axis is supposed to face up right? This is how Babylon works? On the other hand, in Blender this axis is represented by the Z axis?

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [July 8, 2019, 1:48pm UTC](https://forum.babylonjs.com/t/top-view-draggable-orthographic-camera/4309/7 "2019-07-08T13:48:43Z")

</div>

[https://playground.babylonjs.com/#K9MWF6#14](https://playground.babylonjs.com/#K9MWF6#14) - with few explanations 🙂

---

<div class="post-metadata">

**Author:** ![constantinos](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/constantinos/32/3227_2.png) [@constantinos](https://forum.babylonjs.com/u/constantinos)\
**Post date:** [July 8, 2019, 2:07pm UTC](https://forum.babylonjs.com/t/top-view-draggable-orthographic-camera/4309/8 "2019-07-08T14:07:21Z")

</div>

```
camera.panningAxis = new BABYLON.Vector3(1, 1, 0);

```

These are not the world axis? These are the local axis of the camera? The way I thought of it was that panning up & down was on the Z axis which is the 3rd parameter on the above vector.

Why does the ground not change size on zoom in/out? I thought the orthographic camera is just viewing everything flat, with all lines parallel to each other (in case of a box)

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [July 8, 2019, 4:27pm UTC](https://forum.babylonjs.com/t/top-view-draggable-orthographic-camera/4309/9 "2019-07-08T16:27:15Z")

</div>

It seems ArcRotate Camera has only 2 axis for panning X and Y.

> <https://github.com/BabylonJS/Babylon.js/blob/3a2d1be3bb80fc10589ac2c227cf69a8d9d40508/src/Cameras/arcRotateCamera.ts#L821>

  
You are right, the vector3 is x,y,z, but internally arcCamera use for panning only x and y.  
And related to zoom, I think is because of the depth as I wrote (it doesn’t exist), but there should be other way to ‘simulate’ zoom in this mode too.

---

<div class="post-metadata">

**Author:** ![constantinos](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/constantinos/32/3227_2.png) [@constantinos](https://forum.babylonjs.com/u/constantinos)\
**Post date:** [July 9, 2019, 6:47am UTC](https://forum.babylonjs.com/t/top-view-draggable-orthographic-camera/4309/10 "2019-07-09T06:47:07Z")

</div>

Managed to add zoom thanks to this example [https://playground.babylonjs.com/#EBPQH9#1](https://playground.babylonjs.com/#EBPQH9#1)

> And related to zoom, I think is because of the depth as I wrote (it doesn’t exist)

Thanks @MarianG, now I get it.
