UNPKG

@aidinabedi/playcanvas

Version:

PlayCanvas WebGL game engine

813 lines (748 loc) 75.5 kB
<!doctype html> <html lang="en"> <head> <title>pc.GraphNode | PlayCanvas API Reference</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="icon" type="image/png" href="images/playcanvas-favicon.png"> <link href="styles/styles.css" rel="stylesheet"> <link href="styles/playcanvas-theme.css" rel="stylesheet"> <script src="scripts/interface.js"></script> <script src="scripts/highlight.min.js"></script> <script>hljs.initHighlightingOnLoad();</script> </head> <body> <header> <nav class="header-width"> <a href="/" class="header-title"><img src="images/playcanvas-manual.png"></a> <ul class="header-menu"> <li class="user-manual"><a href="https://developer.playcanvas.com/en/user-manual/">User Manual</a></li> <li class="tutorials"><a href="https://developer.playcanvas.com/en/tutorials">Tutorials</a></li> <li class="forum"><a href="https://forum.playcanvas.com/" target="_blank">Forum</a></li> <li class="api active"><a href="/api/">API Reference</a></li> </ul> </nav> <div class="header-content header-page header-width"> <h1><span class="font-icon">&#58195;</span>API Reference</h1> <input id="search" class="search" type="text" placeholder="Search"></input> </div> </header> <div class="container content-width"> <nav class="sidebar"> <div class="sidebarFilter"> <input id="filter-input" type="text" placeholder="Filter"> </div> <ul> <li id="nav-pc"><a href="pc.html">pc</a></li> <li id="nav-pc.callbacks"><a href="pc.callbacks.html">pc.callbacks</a></li> <li id="nav-pc.guid"><a href="pc.guid.html">pc.guid</a></li> <li id="nav-pc.math"><a href="pc.math.html">pc.math</a></li> <li id="nav-pc.path"><a href="pc.path.html">pc.path</a></li> <li id="nav-pc.platform"><a href="pc.platform.html">pc.platform</a></li> <li id="nav-pc.script"><a href="pc.script.html">pc.script</a></li> <li id="nav-pc.string"><a href="pc.string.html">pc.string</a></li> <li id="nav-pc.Animation"><a href="pc.Animation.html">Animation</a></li> <li id="nav-pc.AnimationComponent"><a href="pc.AnimationComponent.html">AnimationComponent</a></li> <li id="nav-pc.AnimationComponentSystem"><a href="pc.AnimationComponentSystem.html">AnimationComponentSystem</a></li> <li id="nav-pc.AnimationHandler"><a href="pc.AnimationHandler.html">AnimationHandler</a></li> <li id="nav-pc.AnimCache"><a href="pc.AnimCache.html">AnimCache</a></li> <li id="nav-pc.AnimClip"><a href="pc.AnimClip.html">AnimClip</a></li> <li id="nav-pc.AnimController"><a href="pc.AnimController.html">AnimController</a></li> <li id="nav-pc.AnimCurve"><a href="pc.AnimCurve.html">AnimCurve</a></li> <li id="nav-pc.AnimData"><a href="pc.AnimData.html">AnimData</a></li> <li id="nav-pc.AnimSnapshot"><a href="pc.AnimSnapshot.html">AnimSnapshot</a></li> <li id="nav-pc.AnimTarget"><a href="pc.AnimTarget.html">AnimTarget</a></li> <li id="nav-pc.AnimTrack"><a href="pc.AnimTrack.html">AnimTrack</a></li> <li id="nav-pc.Application"><a href="pc.Application.html">Application</a></li> <li id="nav-pc.Asset"><a href="pc.Asset.html">Asset</a></li> <li id="nav-pc.AssetReference"><a href="pc.AssetReference.html">AssetReference</a></li> <li id="nav-pc.AssetRegistry"><a href="pc.AssetRegistry.html">AssetRegistry</a></li> <li id="nav-pc.AudioHandler"><a href="pc.AudioHandler.html">AudioHandler</a></li> <li id="nav-pc.AudioListenerComponent"><a href="pc.AudioListenerComponent.html">AudioListenerComponent</a></li> <li id="nav-pc.AudioListenerComponentSystem"><a href="pc.AudioListenerComponentSystem.html">AudioListenerComponentSystem</a></li> <li id="nav-pc.BasicMaterial"><a href="pc.BasicMaterial.html">BasicMaterial</a></li> <li id="nav-pc.Batch"><a href="pc.Batch.html">Batch</a></li> <li id="nav-pc.BatchGroup"><a href="pc.BatchGroup.html">BatchGroup</a></li> <li id="nav-pc.BatchManager"><a href="pc.BatchManager.html">BatchManager</a></li> <li id="nav-pc.BoundingBox"><a href="pc.BoundingBox.html">BoundingBox</a></li> <li id="nav-pc.BoundingSphere"><a href="pc.BoundingSphere.html">BoundingSphere</a></li> <li id="nav-pc.ButtonComponent"><a href="pc.ButtonComponent.html">ButtonComponent</a></li> <li id="nav-pc.ButtonComponentSystem"><a href="pc.ButtonComponentSystem.html">ButtonComponentSystem</a></li> <li id="nav-pc.CameraComponent"><a href="pc.CameraComponent.html">CameraComponent</a></li> <li id="nav-pc.CameraComponentSystem"><a href="pc.CameraComponentSystem.html">CameraComponentSystem</a></li> <li id="nav-pc.CollisionComponent"><a href="pc.CollisionComponent.html">CollisionComponent</a></li> <li id="nav-pc.CollisionComponentSystem"><a href="pc.CollisionComponentSystem.html">CollisionComponentSystem</a></li> <li id="nav-pc.Color"><a href="pc.Color.html">Color</a></li> <li id="nav-pc.Component"><a href="pc.Component.html">Component</a></li> <li id="nav-pc.ComponentSystem"><a href="pc.ComponentSystem.html">ComponentSystem</a></li> <li id="nav-pc.ComponentSystemRegistry"><a href="pc.ComponentSystemRegistry.html">ComponentSystemRegistry</a></li> <li id="nav-pc.ContactPoint"><a href="pc.ContactPoint.html">ContactPoint</a></li> <li id="nav-pc.ContactResult"><a href="pc.ContactResult.html">ContactResult</a></li> <li id="nav-pc.ContainerHandler"><a href="pc.ContainerHandler.html">ContainerHandler</a></li> <li id="nav-pc.ContainerResource"><a href="pc.ContainerResource.html">ContainerResource</a></li> <li id="nav-pc.Controller"><a href="pc.Controller.html">Controller</a></li> <li id="nav-pc.CubemapHandler"><a href="pc.CubemapHandler.html">CubemapHandler</a></li> <li id="nav-pc.Curve"><a href="pc.Curve.html">Curve</a></li> <li id="nav-pc.CurveSet"><a href="pc.CurveSet.html">CurveSet</a></li> <li id="nav-pc.ElementComponent"><a href="pc.ElementComponent.html">ElementComponent</a></li> <li id="nav-pc.ElementComponentSystem"><a href="pc.ElementComponentSystem.html">ElementComponentSystem</a></li> <li id="nav-pc.ElementDragHelper"><a href="pc.ElementDragHelper.html">ElementDragHelper</a></li> <li id="nav-pc.ElementInput"><a href="pc.ElementInput.html">ElementInput</a></li> <li id="nav-pc.ElementInputEvent"><a href="pc.ElementInputEvent.html">ElementInputEvent</a></li> <li id="nav-pc.ElementMouseEvent"><a href="pc.ElementMouseEvent.html">ElementMouseEvent</a></li> <li id="nav-pc.ElementTouchEvent"><a href="pc.ElementTouchEvent.html">ElementTouchEvent</a></li> <li id="nav-pc.Entity"><a href="pc.Entity.html">Entity</a></li> <li id="nav-pc.EventHandler"><a href="pc.EventHandler.html">EventHandler</a></li> <li id="nav-pc.Font"><a href="pc.Font.html">Font</a></li> <li id="nav-pc.FontHandler"><a href="pc.FontHandler.html">FontHandler</a></li> <li id="nav-pc.ForwardRenderer"><a href="pc.ForwardRenderer.html">ForwardRenderer</a></li> <li id="nav-pc.Frustum"><a href="pc.Frustum.html">Frustum</a></li> <li id="nav-pc.GamePads"><a href="pc.GamePads.html">GamePads</a></li> <li id="nav-pc.GraphicsDevice"><a href="pc.GraphicsDevice.html">GraphicsDevice</a></li> <li id="nav-pc.GraphNode"><a href="pc.GraphNode.html">GraphNode</a></li> <li id="nav-pc.Http"><a href="pc.Http.html">Http</a></li> <li id="nav-pc.I18n"><a href="pc.I18n.html">I18n</a></li> <li id="nav-pc.IndexBuffer"><a href="pc.IndexBuffer.html">IndexBuffer</a></li> <li id="nav-pc.Keyboard"><a href="pc.Keyboard.html">Keyboard</a></li> <li id="nav-pc.KeyboardEvent"><a href="pc.KeyboardEvent.html">KeyboardEvent</a></li> <li id="nav-pc.Layer"><a href="pc.Layer.html">Layer</a></li> <li id="nav-pc.LayerComposition"><a href="pc.LayerComposition.html">LayerComposition</a></li> <li id="nav-pc.LayoutChildComponent"><a href="pc.LayoutChildComponent.html">LayoutChildComponent</a></li> <li id="nav-pc.LayoutChildComponentSystem"><a href="pc.LayoutChildComponentSystem.html">LayoutChildComponentSystem</a></li> <li id="nav-pc.LayoutGroupComponent"><a href="pc.LayoutGroupComponent.html">LayoutGroupComponent</a></li> <li id="nav-pc.LayoutGroupComponentSystem"><a href="pc.LayoutGroupComponentSystem.html">LayoutGroupComponentSystem</a></li> <li id="nav-pc.LightComponent"><a href="pc.LightComponent.html">LightComponent</a></li> <li id="nav-pc.LightComponentSystem"><a href="pc.LightComponentSystem.html">LightComponentSystem</a></li> <li id="nav-pc.Lightmapper"><a href="pc.Lightmapper.html">Lightmapper</a></li> <li id="nav-pc.Mat3"><a href="pc.Mat3.html">Mat3</a></li> <li id="nav-pc.Mat4"><a href="pc.Mat4.html">Mat4</a></li> <li id="nav-pc.Material"><a href="pc.Material.html">Material</a></li> <li id="nav-pc.MaterialHandler"><a href="pc.MaterialHandler.html">MaterialHandler</a></li> <li id="nav-pc.Mesh"><a href="pc.Mesh.html">Mesh</a></li> <li id="nav-pc.MeshInstance"><a href="pc.MeshInstance.html">MeshInstance</a></li> <li id="nav-pc.Model"><a href="pc.Model.html">Model</a></li> <li id="nav-pc.ModelComponent"><a href="pc.ModelComponent.html">ModelComponent</a></li> <li id="nav-pc.ModelComponentSystem"><a href="pc.ModelComponentSystem.html">ModelComponentSystem</a></li> <li id="nav-pc.ModelHandler"><a href="pc.ModelHandler.html">ModelHandler</a></li> <li id="nav-pc.Morph"><a href="pc.Morph.html">Morph</a></li> <li id="nav-pc.MorphInstance"><a href="pc.MorphInstance.html">MorphInstance</a></li> <li id="nav-pc.MorphTarget"><a href="pc.MorphTarget.html">MorphTarget</a></li> <li id="nav-pc.Mouse"><a href="pc.Mouse.html">Mouse</a></li> <li id="nav-pc.MouseEvent"><a href="pc.MouseEvent.html">MouseEvent</a></li> <li id="nav-pc.Node"><a href="pc.Node.html">Node</a></li> <li id="nav-pc.OrientedBox"><a href="pc.OrientedBox.html">OrientedBox</a></li> <li id="nav-pc.ParticleSystemComponent"><a href="pc.ParticleSystemComponent.html">ParticleSystemComponent</a></li> <li id="nav-pc.ParticleSystemComponentSystem"><a href="pc.ParticleSystemComponentSystem.html">ParticleSystemComponentSystem</a></li> <li id="nav-pc.Picker"><a href="pc.Picker.html">Picker</a></li> <li id="nav-pc.PostEffect"><a href="pc.PostEffect.html">PostEffect</a></li> <li id="nav-pc.PostEffectQueue"><a href="pc.PostEffectQueue.html">PostEffectQueue</a></li> <li id="nav-pc.Quat"><a href="pc.Quat.html">Quat</a></li> <li id="nav-pc.Ray"><a href="pc.Ray.html">Ray</a></li> <li id="nav-pc.RaycastResult"><a href="pc.RaycastResult.html">RaycastResult</a></li> <li id="nav-pc.RenderTarget"><a href="pc.RenderTarget.html">RenderTarget</a></li> <li id="nav-pc.ResourceHandler"><a href="pc.ResourceHandler.html">ResourceHandler</a></li> <li id="nav-pc.ResourceLoader"><a href="pc.ResourceLoader.html">ResourceLoader</a></li> <li id="nav-pc.RigidBodyComponent"><a href="pc.RigidBodyComponent.html">RigidBodyComponent</a></li> <li id="nav-pc.RigidBodyComponentSystem"><a href="pc.RigidBodyComponentSystem.html">RigidBodyComponentSystem</a></li> <li id="nav-pc.Scene"><a href="pc.Scene.html">Scene</a></li> <li id="nav-pc.SceneHandler"><a href="pc.SceneHandler.html">SceneHandler</a></li> <li id="nav-pc.ScopeId"><a href="pc.ScopeId.html">ScopeId</a></li> <li id="nav-pc.ScopeSpace"><a href="pc.ScopeSpace.html">ScopeSpace</a></li> <li id="nav-pc.ScreenComponent"><a href="pc.ScreenComponent.html">ScreenComponent</a></li> <li id="nav-pc.ScreenComponentSystem"><a href="pc.ScreenComponentSystem.html">ScreenComponentSystem</a></li> <li id="nav-pc.ScriptAttributes"><a href="pc.ScriptAttributes.html">ScriptAttributes</a></li> <li id="nav-pc.ScriptComponent"><a href="pc.ScriptComponent.html">ScriptComponent</a></li> <li id="nav-pc.ScriptComponentSystem"><a href="pc.ScriptComponentSystem.html">ScriptComponentSystem</a></li> <li id="nav-pc.ScriptHandler"><a href="pc.ScriptHandler.html">ScriptHandler</a></li> <li id="nav-pc.ScriptRegistry"><a href="pc.ScriptRegistry.html">ScriptRegistry</a></li> <li id="nav-pc.ScriptType"><a href="pc.ScriptType.html">ScriptType</a></li> <li id="nav-pc.ScrollbarComponent"><a href="pc.ScrollbarComponent.html">ScrollbarComponent</a></li> <li id="nav-pc.ScrollbarComponentSystem"><a href="pc.ScrollbarComponentSystem.html">ScrollbarComponentSystem</a></li> <li id="nav-pc.ScrollViewComponent"><a href="pc.ScrollViewComponent.html">ScrollViewComponent</a></li> <li id="nav-pc.ScrollViewComponentSystem"><a href="pc.ScrollViewComponentSystem.html">ScrollViewComponentSystem</a></li> <li id="nav-pc.Shader"><a href="pc.Shader.html">Shader</a></li> <li id="nav-pc.SingleContactResult"><a href="pc.SingleContactResult.html">SingleContactResult</a></li> <li id="nav-pc.Skeleton"><a href="pc.Skeleton.html">Skeleton</a></li> <li id="nav-pc.Skin"><a href="pc.Skin.html">Skin</a></li> <li id="nav-pc.SkinInstance"><a href="pc.SkinInstance.html">SkinInstance</a></li> <li id="nav-pc.Sound"><a href="pc.Sound.html">Sound</a></li> <li id="nav-pc.SoundComponent"><a href="pc.SoundComponent.html">SoundComponent</a></li> <li id="nav-pc.SoundComponentSystem"><a href="pc.SoundComponentSystem.html">SoundComponentSystem</a></li> <li id="nav-pc.SoundInstance"><a href="pc.SoundInstance.html">SoundInstance</a></li> <li id="nav-pc.SoundInstance3d"><a href="pc.SoundInstance3d.html">SoundInstance3d</a></li> <li id="nav-pc.SoundManager"><a href="pc.SoundManager.html">SoundManager</a></li> <li id="nav-pc.SoundSlot"><a href="pc.SoundSlot.html">SoundSlot</a></li> <li id="nav-pc.Sprite"><a href="pc.Sprite.html">Sprite</a></li> <li id="nav-pc.SpriteAnimationClip"><a href="pc.SpriteAnimationClip.html">SpriteAnimationClip</a></li> <li id="nav-pc.SpriteComponent"><a href="pc.SpriteComponent.html">SpriteComponent</a></li> <li id="nav-pc.SpriteComponentSystem"><a href="pc.SpriteComponentSystem.html">SpriteComponentSystem</a></li> <li id="nav-pc.SpriteHandler"><a href="pc.SpriteHandler.html">SpriteHandler</a></li> <li id="nav-pc.StandardMaterial"><a href="pc.StandardMaterial.html">StandardMaterial</a></li> <li id="nav-pc.StencilParameters"><a href="pc.StencilParameters.html">StencilParameters</a></li> <li id="nav-pc.Tags"><a href="pc.Tags.html">Tags</a></li> <li id="nav-pc.Texture"><a href="pc.Texture.html">Texture</a></li> <li id="nav-pc.TextureAtlas"><a href="pc.TextureAtlas.html">TextureAtlas</a></li> <li id="nav-pc.TextureAtlasHandler"><a href="pc.TextureAtlasHandler.html">TextureAtlasHandler</a></li> <li id="nav-pc.TextureHandler"><a href="pc.TextureHandler.html">TextureHandler</a></li> <li id="nav-pc.Touch"><a href="pc.Touch.html">Touch</a></li> <li id="nav-pc.TouchDevice"><a href="pc.TouchDevice.html">TouchDevice</a></li> <li id="nav-pc.TouchEvent"><a href="pc.TouchEvent.html">TouchEvent</a></li> <li id="nav-pc.TransformFeedback"><a href="pc.TransformFeedback.html">TransformFeedback</a></li> <li id="nav-pc.Vec2"><a href="pc.Vec2.html">Vec2</a></li> <li id="nav-pc.Vec3"><a href="pc.Vec3.html">Vec3</a></li> <li id="nav-pc.Vec4"><a href="pc.Vec4.html">Vec4</a></li> <li id="nav-pc.VertexAttributeDescription"><a href="pc.VertexAttributeDescription.html">VertexAttributeDescription</a></li> <li id="nav-pc.VertexAttributeElement"><a href="pc.VertexAttributeElement.html">VertexAttributeElement</a></li> <li id="nav-pc.VertexBuffer"><a href="pc.VertexBuffer.html">VertexBuffer</a></li> <li id="nav-pc.VertexFormat"><a href="pc.VertexFormat.html">VertexFormat</a></li> <li id="nav-pc.VertexIterator"><a href="pc.VertexIterator.html">VertexIterator</a></li> <li id="nav-pc.VertexIteratorAccessor"><a href="pc.VertexIteratorAccessor.html">VertexIteratorAccessor</a></li> <li id="nav-pc.XrInput"><a href="pc.XrInput.html">XrInput</a></li> <li id="nav-pc.XrInputSource"><a href="pc.XrInputSource.html">XrInputSource</a></li> <li id="nav-pc.XrManager"><a href="pc.XrManager.html">XrManager</a></li> </ul> </nav> <div class='sidebarToggle'><span></span>Class List</div> <main class="cls"> <h1>pc.GraphNode</h1> <p class="extends">Extends: <a href="pc.EventHandler.html">pc.EventHandler</a></p> <p><p>A hierarchical scene node.</p></p> <!-- summary --> <h1>Summary</h1> <!--type definitions--> <!--static properties--> <!--static methods--> <!--properties--> <h3>Properties</h3> <table class="properties"> <tr> <td><a href="#children">children</a></td><td><p>A read-only property to get the children of this graph node.<span class='readonly'>[read only]</span></td> </tr> <tr> <td><a href="#enabled">enabled</a></td><td><p>Enable or disable a GraphNode.</td> </tr> <tr> <td><a href="#forward">forward</a></td><td><p>The normalized local space negative Z-axis vector of the graph node in world space.<span class='readonly'>[read only]</span></td> </tr> <tr> <td><a href="#graphDepth">graphDepth</a></td><td><p>A read-only property to get the depth of this child within the graph.<span class='readonly'>[read only]</span></td> </tr> <tr> <td><a href="#name">name</a></td><td><p>The non-unique name of a graph node.</td> </tr> <tr> <td><a href="#parent">parent</a></td><td><p>A read-only property to get a parent graph node.<span class='readonly'>[read only]</span></td> </tr> <tr> <td><a href="#path">path</a></td><td><p>A read-only property to get the path of the graph node relative to the root of the hierarchy.<span class='readonly'>[read only]</span></td> </tr> <tr> <td><a href="#right">right</a></td><td><p>The normalized local space X-axis vector of the graph node in world space.<span class='readonly'>[read only]</span></td> </tr> <tr> <td><a href="#root">root</a></td><td><p>A read-only property to get highest graph node from current node.<span class='readonly'>[read only]</span></td> </tr> <tr> <td><a href="#tags">tags</a></td><td><p>Interface for tagging graph nodes.</td> </tr> <tr> <td><a href="#up">up</a></td><td><p>The normalized local space Y-axis vector of the graph node in world space.<span class='readonly'>[read only]</span></td> </tr> </table> <!--methods--> <h3>Methods</h3> <table class="properties"> <tr> <td><a href="#addChild">addChild</a></td><td><p>Add a new child to the child list and update the parent value of the child node.</td> </tr> <tr> <td><a href="#find">find</a></td><td><p>Search the graph node and all of its descendants for the nodes that satisfy some search criteria.</td> </tr> <tr> <td><a href="#findByName">findByName</a></td><td><p>Get the first node found in the graph with the name.</td> </tr> <tr> <td><a href="#findByPath">findByPath</a></td><td><p>Get the first node found in the graph by its full path in the graph.</td> </tr> <tr> <td><a href="#findByTag">findByTag</a></td><td><p>Return all graph nodes that satisfy the search query.</td> </tr> <tr> <td><a href="#findOne">findOne</a></td><td><p>Search the graph node and all of its descendants for the first node that satisfies some search criteria.</td> </tr> <tr> <td><a href="#forEach">forEach</a></td><td><p>Executes a provided function once on this graph node and all of its descendants.</td> </tr> <tr> <td><a href="#getEulerAngles">getEulerAngles</a></td><td><p>Get the world space rotation for the specified GraphNode in Euler angle form.</td> </tr> <tr> <td><a href="#getLocalEulerAngles">getLocalEulerAngles</a></td><td><p>Get the rotation in local space for the specified GraphNode.</td> </tr> <tr> <td><a href="#getLocalPosition">getLocalPosition</a></td><td><p>Get the position in local space for the specified GraphNode.</td> </tr> <tr> <td><a href="#getLocalRotation">getLocalRotation</a></td><td><p>Get the rotation in local space for the specified GraphNode.</td> </tr> <tr> <td><a href="#getLocalScale">getLocalScale</a></td><td><p>Get the scale in local space for the specified GraphNode.</td> </tr> <tr> <td><a href="#getLocalTransform">getLocalTransform</a></td><td><p>Get the local transform matrix for this graph node.</td> </tr> <tr> <td><a href="#getPosition">getPosition</a></td><td><p>Get the world space position for the specified GraphNode.</td> </tr> <tr> <td><a href="#getRotation">getRotation</a></td><td><p>Get the world space rotation for the specified GraphNode in quaternion form.</td> </tr> <tr> <td><a href="#getWorldTransform">getWorldTransform</a></td><td><p>Get the world transformation matrix for this graph node.</td> </tr> <tr> <td><a href="#insertChild">insertChild</a></td><td><p>Insert a new child to the child list at the specified index and update the parent value of the child node.</td> </tr> <tr> <td><a href="#isAncestorOf">isAncestorOf</a></td><td><p>Check if node is ancestor for another node.</td> </tr> <tr> <td><a href="#isDescendantOf">isDescendantOf</a></td><td><p>Check if node is descendant of another node.</td> </tr> <tr> <td><a href="#lookAt">lookAt</a></td><td><p>Reorients the graph node so that the negative z-axis points towards the target.</td> </tr> <tr> <td><a href="#removeChild">removeChild</a></td><td><p>Remove the node from the child list and update the parent value of the child.</td> </tr> <tr> <td><a href="#reparent">reparent</a></td><td><p>Remove graph node from current parent and add as child to new parent.</td> </tr> <tr> <td><a href="#rotate">rotate</a></td><td><p>Rotates the graph node in world-space by the specified Euler angles.</td> </tr> <tr> <td><a href="#rotateLocal">rotateLocal</a></td><td><p>Rotates the graph node in local-space by the specified Euler angles.</td> </tr> <tr> <td><a href="#setEulerAngles">setEulerAngles</a></td><td><p>Sets the world-space rotation of the specified graph node using euler angles.</td> </tr> <tr> <td><a href="#setLocalEulerAngles">setLocalEulerAngles</a></td><td><p>Sets the local-space rotation of the specified graph node using euler angles.</td> </tr> <tr> <td><a href="#setLocalPosition">setLocalPosition</a></td><td><p>Sets the local-space position of the specified graph node.</td> </tr> <tr> <td><a href="#setLocalRotation">setLocalRotation</a></td><td><p>Sets the local-space rotation of the specified graph node.</td> </tr> <tr> <td><a href="#setLocalScale">setLocalScale</a></td><td><p>Sets the local-space scale factor of the specified graph node.</td> </tr> <tr> <td><a href="#setPosition">setPosition</a></td><td><p>Sets the world-space position of the specified graph node.</td> </tr> <tr> <td><a href="#setRotation">setRotation</a></td><td><p>Sets the world-space rotation of the specified graph node.</td> </tr> <tr> <td><a href="#translate">translate</a></td><td><p>Translates the graph node in world-space by the specified translation vector.</td> </tr> <tr> <td><a href="#translateLocal">translateLocal</a></td><td><p>Translates the graph node in local-space by the specified translation vector.</td> </tr> </table> <!--events--> <h2>Inherited</h2> <!--inherited methods--> <!--inherited properties--> <!--inherited static methods--> <h3>Methods</h3> <table class="properties"> <tr> <td><a href="#fire">fire</a></td><td><p>Fire an event, all additional arguments are passed on to the event listener.</td> </tr> <tr> <td><a href="#hasEvent">hasEvent</a></td><td><p>Test if there are any handlers bound to an event name.</td> </tr> <tr> <td><a href="#off">off</a></td><td><p>Detach an event handler from an event.</td> </tr> <tr> <td><a href="#on">on</a></td><td><p>Attach an event handler to an event.</td> </tr> <tr> <td><a href="#once">once</a></td><td><p>Attach an event handler to an event.</td> </tr> </table> <!--inherited events--> <h1>Details</h1> <!--type definitions--> <!--static members--> <!--static methods--> <h2>Constructor</h2> <!-- Constructor --> <div id="GraphNode"> <h3 class="methodname">GraphNode([name]) <a class="font-icon" href="#GraphNode">&#58216;</a></h3> <p></p> <h4>Parameters</h4> <table> <tr> <td>name</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></td><td><p>The non-unique name of the graph node, default is &quot;Untitled&quot;.</p></td> </tr> </table> </div> <!--properties--> <h2>Properties</h2> <div id="children"> <span class="property"><a href="pc.GraphNode.html">pc.GraphNode[]</a></span><span class="property">children <a class="font-icon" href="#children">&#58216;</a></span> <p><p>A read-only property to get the children of this graph node.</p><span class='readonly'>[read only]</span></p> </div> <div id="enabled"> <span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span><span class="property">enabled <a class="font-icon" href="#enabled">&#58216;</a></span> <p><p>Enable or disable a GraphNode. If one of the GraphNode's parents is disabled there will be no other side effects. If all the parents are enabled then the new value will activate / deactivate all the enabled children of the GraphNode.</p></p> </div> <div id="forward"> <span class="property"><a href="pc.Vec3.html">pc.Vec3</a></span><span class="property">forward <a class="font-icon" href="#forward">&#58216;</a></span> <p><p>The normalized local space negative Z-axis vector of the graph node in world space.</p><span class='readonly'>[read only]</span></p> </div> <div id="graphDepth"> <span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">graphDepth <a class="font-icon" href="#graphDepth">&#58216;</a></span> <p><p>A read-only property to get 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, i.e. It is not recalculated when a node is simply removed from the graph.</p><span class='readonly'>[read only]</span></p> </div> <div id="name"> <span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span><span class="property">name <a class="font-icon" href="#name">&#58216;</a></span> <p><p>The non-unique name of a graph node.</p></p> </div> <div id="parent"> <span class="property"><a href="pc.GraphNode.html">pc.GraphNode</a></span><span class="property">parent <a class="font-icon" href="#parent">&#58216;</a></span> <p><p>A read-only property to get a parent graph node.</p><span class='readonly'>[read only]</span></p> </div> <div id="path"> <span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span><span class="property">path <a class="font-icon" href="#path">&#58216;</a></span> <p><p>A read-only property to get the path of the graph node relative to the root of the hierarchy.</p><span class='readonly'>[read only]</span></p> </div> <div id="right"> <span class="property"><a href="pc.Vec3.html">pc.Vec3</a></span><span class="property">right <a class="font-icon" href="#right">&#58216;</a></span> <p><p>The normalized local space X-axis vector of the graph node in world space.</p><span class='readonly'>[read only]</span></p> </div> <div id="root"> <span class="property"><a href="pc.GraphNode.html">pc.GraphNode</a></span><span class="property">root <a class="font-icon" href="#root">&#58216;</a></span> <p><p>A read-only property to get highest graph node from current node.</p><span class='readonly'>[read only]</span></p> </div> <div id="tags"> <span class="property"><a href="pc.Tags.html">pc.Tags</a></span><span class="property">tags <a class="font-icon" href="#tags">&#58216;</a></span> <p><p>Interface for tagging graph nodes. Tag based searches can be performed using the <a href="pc.GraphNode.html#findByTag">pc.GraphNode#findByTag</a> function.</p></p> </div> <div id="up"> <span class="property"><a href="pc.Vec3.html">pc.Vec3</a></span><span class="property">up <a class="font-icon" href="#up">&#58216;</a></span> <p><p>The normalized local space Y-axis vector of the graph node in world space.</p><span class='readonly'>[read only]</span></p> </div> <!--methods--> <h2>Methods</h2> <div id="addChild"> <h3 class="methodname">addChild(node) <a class="font-icon" href="#addChild">&#58216;</a></h3> <p><p>Add a new child to the child list and update the parent value of the child node.</p></p> <pre><code class="javascript">var e = new pc.Entity(app); this.entity.addChild(e);</code></pre> <h4>Parameters</h4> <table> <tr> <td>node</td><td><a href="pc.GraphNode.html">pc.GraphNode</a></td><td><p>The new child to add.</p></td> </tr> </table> </div> <div id="find"> <h3 class="methodname">find(attr, [value]) <a class="font-icon" href="#find">&#58216;</a></h3> <p><p>Search the graph node and all of its descendants for the nodes that satisfy some search criteria.</p></p> <pre><code class="javascript">// Finds all nodes that have a model component and have `door` in their lower-cased name var doors = house.find(function (node) { return node.model && node.name.toLowerCase().indexOf('door') !== -1; });</code></pre> <pre><code class="javascript">// Finds all nodes that have the name property set to 'Test' var entities = parent.find('name', 'Test');</code></pre> <h4>Parameters</h4> <table> <tr> <td>attr</td><td><a href="pc.callbacks.html#FindNode">pc.callbacks.FindNode</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></td><td><p>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 valued passed as the second argument to this function.</p></td> </tr> <tr> <td>value</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></td><td><p>If the first argument (attr) is a property name then this value will be checked against the value of the property.</p></td> </tr> </table> <h4>Returns</h4> <a href="pc.GraphNode.html">pc.GraphNode[]</a> <p>The array of graph nodes that match the search criteria.</p> </div> <div id="findByName"> <h3 class="methodname">findByName(name) <a class="font-icon" href="#findByName">&#58216;</a></h3> <p><p>Get the first node found in the graph with the name. The search is depth first.</p></p> <h4>Parameters</h4> <table> <tr> <td>name</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></td><td><p>The name of the graph.</p></td> </tr> </table> <h4>Returns</h4> <a href="pc.GraphNode.html">pc.GraphNode</a> <p>The first node to be found matching the supplied name.</p> </div> <div id="findByPath"> <h3 class="methodname">findByPath(path) <a class="font-icon" href="#findByPath">&#58216;</a></h3> <p><p>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.</p></p> <pre><code class="javascript">var path = this.entity.findByPath('child/another_child');</code></pre> <h4>Parameters</h4> <table> <tr> <td>path</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></td><td><p>The full path of the pc.GraphNode.</p></td> </tr> </table> <h4>Returns</h4> <a href="pc.GraphNode.html">pc.GraphNode</a> <p>The first node to be found matching the supplied path.</p> </div> <div id="findByTag"> <h3 class="methodname">findByTag(query) <a class="font-icon" href="#findByTag">&#58216;</a></h3> <p><p>Return all graph nodes that satisfy the search query. Query can be simply a string, or comma separated strings, to have inclusive results of assets 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 array.</p></p> <pre><code class="javascript">// Return all graph nodes that tagged by `animal` var animals = node.findByTag("animal");</code></pre> <pre><code class="javascript">// Return all graph nodes that tagged by `bird` OR `mammal` var birdsAndMammals = node.findByTag("bird", "mammal");</code></pre> <pre><code class="javascript">// Return all assets that tagged by `carnivore` AND `mammal` var meatEatingMammals = node.findByTag(["carnivore", "mammal"]);</code></pre> <pre><code class="javascript">// Return all assets that tagged by (`carnivore` AND `mammal`) OR (`carnivore` AND `reptile`) var meatEatingMammalsAndReptiles = node.findByTag(["carnivore", "mammal"], ["carnivore", "reptile"]);</code></pre> <h4>Parameters</h4> <table> <tr> <td>query</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></td><td><p>Name of a tag or array of tags.</p></td> </tr> </table> <h4>Returns</h4> <a href="pc.GraphNode.html">pc.GraphNode[]</a> <p>A list of all graph nodes that match the query.</p> </div> <div id="findOne"> <h3 class="methodname">findOne(attr, [value]) <a class="font-icon" href="#findOne">&#58216;</a></h3> <p><p>Search the graph node and all of its descendants for the first node that satisfies some search criteria.</p></p> <pre><code class="javascript">// Find the first node that is called `head` and has a model component var head = player.findOne(function (node) { return node.model && node.name === 'head'; });</code></pre> <pre><code class="javascript">// Finds the first node that has the name property set to 'Test' var node = parent.findOne('name', 'Test');</code></pre> <h4>Parameters</h4> <table> <tr> <td>attr</td><td><a href="pc.callbacks.html#FindNode">pc.callbacks.FindNode</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></td><td><p>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 valued passed as the second argument to this function.</p></td> </tr> <tr> <td>value</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></td><td><p>If the first argument (attr) is a property name then this value will be checked against the value of the property.</p></td> </tr> </table> <h4>Returns</h4> <a href="pc.GraphNode.html">pc.GraphNode</a> <p>A graph node that match the search criteria.</p> </div> <div id="forEach"> <h3 class="methodname">forEach(callback, [thisArg]) <a class="font-icon" href="#forEach">&#58216;</a></h3> <p><p>Executes a provided function once on this graph node and all of its descendants.</p></p> <pre><code class="javascript">// Log the path and name of each node in descendant tree starting with "parent" parent.forEach(function (node) { console.log(node.path + "/" + node.name); });</code></pre> <h4>Parameters</h4> <table> <tr> <td>callback</td><td><a href="pc.callbacks.html#ForEach">pc.callbacks.ForEach</a></td><td><p>The function to execute on the graph node and each descendant.</p></td> </tr> <tr> <td>thisArg</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></td><td><p>Optional value to use as this when executing callback function.</p></td> </tr> </table> </div> <div id="getEulerAngles"> <h3 class="methodname">getEulerAngles() <a class="font-icon" href="#getEulerAngles">&#58216;</a></h3> <p><p>Get the world space rotation for the specified GraphNode in Euler angle form. The order of the returned Euler angles is XYZ. The value returned by this function should be considered read-only. In order to set the world-space rotation of the graph node, use <a href="pc.GraphNode.html#setEulerAngles">pc.GraphNode#setEulerAngles</a>.</p></p> <pre><code class="javascript">var angles = this.entity.getEulerAngles(); // [0,0,0] angles[1] = 180; // rotate the entity around Y by 180 degrees this.entity.setEulerAngles(angles);</code></pre> <h4>Returns</h4> <a href="pc.Vec3.html">pc.Vec3</a> <p>The world space rotation of the graph node in Euler angle form.</p> </div> <div id="getLocalEulerAngles"> <h3 class="methodname">getLocalEulerAngles() <a class="font-icon" href="#getLocalEulerAngles">&#58216;</a></h3> <p><p>Get the rotation in local space for the specified GraphNode. The rotation is returned as euler angles in a 3-dimensional vector where the order is XYZ. The returned vector should be considered read-only. To update the local rotation, use <a href="pc.GraphNode.html#setLocalEulerAngles">pc.GraphNode#setLocalEulerAngles</a>.</p></p> <pre><code class="javascript">var angles = this.entity.getLocalEulerAngles(); angles[1] = 180; this.entity.setLocalEulerAngles(angles);</code></pre> <h4>Returns</h4> <a href="pc.Vec3.html">pc.Vec3</a> <p>The local space rotation of the graph node as euler angles in XYZ order.</p> </div> <div id="getLocalPosition"> <h3 class="methodname">getLocalPosition() <a class="font-icon" href="#getLocalPosition">&#58216;</a></h3> <p><p>Get the position in local space for the specified GraphNode. The position is returned as a 3-dimensional vector. The returned vector should be considered read-only. To update the local position, use <a href="pc.GraphNode.html#setLocalPosition">pc.GraphNode#setLocalPosition</a>.</p></p> <pre><code class="javascript">var position = this.entity.getLocalPosition(); position[0] += 1; // move the entity 1 unit along x. this.entity.setLocalPosition(position);</code></pre> <h4>Returns</h4> <a href="pc.Vec3.html">pc.Vec3</a> <p>The local space position of the graph node.</p> </div> <div id="getLocalRotation"> <h3 class="methodname">getLocalRotation() <a class="font-icon" href="#getLocalRotation">&#58216;</a></h3> <p><p>Get the rotation in local space for the specified GraphNode. The rotation is returned as a quaternion. The returned quaternion should be considered read-only. To update the local rotation, use <a href="pc.GraphNode.html#setLocalRotation">pc.GraphNode#setLocalRotation</a>.</p></p> <pre><code class="javascript">var rotation = this.entity.getLocalRotation();</code></pre> <h4>Returns</h4> <a href="pc.Quat.html">pc.Quat</a> <p>The local space rotation of the graph node as a quaternion.</p> </div> <div id="getLocalScale"> <h3 class="methodname">getLocalScale() <a class="font-icon" href="#getLocalScale">&#58216;</a></h3> <p><p>Get the scale in local space for the specified GraphNode. The scale is returned as a 3-dimensional vector. The returned vector should be considered read-only. To update the local scale, use <a href="pc.GraphNode.html#setLocalScale">pc.GraphNode#setLocalScale</a>.</p></p> <pre><code class="javascript">var scale = this.entity.getLocalScale(); scale.x = 100; this.entity.setLocalScale(scale);</code></pre> <h4>Returns</h4> <a href="pc.Vec3.html">pc.Vec3</a> <p>The local space scale of the graph node.</p> </div> <div id="getLocalTransform"> <h3 class="methodname">getLocalTransform() <a class="font-icon" href="#getLocalTransform">&#58216;</a></h3> <p><p>Get the local transform matrix for this graph node. This matrix is the transform relative to the node's parent's world transformation matrix.</p></p> <pre><code class="javascript">var transform = this.entity.getLocalTransform();</code></pre> <h4>Returns</h4> <a href="pc.Mat4.html">pc.Mat4</a> <p>The node's local transformation matrix.</p> </div> <div id="getPosition"> <h3 class="methodname">getPosition() <a class="font-icon" href="#getPosition">&#58216;</a></h3> <p><p>Get the world space position for the specified GraphNode. The value returned by this function should be considered read-only. In order to set the world-space position of the graph node, use <a href="pc.GraphNode.html#setPosition">pc.GraphNode#setPosition</a>.</p></p> <pre><code class="javascript">var position = this.entity.getPosition(); position.x = 10; this.entity.setPosition(position);</code></pre> <h4>Returns</h4> <a href="pc.Vec3.html">pc.Vec3</a> <p>The world space position of the graph node.</p> </div> <div id="getRotation"> <h3 class="methodname">getRotation() <a class="font-icon" href="#getRotation">&#58216;</a></h3> <p><p>Get the world space rotation for the specified GraphNode in quaternion form. The value returned by this function should be considered read-only. In order to set the world-space rotation of the graph node, use <a href="pc.GraphNode.html#setRotation">pc.GraphNode#setRotation</a>.</p></p> <pre><code class="javascript">var rotation = this.entity.getRotation();</code></pre> <h4>Returns</h4> <a href="pc.Quat.html">pc.Quat</a> <p>The world space rotation of the graph node as a quaternion.</p> </div> <div id="getWorldTransform"> <h3 class="methodname">getWorldTransform() <a class="font-icon" href="#getWorldTransform">&#58216;</a></h3> <p><p>Get the world transformation matrix for this graph node.</p></p> <pre><code class="javascript">var transform = this.entity.getWorldTransform();</code></pre> <h4>Returns</h4> <a href="pc.Mat4.html">pc.Mat4</a> <p>The node's world transformation matrix.</p> </div> <div id="insertChild"> <h3 class="methodname">insertChild(node, index) <a class="font-icon" href="#insertChild">&#58216;</a></h3> <p><p>Insert a new child to the child list at the specified index and update the parent value of the child node.</p></p> <pre><code class="javascript">var e = new pc.Entity(app); this.entity.insertChild(e, 1);</code></pre> <h4>Parameters</h4> <table> <tr> <td>node</td><td><a href="pc.GraphNode.html">pc.GraphNode</a></td><td><p>The new child to insert.</p></td> </tr> <tr> <td>index</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>The index in the child list of the parent where the new node will be inserted.</p></td> </tr> </table> </div> <div id="isAncestorOf"> <h3 class="methodname">isAncestorOf(node) <a class="font-icon" href="#isAncestorOf">&#58216;</a></h3> <p><p>Check if node is ancestor for another node.</p></p> <pre><code class="javascript">if (body.isAncestorOf(foot)) { // foot is within body's hierarchy }</code></pre> <h4>Parameters</h4> <table> <tr> <td>node</td><td><a href="pc.GraphNode.html">pc.GraphNode</a></td><td><p>Potential descendant of node.</p></td> </tr> </table> <h4>Returns</h4> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a> <p>If node is ancestor for another node.</p> </div> <div id="isDescendantOf"> <h3 class="methodname">isDescendantOf(node) <a class="font-icon" href="#isDescendantOf">&#58216;</a></h3> <p><p>Check if node is descendant of another node.</p></p> <pre><code class="javascript">if (roof.isDescendantOf(house)) { // roof is descendant of house entity }</code></pre> <h4>Parameters</h4> <table> <tr> <td>node</td><td><a href="pc.GraphNode.html">pc.GraphNode</a></td><td><p>Potential ancestor of node.</p></td> </tr> </table> <h4>Returns</h4> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a> <p>If node is descendant of another node.</p> </div> <div id="lookAt"> <h3 class="methodname">lookAt(x, y, z, [ux], [uy], [uz]) <a class="font-icon" href="#lookAt">&#58216;</a></h3> <p><p>Reorients the graph node so that the negative z-axis points towards the target. This function has two valid signatures. Either pass 3D vectors for the look at coordinate and up vector, or pass numbers to represent the vectors.</p></p> <pre><code class="javascript">// Look at another entity, using the (default) positive y-axis for up var position = otherEntity.getPosition(); this.entity.lookAt(position);</code></pre> <pre><code class="javascript">// Look at another entity, using the negative world y-axis for up var position = otherEntity.getPosition(); this.entity.lookAt(position, pc.Vec3.DOWN);</code></pre> <pre><code class="javascript">// Look at the world space origin, using the (default) positive y-axis for up this.entity.lookAt(0, 0, 0);</code></pre> <pre><code class="javascript">// 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);</code></pre> <h4>Parameters</h4> <table> <tr> <td>x</td><td><a href="pc.Vec3.html">pc.Vec3</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>If passing a 3D vector, this is the world-space coordinate to look at. Otherwise, it is the x-component of the world-space coordinate to look at.</p></td> </tr> <tr> <td>y</td><td><a href="pc.Vec3.html">pc.Vec3</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>If passing a 3D vector, this is the world-space up vector for look at transform. Otherwise, it is the y-component of the world-space coordinate to look at.</p></td> </tr> <tr> <td>z</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>Z-component of the world-space coordinate to look at.</p></td> </tr> <tr> <td>ux</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>X-component of the up vector for the look at transform.</p></td> </tr> <tr> <td>uy</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Ob