Exploring the spinning globe using ThreeJS

Is there a way to rotate an object in three-dimensional space using THREEJs?
I've been trying the code below but it doesn't seem to work. Can anyone spot what I might be doing incorrectly?

object.matrixAutoUpdate = false;
const matrix = object.matrixWorld.makeRotationFromQuaternion( worldQuaternion );
object.setRotationFromMatrix( matrix );
object.updateMatrix();

Answer №1

To obtain the ultimate local rotation, simply deduct the parent's rotation.

const parentQuatInvert = object.parent.getWorldQuaternion(new Quaternion()).invert();
object.quaternion.multiplyQuaternions(worldQuaternion, parentQuat);
// make sure to update the matrix and other related elements.

If the parent happens to be non-existent, you can directly assign the quaternion using

object.quaternion.copy(worldQuaternion)

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

Can this pagination task be accomplished without the use of backgrid?

I have been exploring ways to implement server-side pagination similar to what Datatables offers, and during my search I came across the backbone.paginator library on GitHub. However, I am curious if there are any other options available as well. After ex ...

Manipulating lines and positions with jQuery

I am looking to implement a feature that allows users to choose a specific region on an image using jQuery. The functionality should be similar to the tagging feature on Facebook, but with the added bonus of being able to rotate and scale the selected area ...

Enabling the source map option for the TerserWebpackPlugin webpack plugin has a noticeable impact on the overall build time of webpack

I've made the decision to enable source maps for production. Utilizing TerserWebpackPlugin for minifying my js files, as suggested by webpack documentation. This plugin includes a config option for sourceMap, which according to the docs, should be ena ...

Tips on concealing the loading image once the d3 chart has finished loading

$(document).on('click', '.tbtn', function(e) { $('#loading-image').show(); if(error){ $('loading-image').hide(); else{ val = $('.barbtn input:checked').val(); draw_summary($.parseJS ...

Steps for toggling the visibility of an input field of type text upon clicking a button

message button <div id="messagebutton" class="btn4 like" style="margin-top:-25px;margin-left:-10px;"> <span class="btn reply" id="messageb">Message</span> </div> text box <div class="col-lg-12" style="background:#eff9c7;" ...

Can WireMock be used to send an HTML file as a response?

Is it possible to return an HTML file as a response in WireMock and how can this be achieved? ...

Import Image Data into AngularJS

I've got a dilemma with downloading images from a browser into a zip file using JSZip. I have a list of image URLs from the server, and I'm trying to use the jszip library to create a zip file. Here's what I attempted: var img = zip.folder( ...

Ways to show a corresponding number beneath every image that is generated dynamically

I have a requirement to show a specific image multiple times based on user input. I have achieved this functionality successfully. However, I now need to display a number below each image. For example, if the user enters '4', there should be 4 im ...

Using PHP code to pass a value to JavaScript

I have both PHP and JavaScript code on my page, and I need to retrieve a value from PHP into my JavaScript code. Below is my JavaScript code: <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "Bread ...

Updating database through AJAX calls does not work

I'm currently developing a system that requires the ability to remove employees from their Saturday shifts. This process involves clicking on an icon that triggers the JavaScript function "removeEmpFromSaturday" and passes relevant parameters. Within ...

Utilizing a variable beyond the confines of the script tag

Is there a way to assign the value of my variable place to my variable address, even though they are not in the same script tag? I want to bind the value and utilize it for fetching data. When I log my variable place, I can see the address, but I am unsure ...

A pair of HTTP GET requests

How can I ensure that data is retrieved from a.json before moving on to b.json and then running the init function, given 2 JSON urls? var urlA = "a.json"; var urlB = "b.json"; This is my approach: var app = angular.module('calendarApp', []); a ...

Filtering out strings of a certain length from an array in JavaScript

Currently working on creating a Wordle game using React. To do this, I require a list of strings. To obtain this list, I am fetching an array of strings from the following API: The challenge lies in the fact that I am interested only in words with a lengt ...

Angular - Collaborative HTML format function

In my project, I have a function that sets the CSS class of an element dynamically. This function is used in different components where dynamic CSS needs to be applied. However, every time I make a change to the function, I have to update it in each compo ...

Error: The function openCity() has not been defined

I'm currently working on creating a form that will allow me to store images into a PostgreSQL database. The database contains a single table with two fields: ID and IMG, which is of type bytea. The page has 2 tabs, and I have a function called 'o ...

Executing a Callback in Node with Redis Publish/Subscribe

Is it possible to implement callback with the PubSub design pattern in Node Redis? For example: server.publish("someChanel", someData, function(response) { // Expecting a response from client }); client.on('message', function(channel, data, ...

Trouble disabling specific days of the week in Meteor's Bootstrap3 datetimepicker

Currently, I'm utilizing bootstrap 3 within a meteor project and I have a requirement to deactivate most of the days of the week in a datetime picker. Although the other options I've configured appear to be functioning correctly, the daysOfWeekD ...

Implement a button transformation upon successful completion of a MySQLi update using AJAX

When displaying multiple database results with buttons that can be turned on or off inside a div, I am looking to implement AJAX to toggle the button state between ON and OFF upon clicking, and then update the button without refreshing or reloading the ent ...

Articles related to Express.js - encountering issues when attempting to read properties from a null object

I'm trying to display related articles based on categories using Mongoose for querying data from MongoDB. However, when I attempt the code below, I encounter an error message stating "TypeError: Cannot read properties of null (reading 'category& ...

React-Native-SVG encountered an error: Invariant Violation - the component "RNSVGGroup" could not be found in the UIManager

Trying to create an SVG in React-Native using react-native-svg. I have set up a React-Native-CLI. After doing some research, I attempted to solve the issue on my own and found something useful. I tried running cd ios && pod install. I wasn't ...