|
|
@@ -31433,134 +31433,7 @@ class WebGLRenderer {
|
|
|
|
|
|
}
|
|
|
|
|
|
- let width, height, minX, minY;
|
|
|
- let dstX, dstY;
|
|
|
- if ( srcRegion !== null ) {
|
|
|
-
|
|
|
- width = srcRegion.max.x - srcRegion.min.x;
|
|
|
- height = srcRegion.max.y - srcRegion.min.y;
|
|
|
- minX = srcRegion.min.x;
|
|
|
- minY = srcRegion.min.y;
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- width = srcTexture.image.width;
|
|
|
- height = srcTexture.image.height;
|
|
|
- minX = 0;
|
|
|
- minY = 0;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( dstPosition !== null ) {
|
|
|
-
|
|
|
- dstX = dstPosition.x;
|
|
|
- dstY = dstPosition.y;
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- dstX = 0;
|
|
|
- dstY = 0;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- const glFormat = utils.convert( dstTexture.format );
|
|
|
- const glType = utils.convert( dstTexture.type );
|
|
|
-
|
|
|
- textures.setTexture2D( dstTexture, 0 );
|
|
|
-
|
|
|
- // As another texture upload may have changed pixelStorei
|
|
|
- // parameters, make sure they are correct for the dstTexture
|
|
|
- _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
|
-
|
|
|
- const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
|
- const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
|
- const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
|
- const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
|
- const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
|
-
|
|
|
- const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
|
-
|
|
|
- _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
|
|
|
-
|
|
|
- if ( srcTexture.isRenderTargetTexture || srcTexture.isDepthTexture ) {
|
|
|
-
|
|
|
- const srcTextureProperties = properties.get( srcTexture );
|
|
|
- const dstTextureProperties = properties.get( dstTexture );
|
|
|
- const srcRenderTargetProperties = properties.get( srcTextureProperties.__renderTarget );
|
|
|
- const dstRenderTargetProperties = properties.get( dstTextureProperties.__renderTarget );
|
|
|
-
|
|
|
- state.bindFramebuffer( _gl.READ_FRAMEBUFFER, srcRenderTargetProperties.__webglFramebuffer );
|
|
|
- state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, dstRenderTargetProperties.__webglFramebuffer );
|
|
|
-
|
|
|
- if ( srcTexture.isDepthTexture ) {
|
|
|
-
|
|
|
- _gl.blitFramebuffer( minX, minY, width, height, dstX, dstY, width, height, _gl.DEPTH_BUFFER_BIT, _gl.NEAREST );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- _gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, minX, minY, width, height );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
|
|
|
- state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- if ( srcTexture.isDataTexture ) {
|
|
|
-
|
|
|
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- if ( srcTexture.isCompressedTexture ) {
|
|
|
-
|
|
|
- _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
|
|
|
-
|
|
|
- // Generate mipmaps only when copying level 0
|
|
|
- if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
|
|
|
-
|
|
|
- state.unbindTexture();
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
- this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
|
-
|
|
|
- // support previous signature with source box first
|
|
|
- if ( srcTexture.isTexture !== true ) {
|
|
|
-
|
|
|
- // @deprecated, r165
|
|
|
- warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
|
|
|
-
|
|
|
- srcRegion = arguments[ 0 ] || null;
|
|
|
- dstPosition = arguments[ 1 ] || null;
|
|
|
- srcTexture = arguments[ 2 ];
|
|
|
- dstTexture = arguments[ 3 ];
|
|
|
- level = arguments[ 4 ] || 0;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+ // gather the necessary dimensions to copy
|
|
|
let width, height, depth, minX, minY, minZ;
|
|
|
let dstX, dstY, dstZ;
|
|
|
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
|
@@ -31568,16 +31441,16 @@ class WebGLRenderer {
|
|
|
|
|
|
width = srcRegion.max.x - srcRegion.min.x;
|
|
|
height = srcRegion.max.y - srcRegion.min.y;
|
|
|
- depth = srcRegion.max.z - srcRegion.min.z;
|
|
|
+ depth = srcRegion.isBox3 ? srcRegion.max.z - srcRegion.min.z : 1;
|
|
|
minX = srcRegion.min.x;
|
|
|
minY = srcRegion.min.y;
|
|
|
- minZ = srcRegion.min.z;
|
|
|
+ minZ = srcRegion.isBox3 ? srcRegion.min.z : 0;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
width = image.width;
|
|
|
height = image.height;
|
|
|
- depth = image.depth;
|
|
|
+ depth = image.depth || 1;
|
|
|
minX = 0;
|
|
|
minY = 0;
|
|
|
minZ = 0;
|
|
|
@@ -31598,6 +31471,7 @@ class WebGLRenderer {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // Set up the destination target
|
|
|
const glFormat = utils.convert( dstTexture.format );
|
|
|
const glType = utils.convert( dstTexture.type );
|
|
|
let glTarget;
|
|
|
@@ -31614,8 +31488,8 @@ class WebGLRenderer {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.' );
|
|
|
- return;
|
|
|
+ textures.setTexture2D( dstTexture, 0 );
|
|
|
+ glTarget = _gl.TEXTURE_2D;
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -31623,6 +31497,7 @@ class WebGLRenderer {
|
|
|
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
|
|
|
|
+ // used for copying data from cpu
|
|
|
const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
|
const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
|
const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
|
@@ -31635,6 +31510,9 @@ class WebGLRenderer {
|
|
|
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
|
|
|
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
|
|
|
|
|
|
+ // set up the src texture
|
|
|
+ const isSrc3D = srcTexture.isDataArrayTexture || srcTexture.isData3DTexture;
|
|
|
+ const isDst3D = dstTexture.isDataArrayTexture || dstTexture.isData3DTexture;
|
|
|
if ( srcTexture.isRenderTargetTexture || srcTexture.isDepthTexture ) {
|
|
|
|
|
|
const srcTextureProperties = properties.get( srcTexture );
|
|
|
@@ -31647,17 +31525,31 @@ class WebGLRenderer {
|
|
|
|
|
|
for ( let i = 0; i < depth; i ++ ) {
|
|
|
|
|
|
- _gl.framebufferTextureLayer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( srcTexture ).__webglTexture, level, minZ + i );
|
|
|
+ // if the source or destination are a 3d target then a layer needs to be bound
|
|
|
+ if ( isSrc3D ) {
|
|
|
+
|
|
|
+ _gl.framebufferTextureLayer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( srcTexture ).__webglTexture, level, minZ + i );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if ( srcTexture.isDepthTexture ) {
|
|
|
|
|
|
- _gl.framebufferTextureLayer( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( dstTexture ).__webglTexture, level, dstZ + i );
|
|
|
+ if ( isDst3D ) {
|
|
|
+
|
|
|
+ _gl.framebufferTextureLayer( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( dstTexture ).__webglTexture, level, dstZ + i );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
_gl.blitFramebuffer( minX, minY, width, height, dstX, dstY, width, height, _gl.DEPTH_BUFFER_BIT, _gl.NEAREST );
|
|
|
|
|
|
- } else {
|
|
|
+ } else if ( isDst3D ) {
|
|
|
|
|
|
_gl.copyTexSubImage3D( glTarget, level, dstX, dstY, dstZ + i, minX, minY, width, height );
|
|
|
|
|
|
+ } else {
|
|
|
+
|
|
|
+ _gl.copyTexSubImage2D( glTarget, level, dstX, dstY, dstZ + i, minX, minY, width, height );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -31667,13 +31559,14 @@ class WebGLRenderer {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
|
|
|
+ if ( isDst3D ) {
|
|
|
|
|
|
- _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
|
|
|
+ // copy data into the 3d texture
|
|
|
+ if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
|
|
|
|
|
|
- } else {
|
|
|
+ _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
|
|
|
|
|
|
- if ( dstTexture.isCompressedArrayTexture ) {
|
|
|
+ } else if ( dstTexture.isCompressedArrayTexture ) {
|
|
|
|
|
|
_gl.compressedTexSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
|
|
|
|
|
|
@@ -31683,10 +31576,28 @@ class WebGLRenderer {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ } else {
|
|
|
+
|
|
|
+ // copy data into the 2d texture
|
|
|
+ if ( srcTexture.isDataTexture ) {
|
|
|
+
|
|
|
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
|
|
|
+
|
|
|
+ } else if ( srcTexture.isCompressedTexture ) {
|
|
|
+
|
|
|
+ _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // reset values
|
|
|
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
|
|
|
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
|
|
|
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
|
@@ -31694,12 +31605,39 @@ class WebGLRenderer {
|
|
|
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
|
|
|
|
|
|
// Generate mipmaps only when copying level 0
|
|
|
- if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( glTarget );
|
|
|
+ if ( level === 0 && dstTexture.generateMipmaps ) {
|
|
|
+
|
|
|
+ _gl.generateMipmap( glTarget );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
state.unbindTexture();
|
|
|
|
|
|
};
|
|
|
|
|
|
+ this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
|
+
|
|
|
+ // support previous signature with source box first
|
|
|
+ if ( srcTexture.isTexture !== true ) {
|
|
|
+
|
|
|
+ // @deprecated, r165
|
|
|
+ warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
|
|
|
+
|
|
|
+ srcRegion = arguments[ 0 ] || null;
|
|
|
+ dstPosition = arguments[ 1 ] || null;
|
|
|
+ srcTexture = arguments[ 2 ];
|
|
|
+ dstTexture = arguments[ 3 ];
|
|
|
+ level = arguments[ 4 ] || 0;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // @deprecated, r170
|
|
|
+ warnOnce( 'WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.' );
|
|
|
+
|
|
|
+ return this.copyTextureToTexture( srcTexture, dstTexture, srcRegion, dstPosition, level );
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
this.initRenderTarget = function ( target ) {
|
|
|
|
|
|
if ( properties.get( target ).__webglFramebuffer === undefined ) {
|
|
|
@@ -34451,6 +34389,7 @@ class BatchedMesh extends Mesh {
|
|
|
}
|
|
|
|
|
|
nextVertexStart += geometryInfo.reservedVertexCount;
|
|
|
+ geometryInfo.start = geometry.index ? geometryInfo.indexStart : geometryInfo.vertexStart;
|
|
|
|
|
|
// step the next geometry points to the shifted position
|
|
|
this._nextIndexStart = geometry.index ? geometryInfo.indexStart + geometryInfo.reservedIndexCount : 0;
|
|
|
@@ -38150,14 +38089,14 @@ class CylinderGeometry extends BufferGeometry {
|
|
|
|
|
|
// faces
|
|
|
|
|
|
- if ( radiusTop > 0 ) {
|
|
|
+ if ( radiusTop > 0 || y !== 0 ) {
|
|
|
|
|
|
indices.push( a, b, d );
|
|
|
groupCount += 3;
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( radiusBottom > 0 ) {
|
|
|
+ if ( radiusBottom > 0 || y !== heightSegments - 1 ) {
|
|
|
|
|
|
indices.push( b, c, d );
|
|
|
groupCount += 3;
|