import { SceneNodeComponent } from './scenenodecomponent' ; /**
 * This class describes a node in a scene hierarchy. To render a scene, a renderer can traverse the hierarchy
 * of SceneNodes, while recursively applying the transformations specfied by each node.
 * Every node contains components that describe the contents of the node, e.g. the contained geometry or the
 * applied transformation.
 */ export class SceneNode { see name protected _name : string ; see parent protected _parent : SceneNode | undefined ; see nodes protected _nodes = new Array < SceneNode > ( ) ; see components protected _components = new Array < SceneNodeComponent > ( ) ; param name constructor ( name ) { this . _name = name ; this . _parent = undefined ; } param callback traverse ( callback ) { callback ( this ) ; for ( const child of this . _nodes ) { child . traverse ( callback ) ; } } param node addNode ( node ) { node . _parent = this ; this . _nodes . push ( node ) ; return node ; } param component addComponent ( component ) { this . _components . push ( component ) ; return component ; } param type todo componentsOfType ( type ) { return this . _components . filter ( ( component ) => type === component . type ) ; } /**
     * Read-only access to the name of this node.
     */ get name ( ) : string { return this . _name ; } /**
     * Read-only access to the parent node of this node if one exists.
     */ get parent ( ) : SceneNode | undefined { return this . _parent ; } /**
     * Read-only access to the child nodes of this node.
     */ get nodes ( ) : Array < SceneNode > | undefined { return this . _nodes ; } /**
     * Read-only access to the components attached to this node.
     */ get components ( ) : Array < SceneNodeComponent > { return this . _components ; } /**
     * Returns whether this node is a leaf, i.e. there are no child nodes attached to it.
     */ get isLeaf ( ) : boolean { return this . _nodes . length === 0 ; } /**
     * Returns whether this is the root node, i.e. it has no parent.
     */ get isRoot ( ) : boolean { return this . _parent === undefined ; } } export namespace SceneNode { export interface NodeCallback { ( node ) : void ; } }