How do I interact with the scene from javascript in the HTML?

Getting started with Babylon, really nice - a bit overwhelming but giving it a go. I’ve got a decent start, but we’d like to try interaction in the browser <–> scene. I’m trying to figure out how to access a function inside the main createScene function, like from a basic Playground.

Basically I’d like to have user click a button elsewhere on the page, outside the canvas, and something in the scene changes, like a simple mesh translation. Just not sure how to do this.
Thank you

Hi @synth and welcome,
Simillar topic

Similar but not really as it’s creating the HTML buttons and event functions within the scene itself. I’m curious how to create a function or new method on the scene class so I can interact with it outside of the local scope. Like elsewhere in the HTML just call “MoveBoxToPoint(3);” where MoveBoxToPoint is a function or method inside of scene and 3 is a value passed to it. Is that possible?

@synth
I hope you’ve read through First Steps - Babylon.js Documentation
A variable (scene…) declared outside a function , becomes GLOBAL and so on.
Maybe I missed the point :thinking:

Yes I did go through those, and the way you’re describing is the way I’ll probably do it for now. I am just checking the value of a global variable in the scene.registerBeforeRender function.

I was just wondering if there’s a more streamlined way to directly call a function and pass a variable. Other JS libraries let you ‘register as global’ functions, thought there might be a way in Babylon.
Thanks for your replies

Can you elaborate on that?