Jump to content

Passing Values into ActionManager ExecuteCodeAction


Calsa
 Share

Recommended Posts

I am having another noob "this" moment. I'm working on a simple class.... These are a few snips of the problem area.

When I call a method such as nodeActions below which binds actions to a mesh, then I click on the mesh triggering moveToNode, the this scope changes to actionManager's this instead of this classes this. Why this happens makes sense to me, but what is the best way to access the classes this scope from within moveToNode so I don't have to do such a sloppy hack to re access scene and my class variables from within the moveToNode method?       

moveToNode(){
        var scene = this._actionManager._scene //HACK
        var pickedNode = scene.pick(scene.pointerX, scene.pointerY, null, false, scene.camera)
        var moveTarget = scene.getMeshByName(pickedNode.name)
        // More to come this is not a simple interpolate function
    }


nodeActions(mesh) {
        mesh.actionManager = new BABYLON.ActionManager(this.scene)
        mesh.actionManager.registerAction( new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, this.moveToNode))
    }

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...