I have a 3D model which I am trying to present on a web page actually this model is like a room I want to change camera position to different points inside the room so that I can view my room from different angles for this purpose I am using Perspective camera and orbit controls I am trying to change this method from oribtcontrols
dollyIn(dollyScale) dollyOut(dollyScale)
here is my code
function dollyIn(dollyScale) {
if (scope.object.isPerspectiveCamera) {
var deg = Math.abs(spherical.theta); //(spherical.theta * 180)/Math.PI;
scope.enableRotate = false;
var th = spherical.theta;
var step = dollyScale;
if (0 <= th && th <= Math.PI) {
if (0 <= th && th < Math.PI / 2) {
console.log("Positive angle First Quad\t" + th);
scope.target.x += step; //(dollyScale * deg);
scope.target.z += step; //(dollyScale * deg);
} else if (Math.PI / 2 <= th && th <= Math.PI) {
console.log("Positive angle Second Quad \t" + th);
scope.target.x -= step; //(dollyScale * deg);
scope.target.z += step; //(dollyScale * deg);
}
} else if (0 > th && th > -Math.PI) {
if (0 > th && th > -Math.PI / 2) {
console.log("Negitive angle Fouth Quad\t" + th);
scope.target.x += step; //(dollyScale * deg);
scope.target.z -= step; //(dollyScale * deg);
} else if (-Math.PI / 2 > th && th > -Math.PI) {
console.log("Negitive angle Third Quad \t" + th);
scope.target.x -= step; //(dollyScale * deg);
scope.target.z -= step; //(dollyScale * deg);
}
}
console.log("resetting the angle to " + th);
spherical.theta = th;
} else if (scope.object.isOrthographicCamera) {
scope.object.zoom = Math.max(
scope.minZoom,
Math.min(scope.maxZoom, scope.object.zoom / dollyScale)
);
scope.object.updateProjectionMatrix();
zoomChanged = true;
} else {
console.warn(
"WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."
);
scope.enableZoom = false;
}
}
so that when I scroll the mouse wheel instead of zoom My camera should move towards the direction it is facing
any help will be appreciated