/src/away3d/core/partition/MeshNode.as

http://github.com/away3d/away3d-core-fp11 · ActionScript · 48 lines · 30 code · 5 blank · 13 comment · 2 complexity · a5823d1c908cf1f334780d4a9c847d0b MD5 · raw file

  1. package away3d.core.partition
  2. {
  3. import away3d.core.base.SubMesh;
  4. import away3d.core.traverse.PartitionTraverser;
  5. import away3d.entities.Mesh;
  6. /**
  7. * MeshNode is a space partitioning leaf node that contains a Mesh object.
  8. */
  9. public class MeshNode extends EntityNode
  10. {
  11. private var _mesh:Mesh;
  12. /**
  13. * Creates a new MeshNode object.
  14. * @param mesh The mesh to be contained in the node.
  15. */
  16. public function MeshNode(mesh:Mesh)
  17. {
  18. super(mesh);
  19. _mesh = mesh; // also keep a stronger typed reference
  20. }
  21. /**
  22. * The mesh object contained in the partition node.
  23. */
  24. public function get mesh():Mesh
  25. {
  26. return _mesh;
  27. }
  28. /**
  29. * @inheritDoc
  30. */
  31. override public function acceptTraverser(traverser:PartitionTraverser):void
  32. {
  33. if (traverser.enterNode(this)) {
  34. super.acceptTraverser(traverser);
  35. var subs:Vector.<SubMesh> = _mesh.subMeshes;
  36. var i:uint;
  37. var len:uint = subs.length;
  38. while (i < len)
  39. traverser.applyRenderable(subs[i++]);
  40. }
  41. }
  42. }
  43. }