下面贴出如何加载的代码:
引入jquery插件:
<script src="r95/jquery-3.1.1.js"></script>
初始化加载shader文件:
function initglsl(){
var error = document.getElementById('error');
vertDeferred = $.ajax({
url: './shaders/pbr-vert.glsl',
dataType: 'text',
async: true,
error: (jqXhr, textStatus, errorThrown) => {
error.innerHTML += 'Failed to load the vertex shader: ' + errorThrown + '<br>';
}
});
fragDeferred = $.ajax({
url: './shaders/pbr-frag.glsl',
dataType: 'text',
async: true,
error: (jqXhr, textStatus, errorThrown) => {
error.innerHTML += 'Failed to load the fragment shader: ' + errorThrown + '<br>'