/src/away3d/materials/SkyBoxMaterial.as

http://github.com/away3d/away3d-core-fp11 · ActionScript · 48 lines · 29 code · 7 blank · 12 comment · 6 complexity · cc3b0ee3c5b2fe7340889fe35714fc99 MD5 · raw file

  1. package away3d.materials
  2. {
  3. import away3d.arcane;
  4. import away3d.materials.passes.SkyBoxPass;
  5. import away3d.textures.CubeTextureBase;
  6. use namespace arcane;
  7. /**
  8. * SkyBoxMaterial is a material exclusively used to render skyboxes
  9. *
  10. * @see away3d.primitives.SkyBox
  11. */
  12. public class SkyBoxMaterial extends MaterialBase
  13. {
  14. private var _cubeMap:CubeTextureBase;
  15. private var _skyboxPass:SkyBoxPass;
  16. /**
  17. * Creates a new SkyBoxMaterial object.
  18. * @param cubeMap The CubeMap to use as the skybox.
  19. */
  20. public function SkyBoxMaterial(cubeMap:CubeTextureBase)
  21. {
  22. _cubeMap = cubeMap;
  23. addPass(_skyboxPass = new SkyBoxPass());
  24. _skyboxPass.cubeTexture = _cubeMap;
  25. }
  26. /**
  27. * The cube texture to use as the skybox.
  28. */
  29. public function get cubeMap():CubeTextureBase
  30. {
  31. return _cubeMap;
  32. }
  33. public function set cubeMap(value:CubeTextureBase):void
  34. {
  35. if (value && _cubeMap && (value.hasMipMaps != _cubeMap.hasMipMaps || value.format != _cubeMap.format))
  36. invalidatePasses(null);
  37. _cubeMap = value;
  38. _skyboxPass.cubeTexture = _cubeMap;
  39. }
  40. }
  41. }