It appears that setting enableRotate/Pan to false in Three.js OrbitControls is not functioning as expected

I need to disable the rotation (.enableRotate) and panning (.enablePan) on my perspectiveCamera with OrbitControls.

I attempted to set them to false, but it didn't work. As a workaround, I used:

controls.maxPolarAngle = 0;
controls.maxAzimuthAngle = - Math.PI;

However, since there isn't a similar option for .enablePan, I'm unable to achieve what I want. Could there be an issue with how I implemented it?

If you prefer to work on it or try it yourself, here is the CodePen link: https://codepen.io/greg_o/pen/jdwZYZ

The part of the code that may interest you is:

function init() {
    camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1000);
    camera.position.z = 68;
    controls = new THREE.OrbitControls(camera);
    controls.maxDistance = 300;
    controls.minDistance = 30;
    controls.enableRotate = false;
    controls.maxPolarAngle = 0;
    controls.maxAzimuthAngle = - Math.PI;
    controls.enablePan = false;
}

Just to mention, the original Pen belongs to Nikita Skargovskii.

Answer №1

After updating to the most recent version of three.js and using OrbitControls, it appears that the issue has been resolved. Check out this link for reference: https://codepen.io/anon/pen/exRQYo

Prior to this update, you were working with release 84, which is over two years old. It's always recommended to work with the latest revision of three.js and make sure that any additional files from the example directory (such as OrbitControls) are compatible with the version of your three.js file.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to retrieve the props from server-side rendering when re-rendering the component on the client side?

After conducting extensive research, I have been unsuccessful in getting it to function properly. My project is built on express.js and react in an isomorphic application setup. To generate my component and send it back to the client side, I utilized ren ...

What is the process for uploading a file with POST in angular?

What is the best way to send a pdf file without completely revamping our current system? I have explored various methods online, but most of them involve significant changes to our architecture, which is not ideal. Although I am not very experienced with ...

JSON.stringify alters the format of a date object

I have a website where users can log in with a specific timezone, regardless of the client-side timezone. When a user selects a date on the website, it is sent to the server side using JSON.stringify along with other properties. However, when the date is r ...

SignalR error: A type conversion issue has occurred where it is not possible to directly convert a task returning an object to a string

I'm encountering an issue with my C# hub class where the JavaScript code is returning a System.Threading.Tasks.Task instead of a string. I need help modifying the JavaScript method to return an actual string. Below is the hub class: public String ge ...

Update the background image every minute with a smooth transition effect

I am currently in the process of developing a personal dashboard that requires dynamic background images to change every minute. To achieve this functionality, I have integrated the [Pixabay API][1] and formulated the following API request: https://pixaba ...

Preserve the form's values after an onclick event to maintain the user's input in session storage

My website consists of a single page with an interface designed to showcase prediction results in {{ prediction_text }} from a flask backend. Users input values into a form that utilizes the app.py script to generate prediction outcomes. The issue I am fac ...

Be notified when multiple checkboxes with identical class names are checked with similar values

Is there a way to use jQuery to alert the user if they try to select the same value from a checkbox more than once? <div> <input type="checkbox" class="check" value="1"/> </div> <div> <input type="checkbox" class="check" ...

Tips for setting a value from an AJAX-created element into a concealed form field

There is a div that contains a button. When the button is clicked, a form appears. The div's id is then assigned to a hidden field within the form. This functionality works for the divs that are present on the page when it initially loads, but it does ...

Ensuring nested JSON key existence before rendering in React

When retrieving data from MarvelAPI, there is no certainty that the key being accessed will be available. Therefore, I am implementing if statements to check each key before accessing them. The current code below appears quite messy. Is there a more effic ...

Tips for loading various content types in Fancybox 3

I am utilizing Fancybox 3 for my gallery where I have disabled the opening/closing animation. Here is how I load my gallery: $(document).on('click', '[data-fancybox-var]', function(e) { e.preventDefault(); var links = $(' ...

After resetting my computer, I am now encountering an error message that states "There is no 'Access-Control-Allow-Origin' header present". Why is this happening?

After reformatting my pc, I encountered a new issue when sending an ajax request which involved calling a php file. The message displayed was: "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' ...

What does the blue digit in the Chrome Developer Console indicate?

I encountered a strange situation in JavaScript where I have a variable that I log to console.log, then increment it and log it again. The Chrome Dev Tools display the following result. This variable has shown some odd behavior, such as using the += opera ...

The issue with Grid component in Nested Single file Component

I'm currently working on creating a grid component in Vue to set up a sortable and searchable chart using Single File Component. I've also integrated vue-router into the project. Below are my two .vue files. At the moment, I can only see the sear ...

Tips for automatically redirecting a webpage to another webpage upon submission of form elements:

I'm currently working on a website where I want to integrate radio buttons as part of a form. Below is the code snippet I've been using... <form action="glitter.php" method="post"> <input type="radio" name="font" value="fonts/darkcrysta ...

jQuery Datatables provide a powerful and customizable way to display

I've been working on a project that requires me to incorporate Grid functionality into the displayed data. To achieve this, I'm utilizing the Datatable plugin from jquery. The implementation is smooth and flawless. However, a concern arises wh ...

Failure in importing a custom CommonJS module

I developed a CommonJS module in project A using the following structure: const { WebElement } = require('selenium-webdriver'); const { By } = require('selenium-webdriver'); class VlElement extends WebElement { constructor(driver, ...

Navigating through an array of latitude and longitude pairs during an AJAX request

Just starting out with PHP/AJAX and I could use some guidance. Currently, I have a leaflet map where I'm attempting to link two AJAX calls together. The initial AJAX call retrieves data based on a selected country ISO code. Subsequently, I've ut ...

Failed to cast to ObjectID due to mongoose error

Hello, I am facing an issue while attempting to add an event to a user's profile upon clicking on the event. The error message I'm encountering is "Cast to ObjectId failed for value "{ event: '600066640807165d042b91dd' }" at path "event ...

Trouble with $scope.currentPage not updating correctly in Angular UI Pagination

Recently, I've been working on this codepen project. In it, I'm utilizing the function '$scope.pageChanged' to monitor page changes. $scope.pageChanged = function() { $log.log('Page changed to: ' + $scope.currentPage); }; H ...

Exploring touch interactions using D3.js and TUIO

I'm currently facing a challenge with implementing multi-touch functionality and the d3.slider in my D3 Map. You can see the current state of my project in this video. With the d3 slider, I can spawn points and navigate around the map using touch even ...