diff --git a/examples/tests/resize-mode.ts b/examples/tests/resize-mode.ts index 1c330cd3..3a960cfe 100644 --- a/examples/tests/resize-mode.ts +++ b/examples/tests/resize-mode.ts @@ -362,6 +362,53 @@ export default async function test(settings: ExampleSettings) { return rowNode.h; }, }, + { + title: + 'Texture Width > Height - resizeMode cover - update height after 20ms', + content: async (rowNode) => { + const curX = 0; + const containerProps = { + w: SQUARE_SIZE * 1.4, + h: SQUARE_SIZE * 1.4, + parent: rowNode, + color: 0x333333ff, + clipping: true, + } satisfies Partial; + + const textureNodeProps = { + w: containerProps.w, + h: containerProps.h, + texture: renderer.createTexture('ImageTexture', { + src: testscreenImg, + }), + textureOptions: { + resizeMode: { + type: 'cover', + }, + }, + } satisfies Partial; + + const container1 = renderer.createNode({ + ...containerProps, + x: curX, + }); + + const node = renderer.createNode({ + ...textureNodeProps, + parent: container1, + }); + + // Add 150 to the h of the node after 20ms + + setTimeout(() => { + node.h += 200; + }, 10); + + rowNode.h = containerProps.h + 200; + await new Promise((resolve) => setTimeout(resolve, 20)); + return rowNode.h; + }, + }, ]); return pageContainer; diff --git a/src/core/CoreNode.ts b/src/core/CoreNode.ts index 448e6fc6..b4e1c2e8 100644 --- a/src/core/CoreNode.ts +++ b/src/core/CoreNode.ts @@ -2012,19 +2012,28 @@ export class CoreNode extends EventEmitter { } set w(value: number) { - if (this.props.w !== value) { - this.props.w = value; - this.setUpdateType(UpdateType.Local); + const props = this.props; + if (props.w !== value) { + props.w = value; + let updateType = UpdateType.Local; - if (this.props.rtt === true) { + if ( + props.texture !== null && + this.stage.calculateTextureCoord === true && + props.textureOptions !== null + ) { + this.textureCoords = this.stage.renderer.getTextureCoords!(this); + } + + if (props.rtt === true) { this.framebufferDimensions!.w = value; this.texture = this.stage.txManager.createTexture( 'RenderTexture', this.framebufferDimensions!, ); - - this.setUpdateType(UpdateType.RenderTexture); + updateType |= UpdateType.RenderTexture; } + this.setUpdateType(updateType); } } @@ -2033,19 +2042,28 @@ export class CoreNode extends EventEmitter { } set h(value: number) { - if (this.props.h !== value) { - this.props.h = value; - this.setUpdateType(UpdateType.Local); + const props = this.props; + if (props.h !== value) { + props.h = value; + let updateType = UpdateType.Local; - if (this.props.rtt === true) { + if ( + props.texture !== null && + this.stage.calculateTextureCoord === true && + props.textureOptions !== null + ) { + this.textureCoords = this.stage.renderer.getTextureCoords!(this); + } + + if (props.rtt === true) { this.framebufferDimensions!.h = value; this.texture = this.stage.txManager.createTexture( 'RenderTexture', this.framebufferDimensions!, ); - - this.setUpdateType(UpdateType.RenderTexture); + updateType |= UpdateType.RenderTexture; } + this.setUpdateType(updateType); } } diff --git a/visual-regression/certified-snapshots/chromium-ci/resize-mode-5.png b/visual-regression/certified-snapshots/chromium-ci/resize-mode-5.png new file mode 100644 index 00000000..9f9e8170 Binary files /dev/null and b/visual-regression/certified-snapshots/chromium-ci/resize-mode-5.png differ