# Scene

#### new Cesium.Scene(options)
Scene/Scene.js 192

  The container for all 3D graphical objects and state in a Cesium virtual scene. Generally, a scene is not created directly; instead, it is implicitly created by `CesiumWidget`.

  `contextOptions` parameter details:

  The default values are: `{ webgl : { alpha : false, depth : true, stencil : false, antialias : true, premultipliedAlpha : true, preserveDrawingBuffer : false, failIfMajorPerformanceCaveat : false }, allowTextureFilterAnisotropic : true }`

  The `webgl` property corresponds to the WebGLContextAttributes object used to create the WebGL context.

  `webgl.alpha` defaults to false, which can improve performance compared to the standard WebGL default of true. If an application needs to composite Cesium above other HTML elements using alpha-blending, set `webgl.alpha` to true.

  The other `webgl` properties match the WebGL defaults for WebGLContextAttributes.

  `allowTextureFilterAnisotropic` defaults to true, which enables anisotropic texture filtering when the WebGL extension is supported. Setting this to false will improve performance, but hurt visual quality, especially for horizon views.

  Name | Type | Description
  --- | --- | ---
  `options` | Object | optional Object with the following properties:
  Name | Type | Default | Description
  --- | --- | --- | ---
  `canvas` | Canvas |  | The HTML canvas element to create the scene for.
  `contextOptions` | Object |  | optional Context and WebGL creation properties. See details above.
  `creditContainer` | Element |  | optional The HTML element in which the credits will be displayed.
  `mapProjection` | MapProjection | `new GeographicProjection()` | optional The map projection to use in 2D and Columbus View modes.
  `orderIndependentTranslucency` | Boolean | `true` | optional If true and the configuration supports it, use order independent translucency.
  `scene3DOnly` | Boolean | `false` | optional If true, optimizes memory use and performance for 3D mode but disables the ability to use 2D or Columbus View.
  `terrainExaggeration` | Number | `1.0` | optional A scalar used to exaggerate the terrain. Note that terrain exaggeration will not modify any other primitive as they are positioned relative to the ellipsoid.

  ##### Throws:

  - DeveloperError : options and options.canvas are required.

  ##### Example:

      // Create scene without anisotropic texture filtering
      var scene = new Cesium.Scene({
        canvas : canvas,
        contextOptions : {
          allowTextureFilterAnisotropic : false
        }
      });

  ##### See:

  - CesiumWidget
  - WebGLContextAttributes

### Members

#### backgroundColor : Color
Scene/Scene.js 372

  The background color, which is only visible if there is no sky box, i.e., `Scene#skyBox` is undefined.
  Default Value: ``Color.BLACK``

  ##### See:

  - Scene#skyBox

#### readonlycamera : Camera
Scene/Scene.js 709

  Gets the camera.

#### readonlycanvas : Canvas
Scene/Scene.js 581

  Gets the canvas element to which this scene is bound.

#### completeMorphOnUserInput : Boolean
Scene/Scene.js 305

  Determines whether or not to instantly complete the scene transition animation on user input.
  Default Value: `true`

#### debugCommandFilter : function
Scene/Scene.js 423

  This property is for debugging only; it is not for production use.

  A function that determines what commands are executed. As shown in the examples below, the function receives the command's `owner` as an argument, and returns a boolean indicating if the command should be executed.

  The default is `undefined`, indicating that all commands are executed.

  Default Value: `undefined`

  ##### Example:

      // Do not execute any commands.
      scene.debugCommandFilter = function(command) {
          return false;
      };

      // Execute only the billboard's commands.  That is, only draw the billboard.
      var billboards = new Cesium.BillboardCollection();
      scene.debugCommandFilter = function(command) {
          return command.owner === billboards;
      };

#### readonlydebugFrustumStatistics : Object
Scene/Scene.js 876

  This property is for debugging only; it is not for production use.

  When `Scene.debugShowFrustums` is `true`, this contains properties with statistics about the number of command execute per frustum. `totalCommands` is the total number of commands executed, ignoring overlap. `commandsInFrustums` is an array with the number of times commands are executed redundantly, e.g., how many commands overlap two or three frustums.

  Default Value: `undefined`

#### debugShowCommands : Boolean
Scene/Scene.js 437

  This property is for debugging only; it is not for production use.

  When `true`, commands are randomly shaded. This is useful for performance analysis to see what parts of a scene or model are command-dense and could benefit from batching.

  Default Value: `false`

#### debugShowDepthFrustum : Number
Scene/Scene.js 492

  This property is for debugging only; it is not for production use.

  Indicates which frustum will have depth information displayed.

  Default Value: `1`

#### debugShowFramesPerSecond : Boolean
Scene/Scene.js 468

  This property is for debugging only; it is not for production use.

  Displays frames per second and time between frames.

  Default Value: `false`

#### debugShowFrustums : Boolean
Scene/Scene.js 454

  This property is for debugging only; it is not for production use.

  When `true`, commands are shaded based on the frustums they overlap. Commands in the closest frustum are tinted red, commands in the next closest are green, and commands in the farthest frustum are blue. If a command overlaps more than one frustum, the color components are combined, e.g., a command overlapping the first two frustums is tinted yellow.

  Default Value: `false`

#### debugShowGlobeDepth : Boolean
Scene/Scene.js 480

  This property is for debugging only; it is not for production use.

  Displays depth information for the indicated frustum.

  Default Value: `false`

#### readonlydrawingBufferHeight : Number
Scene/Scene.js 596

  The drawingBufferWidth of the underlying GL context.

  ##### See:

  - drawingBufferWidth

#### readonlydrawingBufferWidth : Number
Scene/Scene.js 611

  The drawingBufferHeight of the underlying GL context.

  ##### See:

  - drawingBufferHeight

#### farToNearRatio : Number
Scene/Scene.js 394

  The far-to-near ratio of the multi-frustum. The default is 1,000.0.
  Default Value: `1000.0`

#### fog : Fog
Scene/Scene.js 524

  Blends the atmosphere to geometry far from the camera for horizon views. Allows for additional performance improvements by rendering less geometry and dispatching less terrain requests.

#### fxaa : Boolean
Scene/Scene.js 501

  When `true`, enables Fast Approximate Anti-aliasing even when order independent translucency is unsupported.
  Default Value: `true`

#### globe : Globe
Scene/Scene.js 665

  Gets or sets the depth-test ellipsoid.

#### readonlygroundPrimitives : PrimitiveCollection
Scene/Scene.js 696

  Gets the collection of ground primitives.

#### readonlyid : String
Scene/Scene.js 914

  Gets the unique identifier for this scene.

#### readonlyimageryLayers : ImageryLayerCollection
Scene/Scene.js 782

  Gets the collection of image layers that will be rendered on the globe.

#### readonlymapProjection : MapProjection
Scene/Scene.js 738

  Get the map projection to use in 2D and Columbus View modes.
  Default Value: `new GeographicProjection()`

#### readonlymaximumAliasedLineWidth : Number
Scene/Scene.js 626

  The maximum aliased line width, in pixels, supported by this WebGL implementation. It will be at least one.

  ##### See:

  - glGet with `ALIASED_LINE_WIDTH_RANGE`.

#### readonlymaximumCubeMapSize : Number
Scene/Scene.js 641

  The maximum length in pixels of one edge of a cube map, supported by this WebGL implementation. It will be at least 16.

  ##### See:

  - glGet with `GL_MAX_CUBE_MAP_TEXTURE_SIZE`.

#### mode : SceneMode
Scene/Scene.js 926

  Gets or sets the current mode of the scene.
  Default Value: ``SceneMode.SCENE3D``

#### moon : Moon
Scene/Scene.js 362

  The `Moon`
  Default Value: `undefined`

#### morphComplete : Event
Scene/Scene.js 319

  The event fired at the completion of a scene transition.
  Default Value: `Event()`

#### morphStart : Event
Scene/Scene.js 312

  The event fired at the beginning of a scene transition.
  Default Value: `Event()`

#### morphTime : Number
Scene/Scene.js 387

  The current morph transition time between 2D/Columbus View and 3D, with 0.0 being 2D or Columbus View and 1.0 being 3D.
  Default Value: `1.0`

#### readonlyorderIndependentTranslucency : Boolean
Scene/Scene.js 902

  Gets whether or not the scene has order independent translucency enabled. Note that this only reflects the original construction option, and there are other factors that could prevent OIT from functioning on a given system configuration.

#### readonlypostRender : Event
Scene/Scene.js 841

  Gets the event that will be raised at the end of each call to `render`. Subscribers to the event receive the Scene instance as the first parameter and the current time as the second parameter.

#### readonlypreRender : Event
Scene/Scene.js 827

  Gets the event that will be raised at the start of each call to `render`. Subscribers to the event receive the Scene instance as the first parameter and the current time as the second parameter.

#### readonlyprimitives : PrimitiveCollection
Scene/Scene.js 683

  Gets the collection of primitives.

#### readonlyrenderError : Event
Scene/Scene.js 813

  Gets the event that will be raised when an error is thrown inside the `render` function. The Scene instance and the thrown error are the only two parameters passed to the event handler. By default, errors are not rethrown after this event is raised, but that can be changed by setting the `rethrowRenderErrors` property.

#### rethrowRenderErrors : Boolean
Scene/Scene.js 296

  Exceptions occurring in `render` are always caught in order to raise the `renderError` event. If this property is true, the error is rethrown after the event is raised. If this property is false, the `render` function returns normally after raising the event.
  Default Value: `false`

#### readonlyscene3DOnly : Boolean
Scene/Scene.js 888

  Gets whether or not the scene is optimized for 3D only viewing.

#### readonlyscreenSpaceCameraController : ScreenSpaceCameraController
Scene/Scene.js 723

  Gets the controller for camera input handling.

#### skyAtmosphere : SkyAtmosphere
Scene/Scene.js 337

  The sky atmosphere drawn around the globe.
  Default Value: `undefined`

#### skyBox : SkyBox
Scene/Scene.js 329

  The `SkyBox` used to draw the stars.
  Default Value: `undefined`

  ##### See:

  - Scene#backgroundColor

#### sun : Sun
Scene/Scene.js 345

  The `Sun`.
  Default Value: `undefined`

#### sunBloom : Boolean
Scene/Scene.js 353

  Uses a bloom filter on the sun when enabled.
  Default Value: `true`

#### terrainExaggeration : Number
Scene/Scene.js 969

  Gets the scalar used to exaggerate the terrain.

#### terrainProvider : TerrainProvider
Scene/Scene.js 794

  The terrain provider providing surface geometry for the globe.

### Methods

#### completeMorph()
Scene/Scene.js 2155

  Instantly completes an active transition.

#### destroy() → undefined
Scene/Scene.js 2239

  Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object.
  Once an object is destroyed, it should not be used; calling any function other than `isDestroyed` will result in a `DeveloperError` exception. Therefore, assign the return value (`undefined`) to the object as done in the example.

  ##### Returns:

  ##### Throws:

  - DeveloperError : This object was destroyed, i.e., destroy() was called.

  ##### Example:

      scene = scene && scene.destroy();

  ##### See:

  - Scene#isDestroyed

#### drillPick(windowPosition, limit) → Array.<Object>
Scene/Scene.js 2088

  Returns a list of objects, each containing a `primitive` property, for all primitives at a particular window coordinate position. Other properties may also be set depending on the type of primitive. The primitives in the list are ordered by their visual order in the scene (front to back).

  Name | Type | Description
  --- | --- | ---
  `windowPosition` | Cartesian2 | Window coordinates to perform picking on.
  `limit` | Number | optional If supplied, stop drilling after collecting this many picks.

  ##### Returns:

  Array of objects, each containing 1 picked primitives.

  ##### Throws:

  - DeveloperError : windowPosition is undefined.

  ##### Example:

      var pickedObjects = scene.drillPick(new Cesium.Cartesian2(100.0, 200.0));

#### isDestroyed() → Boolean
Scene/Scene.js 2217

  Returns true if this object was destroyed; otherwise, false.
  If this object was destroyed, it should not be used; calling any function other than `isDestroyed` will result in a `DeveloperError` exception.

  ##### Returns:

  `true` if this object was destroyed; otherwise, `false`.

  ##### See:

  - Scene#destroy

#### morphTo2D(duration)
Scene/Scene.js 2163

  Asynchronously transitions the scene to 2D.

  Name | Type | Default | Description
  --- | --- | --- | ---
  `duration` | Number | `2.0` | optional The amount of time, in seconds, for transition animations to complete.

#### morphTo3D(duration)
Scene/Scene.js 2195

  Asynchronously transitions the scene to 3D.

  Name | Type | Default | Description
  --- | --- | --- | ---
  `duration` | Number | `2.0` | optional The amount of time, in seconds, for transition animations to complete.

#### morphToColumbusView(duration)
Scene/Scene.js 2179

  Asynchronously transitions the scene to Columbus View.

  Name | Type | Default | Description
  --- | --- | --- | ---
  `duration` | Number | `2.0` | optional The amount of time, in seconds, for transition animations to complete.

#### pick(windowPosition) → Object
Scene/Scene.js 1961

  Returns an object with a `primitive` property that contains the first (top) primitive in the scene at a particular window coordinate or undefined if nothing is at the location. Other properties may potentially be set depending on the type of primitive.

  Name | Type | Description
  --- | --- | ---
  `windowPosition` | Cartesian2 | Window coordinates to perform picking on.

  ##### Returns:

  Object containing the picked primitive.

  ##### Throws:

  - DeveloperError : windowPosition is undefined.

#### pickPosition(windowPosition, result) → Cartesian3
Scene/Scene.js 2015

  Returns the cartesian position reconstructed from the depth buffer and window position.

  Name | Type | Description
  --- | --- | ---
  `windowPosition` | Cartesian2 | Window coordinates to perform picking on.
  `result` | Cartesian3 | optional The object on which to restore the result.

  ##### Returns:

  The cartesian position.

  ##### Throws:

  - DeveloperError : Picking from the depth buffer is not supported. Check pickPositionSupported.
  - DeveloperError : 2D is not supported. An orthographic projection matrix is not invertible.