Setting up a test workspace in visual studio code to learn webgl, using this good book https://sites.google.com/site/webglbook/
Samples are structured like this:
examples
ch02
HelloCanvas.html
HelloCanvas.js
ch03
...
lib
webgl-utils.js
cuon-utils.js
...
Take for example HelloCanvas.html
Clear "canvas"Please use a browser that supports "canvas"
It contains references to external scripts.
If I open the HelloCanvas.js file
// HelloCanvas.js (c) 2012 matsuda
function main() {
// Retrieve element
var canvas = document.getElementById('webgl');
// Get the rendering context for WebGL
var gl = getWebGLContext(canvas);
if (!gl) {
console.log('Failed to get the rendering context for WebGL');
return;
}
// Set clear color
gl.clearColor(0.0, 0.0, 0.0, 1.0);
// Clear
gl.clear(gl.COLOR_BUFFER_BIT);
}
vscode cannot find declarations in other js files contained in the lib folder.
For example I expect vscode to be able to "Go to the declaration" of getWebGLContext that is contained in cuon-utils.js
cuon-utils.js (excerpt)
/**
* Initialize and get the rendering for WebGL
* @param canvas element
* @param opt_debug flag to initialize the context for debugging
* @return the rendering context for WebGL
*/
function getWebGLContext(canvas, opt_debug) {
// Get the rendering context for WebGL
var gl = WebGLUtils.setupWebGL(canvas);
if (!gl) return null;
// if opt_debug is explicitly false, create the context for debugging
if (arguments.length < 2 || opt_debug) {
gl = WebGLDebugUtils.makeDebugContext(gl);
}
return gl;
}
So far I tried adding a jsconfig.json in the root folder or in the same folder of HelloCanvas.js
{
"include": [ "../lib/**/*"]
}
with no success