Does TweenJS consistently begin at 0?

I'm currently working on a threejs project and I have encountered an issue with rotating a plane using tween. The problem is that the tween always starts at 0, despite having the correct initial value (a) when checked in the console.

For instance,

When I attempt to create a tween from 40 to 60, the code seems to be disregarding the starting point and going from 0 to 60 instead.

a = {rotationY:plane.rotation.y};
b = json["rooms"][currentRoom]["camera"]; //{"rotationY":60}
var tween = new TWEEN.Tween(a)
        .to(b, 500)
        .easing( TWEEN.Easing.Quartic.Out )
        .onUpdate(function(){
            plane.rotation.y = (this.rotationY*2*Math.PI)/360;
        });

tween.start();

Answer №1

I made such a foolish mistake...

var position = {rotationY:(plane.rotation.y*360/(2*Math.PI))};
var target = json["rooms"][currentRoom]["camera"];
var tween = new TWEEN.Tween(position)
            .to(target, 500)
            .easing( TWEEN.Easing.Quartic.Out )
            .onUpdate(function(){
                plane.rotation.y = (this.rotationY*2*Math.PI)/360;
});
tween.start();

The tween had the initial value in radians and the target set in degrees...

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

Unexpected addition of values to a list occurs when scrolling through a web element using Selenium

Having recently delved into Python, as well as programming in general, I am eager to extract data from a webelement that updates dynamically with scrolling using Selenium. A particular post on Stack Overflow titled Trying to use Python and Selenium to scro ...

Retrieve both positive and negative reviews using the Steam API

I'm trying to calculate the percentage of positive reviews, but I haven't been able to find the necessary data. I've been using this endpoint to retrieve game information: "", but it only provides the total number of reviews. I am aware of a ...

Filtering data in Vue.js using JSON specifications

How can I display only the names in the data? I currently have cards filtered by cities <div v-for="item in stationCityData"> <div v-for="option in filteredCity" style="background:#eee;padding: 20px"> <!-- <div v-for="option ...

In dire need of assistance with dividing an array into a menu using JavaScript before my brain implodes

With the usage of Javascript, I am dealing with an array structured as follows: [{"id":171, "children": [{"id":172}, {"id":170}, {"id":173}]}, {"id":174}, {"id":175}] This array is created from a nestable jQuery list. Now, I have the require ...

Managing media file transfers using multer and mongodb in a Node.js environment

As I work on developing a blog-style application for a business website, I have successfully implemented a login system and a basic blog structure. My current focus is on enabling users to upload images along with their blog posts. At the moment, I am trou ...

Tips for postponing the execution of following tasks until the completion of the setState and ensuring that they are reliant on

I'm encountering an issue with the useEffect hook in my React app that uses useState. Here's the code snippet: const [jobTypes, setJobTypes] = useState([]); const getJobTypes = async () => { try { const response = await fetch(&a ...

What is the reason behind V8's perplexing error notification?

When running this code on Chrome or Node (v8), an error message is displayed: Uncaught TypeError: f is not iterable function f(){} f(...undefined); Why is such an ambiguous error message generated in this case? Does it really have nothing to do with ...

Node.js application experiencing bug with End of Line (EOL) not displaying correctly

I've encountered an issue with my node.js application that involves writing the following code: word_meaning = 'line 1' + os.EOL +'line 2'; When attempting to render this in an HTML file using the following code: <p> <% ...

Reducing the number of DOM manipulations for websites that heavily utilize jquery.append

Here's a snippet of my coding style for the website: !function(){ window.ResultsGrid = Class.extend(function(){ this.constructor = function($container, options){ this.items = []; this.$container = $($container); ...

Tips for avoiding an automatic slide up in a CSS menu

Is there a way to disable the automatic slide-up effect on my CSS menu when clicking a list item? I have tried using stop().slideup() function in my JavaScript code, but it doesn't seem to work. Additionally, I would like to highlight the selected lis ...

Can an identification be included in a label element?

My inquiry is as follows: <label for="gender" class="error">Choose</label> I am interested in dynamically adding an id attribute to the above line using jQuery or JavaScript, resulting in the following html: <label for="gender" class="err ...

Delayed Page Update: Click Event Doesn't Execute Correctly Without JQuery

I'm a beginner in JavaScript and unable to use JQuery I have a table and I want to highlight the selected row on the click event. At the same time, I need to change the value of an input field. However, when I click on a row, the highlight effect get ...

Setting a Value?

Within the services.js/Cordova file, I am encountering an issue with the following code: .factory('GCs', ['$http', function($http) { var obj= {}; $http.post("mydomina.com?myrequest=getbyid", { "id": "1"} ) ...

Is there a way to include multiple TinyMCE editors with unique configurations for each one?

Is it possible to incorporate multiple TinyMCE editors on a single page, each with its own distinct configuration settings? If so, how can this be achieved? ...

Using HTML and JavaScript allows for the video URL to seamlessly open in the default video player app on the device

Working on my mediaplayer website, I want to give users the option to choose which app to play their uploaded videos with. So far, I've attempted to implement a button that triggers this action: window.open("video.mkv", '_blank'); Howeve ...

Adjust the positioning of axisLeft labels to the left side

I have incorporated a @nivo/bar chart in my project as shown below: <ResponsiveBar height="400" data={barData} keys={["value"]} indexBy="label" layout="horizontal" axisLeft={{ width ...

Semantic UI (React): Transforming vertical menu into horizontal layout for mobile responsiveness

I have implemented a vertical menu using Semantic UI React. Here is the structure of my menu: <Grid> <Grid.Column mobile={16} tablet={5} computer={5}> <div className='ui secondary pointing menu vertical compact inherit&apos ...

Pop-up message on card selection using JavaScript, CSS, and PHP

I have a total of 6 cards displayed in my HTML. Each card, when clicked, should trigger a modal window to pop up (with additional information corresponding to that specific card). After spending a day searching for a solution online, I've come here s ...

Error detected in ASP.NET MVC due to a Javascript runtime issue

After creating a new ASP .net mvc 2 web application using the default template in Visual Studio 2008, I wanted to test how the document.ready function fires. In the Site.Master file, I included the jQuery Scripts in the following manner: " <script src ...

Receive alerts in Swift from WKWebView when a particular screen is displayed in HTML

Check out this sample HTML file I have. I'm currently using the WKWebView to display this HTML. My goal is to receive a notification in our Swift code when the user finishes the game and the "high score" screen appears, so we can dismiss the view and ...