PageRenderTime 35ms CodeModel.GetById 31ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/away3d/bounds/NullBounds.as

http://github.com/away3d/away3d-core-fp11
ActionScript | 81 lines | 54 code | 11 blank | 16 comment | 1 complexity | 8cd3b87660f0e9d370bcd787576087a2 MD5 | raw file
 1package away3d.bounds
 2{
 3	import away3d.core.base.*;
 4	import away3d.core.math.Plane3D;
 5	import away3d.core.math.PlaneClassification;
 6	import away3d.primitives.*;
 7	
 8	import flash.geom.*;
 9	
10	/**
11	 * NullBounds represents a debug bounding "volume" that is either considered always in, or always out of the frustum.
12	 * NullBounds is useful for entities that are always considered in the frustum, such as directional lights or skyboxes.
13	 */
14	public class NullBounds extends BoundingVolumeBase
15	{
16		private var _alwaysIn:Boolean;
17		private var _renderable:WireframePrimitiveBase;
18		
19		public function NullBounds(alwaysIn:Boolean = true, renderable:WireframePrimitiveBase = null)
20		{
21			super();
22			_alwaysIn = alwaysIn;
23			_renderable = renderable;
24			_max.x = _max.y = _max.z = Number.POSITIVE_INFINITY;
25			_min.x = _min.y = _min.z = _alwaysIn? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
26		}
27		
28		override public function clone():BoundingVolumeBase
29		{
30			return new NullBounds(_alwaysIn);
31		}
32		
33		override protected function createBoundingRenderable():WireframePrimitiveBase
34		{
35			return _renderable || new WireframeSphere(100, 16, 12, 0xffffff, 0.5);
36		}
37		
38		/**
39		 * @inheritDoc
40		 */
41		override public function isInFrustum(planes:Vector.<Plane3D>, numPlanes:int):Boolean
42		{
43			planes = planes;
44			numPlanes = numPlanes;
45			return _alwaysIn;
46		}
47		
48		/**
49		 * @inheritDoc
50		 */
51		override public function fromGeometry(geometry:Geometry):void
52		{
53		}
54		
55		/**
56		 * @inheritDoc
57		 */
58		override public function fromSphere(center:Vector3D, radius:Number):void
59		{
60		}
61		
62		/**
63		 * @inheritDoc
64		 */
65		override public function fromExtremes(minX:Number, minY:Number, minZ:Number, maxX:Number, maxY:Number, maxZ:Number):void
66		{
67		}
68		
69		override public function classifyToPlane(plane:Plane3D):int
70		{
71			plane = plane;
72			return PlaneClassification.INTERSECT;
73		}
74		
75		override public function transformFrom(bounds:BoundingVolumeBase, matrix:Matrix3D):void
76		{
77			matrix = matrix;
78			_alwaysIn = NullBounds(bounds)._alwaysIn;
79		}
80	}
81}