| 10 | } |
| 11 | |
| 12 | override load( |
| 13 | url: string, |
| 14 | onLoad: (data: Data3DTexture) => void, |
| 15 | onProgress?: (event: ProgressEvent) => void, |
| 16 | onError?: (error: unknown) => void |
| 17 | ): void { |
| 18 | const loader = new EXRLoader(this.manager) |
| 19 | loader.setRequestHeader(this.requestHeader) |
| 20 | loader.setPath(this.path) |
| 21 | loader.setWithCredentials(this.withCredentials) |
| 22 | loader.load( |
| 23 | url, |
| 24 | exr => { |
| 25 | const { data, width, height } = exr.image |
| 26 | const depth = this.depth ?? Math.sqrt(height) |
| 27 | const texture = new Data3DTexture(data, width, height / depth, depth) |
| 28 | texture.type = exr.type |
| 29 | texture.format = exr.format |
| 30 | texture.colorSpace = exr.colorSpace |
| 31 | texture.needsUpdate = true |
| 32 | |
| 33 | try { |
| 34 | onLoad(texture) |
| 35 | } catch (error) { |
| 36 | if (onError != null) { |
| 37 | onError(error) |
| 38 | } else { |
| 39 | console.error(error) |
| 40 | } |
| 41 | this.manager.itemError(url) |
| 42 | } |
| 43 | }, |
| 44 | onProgress, |
| 45 | onError |
| 46 | ) |
| 47 | } |
| 48 | } |