From a32b50b89052d15e9d12230f4c10a4a90233ef79 Mon Sep 17 00:00:00 2001 From: Dave Pagurek Date: Sat, 17 Jan 2026 15:22:37 -0500 Subject: [PATCH] Fix rotation accidentally applying to main canvas --- preview/index.html | 1 + src/webgpu/p5.RendererWebGPU.js | 1 + test/unit/visual/cases/webgpu.js | 10 ++++++++++ .../outside of push() and pop()/000.png | Bin 0 -> 424 bytes .../outside of push() and pop()/metadata.json | 3 +++ 5 files changed, 15 insertions(+) create mode 100644 test/unit/visual/screenshots/WebGPU/transformation/outside of push() and pop()/000.png create mode 100644 test/unit/visual/screenshots/WebGPU/transformation/outside of push() and pop()/metadata.json diff --git a/preview/index.html b/preview/index.html index 3584e5e251..ed76b913f5 100644 --- a/preview/index.html +++ b/preview/index.html @@ -107,6 +107,7 @@ p.draw = function () { p.clear(); + p.rotateY(p.millis() * 0.001); p.push(); //p.clip(() => p.rect(-50, -50, 200, 200)); /*p.orbitControl(); diff --git a/src/webgpu/p5.RendererWebGPU.js b/src/webgpu/p5.RendererWebGPU.js index 8ed51bd96a..4ef6f1934a 100644 --- a/src/webgpu/p5.RendererWebGPU.js +++ b/src/webgpu/p5.RendererWebGPU.js @@ -1013,6 +1013,7 @@ function rendererWebGPU(p5, fn) { this.states.setValue('activeImageLight', null); this._pInst.setCamera(this.finalCamera); this._pInst.resetShader(); + this._pInst.resetMatrix(); this._pInst.imageMode(this._pInst.CENTER); this._pInst.image(this.mainFramebuffer, 0, 0); this._pInst.pop(); diff --git a/test/unit/visual/cases/webgpu.js b/test/unit/visual/cases/webgpu.js index 45c793a322..41ff0f9326 100644 --- a/test/unit/visual/cases/webgpu.js +++ b/test/unit/visual/cases/webgpu.js @@ -844,4 +844,14 @@ visualSuite("WebGPU", function () { ); } }); + + visualSuite('transformation', function() { + visualTest('outside of push() and pop()', async function (p5, screenshot) { + await p5.createCanvas(50, 50, p5.WEBGPU); + p5.background(200); + p5.rotateY(p5.PI * 0.1); + p5.box(30); + await screenshot(); + }); + }); }); diff --git a/test/unit/visual/screenshots/WebGPU/transformation/outside of push() and pop()/000.png b/test/unit/visual/screenshots/WebGPU/transformation/outside of push() and pop()/000.png new file mode 100644 index 0000000000000000000000000000000000000000..831a6032bc2f1b09da1137ea538234793e37060e GIT binary patch literal 424 zcmV;Z0ayNsP)k~Q+(#T%h zjCW@IQcC@N177qcAA~$DNF;(pJUM`;<;mFFw3msj>q>p!pD4?cY$QoS8up&AntO7o zbqZk-!!S@3MJMt+r?zcR1VKP)n$k2)2h2U6bH4ZALik`^*JOhmH^Jx3`V(`$(*O-TF*ArdZ1av%{&Hzl}`h=hxh97sgcO$ja} zBH^MW2NIEVQ-TYLNVq7;fkY(Tl;A=l5-v(|Tqd$C3pGvihIyW8{)28p*Pj~oz4qu7 z62~!xVMyDyy`icq(iq3_5S3-wxu*97#!Jq9-)#*??G(a0ET$+5GSPJ%nNUg*!(8({ z=YF_98<#@tgHNv^