# GraphNode

Class · extends [`EventHandler`](https://api.playcanvas.com/engine/classes/EventHandler.md) · category: Framework

Source: https://github.com/playcanvas/engine/blob/f059dc005842f76e052cdf44d8370c8c7ec475ac/src/scene/graph-node.js#L122

A GraphNode is a node in the scene graph: a named object with a position, rotation and scale,
and a list of [children](https://api.playcanvas.com/engine/classes/GraphNode.md#children) whose transforms are expressed relative to it. Nodes form a tree,
and the world transform of any node is its local transform combined with the world transform of
its [parent](https://api.playcanvas.com/engine/classes/GraphNode.md#parent); the [root](https://api.playcanvas.com/engine/classes/GraphNode.md#root) has no parent, so its world transform is its local one. The
engine brings every world transform up to date each frame before rendering, so a change to a
parent reaches all of its descendants.

GraphNode is the base class of [Entity](https://api.playcanvas.com/engine/classes/Entity.md), which adds components, so in practice these
methods are called on entities. The conventions are the same on both:

- Local methods such as [setLocalPosition](https://api.playcanvas.com/engine/classes/GraphNode.md#setlocalposition) and [getLocalRotation](https://api.playcanvas.com/engine/classes/GraphNode.md#getlocalrotation) work relative to
the parent. Their world counterparts, [setPosition](https://api.playcanvas.com/engine/classes/GraphNode.md#setposition), [getRotation](https://api.playcanvas.com/engine/classes/GraphNode.md#getrotation) and the rest,
account for the whole chain of ancestors.
- Setters accept separate components or a vector or quaternion, and copy the value.
- Getters return the node's internal storage as read-only; clone the result if you need to
keep or modify it.
- Euler angles are in degrees, and [forward](https://api.playcanvas.com/engine/classes/GraphNode.md#forward) is the node's negative Z axis.

Build the hierarchy with [addChild](https://api.playcanvas.com/engine/classes/GraphNode.md#addchild), [insertChild](https://api.playcanvas.com/engine/classes/GraphNode.md#insertchild), [removeChild](https://api.playcanvas.com/engine/classes/GraphNode.md#removechild) and
[reparent](https://api.playcanvas.com/engine/classes/GraphNode.md#reparent), and search it with [findByName](https://api.playcanvas.com/engine/classes/GraphNode.md#findbyname), [findByPath](https://api.playcanvas.com/engine/classes/GraphNode.md#findbypath), [findByTag](https://api.playcanvas.com/engine/classes/GraphNode.md#findbytag)
and [find](https://api.playcanvas.com/engine/classes/GraphNode.md#find). Setting [enabled](https://api.playcanvas.com/engine/classes/GraphNode.md#enabled) to false disables the node and its whole subtree.

**Example**

```ts
// Move a node one unit in its own facing direction, then turn it to face a target
node.translateLocal(0, 0, -1);
node.lookAt(target.getPosition());
```

**Example**

```ts
// Getters return read-only internal storage: clone before modifying
const start = node.getPosition().clone();
start.y += 1;
node.setPosition(start);
```

## Constructors

### constructor

```ts
new GraphNode(name?: string)
```

Create a new GraphNode instance.

**Parameters**

- `name` (`string`, optional, default `'Untitled'`): The non-unique name of a graph node. Defaults to 'Untitled'.

## Properties

### _children

```ts
protected _children: GraphNode[] = []
```

### name

```ts
name: string
```

The non-unique name of a graph node. Defaults to 'Untitled'.

### tags

```ts
tags: Tags
```

Interface for tagging graph nodes. Tag based searches can be performed using the
[findByTag](https://api.playcanvas.com/engine/classes/GraphNode.md#findbytag) function.

## Accessors

### children

```ts
get children(): readonly GraphNode[]
```

Gets the children of this graph node. Use addChild, insertChild, removeChild or reparent to
change the hierarchy.

### enabled

```ts
get enabled(): boolean
set enabled(enabled: boolean)
```

Gets the enabled state of the GraphNode.

### forward

```ts
get forward(): Readonly<Vec3>
```

Gets the normalized local space negative Z-axis vector of the graph node in world space.

### graphDepth

```ts
get graphDepth(): number
```

Gets the depth of this child within the graph. Note that for performance reasons this is
only recalculated when a node is added to a new parent. In other words, it is not
recalculated when a node is simply removed from the graph.

### parent

```ts
get parent(): GraphNode | null
```

Gets the parent of this graph node.

### path

```ts
get path(): string
```

Gets the path of this graph node relative to the root of the hierarchy.

### right

```ts
get right(): Readonly<Vec3>
```

Gets the normalized local space X-axis vector of the graph node in world space.

### root

```ts
get root(): GraphNode
```

Gets the oldest ancestor graph node from this graph node.

### up

```ts
get up(): Readonly<Vec3>
```

Gets the normalized local space Y-axis vector of the graph node in world space.

## Methods

### _notifyHierarchyStateChanged

```ts
protected _notifyHierarchyStateChanged(node: GraphNode, enabled: boolean): void
```

**Parameters**

- `node` ([`GraphNode`](https://api.playcanvas.com/engine/classes/GraphNode.md)): Graph node to update.
- `enabled` (`boolean`): True if enabled in the hierarchy, false if disabled.

### _onHierarchyStateChanged

```ts
protected _onHierarchyStateChanged(enabled: boolean): void
```

Called when the enabled flag of the entity or one of its parents changes.

**Parameters**

- `enabled` (`boolean`): True if enabled in the hierarchy, false if disabled.

### addChild

```ts
addChild(node: GraphNode): void
```

Add a new child to the child list and update the parent value of the child node.
If the node already had a parent, it is removed from its child list.

The child keeps its existing local transform, which is now interpreted relative to the new
parent, so a node placed in world space before being added will appear to move. Set the
transform after adding, or re-apply the world placement with [GraphNode#setPosition](https://api.playcanvas.com/engine/classes/GraphNode.md#setposition).

**Parameters**

- `node` ([`GraphNode`](https://api.playcanvas.com/engine/classes/GraphNode.md)): The new child to add.

**Example**

```ts
const e = new Entity(app);
this.entity.addChild(e);
```

### clone

```ts
clone(): GraphNode
```

Clone a graph node.

**Returns** [`GraphNode`](https://api.playcanvas.com/engine/classes/GraphNode.md): A clone of the specified graph node.

### destroy

```ts
destroy(): void
```

Destroy the graph node and all of its descendants. First, the graph node is removed from the
hierarchy. This is then repeated recursively for all descendants of the graph node.

The last thing the graph node does is fire the `destroy` event.

**Example**

```ts
const firstChild = graphNode.children[0];
firstChild.destroy(); // destroy child and all of its descendants
```

### find

```ts
find(attr: string | FindNodeCallback, value?: any): GraphNode[]
```

Search the graph node and all of its descendants for the nodes that satisfy some search
criteria.

**Parameters**

- `attr` (`string |` [`FindNodeCallback`](https://api.playcanvas.com/engine/types/FindNodeCallback.md)): This can either be a function or a string. If it's a
  function, it is executed for each descendant node to test if node satisfies the search
  logic. Returning true from the function will include the node into the results. If it's a
  string then it represents the name of a field or a method of the node. If this is the name
  of a field then the value passed as the second argument will be checked for equality. If
  this is the name of a function then the return value of the function will be checked for
  equality against the value passed as the second argument to this function.
- `value` (`any`, optional): If the first argument (attr) is a property name then this value
  will be checked against the value of the property.

**Returns** [`GraphNode`](https://api.playcanvas.com/engine/classes/GraphNode.md)`[]`: The array of graph nodes that match the search criteria.

**Example**

```ts
// Finds all nodes that have a model component and have 'door' in their lower-cased name
const doors = house.find((node) => {
    return node.model && node.name.toLowerCase().indexOf('door') !== -1;
});
```

**Example**

```ts
// Finds all nodes that have the name property set to 'Test'
const entities = parent.find('name', 'Test');
```

### findByName

```ts
findByName(name: string): GraphNode | null
```

Get the first node found in the graph with the name. The search is depth first.

**Parameters**

- `name` (`string`): The name of the node.

**Returns** [`GraphNode`](https://api.playcanvas.com/engine/classes/GraphNode.md) `| null`: The first node to be found matching the supplied name. Returns
null if no node is found.

### findByPath

```ts
findByPath(path: string | string[]): GraphNode | null
```

Get the first node found in the graph by its full path in the graph. The full path has this
form 'parent/child/sub-child'. The search is depth first.

**Parameters**

- `path` (`string | string[]`): The full path of the GraphNode as either a string or array
  of GraphNode names.

**Returns** [`GraphNode`](https://api.playcanvas.com/engine/classes/GraphNode.md) `| null`: The first node to be found matching the supplied path. Returns
null if no node is found.

**Example**

```ts
// String form
const grandchild = this.entity.findByPath('child/grandchild');
```

**Example**

```ts
// Array form
const grandchild = this.entity.findByPath(['child', 'grandchild']);
```

### findByTag

```ts
findByTag(...query: any[]): GraphNode[]
```

Return all graph nodes that satisfy the search query. Query can be simply a string, or comma
separated strings, to have inclusive results of graph nodes that match at least one query. A
query that consists of an array of tags can be used to match graph nodes that have each tag
of the array.

**Parameters**

- `query` (`any[]`): Name of a tag or array of tags.

**Returns** [`GraphNode`](https://api.playcanvas.com/engine/classes/GraphNode.md)`[]`: A list of all graph nodes that match the query.

**Example**

```ts
// Return all graph nodes tagged with `animal`
const animals = node.findByTag("animal");
```

**Example**

```ts
// Return all graph nodes tagged with `bird` OR `mammal`
const birdsAndMammals = node.findByTag("bird", "mammal");
```

**Example**

```ts
// Return all graph nodes tagged with `carnivore` AND `mammal`
const meatEatingMammals = node.findByTag(["carnivore", "mammal"]);
```

**Example**

```ts
// Return all graph nodes tagged with (`carnivore` AND `mammal`) OR (`carnivore` AND `reptile`)
const meatEatingMammalsAndReptiles = node.findByTag(["carnivore", "mammal"], ["carnivore", "reptile"]);
```

### findOne

```ts
findOne(attr: string | FindNodeCallback, value?: any): GraphNode | null
```

Search the graph node and all of its descendants for the first node that satisfies some
search criteria.

**Parameters**

- `attr` (`string |` [`FindNodeCallback`](https://api.playcanvas.com/engine/types/FindNodeCallback.md)): This can either be a function or a string. If it's a
  function, it is executed for each descendant node to test if node satisfies the search
  logic. Returning true from the function will result in that node being returned from
  findOne. If it's a string then it represents the name of a field or a method of the node. If
  this is the name of a field then the value passed as the second argument will be checked for
  equality. If this is the name of a function then the return value of the function will be
  checked for equality against the value passed as the second argument to this function.
- `value` (`any`, optional): If the first argument (attr) is a property name then this value
  will be checked against the value of the property.

**Returns** [`GraphNode`](https://api.playcanvas.com/engine/classes/GraphNode.md) `| null`: A graph node that matches the search criteria. Returns null if no
node is found.

**Example**

```ts
// Find the first node that is called 'head' and has a model component
const head = player.findOne((node) => {
    return node.model && node.name === 'head';
});
```

**Example**

```ts
// Finds the first node that has the name property set to 'Test'
const node = parent.findOne('name', 'Test');
```

### forEach

```ts
forEach(callback: ForEachNodeCallback, thisArg?: any): void
```

Executes a provided function once on this graph node and all of its descendants.

**Parameters**

- `callback` ([`ForEachNodeCallback`](https://api.playcanvas.com/engine/types/ForEachNodeCallback.md)): The function to execute on the graph node and each
  descendant.
- `thisArg` (`any`, optional): Optional value to use as this when executing callback function.

**Example**

```ts
// Log the path and name of each node in descendant tree starting with "parent"
parent.forEach((node) => {
    console.log(node.path + "/" + node.name);
});
```

### getEulerAngles

```ts
getEulerAngles(): Readonly<Vec3>
```

Get the world space rotation for the specified GraphNode in Euler angles. The angles are in
degrees and in XYZ order.

Important: The value returned by this function should be considered read-only. In order to
set the world space rotation of the graph node, use [setEulerAngles](https://api.playcanvas.com/engine/classes/GraphNode.md#seteulerangles).

**Returns** `Readonly<`[`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)`>`: The world space rotation of the graph node in Euler angle form.

**Example**

```ts
const angles = this.entity.getEulerAngles();
angles.y = 180; // rotate the entity around Y by 180 degrees
this.entity.setEulerAngles(angles);
```

### getLocalEulerAngles

```ts
getLocalEulerAngles(): Readonly<Vec3>
```

Get the local space rotation for the specified GraphNode in Euler angles. The angles are in
degrees and in XYZ order.

Important: The value returned by this function should be considered read-only. In order to
set the local space rotation of the graph node, use [setLocalEulerAngles](https://api.playcanvas.com/engine/classes/GraphNode.md#setlocaleulerangles).

**Returns** `Readonly<`[`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)`>`: The local space rotation of the graph node as Euler angles in XYZ order.

**Example**

```ts
const angles = this.entity.getLocalEulerAngles();
angles.y = 180;
this.entity.setLocalEulerAngles(angles);
```

### getLocalPosition

```ts
getLocalPosition(): Readonly<Vec3>
```

Get the position in local space for the specified GraphNode. The position is returned as a
[Vec3](https://api.playcanvas.com/engine/classes/Vec3.md). The returned vector should be considered read-only. To update the local
position, use [setLocalPosition](https://api.playcanvas.com/engine/classes/GraphNode.md#setlocalposition).

**Returns** `Readonly<`[`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)`>`: The local space position of the graph node.

**Example**

```ts
const position = this.entity.getLocalPosition().clone();
position.x += 1; // move the entity 1 unit along x.
this.entity.setLocalPosition(position);
```

### getLocalRotation

```ts
getLocalRotation(): Readonly<Quat>
```

Get the rotation in local space for the specified GraphNode. The rotation is returned as a
[Quat](https://api.playcanvas.com/engine/classes/Quat.md). The returned quaternion should be considered read-only. To update the local
rotation, use [setLocalRotation](https://api.playcanvas.com/engine/classes/GraphNode.md#setlocalrotation).

**Returns** `Readonly<`[`Quat`](https://api.playcanvas.com/engine/classes/Quat.md)`>`: The local space rotation of the graph node as a quaternion.

**Example**

```ts
const rotation = this.entity.getLocalRotation();
```

### getLocalScale

```ts
getLocalScale(): Readonly<Vec3>
```

Get the scale in local space for the specified GraphNode. The scale is returned as a
[Vec3](https://api.playcanvas.com/engine/classes/Vec3.md). The returned vector should be considered read-only. To update the local scale,
use [setLocalScale](https://api.playcanvas.com/engine/classes/GraphNode.md#setlocalscale).

**Returns** `Readonly<`[`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)`>`: The local space scale of the graph node.

**Example**

```ts
const scale = this.entity.getLocalScale().clone();
scale.x = 100;
this.entity.setLocalScale(scale);
```

### getLocalTransform

```ts
getLocalTransform(): Readonly<Mat4>
```

Get the local transform matrix for this graph node. This matrix is the transform relative to
the node's parent's world transformation matrix.

**Returns** `Readonly<`[`Mat4`](https://api.playcanvas.com/engine/classes/Mat4.md)`>`: The node's local transformation matrix.

**Example**

```ts
const transform = this.entity.getLocalTransform();
```

### getPosition

```ts
getPosition(): Readonly<Vec3>
```

Get the world space position for the specified GraphNode. The position is returned as a
[Vec3](https://api.playcanvas.com/engine/classes/Vec3.md). The value returned by this function should be considered read-only. In order
to set the world space position of the graph node, use [setPosition](https://api.playcanvas.com/engine/classes/GraphNode.md#setposition).

**Returns** `Readonly<`[`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)`>`: The world space position of the graph node.

**Example**

```ts
const position = this.entity.getPosition().clone();
position.x = 10;
this.entity.setPosition(position);
```

### getRotation

```ts
getRotation(): Readonly<Quat>
```

Get the world space rotation for the specified GraphNode. The rotation is returned as a
[Quat](https://api.playcanvas.com/engine/classes/Quat.md). The value returned by this function should be considered read-only. In order
to set the world space rotation of the graph node, use [setRotation](https://api.playcanvas.com/engine/classes/GraphNode.md#setrotation).

**Returns** `Readonly<`[`Quat`](https://api.playcanvas.com/engine/classes/Quat.md)`>`: The world space rotation of the graph node as a quaternion.

**Example**

```ts
const rotation = this.entity.getRotation();
```

### getWorldTransform

```ts
getWorldTransform(): Readonly<Mat4>
```

Get the world transformation matrix for this graph node.

**Returns** `Readonly<`[`Mat4`](https://api.playcanvas.com/engine/classes/Mat4.md)`>`: The node's world transformation matrix.

**Example**

```ts
const transform = this.entity.getWorldTransform();
```

### insertChild

```ts
insertChild(node: GraphNode, index: number): void
```

Insert a new child to the child list at the specified index and update the parent value of
the child node. If the node already had a parent, it is removed from its child list.

**Parameters**

- `node` ([`GraphNode`](https://api.playcanvas.com/engine/classes/GraphNode.md)): The new child to insert.
- `index` (`number`): The index in the child list of the parent where the new node will be
  inserted.

**Example**

```ts
const e = new Entity(app);
this.entity.insertChild(e, 1);
```

### isAncestorOf

```ts
isAncestorOf(node: GraphNode): boolean
```

Check if node is ancestor for another node.

**Parameters**

- `node` ([`GraphNode`](https://api.playcanvas.com/engine/classes/GraphNode.md)): Potential descendant of node.

**Returns** `boolean`: If node is ancestor for another node.

**Example**

```ts
if (body.isAncestorOf(foot)) {
    // foot is within body's hierarchy
}
```

### isDescendantOf

```ts
isDescendantOf(node: GraphNode): boolean
```

Check if node is descendant of another node.

**Parameters**

- `node` ([`GraphNode`](https://api.playcanvas.com/engine/classes/GraphNode.md)): Potential ancestor of node.

**Returns** `boolean`: If node is descendant of another node.

**Example**

```ts
if (roof.isDescendantOf(house)) {
    // roof is descendant of house entity
}
```

### lookAt

```ts
lookAt(x: number, y: number, z: number, ux?: number, uy?: number, uz?: number): void
```

Reorients the graph node so that the negative z-axis points towards the target.

The up vector must not be parallel to the direction from the node to the target. When it is —
looking straight up or down with the default up vector, or at the node's own position — the
basis is degenerate and the node's rotation is reset to identity, discarding whatever
rotation it already had, with nothing reported. Pass a different up vector in those cases.

**Parameters**

- `x` (`number`): X-component of the world space coordinate to look at.
- `y` (`number`): Y-component of the world space coordinate to look at.
- `z` (`number`): Z-component of the world space coordinate to look at.
- `ux` (`number`, optional): X-component of the up vector for the look at transform. Defaults to 0.
- `uy` (`number`, optional): Y-component of the up vector for the look at transform. Defaults to 1.
- `uz` (`number`, optional): Z-component of the up vector for the look at transform. Defaults to 0.

**Returns** `void`

**Example**

```ts
// Look at the world space origin, using the (default) positive y-axis for up
this.entity.lookAt(0, 0, 0);
```

**Example**

```ts
// Look at world space coordinate [10, 10, 10], using the negative world y-axis for up
this.entity.lookAt(10, 10, 10, 0, -1, 0);
```

```ts
lookAt(target: Vec3, up?: Vec3): void
```

Reorients the graph node so that the negative z-axis points towards the target.

**Parameters**

- `target` ([`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)): The world space coordinate to look at.
- `up` ([`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md), optional): The world space up vector for look at transform. Defaults to [Vec3.UP](https://api.playcanvas.com/engine/classes/Vec3.md#up).

**Returns** `void`

**Example**

```ts
// Look at another entity, using the (default) positive y-axis for up
const target = otherEntity.getPosition();
this.entity.lookAt(target);
```

**Example**

```ts
// Look at another entity, using the negative world y-axis for up
const target = otherEntity.getPosition();
this.entity.lookAt(target, Vec3.DOWN);
```

### remove

```ts
remove(): void
```

Remove graph node from current parent.

### removeChild

```ts
removeChild(child: GraphNode): void
```

Remove the node from the child list and update the parent value of the child.

This detaches the node without disabling it: the removed subtree still reports
`enabled === true`, and its lights, cameras, scripts and sounds keep running. Set
`enabled = false` to deactivate a node, or destroy the entity to remove it outright.

**Parameters**

- `child` ([`GraphNode`](https://api.playcanvas.com/engine/classes/GraphNode.md)): The node to remove.

**Example**

```ts
const child = this.entity.children[0];
this.entity.removeChild(child);
```

### reparent

```ts
reparent(parent: GraphNode, index?: number): void
```

Remove graph node from current parent and add as child to new parent.

**Parameters**

- `parent` ([`GraphNode`](https://api.playcanvas.com/engine/classes/GraphNode.md)): New parent to attach graph node to.
- `index` (`number`, optional): The child index where the child node should be placed.

### rotate

```ts
rotate(x: number, y: number, z: number): void
```

Rotates the graph node in world space by the specified Euler angles. Eulers are specified in
degrees in XYZ order.

**Parameters**

- `x` (`number`): Rotation around world space x-axis in degrees.
- `y` (`number`): Rotation around world space y-axis in degrees.
- `z` (`number`): Rotation around world space z-axis in degrees.

**Returns** `void`

**Example**

```ts
this.entity.rotate(0, 90, 0);
```

```ts
rotate(rotation: Vec3): void
```

Rotates the graph node in world space by the specified Euler angles. Eulers are specified in
degrees in XYZ order.

**Parameters**

- `rotation` ([`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)): Vector holding world space rotation.

**Returns** `void`

**Example**

```ts
const rotation = new Vec3(0, 90, 0);
this.entity.rotate(rotation);
```

### rotateLocal

```ts
rotateLocal(x: number, y: number, z: number): void
```

Rotates the graph node in local space by the specified Euler angles. Eulers are specified in
degrees in XYZ order.

**Parameters**

- `x` (`number`): Rotation around local space x-axis in degrees.
- `y` (`number`): Rotation around local space y-axis in degrees.
- `z` (`number`): Rotation around local space z-axis in degrees.

**Returns** `void`

**Example**

```ts
this.entity.rotateLocal(0, 90, 0);
```

```ts
rotateLocal(rotation: Vec3): void
```

Rotates the graph node in local space by the specified Euler angles. Eulers are specified in
degrees in XYZ order.

**Parameters**

- `rotation` ([`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)): Vector holding local space rotation.

**Returns** `void`

**Example**

```ts
const rotation = new Vec3(0, 90, 0);
this.entity.rotateLocal(rotation);
```

### setEulerAngles

```ts
setEulerAngles(x: number, y: number, z: number): void
```

Sets the world space rotation of the specified graph node using Euler angles. Eulers are
interpreted in XYZ order.

**Parameters**

- `x` (`number`): Rotation around world space x-axis in degrees.
- `y` (`number`): Rotation around world space y-axis in degrees.
- `z` (`number`): Rotation around world space z-axis in degrees.

**Returns** `void`

**Example**

```ts
this.entity.setEulerAngles(0, 90, 0);
```

```ts
setEulerAngles(angles: Vec3): void
```

Sets the world space rotation of the specified graph node using Euler angles. Eulers are
interpreted in XYZ order.

**Parameters**

- `angles` ([`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)): Vector holding rotations around world space axes in degrees.

**Returns** `void`

**Example**

```ts
const angles = new Vec3(0, 90, 0);
this.entity.setEulerAngles(angles);
```

### setLocalEulerAngles

```ts
setLocalEulerAngles(x: number, y: number, z: number): void
```

Sets the local space rotation of the specified graph node using Euler angles. Eulers are
interpreted in XYZ order.

**Parameters**

- `x` (`number`): Rotation around local space x-axis in degrees.
- `y` (`number`): Rotation around local space y-axis in degrees.
- `z` (`number`): Rotation around local space z-axis in degrees.

**Returns** `void`

**Example**

```ts
// Set rotation of 90 degrees around y-axis via 3 numbers
this.entity.setLocalEulerAngles(0, 90, 0);
```

```ts
setLocalEulerAngles(angles: Vec3): void
```

Sets the local space rotation of the specified graph node using Euler angles. Eulers are
interpreted in XYZ order.

**Parameters**

- `angles` ([`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)): Vector holding rotations around local space axes in degrees.

**Returns** `void`

**Example**

```ts
// Set rotation of 90 degrees around y-axis via a vector
const angles = new Vec3(0, 90, 0);
this.entity.setLocalEulerAngles(angles);
```

### setLocalPosition

```ts
setLocalPosition(x: number, y: number, z: number): void
```

Sets the local space position of the specified graph node.

**Parameters**

- `x` (`number`): X-coordinate of local space position.
- `y` (`number`): Y-coordinate of local space position.
- `z` (`number`): Z-coordinate of local space position.

**Returns** `void`

**Example**

```ts
this.entity.setLocalPosition(0, 10, 0);
```

```ts
setLocalPosition(position: Vec3): void
```

Sets the local space position of the specified graph node.

**Parameters**

- `position` ([`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)): Vector holding local space position.

**Returns** `void`

**Example**

```ts
const pos = new Vec3(0, 10, 0);
this.entity.setLocalPosition(pos);
```

### setLocalRotation

```ts
setLocalRotation(x: number, y: number, z: number, w: number): void
```

Sets the local space rotation of the specified graph node.

**Parameters**

- `x` (`number`): X-component of local space quaternion rotation.
- `y` (`number`): Y-component of local space quaternion rotation.
- `z` (`number`): Z-component of local space quaternion rotation.
- `w` (`number`): W-component of local space quaternion rotation.

**Returns** `void`

**Example**

```ts
this.entity.setLocalRotation(0, 0, 0, 1);
```

```ts
setLocalRotation(rotation: Quat): void
```

Sets the local space rotation of the specified graph node.

**Parameters**

- `rotation` ([`Quat`](https://api.playcanvas.com/engine/classes/Quat.md)): Quaternion holding local space rotation.

**Returns** `void`

**Example**

```ts
const q = new Quat();
this.entity.setLocalRotation(q);
```

### setLocalScale

```ts
setLocalScale(x: number, y: number, z: number): void
```

Sets the local space scale factor of the specified graph node.

**Parameters**

- `x` (`number`): X-coordinate of local space scale.
- `y` (`number`): Y-coordinate of local space scale.
- `z` (`number`): Z-coordinate of local space scale.

**Returns** `void`

**Example**

```ts
this.entity.setLocalScale(10, 10, 10);
```

```ts
setLocalScale(scale: Vec3): void
```

Sets the local space scale factor of the specified graph node.

**Parameters**

- `scale` ([`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)): Vector holding local space scale.

**Returns** `void`

**Example**

```ts
const scale = new Vec3(10, 10, 10);
this.entity.setLocalScale(scale);
```

### setPosition

```ts
setPosition(x: number, y: number, z: number): void
```

Sets the world space position of the specified graph node.

**Parameters**

- `x` (`number`): X-coordinate of world space position.
- `y` (`number`): Y-coordinate of world space position.
- `z` (`number`): Z-coordinate of world space position.

**Returns** `void`

**Example**

```ts
this.entity.setPosition(0, 10, 0);
```

```ts
setPosition(position: Vec3): void
```

Sets the world space position of the specified graph node.

**Parameters**

- `position` ([`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)): Vector holding world space position.

**Returns** `void`

**Example**

```ts
const position = new Vec3(0, 10, 0);
this.entity.setPosition(position);
```

### setPositionAndRotation

```ts
setPositionAndRotation(position: Vec3, rotation: Quat): void
```

Sets the world space position and rotation of the specified graph node. This is faster than
setting the position and rotation independently.

**Parameters**

- `position` ([`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)): The world space position to set.
- `rotation` ([`Quat`](https://api.playcanvas.com/engine/classes/Quat.md)): The world space rotation to set.

**Example**

```ts
const position = new Vec3(0, 10, 0);
const rotation = new Quat().setFromEulerAngles(0, 90, 0);
this.entity.setPositionAndRotation(position, rotation);
```

### setRotation

```ts
setRotation(x: number, y: number, z: number, w: number): void
```

Sets the world space rotation of the specified graph node.

**Parameters**

- `x` (`number`): X-component of world space quaternion rotation.
- `y` (`number`): Y-component of world space quaternion rotation.
- `z` (`number`): Z-component of world space quaternion rotation.
- `w` (`number`): W-component of world space quaternion rotation.

**Returns** `void`

**Example**

```ts
this.entity.setRotation(0, 0, 0, 1);
```

```ts
setRotation(rotation: Quat): void
```

Sets the world space rotation of the specified graph node.

**Parameters**

- `rotation` ([`Quat`](https://api.playcanvas.com/engine/classes/Quat.md)): Quaternion holding world space rotation.

**Returns** `void`

**Example**

```ts
const rotation = new Quat();
this.entity.setRotation(rotation);
```

### translate

```ts
translate(x: number, y: number, z: number): void
```

Translates the graph node in world space by the specified translation vector.

**Parameters**

- `x` (`number`): X-coordinate of world space translation.
- `y` (`number`): Y-coordinate of world space translation.
- `z` (`number`): Z-coordinate of world space translation.

**Returns** `void`

**Example**

```ts
this.entity.translate(10, 0, 0);
```

```ts
translate(translation: Vec3): void
```

Translates the graph node in world space by the specified translation vector.

**Parameters**

- `translation` ([`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)): Vector holding world space translation.

**Returns** `void`

**Example**

```ts
const translation = new Vec3(10, 0, 0);
this.entity.translate(translation);
```

### translateLocal

```ts
translateLocal(x: number, y: number, z: number): void
```

Translates the graph node in local space by the specified translation vector.

**Parameters**

- `x` (`number`): X-coordinate of local space translation.
- `y` (`number`): Y-coordinate of local space translation.
- `z` (`number`): Z-coordinate of local space translation.

**Returns** `void`

**Example**

```ts
this.entity.translateLocal(10, 0, 0);
```

```ts
translateLocal(translation: Vec3): void
```

Translates the graph node in local space by the specified translation vector.

**Parameters**

- `translation` ([`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md)): Vector holding local space translation.

**Returns** `void`

**Example**

```ts
const t = new Vec3(10, 0, 0);
this.entity.translateLocal(t);
```

## Inherited from [EventHandler](https://api.playcanvas.com/engine/classes/EventHandler.md)

- `fire(name: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any, arg6?: any, arg7?: any, arg8?: any): EventHandler`
- `hasEvent(name: string): boolean`
- `off(name?: string, callback?: HandleEventCallback, scope?: any): EventHandler`
- `on(name: string, callback: HandleEventCallback, scope?: any): EventHandle`
- `once(name: string, callback: HandleEventCallback, scope?: any): EventHandle`
