Skip to content

Commit

Permalink
WebGPURenderer: Add copyTextureToTexture support (#864)
Browse files Browse the repository at this point in the history
* WebGPURenderer: Add copyTextureToTexture support

* Add examples

* Update patch

* Remove examples

* Format
  • Loading branch information
Methuselah96 authored Mar 23, 2024
1 parent 5cf9c0a commit aa83cbd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
33 changes: 30 additions & 3 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -13999,6 +13999,33 @@ index ca0ae9e..2125232 100644
const windowHalfX = window.innerWidth / 2;
const windowHalfY = window.innerHeight / 2;

diff --git a/examples-testing/examples/webgpu_materials_texture_partialupdate.ts b/examples-testing/examples/webgpu_materials_texture_partialupdate.ts
index 3fb91ed..67f2f7b 100644
--- a/examples-testing/examples/webgpu_materials_texture_partialupdate.ts
+++ b/examples-testing/examples/webgpu_materials_texture_partialupdate.ts
@@ -1,7 +1,12 @@
import * as THREE from 'three';
import WebGPURenderer from 'three/addons/renderers/webgpu/WebGPURenderer.js';

-let camera, scene, renderer, clock, dataTexture, diffuseMap;
+let camera: THREE.PerspectiveCamera,
+ scene: THREE.Scene,
+ renderer: WebGPURenderer,
+ clock: THREE.Clock,
+ dataTexture: THREE.DataTexture,
+ diffuseMap: THREE.Texture;

let last = 0;
const position = new THREE.Vector2();
@@ -79,7 +84,7 @@ async function animate() {
}
}

-function updateDataTexture(texture) {
+function updateDataTexture(texture: THREE.DataTexture) {
const size = texture.image.width * texture.image.height;
const data = texture.image.data;

diff --git a/examples-testing/examples/webgpu_materials_video.ts b/examples-testing/examples/webgpu_materials_video.ts
index fbbabfc..a1a82bd 100644
--- a/examples-testing/examples/webgpu_materials_video.ts
Expand Down Expand Up @@ -14496,7 +14523,7 @@ index b659652..06e3224 100644
//

diff --git a/examples-testing/examples/webxr_vr_sandbox.ts b/examples-testing/examples/webxr_vr_sandbox.ts
index d8212a4..3302cb5 100644
index 27c8572..0e78647 100644
--- a/examples-testing/examples/webxr_vr_sandbox.ts
+++ b/examples-testing/examples/webxr_vr_sandbox.ts
@@ -12,9 +12,9 @@ import { XRControllerModelFactory } from 'three/addons/webxr/XRControllerModelFa
Expand All @@ -14512,7 +14539,7 @@ index d8212a4..3302cb5 100644

const parameters = {
radius: 0.6,
@@ -200,7 +200,7 @@ function animate() {
@@ -199,7 +199,7 @@ function animate() {

function render() {
const time = performance.now() * 0.0002;
Expand All @@ -14521,7 +14548,7 @@ index d8212a4..3302cb5 100644
torus.rotation.x = time * 0.4;
torus.rotation.y = time;

@@ -208,5 +208,9 @@ function render() {
@@ -207,5 +207,9 @@ function render() {
stats.update();

// Canvas elements doesn't trigger DOM updates, so we have to update the texture
Expand Down
3 changes: 3 additions & 0 deletions types/three/examples/jsm/renderers/common/Renderer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
RenderTarget,
Scene,
ShadowMapType,
Texture,
ToneMapping,
Vector2,
Vector4,
Expand Down Expand Up @@ -268,6 +269,8 @@ export default class Renderer {

copyFramebufferToTexture(framebufferTexture: FramebufferTexture): void;

copyTextureToTexture(position: Vector2, srcTexture: Texture, dstTexture: Texture, level?: number): void;

readRenderTargetPixelsAsync(
renderTarget: RenderTarget,
x: number,
Expand Down

0 comments on commit aa83cbd

Please sign in to comment.