Skip to content

Commit cad4ed7

Browse files
nockawaRaananW
authored andcommitted
Fix actionManager dispose (BabylonJS#1149)
* Fix actionManager dispose * Rectangle2D Primitives now render Border correctly in notRounded Case
1 parent d4c3aed commit cad4ed7

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

src/Canvas2d/babylon.prim2dBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@
728728
return false;
729729
}
730730

731-
if (!this._actionManager) {
731+
if (this._actionManager) {
732732
this._actionManager.dispose();
733733
this._actionManager = null;
734734
}

src/Shaders/rect2d.vertex.fx

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,50 @@ void main(void) {
5757

5858
// notRound case, only five vertices, 0 is center, then the 4 other for perimeter
5959
if (properties.z == 0.0) {
60+
#ifdef Border
61+
float w = properties.x;
62+
float h = properties.y;
63+
vec2 borderOffset = vec2(1.0, 1.0);
64+
65+
float segi = index;
66+
if (index < 4.0) {
67+
borderOffset = vec2(1.0 - (borderThickness*2.0 / w), 1.0 - (borderThickness*2.0 / h));
68+
}
69+
else {
70+
segi -= 4.0;
71+
}
72+
73+
if (segi == 0.0) {
74+
pos2 = vec2(1.0, 1.0);
75+
}
76+
else if (segi == 1.0) {
77+
pos2 = vec2(1.0, 0.0);
78+
}
79+
else if (segi == 2.0) {
80+
pos2 = vec2(0.0, 0.0);
81+
}
82+
else {
83+
pos2 = vec2(0.0, 1.0);
84+
}
85+
pos2.x = ((pos2.x - 0.5) * borderOffset.x) + 0.5;
86+
pos2.y = ((pos2.y - 0.5) * borderOffset.y) + 0.5;
87+
#else
6088
if (index == 0.0) {
6189
pos2 = vec2(0.5, 0.5);
62-
}
90+
}
6391
else if (index == 1.0) {
6492
pos2 = vec2(1.0, 1.0);
65-
}
93+
}
6694
else if (index == 2.0) {
6795
pos2 = vec2(1.0, 0.0);
6896
}
6997
else if (index == 3.0) {
7098
pos2 = vec2(0.0, 0.0);
71-
}
99+
}
72100
else {
73101
pos2 = vec2(0.0, 1.0);
74102
}
103+
#endif
75104
}
76105
else
77106
{

0 commit comments

Comments
 (0)