I need to access the text of a string which I import using HTML from inside another script.
I include the text file in question in the html file:
<script src="shaders/fragmentshader.fs" id=fragmentshader></script>
I then want to put the contents of this file in a variable within another script file and use it as a shader for three,js :
var fShader = $('#fragmentshader');
var shader = new THREE.ShaderMaterial({
vertexShader: vShader.text(),
fragmentShader: fShader.text()
});
This code works fine if I just write the necessary shader code between the script tags in the html file, but only accesses the strict url(not the data) if used as above.
My question is how do I access the text within the file after loading it as shown above?