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 SplatSorterimport { 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)| Parameter | Type | Description |
|---|---|---|
options | SplatSorterOptions |
Accessors
| Name | Type | Description |
|---|---|---|
orderget | Uint32Array | null | The standing order, or null until the first sort lands. |
drawCountget | number | How many entries of order are real. Below the capture's count when a budget bit. |
versionget | number | How many orders have landed. A caller uploads when this changes and not otherwise. |
sortingget | boolean | Whether a sort is in flight.MoreWhat a measuring page waits on, and it has to wait on more than |
Methods
frame
frame(local: SplatViewLocal, force?: boolean): voidOffer the current view, in the capture's own space. Starts a sort if one is wanted.
| Parameter | Type | Description |
|---|---|---|
local | SplatViewLocal | |
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.