Is there a way to stop mouse panning in ThreeJs OrbitControls without affecting the ability to pan using keys?

My goal is to prevent users from panning with their mouse while still allowing them to pan using the keys. When I use controls.enablePan = false;, it disables key panning as well. Trying to rebind the mouse buttons requires me to assign a button to Orbit, Pan, and Zoom. How can I restrict mouse panning for users but retain the ability to pan with the keys? Disabling the mouse entirely is not an option since I still need the right mouse button for orbiting.

Answer №1

If you want to disable mouse pan, unfortunately, there is no direct option for that in the settings. The workaround is to access and modify the code in OrbitControls.js. You will need to locate and adjust the sections of the code related to mouse panning according to your requirements.

For instance, take a look at this specific line:

https://github.com/mrdoob/three.js/blob/bcd4bec92609ce8af76a590b0f281ecf71019c2b/examples/js/controls/OrbitControls.js#L703

and also consider adjusting this line as needed:

https://github.com/mrdoob/three.js/blob/bcd4bec92609ce8af76a590b0f281ecf71019c2b/examples/js/controls/OrbitControls.js#L780

Continue modifying any other relevant lines accordingly...

Answer №2

Have you attempted to adjust the mouse buttons setting?

Maybe something along these lines:

controls.mouseButtons = {
    LEFT: THREE.MOUSE.ROTATE,
    MIDDLE: THREE.MOUSE.DOLLY,
    RIGHT: ''
}

This solution worked for a similar issue I encountered in the past.

Answer №3

To deactivate the control keys, you have the option to reassign them:

this.controls.keys = { LEFT: 0, RIGHT: 0, UP: 0, BOTTOM: 0 }

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

Encountered an issue while compiling code using the Istanbul plugin

I'm currently working on generating a code coverage report for my ReactJS project using the babel-istanbul-plugin. However, when I incorporate "istanbul" as a plugin in my .babelrc file and attempt to build, I encounter the following error: ERROR in ...

Ways to extract a value from an object with no properties using jQuery

In order to perform statistical calculations like Averages (Mean, Median, Mode) on data extracted from Datatables, I need the automatic calculation to remain accurate even when the table is filtered. While I have managed to obtain the desired values, extra ...

Changing the i18n locale in the URL and navigating through nested routes

Seeking assistance to navigate through the complexities of Vue Router configurations! I've dedicated several days to integrating various resources, but have yet to achieve successful internalization implementation with URL routes in my unique setup. ...

Include a fresh attribute to a current JSON within a FOR loop

My goal is to populate a bootstrap-carousel using a more detailed JSON file pulled from a database. To illustrate, here is an example of my old JSON structure: old.json [ {"screen": [{ "img" : "../static/images/product/34.jpg", "price": "Rs 100", ...

Structures and Shader Interactions

Last Updated: August 16, 2016 After several attempts, I was finally able to trigger an error that might shed some light on the issue. While working on my latest code modification to allow hot-swapping between fragment shaders, I encountered a problem. The ...

What is the best way to ensure messages are sequentially delivered in NodeJS?

I've successfully deployed a node server responsible for updating the database with the connectivity status of IOT devices. Issue Due to the asynchronous nature of NodeJS and its single-threaded execution, there is a possibility of receiving confli ...

Using MySQL and PHP, implementing a feature that generates lines on Google Maps by fetching coordinates from a database

I have an idea to develop a navigation application where I need to draw a line connecting two points stored in a Database. The line starts from the starting point, goes through a fixed point defined in the code, and ends at the destination point. To achi ...

Utilizing the Jquery hover feature to reveal or conceal an element

My Hover function is designed to display and hide sub menus when a person hovers on them. The issue I'm facing is that the menu disappears when I move the mouse down towards it. Can someone help me identify what I am doing wrong here? ...

Tips on handling a JSON string alert

Can someone guide me on how to extract a specific value from a JSON string I received in an alert message? The JSON string looks like this: {"Error":true, "data":["not available","somethinghere"]} The JSON string is obtained from an alert using the follow ...

unable to access dropdownlist within the panel

<script type="text/javascript"> function GetSelectedValue() { var selectedValue = document.GetElementById('<%= pnSearch.FindControl("ddlFromFolders").ClientID %>').value; alert(selectedValue); } </script> ...

Acquire key for object generated post push operation (using Angular with Firebase)

I'm running into some difficulties grasping the ins and outs of utilizing Firebase. I crafted a function to upload some data into my firebase database. My main concern is obtaining the Key that is generated after I successfully push the data into the ...

Searching for an object in Vue 3 Composition API and displaying its contents

Experiencing a challenge with my first Vue.js project, seeking assistance in resolving the issue. Upon receiving a response from my API, I retrieve a list of projects and aim to locate the one matching the ID provided in the URL parameter. A peculiar error ...

Sending an HTML form to an external ASP script

I am currently attempting to create an HTML form that can submit multiple variables to an external ASP file that generates a chat window. The given example I am working with can be viewed through this link, although it involves a two-step process. In the ...

Fetching content and an image simultaneously via AJAX

My website features a photo gallery that I created using the code below: /*Begin Photo Gallery Code*/ var images = ['g1.jpg', 'g2.jpg', 'g3.jpg', 'g4.jpg']; function loadImage(src) { ...

What is the method for including an echo inside a URL call?

I am attempting to achieve the following: <?php include_once ("includes/'<?php echo $mymodule1; ?>'.php"); ?> Previously, I tried using: <?php include_once ("includes/'.echo $mymodule1.'.php"); ?> Unfortunately, it ...

Use ASP.NET MVC to pass data from an action to an AJAX call and utilize it in the success function

I have a custom ResultOfOperation class that I use to retrieve details about an activity: public class ResultOfOperation { public string Message1 { get; set; } public string Message2 { get; set; } public string Message3 { get; ...

Exploring attributes within designated namespaces using jQuery

If I have a document structured like this: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> <body> ... </body> Is there a way to extract the value of the xml:lang attribute using jQuery? I know how to select elements with ...

Click on the child element while it is already being clicked by manually implementing the 'declick' function in Javascript

Hey there, I'm looking for suggestions on a better title for this issue. I couldn't come up with the right wording myself. Problem I currently have a Google Maps element with pointer events set to none, preventing it from being scrolled when ho ...

Ajax updates previous text to new text upon successfully completing the task

I have a question regarding changing text using AJAX after success. I have written this AJAX code which is functioning properly. However, I aim to replace the old text with new text in the .chnged div. For instance: <input type="text" name="text" va ...

Is there a way to change the text (price) when I select an option?

<div class="single-pro-details"> <!--Customize in the CSS--> <h6>Home / Beats</h6> <h4>Unique Lil Tecca Type Beat - New Love</h4> <h2 id="price">$ ...