From d566e4eb7760c7d04c64073688d04549478be86c Mon Sep 17 00:00:00 2001 From: Popov72 Date: Mon, 4 Sep 2023 15:02:55 +0200 Subject: [PATCH] Fix loading of existing snippet not working --- src/dataExport.js | 2 +- src/hashUtils.js | 4 ++-- src/index.js | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dataExport.js b/src/dataExport.js index 9fd44ce..49f09e7 100644 --- a/src/dataExport.js +++ b/src/dataExport.js @@ -1,6 +1,6 @@ import './fileSaver.js'; -const snippetUrl = "https://snippet.babylonjs.com"; +export const snippetUrl = "https://snippet.babylonjs.com"; let currentSnippetToken; diff --git a/src/hashUtils.js b/src/hashUtils.js index a9bbbb1..e86a157 100644 --- a/src/hashUtils.js +++ b/src/hashUtils.js @@ -11,7 +11,7 @@ function cleanHash() { location.hash = splits.join("#"); } -export function checkHash() { +export function checkHash(snippetUrl, vertexEditor, pixelEditor, selectMesh, compile) { if (location.hash) { if (previousHash != location.hash) { cleanHash(); @@ -53,5 +53,5 @@ export function checkHash() { } } - setTimeout(checkHash, 200); + setTimeout(checkHash.bind(checkHash, snippetUrl, vertexEditor, pixelEditor, selectMesh), 200); } \ No newline at end of file diff --git a/src/index.js b/src/index.js index 11d024f..704fe7b 100644 --- a/src/index.js +++ b/src/index.js @@ -2,7 +2,7 @@ import { loadShader } from './shaders.js'; import { checkHash } from './hashUtils.js'; -import { saveFunction, getZip } from './dataExport.js'; +import { saveFunction, getZip, snippetUrl } from './dataExport.js'; let engine; @@ -234,9 +234,9 @@ async function createEngine(canvas) { (function () { document.addEventListener("DOMContentLoaded", start, false); - function start() { - effectiveStart(); - checkHash(); + async function start() { + await effectiveStart(); + checkHash(snippetUrl, vertexEditor, pixelEditor, selectMesh, compile); } async function effectiveStart() {