Project Mammut Wiki
Project Mammut is currently in open beta. The UI is being updated a lot during this time, and you may run into bugs. If you'd like to help develop the engine or suggest features, come find us on Bluesky or Discord.

Document Object Model (DOM)

Written 5 Aug 2026 · Updated 10 Nov 2026 · Requires Mammut 0.6.2+

A Project Mammut game is effectively a fancy web page, and the DOM is how the browser represents that page before it gets drawn to the screen: a tree of elements that scripts can read and change while the game runs.

This is basically what the Scene Editor's tree view is showing.

Using it from a scene script

this.dom gives your scene script direct access to those elements: the scene's root (this.dom.root) and every node marked Referenceable, by node id. They're ordinary DOM elements, so the standard browser APIs all work on them, alongside the helpers Mammut adds such as hide(), show() and setState().

onStart() {
  this.dom.score_label.textContent = "Score: 0";
  this.dom.title.classList.add("glow");
  this.dom.start_button.addEventListener("click", () => {
    SceneManager.SwitchScene("level_1");
  });
},

See Coding for the helpers Mammut adds, and Script Types for how this.dom is typed. To look at the DOM of a running game, see Debugging.

Further reading

  • Document Object Model (DOM) on MDN: what the DOM is and how scripts see a page as a tree of nodes.
  • DOM scripting introduction on MDN: a beginner guide to finding, creating, moving and styling elements with JavaScript.
  • Introduction to events on MDN: reacting to clicks, key presses and other input with addEventListener().
  • Document on javascript.info: the DOM step by step, from the tree itself to attributes, styles, classes and coordinates, with exercises.
  • Viewing and changing the DOM in Chrome DevTools: inspecting and editing elements on a live page.

Reference