Class: Scene

pc.Scene

A scene is graphical representation of an environment. It manages the scene hierarchy, all graphical objects, lights, and scene-wide properties.

Constructor

new Scene()

Creates a new Scene.
Properties:
Name Type Description
ambientLight pc.Color The color of the scene's ambient light. Defaults to black (0, 0, 0).
fog String The type of fog used by the scene. Can be:
  • pc.FOG_NONE
  • pc.FOG_LINEAR
  • pc.FOG_EXP
  • pc.FOG_EXP2
Defaults to pc.FOG_NONE.
fogColor pc.Color The color of the fog (if enabled). Defaults to black (0, 0, 0).
fogDensity Number The density of the fog (if enabled). This property is only valid if the fog property is set to pc.FOG_EXP or pc.FOG_EXP2. Defaults to 0.
fogEnd Number The distance from the viewpoint where linear fog reaches its maximum. This property is only valid if the fog property is set to pc.FOG_LINEAR. Defaults to 1000.
fogStart Number The distance from the viewpoint where linear fog begins. This property is only valid if the fog property is set to pc.FOG_LINEAR. Defaults to 1.
gammaCorrection Number The gamma correction to apply when rendering the scene. Can be:
  • pc.GAMMA_NONE
  • pc.GAMMA_SRGB
Defaults to pc.GAMMA_NONE.
toneMapping Number The tonemapping transform to apply when writing fragments to the frame buffer. Can be:
  • pc.TONEMAP_LINEAR
  • pc.TONEMAP_FILMIC
  • pc.TONEMAP_HEJL
  • pc.TONEMAP_ACES
Defaults to pc.TONEMAP_LINEAR.
skybox pc.Texture A cube map texture used as the scene's skybox. Defaults to null.
skyboxIntensity Number Multiplier for skybox intensity. Defaults to 1.
skyboxMip Number The mip level of the skybox to be displayed. Only valid for prefiltered cubemap skyboxes. Defaults to 0 (base level).
lightmapSizeMultiplier Number The lightmap resolution multiplier. Defaults to 1.
lightmapMaxResolution Number The maximum lightmap resolution. Defaults to 2048.
lightmapMode Number The lightmap baking mode. Can be:
  • pc.BAKE_COLOR: single color lightmap
  • pc.BAKE_COLORDIR: single color lightmap + dominant light direction (used for bump/specular)
Only lights with bakeDir=true will be used for generating the dominant light direction. Defaults to pc.BAKE_COLORDIR.
layers pc.LayerComposition A pc.LayerComposition that defines rendering order of this scene.
Source:

Events

set:layers

Fired when the layer composition is set. Use this event to add callbacks or advanced properties to your layers.
Parameters:
Name Type Description
oldComp pc.LayerComposition Previously used pc.LayerComposition.
newComp pc.LayerComposition Newly set pc.LayerComposition.
Source:
Example
this.app.scene.on('set:layers', function(oldComp, newComp) {
      var list = newComp.layerList;
      var layer;
      for(var i=0; i<list.length; i++) {
          layer = list[i];
          switch(layer.name) {
              case 'MyLayer':
                  layer.onEnable = myOnEnableFunction;
                  layer.onDisable = myOnDisableFunction;
                  break;
              case 'MyOtherLayer':
                  layer.shaderPass = myShaderPass;
                  break;
          }
      }
  });

set:skybox

Fired when the skybox is set.
Parameters:
Name Type Description
usedTex pc.Texture Previously used cubemap texture. New is in the pc.Scene#skybox.
Source: