Skip to content

Commit 723d2dc

Browse files
committed
Updated builds.
1 parent 1859806 commit 723d2dc

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

build/three.cjs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75658,8 +75658,9 @@ class WebGLRenderer {
7565875658
* @param {number} height - The height of the copy region.
7565975659
* @param {TypedArray} buffer - The result buffer.
7566075660
* @param {number} [activeCubeFaceIndex] - The active cube face index.
75661+
* @param {number} [textureIndex=0] - The texture index of an MRT render target.
7566175662
*/
75662-
this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
75663+
this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex, textureIndex = 0 ) {
7566375664

7566475665
if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
7566575666

@@ -75682,7 +75683,7 @@ class WebGLRenderer {
7568275683

7568375684
try {
7568475685

75685-
const texture = renderTarget.texture;
75686+
const texture = renderTarget.textures[ textureIndex ];
7568675687
const textureFormat = texture.format;
7568775688
const textureType = texture.type;
7568875689

@@ -75704,6 +75705,10 @@ class WebGLRenderer {
7570475705

7570575706
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
7570675707

75708+
// when using MRT, select the corect color buffer for the subsequent read command
75709+
75710+
if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
75711+
7570775712
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer );
7570875713

7570975714
}
@@ -75734,9 +75739,10 @@ class WebGLRenderer {
7573475739
* @param {number} height - The height of the copy region.
7573575740
* @param {TypedArray} buffer - The result buffer.
7573675741
* @param {number} [activeCubeFaceIndex] - The active cube face index.
75742+
* @param {number} [textureIndex=0] - The texture index of an MRT render target.
7573775743
* @return {Promise<TypedArray>} A Promise that resolves when the read has been finished. The resolve provides the read data as a typed array.
7573875744
*/
75739-
this.readRenderTargetPixelsAsync = async function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
75745+
this.readRenderTargetPixelsAsync = async function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex, textureIndex = 0 ) {
7574075746

7574175747
if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
7574275748

@@ -75759,7 +75765,7 @@ class WebGLRenderer {
7575975765
// set the active frame buffer to the one we want to read
7576075766
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
7576175767

75762-
const texture = renderTarget.texture;
75768+
const texture = renderTarget.textures[ textureIndex ];
7576375769
const textureFormat = texture.format;
7576475770
const textureType = texture.type;
7576575771

@@ -75778,6 +75784,11 @@ class WebGLRenderer {
7577875784
const glBuffer = _gl.createBuffer();
7577975785
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
7578075786
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
75787+
75788+
// when using MRT, select the corect color buffer for the subsequent read command
75789+
75790+
if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
75791+
7578175792
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
7578275793

7578375794
// reset the frame buffer to the currently set buffer before waiting

build/three.module.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17565,8 +17565,9 @@ class WebGLRenderer {
1756517565
* @param {number} height - The height of the copy region.
1756617566
* @param {TypedArray} buffer - The result buffer.
1756717567
* @param {number} [activeCubeFaceIndex] - The active cube face index.
17568+
* @param {number} [textureIndex=0] - The texture index of an MRT render target.
1756817569
*/
17569-
this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
17570+
this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex, textureIndex = 0 ) {
1757017571

1757117572
if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
1757217573

@@ -17589,7 +17590,7 @@ class WebGLRenderer {
1758917590

1759017591
try {
1759117592

17592-
const texture = renderTarget.texture;
17593+
const texture = renderTarget.textures[ textureIndex ];
1759317594
const textureFormat = texture.format;
1759417595
const textureType = texture.type;
1759517596

@@ -17611,6 +17612,10 @@ class WebGLRenderer {
1761117612

1761217613
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
1761317614

17615+
// when using MRT, select the corect color buffer for the subsequent read command
17616+
17617+
if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
17618+
1761417619
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer );
1761517620

1761617621
}
@@ -17641,9 +17646,10 @@ class WebGLRenderer {
1764117646
* @param {number} height - The height of the copy region.
1764217647
* @param {TypedArray} buffer - The result buffer.
1764317648
* @param {number} [activeCubeFaceIndex] - The active cube face index.
17649+
* @param {number} [textureIndex=0] - The texture index of an MRT render target.
1764417650
* @return {Promise<TypedArray>} A Promise that resolves when the read has been finished. The resolve provides the read data as a typed array.
1764517651
*/
17646-
this.readRenderTargetPixelsAsync = async function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
17652+
this.readRenderTargetPixelsAsync = async function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex, textureIndex = 0 ) {
1764717653

1764817654
if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
1764917655

@@ -17666,7 +17672,7 @@ class WebGLRenderer {
1766617672
// set the active frame buffer to the one we want to read
1766717673
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
1766817674

17669-
const texture = renderTarget.texture;
17675+
const texture = renderTarget.textures[ textureIndex ];
1767017676
const textureFormat = texture.format;
1767117677
const textureType = texture.type;
1767217678

@@ -17685,6 +17691,11 @@ class WebGLRenderer {
1768517691
const glBuffer = _gl.createBuffer();
1768617692
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
1768717693
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
17694+
17695+
// when using MRT, select the corect color buffer for the subsequent read command
17696+
17697+
if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
17698+
1768817699
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
1768917700

1769017701
// reset the frame buffer to the currently set buffer before waiting

build/three.module.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)