Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bffadd8

Browse files
committed
project container.cullArea to global coordinates before doing cull check
1 parent ca6420d commit bffadd8

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

src/culling/Culler.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import { Point } from '..';
12
import { Bounds } from '../scene/container/bounds/Bounds';
23
import { getGlobalBounds } from '../scene/container/bounds/getGlobalBounds';
34

45
import type { Container } from '../scene/container/Container';
56

67
const tempBounds = new Bounds();
8+
const tempPoint = new Point();
79

810
/**
911
* A rectangle-like object that contains x, y, width, and height properties.
@@ -96,7 +98,34 @@ export class Culler
9698
{
9799
if (container.cullable && container.measurable && container.includeInBuild)
98100
{
99-
const bounds = container.cullArea ?? getGlobalBounds(container, skipUpdateTransform, tempBounds);
101+
let bounds = new Bounds();
102+
103+
if (container.cullArea)
104+
{
105+
const globalTL = container.toGlobal(
106+
{
107+
x: container.cullArea.x,
108+
y: container.cullArea.y
109+
},
110+
tempPoint,
111+
skipUpdateTransform
112+
);
113+
114+
const globalBR = container.toGlobal(
115+
{
116+
x: container.cullArea.x + container.cullArea.width,
117+
y: container.cullArea.y + container.cullArea.height
118+
},
119+
tempPoint,
120+
skipUpdateTransform
121+
);
122+
123+
bounds = new Bounds(globalTL.x, globalTL.y, globalBR.x, globalBR.y);
124+
}
125+
else
126+
{
127+
bounds = getGlobalBounds(container, skipUpdateTransform, tempBounds);
128+
}
100129

101130
// check view intersection..
102131
container.culled = bounds.x >= view.x + view.width

0 commit comments

Comments
 (0)