Skip to content

Commit

Permalink
WebGLRenderer: Enable subframe upload in copyTextureToTexture, align …
Browse files Browse the repository at this point in the history
…API to 3d version (#956)

* WebGLRenderer: Enable subframe upload in copyTextureToTexture

* Update three.js

* Add examples

* Update patch

* Delete examples
  • Loading branch information
Methuselah96 authored May 18, 2024
1 parent af22e44 commit a408595
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
10 changes: 5 additions & 5 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ index 977dbadb..fb1460ca 100644
material.uniforms['u_renderthreshold'].value = volconfig.isothreshold; // For ISO renderstyle
material.uniforms['u_cmdata'].value = cmtextures[volconfig.colormap];
diff --git a/examples-testing/examples/webgl2_materials_texture3d_partialupdate.ts b/examples-testing/examples/webgl2_materials_texture3d_partialupdate.ts
index fc2fc783..cd17b027 100644
index 1ad6d264..10b32582 100644
--- a/examples-testing/examples/webgl2_materials_texture3d_partialupdate.ts
+++ b/examples-testing/examples/webgl2_materials_texture3d_partialupdate.ts
@@ -6,14 +6,14 @@ import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
Expand Down Expand Up @@ -1987,8 +1987,8 @@ index fc2fc783..cd17b027 100644
const scaleFactor = (Math.random() + 0.5) * 0.5;
const source = generateCloudTexture(perElementPaddedSize, scaleFactor);

- renderer.copyTextureToTexture3D(box, position, source, cloudTexture);
+ renderer.copyTextureToTexture3D(box, position, source, cloudTexture!);
- renderer.copyTextureToTexture3D(source, cloudTexture, box, position);
+ renderer.copyTextureToTexture3D(source, cloudTexture!, box, position);

prevTime = time;

Expand Down Expand Up @@ -5901,7 +5901,7 @@ index adfcfddf..d26cee37 100644
INTERSECTED = null;
}
diff --git a/examples-testing/examples/webgl_interactive_cubes_gpu.ts b/examples-testing/examples/webgl_interactive_cubes_gpu.ts
index 313b023a..7e77fbc5 100644
index 2644469c..d48fa232 100644
--- a/examples-testing/examples/webgl_interactive_cubes_gpu.ts
+++ b/examples-testing/examples/webgl_interactive_cubes_gpu.ts
@@ -5,12 +5,12 @@ import Stats from 'three/addons/libs/stats.module.js';
Expand Down Expand Up @@ -9104,7 +9104,7 @@ index 24bd4eb9..5d5e77b6 100644
mouseY = event.clientY - windowHalfY;
}
diff --git a/examples-testing/examples/webgl_materials_texture_partialupdate.ts b/examples-testing/examples/webgl_materials_texture_partialupdate.ts
index 04844817..2f734b77 100644
index 5adfc8e6..55d802e3 100644
--- a/examples-testing/examples/webgl_materials_texture_partialupdate.ts
+++ b/examples-testing/examples/webgl_materials_texture_partialupdate.ts
@@ -1,6 +1,11 @@
Expand Down
27 changes: 19 additions & 8 deletions types/three/src/renderers/WebGLRenderer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TypedArray } from "../core/BufferAttribute.js";
import { BufferGeometry } from "../core/BufferGeometry.js";
import { Object3D } from "../core/Object3D.js";
import { Material } from "../materials/Material.js";
import { Box2 } from "../math/Box2.js";
import { Box3 } from "../math/Box3.js";
import { Color, ColorRepresentation } from "../math/Color.js";
import { Plane } from "../math/Plane.js";
Expand Down Expand Up @@ -447,28 +448,38 @@ export class WebGLRenderer implements Renderer {
copyFramebufferToTexture(position: Vector2, texture: Texture, level?: number): void;

/**
* Copies srcTexture to the specified level of dstTexture, offset by the input position.
* Copies the pixels of a texture in the bounds `srcRegion` in the destination texture starting from the given
* position.
*
* @param position Specifies the pixel offset into the dstTexture where the copy will occur.
* @param srcTexture Specifies the source texture.
* @param dstTexture Specifies the destination texture.
* @param srcRegion Specifies the bounds
* @param dstPosition Specifies the pixel offset into the dstTexture where the copy will occur.
* @param level Specifies the destination mipmap level of the texture.
*/
copyTextureToTexture(position: Vector2, srcTexture: Texture, dstTexture: Texture, level?: number): void;
copyTextureToTexture(
srcTexture: Texture,
dstTexture: Texture,
srcRegion?: Box2 | null,
dstPosition?: Vector2 | null,
level?: number,
): void;

/**
* Copies the pixels of a texture in the bounds sourceBox in the desination texture starting from the given position.
* @param sourceBox Specifies the bounds
* @param position Specifies the pixel offset into the dstTexture where the copy will occur.
* Copies the pixels of a texture in the bounds `srcRegion` in the destination texture starting from the given
* position.
*
* @param srcTexture Specifies the source texture.
* @param dstTexture Specifies the destination texture.
* @param srcRegion Specifies the bounds
* @param dstPosition Specifies the pixel offset into the dstTexture where the copy will occur.
* @param level Specifies the destination mipmap level of the texture.
*/
copyTextureToTexture3D(
sourceBox: Box3,
position: Vector3,
srcTexture: Texture,
dstTexture: Data3DTexture | DataArrayTexture,
srcRegion?: Box3 | null,
dstPosition?: Vector3 | null,
level?: number,
): void;

Expand Down

0 comments on commit a408595

Please sign in to comment.