Sanprieto Posted October 21, 2020 Share Posted October 21, 2020 First of all congratulations, GSAP is extraordinary !! I'm beginner in this. I would like to access to time's property ( duration tween ) in onUpdateParam() Something like this : this.parent._time (And I can't find the main object here... ) Link to comment Share on other sites More sharing options...
Solution akapowl Posted October 21, 2020 Solution Share Posted October 21, 2020 Hey @Sanprieto - welcome to the forums. There is .time() Is this what you're looking for? See the Pen 3cd383d2720957175420d81d625935ec by akapowl (@akapowl) on CodePen 4 Link to comment Share on other sites More sharing options...
ZachSaucier Posted October 21, 2020 Share Posted October 21, 2020 Just noting that this refers to the tween in an onUpdate if you don't use an arrow function so you don't need a variable reference to the tween: onUpdate: function() { console.log(this.time()); } 3 Link to comment Share on other sites More sharing options...
Sanprieto Posted October 21, 2020 Author Share Posted October 21, 2020 On 10/21/2020 at 4:28 PM, akapowl said: Hey @Sanprieto - welcome to the forums. There is .time() Is this what you're looking for? Totally yes !! Thank you so much. following your example, can you access to 'box' in onUpdate ? Link to comment Share on other sites More sharing options...
Sanprieto Posted October 21, 2020 Author Share Posted October 21, 2020 12 minutes ago, ZachSaucier said: Just noting that this refers to the tween in an onUpdate if you don't use an arrow function so you don't need a variable reference to the tween: onUpdate: function() { console.log(this.time()); } okay thanks for advice!! Link to comment Share on other sites More sharing options...
ZachSaucier Posted October 21, 2020 Share Posted October 21, 2020 3 minutes ago, Sanprieto said: can you access to 'box' in onUpdate ? Sure. onUpdate: function() { console.log(this.time(), this.targets()[0]) } 2 Link to comment Share on other sites More sharing options...
Sanprieto Posted October 21, 2020 Author Share Posted October 21, 2020 3 minutes ago, ZachSaucier said: Sure. onUpdate: function() { console.log(this.time(), this.targets()[0]) } I'm working with three.js and the object is a mesh and with gsap animation the position. But I want to access to the mesh ( 3D object) gsap.to( object3D.position, { duration: 10, motionPath: { path: gsapPath, type:'cubic', },onUpdate: this.runGsap, onUpdateParams: [ object3D, this.startHSL, this.sizeHSL, 10 ] }) I pass like parameter object3D in onUpdateParams but I think It isn't necessary. In this case with targets[0] I have the vectors of position. Link to comment Share on other sites More sharing options...
Sanprieto Posted October 22, 2020 Author Share Posted October 22, 2020 21 hours ago, Sanprieto said: I'm working with three.js and the object is a mesh and with gsap animation the position. But I want to access to the mesh ( 3D object) gsap.to( object3D.position, { duration: 10, motionPath: { path: gsapPath, type:'cubic', },onUpdate: this.runGsap, onUpdateParams: [ object3D, this.startHSL, this.sizeHSL, 10 ] }) I pass like parameter object3D in onUpdateParams but I think It isn't necessary. In this case with targets[0] I have the vectors of position. I guess GSAP is animating the property's position of the object. It isn't a problem to pass object like parameter. Thank you very much for your answers !!!! 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