Skip to content
Open
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
47 changes: 47 additions & 0 deletions examples/tests/resize-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<INodeProps>;

const textureNodeProps = {
w: containerProps.w,
h: containerProps.h,
texture: renderer.createTexture('ImageTexture', {
src: testscreenImg,
}),
textureOptions: {
resizeMode: {
type: 'cover',
},
},
} satisfies Partial<INodeProps>;

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;
Expand Down
42 changes: 30 additions & 12 deletions src/core/CoreNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.