Using ExecuteCodeAction with pick trigger throwing an error

I am trying to call a function by registering a pick action then using ExecuteCodeAction. The function call works properly when called from an if, but throws an error when I click on the sphere. Here is the code in playground:

The error is
Uncaught TypeError: this.func is not a function
at t.execute (babylon.js:16)
at t.e._executeCurrent (babylon.js:16)
at t.processTrigger (babylon.js:16)
at e._processPointerUp (babylon.js:16)
at babylon.js:16
at e._initClickEvent (babylon.js:16)
at _onPointerUp (babylon.js:16)

Any advice?

Hi @drburton
you need to encapsulate it in another function,

Or a separate function checking the evt then calling pushMesh

1 Like

Perfect! Thank you!

1 Like