Jump to content
Search Community

gsap value

Teymooor test
Moderator Tag

Recommended Posts

Hi @Teymooor. I read your question 4 times and I'm still unsure what you're asking. Maybe I'm missing something obvious. Do you just want to read the current "x" value of a particular element so that you can find out how far away from 20 it is (determine "k")? Where does the randomness come in? 

 

It would significantly improve your chances of getting a good answer if you provide a minimal demo (a CodePen) that illustrates what you're trying to do. 

Link to comment
Share on other sites

Hi,

 

I'm a bit confused by your question. That is basically a super simple algebra equation. What exactly you want to do, tween the value of K in order to get 20 all the time? I assume that pos.x is always defined and static? Or is it variable as well? Or you want to animate pos.x as well? How are you planning on using GSAP with this. Keep in mind that GSAP can tween any numeric value of any object you pass to it (and some CSS spcecific strings as well).

 

As you can see your question creates a whole new set of questions, which makes helping you a bit difficult. Please try to provide a minimal demo in order to get a better idea of what you're trying to do.

 

Happy Tweening!

Link to comment
Share on other sites

The number indicates the location of the camera. (threejs) This value is changing, But its number (x,y,z) is always known, the value of 'pos.x' is always less than 20.
I want to create a variable number that will always be 20 when added to the value of 'pos.x'.

For example, if 'pos.x' is 12, 8 should be added to it to get 20.
k is 8 in this situation.

Link to comment
Share on other sites

I'm still totally lost, sorry - Rodrigo seems right, that it's a very basic algebra thing, unrelated to GSAP. What are we missing? Can't you easily calculate that number by doing 20 - pos.x? 

 

If you want to tween the value of k, wouldn't you just calculate what the end needs to be based on the current value, and plug that into the tween? Again, a very minimal demo would be EXTREMELY helpful. It doesn't even need to use Three.js. Literally a generic JS object with one or two properties is fine, and console.log() whatever...SUPER simple. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...