Skip to content

Commit e9cbe6b

Browse files
committed
refactor: Improve RTT update graph and node insertion
This commit enhances the Render-to-Texture (RTT) node handling by refining inheritance, update propagation, and insertion logic: - RTT Inheritance Refactor: Streamlined RTT inheritance between child and parent nodes, ensuring a consistent RTT state across the hierarchy. - Efficient RTT Clearing: Optimized the clearing of RTT nodes - Update Loop Optimization: Removed duplicate `update()` calls for RTT nodes for improved performance - Hierarchical RTT Node Insertion: Implemented an insertion strategy that respects the hierarchy when adding new RTT nodes, ensuring that child RTT nodes render before parent RTT nodes.
1 parent 25f8b17 commit e9cbe6b

File tree

4 files changed

+265
-84
lines changed

4 files changed

+265
-84
lines changed

examples/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,9 @@ async function runAutomation(
382382
// Override Math.random() as stable random number generator
383383
// - Each test gets the same sequence of random numbers
384384
// - This only is in effect when tests are run in automation mode
385-
const rand = mt19937.factory({ seed: 1234 });
385+
// eslint-disable-next-line @typescript-eslint/unbound-method
386+
const factory = mt19937.factory || mt19937.default.factory;
387+
const rand = factory({ seed: 1234 });
386388
Math.random = function () {
387389
return rand() / rand.MAX;
388390
};

examples/tests/rtt-dimension.ts

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ import type { ExampleSettings } from '../common/ExampleSettings.js';
22
import rocko from '../assets/rocko.png';
33

44
export async function automation(settings: ExampleSettings) {
5-
await test(settings);
6-
await settings.snapshot();
5+
const page = await test(settings);
6+
7+
const maxPages = 6;
8+
for (let i = 0; i < maxPages; i++) {
9+
page(i);
10+
await settings.snapshot();
11+
}
712
}
813

914
export default async function test({ renderer, testRoot }: ExampleSettings) {
@@ -251,4 +256,44 @@ export default async function test({ renderer, testRoot }: ExampleSettings) {
251256
rttNode.height = rttNode.height === 200 ? 300 : 200;
252257
}
253258
});
259+
260+
// Define the page function to configure different test scenarios
261+
const page = (i = 0) => {
262+
switch (i) {
263+
case 1:
264+
rttNode.rtt = false;
265+
rttNode2.rtt = false;
266+
rttNode3.rtt = false;
267+
break;
268+
269+
case 2:
270+
rttNode.rtt = true;
271+
rttNode2.rtt = true;
272+
rttNode3.rtt = true;
273+
break;
274+
275+
case 4:
276+
// Modify child texture properties in nested RTT node
277+
rocko4.x = 0;
278+
break;
279+
280+
case 5:
281+
nestedRTTNode1.rtt = false;
282+
break;
283+
284+
case 6:
285+
nestedRTTNode1.rtt = true;
286+
break;
287+
288+
default:
289+
// Reset to initial state
290+
rttNode.rtt = true;
291+
rttNode2.rtt = true;
292+
rttNode3.rtt = true;
293+
nestedRTTNode1.rtt = true;
294+
break;
295+
}
296+
};
297+
298+
return page;
254299
}

0 commit comments

Comments
 (0)