Adjusting the orientation of the camera's `up` vector within the Three.js

I am incorporating components of the Three.js Editor into my current project.

Recently, I adjusted the z-axis to serve as the camera.up element, following the instructions provided here and illustrated in the image below.

Issue

The behavior of my EditorControls has become erratic when executing rotations, presumably due to its failure to consider the camera.up. How can I update the class to factor in camera.up during rotations?

Below is the rotate function:

this.rotate = function ( delta ) {
    vector.copy( object.position ).sub( center );
    var theta = Math.atan2( vector.x, vector.z );
    var phi = Math.atan2( Math.sqrt( vector.x * vector.x + vector.z * vector.z ), vector.y );
    theta += delta.x;
    phi += delta.y;
    var EPS = 0.000001;
    phi = Math.max( EPS, Math.min( Math.PI - EPS, phi ) );
    var radius = vector.length();
    vector.x = radius * Math.sin( phi ) * Math.sin( theta );
    vector.y = radius * Math.cos( phi );
    vector.z = radius * Math.sin( phi ) * Math.cos( theta );
    object.position.copy( center ).add( vector );
    object.lookAt( center );
    scope.dispatchEvent( changeEvent );
};

Answer №1

Altering the coordinate system according to the illustration is more complex than simply adjusting an up-vector. To achieve the desired outcome depicted in the image, three.js would need to utilize a left-handed coordinate system instead of its current right-handed one. Unfortunately, it's not possible to transition from one type to another through a simple rotation.

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

Show vimeo videos using ng-repeat angularjs and videojs player

I need help trying to showcase videos using angularJS. Below is the code I have: <span class="video-inner" ng-repeat="item in items"> <video id="video-{{item.id}}" class="video-js vjs-default-skin" controls preload="au ...

The output date from momentjs's toDate() method may differ from the date formatted using format()

Currently, I am utilizing moment 2.16.0 and I am interested in obtaining the starting days of the month. I have noticed that there are varying results when using the toDate() and format() methods. To see a demonstration, you can check out this jsfiddle. E ...

Column reverse flex-direction is functioning correctly, however, it is imperative that it does not automatically scroll to the bottom

I have a Flexbox set up where I need the contents to display in reverse order. Everything is working well, but the list has many items and the newest ones are appearing at the top. Currently, the Flexbox automatically scrolls to the bottom, but I want it t ...

Setting document expiration with MONK: A step-by-step guide

I recently went through the MongoDB documentation to understand how to set a Time To Live property for expiring documents. The documentation explains: In order to expire data after a certain number of seconds have passed since the indexed field, you ne ...

Tips on stopping or unbinding a previous $watch in AngularJS

Currently, I am utilizing $watch in a dynamic manner which results in the creation of another $watch on each call. However, my intention is to unbind the previous $watch. $scope.pagination =function(){ $scope.$watch('currentPage + numPerPage', ...

Disable the border and background colors in CloudFlare Turnstile

I have implemented the CloudFlare reCaptcha Turnstile and I am looking to modify the widget by removing the border and background color. I believe this customization can be achieved using CSS or Javascript. Thank you for any assistance! ...

Error message: Unable to locate "store" in React-Redux

I recently started learning web development and I'm facing challenges with understanding react, redux, express, and single-page routing. I apologize if I'm overlooking a simple solution. The error message I see in the server console is: Invarian ...

Insert fixed text before or after the input value without altering the value itself

Is it possible to prepend or append additional text to an input value? I am looking to customize the display of a value without altering the actual value itself. For instance, if the value is 1000, I want it to still return 1000 when accessed. <input ...

Is the next function triggered only after the iframe has finished loading?

First and foremost, I understand the importance of running things asynchronously whenever possible. In my code, there exists a function known as wrap: This function essentially loads the current page within an iframe. This is necessary to ensure that Jav ...

Error Message: "Angular Mocks and Jasmine encountered an issue: 'fn' is not a function, instead got Object"

I'm encountering a problem when it comes to unit testing in Angular using Angular-Mocks, Jasmine, and CoffeeScript. The issue lies within this code snippet: 'use strict' describe 'sample suite', -> beforeEach inject(($ro ...

Extract the names and corresponding keys from an array, then display them as a list

I am currently working on extracting key names and sub key names from a file in order to display the results in a list format as shown below. Anna was removed by AdminWhoRemoved due to Removal Reason Ethan was removed by AdminWhoRemoved due to Removal Re ...

Incorporating a navigation bar into my Jade template

I am working with nodejs, express, and bootstrap for my project. While this may seem like a basic question, I have been unable to find the specific solution I need. My issue lies in the fact that I have a layout.jade file and an index.jade file, with the ...

Utilizing jQuery's then() method to display HTML and JSON outputs from printing operations

Currently, I am in the process of mastering jquery deferreds. When working with html on jsfiddle, I receive an object that contains two lines when printed within the then() statement: "success" and the html returned by the ajax request. For instance, upo ...

How to use v-if in Quasar framework to hide a Vuejs component on the signup page

Currently, I am utilizing the Quasar drawer feature in my application. On the signup view, I would like to hide the drawer. While my current code successfully hides the drawer, an issue arises when I reload the signup page as it briefly renders in the DOM ...

Oops! Looks like we have encountered an issue with reading the property 'checked' of nothing

Whenever I click the checkbox, an image should be displayed. Unfortunately, I encountered an error: Uncaught TypeError: Cannot read property 'checked' of null at (index):185 at dispatch (VM576 jquery.min.js:3) at i (VM5 ...

Show data retrieved by an AJAX call in a user interface

Through an ajax call, I successfully retrieved data from active directory. The PHP file used for this ajax call to active directory can be found here. Upon inspecting the browser console, the ajax call output includes information such as sn, givenname, e ...

Validating an Element Directive in AngularJS: A Step-by-Step Guide

I have developed a directive for handling numbers function numberInputDirective() { return { restrict: 'E', scope: { model: '=', disabled: '=?', decimals: ...

Creating various objects through an existing object in javascript: A step-by-step guide

I have an object that looks like this: { "Distrubutor":"DISTRIBUTOR1", "INCLUDE":"INDIA,United States", "EXCLUDE":"KARNATAKA-INDIA,CHENNAI-TAMILNADU-INDIA", "PARENT-ID":"" } I am looking to generate multiple objects based on the INCLUDE p ...

The act of delegating ngshow and nghide functionality

check out this demo: http://plnkr.co/edit/EWOvKsTEutiveMEAGTKf?p=preview <li ng-show="showList" ng-repeat="task in tasks" ng-hide="task.checked=1"> {{task.name}} </li> Is it possible to use ng-show and ng-hide together on the same element? ...

Removing duplicate entries from a dropdown menu can be achieved by implementing

As a newcomer to the world of PHP PDO, I've learned that the database connection should be in a separate PHP file. However, after spending an entire day trying different things, I'm still facing issues. I suspect that the duplicate entries are a ...