Browse Source

handle helper paths

Gregg Tavares 6 years ago
parent
commit
0a3cff6f74
1 changed files with 5 additions and 1 deletions
  1. 5 1
      threejs/resources/editor.js

+ 5 - 1
threejs/resources/editor.js

@@ -370,7 +370,11 @@ function getSourceBlob(htmlParts) {
   g.rootScriptInfo.source = htmlParts.js;
   makeBlobURLsForSources(g.rootScriptInfo);
 
-  const prefix = dirname(g.url);
+  const dname = dirname(g.url);
+  // HACK! for webgl-2d-vs... those examples are not in /webgl they're in /webgl/resources
+  // We basically assume url is https://foo/base/example.html so there will be 4 slashes
+  // If the path is longer than then we need '../' to back up so prefix works below
+  const prefix = `${dname}${dname.split('/').slice(4).map(() => '/..').join('')}`;
   let source = g.html;
   source = source.replace('${hackedParams}', JSON.stringify(g.query));
   source = source.replace('${html}', htmlParts.html);