# Reference: framescript/light

What a scene imports from `framescript/light` and calls, in the order the module exports it. Each entry has its signature, what it does, and the examples that use it; the types its signatures name are [at the end](#types).

Explained in [Light and materials](/docs/framework/scene/light.md).

## `shadows`

```ts
function shadows<
  T extends THREE.DirectionalLight | THREE.SpotLight | THREE.PointLight,
>(light: T, options?: ShadowOptions): T
```

Makes a light cast soft shadows. Objects take part by their own `castShadow` and `receiveShadow`; a `ground` receives them.

- `light`: A directional, spot or point light.
- `options`: The softness, the resolution and the area covered.
- Returns: The same light.

Examples: light/shadows

## `glass`

```ts
function glass(options?: GlassOptions): THREE.MeshPhysicalMaterial
```

Makes a glass material: what is behind it shows through, bent and, with some roughness, frosted. It needs light from an `environment` or from lights to look like glass.

- `options`: The tint, the frosting, the thickness and the bending.
- Returns: The material; its numbers are tween targets.

Examples: fills/fills

## `flat`

```ts
function flat(
  color?: THREE.ColorRepresentation
): THREE.MeshBasicMaterial
```

Makes a flat material: one colour that takes no light, so that the colour on screen is the colour that was written. Its `color` and `opacity` can be animated.

- `color`: The colour. Defaults to white.
- Returns: The material.

Examples: composing/preview, components/Badge, layers/blur

## `soft`

```ts
function soft(
  color?: THREE.ColorRepresentation
): THREE.MeshStandardMaterial
```

Makes a soft material: matt, like paper or clay, shaded by the light that falls on it. It needs light from an `environment` or from lights. Its `color` can be animated.

- `color`: The colour. Defaults to white.
- Returns: The material.

Examples: effects/bloom-and-tone, light/shadows, shapes/solid

## `metal`

```ts
function metal(
  color?: THREE.ColorRepresentation,
  roughness?: number
): THREE.MeshStandardMaterial
```

Makes a metal: it shows its surroundings in its own colour, sharply or, with more `roughness`, brushed. It needs an `environment` to have something to show. Its `color` and `roughness` can be animated.

- `color`: The colour. Defaults to a light grey.
- `roughness`: How brushed it is, from 0 (a mirror) to 1. Defaults to 0.25.
- Returns: The material.

Examples: loading/assets, fills/fills

## `ground`

```ts
function ground(options?: GroundOptions): THREE.Group
```

Makes a ground: a horizontal surface at its own height that takes shadows and, when asked, mirrors the scene faintly. It is a group, so it is placed and animated as one object.

- `options`: The size, the colour, the reflection and the shadows.
- Returns: The ground, lying in the plane y = 0 of its own space.

Examples: light/shadows

## Types

### `GlassOptions`

```ts
interface GlassOptions {
  /** The tint of the glass. */
  readonly color?: THREE.ColorRepresentation
  /** How frosted it is, from 0 (clear) to 1. */
  readonly roughness?: number
  /** How thick it is for bending light, in world units. */
  readonly thickness?: number
  /** How strongly it bends light; glass is about 1.5. */
  readonly ior?: number
  /** How much light passes through, from 0 to 1. */
  readonly transmission?: number
}
```

### `GroundOptions`

```ts
interface GroundOptions {
  /** The ground's width and depth, in world units. */
  readonly size?: number
  /** Its colour. */
  readonly color?: THREE.ColorRepresentation
  /** How much of the scene it mirrors, from 0 (none) to 1 (a mirror). */
  readonly reflection?: number
  /** How dark shadows on it are, from 0 to 1. */
  readonly shadow?: number
}
```

### `ShadowOptions`

```ts
interface ShadowOptions {
  /** How soft the shadow's edge is; 0 is hard. */
  readonly softness?: number
  /** The shadow map's width and height in pixels. */
  readonly resolution?: number
  /**
   * For a directional light: half the width of the area, around the
   * light's target, in which shadows are cast, in world units.
   */
  readonly area?: number
  /** How far from the light shadows are still cast, in world units. */
  readonly far?: number
}
```
