Teymooor Posted December 23, 2022 Share Posted December 23, 2022 Hi, pos : (x,y,z) k : a random value I want pos.x + k = 20 "k" must be the value that is added to the value of the pos.x to return the value of 20. Is it possible with gsap? Link to comment Share on other sites More sharing options...
GreenSock Posted December 23, 2022 Share Posted December 23, 2022 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 More sharing options...
Rodrigo Posted December 23, 2022 Share Posted December 23, 2022 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 More sharing options...
Teymooor Posted December 23, 2022 Author Share Posted December 23, 2022 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 More sharing options...
Teymooor Posted December 23, 2022 Author Share Posted December 23, 2022 It is part of a project and it is difficult to create a codepen for it. I hope the explanation is enough Link to comment Share on other sites More sharing options...
Teymooor Posted December 23, 2022 Author Share Posted December 23, 2022 20 minutes ago, Rodrigo said: tween the value of K in order to get 20 all the time? yes exactly 21 minutes ago, Rodrigo said: I assume that pos.x is always defined and static? Or is it variable as well? Its variable as well Link to comment Share on other sites More sharing options...
GreenSock Posted December 23, 2022 Share Posted December 23, 2022 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 More sharing options...
Teymooor Posted December 24, 2022 Author Share Posted December 24, 2022 The problem is solved, guys. Thank you for your time. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now