Instructions for rotating a sphere simultaneously along the x, y, and z axes

Seeking assistance on how to properly rotate an image along all three axes using the Three Js library. Currently, rotation along one axis works fine, but when attempting rotation along all three axes, the results are abnormal. I have read about using quaternions to avoid gimbal lock and tried using Euler angles without success.

sphericImageMesh_ represents my sphere object, and this.getRollDeg() is a method to retrieve the roll angle indicated by the camera.

My attempted solution is shown below:

// var euler = new THREE.Euler( - THREE.Math.degToRad(this.getRollDeg()), - THREE.Math.degToRad( this.getHeadingDeg()) , - THREE.Math.degToRad(this.getPitchDeg()), 'XYZ' );
// this.sphericImageMesh_.setRotationFromEuler(euler);

// this.sphericImageMesh_.rotateZ(THREE.Math.degToRad(-this.getPitchDeg()));
// this.sphericImageMesh_.rotateX(THREE.Math.degToRad(-this.getRollDeg()));
this.sphericImageMesh_.rotateY(THREE.Math.degToRad(-this.getHeadingDeg()));

I have read about using Quaternions and MatrixX4, but I am unsure how to implement them. Any assistance on this matter would be greatly appreciated.

Answer №1

If you want to tweak the rotation behavior, consider changing the order of rotations. While the default is XYZ, you might find that YXZ or YZX makes more sense to you. Try using n.rotation.order('YXZ'); and see if it aligns better with your expectations. Especially in a flightsim scenario where +Z represents forward movement, this approach can feel more natural. Remember: yaw, then pitch, then roll.

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

Function compilation did not succeed in the module

I've put together a MERN (MongoDB, ExpressJS, React, Node) project using express-generator (express myNewApp). Within a react component, I have implemented this ES6 code snippet: onChange = (event, { newValue }) => { // Line 53 this.setSt ...

TypeScript raises an issue with a Vue component property that has been defined using vue-property-decorator

I have a Vue component with a property defined using a decorator: import { Component, Vue } from "vue-property-decorator" @Component({ props: { myId: String, }, }) class TestProp extends Vue { myFuncti ...

Assign an array value to the input based on the selection made in Javascript

After finding a lot of useful information in previous questions, I am struggling to get the last piece that I need. My PHP code helps me loop through form fields and assign unique names to each field using a variable. One of these fields is for "expense ty ...

Error message: Unspecified service injected

I am currently working with 2 separate javascript files for my project. One is being used as a controller, while the other serves as a service. However, when I attempt to inject the service into the controller and access its function, an error message pops ...

Setting a Javascript value to a Controller variable within an ASP.NET MVC View

I am trying to set the javascript variable contentArea to match content.Contents in my controller. How can this be accomplished? <script language="javascript" type="text/javascript"> $("#btnTest").click(function () { var content ...

Challenges surrounding jQuery's .before

Currently, I am in the process of creating a simple carousel consisting of 4 divs. The carousel is utilizing 2 jQuery functions to position a div at either the first or last slot. The transitions being used are only alpha transitions as there is no need fo ...

When using Next JS with StoryBook, an error may occur if styles are written in a module.scss file

Every time I try to add some styles to my ButtonWidget.scss file, I encounter an error in the console when running the command yarn storybook Error Code: ERROR in ./src/components/ButtonWidget/ButtonWidget.module.scss 1:0 Module parse failed: Unexpected ...

Unable to receive the expected response within the Ajax success callback

I'm new to PHP and WordPress and I'm using an Ajax call to submit form information. I want to display a "Thank you" message within a <div> element as a response. Although I can execute the function in function.php, I'm not receiving a ...

Having trouble loading multiple JSON files with three.js

I have been using the loadmodel function to import JSON files into HTML. These JSON files were exported from Blender. (function init(){ console.log("Init") loadmodel('object1'); loadmodel('object2'); loadmodel('ob ...

Guidelines on Transferring Variables to a JavascriptExecutor Script

Currently, I am utilizing C# and Selenium to browse through a website and have come across an issue regarding passing variables into my JavaScriptExecutor command. When I attempt to do so using the code below: ((IJavaScriptExecutor)webdriver).ExecuteScript ...

Tips for accessing information from a FOR loop within DIV tags

Let's explore the following code snippet: Here is the HTML generated: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Website ...

The rotation of the Torus object in Three.js is not centered around the 0z axis

Attempting to rotate a torus along 2 axes: Ox and Oz. The goal is to apply this rotation with a slider from dat.gui that is modified by mouse input. The torus is defined as follows: var geometryTorus = new THREE.TorusGeometry( radius, 2*widthLine, 100, 1 ...

Vue.js app does not have the capability to display JSON data as a table

I successfully fetched JSON data in my vue app from the endpoint '/v1/api/sse?raceId=1', but I'm struggling to convert this JSON into a table format. The JSON is displaying correctly, but I'm unsure how to structure it into a table. He ...

Showing information at succeeding intervals with AngularJS

Check out the jsFiddle link provided for AngularJS data display: AngularJS : Display Data Here is a sample of the HTML file: <div ng-controller="myCtrl"> <div ng-repeat="test in tests"> <p>{{test.testName}}</p ...

Displaying information in form using ajax within the laravel framework

I am currently utilizing ajax to retrieve data from a database. While I am able to successfully retrieve the data on the backend, I am facing difficulties displaying it in the input field below. I have tried writing some code, but it seems that the JavaScr ...

Empower the user with the ability to interact through touch on dynamically

I am trying to make a div touchable and draggable. I have dynamically created 1 to 10 divs within another div. Currently, these divs can only be dragged using the mouse or cursor. However, I want to enable dragging through touch as well. Can anyone provi ...

Create a loop in Vue.js 3 without the need for a query

Can someone help me understand how to fetch data using a loop in Vue.js version 3 when working with queries? I am trying to retrieve an object based on its id, which is obtained from the URL. However, I seem to be facing some difficulties. Any guidance wou ...

Validation of AngularJS dropdown selection must be completed before submitting the form

I have a Dropdown list within my form and I want to disable the submit button until an element is selected from the list. Here is my button: <input type="submit" value="Get" ng-disabled="form.$invalid " /> I attempted to implement the solution foun ...

What could be causing my React app to consistently reload whenever I save a file in my project?

Hi there, I am currently working on a project using React, GraphQL, Node, and MongoDB. I have been trying to upload images to a folder within my app, but I am facing an issue with the app reloading after saving the file. I attempted to manage a local state ...

I'm getting a JS error saying that the variable "var" is not defined. Does anyone know how I can

Here is the code I am using to dynamically create a sitemap.xml file when accessing /sitemap.xml database = firebase.database(); var ref = database.ref('urls'); ref.on('value', gotData, errData); function errData(err){ ...