Just thinking out loud here before going into a large production. Is there a way to communicate with a playcanvas app via URL link. Let’s say I wanted to load a certain scene or pass on a flag/argument/parameter that would change something dynamically in my scene, could I do that via a link / GET URL ?
I’m not sure about what you want exactly. But yes, you should be able to get parameters from an URL using basic Javascript. The problem is that you don’t want to reload your Playcanvas project each time the URL change.
What I do to send basic data to Playcanvas is using postMessage to send data to my iframe with my canvas inside of it. So, I can have an HTML website with buttons that can change the content of my Playcanvas project.
aha, interesting. That’s a possibility. Now I was mostly thinking about if I wanted to access my playcanvas app (residing and hosted locally on it’s own page) from two different parts of larger site. Perhaps one of the links to the playcanvas page want’s to access a certain part of the app, but the other link is after something else. Two different camera position/zoom levels, or loading two separate scenes. Or perhaps, passing on a variable saying which country the user is in - then dynamically replacing it with a 3D model of that flag of the country somehere in the 3D models.
Buy perhaps I should be thinking more like this: The page where the webgl app is placed and loaded has a script responsible for reading URL/GET parameters, then communicates with the app depending on what it gets.
I understand! This is all hypothetically as of now. (and I’m rusty on my web app programming).
Perhaps I can think like this: If I access the window.location.href attribute from within a script in playcanvas. Then I can react to any made up parameters like this:
Oh that, yes definitely, Playcanvas doesn’t do anything special on that aspect. As any regular web app you can read all query params and act on them in your Playcanvas scripts.