Module: controls

Implements the event-driven model of Blend4Web.
Sensor
Sensor is a programming entity intended for detecting events occured in the scene. Some sensors may carry a payload. For example the ray-tracing sensor (Ray Sensor) provides the relative length of the intersection ray.
Sensor Manifold (or simply manifold)
Sensors should be present in one or multiple collections - so called sensor manifolds. A manifold is a logic container associated with a scene object. It generates a response (pulse) to a defined set of sensor events by executing a callback function.

In order to use the input-output sensors, register the corresponding event listeners by using register_* methods.

Summary

Members

Methods

Type Definitions

Detailed Description

Members

CT_CHANGE

Manifold control type: change. Such manifold executes the callback each time the value of any sensor is changed. The logic function is ignored.
Source:

CT_CONTINUOUS

Manifold control type: continuous. Such manifold executes the callback with a positive pulse (+1) each frame when the result of evaluation of its logic function is non-zero. It executes a callback with a negative pulse (-1) once the logic function evaluates to zero.
Source:

CT_LEVEL

Manifold control type: level. Such manifold executes the callback each time the result of evaluation of its logic function is changed.
Source:

CT_POSITIVE

Manifold control type: positive. Such manifold executes the callback each frame when the result of evaluation of its logic function is positive.
Source:

CT_SHOT

Manifold control type: shot. Such manifold executes the callback once the result of evaluation of its logic function becomes a non-zero value.
Source:

CT_TRIGGER

Manifold control type: trigger. Such manifold executes the callback with a single positive pulse (+1) once the result of evaluation of its logic function is non-zero. It executes a callback with a single negative pulse (-1) once the logic function evaluates to zero.
Source:

default_AND_logic_fun

Default logic AND function for sensor manifold
Source:

default_OR_logic_fun

Default logic OR function for sensor manifold
Source:

KEY_1

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_2

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_3

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_4

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_5

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_6

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_7

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_8

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_9

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_A

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_ALT

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_B

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_BACK_SLASH

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_BACKSPACE

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_C

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_CAPSLOCK

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_COMMA

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_CTRL

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_D

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_DASH

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_DEC_POINT

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent. Can only be used when NUM LOCK is turned on.
Source:

KEY_DOWN

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_E

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_ENTER

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_EQUAL_SIGN

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_ESC

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_F

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_FORWARD_SLASH

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_G

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_GRAVE_ACCENT

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_H

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_I

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_J

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_K

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_L

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_LEFT

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_LEFT_SQ_BRACKET

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_M

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_N

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_NUM0

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_NUM1

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_NUM2

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_NUM3

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_NUM4

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_NUM5

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_NUM6

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_NUM7

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_NUM8

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_NUM9

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_NUM9

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_NUM9

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_NUM9

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_NUM9

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_O

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_P

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_PAUSE

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_PERIOD

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_Q

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_R

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_RIGHT

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_RIGHT_SQ_BRACKET

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_S

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_SEMI_COLON

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_SHIFT

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_SINGLE_QUOTE

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_SPACE

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_T

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_TAB

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_U

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_UP

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_V

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_W

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_X

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_Y

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

KEY_Z

Keyboard sensor parameter. Corresponds to keyCode property of KeyboardEvent.
Source:

PL_MULTITOUCH_MOVE_PAN

Payload value of a touch movement sensor. Returned by get_sensor_payload() for multi-finger pan gestures.
Source:

PL_MULTITOUCH_MOVE_ROTATE

Payload value of a touch movement sensor. Returned by get_sensor_payload() for multi-finger rotate gestures.
Source:

PL_MULTITOUCH_MOVE_ZOOM

Payload value of a touch movement sensor. Returned by get_sensor_payload() for multi-finger zoom gestures.
Source:

PL_SINGLE_TOUCH_MOVE

Payload value of a touch movement sensor. Returned by get_sensor_payload() for single-finger pan gestures.
Source:

Methods

check_sensor_manifold(objnullable, id) → {Boolean}

Check whether the object has the manifold attached.
Parameters:
Name Type Attributes Description
obj Object3D <nullable>
Object 3D, or null to denote the global object
id String Manifold ID
Returns:
Result of the check
Type
Boolean
Source:

check_sensor_manifolds(objnullable) → {Boolean}

Check whether the object has any manifolds attached.
Parameters:
Name Type Attributes Description
obj Object3D <nullable>
Object 3D, or null to denote the global object
Returns:
Result of the check
Type
Boolean
Source:

create_callback_sensor(callback, valueopt) → {Sensor}

Create a callback sensor. The given callback is executed every frame and its return value is copied into the sensor value.
Parameters:
Name Type Attributes Default Description
callback SensorCallback A callback which modifies sensor value.
value Number <optional>
0 Initial sensor value.
Returns:
Sensor object
Type
Sensor
Source:

create_collision_impulse_sensor(obj) → {Sensor}

Create a collision impulse sensor. It is intended to obtain the value of the impulse (that is, mass multiplied by velocity) applied to the object at the collision point.
Parameters:
Name Type Description
obj Object3D Collision object.
Returns:
Sensor object
Type
Sensor
Source:

create_collision_sensor(obj_src, collision_idopt, nullable, calc_pos_normopt) → {Sensor}

Create a collision sensor. Detects collisions between the object and the entities (objects or physics materials) with the specified collision ID. If the collision ID is not specified, the sensor will detect collisions with any entities. This sensor carries the following payload.
Parameters:
Name Type Attributes Default Description
obj_src Object3D Collision object.
collision_id String <optional>
<nullable>
"ANY" Collision ID, "ANY" for any collision ID
calc_pos_norm Boolean <optional>
false Should the sensor return the collision position/normal/distance or not.
Returns:
Sensor object
Type
Sensor
Source:

create_custom_sensor(value) → {Sensor}

Create a custom sensor. A custom sensor can be controlled manually by using the get_custom_sensor() and set_custom_sensor() methods.
Parameters:
Name Type Description
value Number Initial custom sensor value
Returns:
Sensor object
Type
Sensor
Source:

create_elapsed_sensor() → {Sensor}

Create an elapsed sensor. The sensor's value is the time elapsed from the previous frame.
Returns:
Sensor object
Type
Sensor
Source:

create_gamepad_axis_sensor(axis, numberopt) → {Sensor}

Create a gamepad an axis sensor.
Parameters:
Name Type Attributes Description
axis Number Axis number
number Number <optional>
Connected gamepad number
Returns:
Sensor object
Type
Sensor
Source:

create_gamepad_btn_sensor(ind, numberopt) → {Sensor}

Create a gamepad button sensor.
Parameters:
Name Type Attributes Description
ind Number Button number
number Number <optional>
Connected gamepad number
Returns:
Sensor object
Type
Sensor
Source:

create_gyro_angles_sensor() → {Sensor}

Create a gyroscope angle sensor. The sensor's payload stores the Euler angles of orientation of a mobile device.
Returns:
Sensor object
Type
Sensor
Source:

create_gyro_delta_sensor() → {Sensor}

Create a gyroscope delta sensor. The sensor's payload stores the differences between Euler angles of the current orientation and the previous orientation of a mobile device.
Returns:
Sensor object
Type
Sensor
Source:

create_gyro_quat_sensor() → {Sensor}

Create a gyroscope quaternion sensor. The sensor's payload stores the quaternion of orientation of a mobile device.
Returns:
Sensor object
Type
Sensor
Source:

create_hmd_position_sensor() → {Sensor}

Create a HMD position sensor. The sensor's payload stores the vector of HMD position.
Returns:
Sensor object
Type
Sensor
Source:

create_hmd_quat_sensor() → {Sensor}

Create a HMD quaternion sensor. The sensor's payload stores the quaternion of orientation of a HMD.
Returns:
Sensor object
Type
Sensor
Source:

create_kb_sensor_manifold(objnullable, id, type, key, callback, callback_paramopt)

Convenience function: creates a manifold coupled with a single keyboard sensor. Can be used to quickly create a single-key functionality.
Parameters:
Name Type Attributes Description
obj Object3D <nullable>
Object 3D to attach the manifold to, or null to denote the global object
id String New manifold ID
type Number Manifold control type (CT_SHOT, CT_TRIGGER etc)
key Number Sensor key KEY_*
callback ManifoldCallback Manifold's callback
callback_param * <optional>
Parameter to pass to the manifold's callback (e.g. some state)
Source:

create_keyboard_sensor(key, elementopt) → {Sensor}

Create a keyboard sensor. This sensor carries the following payload values: 0 --- button wasn't pressed at the last frame, and it wasn't pressed at the current frame, 1 --- button wasn't pressed at the last frame, but it was pressed at the current frame, 2 --- button was pressed at the last frame, and it was pressed at the current frame, 3 --- button was pressed at the last frame, and it wasn't pressed at the current frame.
Parameters:
Name Type Attributes Default Description
key Number Sensor key KEY_*
element HTMLElement <optional>
Canvas container element HTML element
Returns:
Sensor object
Type
Sensor
Source:

create_motion_sensor(obj, thresholdopt, rotation_thresholdopt) → {Sensor}

Create a motion sensor. The sensor's value is 1 if the object is in motion.
Parameters:
Name Type Attributes Default Description
obj Object3D Object 3D
threshold Number <optional>
0.1 Translation velocity threshold, units (meters) per second
rotation_threshold Number <optional>
0.1 Rotation velocity threshold, radians per second
Returns:
Sensor object
Type
Sensor
Source:

create_mouse_click_sensor(elementopt) → {Sensor}

Create a mouse click sensor. The sensor's payload is an object with useful properties like coordinates, and index of button
Parameters:
Name Type Attributes Default Description
element HTMLElement <optional>
Canvas container element HTML element
Returns:
Sensor object
Type
Sensor
Source:

create_mouse_move_sensor(axisopt, elementopt) → {Sensor}

Create a mouse movement sensor. The sensor's value is a number of pixels, the sensor's payload is an object with useful properties like coordinates
Parameters:
Name Type Attributes Default Description
axis String <optional>
"XY" Coordinate(s) to track: "X", "Y", "XY"
element HTMLElement <optional>
Canvas container element HTML element
Returns:
Sensor object
Type
Sensor
Source:

create_mouse_wheel_sensor(elementopt) → {Sensor}

Create a mouse wheel sensor. The sensor's value is 1 for a single wheel notch scrolled away from the user.
Parameters:
Name Type Attributes Default Description
element HTMLElement <optional>
Canvas container element HTML element
Returns:
Sensor object
Type
Sensor
Source:

create_plock_mouse_sensor(elementopt) → {Sensor}

Create a mouse move pointerlock sensor. The sensor's value is a number of pixels, the sensor's payload is an object with useful properties like coordinates
Parameters:
Name Type Attributes Default Description
element HTMLElement <optional>
Canvas container element HTML element
Returns:
Sensor object
Type
Sensor
Source:

create_plock_sensor(elementopt) → {Sensor}

Create a mouse pointerlock sensor. The sensor's value is a pointerlock state
Parameters:
Name Type Attributes Default Description
element HTMLElement <optional>
Canvas container element HTML element
Returns:
Sensor object
Type
Sensor
Source:

create_ray_sensor(obj_src, from, to, collision_idopt, nullable, is_binary_valueopt, calc_pos_normopt, ign_src_rotopt) → {Sensor}

Create a ray sensor. The sensor casts a ray between the from and to positions. These positions are specified relatively to the object's origin (ign_src_rot = true), in the world space (obj_src = null) or in the local space (ign_src_rot = false). Checks intersection of this ray with the specified collision ID. If the collision ID is not specified, the sensor will detect collisions with any entities. This sensor carries the following payload.
Parameters:
Name Type Attributes Default Description
obj_src Object3D Source object, pass a non-null value to perform ray casting in object space, e.g. from/to vectors specified in object space.
from Vec3 From vector.
to Vec3 To vector.
collision_id String <optional>
<nullable>
"ANY" Collision ID, "ANY" for any collision ID
is_binary_value Boolean <optional>
false Calculate the value of the sensor as a binary (hit/non-hit) instead of hit fraction.
calc_pos_norm Boolean <optional>
false Calculate hit position/normal (accessed from payload object).
ign_src_rot Boolean <optional>
false Ignore any rotation of the source object during ray casting.
Returns:
Sensor object.
Type
Sensor
Source:

create_selection_sensor(obj, enable_toggle_switchopt) → {Sensor}

Create a selection sensor for the object. The sensor's value becomes 1 when the object is selected by the user.
Parameters:
Name Type Attributes Default Description
obj Object3D Object 3D
enable_toggle_switch Boolean <optional>
false If true, reset the sensor (set it to 0) only when another object is selected. If false, reset the sensor when the mouse button/touch is released.
Returns:
Sensor object
Type
Sensor
Source:

create_sensor_manifold(objnullable, id, type, sensors, logic_funnullable, callback, callback_paramopt)

Create a sensor manifold.
Parameters:
Name Type Attributes Description
obj Object3D <nullable>
Object 3D to attach the manifold to, or null to denote the global object.
id String New manifold ID.
type Number Manifold control type (CT_SHOT, CT_TRIGGER etc).
sensors Array.<Sensor> Array of sensors.
logic_fun ManifoldLogicFunction <nullable>
Manifold's logic function, if null use default_AND_logic_fun function.
callback ManifoldCallback Manifold's callback.
callback_param * <optional>
Parameter to pass to the manifold's callback (e.g. some state).
Source:

create_timeline_sensor() → {Sensor}

Create a timeline sensor. The sensor's value is the value of the global engine timeline.
Returns:
Sensor object
Type
Sensor
Source:

create_timer_sensor(period, do_repeatopt) → {Sensor}

Create a timer sensor. The sensor's value becomes 1 for the frame which comes next after the period of time has elapsed. After that, its value becomes 0 again. The timer's precision depends on FPS, so it is not effective for measuring short intervals.
Parameters:
Name Type Attributes Default Description
period Number Timer period, in seconds
do_repeat Boolean <optional>
false Re-start the timer upon expiration
Returns:
Sensor object
Type
Sensor
Source:

create_touch_click_sensor(elementopt) → {Sensor}

Create a touch click sensor. The sensor's value is 1 for a touched fouchscreen.the sensor's payload is an object with useful properties like coordinates
Parameters:
Name Type Attributes Default Description
element HTMLElement <optional>
Canvas container element HTML element
Returns:
Sensor object
Type
Sensor
Source:

create_touch_move_sensor(axisopt, elementopt) → {Sensor}

Create a touch movement sensor. The sensor's value is a number of pixels, the sensor's payload is an object with useful properties like coordinates
Parameters:
Name Type Attributes Default Description
axis String <optional>
"XY" Coordinate(s) to track: "X", "Y" or "XY"
element HTMLElement <optional>
Canvas container element HTML element
Returns:
Sensor object
Type
Sensor
Source:

create_touch_rotate_sensor(elementopt) → {Sensor}

Create a touch rotate sensor. The sensor's value is the angle from -PI to PI.
Parameters:
Name Type Attributes Default Description
element HTMLElement <optional>
Canvas container element HTML element
Returns:
Sensor object
Type
Sensor
Source:

create_touch_zoom_sensor(elementopt) → {Sensor}

Create a touch zoom sensor. The sensor's value is the distance difference in pixels.
Parameters:
Name Type Attributes Default Description
element HTMLElement <optional>
Canvas container element HTML element
Returns:
Sensor object
Type
Sensor
Source:

create_vertical_velocity_sensor(obj, thresholdopt) → {Sensor}

Create a velocity sensor. The sensor's value is 1 if abs() of the object's vertical velocity exceeds the threshold.
Parameters:
Name Type Attributes Default Description
obj Object3D Object 3D
threshold Number <optional>
1.0 Vertical velocity threshold, units (meters) per second
Returns:
Sensor object
Type
Sensor
Source:

get_custom_sensor(sensor) → {Number}

Get the value of the custom sensor.
Parameters:
Name Type Description
sensor Sensor Sensor object
Returns:
Sensor value
Type
Number
Source:

get_sensor_payload(objnullable, manifold_id, num) → {*}

Return the payload data of the sensor from the object's manifold. The sensor is identified by its index in the manifold's array of sensors.
Parameters:
Name Type Attributes Description
obj Object3D <nullable>
Object 3D, or null to denote the global object
manifold_id String Object's manifold ID
num Number Sensor index in manifold's array
Returns:
Sensor payload
Type
*
Source:

get_sensor_value(objnullable, manifold_id, num) → {Number}

Return the value of the sensor from the object's manifold. The sensor is identified by its index in the manifold's array of sensors.
Parameters:
Name Type Attributes Description
obj Object3D <nullable>
Object 3D, or null to denote the global object
manifold_id String Object's manifold ID
num Number Sensor index in manifold's array
Returns:
Sensor value
Type
Number
Source:

register_device_orientation()

Add device orientation event listener (deviceorientation) to the DOM window.
Deprecated:
  • Not needed anymore.
Source:

register_keyboard_events(element, prevent_default)

Add keyboard event listeners (keydown and keyup) to the HTML element. Required for work of keyboard sensors.
Parameters:
Name Type Description
element HTMLElement HTML element to add event listeners to
prevent_default Boolean Prevent browsers' default actions for registered events.
Deprecated:
  • Not needed anymore.
Source:

register_mouse_events(element, prevent_default, allow_element_exitopt)

Add mouse event listeners (mousedown, mouseup, mousemove and mouseout) to the HTML element. Required for work of mouse click and mouse movement sensors.
Parameters:
Name Type Attributes Default Description
element HTMLElement HTML element to add event listeners to
prevent_default Boolean Prevent browser default actions for registered events.
allow_element_exit Boolean <optional>
false Continue receiving mouse events even when the mouse is leaving the HTML element
Deprecated:
  • Not needed anymore.
Source:

register_touch_events(element, prevent_default)

Add touch event listeners (touchstart and touchmove) to the HTML element. Required for work of touch movement and touch zoom sensors.
Parameters:
Name Type Description
element HTMLElement HTML element to add event listeners to
prevent_default Boolean Prevent browser default actions for registered events.
Deprecated:
  • Not needed anymore.
Source:

register_wheel_events(element, prevent_default)

Add mouse wheel event listeners (mousewheel and DOMMouseScroll) to the HTML element. Required for work of mouse wheel sensors.
Parameters:
Name Type Description
element HTMLElement HTML element to add event listeners to
prevent_default Boolean Prevent browser default actions for registered events.
Deprecated:
  • Not needed anymore.
Source:

remove_sensor_manifold(objnullable, idopt)

Remove the sensor manifold registered for the object.
Parameters:
Name Type Attributes Default Description
obj Object3D <nullable>
Object 3D to delete the manifold from, or null to denote the global object
id String <optional>
null ID of the sensor manifold, or null to delete all manifolds
Source:

reset()

Reset controls for all the objects. Calling this method is discouraged, use remove_sensor_manifold() instead.
Source:

reset_timer_sensor(obj, manifold_id, num, period)

Reset the timer sensor and set a new period value.
Parameters:
Name Type Description
obj Object3D Object 3D
manifold_id String Object's manifold ID
num Number Sensor's number in the manifold
period Number A new period value for the sensor
Source:

set_custom_sensor(sensor, value)

Set the value of the custom sensor.
Parameters:
Name Type Description
sensor Sensor Sensor object
value Number New sensor value
Source:

set_plock_smooth_factor(value)

Set smooth factor for mouse pointerlock sensor.
Parameters:
Name Type Description
value Number Set
Source:

unregister_device_orientation()

Remove device orientation event listener (deviceorientation) from the DOM window.
Deprecated:
  • Not needed anymore.
Source:

unregister_keyboard_events(element)

Remove keyboard event listeners (keydown and keyup) from the HTML element.
Parameters:
Name Type Description
element HTMLElement HTML element to remove event listeners from
Deprecated:
  • Not needed anymore.
Source:

unregister_mouse_events(element)

Remove mouse event listeners (mousedown, mouseup, mousemove and mouseout) from the HTML element.
Parameters:
Name Type Description
element HTMLElement HTML element to remove event listeners from
Deprecated:
  • Not needed anymore.
Source:

unregister_touch_events(element)

Remove touch event listeners (touchstart and touchmove) from the HTML element.
Parameters:
Name Type Description
element HTMLElement HTML element to remove event listeners from
Deprecated:
  • Not needed anymore.
Source:

unregister_wheel_events(element)

Remove mouse wheel event listeners (mousewheel and DOMMouseScroll) from the HTML element.
Parameters:
Name Type Description
element HTMLElement HTML element to remove event listeners from
Deprecated:
  • Not needed anymore.
Source:

Type Definitions

CollisionPayload(coll_objnullable, coll_posnullable, coll_normnullable, coll_distnullable)

Collision sensor payload.
Parameters:
Name Type Attributes Description
coll_obj Object3D <nullable>
The target collision object, i.e the object the source object collides with (null for no collision or when this object is represented by collision material).
coll_pos Vec3 <nullable>
Position of collision point.
coll_norm Vec3 <nullable>
Normal of collision point.
coll_dist Number <nullable>
Distance between collision points of colliding objects.
Source:

ManifoldCallback(objnullable, id, pulse, paramopt)

Manifold's callback. It is executed when the manifold generates a pulse.
Parameters:
Name Type Attributes Description
obj Object3D <nullable>
Object 3D, or null to denote the global object
id String Manifold ID
pulse Number Additional callback condition for CT_TRIGGER or CT_CONTINUOUS manifolds: +1 or -1
param * <optional>
Callback parameter. The user-defined parameter which is passed to create_sensor_manifold(). Can be used, for example, as a storage object to communicate between different manifolds.
Source:

ManifoldLogicFunction(s) → {Number}

Manifold's logic function. Specifies a logic expression which consists of sensor values. This logic expression will be evaluated every frame. As a result, the manifold changes its internal state and fires the callback.
Parameters:
Name Type Description
s Array Numeric array with sensor values.
Returns:
Result of evaluation of the logic expression
Type
Number
Source:

RayPayload(hit_fract, obj_hitnullable, hit_time, hit_pos, hit_norm)

Ray sensor payload.
Parameters:
Name Type Attributes Description
hit_fract Number Fraction of ray length where hit has occured (0-1) or -1 if there is no hit anymore.
obj_hit Object3D <nullable>
The hit object.
hit_time Number Time the hit happened.
hit_pos Vec3 Hit position in world space.
hit_norm Vec3 Hit normal in world space.
Source:

SensorCallback()

Special callback for callback-sensor. It's executed every frame and its return value is copied into the sensor value. Should return a numeric value.
Source: