|
@@ -1562,6 +1562,35 @@ function warnOnce( message ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+function probeAsync( gl, sync, interval ) {
|
|
|
+
|
|
|
+ return new Promise( function ( resolve, reject ) {
|
|
|
+
|
|
|
+ function probe() {
|
|
|
+
|
|
|
+ switch ( gl.clientWaitSync( sync, gl.SYNC_FLUSH_COMMANDS_BIT, 0 ) ) {
|
|
|
+
|
|
|
+ case gl.WAIT_FAILED:
|
|
|
+ reject();
|
|
|
+ break;
|
|
|
+
|
|
|
+ case gl.TIMEOUT_EXPIRED:
|
|
|
+ setTimeout( probe, interval );
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ resolve();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ setTimeout( probe, interval );
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
|
|
|
* or clipping. Based on W3C specifications for sRGB and Display P3,
|
|
@@ -13890,15 +13919,15 @@ var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_META
|
|
|
|
|
|
var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif";
|
|
|
|
|
|
-var morphinstance_vertex = "#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[MORPHTARGETS_COUNT];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif";
|
|
|
+var morphinstance_vertex = "#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif";
|
|
|
|
|
|
-var morphcolor_vertex = "#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif";
|
|
|
+var morphcolor_vertex = "#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif";
|
|
|
|
|
|
-var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif";
|
|
|
+var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif";
|
|
|
|
|
|
-var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t#endif\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\t#ifndef USE_INSTANCING_MORPH\n\t\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\t#endif\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif";
|
|
|
+var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif";
|
|
|
|
|
|
-var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif";
|
|
|
+var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif";
|
|
|
|
|
|
var normal_fragment_begin = "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;";
|
|
|
|
|
@@ -17746,8 +17775,7 @@ function WebGLMorphtargets( gl, capabilities, textures ) {
|
|
|
|
|
|
const objectInfluences = object.morphTargetInfluences;
|
|
|
|
|
|
- // instead of using attributes, the WebGL 2 code path encodes morph targets
|
|
|
- // into an array of data textures. Each layer represents a single morph target.
|
|
|
+ // the following encodes morph targets into an array of data textures. Each layer represents a single morph target.
|
|
|
|
|
|
const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
|
|
|
const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
|
|
@@ -17991,9 +18019,7 @@ function WebGLObjects( gl, geometries, attributes, info ) {
|
|
|
|
|
|
class DepthTexture extends Texture {
|
|
|
|
|
|
- constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
|
|
|
-
|
|
|
- format = format !== undefined ? format : DepthFormat;
|
|
|
+ constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format = DepthFormat ) {
|
|
|
|
|
|
if ( format !== DepthFormat && format !== DepthStencilFormat ) {
|
|
|
|
|
@@ -19817,7 +19843,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
parameters.morphTargets ? '#define USE_MORPHTARGETS' : '',
|
|
|
parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '',
|
|
|
( parameters.morphColors ) ? '#define USE_MORPHCOLORS' : '',
|
|
|
- ( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE' : '',
|
|
|
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE_STRIDE ' + parameters.morphTextureStride : '',
|
|
|
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '',
|
|
|
parameters.doubleSided ? '#define DOUBLE_SIDED' : '',
|
|
@@ -19898,31 +19923,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
|
|
|
'#endif',
|
|
|
|
|
|
- '#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )',
|
|
|
-
|
|
|
- ' attribute vec3 morphTarget0;',
|
|
|
- ' attribute vec3 morphTarget1;',
|
|
|
- ' attribute vec3 morphTarget2;',
|
|
|
- ' attribute vec3 morphTarget3;',
|
|
|
-
|
|
|
- ' #ifdef USE_MORPHNORMALS',
|
|
|
-
|
|
|
- ' attribute vec3 morphNormal0;',
|
|
|
- ' attribute vec3 morphNormal1;',
|
|
|
- ' attribute vec3 morphNormal2;',
|
|
|
- ' attribute vec3 morphNormal3;',
|
|
|
-
|
|
|
- ' #else',
|
|
|
-
|
|
|
- ' attribute vec3 morphTarget4;',
|
|
|
- ' attribute vec3 morphTarget5;',
|
|
|
- ' attribute vec3 morphTarget6;',
|
|
|
- ' attribute vec3 morphTarget7;',
|
|
|
-
|
|
|
- ' #endif',
|
|
|
-
|
|
|
- '#endif',
|
|
|
-
|
|
|
'#ifdef USE_SKINNING',
|
|
|
|
|
|
' attribute vec4 skinIndex;',
|
|
@@ -30666,24 +30666,159 @@ class WebGLRenderer {
|
|
|
|
|
|
};
|
|
|
|
|
|
- this.copyFramebufferToTexture = function ( position, texture, level = 0 ) {
|
|
|
+ this.readRenderTargetPixelsAsync = async function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
|
|
|
+
|
|
|
+ if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
|
|
|
+
|
|
|
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ let framebuffer = properties.get( renderTarget ).__webglFramebuffer;
|
|
|
+ if ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) {
|
|
|
+
|
|
|
+ framebuffer = framebuffer[ activeCubeFaceIndex ];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( framebuffer ) {
|
|
|
+
|
|
|
+ state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ const texture = renderTarget.texture;
|
|
|
+ const textureFormat = texture.format;
|
|
|
+ const textureType = texture.type;
|
|
|
+
|
|
|
+ if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
|
+
|
|
|
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( ! capabilities.textureTypeReadable( textureType ) ) {
|
|
|
+
|
|
|
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
|
|
|
+ if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
|
+
|
|
|
+ const glBuffer = _gl.createBuffer();
|
|
|
+ _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
|
+ _gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
|
|
|
+ _gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
|
|
|
+ _gl.flush();
|
|
|
+
|
|
|
+ // check if the commands have finished every 8 ms
|
|
|
+ const sync = _gl.fenceSync( _gl.SYNC_GPU_COMMANDS_COMPLETE, 0 );
|
|
|
+ await probeAsync( _gl, sync, 4 );
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
|
+ _gl.getBufferSubData( _gl.PIXEL_PACK_BUFFER, 0, buffer );
|
|
|
+
|
|
|
+ } finally {
|
|
|
+
|
|
|
+ _gl.deleteBuffer( glBuffer );
|
|
|
+ _gl.deleteSync( sync );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return buffer;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } finally {
|
|
|
+
|
|
|
+ // restore framebuffer of current render target if necessary
|
|
|
+
|
|
|
+ const framebuffer = ( _currentRenderTarget !== null ) ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
|
|
|
+ state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ this.copyFramebufferToTexture = function ( texture, position = null, level = 0 ) {
|
|
|
+
|
|
|
+ // support previous signature with position first
|
|
|
+ if ( texture.isTexture !== true ) {
|
|
|
+
|
|
|
+ // @deprecated, r165
|
|
|
+ console.warn( 'WebGLRenderer: copyFramebufferToTexture function signature has changed.' );
|
|
|
+
|
|
|
+ position = arguments[ 0 ] || null;
|
|
|
+ texture = arguments[ 1 ];
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
const levelScale = Math.pow( 2, - level );
|
|
|
const width = Math.floor( texture.image.width * levelScale );
|
|
|
const height = Math.floor( texture.image.height * levelScale );
|
|
|
|
|
|
+ const x = position !== null ? position.x : 0;
|
|
|
+ const y = position !== null ? position.y : 0;
|
|
|
+
|
|
|
textures.setTexture2D( texture, 0 );
|
|
|
|
|
|
- _gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0, position.x, position.y, width, height );
|
|
|
+ _gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0, x, y, width, height );
|
|
|
|
|
|
state.unbindTexture();
|
|
|
|
|
|
};
|
|
|
|
|
|
- this.copyTextureToTexture = function ( position, srcTexture, dstTexture, level = 0 ) {
|
|
|
+ this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
|
+
|
|
|
+ // support previous signature with dstPosition first
|
|
|
+ if ( srcTexture.isTexture !== true ) {
|
|
|
+
|
|
|
+ // @deprecated, r165
|
|
|
+ console.warn( 'WebGLRenderer: copyTextureToTexture function signature has changed.' );
|
|
|
+
|
|
|
+ dstPosition = arguments[ 0 ] || null;
|
|
|
+ srcTexture = arguments[ 1 ];
|
|
|
+ dstTexture = arguments[ 2 ];
|
|
|
+ level = arguments[ 3 ] || 0;
|
|
|
+ srcRegion = null;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 width = srcTexture.image.width;
|
|
|
- const height = srcTexture.image.height;
|
|
|
const glFormat = utils.convert( dstTexture.format );
|
|
|
const glType = utils.convert( dstTexture.type );
|
|
|
|
|
@@ -30695,24 +30830,43 @@ class WebGLRenderer {
|
|
|
_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.isDataTexture ) {
|
|
|
|
|
|
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );
|
|
|
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if ( srcTexture.isCompressedTexture ) {
|
|
|
|
|
|
- _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data );
|
|
|
+ _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, glFormat, glType, srcTexture.image );
|
|
|
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, 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 );
|
|
|
|
|
@@ -30720,11 +30874,59 @@ class WebGLRenderer {
|
|
|
|
|
|
};
|
|
|
|
|
|
- this.copyTextureToTexture3D = function ( sourceBox, position, srcTexture, dstTexture, level = 0 ) {
|
|
|
+ this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
|
+
|
|
|
+ // support previous signature with source box first
|
|
|
+ if ( srcTexture.isTexture !== true ) {
|
|
|
+
|
|
|
+ // @deprecated, r165
|
|
|
+ console.warn( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
|
|
|
+
|
|
|
+ srcRegion = arguments[ 0 ] || null;
|
|
|
+ dstPosition = arguments[ 1 ] || null;
|
|
|
+ srcTexture = arguments[ 2 ];
|
|
|
+ dstTexture = arguments[ 3 ];
|
|
|
+ level = arguments[ 4 ] || 0;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ let width, height, depth, minX, minY, minZ;
|
|
|
+ let dstX, dstY, dstZ;
|
|
|
+ const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
|
+ if ( srcRegion !== null ) {
|
|
|
+
|
|
|
+ width = srcRegion.max.x - srcRegion.min.x;
|
|
|
+ height = srcRegion.max.y - srcRegion.min.y;
|
|
|
+ depth = srcRegion.max.z - srcRegion.min.z;
|
|
|
+ minX = srcRegion.min.x;
|
|
|
+ minY = srcRegion.min.y;
|
|
|
+ minZ = srcRegion.min.z;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ width = image.width;
|
|
|
+ height = image.height;
|
|
|
+ depth = image.depth;
|
|
|
+ minX = 0;
|
|
|
+ minY = 0;
|
|
|
+ minZ = 0;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( dstPosition !== null ) {
|
|
|
+
|
|
|
+ dstX = dstPosition.x;
|
|
|
+ dstY = dstPosition.y;
|
|
|
+ dstZ = dstPosition.z;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ dstX = 0;
|
|
|
+ dstY = 0;
|
|
|
+ dstZ = 0;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- const width = sourceBox.max.x - sourceBox.min.x;
|
|
|
- const height = sourceBox.max.y - sourceBox.min.y;
|
|
|
- const depth = sourceBox.max.z - sourceBox.min.z;
|
|
|
const glFormat = utils.convert( dstTexture.format );
|
|
|
const glType = utils.convert( dstTexture.type );
|
|
|
let glTarget;
|
|
@@ -30750,43 +30952,41 @@ class WebGLRenderer {
|
|
|
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
|
|
|
|
- const unpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
|
- const unpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
|
- const unpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
|
- const unpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
|
- const unpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
|
-
|
|
|
- const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
|
+ 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 );
|
|
|
|
|
|
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
|
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, sourceBox.min.x );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, sourceBox.min.y );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, sourceBox.min.z );
|
|
|
+ _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
|
|
|
+ _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
|
|
|
+ _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
|
|
|
|
|
|
if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
|
|
|
|
|
|
- _gl.texSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image.data );
|
|
|
+ _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if ( dstTexture.isCompressedArrayTexture ) {
|
|
|
|
|
|
- _gl.compressedTexSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, image.data );
|
|
|
+ _gl.compressedTexSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- _gl.texSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image );
|
|
|
+ _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, unpackRowLen );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, unpackImageHeight );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, unpackSkipPixels );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, unpackSkipRows );
|
|
|
- _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, unpackSkipImages );
|
|
|
+ _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( glTarget );
|
|
@@ -30795,6 +30995,16 @@ class WebGLRenderer {
|
|
|
|
|
|
};
|
|
|
|
|
|
+ this.initRenderTarget = function ( target ) {
|
|
|
+
|
|
|
+ if ( properties.get( target ).__webglFramebuffer === undefined ) {
|
|
|
+
|
|
|
+ textures.setupRenderTarget( target );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
this.initTexture = function ( texture ) {
|
|
|
|
|
|
if ( texture.isCubeTexture ) {
|
|
@@ -42661,7 +42871,16 @@ KeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear;
|
|
|
/**
|
|
|
* A Track of Boolean keyframe values.
|
|
|
*/
|
|
|
-class BooleanKeyframeTrack extends KeyframeTrack {}
|
|
|
+class BooleanKeyframeTrack extends KeyframeTrack {
|
|
|
+
|
|
|
+ // No interpolation parameter because only InterpolateDiscrete is valid.
|
|
|
+ constructor( name, times, values ) {
|
|
|
+
|
|
|
+ super( name, times, values );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
BooleanKeyframeTrack.prototype.ValueTypeName = 'bool';
|
|
|
BooleanKeyframeTrack.prototype.ValueBufferType = Array;
|
|
@@ -42732,13 +42951,22 @@ class QuaternionKeyframeTrack extends KeyframeTrack {
|
|
|
|
|
|
QuaternionKeyframeTrack.prototype.ValueTypeName = 'quaternion';
|
|
|
// ValueBufferType is inherited
|
|
|
-QuaternionKeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear;
|
|
|
+// DefaultInterpolation is inherited;
|
|
|
QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined;
|
|
|
|
|
|
/**
|
|
|
* A Track that interpolates Strings
|
|
|
*/
|
|
|
-class StringKeyframeTrack extends KeyframeTrack {}
|
|
|
+class StringKeyframeTrack extends KeyframeTrack {
|
|
|
+
|
|
|
+ // No interpolation parameter because only InterpolateDiscrete is valid.
|
|
|
+ constructor( name, times, values ) {
|
|
|
+
|
|
|
+ super( name, times, values );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
StringKeyframeTrack.prototype.ValueTypeName = 'string';
|
|
|
StringKeyframeTrack.prototype.ValueBufferType = Array;
|
|
@@ -45450,7 +45678,9 @@ class MaterialLoader extends Loader {
|
|
|
|
|
|
class LoaderUtils {
|
|
|
|
|
|
- static decodeText( array ) {
|
|
|
+ static decodeText( array ) { // @deprecated, r165
|
|
|
+
|
|
|
+ console.warn( 'THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead.' );
|
|
|
|
|
|
if ( typeof TextDecoder !== 'undefined' ) {
|
|
|
|