Show/Hide nodes

Goal: show single node and hide rest ones. For instance, this function may be used to show selected node and hide rest ones. If tree view is used, it will be updated automatically.

Show single node

function showNode(view,node) {
  node.show(true);
  var parent=node.parent;
  while(parent) // traverse scene to the root node and hide all objects except parent of our node
 	  {	  
	 	  // hide object attached to parent node
	 	  if(parent.object)parent.setState(iv.NS_VIS_CHILDREN,iv.NS_VIS_THIS|iv.NS_VIS_CHILDREN);
	 	  else parent.show(true);
	 	  var n=parent.firstChild;
	 	  while(n)
	 	  {
	 	  // skip lights
	             if((n!=node) && (!(n.object && n.object instanceof iv.light)))n.show(false);
	 	     n=n.next;
	 	  }
	 	  node=parent;
	 	  parent=parent.parent;
	  }
if(view)view.invalidate(iv.INV_STRUCTURE);// update shadows
}

// test function
function testShow()
{
  var a=view3d.searchNode("Object_A")
  if(a)showNode(view3d,a);
}

In this article