JackFalcon Posted July 25, 2018 Share Posted July 25, 2018 Hi. Too easy. Anyone have a link to an example of how to deregister a beforeRender or afterRender callback? looking for a good pattern... Or unregister...? Thx. Quote Link to comment Share on other sites More sharing options...
JackFalcon Posted July 25, 2018 Author Share Posted July 25, 2018 Ok, maybe got it... scene.unregisterAfterRender(unregister); Quote Link to comment Share on other sites More sharing options...
JackFalcon Posted July 25, 2018 Author Share Posted July 25, 2018 Here it is (in a nice little pattern): scene.registerBeforeRender(function someCallback() { if(done){ scene.unregisterBeforeRender(someCallback); } }); solved. Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 25, 2018 Share Posted July 25, 2018 If you only need it to run once, it's built-in. Your example will run for each render until 'done', so it's obviously different: https://github.com/BabylonJS/Babylon.js/blob/master/src/babylon.scene.ts#L2393 I mention this, because of the part you may find interesting; where it wraps the original function call into a variable for deregistration: https://github.com/BabylonJS/Babylon.js/blob/master/src/babylon.scene.ts#L2376 JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted July 26, 2018 Share Posted July 26, 2018 Or even better: Quote scene.onBeforeRenderObservable.addOnce(function() { }) JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 26, 2018 Share Posted July 26, 2018 57 minutes ago, Deltakosh said: Or even better: That is better. I finally checked out the Observable, as that is not standard from the pattern - found the mask there too! Never stop learning Quote Link to comment Share on other sites More sharing options...
Guest Posted July 27, 2018 Share Posted July 27, 2018 Quote that is not standard from the pattern What do you mean? Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 27, 2018 Share Posted July 27, 2018 @Deltakosh just meant that 'mask' is not in the GoF description. I meant it in a good way that it looks useful JackFalcon and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
JackFalcon Posted July 30, 2018 Author Share Posted July 30, 2018 @Deltakosh and @brianzinn ... the best. Thanks for the insight and the code links! : ) Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 1, 2018 Share Posted August 1, 2018 https://www.babylonjs-playground.com/#BKTNDB JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.