Titania X3D Editor

Bring Colours to Your Life.

Titania v4.1.1

Bring Colours to Your Life.

X3D Reference

Sensing viewer actions

Motivation

You can sense when the viewer's cursor:

  • Is over a shape
  • Has touched a shape
  • Is dragging atop a shape

What can you do:

  • You can trigger animations on a viewer's touch
  • You can enable the viewer to move and rotate shapes

Using action sensors

There are four main action sensor types:

The Anchor node is a special-purpose action sensor with a built-in response

Sensing shapes

  • All action sensors sense all shapes in the same group
  • Sensors trigger when the viewer's cursor touches a sensed shape

Syntax: TouchSensor

A TouchSensor node senses the cursor's touch:

  • isOver - send true/false when cursor over/not over
  • isActive - send true/false when mouse button pressed/released
  • touchTime - send time when mouse button released

A sample use of a TouchSensor node

Syntax: SphereSensor

A SphereSensor node senses a cursor drag and generates rotations as if rotating a ball:

  • isActive - sends true/false when mouse button pressed/released
  • rotation_changed - sends rotation during a drag

Syntax: CylinderSensor

A CylinderSensor node senses a cursor drag and generates rotations as if rotating a cylinder:

  • isActive - sends true/false when mouse button pressed/released
  • rotation_changed - sends rotation during a drag

Syntax: PlaneSensor

A PlaneSensor node senses a cursor drag and generates translations as if sliding on a plane:

  • isActive - sends true/false when mouse button pressed/released
  • translation_changed - sends translations during a drag

Using multiple sensors

Multiple sensors can sense the same shape but ...

If sensors are in the same group:

  • They all respond

If sensors are at different depths in the hierarchy:

  • The deepest sensor responds
  • The other sensors do not respond

Summary

Action sensors sense when the viewer's cursor:

  • is over a shape
  • has touched a shape
  • is dragging atop a shape

Sensors convert viewer actions into events to:

  • Start and stop animations
  • Orient shapes
  • Position shapes