Skip to main content

Function: decodeConstantValues()

decodeConstantValues(constantValues, channels?): Record<string, NTCConstantValue>

Decodes a constantValues map (see NTCSource. classifyMaterialChannels, and the manifest round trip in NTCManifest.js/NTCLoader.js) back into each channel's true semantic values, via each channel's own (optional) decodeConstant hook - a channel without one is passed through unchanged. Currently only attenuationDistance defines one (unwrapping its ATTENUATION_DISTANCE_INFINITY_SENTINEL encoding back into a real Infinity), but this is deliberately as generic/open as every other piece of this file: a caller-supplied custom channel can define its own decodeConstant for the same reason it can define its own applyConstant

  • some other physical quantity that isn't itself JSON/shader-safe in its natural range.

Unknown keys in constantValues (not present in channels) are passed through unchanged rather than dropped or erroring - this only decodes values it recognizes, it doesn't validate the map's shape (that's NTCLoader.validateManifest's job, for the manifest path).

Parameters​

constantValues​

Record<string, NTCConstantValue>

channels?​

NTCChannel[] = CHANNELS

Returns​

Record<string, NTCConstantValue>