| 385 | return texture; |
| 386 | } |
| 387 | class FakeTextureLoader extends WebGLTextureLoader<FakeTexture> { |
| 388 | textures: Array<WebGLTexture>; |
| 389 | constructor(gl: WebGLRenderingContext) { |
| 390 | super(gl); |
| 391 | this.textures = []; |
| 392 | } |
| 393 | dispose() { |
| 394 | const { gl } = this; |
| 395 | this.textures.forEach(t => gl.deleteTexture(t)); |
| 396 | } |
| 397 | canLoad(input: any) { |
| 398 | return input instanceof FakeTexture; |
| 399 | } |
| 400 | get(ft: FakeTexture) { |
| 401 | const array = ft.getPixels(); |
| 402 | if (array) { |
| 403 | const t = createNDArrayTexture(this.gl, array); |
| 404 | this.textures.push(t); |
| 405 | return { |
| 406 | texture: t, |
| 407 | width: ft.width, |
| 408 | height: ft.height |
| 409 | }; |
| 410 | } |
| 411 | } |
| 412 | load(ft: FakeTexture) { |
| 413 | const res = this.get(ft); |
| 414 | return res ? Promise.resolve(res) : Promise.reject(); |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | globalRegistry.add(FakeTextureLoader); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…