Skip to content

Commit 339b825

Browse files
stepankuzmingithub-actions[bot]
authored andcommitted
Fix texSubImage2D call in Texture (internal-6461)
GitOrigin-RevId: 112262f607ecd659a124a6a571082e55d90cfba3
1 parent d21f595 commit 339b825

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/render/texture.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ class Texture {
9595
if (this.size) {
9696
if (externalImage) {
9797
gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, _getLegacyFormat(this.format), _getType(this.format), image);
98-
} else {
99-
gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, srcWidth, srcHeight, _getLegacyFormat(this.format), _getType(this.format), (image as RGBAImage | AlphaImage | Float32Image | EmptyImage).data);
98+
} else if ('data' in image && image.data) {
99+
gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, srcWidth, srcHeight, _getLegacyFormat(this.format), _getType(this.format), image.data);
100100
}
101101
}
102102

@@ -200,7 +200,9 @@ export class Texture3D {
200200
assert(image.height === height);
201201
assert(image.width === width * depth);
202202

203-
gl.texImage3D(gl.TEXTURE_3D, 0, this.format, width, height, depth, 0, _getLegacyFormat(this.format), _getType(this.format), (image as RGBAImage | AlphaImage | Float32Image | EmptyImage).data);
203+
if ('data' in image && image.data) {
204+
gl.texImage3D(gl.TEXTURE_3D, 0, this.format, width, height, depth, 0, _getLegacyFormat(this.format), _getType(this.format), image.data);
205+
}
204206
}
205207

206208
bind(filter: TextureFilter, wrap: TextureWrap) {

0 commit comments

Comments
 (0)