Skip to main content

Website Arena Editor

The website's Setup > Arena panel edits the arena in the browser with the same controls as the Godot Prepare > Arena editor described in Setup Editor Features. Before Sprint 3 the website panel only listed doors; the client asked for the two to be identical.

Built by Huzaifa in Sprint 3.

What the panel offers​

ControlWhat it does
Undo / RedoStep back and forward through arena changes.
ShowFilter the object list: all objects, floor regions, walls, barriers and doors, stimuli, or the treatment chamber.
ObjectChoose the object to edit. Objects can also be chosen by clicking them in the 3D view.
Bulk material changeGive all walls, all regions or all doors the same material.
Outer wall materialChange the arena's surrounding walls.
InspectorPosition (X and Z in centimetres), rotation, grid snap, enabled, material, colour, door default state, and light or stimulus settings.
Apply setup change / Revert / Delete...Apply the inspector, undo unapplied edits, or remove the object (with confirmation; Undo restores it).
Save draftStore the arena so everyone in the project, and the Python SDK, sees it.

Only objects the researcher's project role allows appear in the list. Editing is locked while a simulation is running.

Selecting objects​

Selection works in both directions:

  • choosing an object in the Object list highlights it in the 3D view; and
  • clicking an object in the 3D view selects it in the list and opens it in the inspector.

Clicking selects objects only while Setup > Arena is showing, so clicks during a run never select anything.

How a change is applied​

Inspector edit
|
v
Website draft changes --preview_configuration--> Godot validates and rebuilds the arena
| |
|<--------------- configuration_previewed -------------+
v
Accepted: keep the change Refused: restore the previous draft and show the problems

Godot is the judge of whether a change is valid, using the same validator as every other load. If it refuses, nothing changes and the reasons appear in red below the buttons. If no answer arrives within 15 seconds, for example because the web export is out of date, the website rolls back and asks for the web build to be re-exported.

A preview restarts the simulation from the seed, as the Godot editor's preview does.

Messages between the website and Godot​

The website and the embedded Godot talk through the browser's postMessage, limited to the site's own address. The arena editor added:

MessageDirectionPurpose
set_edit_mode {enabled}Website to GodotTurns 3D clicks into selection while Setup > Arena is showing.
select_object {id}Website to GodotHighlights an object; an empty id clears the highlight.
preview_configuration {configuration, select}Website to GodotValidates and rebuilds the arena, then keeps the selection.
object_selected {id, type}Godot to websiteThe user clicked an object in 3D.
configuration_previewed {ok, problems}Godot to websiteThe answer to a preview.

Zidan's stimulus placement builds on edit mode: while placement is switched on, a click places the stimulus instead of selecting an object, and placement then switches off.

The Godot side is in src/app/main.gd and src/app/services/web_bridge.gd; the website side is in web/app.js, web/index.html and web/styles.css.

Permissions​

The panel respects the same module scopes as the rest of the website: a researcher allowed only light sees and edits only lights. The browser's checks are for convenience; the database enforces the real rule when the draft is saved. See Database Schema and Deployment.

Evidence​

  • tests/test_web_arena_setup.gd checks edit mode, selection, a preview that changes wall and outer wall materials, that the selection survives the rebuild, that an invalid preview is refused without replacing the experiment, and that leaving edit mode clears the highlight.
  • backend/tests/test_ui_contract.py checks that the panel's elements and the new bridge messages exist.
  • The panel was also driven in a headless browser against a stand-in simulator: moving and rotating a wall with snapping, bulk and outer wall materials, undo and redo, a refused change rolling back, and selecting a door by clicking in 3D.

Using it after an update​

Changes to the Godot side only reach the website after the web build is re-exported (Project > Export > RODENT Web, into web/simulator/) and the page is reloaded with the cache cleared.