Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CoreNode.checkRenderProps, cleanup constructor #330

Merged
merged 1 commit into from
Jul 8, 2024
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
28 changes: 10 additions & 18 deletions src/core/CoreNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ export interface CoreNodeAnimateProps extends NumberProps<CoreNodeProps> {
export class CoreNode extends EventEmitter {
readonly children: CoreNode[] = [];
protected _id: number = getNewId();
readonly props: Required<CoreNodeProps>;
readonly props: CoreNodeProps;

public updateType = UpdateType.All;

Expand Down Expand Up @@ -673,7 +673,6 @@ export class CoreNode extends EventEmitter {
public calcZIndex = 0;
public hasRTTupdates = false;
public parentHasRenderTexture = false;
private _src = '';

constructor(readonly stage: Stage, props: CoreNodeProps) {
super();
Expand All @@ -682,19 +681,14 @@ export class CoreNode extends EventEmitter {
...props,
parent: null,
texture: null,
shader: stage.defShaderCtr,
src: '',
src: null,
rtt: false,
data: props.data || {},
};

// Assign props to instance
this.parent = props.parent;
this.shader = props.shader;
this.texture = props.texture;
this.src = props.src || '';
// FIXME
// this.data = props.data;
this.src = props.src;
this.rtt = props.rtt;

this.updateScaleRotateTransform();
Expand Down Expand Up @@ -1062,7 +1056,7 @@ export class CoreNode extends EventEmitter {
return false;
}

if (this.props.shader === this.stage.defShaderCtr) {
if (this.props.shader !== this.stage.defShaderCtr) {
return true;
}

Expand Down Expand Up @@ -1830,21 +1824,19 @@ export class CoreNode extends EventEmitter {

this.props.shader = value;

if (value === this.stage.defShaderCtr) {
this.setUpdateType(UpdateType.IsRenderable);
}
this.setUpdateType(UpdateType.IsRenderable);
}

get src(): string {
return this._src;
get src(): string | null {
return this.props.src;
}

set src(imageUrl: string) {
if (this._src === imageUrl) {
set src(imageUrl: string | null) {
if (this.props.src === imageUrl) {
return;
}

this._src = imageUrl;
this.props.src = imageUrl;

if (!imageUrl) {
this.texture = null;
Expand Down
2 changes: 1 addition & 1 deletion src/core/Stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ export class Stage {
shader: props.shader ?? this.defShaderCtr,
// Since setting the `src` will trigger a texture load, we need to set it after
// we set the texture. Otherwise, problems happen.
src: props.src ?? '',
src: props.src ?? null,
scale: props.scale ?? null,
scaleX: props.scaleX ?? props.scale ?? 1,
scaleY: props.scaleY ?? props.scale ?? 1,
Expand Down
Loading