@modoki/engine / rendering / syncFog
Function: syncFog()
syncFog(
world,scene):void
Apply the first active Fog entity's settings to the scene. A hybrid mechanism:
linear/exponentialdrive the classicscene.fogobject (THREE.Fog/FogExp2). Despite this engine rendering exclusively through WebGPURenderer/NodeMaterial, that classic object IS the right integration point:NodeMaterial.fogdefaults totrue, and three's ownNodeManager.updateFog()transparently convertsscene.foginto the equivalent TSL node graph each render, caching it by the Fog/FogExp2 object's OWN identity and refreshing color/near/far/density viareference()nodes (NodeUpdateType.OBJECT— re-read every frame). So mutating the SAME object's fields already gets "update without recompiling the shader" for free.height(density varying with world Y — fog pools in valleys, independent of camera distance) has NO classic-object equivalent, so it drivesscene.fogNodedirectly viaexponentialHeightFogFactor(density, height)— seeHeightFogStateabove for why that node's identity must stay stable.
NodeManager.getFogNode() prefers scene.fogNode over a derived-from-scene.fog node, so whichever path is inactive must be explicitly cleared or a stale one would win. First-entity-wins + clear-on-none mirrors syncEnvironment.
Parameters
world
World
scene
Scene
Returns
void