From 492a80dc673e87bf1cda34abb86206cf72ea785e Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Mon, 24 Feb 2020 15:36:01 -0500 Subject: [PATCH] Check the 'scene' parameter for a base64 encoded scene to load --- macrovision.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/macrovision.js b/macrovision.js index ba81912f..f17e9e3b 100644 --- a/macrovision.js +++ b/macrovision.js @@ -878,7 +878,28 @@ document.addEventListener("DOMContentLoaded", () => { unitSelector.appendChild(option); }); - scenes["Demo"](); + param = new URL(window.location.href).searchParams.get("scene"); + + if (param === null) + scenes["Demo"](); + else { + try { + const data = JSON.parse(atob(param)); + if (data.entities === undefined) { + return; + } + if (data.world === undefined) { + return; + } + + importScene(data); + } catch (err) { + console.error(err); + scenes["Demo"](); + + // probably wasn't valid data + } + } fitWorld(); document.querySelector("#world").addEventListener("wheel", e => {