Splats · class

SplatSorter

Hold the newest order, ask for a new one when the view has changed enough, and never queue.

Explained in Gaussian splats.

class SplatSorter
import { SplatSorter } from '@driftengine/splats';

In depth

At most one sort in flight, and a request while one is running is dropped rather than queued. The newest view is the only one worth sorting for: a queue would sort for a camera position the player has already left, and then sort again, so it converts a busy moment into a backlog that never catches up.

Two buffers, ping-ponged. One is being filled by the sorter and the other is what the pass draws from, so a sort landing mid-frame never rewrites the order under a draw call.

Constructor

new

constructor(options: SplatSorterOptions)
ParameterTypeDescription
optionsSplatSorterOptions

Accessors

NameTypeDescription
ordergetUint32Array | nullThe standing order, or null until the first sort lands.
drawCountgetnumberHow many entries of order are real. Below the capture's count when a budget bit.
versiongetnumberHow many orders have landed. A caller uploads when this changes and not otherwise.
sortinggetbooleanWhether a sort is in flight.
More

What a measuring page waits on, and it has to wait on more than version. With a budget the sort chooses which splats are drawn and not merely their order, so a capture photographed at the first landed sort is a capture photographed at whichever sort the worker happened to finish — and two backends that reach the held frame at different wall-clock times then draw different splats. A held camera is settled when this is false and the standing version has been uploaded: at a fixed direction frame asks for nothing further, so that state is reached and then keeps.

Methods

frame

frame(local: SplatViewLocal, force?: boolean): void

Offer the current view, in the capture's own space. Starts a sort if one is wanted.

ParameterTypeDescription
localSplatViewLocal
force?boolean
More

resolveSplatView is what turns a camera and a model matrix into this. force is for the first frame and for a capture whose transform moved, where the view in its own space may be unchanged and the order is stale anyway.

Turning always matters; moving only matters when there is a budget. Depth is measured along the view axis, so translating the camera shifts every splat's depth by the same amount and leaves the ordering exactly as it was — which is why this gate did not exist until a budget did. A budget keeps the splats largest on screen, which is the extent over the distance, so a camera that walks across a capture without turning changes which splats are drawn. What that costs is a sort every tenth of a capture-radius while a viewer moves; what would make it wrong is a budget so generous that nothing is ever dropped, where the gate spends sorts to reach the same answer.