From 55d8619ac2cd293f13a20f182ebb12598051f266 Mon Sep 17 00:00:00 2001 From: David Peicho Date: Mon, 11 Feb 2019 15:41:06 -0500 Subject: [PATCH] texture3D: add support for TEXTURE_WRAP_R --- rollup.config.js | 1 + src/renderers/webgl/WebGLTextures.js | 12 ++++++++++++ src/textures/DataTexture3D.js | 4 +++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/rollup.config.js b/rollup.config.js index 62bfab82e0..440ab7c746 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -66,6 +66,7 @@ function glconstants() { TEXTURE_MIN_FILTER: 10241, TEXTURE_WRAP_S: 10242, TEXTURE_WRAP_T: 10243, + TEXTURE_WRAP_R: 32882, REPEAT: 10497, COLOR_BUFFER_BIT: 16384, FUNC_ADD: 32774, diff --git a/src/renderers/webgl/WebGLTextures.js b/src/renderers/webgl/WebGLTextures.js index 70d8dc1d7c..bdebc9a332 100644 --- a/src/renderers/webgl/WebGLTextures.js +++ b/src/renderers/webgl/WebGLTextures.js @@ -434,6 +434,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, utils.convert( texture.wrapS ) ); _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, utils.convert( texture.wrapT ) ); + if ( textureType === _gl.TEXTURE_3D ) { + + _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, utils.convert( texture.wrapR ) ); + + } + _gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, utils.convert( texture.magFilter ) ); _gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, utils.convert( texture.minFilter ) ); @@ -442,6 +448,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE ); _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE ); + if ( textureType === _gl.TEXTURE_3D ) { + + _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, _gl.CLAMP_TO_EDGE ); + + } + if ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) { console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' ); diff --git a/src/textures/DataTexture3D.js b/src/textures/DataTexture3D.js index 5aae3909dd..d34a3ab4e0 100644 --- a/src/textures/DataTexture3D.js +++ b/src/textures/DataTexture3D.js @@ -3,7 +3,7 @@ */ import { Texture } from './Texture.js'; -import { NearestFilter } from '../constants.js'; +import { ClampToEdgeWrapping, NearestFilter } from '../constants.js'; function DataTexture3D( data, width, height, depth ) { @@ -22,6 +22,8 @@ function DataTexture3D( data, width, height, depth ) { this.magFilter = NearestFilter; this.minFilter = NearestFilter; + this.wrapR = ClampToEdgeWrapping; + this.generateMipmaps = false; this.flipY = false; -- GitLab