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.

Methods

add

(
  • objects
)

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

Parameters:

addAbove

(
  • object
  • index
)

Provided by the Textures module.

Add object as children of this object above the indicated children

Parameters:

  • object THREE.Object3D
  • index Number

addBellow

(
  • object
  • index
)

Provided by the Textures module.

Add object as children of this object bellow the indicated children

Parameters:

  • object THREE.Object3D
  • index Number

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.

contains

(
  • object
)
Boolean

Provided by the Textures module.

Check if this object contains a object.

Parameters:

  • object THREE.Object3D

    Object to look for.

Returns:

Boolean:

True if this object contains the object.

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

()

Provided by the Textures module.

Destroy object, dispose and remove from its parent.

dispose

()

Provided by the Textures module.

Disposes the object from memory.

Should be called when the object is no longer required 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.

getScene

() THREE.Object3D

Provided by the Textures module.

Get scene that contains this object.

Returns:

THREE.Object3D:

scene

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.

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

()

Provided by the Textures module.

Initializes the object.

This method is calling one time on initialization.

isEmpty

() Boolean

Provided by the Textures module.

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.

playAnimation

()

Provided by the Textures module.

Play animations attached to this object.

Animations rely on other objects, if some of these are missing the animation will have problems playing.

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

()

Provided by the Textures module.

Remove all children from the object.

resize

(
  • x
  • y
)

Provided by the Textures module.

Resize this object, called everytime the window is resized.

Parameters:

  • x Number

    Screen width.

  • y Number

    Screen 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.

stopAnimation

()

Provided by the Textures module.

Stop all animations playback.

toJSON

(
  • meta
  • resourceAccess
  • recursive
)
Object

Provided by the Textures module.

Serialize the object data to JSON. Should serialize all attributes and resources used by the object.

Parsing of the data serialized is performed using the ObjectLoader class.

The objects being serialized share a "meta" object where the resources can be stored to avoid repetition in the serialized data.

On the root object the meta object does not need to be initialized manually it is automatically created, to access resource the resourceAccess callback should be used.

Parameters:

  • meta Object

    Resource storage passed to all resources toJSON for self storage.

  • resourceAccess Function

    Callback method used to access the resources receives (meta, object) as parameters, meta is the resource storage and object is the current serialized status of the object new attributes can be added here.

  • recursive Boolean

    If true the method will call toJSON for all available children and store the result in children attribute.

Returns:

Object:

json Output JSON will all data serialized, this can be stores in file or transfered to later be loaded using the ObjectLoader.

update

(
  • delta
)

Provided by the Textures module.

Update the object state.

Called every time before rendering into the screen.

Parameters:

  • delta Number

    Time since last update call.

worldToLocal

(
  • vector
)

Updates the vector from world space to local space.

Parameters:

  • vector Vector3

    A world vector

Properties

animations

Array

Array with the animations available in this object.

Each position contains an AnimationClip that has name, tracks, duration and uuid.

castShadow

Boolean

Whether the object gets rendered into shadow map.

Default: false

children

Array

Array with object's children.

folded

Boolean

Provided by the Textures module.

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

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.

locked

Boolean

Provided by the Textures module.

Indicates if the object is locked. A locked object cannot be edited.

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