Uneven rotation of objects within the browser

I am currently working on visualizing objects in a web browser. The goal is to display these objects rotating around one axis at a time (either X, Y, or Z) or allow the user to interactively rotate them using their mouse. However, I have encountered several issues that need to be addressed:

1- When I enable auto-rotation of the object along a single axis, it initially rotates smoothly but after some time, the rotation becomes discrete with abrupt changes (approximating 180-degree increments).

2- Rotating the object using the mouse results in a non-smooth experience, likely due to the frequency of mouse events being fired.

3- Is there a way to implement dual-axis rotation for the object using the mouse? Specifically, around both the Y and X axes simultaneously.

4- I have attempted to confine the view window within a small div, however, the rendered output exceeds the boundaries of the specified container.

Below is the code snippet I am currently using:

<script>
    // Code snippet goes here...
</script>

I appreciate any insights or assistance regarding the mentioned issues. Thank you!

Answer №1

In order to resize the window, you can adjust the element styling by specifying the desired height and width values:

renderer.domElement.style.width = '100px';
renderer.domElement.style.height = '100px';

If you need mouse control and rotation functionality, check out the examples provided on threejs.org (particularly in the 'canvas' section):

  • Mouse Control Example
  • Additional Mouse Control Demo

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 connect to the express.js/passport.js API using an Android device as the client

Trying to access an express.js API created with node.js and passport.js. Certain methods only work when the req.user is available. Attempting to log in with Facebook and Twitter from my client app results in a plain cookie being returned. The cookie look ...

When combining React and ReactDOM with browserify, the resulting bundle size exceeds that of react.min.js and react-dom.min.js

I'm currently working through the React beginner's tutorial and things are going smoothly so far. However, I decided to delve into importing external packages and began using tools like npm, browserify, watchify, etc. In the tutorial, there is a ...

Displaying JSON data within a div section using Ajax and jQuery is not possible

I have generated a JSON in a specific format from an external PHP file: [ { "title": "Welcome!", "description": "The world has changed dramatically..", "image": "img/strawberry-wallpaper.jpg" } ] I am trying to use this data to populate a par ...

Every time a new modal is opened, the Bootstrap modal within the code seems to magically multiply itself

Hey there! I recently implemented a room password validation feature for the chat application I developed. To display the password input to users, I utilized Bootstrap's 4 modal. https://i.sstatic.net/4wJQp.png The modal is triggered using jQuery wi ...

Angular - How child components can communicate with their parent components

I'm struggling to understand how to communicate between components and services. :( Even though I've read and tried a lot, some examples work but I still don't grasp why (?). My goal is to have one parent and two child components: dashboa ...

Why is it that this specific ASP.NET + jQuery + JavaScript custom MVC setup isn't displaying any content?

After attempting to incorporate this JavaScript MVC example from into an ASP.NET page, I am facing issues as a beginner with jQuery. Nothing seems to show up on the page, and I'm unsure why. Update: I have included the missing HTML listbox, but now ...

Error in Javascript programming | tracking progress bar

After stumbling upon this code snippet at this link, I was eager to delve deeper into the world of JavaScript and jQuery. However, upon implementing these codes, I encountered a perplexing issue. The progress bar and continue buttons seem to be non-funct ...

Displaying hyperlinks within a table that is contained within a div on the current webpage

I have created an HTML page that looks like this: <!DOCTYPE html> <html> <body bgcolor="#EBF5FB"> <h1 align="center">SLA Monitor Reports </h1> <div id="link" align="center"> <table cellpadding="25px" bord ...

Show the loader animation until the browser's loading icon stops spinning

My website receives a high volume of traffic and pulls data from several servers to display on the page. It typically takes 3-4 minutes for the entire page to finish loading. Here is a preview of some of the partial page data: https://i.sstatic.net/br4sr. ...

Searching for repeated values across disparate object fields?

Inquiring about the method to utilize mongoose for identifying duplicate values across different fields. Providing a sample document for reference: { "followers": { { "_id": "5bf6d610d3a3f31a6c75a9f4" }, ...

What is preventing the angular.bootstrap code from functioning properly in AngularJS versions prior to V1.6?

Can someone explain why when using the URL http://code.angularjs.org/snapshot/angular.js everything works fine in my code within the <script> tag, but when I switch to https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js, Angular does ...

Guide to setting up ajax to parse the text input and generate a table

Strange dilemma I've been grappling with for the past couple of days. Definitely a novice at this. Here's my code: $(document).ready(function() { var table = $('#table1').DataTable({ "ajax" : { url ...

Making an Axios call to retrieve data from VUEX storage

Is it common practice in the Vue.js (Nuxt.js) development community to send data to the server from a VUEX storage using code similar to this example? setTrackingData (state, value) { state.to_the_final_destination = value.to_the_final_destination; con ...

JavaScript: Troubleshooting Array Formatting

Seeking assistance with formatting this JavaScript array accurately. It seems like I am overlooking something crucial: Javascript: <script type="text/javascript"> var dimensions = new Array("225","320","480", "--"); var walls = new Array() ...

Unexpected behavior found in certain parts of jquery due to the implementation of Ajax

Every time I try to use the ajax code on the same page or an external .js file, it seems to cause issues and prevents other parts of the code (jquery) from functioning properly. The ajax should only trigger when clicking on a specific li element with the c ...

Trying to update the +/- icon on an accordion dropdown, however, the local HTML file is not loading the JavaScript file. (Using Bootstrap 4)

I'm completely new to JS and struggling a bit, so please be patient. I've been searching online for a few days now without much luck. I'm using Bootstrap 4 and trying to create an accordion with a +/- icon that changes when expanded or colla ...

The form does not allow for editing in the input fields

I am experiencing an issue with my simple form where I can only click and type into the input fields below the menu. The CSS and JS in this snippet may be a bit all over the place, but it closely resembles my app's structure. I'm baffled by why t ...

What is the process of intersecting a 3D object in THREE.js when provided with a coordinate pair (X, Y)?

Is it possible to determine if points within a scene with (X, Y) coordinates intersect a specific object using the RayCaster in Three.js? Additionally, how can we find out the updated (X, Y, Z) coordinates after the intersection has occurred? ...

Filtering MUI Data Grid by array elements

I am in the process of developing a management system that utilizes three MUIDataGrids. Although only one grid is displayed at a time, users can switch between the three grids by clicking on tabs located above. The setup I have resembles the Facebook Ads ...

Extracting multiline value from a textarea using JavaScript

I'm trying to extract a multiline value from a textarea using JavaScript or jQuery and store it in a cookie. Below is the code snippet I am using: HTML: <textarea id="cont" cols="72" rows="15"> JavaScript: var txt = $('#cont').val( ...