Object3D Class

Module: THREE

This is the base class for most objects in three.js and provides a set of properties and methods for manipulating objects in 3D space.

This page provides documentation for some of the main features of this class, the original documentation of this class can be found at https://threejs.org/docs/index.html#Reference/Core/Object3D.

All nunuStudio objects extend the Object3D class of some other higher level class from three.js.

Constructor

Object3D

()

Methods

add

(
  • objects
)

Adds object as child of this object. An arbitrary number of objects may be added.

Parameters:

addAbove

(
  • object
  • index
)

Add object as children of this object above the indicated children

Parameters:

addBellow

(
  • object
  • index
)

Add object as children of this object bellow the indicated children

Parameters:

applyMatrix

(
  • matrix
)

This updates the position, rotation and scale with the matrix.

Parameters:

  • matrix Matrix4

clone

(
  • recursive
)

Returns a clone of this object and optionaly all descendants.

Parameters:

  • recursive Boolean

    If true, descendants of the object are also cloned. Default is true.

copy

(
  • object
  • recursive
)

Copy the given object into this object.

Parameters:

  • object Object3D
  • recursive Boolean

    If true, descendants of the object are also copied. Default is true.

destroy

()

Destroy object, dispose and remove from its parent.

dispose

()

Disposes the object (to avoid memory leaks).

getObjectByName

(
  • name
)

Searches through the object's children and returns the first with a matching name.

Parameters:

  • name String

    String to match to the children's Object3d.name property.

getObjectByProperty

(
  • name
  • value
)

Searches through the object's children and returns the first with a property that matches the aclue given.

Parameters:

  • name String

    The property name to search for.

  • value Object

    Value of the given property.

getWorldDirection

(
  • optionalTarget
)

Returns a vector representing the direction of object's positive z-axis in world space.

Parameters:

  • optionalTarget Vector3

    If specified, the result will be copied into this Vector3, otherwise a new Vector3 will be created.

getWorldPosition

(
  • optionalTarget
)
Vector3

Parameters:

  • optionalTarget Vector3

    Target to set the result. Otherwise, a new Vector3 is instantiated.

Returns:

Vector3:

Returns a vector representing the position of the object in world space.

getWorldQuaternion

(
  • optionalTarget
)

Returns a quaternion representing the rotation of the object in world space.

Parameters:

  • optionalTarget Quaternion

    If specified, the result will be copied into this Quaternion, otherwise a new Quaternion will be created.

getWorldRotation

(
  • optionalTarget
)

Returns the euler angles representing the rotation of the object in world space.

Parameters:

  • optionalTarget Euler

    If specified, the result will be copied into this Euler, otherwise a new Euler will be created.

getWorldScale

(
  • optionalTarget
)

Returns a vector of the scaling factors applied to the object for each axis in world space.

Parameters:

  • optionalTarget Vector3

    If specified, the result will be copied into this Vector3, otherwise a new Vector3 will be created.

initialize

()

Initialize the object.

isEmpty

() Boolean

Check if object is empty (has no childrens).

Returns:

Boolean:

True is object is empty

localToWorld

(
  • vector
)

Converts the vector from local space to world space.

Parameters:

  • vector Vector3

    vector representing a position in local (object) space.

lookAt

(
  • vector
)

Rotates the object to face a point in world space.

Parameters:

  • vector Vector3

    A vector representing a position in world space.

remove

(
  • objects
)

Remove children from this object

Parameters:

  • objects Object3D

    Removes object as child of this object. An arbitrary number of objects may be removed.

removeAll

()

Remove all children from the object.

resize

(
  • x
  • y
)

Resize this object, called everytime the window is resized.

Parameters:

  • x Number

    Width.

  • y Number

    Height.

rotateOnAxis

(
  • axis
  • angle
)

Rotate an object along an axis in object space. The axis is assumed to be normalized..

Parameters:

  • axis Vector3

    A normalized vector in object space.

  • angle Number

    The angle in radians.

rotateX

(
  • rad
)

Rotates the object around x axis in local space.

Parameters:

  • rad Number

    The angle to rotate in radians.

rotateY

(
  • rad
)

Rotates the object around y axis in local space.

Parameters:

  • rad Number

    The angle to rotate in radians.

rotateZ

(
  • rad
)

Rotates the object around z axis in local space.

Parameters:

  • rad Number

    The angle to rotate in radians.

toJSON

(
  • meta
  • resourceAccess
  • recursive
)
Object

Serialize object to JSON.

Parameters:

  • meta Object
  • resourceAccess Function
  • recursive Boolean

Returns:

Object:

json

update

()

Update the object state, called every time before rendering into the screen.

worldToLocal

(
  • vector
)

Updates the vector from world space to local space.

Parameters:

Properties

castShadow

Boolean

Whether the object gets rendered into shadow map.

Default: false

children

Array

Array with object's children.

folded

Boolean

Folded attribute is used only for editing, if true the object shows as folded in the object explorer.

frustumCulled

Boolean

When this is set, it checks every frame if the object is in the frustum of the camera before rendering the object. Otherwise the object gets renderered every frame even if it isn't visible.

Default: true

hidden

Boolean

Hidden objects do not show in the editor.

layers

Layers

The layer membership of the object. The object is only visible if it has at least one layer in common with the Camera in use.

matrix

Matrix4

The local transform matrix

matrixAutoUpdate

Boolean

When this is set, it calculates the matrix of position, (rotation or quaternion) and scale every frame and also recalculates the matrixWorld property.

Default: true

matrixWorld

Matrix4

The global transform of the object. If the Object3d has no parent, then it's identical to the local transform.

name

String

Name of the object (doesn't need to be unique).

position

Vector3

The object's local position.

quaternion

Quaternion

Object's local rotation as a Quaternion.

receiveShadow

Boolean

Whether the material receives shadows.

Default: false

renderOrder

Number

This value allows the default rendering order of scene graph objects to be overridden although opaque and transparent objects remain sorted independently.

Default: 0

rotation

Euler

Object's local rotation (see Euler angles), in radians.

scale

Vector3

The object's local scale.

up

Vector3

This is used by the lookAt method, for example, to determine the orientation of the result.

userData

Object

Space reserved for user data, can be used for variables in runtime or can be used by scripts to store values on an object.

uuid

String

UUID of this object instance. This gets automatically assigned, so this shouldn't be edited.

visible

Boolean

Object gets rendered if true.

Default: true