Hi, simple question as my knowledge of JS is not that good…
Would be great if the standard orbit-camera.js script included in the ‘standard model viewer’ had the ability to set starting yaw (ie rotation around Y, up-axis).
Im trying to call the object attribute ‘yaw’ (from the original pc script):
Object.defineProperty(OrbitCamera.prototype, "yaw", {
get: function() {
return this._targetYaw;
},
set: function(value) {
this._targetYaw = value;
// Ensure that the yaw takes the shortest route by making sure that
// the difference between the targetYaw and the actual is 180 degrees
// in either direction
var diff = this._targetYaw - this._yaw;
var reminder = diff % 360;
if (reminder > 180) {
this._targetYaw = this._yaw - (360 - reminder);
} else if (reminder < -180) {
this._targetYaw = this._yaw + (360 + reminder);
} else {
this._targetYaw = this._yaw + reminder;
}
}
});
… within the script’s focusEntity() function:
OrbitCamera.prototype.focus = function (focusEntity) {
// Calculate an bounding box that encompasses all the models to frame in the camera view
this._buildAabb(focusEntity, 0);
var halfExtents = this._modelsAabb.halfExtents;
var distance = Math.max(halfExtents.x, Math.max(halfExtents.y, halfExtents.z));
distance = (distance / Math.tan(0.5 * this.entity.camera.fov * pc.math.DEG_TO_RAD));
distance = (distance * 2);
this.distance = distance;
this._removeInertia();
this._pivotPoint.copy(this._modelsAabb.center);
/// smthg like this?
this.yaw.set(this.useryaw);
};
Thanks v much for responses folks.
By the way can we also set a user-input in editor for an orbit rotation speed? (so camera rotates around model)