# Repeating scenes

A scene can be repeated once per item of an array variable, so one authored scene
becomes many rendered ones: a card per product, a slide per speaker, a room per
room. The underlying movie JSON property is
[`iterate`](@/reference/json-syntax/scene).

## Setting it up

Select the scene and open the **Repeat (iterate)** group in the properties panel:

![The Repeat group on a scene that has no array variable yet](@/images/editor/editor-scene-repeat.png)

1. Pick the array variable to repeat over. The picker lists only the movie's
   array variables and shows how many items each one holds. A dotted path such as
   `product.images` can be typed directly.
2. The panel reports how many copies the scene will produce.
3. Optionally narrow the range with **From**, **To** and **Step**. `From` is
   inclusive, `To` is exclusive, both are 1-based, and negative values count back
   from the end of the array. These fields appear only once the scene repeats.

If the movie has no array variable yet — the state in the screenshot above — the
panel says so and offers **Create an array variable**, which takes you to the
[schema editor](@/guides/editor/variables#the-schema-editor) with the new variable
ready to define.

## Referring to the current item

Inside a repeated scene, each item's own fields are available as variables. For an
array like this:

```json
{
  "variables": {
    "products": [
      { "name": "Blue mug",  "price": "$12" },
      { "name": "Red mug",   "price": "$14" }
    ]
  }
}
```

…a text element in the repeated scene can simply write `{{name}}` and `{{price}}`.
Three extra variables describe the position in the loop:

| Variable | Value |
|---|---|
| `{{iteration}}` | The index of the current copy |
| `{{first_iteration}}` | True on the first copy |
| `{{last_iteration}}` | True on the last copy |

The **Inspector** panel resolves all of these at the playhead, so you can see
exactly which item the copy under the playhead is showing.

## What it looks like in the Editor

The outline keeps showing **one** row — the scene you authored — with a badge
carrying the number of copies. The timeline shows the copies as separate blocks,
grouped under a band naming the array, and labels each one after the authored
scene: `Scene 2 · 2/3`.

Selecting any copy selects the authored scene, because that is the thing you can
actually edit. Editing it changes every copy.

## Three ways a repeat produces nothing

A repeated scene can silently vanish from the movie. The Editor badges the scene
in a warning colour when this happens, but it is worth knowing the causes:

- **The array is empty.** No items, no copies, no scene.
- **The array holds plain values, not objects.** `["a", "b"]` produces zero
  copies. Items must be objects — `[{ "value": "a" }, { "value": "b" }]` works.
- **A `condition` on the scene evaluates to false.** The scene is removed from the
  rendered movie.

None of the three is an error, and none of them fails the render — the movie
simply comes out shorter than expected.

## Conditions

A scene can also carry a `condition`, which decides whether it renders at all. The
Editor flags a conditioned scene with an icon in the outline and keeps it fully
visible and editable — a scene you cannot see is a scene you cannot fix.

## Repeating a single element

`iterate` is editable from the Editor on **scenes**. To repeat an individual
element rather than a whole scene, write the property in the
[JSON view](@/guides/editor/interface#the-json-view).

## See also

- [Dynamic scenes tutorial](@/tutorials/13-dynamic-scenes)
- [Conditions tutorial](@/tutorials/14-conditions)
- [Scene reference](@/reference/json-syntax/scene)
