From 4829984a70a790c06c0781d57195ac1419500272 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Fri, 13 Oct 2023 14:06:51 +0200 Subject: [PATCH] fix format --- WGLMakie/src/Serialization.js | 13 ++++++++++--- WGLMakie/src/wglmakie.bundled.js | 11 +++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/WGLMakie/src/Serialization.js b/WGLMakie/src/Serialization.js index 50202501e03..327ce2515f0 100644 --- a/WGLMakie/src/Serialization.js +++ b/WGLMakie/src/Serialization.js @@ -253,6 +253,7 @@ function convert_RGB_to_RGBA(rgbArray) { return rgbaArray; } + function create_texture(data) { const buffer = data.data; if (data.size.length == 3) { @@ -267,16 +268,22 @@ function create_texture(data) { return tex; } else { // a little optimization to not send the texture atlas over & over again - let tex_data = - buffer == "texture_atlas" ? TEXTURE_ATLAS[0].value : buffer; + let tex_data; + if (buffer == "texture_atlas") { + tex_data = TEXTURE_ATLAS[0].value; + } else { + tex_data = buffer; + } + let format = THREE[data.three_format]; if (data.three_format == "RGBFormat") { tex_data = convert_RGB_to_RGBA(tex_data); + format = THREE.RGBAFormat; } return new THREE.DataTexture( tex_data, data.size[0], data.size[1], - THREE.RGBAFormat, + format, THREE[data.three_type] ); } diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index 0ddc275f370..0c7d86e9422 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -20680,11 +20680,18 @@ function create_texture(data) { tex.type = mod[data.three_type]; return tex; } else { - let tex_data = buffer == "texture_atlas" ? TEXTURE_ATLAS[0].value : buffer; + let tex_data; + if (buffer == "texture_atlas") { + tex_data = TEXTURE_ATLAS[0].value; + } else { + tex_data = buffer; + } + let format = mod[data.three_format]; if (data.three_format == "RGBFormat") { tex_data = convert_RGB_to_RGBA(tex_data); + format = mod.RGBAFormat; } - return new mod.DataTexture(tex_data, data.size[0], data.size[1], mod.RGBAFormat, mod[data.three_type]); + return new mod.DataTexture(tex_data, data.size[0], data.size[1], format, mod[data.three_type]); } } function re_create_texture(old_texture, buffer, size) {