src/util/WWMath.js
function (viewportWidth, viewportHeight, distance) {
                if (viewportWidth <= 0) {
                    throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "WWMath", "perspectiveFrustumRectangle",
                        "invalidWidth"));
                }

                if (viewportHeight <= 0) {
                    throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "WWMath", "perspectiveFrustumRectangle",
                        "invalidHeight"));
                }

                if (distance < 0) {
                    throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "WWMath", "perspectiveFrustumRectangle",
                        "The specified distance is negative."));
                }

                // Assumes a 45 degree horizontal field of view.
                var width = distance,
                    height = distance * viewportHeight / viewportWidth;

                return new Rectangle(-width / 2, -height / 2, width, height);
            }
function (viewportWidth, viewportHeight, distance) {
                if (viewportWidth <= 0) {
                    throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "WWMath", "perspectiveFrustumRectangle",
                        "invalidWidth"));
                }

                if (viewportHeight <= 0) {
                    throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "WWMath", "perspectiveFrustumRectangle",
                        "invalidHeight"));
                }

                if (distance < 0) {
                    throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "WWMath", "perspectiveFrustumRectangle",
                        "The specified distance is negative."));
                }

                // Assumes a 45 degree horizontal field of view.
                var width = distance,
                    height = distance * viewportHeight / viewportWidth;

                return new Rectangle(-width / 2, -height / 2, width, height);
            }
function ( viewportWidth , viewportHeight , distance ) { if ( viewportWidth <= 0 ) { throw new ArgumentError ( Logger . logMessage ( Logger . LEVEL_SEVERE , "WWMath" , "perspectiveFrustumRectangle" , "invalidWidth" ) ) ; } if ( viewportHeight <= 0 ) { throw new ArgumentError ( Logger . logMessage ( Logger . LEVEL_SEVERE , "WWMath" , "perspectiveFrustumRectangle" , "invalidHeight" ) ) ; } if ( distance < 0 ) { throw new ArgumentError ( Logger . logMessage ( Logger . LEVEL_SEVERE , "WWMath" , "perspectiveFrustumRectangle" , "The specified distance is negative." ) ) ; } // Assumes a 45 degree horizontal field of view. var width = distance , height = distance * viewportHeight / viewportWidth ; return new Rectangle ( - width / 2 , - height / 2 , width , height ) ; }
Computes the coordinates of a rectangle carved out of a perspective projection's frustum at a given
distance in model coordinates. This returns an empty rectangle if the specified distance is zero.

@param {Number} viewportWidth The viewport width, in screen coordinates.
@param {Number} viewportHeight The viewport height, in screen coordinates.
@param {Number} distance The distance along the negative Z axis, in model coordinates.
@returns {Rectangle} The frustum rectangle, in model coordinates.
@throws {ArgumentError} If the specified width or height is less than or equal to zero, or if the
specified distance is negative.
Computes the coordinates of a rectangle carved out of a perspective projection s frustum at a given distance in model coordinates . This returns an empty rectangle if the specified distance is zero .