How to get the picking point with OnPickTrigger and ExecuteCodeAction?

How do we get the picking point in from the ActionEvent passed to my ExecuteCodeAction triggered by OnPickTrigger?

For example:

        const actionManager = new ActionManager(scene)

        actionManager.registerAction(
            new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, (event) => {
                const pickingPoint = // ... get the picking point from the event ...
                console.log(pickingPoint)
            })
        );

        mesh.actionManager = actionManager

Ah, the event.additionalData has type any, so I didn’t realize that’s where the info was.

Solution:

        const actionManager = new ActionManager(scene)

        actionManager.registerAction(
            new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, (event) => {
                const pickingPoint = event.additionalData.pickedPoint
                console.log(pickingPoint) // yay
            })
        );

        mesh.actionManager = actionManager
2 Likes