/*
Compare this example with the similar example
for X3DObject.FindChildren
*/
// Create a sample scene
NewScene( null, false ) ;
var oRoot = Application.ActiveSceneRoot;
var oNull = oRoot.AddNull( "MyNull" ) ;
var oSphere = oRoot.AddGeometry( "Sphere", "MeshSurface", "MySphere" ) ;
var oNestedSphere = oNull.AddNull( "NestedNull" ) ;
var oConeInModel = oRoot.AddGeometry( "Cone", "NurbsSurface", "ConeInMdl" ) ;
var oModel = oRoot.AddModel(oConeInModel, "MyModel") ;
// The X3DObject.Children collection returns all X3DObjects
// but it is not recursive.
PrintChildren( "Children of SceneRoot:", oRoot.Children ) ;
PrintChildren( "Children of Null:", oNull.Children ) ;
PrintChildren( "Children of Model:", oModel.Children ) ;
// Expected result:
//INFO : Children of SceneRoot:
//INFO : Camera_Root
//INFO : light
//INFO : MyNull
//INFO : MySphere
//INFO : MyModel
//INFO : ----------------------------
//INFO : Children of Null:
//INFO : NestedNull
//INFO : ----------------------------
//INFO : Children of Model:
//INFO : MyModel.ConeInMdl
//INFO : ----------------------------
// Helper function showing the contents of a collection
function PrintChildren( in_msg, in_oChildren )
{
Application.LogMessage( in_msg ) ;
for ( var i=0 ; i<in_oChildren.Count; i++ ) {
Application.LogMessage( "\t" + in_oChildren.Item(i).FullName ) ;
}
Application.LogMessage( "----------------------------" ) ;
} |