Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,11 @@ async function runAutomation(
},
memMonitor: null,
};
await automation(exampleSettings);
try {
await automation(exampleSettings);
} catch (err) {
console.error(`Automation for ${testName} threw:`, err);
}
testRoot.parent = null;
testRoot.destroy();
}
Expand Down
188 changes: 0 additions & 188 deletions examples/tests/animation-events.ts

This file was deleted.

2 changes: 2 additions & 0 deletions examples/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export default defineConfig(({ command, mode, isSsrBuild }) => {
define: {
__DEV__: true,
__enableAutosize__: process.env.VRT_AUTOSIZE === 'true',
__emitBoundsEvents__: true,
__RTT__: true,
},
};
});
15 changes: 13 additions & 2 deletions src/core/CoreNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2577,10 +2577,21 @@ export class CoreNode extends EventEmitter {
return;
}

// If there's still an RTT ancestor higher up (nested RTT case), descendants
// should inherit from that ancestor rather than be detached from RTT
// entirely. Otherwise — when this node was the only RTT in the chain —
// fully clear inheritance.
const ancestorRTT = this.findParentRTTNode();

for (const child of this.children) {
if (ancestorRTT !== null) {
child.parentHasRenderTexture = true;
child.rttParent = ancestorRTT;
} else {
child.parentHasRenderTexture = false;
child.rttParent = null;
}
// force child to update everything as the RTT inheritance has changed
child.parentHasRenderTexture = false;
child.rttParent = null;
child.setUpdateType(UpdateType.All);
child.clearRTTInheritance();
}
Expand Down
6 changes: 6 additions & 0 deletions src/core/Stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,12 @@ export class Stage {
this.strictBound,
this.boundsMargin,
);
// The frame loop walks root.children directly without running root.update
// (see this.update), so root.createRenderBounds is never invoked. Refresh
// root's bounds in lockstep with the stage so descendants pick up the new
// viewport via createRenderBounds' parent.strictBound copy.
this.root.strictBound = this.strictBound;
this.root.preloadBound = this.preloadBound;
this.root.setUpdateType(UpdateType.RenderBounds | UpdateType.Children);
this.root.childUpdateType |= UpdateType.RenderBounds;
}
Expand Down
30 changes: 25 additions & 5 deletions src/core/renderers/webgl/WebGlRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ export class WebGlRenderer extends CoreRenderer {
quadBuffer: ArrayBuffer;
fQuadBuffer: Float32Array;
uiQuadBuffer: Uint32Array;
/**
* Separate buffer for RTT quad data. Required when DIRTY_QUAD_BUFFER is on:
* main-scene nodes own permanent slots in `quadBuffer` and only rewrite when
* dirty, so if RTT wrote into the same backing storage starting at index 0
* it would silently overwrite (and corrupt) main-scene slots whose owners
* aren't dirty this frame. Allocated lazily on first RTT.
*/
rttQuadBuffer: ArrayBuffer | null = null;
fRttQuadBuffer: Float32Array | null = null;
uiRttQuadBuffer: Uint32Array | null = null;
renderOps: WebGlRenderOp[] = [];
/**
* Deferred queue for SDF text render ops, used when RENDER_TEXT_BATCHING is
Expand Down Expand Up @@ -373,8 +383,17 @@ export class WebGlRenderer extends CoreRenderer {
* The function updates the length and number of quads in the current render operation, and updates the current buffer index.
*/
addQuad(node: CoreNode) {
const f = this.fQuadBuffer;
const u = this.uiQuadBuffer;
let f = this.fQuadBuffer;
let u = this.uiQuadBuffer;
if (USE_RTT && this.renderToTextureActive === true) {
if (this.fRttQuadBuffer === null) {
this.rttQuadBuffer = new ArrayBuffer(this.stage.options.quadBufferSize);
this.fRttQuadBuffer = new Float32Array(this.rttQuadBuffer);
this.uiRttQuadBuffer = new Uint32Array(this.rttQuadBuffer);
}
f = this.fRttQuadBuffer;
u = this.uiRttQuadBuffer!;
}

// Explicit zIndex on a non-text quad opts out of the text-batching
// ordering: flush deferred text now so this quad lands above any text
Expand Down Expand Up @@ -1186,12 +1205,13 @@ export class WebGlRenderer extends CoreRenderer {
if (RENDER_TEXT_BATCHING === true) {
this.flushTextRenderOps();
}
const { glw, quadBuffer } = this;
const { glw } = this;
const buffer = this.quadBufferCollection.getBuffer('a_position') || null;

// Always do a full upload for RTT — the buffer is rebuilt from scratch
// each frame with sequential slots starting at index 0.
const arr = new Float32Array(quadBuffer, 0, this.curBufferIdx);
// each frame with sequential slots starting at index 0. Upload from the
// dedicated RTT ArrayBuffer so we don't read stale main-scene data.
const arr = new Float32Array(this.rttQuadBuffer!, 0, this.curBufferIdx);
glw.arrayBufferData(buffer, arr, glw.STATIC_DRAW);

for (let i = 0, length = this.renderOps.length; i < length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/text-rendering/SdfTextRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const font: FontHandler = SdfFontHandler;
const layoutCache = new Map<string, TextLayout>();

const getLayoutCacheKey = (props: CoreTextNodeProps): string =>
`${props.fontFamily}-${props.fontSize}-${props.letterSpacing}-${props.lineHeight}-${props.maxHeight}-${props.maxWidth}-${props.textAlign}-${props.text}`;
`${props.fontFamily}-${props.fontSize}-${props.letterSpacing}-${props.lineHeight}-${props.maxHeight}-${props.maxWidth}-${props.maxLines}-${props.textAlign}-${props.wordBreak}-${props.overflowSuffix}-${props.text}`;

/**
* SDF text renderer using MSDF/SDF fonts with WebGL
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading