Module: transform

Object transformations API. With some exceptions specified below, make sure that the objects are dynamic.

Summary

Members

Methods

Detailed Description

Members

SPACE_LOCAL

Transform in the local space
Type:
Deprecated:
  • Not needed anymore.
Source:

SPACE_WORLD

Transform in the world space
Type:
Deprecated:
  • Not needed anymore.
Source:

Methods

distance(obj1, obj2) → {Number}

Get distance between the two objects.
Parameters:
Name Type Description
obj1 Object3D Object 3D 1
obj2 Object3D Object 3D 2
Returns:
Distance
Type
Number
Source:

empty_reset_transform(obj)

Reset EMPTY's transform to allow child objects behave in the absolute (world) space.
Parameters:
Name Type Description
obj Object3D Object 3D
Source:

get_matrix(obj, destopt) → {Mat4}

Return the object's transformation matrix. It's better to use TSR form.
Parameters:
Name Type Attributes Description
obj Object3D Object 3D
dest Mat4 <optional>
Destination matrix.
Returns:
Destination matrix.
Type
Mat4
Source:

get_matrix_rel(obj, destopt) → {Mat4}

Return the object's transformation matrix (in the coordinate space of its parent). It's better to use TSR form.
Parameters:
Name Type Attributes Description
obj Object3D Object 3D
dest Mat4 <optional>
Destination matrix.
Returns:
Destination matrix.
Type
Mat4
Source:

get_object_bounding_box(obj) → {BoundingBox}

Get object bounding box.
Parameters:
Name Type Description
obj Object3D Object 3D
Returns:
Bounding box
Type
BoundingBox
Source:

get_object_center(obj, calc_bs_center, destopt) → {Vec3}

Get the object center in the world space. Works for dynamic and static objects.
Parameters:
Name Type Attributes Description
obj Object3D Object 3D
calc_bs_center Boolean Use the object's bounding sphere to calculate center, otherwise use the bounding box.
dest Vec3 <optional>
Destination vector
Returns:
Destination vector
Type
Vec3
Source:

get_object_size(obj) → {Number}

Get object size (maximum radius, calculated from bounding box).
Parameters:
Name Type Description
obj Object3D Object 3D
Returns:
Object size
Type
Number
Source:

get_rotation(obj, opt_destopt) → {Quat}

Get the object's rotation quaternion.
Parameters:
Name Type Attributes Description
obj Object3D Object 3D
opt_dest Quat <optional>
Destination vector
Returns:
Destination vector
Type
Quat
Source:
Example
var m_scenes = require("scenes");
var m_trans = require("transform");
var m_quat  = require("quat");
// precache quaternion
var _quat_tmp = m_quat.create();
// ...
var cube = m_scenes.get_object_by_name("Cube");
var rot_quat = m_trans.get_rotation(cube, _quat_tmp);

get_rotation_euler(obj, destopt) → {Quat}

Get Euler rotation of object in the ZYX intrinsic system. Using euler angles is discouraged, use quaternion instead.
Parameters:
Name Type Attributes Default Description
obj Object3D Object 3D
dest Euler <optional>
new Float32Array(3) Destination vector
Returns:
Vector with Euler angles
Type
Quat
Source:

get_rotation_euler(obj, destopt) → {Quat}

Get Euler rotation of object in the ZYX intrinsic system (in the coordinate space of its parent). Using euler angles is discouraged, use quaternion instead.
Parameters:
Name Type Attributes Default Description
obj Object3D Object 3D
dest Euler <optional>
new Float32Array(3) Destination vector
Returns:
Vector with Euler angles
Type
Quat
Source:

get_rotation_rel(obj, opt_destopt) → {Quat}

Get the object's rotation quaternion (in the coordinate space of its parent).
Parameters:
Name Type Attributes Description
obj Object3D Object 3D
opt_dest Quat <optional>
Destination vector
Returns:
Destination vector
Type
Quat
Source:

get_scale(obj) → {Number}

Get the object scale.
Parameters:
Name Type Description
obj Object3D Object 3D
Returns:
scale
Type
Number
Source:

get_scale_rel(obj) → {Number}

Get the object scale (in the coordinate space of its parent).
Parameters:
Name Type Description
obj Object3D Object 3D
Returns:
scale
Type
Number
Source:

get_translation(obj, destopt) → {Vec3}

Get the object's translation vector.
Parameters:
Name Type Attributes Description
obj Object3D Object 3D
dest Vec3 <optional>
Destination vector
Returns:
Destination vector
Type
Vec3
Source:
Example
var m_scenes = require("scenes");
var m_trans = require("transform");
var m_vec3 = require("vec3");
// precache 3D vector
var _vec3_tmp = m_vec3.create();
// ...
var cube = m_scenes.get_object_by_name("Cube");
var translation = m_trans.get_translation(cube, _vec3_tmp);

get_translation_rel(obj, destopt) → {Vec3}

Get the object's translation vector (in the coordinate space of its parent).
Parameters:
Name Type Attributes Description
obj Object3D Object 3D
dest Vec3 <optional>
Destination vector
Returns:
Destination vector
Type
Vec3
Source:

get_tsr(obj, destopt) → {TSR}

Return an object's transformation in TSR form.
Parameters:
Name Type Attributes Description
obj Object3D Object 3D
dest TSR <optional>
Destination vector.
Returns:
Destination vector.
Type
TSR
Source:

get_tsr_rel(obj, destopt) → {TSR}

Return the object transformation in TSR form. (in the coordinate space of its parent).
Parameters:
Name Type Attributes Description
obj Object3D Object 3D
dest TSR <optional>
Destination vector.
Returns:
Destination vector.
Type
TSR
Source:

move_local(obj, dx, dy, dz)

Perform incremental object translation in the local space.
Parameters:
Name Type Description
obj Object3D Object 3D
dx Number Translation offset along X axis
dy Number Translation offset along Y axis
dz Number Translation offset along Z axis
Source:

rotate_x_local(obj, angle)

Perform incremental rotation around X axis in the local space.
Parameters:
Name Type Description
obj Object3D Object 3D
angle Number Angle
Source:

rotate_y_local(obj, angle)

Perform incremental rotation around Y axis in the local space.
Parameters:
Name Type Description
obj Object3D Object 3D
angle Number Angle
Source:

rotate_z_local(obj, angle)

Perform incremental rotation around Z axis in the local space.
Parameters:
Name Type Description
obj Object3D Object 3D
angle Number Angle
Source:

set_matrix(obj, mat)

Set the object's transformation matrix. It's better to use TSR form.
Parameters:
Name Type Description
obj Object3D Object 3D
mat Mat4 Matrix
Source:

set_matrix_rel(obj, mat)

Set the object's transformation matrix (in the coordinate space of its parent). It's better to use TSR form.
Parameters:
Name Type Description
obj Object3D Object 3D
mat Mat4 Matrix
Source:

set_rotation(obj, x, y, z, w)

Set the object's rotation quaternion.
Parameters:
Name Type Description
obj Object3D Object 3D
x Number X part of quaternion
y Number Y part of quaternion
z Number Z part of quaternion
w Number W part of quaternion
Source:

set_rotation_euler(obj, x, y, z)

Set euler rotation in the ZYX intrinsic system. Using euler angles is discouraged, use quaternion instead.
Parameters:
Name Type Description
obj Object3D Object 3D
x Number Angle X
y Number Angle Y
z Number Angle Z
Source:

set_rotation_euler_rel(obj, x, y, z)

Set euler rotation in the ZYX intrinsic system (in the coordinate space of its parent). Using euler angles is discouraged, use quaternion instead.
Parameters:
Name Type Description
obj Object3D Object 3D
x Number Angle X
y Number Angle Y
z Number Angle Z
Source:

set_rotation_euler_rel_v(obj, euler)

Set euler rotation in vector form relatively to its parent (in the coordinate space of its parent). Using euler angles is discouraged, use quaternion instead.
Parameters:
Name Type Description
obj Object3D Object 3D
euler Euler Vector with euler angles
Source:

set_rotation_euler_v(obj, euler)

Set euler rotation in vector form. Using euler angles is discouraged, use quaternion instead.
Parameters:
Name Type Description
obj Object3D Object 3D
euler Euler Vector with euler angles
Source:

set_rotation_rel(obj, x, y, z, w)

Set the object's rotation quaternion (in the coordinate space of its parent).
Parameters:
Name Type Description
obj Object3D Object 3D
x Number X part of quaternion
y Number Y part of quaternion
z Number Z part of quaternion
w Number W part of quaternion
Source:

set_rotation_rel_v(obj, quat)

Set the object's rotation in vector form (in the coordinate space of its parent).
Parameters:
Name Type Description
obj Object3D Object 3D
quat Quat Quaternion vector
Source:

set_rotation_v(obj, quat)

Set the object's rotation in vector form.
Parameters:
Name Type Description
obj Object3D Object 3D
quat Quat Quaternion vector
Source:

set_scale(obj, scale)

Set the object scale.
Parameters:
Name Type Description
obj Object3D Object 3D
scale Number Object scale
Source:

set_scale_rel(obj, scale)

Set the object's scale (in the coordinate space of its parent).
Parameters:
Name Type Description
obj Object3D Object 3D
scale Number Object scale
Source:

set_translation(obj, x, y, z)

Set the object translation.
Parameters:
Name Type Description
obj Object3D Object 3D
x Number X coord
y Number Y coord
z Number Z coord
Source:

set_translation_obj_rel(obj, x, y, z, obj_ref)

Set the object translation relatively to another object.
Parameters:
Name Type Description
obj Object3D Transformed object
x Number X coord
y Number Y coord
z Number Z coord
obj_ref Object3D Reference object
Source:

set_translation_rel(obj, x, y, z)

Set the object translation (in the coordinate space of its parent).
Parameters:
Name Type Description
obj Object3D Object 3D
x Number X coord
y Number Y coord
z Number Z coord
Source:

set_translation_rel_v(obj, trans)

Set the object translation in vector form (in the coordinate space of its parent).
Parameters:
Name Type Description
obj Object3D Object 3D
trans Vec3 Translation vector
Source:

set_translation_v(obj, trans)

Set the object translation (vector form).
Parameters:
Name Type Description
obj Object3D Object 3D
trans Vec3 Translation vector
Source:

set_tsr(obj, tsr)

Set the object's TSR vector.
Parameters:
Name Type Description
obj Object3D Object 3D
tsr TSR vector
Source:

set_tsr_rel(obj, tsr)

Set the object's TSR vector (in the coordinate space of its parent).
Parameters:
Name Type Description
obj Object3D Object 3D
tsr TSR vector
Source: