ReferenceSamplersFunction
evaluateSampler()
Resolves a sampler to a value.
function evaluateSampler<T>(sampler: Sampler<T>, ctx: SamplerContext): T;Resolves a Sampler to a value, by calling it if it is a function, or returning it unchanged if it is a fixed value.
This can be useful when writing your own samplers that build on other samplers.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”samplerSampler<T>The sampler to resolve.
ctxSamplerContextThe context to pass on if the
sampleris a function.
Returns
Section titled “Returns”TThe sampled value.
Example
Section titled “Example”const doubled = (base: Sampler<number>): SamplerFn<number> => (ctx) => 2 * evaluateSampler(base, ctx);