webEventReceived


#1

Hi all,

I am writing a script that basically puts a web3d overlay onto my wrist in vr mode, but I can’t figure out how to make the script listen for the webEventReceived event.
The only way I can find it is for the tablet but that means using the tablet which isn’t my goal.
The part I have so far is just webEventReceived.connect(onWebEventReceived); but that doesn’t work as I need the first part e.g. EventBridge.webEventReceived.connect(onWebEventReceived); but EventBridge isn’t defined.

That is my wrist overlay. I hope someone knows something.

Thanks,
-Fluffy


#2

Do you really need EventBridge? what are you trying to do respond to… a click? maybe there’s a more basic approach.


#3

Well I’m going on from what I can figure out, It seems that is needed for it to ‘hear’ the click from the webpage.

// Handle the events we're recieving from the web UI
function onWebEventReceived(event) {
print("test.js received a web event:" + event);

// Converts the event to a JavasScript Object
if (typeof event === "string") {
    event = JSON.parse(event);
}

if (event.type === "click") {
    // Define the entity properties of for each of the gemstone, then add it to the scene
    if (event.data  === "BucketHouseSpawn") {
		BucketHouse();
    }

#4

That’s only useful for the tablet where we have a javascript + html file I think. how are you making the GUI for the wrist item? a webentity?


#5

A Web3d overlay and a html file, I’m basically trying to replicate how the tablet works but for my own device.


#6

You need the Web3DOverlay object itself to connect…

var id = Overlays.addOverlay(...);
var obj = Overlays.getOverlayObject(...);
obj.webEventReceived.connect(function(message) {
  ... your handler logic here ...
});

The event bridge is only for the HTML/JS side of things.


#7

IT WORKS THANK YOUUUUUUUUUUU.

[filler text so it lets me post my happiness]


#8

Now… do you happen to know how to stop my web3d overlay from showing the tablet? cause I can’t undo it without remaking the overlay