Skip to content

Commit fd6107f

Browse files
committed
1 parent 1316767 commit fd6107f

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
"version": "0.0.0",
44
"description": "Some WebGL Tutorials designed for real WebGL and not 20yr old OpenGL",
55
"main": "index.js",
6-
"dependencies": {},
76
"devDependencies": {
87
"@gfxfundamentals/lesson-builder": "git+https://github.com/gfxfundamentals/lesson-builder.git#v1.8.2",
9-
"@gfxfundamentals/live-editor": "git+https://github.com/gfxfundamentals/live-editor.git#v1.0.19",
8+
"@gfxfundamentals/live-editor": "git+https://github.com/gfxfundamentals/live-editor.git#v1.2.0",
109
"eslint-plugin-google-camelcase": "0.0.2",
1110
"eslint-plugin-html": "6.1.1",
1211
"eslint-plugin-one-variable-per-var": "0.0.3",
@@ -19,7 +18,7 @@
1918
"grunt-contrib-watch": "1.1.0",
2019
"grunt-eslint": "23.0.0",
2120
"grunt-jsdoc": "2.4.1",
22-
"ld-check-dependencies": "1.1.1",
21+
"ld-check-dependencies": "1.2.1",
2322
"load-grunt-tasks": "5.1.0",
2423
"minami": "1.2.3",
2524
"servez": "1.11.0"

webgl/resources/editor-settings.js

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ function getPrefix(url) {
1212
return prefix;
1313
}
1414

15+
const lessonHelperScriptRE = /<script src="[^"]+lessons-helper\.js"><\/script>/;
16+
const webglDebugHelperScriptRE = /<script src="[^"]+webgl-debug-helper\.js"><\/script>/;
17+
18+
function fixHTMLForCodeSite(html) {
19+
html = html.replace(lessonHelperScriptRE, '');
20+
html = html.replace(webglDebugHelperScriptRE, '');
21+
return html;
22+
}
23+
1524
/**
1625
* Fix any local URLs into fully qualified urls.
1726
*
@@ -141,14 +150,36 @@ function requestCORSIfNotSameOrigin(img, url) {
141150
return js;
142151
}
143152

153+
function prepHTML(source, prefix) {
154+
source = source.replace('<head>', `<head>
155+
<link rel="stylesheet" href="${prefix}/resources/lesson-helper.css" type="text/css">
156+
<script match="false">self.lessonSettings = ${JSON.stringify(lessonSettings)}</script>`);
157+
158+
source = source.replace('</head>', `<script src="${prefix}/resources/webgl-debug-helper.js"></script>
159+
<script src="${prefix}/resources/lessons-helper.js"></script>
160+
</head>`);
161+
return source;
162+
}
163+
164+
function getWorkerPreamble(scriptInfo) {
165+
return `self.lessonSettings = ${JSON.stringify(lessonSettings)};
166+
import '${dirname(scriptInfo.fqURL)}/resources/webgl-debug-helper.js';
167+
import '${dirname(scriptInfo.fqURL)}/resources/lessons-worker-helper.js';`;
168+
}
169+
170+
const lessonSettings = {
171+
glDebug: true,
172+
};
173+
144174
window.lessonEditorSettings = {
145175
extraHTMLParsing,
146176
fixSourceLinks,
147177
fixJSForCodeSite,
178+
fixHTMLForCodeSite,
148179
runOnResize: true,
149-
lessonSettings: {
150-
glDebug: true,
151-
},
180+
lessonSettings,
181+
prepHTML,
182+
getWorkerPreamble,
152183
tags: ['webgl', 'webglfundamentals.org'],
153184
name: 'WebGLFundamentals',
154185
icon: '/webgl/lessons/resources/webglfundamentals-icon-256.png',

0 commit comments

Comments
 (0)