* Loads a LUT. * * @param {String} url - The URL of the 3dl-file. * @param {Function} [onLoad] - A callback that receives the loaded lookup texture. * @param {Function} [onProgress] - A progress callback that receives the XMLHttpRequest instance. * @param {Function} [onError] - An error ca
(url, onLoad = () => {}, onProgress = () => {}, onError = null)
| 25 | */ |
| 26 | |
| 27 | load(url, onLoad = () => {}, onProgress = () => {}, onError = null) { |
| 28 | |
| 29 | const externalManager = this.manager; |
| 30 | const internalManager = new LoadingManager(); |
| 31 | |
| 32 | const loader = new FileLoader(internalManager); |
| 33 | loader.setPath(this.path); |
| 34 | loader.setResponseType("text"); |
| 35 | externalManager.itemStart(url); |
| 36 | |
| 37 | loader.load(url, (data) => { |
| 38 | |
| 39 | try { |
| 40 | |
| 41 | const result = this.parse(data); |
| 42 | externalManager.itemEnd(url); |
| 43 | onLoad(result); |
| 44 | |
| 45 | } catch(e) { |
| 46 | |
| 47 | internalManager.onError(url); |
| 48 | onError(e); |
| 49 | |
| 50 | } |
| 51 | |
| 52 | }, onProgress); |
| 53 | |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Loads a LUT. |