Created
October 27, 2016 09:29
-
-
Save THeK3nger/300b6a62b923c913223fbd29c8b5ac73 to your computer and use it in GitHub Desktop.
THREE.js Asynchronous Shader Loader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a basic asyncronous shader loader for THREE.js. | |
function ShaderLoader(vertex_url, fragment_url, onLoad, onProgress, onError) { | |
var vertex_loader = new THREE.XHRLoader(THREE.DefaultLoadingManager); | |
vertex_loader.setResponseType('text'); | |
vertex_loader.load(vertex_url, function (vertex_text) { | |
var fragment_loader = new THREE.XHRLoader(THREE.DefaultLoadingManager); | |
fragment_loader.setResponseType('text'); | |
fragment_loader.load(fragment_url, function (fragment_text) { | |
onLoad(vertex_text, fragment_text); | |
}); | |
}, onProgress, onError); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment