소스 검색

Merge pull request #15756 from DavidPeicho/feature/texture3d-wrapR

Adds support for TEXTURE_WRAP_R in DataTexture3D
Mr.doob 6 년 전
부모
커밋
4a1f478cf3
4개의 변경된 파일26개의 추가작업 그리고 3개의 파일을 삭제
  1. 10 2
      docs/api/en/textures/DataTexture3D.html
  2. 1 0
      rollup.config.js
  3. 12 0
      src/renderers/webgl/WebGLTextures.js
  4. 3 1
      src/textures/DataTexture3D.js

+ 10 - 2
docs/api/en/textures/DataTexture3D.html

@@ -32,10 +32,18 @@
 		<div>[example:webgl2_materials_texture3d WebGL2 / materials / texture3d]</div>
 		<div>[example:webgl2_materials_texture3d_volume WebGL2 / materials / texture3d / volume]</div>
 
-		<h2>Properties</h2>
+    <h2>Properties</h2>
 
 		<p>
-		See the base [page:Texture Texture] class for common properties.
+    See the base [page:Texture Texture] class for common properties.
+    </p>
+
+    <h3>[property:number wrapR]</h3>
+		<p>
+		This defines how the texture is wrapped in the depth direction.<br />
+		The default is [page:Textures THREE.ClampToEdgeWrapping], where the edge is clamped to the outer edge texels.
+		The other two choices are [page:Textures THREE.RepeatWrapping] and [page:Textures THREE.MirroredRepeatWrapping].
+		See the [page:Textures texture constants] page for details.
 		</p>
 
 		<h2>Methods</h2>

+ 1 - 0
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,

+ 12 - 0
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.' );

+ 3 - 1
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;