the original function find in away builder. i change them in my project. but for each ObjectContainer3D with diffrent sizes not work correctly.
anybody has a solution?
public static function abs( value:Number ):Number {
return value < 0 ? -value : value;
}
public function updateDefaultCameraFarPlane(oC:ObjectContainer3D) : void {
var bounds:Vector.<Number> = containerBounds(oC,true);
if (abs(bounds[0])==Infinity || abs(bounds[1])==Infinity || abs(bounds[2])==Infinity || abs(bounds[3])==Infinity || abs(bounds[4])==Infinity || abs(bounds[5])==Infinity)
cameraController.distance = 100000;
else {
var vec:Vector3D = new Vector3D(bounds[3] - bounds[0], bounds[4] - bounds[1], bounds[5] - bounds[2]);
var objRadius:Number = vec.length / 2;
vec.x = (vec.x * 0.5) + bounds[0];
vec.y = (vec.y * 0.5) + bounds[1];
vec.z = (vec.z * 0.5) + bounds[2];
cameraController.distance = Vector3D.distance(camera.position, vec) + objRadius;
}
}
public static function containerBounds(oC:ObjectContainer3D, sceneBased:Boolean = true) : Vector.<Number> {
Bounds.getObjectContainerBounds(oC, sceneBased);
return Vector.<Number>([Bounds.minX, Bounds.minY, Bounds.minZ, Bounds.maxX, Bounds.maxY, Bounds.maxZ]);
}