From 9aca8b396443cde4f223ca5a9122adbd539455a0 Mon Sep 17 00:00:00 2001 From: sawa-zen Date: Thu, 30 Jul 2026 20:43:45 +0900 Subject: [PATCH] Use uploadU32DataTextureRows for LoD index uploads updateLodIndices duplicated the texSubImage2D path inline instead of calling the existing helper, and the inline copy did not save and restore the pixelStorei parameters. Leaving UNPACK_FLIP_Y_WEBGL at false desynchronises three.js's WebGLState cache: the cache still believes the value is true, so three skips the pixelStorei call before its own uploads and every subsequent texture is transferred flipped. uploadU32DataTextureRows already handles this. Fixes #405 --- src/SparkRenderer.ts | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/SparkRenderer.ts b/src/SparkRenderer.ts index 6c72c595..6b7920ba 100644 --- a/src/SparkRenderer.ts +++ b/src/SparkRenderer.ts @@ -1627,31 +1627,14 @@ export class SparkRenderer extends THREE.Mesh { // instance.indices.set(indices.subarray(0, numSplats)); const renderer = this.renderer; - const gl = renderer.getContext() as WebGL2RenderingContext; if (renderer.properties.has(instance.texture)) { - const props = renderer.properties.get(instance.texture) as { - __webglTexture: WebGLTexture; - }; - const glTexture = props.__webglTexture; - if (!glTexture) { - throw new Error("lodIndices texture not found"); - } - renderer.state.activeTexture(gl.TEXTURE0); - renderer.state.bindTexture(gl.TEXTURE_2D, glTexture); - gl.bindBuffer(gl.PIXEL_UNPACK_BUFFER, null); - gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); - gl.texSubImage2D( - gl.TEXTURE_2D, - 0, - 0, - 0, + uploadU32DataTextureRows( + renderer, + instance.texture, 4096, rows, - gl.RGBA_INTEGER, - gl.UNSIGNED_INT, indices, ); - renderer.state.bindTexture(gl.TEXTURE_2D, null); } } }