convert() function
Provides conversion functionality between units.
Signature:
declare function convert<TFrom extends ConvertUnit, TTo extends ConvertUnit>({ from, extra, ratio, to, value, }: ConvertParameters<TFrom, TTo>): number;
Parameters
Parameter |
Type |
Description |
---|---|---|
{ from, extra, ratio, to, value, } |
ConvertParameters<TFrom, TTo> |
number
Remarks
This helper is used internally to convert units when needed. It relies on the ratio
property of Model resources to work properly.
Occasionally you need to run conversions in your code i.e. when building an editor that takes real-world units into account. You may use this utility to help with that.