How to set the viewpoint of the route roam?

When I activate a route roam, the viewpoint looks incorrect,it is tilted.How to set the correct viewpoint?
1
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

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.

1 Like

How can I calculate the correct value of upVector?

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