environment property

Implementation

static ComponentSchema<EnvironmentComponent>
get environment => ComponentSchema<EnvironmentComponent>(
  type: 'EnvironmentComponent',
  id: 'environment_3d_b38e5c17',
  create: EnvironmentComponent.new,
  hints: ComponentHints(
    dimensions: Dimensions.threeD,
    name: 'Environment',
    group: '3D',
    description: 'The sky and ambient light of a 3D scene.',
    icon: Icons.wb_sunny_outlined,
    accentColor: const Color(0xFF26C6DA),
    fields: {
      'sky': const FieldHint(label: 'Sky'),
      'zenith': FieldHint(
        label: 'Zenith',
        visibleWhen: (c) => (c as EnvironmentComponent).sky,
      ),
      'horizon': FieldHint(
        label: 'Horizon',
        visibleWhen: (c) => (c as EnvironmentComponent).sky,
      ),
      'ground': FieldHint(
        label: 'Ground',
        visibleWhen: (c) => (c as EnvironmentComponent).sky,
      ),
      'background': FieldHint(
        label: 'Background',
        visibleWhen: (c) => !(c as EnvironmentComponent).sky,
      ),
      'ambientSky': const FieldHint(label: 'Ambient above'),
      'ambientGround': const FieldHint(label: 'Ambient below'),
      'exposure': const FieldHint(
        label: 'Exposure',
        scrub: ScrubHint(step: 0.05, fractionDigits: 2),
      ),
      'fog': const FieldHint(label: 'Fog'),
      'fogColor': FieldHint(
        label: 'Fog colour',
        visibleWhen: (c) => (c as EnvironmentComponent).fog,
      ),
      'fogDensity': FieldHint(
        label: 'Fog density',
        scrub: const ScrubHint(step: 0.001, fractionDigits: 3),
        visibleWhen: (c) => (c as EnvironmentComponent).fog,
      ),
      'fogStart': FieldHint(
        label: 'Fog starts',
        scrub: const ScrubHint(step: 0.5, fractionDigits: 1, suffix: 'm'),
        visibleWhen: (c) => (c as EnvironmentComponent).fog,
      ),
      'reflections': const FieldHint(
        label: 'Reflections',
        description:
            'Light and reflections from the skybox or the sky, not the two ambient colours.',
      ),
      'reflectionStrength': FieldHint(
        label: 'Strength',
        scrub: const ScrubHint(step: 0.05, fractionDigits: 2),
        visibleWhen: (c) => (c as EnvironmentComponent).reflections,
      ),
      'skybox': const FieldHint(
        label: 'Skybox',
        description:
            'A panorama (.hdr) for the sky and its light; empty for the gradient.',
        fileExtensions: ['hdr'],
      ),
      'skyboxBlur': FieldHint(
        label: 'Skybox blur',
        scrub: const ScrubHint(step: 0.05, fractionDigits: 2),
        visibleWhen: (c) => (c as EnvironmentComponent).skybox.isNotEmpty,
      ),
    },
  ),
  fields: [
    SchemaField(
      name: 'sky',
      kind: FieldTypes.boolean,
      read: (c) => (c as EnvironmentComponent).sky,
      write: (c, v) => (c as EnvironmentComponent).sky = v as bool,
    ),
    _color('zenith', (c) => c.zenith, (c, v) => c.zenith = v),
    _color('horizon', (c) => c.horizon, (c, v) => c.horizon = v),
    _color('ground', (c) => c.ground, (c, v) => c.ground = v),
    _color('background', (c) => c.background, (c, v) => c.background = v),
    _color('ambientSky', (c) => c.ambientSky, (c, v) => c.ambientSky = v),
    _color(
      'ambientGround',
      (c) => c.ambientGround,
      (c, v) => c.ambientGround = v,
    ),
    _decimal(
      'exposure',
      (c) => (c as EnvironmentComponent).exposure,
      (c, v) => (c as EnvironmentComponent).exposure = v,
      min: 0,
    ),
    SchemaField(
      name: 'fog',
      kind: FieldTypes.boolean,
      read: (c) => (c as EnvironmentComponent).fog,
      write: (c, v) => (c as EnvironmentComponent).fog = v as bool,
    ),
    _color('fogColor', (c) => c.fogColor, (c, v) => c.fogColor = v),
    _decimal(
      'fogDensity',
      (c) => (c as EnvironmentComponent).fogDensity,
      (c, v) => (c as EnvironmentComponent).fogDensity = v,
      min: 0,
    ),
    _decimal(
      'fogStart',
      (c) => (c as EnvironmentComponent).fogStart,
      (c, v) => (c as EnvironmentComponent).fogStart = v,
      min: 0,
    ),
    SchemaField(
      name: 'reflections',
      kind: FieldTypes.boolean,
      read: (c) => (c as EnvironmentComponent).reflections,
      write: (c, v) => (c as EnvironmentComponent).reflections = v as bool,
    ),
    _decimal(
      'reflectionStrength',
      (c) => (c as EnvironmentComponent).reflectionStrength,
      (c, v) => (c as EnvironmentComponent).reflectionStrength = v,
      min: 0,
    ),
    SchemaField(
      name: 'skybox',
      kind: FieldTypes.assetRef,
      read: (c) => (c as EnvironmentComponent).skybox,
      write: (c, v) =>
          (c as EnvironmentComponent).skybox = v as String? ?? '',
    ),
    _decimal(
      'skyboxBlur',
      (c) => (c as EnvironmentComponent).skyboxBlur,
      (c, v) => (c as EnvironmentComponent).skyboxBlur = v.clamp(0.0, 1.0),
      min: 0,
    ),
  ],
);