Skip to content

Commit 9ead970

Browse files
committed
Preparing for trim crop support
1 parent 325fb46 commit 9ead970

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

src/textures/Frame.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,12 +475,20 @@ var Frame = new Class({
475475
var cy = this.cutY;
476476
var cw = this.cutWidth;
477477
var ch = this.cutHeight;
478+
var rw = this.realWidth;
479+
var rh = this.realHeight;
478480

479-
x = Clamp(x, 0, cw);
480-
y = Clamp(y, 0, ch);
481+
// x = Clamp(x, 0, cw);
482+
// y = Clamp(y, 0, ch);
481483

482-
width = Clamp(width, 0, cw - x);
483-
height = Clamp(height, 0, ch - y);
484+
// width = Clamp(width, 0, cw - x);
485+
// height = Clamp(height, 0, ch - y);
486+
487+
x = Clamp(x, 0, rw);
488+
y = Clamp(y, 0, rh);
489+
490+
width = Clamp(width, 0, rw - x);
491+
height = Clamp(height, 0, rh - y);
484492

485493
var ox = cx + x;
486494
var oy = cy + y;
@@ -495,6 +503,22 @@ var Frame = new Class({
495503
oy = cy + (ch - y - height);
496504
}
497505

506+
// Check ox/oy within cut region, otherwise make UVs empty
507+
508+
if (this.data.trim)
509+
{
510+
// Need to check for intersection between the cut xywh and ox
511+
// If there is none, we set UV to be empty, otherwise set it to be the intersection rect
512+
513+
// return !(rectA.right < rectB.x || rectA.bottom < rectB.y || rectA.x > rectB.right || rectA.y > rectB.bottom);
514+
515+
// out.x = Math.max(rectA.x, rectB.x);
516+
// out.y = Math.max(rectA.y, rectB.y);
517+
// out.width = Math.min(rectA.right, rectB.right) - out.x;
518+
// out.height = Math.min(rectA.bottom, rectB.bottom) - out.y;
519+
520+
}
521+
498522
var tw = this.source.width;
499523
var th = this.source.height;
500524

0 commit comments

Comments
 (0)