How to add listener for spatial trigger in vue?

Hello, I am creating a project with vue.js. I use the vue project template provided and it works great.
Now I want to pop up a div element in vue whenever the spatial trigger is hit in the needle engine. I’m experienced with Unity but not very familiar with vue or frontend world… Does this means that I need to do something like “setInterval()” to keep checking the state in needle?

Original Post on Discord

by user 1011108787932909679

Sorry for missing this question - you can send events from vue to Needle components and vice versa. One way for example is to use dispatchEvent() on this.context.domElement and then from vue listen to it by using addEventListener() as usual.

Or you can query the SpatialTriggerReceivers in your scene and then register on the events, something like that (you can do this in your vue component for example)

ContextRegistry.addContextCreatedCallback(() => {

    const reg: SpatialTriggerReceiver = GameObject.findObjectOfType(SpatialTriggerReceiver)!;
    reg.onEnter?.addEventListener(evt => {

    });
})

Alternatively you can also add SpatialTriggerReceiver components from vue and listen to the events there