\n\n\n","publisher":{"@type":"Organization","name":"MML","url":"https://mml.io"}}MML - Metaverse Markup Language

<m-interaction>

The m-interaction element is used to describe an action that a user can take at a point in 3D space.

<m-interaction
    prompt="Toggle Color"
    debug="true"
    id="my-interaction"
>
  <m-cube y="1" id="color-cube" color="blue"></m-cube>
</m-interaction>

<script>
  const mInteraction = document.getElementById("my-interaction");
  const mCube = document.getElementById("color-cube");

  let toggle = false;
  function handleInteract() {
    toggle = !toggle;
    mCube.setAttribute("color", toggle ? "red" : "blue");
  }

  mInteraction.addEventListener("interact", handleInteract);
</script>

<m-label id="my-label" y="7" width="10" height="2" content="Move into range and press E" font-size="80" alignment="center" color="#BBB" font-color="#000"></m-label>
  • The range that this interaction can be used from in meters. Default value is 5 meters.

  • Whether the interaction must be in the direction of the camera to be used. Default value is true.

  • Whether the interaction must be visible to the camera to be used. Default value is false.

  • The priority of this interaction. Lower priority interactions will be shown first. Default value is 1.

  • The prompt to be displayed when the interaction is presented to the user.

  • A script expression that is executed when the element is interacted with. Events are also dispatched to "interact" event listeners.

    • A boolean that indicates whether the element should be drawn with debug information (e.g. axes helper). Default value is false.

    • The position of the element along the X-axis in meters. Default value is 0.

    • The position of the element along the Y-axis in meters. Default value is 0.

    • The position of the element along the Z-axis in meters. Default value is 0.

    • The rotation of the element around the X-axis in degrees. Default value is 0.

    • The rotation of the element around the Y-axis in degrees. Default value is 0.

    • The rotation of the element around the Z-axis in degrees. Default value is 0.

    • The scale of the element along the X-axis. Default value is 1.

    • The scale of the element along the Y-axis. Default value is 1.

    • The scale of the element along the Z-axis. Default value is 1.

    • Whether the element is visible (true) or hidden (false) in the scene. Default value is true.

    • The name of a bone in the parent element's skeletal mesh to which this element will be attached. If not specified, the element will attach to the origin of its parent.

    • A unique identifier for the element, used for selection and manipulation through scripting. It must be unique within the document.

    • A space-separated list of class names that can be used for scripting purposes.

Multiple m-interactions can be present at once. The menu presents the available interactions. In this example the positions of the m-interaction elements differ to allow moving into range of multiple of the interactions or just a subset.

<m-interaction x="-3" in-focus="false" prompt="Set to red" debug="true" id="red-interaction"></m-interaction>
<m-interaction x="0" in-focus="false" prompt="Set to green" debug="true" id="green-interaction"></m-interaction>
<m-interaction x="3" in-focus="false" prompt="Set to blue" debug="true" id="blue-interaction"></m-interaction>

<m-cube y="1" id="color-cube" color="blue"></m-cube>

<script>
  const mCube = document.getElementById("color-cube");
  document.getElementById("red-interaction").addEventListener("interact", () => {
    mCube.setAttribute("color", "red");
  });
  document.getElementById("green-interaction").addEventListener("interact", () => {
    mCube.setAttribute("color", "green");
  });
  document.getElementById("blue-interaction").addEventListener("interact", () => {
    mCube.setAttribute("color", "blue");
  });
</script>

<m-label id="my-label" y="7" width="10" height="2" content="Move into range and press E" font-size="80" alignment="center" color="#BBB" font-color="#000"></m-label>
WEBUNREAL
m-interaction
range
in-focus
line-of-sight
priority
prompt
oninteract
debug
x
y
z
rx
ry
rz
sx
sy
sz
visible
socket
id
class