OOP on the LOOP - hot-swapping beforeRender-added funcs

Hi gang!


I’m trying demented things… there.

Objective: Have a custom-class object… change onBeforeRender code… from within its own local-scope. (sorry, badly stated)


Line 66: Create a custom object.

Line 16: In object.init(), put whatever function is in obj.wedgeCode… onto the renderLoop. Initially it is set to function(){}; … a do-nothing function.

Line 17: Call changeWedgeCode() which waits for scene.onReady… and then changes the function that is contained in obj.wedgeCode.

Important point about line 33: I REALLY want to be able to use this in the wedgeCode… like line 33 does. But, that is for later, as I cannot get line 38 to work.

Line 38: Exchange the old do-nothing function stored in obj.wedgeCode… with a fresh new do-something function… and get beforeRenderObserver to run THAT, instead.

Essentially, I want my own onBeforeRender observer thing… on the object itself. I would love to have obj.onBeforeRenderObservable.add(some within-obj-scope function).

Does this make sense to anyone reading? Possible?

I would prefer that the object NOT need-to reach outside its scope… to do scene.onBeforeRenderObservable.add/remove calls (well, just once, at line 16). Instead, perhaps it could do its own hot-swapping of obj.wedgeCode contents.

Again, it would be nice to allow this “hot swap” of the contents of obj.wedgeCode… and it would be REALLY nice if the new func inside obj.wedgeCode would allow this keyword.

Any help, info, shooting-full-of-holes… welcomed, thx. Some of you might have flashbacks to hot-swapping the address in the IRQ vector on Commodore 64’s. :slight_smile:

1 Like

Hi Wingnut,

You mean like this?



With arrow functions on line 16 & 37


Thanks G (and Hi)! Well done!

No chance of it working in standard IE, I suppose.

(Wingnut shoves his flashing firefox and chrome backgrounds… into IE’s face… with a condescending look.) :slight_smile:

1 Like