Created
September 24, 2012 11:25
-
-
Save k0t0vich/3775520 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static var MAXIMUM_POOL_LENGTH:uint = 5000; | |
private static var POOL:Array = []; | |
public function SphericalCoordinates(azimuth:Number = 0, elevation:Number = 0, | |
radius:Number = 1) { | |
this.elevation = elevation; | |
this.azimuth = azimuth; | |
this.radius = radius; | |
} | |
public static function fromCache(azimuth:Number = 0, elevation:Number = 0, | |
radius:Number = 1):SphericalCoordinates { | |
var sp:SphericalCoordinates; | |
if (POOL.length > 0){ | |
sp = POOL.pop(); | |
sp.azimuth = azimuth; | |
sp.elevation = elevation; | |
sp.radius = radius; | |
} else { | |
sp = new SphericalCoordinates(azimuth, elevation, radius); | |
} | |
return sp; | |
} | |
public function destroy():void { | |
if (POOL.length < MAXIMUM_POOL_LENGTH) { | |
POOL.push(this); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment