Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions examples/jsm/misc/VolumeSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,30 @@ class VolumeSlice {
*/
this.ctxBuffer;

/**
* Width of slice in the original coordinate system, corresponds to the width of the buffer canvas.
*
* @type {number}
* @default 0
*/
this.iLength = 0;

/**
* Height of slice in the original coordinate system, corresponds to the height of the buffer canvas.
*
* @type {number}
* @default 0
*/
this.jLength = 0;

/**
* Function that allow the slice to access right data.
*
* @type {?Function}
* @see {@link Volume#extractPerpendicularPlane}
*/
this.sliceAccess = null;

this.updateGeometry();


Expand Down Expand Up @@ -120,30 +144,6 @@ class VolumeSlice {
this.geometryNeedsUpdate = true;
this.repaint();

/**
* Width of slice in the original coordinate system, corresponds to the width of the buffer canvas.
*
* @type {number}
* @default 0
*/
this.iLength = 0;

/**
* Height of slice in the original coordinate system, corresponds to the height of the buffer canvas.
*
* @type {number}
* @default 0
*/
this.jLength = 0;

/**
* Function that allow the slice to access right data.
*
* @type {?Function}
* @see {@link Volume#extractPerpendicularPlane}
*/
this.sliceAccess = null;

}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/common/Backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ class Backend {
* @param {number} y - The y coordinate of the copy origin.
* @param {number} width - The width of the copy.
* @param {number} height - The height of the copy.
* @param {number} faceIndex - The face index.
* @param {number} faceIndex - The cube face, depth slice or array layer index.
* @return {Promise<TypedArray>} A Promise that resolves with a typed array when the copy operation has finished.
*/
async copyTextureToBuffer( /*texture, x, y, width, height, faceIndex*/ ) {}
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3214,7 +3214,7 @@ class Renderer {
* @param {number} width - The width of the copy region.
* @param {number} height - The height of the copy region.
* @param {number} [textureIndex=0] - The texture index of a MRT render target.
* @param {number} [faceIndex=0] - The active cube face index.
* @param {number} [faceIndex=0] - The cube face, depth slice or array layer index.
* @return {Promise<TypedArray>} A Promise that resolves when the read has been finished. The resolve provides the read data as a typed array.
*/
async readRenderTargetPixelsAsync( renderTarget, x, y, width, height, textureIndex = 0, faceIndex = 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/webgl-fallback/WebGLBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ class WebGLBackend extends Backend {
* @param {number} y - The y coordinate of the copy origin.
* @param {number} width - The width of the copy.
* @param {number} height - The height of the copy.
* @param {number} faceIndex - The face index.
* @param {number} faceIndex - The cube face, depth slice or array layer index.
* @return {Promise<TypedArray>} A Promise that resolves with a typed array when the copy operation has finished.
*/
async copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
Expand Down
14 changes: 11 additions & 3 deletions src/renderers/webgl-fallback/utils/WebGLTextureUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ class WebGLTextureUtils {
* @param {number} y - The y coordinate of the copy origin.
* @param {number} width - The width of the copy.
* @param {number} height - The height of the copy.
* @param {number} faceIndex - The face index.
* @param {number} faceIndex - The cube face, depth slice or array layer index.
* @return {Promise<TypedArray>} A Promise that resolves with a typed array when the copy operation has finished.
*/
async copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
Expand All @@ -1246,9 +1246,17 @@ class WebGLTextureUtils {

backend.state.bindFramebuffer( gl.READ_FRAMEBUFFER, fb );

const target = texture.isCubeTexture ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D;
if ( texture.isData3DTexture || texture.isDataArrayTexture || texture.isArrayTexture ) {

gl.framebufferTexture2D( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, target, textureGPU, 0 );
gl.framebufferTextureLayer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, textureGPU, 0, faceIndex );

} else {

const target = texture.isCubeTexture ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D;

gl.framebufferTexture2D( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, target, textureGPU, 0 );

}

const typedArrayType = this._getTypedArrayType( glType );
const bytesPerTexel = this._getBytesPerTexel( glType, glFormat );
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/webgpu/WebGPUBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,7 @@ class WebGPUBackend extends Backend {
* @param {number} y - The y coordinate of the copy origin.
* @param {number} width - The width of the copy.
* @param {number} height - The height of the copy.
* @param {number} faceIndex - The face index.
* @param {number} faceIndex - The cube face, depth slice or array layer index.
* @return {Promise<TypedArray>} A Promise that resolves with a typed array when the copy operation has finished.
*/
async copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/webgpu/utils/WebGPUTextureUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ class WebGPUTextureUtils {
* @param {number} y - The y coordinate of the copy origin.
* @param {number} width - The width of the copy.
* @param {number} height - The height of the copy.
* @param {number} faceIndex - The face index.
* @param {number} faceIndex - The cube face, depth slice or array layer index.
* @return {Promise<TypedArray>} A Promise that resolves with a typed array when the copy operation has finished.
*/
async copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
Expand Down
17 changes: 14 additions & 3 deletions src/renderers/webgpu/utils/WebGPUUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,21 @@ class WebGPUUtils {

} else if ( texture.isDepthTexture && ! texture.renderTarget ) {

const renderer = this.backend.renderer;
const renderTarget = renderer.getRenderTarget();
const textureData = this.backend.get( texture );

samples = renderTarget ? renderTarget.samples : renderer.currentSamples;
if ( textureData.texture !== undefined ) {

// use the effective sample count of the allocated texture

samples = textureData.texture.sampleCount;

} else {

// otherwise use the current samples of the renderer

samples = this.backend.renderer.currentSamples;

}

} else if ( texture.renderTarget ) {

Expand Down