-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct clipping of children in render-to-texture nodes (#458)
This PR resolves an issue where children nodes rendered as part of a render-to-texture were not properly clipped according to the parent node's bounds. The fix ensures that clipping is correctly applied within the render-to-texture pipeline, maintaining visual consistency and expected behavior for nested scenes
- Loading branch information
Showing
2 changed files
with
88 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import type { ExampleSettings } from '../common/ExampleSettings.js'; | ||
import rocko from '../assets/rocko.png'; | ||
|
||
export default async function test({ renderer, testRoot }: ExampleSettings) { | ||
const node = renderer.createNode({ | ||
x: 0, | ||
y: 0, | ||
width: 1920, | ||
height: 1080, | ||
color: 0x000000ff, | ||
parent: testRoot, | ||
}); | ||
|
||
// RTT Node 1 | ||
const rttNode = renderer.createNode({ | ||
x: 100, | ||
y: 200, | ||
width: 400, | ||
height: 400, | ||
parent: node, | ||
rtt: true, | ||
zIndex: 5, | ||
colorTop: 0xfff00fff, | ||
colorBottom: 0x00ffffff, | ||
}); | ||
|
||
const rect = renderer.createNode({ | ||
x: 0, | ||
y: 0, | ||
width: 300, | ||
height: 300, | ||
parent: rttNode, | ||
clipping: true, | ||
color: 0xff0000ff, | ||
}); | ||
|
||
renderer.createTextNode({ | ||
x: 0, | ||
y: 0, | ||
text: 'Render to texture', | ||
parent: rttNode, | ||
fontSize: 48, | ||
color: 0xffffffff, | ||
fontFamily: 'Ubuntu', | ||
}); | ||
|
||
renderer.createNode({ | ||
x: 50, | ||
y: 100, | ||
width: 600, | ||
height: 600, | ||
parent: rttNode, | ||
src: rocko, | ||
}); | ||
|
||
window.addEventListener('keydown', (e) => { | ||
if (e.key === 's') { | ||
// rect.clipping = !rect.clipping; | ||
rect | ||
.animate( | ||
{ | ||
x: 100, //going to render out of bounds as well | ||
}, | ||
{ | ||
duration: 3000, | ||
easing: 'ease-out', | ||
loop: true, | ||
stopMethod: 'reverse', | ||
}, | ||
) | ||
.start(); | ||
} | ||
}); | ||
|
||
// Define the page function to configure different test scenarios | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters