Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
Is there a way I can move my camera to look around inside the 3D model using three js?

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!