fromEquirectImageAsset static method
Future<EnvironmentMap>
fromEquirectImageAsset({
- required String assetPath,
- int maxWidth = 4096,
- List<
Vector3> ? diffuseSphericalHarmonics, - AssetBundle? bundle,
Loads an EnvironmentMap from an equirectangular image in the asset
bundle, detecting Radiance HDR (.hdr), OpenEXR (.exr), or a standard
sRGB image (.png/.jpg) from its contents. HDR and EXR are read as
linear radiance, so bright skies and the sun keep their true intensity;
LDR images are interpreted as sRGB.
The decode runs on a background isolate. maxWidth caps the working
equirect so a very large panorama is box-downsampled (HDR/EXR) or decoded
scaled down (LDR) instead of materializing at full resolution. Pass
diffuseSphericalHarmonics to supply your own diffuse term instead of
projecting it.
In debug builds, a Scene.loadEnvironment built on this re-runs on hot
reload when the asset's content changes.
Implementation
static Future<EnvironmentMap> fromEquirectImageAsset({
required String assetPath,
int maxWidth = 4096,
List<Vector3>? diffuseSphericalHarmonics,
AssetBundle? bundle,
}) async {
final environment = await fromEquirectImageBytes(
bytes: await bytesFromAsset(assetPath, bundle: bundle),
maxWidth: maxWidth,
diffuseSphericalHarmonics: diffuseSphericalHarmonics,
);
_environmentAssetPaths[environment] = assetPath;
return environment;
}