Skip to content

Commit 7a1c89c

Browse files
committed
fix: ensure local transform updates on width and height changes for text
1 parent 0dbefa0 commit 7a1c89c

File tree

2 files changed

+15
-31
lines changed

2 files changed

+15
-31
lines changed

src/core/CoreNode.ts

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,31 +1075,25 @@ export class CoreNode extends EventEmitter {
10751075

10761076
let renderState: CoreNodeRenderState | null = null;
10771077

1078-
if (
1079-
updateType & UpdateType.Local ||
1080-
this.updateType & UpdateType.ScaleRotate
1081-
) {
1078+
if (updateType & UpdateType.Local || updateType & UpdateType.ScaleRotate) {
10821079
this.updateLocalTransform({
10831080
scaleRotate: (updateType & UpdateType.ScaleRotate) !== 0,
10841081
});
10851082

1086-
// this.setUpdateType(UpdateType.Global);
10871083
updateType |= UpdateType.Global;
10881084
}
10891085

10901086
if (updateType & UpdateType.Global) {
10911087
// global
10921088
let lt = this.localTransform || Matrix3d.identity();
1093-
let gt = this.globalTransform || Matrix3d.identity();
1089+
let gt = this.globalTransform || Matrix3d.copy(lt);
10941090

10951091
if (parentHasRenderTexture === true) {
10961092
if (parent?.rtt === true) {
10971093
this.globalTransform = Matrix3d.identity();
10981094

10991095
// Maintain a full scene global transform for bounds detection
1100-
this.sceneGlobalTransform = Matrix3d.copy(
1101-
parent?.globalTransform || Matrix3d.identity(),
1102-
).multiply(lt);
1096+
this.sceneGlobalTransform = Matrix3d.copy(gt).multiply(lt);
11031097
} else {
11041098
// we're part of an RTT chain but our parent is not the main RTT node
11051099
// so we need to propogate the sceneGlobalTransform of the parent
@@ -1109,7 +1103,7 @@ export class CoreNode extends EventEmitter {
11091103
this.sceneGlobalTransform,
11101104
).multiply(lt);
11111105

1112-
gt = Matrix3d.copy(parent?.globalTransform || lt, gt);
1106+
Matrix3d.copy(parent?.globalTransform || lt, gt);
11131107
}
11141108
} else {
11151109
Matrix3d.copy(parent?.globalTransform || gt, gt);
@@ -1125,37 +1119,27 @@ export class CoreNode extends EventEmitter {
11251119
this.calculateRenderCoords();
11261120
this.updateBoundingRect();
11271121

1128-
// this.setUpdateType(
1129-
// UpdateType.RenderState |
1130-
// UpdateType.Children |
1131-
// UpdateType.RecalcUniforms,
1132-
// );
1133-
11341122
updateType |=
11351123
UpdateType.RenderState |
11361124
UpdateType.Children |
11371125
UpdateType.RecalcUniforms;
11381126
this.childUpdateType |= UpdateType.Global;
11391127

11401128
if (this.clipping === true) {
1141-
// this.setUpdateType(UpdateType.Clipping | UpdateType.RenderBounds);
11421129
updateType |= UpdateType.Clipping | UpdateType.RenderBounds;
11431130
this.childUpdateType |= UpdateType.RenderBounds;
11441131
}
11451132
}
11461133

1147-
if (this.updateType & UpdateType.RenderBounds) {
1134+
if (updateType & UpdateType.RenderBounds) {
11481135
this.createRenderBounds();
1149-
// this.setUpdateType(UpdateType.RenderState);
1150-
// this.setUpdateType(UpdateType.Children);
11511136
updateType |= UpdateType.RenderState | UpdateType.Children;
11521137

11531138
this.childUpdateType |= UpdateType.RenderBounds;
11541139
}
11551140

1156-
if (this.updateType & UpdateType.RenderState) {
1141+
if (updateType & UpdateType.RenderState) {
11571142
renderState = this.checkRenderBounds();
1158-
// this.setUpdateType(UpdateType.IsRenderable);
11591143
updateType |= UpdateType.IsRenderable;
11601144

11611145
// if we're not going out of bounds, update the render state
@@ -1168,11 +1152,6 @@ export class CoreNode extends EventEmitter {
11681152

11691153
if (updateType & UpdateType.WorldAlpha) {
11701154
this.worldAlpha = ((parent && parent.worldAlpha) || 1) * props.alpha;
1171-
// this.setUpdateType(
1172-
// UpdateType.Children |
1173-
// UpdateType.PremultipliedColors |
1174-
// UpdateType.IsRenderable,
1175-
// );
11761155

11771156
updateType |=
11781157
UpdateType.Children |
@@ -1297,7 +1276,7 @@ export class CoreNode extends EventEmitter {
12971276

12981277
// Sorting children MUST happen after children have been updated so
12991278
// that they have the oppotunity to update their calculated zIndex.
1300-
if (this.updateType & UpdateType.ZIndexSortedChildren) {
1279+
if (updateType & UpdateType.ZIndexSortedChildren) {
13011280
// reorder z-index
13021281
this.sortChildren();
13031282
}
@@ -1321,7 +1300,6 @@ export class CoreNode extends EventEmitter {
13211300
// notify children that we are going out of bounds
13221301
// we have to do this now before we stop processing the render tree
13231302
this.notifyChildrenRTTOfUpdate(renderState);
1324-
// this.childUpdateType |= UpdateType.RenderState;
13251303
}
13261304
}
13271305

src/core/CoreTextNode.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,17 @@ export class CoreTextNode extends CoreNode implements CoreTextNodeProps {
134134
this.props.width = calcWidth;
135135
this.props.height = calcHeight;
136136
}
137-
this.updateLocalTransform();
137+
138+
// Force local transform update
139+
// to account for the new width and height
140+
this.updateType |= UpdateType.Local;
138141

139142
// Incase the RAF loop has been stopped already before text was loaded,
140143
// we request a render so it can be drawn.
141-
this.stage.requestRender();
144+
145+
// WvB Do we really need this?
146+
// this.stage.requestRender();
147+
142148
this.emit('loaded', {
143149
type: 'text',
144150
dimensions: {

0 commit comments

Comments
 (0)