diff --git a/src/WorldWindow.js b/src/WorldWindow.js index 8cb44e58b..6a4b37ffa 100644 --- a/src/WorldWindow.js +++ b/src/WorldWindow.js @@ -572,11 +572,17 @@ define([ * @returns {LookAt} A reference to the result parameter. * @throws {ArgumentError} If the specified result object is null or undefined. */ - WorldWindow.prototype.cameraAsLookAt = function (result, terrainPosition = this.pick([this.viewport.width / 2, this.viewport.height / 2]).terrainObject().position) { + WorldWindow.prototype.cameraAsLookAt = function (result, terrainPosition) { if (!result) { throw new ArgumentError( Logger.logMessage(Logger.LEVEL_SEVERE, "Camera", "getAsLookAt", "missingResult")); } + if (!terrainPosition) { + var terrainObject = this.pick([this.viewport.width / 2, this.viewport.height / 2]).terrainObject(); + if (terrainObject) { + terrainPosition = terrainObject.position; + } + } var globe = this.globe, forwardRay = this.scratchRay,