If enabled, the ambient lighting will be baked into lightmaps. This will be either the Scene#skybox if set up, otherwise Scene#ambientLight. Defaults to false.
If Scene#ambientBake is true, this specifies the brightness of ambient occlusion. Typical range is -1 to 1. Defaults to 0, representing no change to brightness.
If Scene#ambientBake is true, this specifies the contrast of ambient occlusion. Typical range is -1 to 1. Defaults to 0, representing no change to contrast.
The color of the scene's ambient light. Defaults to black (0, 0, 0).
The luminosity of the scene's ambient light in lux (lm/m^2). Used if physicalUnits is true. Defaults to 0.
The exposure value tweaks the overall brightness of the scene. Ignored if physicalUnits is true. Defaults to 1.
The color of the fog (if enabled). Defaults to black (0, 0, 0).
The distance from the viewpoint where linear fog reaches its maximum. This property is only valid if the fog property is set to FOG_LINEAR. Defaults to 1000.
The distance from the viewpoint where linear fog begins. This property is only valid if the fog property is set to FOG_LINEAR. Defaults to 1.
Enables bilateral filter on runtime baked color lightmaps, which removes the noise and banding while preserving the edges. Defaults to false. Note that the filtering takes place in the image space of the lightmap, and it does not filter across lightmap UV space seams, often making the seams more visible. It's important to balance the strength of the filter with number of samples used for lightmap baking to limit the visible artifacts.
Enables HDR lightmaps. This can result in smoother lightmaps especially when many samples are used. Defaults to false.
The maximum lightmap resolution. Defaults to 2048.
The lightmap baking mode. Can be:
Defaults to BAKE_COLORDIR.
The lightmap resolution multiplier. Defaults to 1.
Use physically based units for cameras and lights. When used, the exposure value is ignored.
The root entity of the scene, which is usually the only child to the Application root entity.
Gets the number of samples used to bake the ambient light into the lightmap.
Sets the number of samples used to bake the ambient light into the lightmap. Note that Scene#ambientBake must be true for this to have an effect. Defaults to 1. Maximum value is 255.
Gets the part of the sphere which represents the source of ambient light.
Sets the part of the sphere which represents the source of ambient light. Note that Scene#ambientBake must be true for this to have an effect. The valid range is 0..1, representing a part of the sphere from top to the bottom. A value of 0.5 represents the upper hemisphere. A value of 1 represents a full sphere. Defaults to 0.4, which is a smaller upper hemisphere as this requires fewer samples to bake.
Gets whether clustered lighting is enabled.
Sets whether clustered lighting is enabled. Set to false before the first frame is rendered to use non-clustered lighting. Defaults to true.
Gets the type of fog used by the scene.
Sets the type of fog used by the scene. Can be:
Defaults to FOG_NONE.
Gets the gamma correction to apply when rendering the scene.
Sets the gamma correction to apply when rendering the scene. Can be:
Defaults to GAMMA_SRGB.
Gets the LayerComposition that defines rendering order of this scene.
Sets the LayerComposition that defines rendering order of this scene.
Gets the LightingParams that define lighting parameters.
Gets the range parameter of the bilateral filter.
Sets the range parameter of the bilateral filter. It's used when Scene#lightmapFilterEnabled is enabled. Larger value applies more widespread blur. This needs to be a positive non-zero value. Defaults to 10.
Gets the spatial parameter of the bilateral filter.
Sets the spatial parameter of the bilateral filter. It's used when Scene#lightmapFilterEnabled is enabled. Larger value blurs less similar colors. This needs to be a positive non-zero value. Defaults to 0.2.
Gets the lightmap pixel format.
Gets the multiplier for skybox intensity.
Sets the multiplier for skybox intensity. Defaults to 1. Unused if physical units are used.
Gets the luminance (in lm/m^2) of the skybox.
Sets the luminance (in lm/m^2) of the skybox. Defaults to 0. Only used if physical units are used.
Gets the mip level of the skybox to be displayed.
Sets the mip level of the skybox to be displayed. Only valid for prefiltered cubemap skyboxes. Defaults to 0 (base level).
Gets the rotation of the skybox to be displayed.
Sets the rotation of the skybox to be displayed. Defaults to Quat.IDENTITY.
Gets the tonemapping transform to apply when writing fragments to the frame buffer.
Sets the tonemapping transform to apply when writing fragments to the frame buffer. Can be:
Defaults to TONEMAP_LINEAR.
Fire an event, all additional arguments are passed on to the event listener.
Name of event to fire.
Optional
arg1: anyFirst argument that is passed to the event handler.
Optional
arg2: anySecond argument that is passed to the event handler.
Optional
arg3: anyThird argument that is passed to the event handler.
Optional
arg4: anyFourth argument that is passed to the event handler.
Optional
arg5: anyFifth argument that is passed to the event handler.
Optional
arg6: anySixth argument that is passed to the event handler.
Optional
arg7: anySeventh argument that is passed to the event handler.
Optional
arg8: anyEighth argument that is passed to the event handler.
Self for chaining.
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Optional
name: stringName of the event to unbind.
Optional
callback: HandleEventCallbackFunction to be unbound.
Optional
scope: objectScope that was used as the this when the event is fired.
Self for chaining.
const handler = function () {
};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Attach an event handler to an event.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Can be used for removing event in the future.
Attach an event handler to an event. This handler will be removed after being fired once.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Sets the cubemap for the scene skybox.
Optional
cubemaps: Texture[]An array of cubemaps corresponding to the skybox at different mip levels. If undefined, scene will remove skybox. Cubemap array should be of size 7, with the first element (index 0) corresponding to the base cubemap (mip level 0) with original resolution. Each remaining element (index 1-6) corresponds to a fixed prefiltered resolution (128x128, 64x64, 32x32, 16x16, 8x8, 4x4).
Static
EVENT_Fired when the layer composition is set. Use this event to add callbacks or advanced properties to your layers. The handler is passed the old and the new LayerComposition.
app.scene.on('set:layers', (oldComp, newComp) => {
const list = newComp.layerList;
for (let i = 0; i < list.length; i++) {
const layer = list[i];
switch (layer.name) {
case 'MyLayer':
layer.onEnable = myOnEnableFunction;
layer.onDisable = myOnDisableFunction;
break;
case 'MyOtherLayer':
layer.shaderPass = myShaderPass;
break;
}
}
});
Static
EVENT_Fired when the skybox is set. The handler is passed the Texture that is the previously used skybox cubemap texture. The new skybox cubemap texture is in the Scene#skybox property.
A scene is graphical representation of an environment. It manages the scene hierarchy, all graphical objects, lights, and scene-wide properties.