How to add mouse events to 3D objects?

I see you can add click and other events to unitys canvas UI objects through the editor. But how do I add those events to a “normal” 3D object? Through typescript would be best.

Original Post on Discord

by user 367081956959322114

You can implement the IPointerEventHandler interface for example

export class MyScript extends Behaviour implements IPointerEventHandler {

    onPointerClick(args) {


Make sure to have an ObjectRaycaster component in your parent hierarchy somewhere

Thank you!
Where can I find this sort of information? Is it already somehwere in the docs or maybe is it more like: it should be clear if you understand typescript/three/unity?

by user 367081956959322114

Some of this can be found here: needle-engine-support/documentation/ at main · needle-tools/needle-engine-support · GitHub

But the docs are not yet exhaustive so feel free to ask if you’re missing information or you can also always have a look at our builtin components