# How to set the viewpoint of the route roam?

**URL:** <https://forum.techsoft3d.com/t/how-to-set-the-viewpoint-of-the-route-roam/1277>\
**Category:** HOOPS Visualize Web\
**Created:** [January 3, 2023, 3:30am UTC](https://forum.techsoft3d.com/t/how-to-set-the-viewpoint-of-the-route-roam/1277 "2023-01-03T03:30:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![619944680](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/619944680/32/516_2.png) [@619944680](https://forum.techsoft3d.com/u/619944680)\
**Post date:** [January 3, 2023, 3:30am UTC](https://forum.techsoft3d.com/t/how-to-set-the-viewpoint-of-the-route-roam/1277/1 "2023-01-03T03:30:55Z")

</div>

When I activate a route roam, the viewpoint looks incorrect,it is tilted.How to set the correct viewpoint？  
 ![1](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/13ad9a2e6b753e9b1538764f4bdcd43534f89b99.gif)  
The following is part of the code for this roma class

h.prototype.routeRoma = function (s, r) {  
var that = this;  
var roma = (function () {  
function a() {  
this.points = ;  
this.index = 0;  
this.view = that.hwv.view;  
this.status = 0;  
this.speed = s;  
this.repeat = r;  
this.timeId = null;  
var c = this.view.getCamera();  
c.\_projection = 1;  
this.view.setCamera(c);  
}

```
  a.prototype.setRoutes = function (v, l) {
    if (l) that.setViewPoint(l);
    this.points = [];
    for (var i = 1; i < v.length; i++) {
      var xGap = (v[i].x - v[i - 1].x) / 50,
        yGap = (v[i].y - v[i - 1].y) / 50,
        zGap = (v[i].z - v[i - 1].z) / 50;
      for (var n = 0; n < 50; n++) {
        this.points.push(new Communicator.Point3(v[i - 1].x + xGap * n, v[i - 1].y + yGap * n, v[i - 1].z + zGap * n));
      }
    }
  };
  a.prototype.play = function () {
    this.status = 1;
    this.index = 0;
    var timer = this.speed === "normal" ? 200 : this.speed === "fast" ? 100 : 350;
    clearInterval(this.timeId);
    this.timeId = setInterval(() => {
      this.update();
    }, timer);
  };
  a.prototype.pause = function (a) {
    this.status = 2;
  };
  a.prototype.resume = function (a) {
    this.status = 1;
  };
  a.prototype.stop = function () {
    this.status = 0;
    clearInterval(this.timeId);
  };
  a.prototype.setLoop = function (rp) {
    this.repeat = rp;
  };
  a.prototype.setSpeed = function (sp) {
    this.speed = sp;
  };
  a.prototype.update = function () {
    if (this.status === 1) {
      var f = this.view.getCamera();
      console.log(this.index, this.points);
      var pt1 = this.points[this.index],
        pt2 = this.points[this.index + 1];
      pt2.z += 500;
      f.setPosition(pt1);
      f.setTarget(pt2);
      f.setWidth(1500);
      f.setHeight(1500); // 没设置会变形

      var timer = this.speed === "normal" ? 200 : this.speed === "fast" ? 100 : 350;
      this.view.setCamera(f, timer);
      if (this.index < this.points.length - 2) this.index++;
      else if (this.repeat) this.index = 0;
    }
  };
  return a;
})();
return new roma();

```

};

> Blockquote

---

<div class="post-metadata">

**Author:** ![guido](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/guido/32/115_2.png) [@guido](https://forum.techsoft3d.com/u/guido)\
**Post date:** [January 3, 2023, 8:43pm UTC](https://forum.techsoft3d.com/t/how-to-set-the-viewpoint-of-the-route-roam/1277/2 "2023-01-03T20:43:44Z")

</div>

In order to get the right orientation you have to make sure to also adjust the upVector of the camera. (camera.setUp) This might be the issue here.

---

<div class="post-metadata">

**Author:** ![619944680](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/619944680/32/516_2.png) [@619944680](https://forum.techsoft3d.com/u/619944680)\
**Post date:** [January 4, 2023, 1:51am UTC](https://forum.techsoft3d.com/t/how-to-set-the-viewpoint-of-the-route-roam/1277/3 "2023-01-04T01:51:56Z")

</div>

How can I calculate the correct value of upVector?

---

<div class="post-metadata">

**Author:** ![guido](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/guido/32/115_2.png) [@guido](https://forum.techsoft3d.com/u/guido)\
**Post date:** [January 4, 2023, 1:03pm UTC](https://forum.techsoft3d.com/t/how-to-set-the-viewpoint-of-the-route-roam/1277/4 "2023-01-04T13:03:14Z")

</div>

The up vector usually represents the roll/tilt of the camera so you have to set it according to your needs. If you want the camera to to look straight “forward” then it should be set to the up axis of the model which can be retrieved with hwv.model.getViewAxes().

[https://docs.techsoft3d.com/communicator/latest/api\_ref/viewing/classes/Communicator.Model.html#Communicator.Communicator.Model.getViewAxes](https://docs.techsoft3d.com/communicator/latest/api_ref/viewing/classes/Communicator.Model.html#Communicator.Communicator.Model.getViewAxes)
