Log inGet started
Package

meshLod.package

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

meshLod.module

Owns which level each tracked entity draws at, and the arithmetic that decides it.

screenFraction(radius, distance, fovDegrees) returns the fraction of the viewport's height a sphere of that radius spans — 1.0 fills the frame, 0.05 spans a twentieth of it.

selectLevel(fraction, thresholds, current, hysteresis) maps that fraction to a level. thresholds are ordered largest to smallest, one per cheaper level; level 0 is the authored full-detail mesh. Passing current lets the climb back to a richer level require 1 + hysteresis times the threshold that was crossed, so a camera resting on a boundary settles instead of alternating.

Both are pure, so a level can be checked for a given size and range without a camera or a scene.

register / unregister track an entity, evaluate measures one against the camera and returns the level, the mesh to draw and whether that changed. The caller applies the mesh — the module never writes another component's fields.

levelOf, fractionOf and stats report what is being drawn and the measurement it came from.