PageRenderTime 15ms CodeModel.GetById 10ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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