Renderer · function
boundsVisible
Whether a mesh placed by a model matrix is anywhere inside a frustum.
Explained in Hello world.
function boundsVisible(frustum: Frustum, bounds: Bounds, model: ReadonlyMat4): booleanimport { boundsVisible } from '@driftengine/core';Parameters
| Parameter | Type | Description |
|---|---|---|
frustum | Frustum | |
bounds | Bounds | |
model | ReadonlyMat4 |
In depth
Shared by both backends rather than written twice, for the reason the resource table is: two copies of a decision are two chances to answer it differently, and a culling disagreement between backends is an object that is present on one and missing on the other.
Scale is the trap, and it is why this is not two lines at each call site. A bounding sphere put through a scaling matrix is a sphere of a different size, so the world radius is the local radius times the largest of the three axis scales. Taking the average, or the x scale, or forgetting entirely, culls an enlarged object while it is plainly on screen — and the failure looks like a threshold to tune rather than a factor that is missing.
Non-uniform scale makes the transformed shape an ellipsoid, and the largest axis is the sphere that contains it. Conservative, which is the only direction a cull may err in.
Allocates nothing.