Angle in degrees of the current perspective camera in three.js

Working on a project where I am utilizing a PerspectiveCamera that is being rotated using vrcontrols from version 69. There comes a point where I need to determine the current viewing angle degrees (both horizontally and vertically) at which direction the camera is pointed. How can I go about obtaining this information?

Answer №1

If you're looking for them, euler angles are also known as what you want. In Three.js, eulers can be easily set from a quaternion using a built-in function.

var quat = new THREE.Quaternion();
var euler = new THREE.Euler();
euler.setFromQuaternion(quat);

alert('Convert to X degrees: ' + euler.x + '\n' +'Convert to Y degrees: ' + euler.y + '\n' + 'Convert to Z degrees: ' + euler.z);

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

Refresh web content dynamically without having to reload the entire page using JavaScript

Currently, I am struggling to find a solution on how to dynamically update a section of a webpage using JavaScript when a user modifies an input field in another part of the same page. Unfortunately, my use of document.write is inhibiting me from making th ...

I'm experimenting with using jQuery toggle to switch between text and images on my webpage

I attempted to use jquery "toggle" in order to hide the div containing text and display an image instead, and vice versa. However, when I click on the button, it does not work as expected. The button is from a bootstrap example - could that be the source o ...

struggling with toggle functionality

I am encountering an issue with a list in jQuery where toggling between slim and wide side menus is affecting multiple menu items instead of just one. The toggle should only occur when the user clicks on a specific class, the "toggle-button-on" menu. How ...

Troubleshooting HTTP Response Body Encoding Problem in Node.js

When making HTTP requests with the native 'http' module, unicode characters are not displayed correctly in the response body. Instead of showing the actual value, question mark characters appear. Below is a snippet of the code that I am working w ...

Fixing the issue: "Tricky situation with JavaScript not working within Bootstrap 4's div tag while JS functions properly elsewhere"

Currently, I'm working on implementing a hide/show function for comments using JavaScript. Fortunately, I was able to find a helpful solution here (thanks to "PiggyPlex" for providing the solution on How can I hide/show a div when a button is clicked? ...

Can you explain the function of "pan" in trackball control?

Can you explain the significance of the term "Pan" in relation to trackball control in the three.js library? controls.rotateSpeed = 1; controls.zoomSpeed = .5; controls.panSpeed = 1; How would you define the concept of "panspeed" ...

Show only the selected option with jQuery's on change event and disable or remove the other options

My goal is to make it so that when a user selects an option from a dropdown menu, the other options are disabled or hidden. For example, if option "1" is selected, options "2", "3", and "4" will be removed: <div class="abc"> <div class="xyz"> ...

Using jQuery to smoothly animate a sliding box horizontally

Is there a way to smoothly slide a div left and right using jQuery animation? I have been trying to achieve this by implementing the code below, which can be found in this fiddle. The issue I am facing is that every time I click on the left or right butto ...

Menu button is expanded without the need to click

The Bootstrap 5 button extends the default behavior and does not collapse. Here is the code: <nav id="header-nav" class="navbar navbar-expand-lg navbar-light"> <div class="container"> <a class= ...

Ways to modify the text of an HTML element when hovering over it

One of my elements contains the text &times; within a <span>. Is there a way to change this symbol to something else, like &infin;, when hovered over? <span class="change-text">&times;</span> When the mouse hovers over it, I ...

React-Native introduces a new container powered by VirtualizedList

Upon updating to react-native 0.61, a plethora of warnings have started appearing: There are VirtualizedLists nested inside plain ScrollViews with the same orientation - it's recommended to avoid this and use another VirtualizedList-backed container ...

The ins and outs of implementing i18n on an Angular component library

My custom component library is not functioning properly with i18n within my module // To enable Ahead-of-Time compilation, a function must be exported for factories export function HttpLoaderFactory(http: HttpClient) { return new TranslateHttpLoader(ht ...

Ways to declare a function within the events onMouseOver and onMouseOut

<div align="right" style="border:1 #FF0 solid; background-color:#999" onMouseOver="javascript: function(){this.style.backgroundColor = '#DDD';}" onMouseOut="javascript: function(){this.style.backgroundColor = '#999';}"> Register & ...

Display or conceal div based on chosen options

I am working on a feature that involves three dropdown select boxes, each containing different sets of demographic attributes. My goal is to show a score based on the combination of selections made by the user. For example, if a user chooses Male, 18-24, A ...

Issue encountered while retrieving value from asynchronous dns.lookup() function

I am currently in the process of developing a function that validates a url by utilizing the dns.lookup() function, which is outlined below: const dns = require('dns'); const verifyURL = (url) => { const protocolRegEx = /^https?:\/& ...

Encountered a problem during the installation of tensorflowjs for node | Received an error: Command failed: node-pre-gyp install

While attempting to install @tensorflow/tfjs-node, I encountered the following error: Command failed: node-pre-gyp install --fallback-to-build. Is there a solution to resolve this issue? Below is the complete log: npm ERR! code 1 npm ERR! path E:\ ...

The Ajax call failed to complete

As part of my project, I am creating a subscription form for newsletters. To integrate the form with the MailChimp API, I am utilizing an AJAX request. The API functions correctly when tested independently. However, I encountered an issue with the AJAX cod ...

Troubleshooting: AngularJS not retrieving values from hidden input fields in ASP.NET MVC

I'm working on passing a list to a view as a hidden type and retrieving those values using Angular. for(int i = 0; i < Model.ListOfIds.Count;i++) { <input type="hidden" ng-model="model.ManagersId" value="@Model.ListOfIds[i]" /> / ...

"Exploring the depths of PHP: Generating a JSON string from an array

I am trying to work with PHP code in an Object-Oriented manner and the values I am getting are objects. However, I need to convert these O.O.P objects into JSON data for use by JavaScript. So, I converted my objects into arrays on the PHP end, but when I t ...

JavaScript function using recursion returning an undefined value

I have created a function that generates a random number and checks if it already exists in an array. If it does, the function generates a new number until a unique one is found and adds it to the array. However, I am encountering an issue where the functi ...