BF2.US bf2-rsdeveloper wiki Parity Discord bf2.us
in progress
On this page

The web modding editor

BF22142Heroes

A modding editor in the browser: load a real level of Battlefield 2, 2142 or Heroes, inspect its objects and vehicles, edit them, save the changes locally as overlays, and later play a round in the same tab. It is being built now (milestone M11); this page is the map of how it fits together.

How it is put together#

  • The viewport is the game's own renderer. The engine crates (bf2-render, bf2-terrain, bf2-world, bf2-fs / bf2-webfs) are compiled to WebAssembly and draw the level in a canvas the page owns; there is no second renderer. The editor visuals (grid, selection outline, gizmo, markers) are editor layers in bf2-render behind an editor flag (notes/editor/render_layers.md).
  • crates/bf2-editor is the engine-side host: a native bf2_editor binary for tests and the wasm build bound with wasm-bindgen. It reads the published web data of the three games, the same packages the play pages stream.
  • web/editor/ is the page: Vite, React, TypeScript, Tailwind and shadcn/ui, state in zustand. Top bar (game, level, camera mode), scene tree, viewport, inspector and console (notes/editor/web.md).
  • The JS / wasm contract (editor_init, editor_load_level, editor_objects, editor_object, editor_pick, editor_select, editor_set_transform, ...) is written down in notes/editor/api.md; structured data crosses as JSON strings.

Stages#

StageWhatState
1. Viewerthe shell, the engine host, render layers (pick, outline, grid, gizmo), panelsin progress
2. Overlays and playan overlay file system with CON writers, transform editing with undo, PLAY in the pageplanned
3. Authorterrain writers and sculpting, the painter, roads and water, lightmaps, a new-level wizardplanned

Stage 3 writes level files; the level editor plan lists every file of a level, its bf2-rs reader and the round-trip contract each writer has to meet.

Mods in the editor is the plan and the beginner tutorial for a mod's maps: mount a mod you have installed (Project Reality, Forgotten Hope 2; the mount is H2371's, not there yet), edit a map, Export for the game and put it back into the mod to test it.

The BF2Editor feature inventory is the feature floor: every tool of DICE's 2005 editor (terrain, objects, gameplay objects, lighting, materials, animation, AI, the Maya pipeline, level and mod settings, the console) next to what this editor has, the registry task that plans it, and the missing tools in priority order.

Look and feel#

The editor and this wiki share one set of design tokens, web/tokens/bf2.css: Battlefield 2's dark blue-grey panels with the orange accent and desert tan surfaces, with 2142's cyan and Heroes' parchment and red as the accent of pages and editor sessions about those games (the data-game attribute).

More to write

Keyboard map, preferences, the overlay format and the PLAY flow, as the stages land.

How it is tested#

The editor has the largest set of test programs in the tree (crates/bf2-editor/tests, over a hundred), each opening a shipped level and doing one thing a user does:

  • Edit, save, reload: a level's settings, terrain export and import, a moved building's baked light maps read back from an exported package in the game's own layout.
  • Mods: a mod's level opened over its parent mod's chain (editing a mod's map).
  • Navigation maps measured against the shipped ones (navmesh).
  • In the browser: tools/web/editor_checks drives the built page and checks what it draws.

They need an install and are skipped without one. What they hold is that the editor reads and writes what the game reads; whether a feature matches the original editor is on the feature comparison.

In the code#

The crates this page names, each with its line of docs/release/LAYOUT.md (the list is gathered by the wiki's build from the page itself):

CrateWhat it is
crates/bf2-editorPROGRAM bf2_editor: the web editor's engine host (wasm for the page, native for tests)
Source: docs/dev/editor/index.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.