Whether the Lights Manager is enabled.
The ambient color.
The Lights in the Scene.
ReadonlymaxThe maximum number of lights that a single Camera and the lights shader can process.
Change this via the maxLights property in your game config, as it cannot be changed at runtime.
ReadonlyvisibleThe number of lights processed in the previous frame.
Creates a new cone-limited Phaser.GameObjects.Light object, adds it to this Lights Manager, and returns it.
The cone angles are full cone widths in radians. Fragments inside innerAngle receive full light,
and fragments between innerAngle and outerAngle are softly attenuated.
Optionalx: number
The horizontal position of the Light. Default 0.
Optionaly: number
The vertical position of the Light. Default 0.
Optionalradius: number
The radius of the Light. Default 128.
Optionalrgb: number
The integer RGB color of the light. Default 0xffffff.
Optionalintensity: number
The intensity of the Light. Default 1.
Optionalrotation: number
The direction of the cone, in radians. Default 0.
OptionalinnerAngle: number
The fully-lit cone width, in radians. Default Math.PI / 4.
OptionalouterAngle: number
The outer falloff cone width, in radians. Default innerAngle.
Optionalz: number
The z position of the light. If omitted, it will be set to radius * 0.1.
The Light that was added.
Creates a new Phaser.GameObjects.Light object, adds it to this Lights Manager, and returns it. The Light will influence all Game Objects using the Light Filter that are within its radius, using the texture's normal map data to compute shading. You can configure its position, radius, color, intensity, and z-height (which affects the angle of the shading effect).
Optionalx: number
The horizontal position of the Light. Default 0.
Optionaly: number
The vertical position of the Light. Default 0.
Optionalradius: number
The radius of the Light. Default 128.
Optionalrgb: number
The integer RGB color of the light. Default 0xffffff.
Optionalintensity: number
The intensity of the Light. Default 1.
Optionalz: number
The z position of the light. If omitted, it will be set to radius * 0.1.
The Light that was added.
Creates a new Point Light Game Object and adds it to the Scene.
Note: This method will only be available if the Point Light Game Object has been built into Phaser.
The Point Light Game Object provides a way to add a point light effect into your game, without the expensive shader processing requirements of the traditional Light Game Object.
The difference is that the Point Light renders using a custom shader, designed to give the impression of a point light source, of variable radius, intensity and color, in your game. However, unlike the Light Game Object, it does not impact any other Game Objects, or use their normal maps for calculations. This makes them extremely fast to render compared to Lights and perfect for special effects, such as flickering torches or muzzle flashes.
For maximum performance you should batch Point Light Game Objects together. This means ensuring they follow each other consecutively on the display list. Ideally, use a Layer Game Object and then add just Point Lights to it, so that it can batch together the rendering of the lights. You don't have to do this, and if you've only a handful of Point Lights in your game then it's perfectly safe to mix them into the display list as normal. However, if you're using a large number of them, please consider how they are mixed into the display list.
The renderer will automatically cull Point Lights. Those with a radius that does not intersect with the Camera will be skipped in the rendering list. This happens automatically and the culled state is refreshed every frame, for every camera.
The origin of a Point Light is always 0.5 and it cannot be changed.
Point Lights are a WebGL only feature and do not have a Canvas counterpart.
The horizontal position of this Point Light in the world.
The vertical position of this Point Light in the world.
Optionalcolor: number
The color of the Point Light, given as a hex value. Default 0xffffff.
Optionalradius: number
The radius of the Point Light. Default 128.
Optionalintensity: number
The intensity, or color blend, of the Point Light. Default 1.
Optionalattenuation: number
The attenuation of the Point Light. This is the reduction of light from the center point. Default 0.1.
The Game Object that was created.
Destroy the Lights Manager.
Cleans up all references by calling Phaser.GameObjects.LightsManager#shutdown.
Disable the Lights Manager. When disabled, the lighting system no longer affects the rendering of Game Objects using the Light Filter, effectively switching them back to unlit rendering. The existing lights and ambient color are preserved and will take effect again if the manager is re-enabled.undefined
This Lights Manager instance.
Enable the Lights Manager. This activates the lighting system for the Scene, causing all
Game Objects using the Light Filter to be affected by the configured lights and ambient
color. On first enable, the maxLights value is read from the renderer configuration.undefined
This Lights Manager instance.
Get the number of Lights managed by this Lights Manager.undefined
The number of Lights managed by this Lights Manager.
Get all lights that can be seen by the given Camera.
It will automatically cull lights that are outside the world view of the Camera.
If more lights are returned than supported by the renderer, the lights are then culled based on the distance from the center of the camera. Only those closest are rendered.
The Camera to cull Lights for.
The culled Lights.
Returns the maximum number of Lights allowed to appear at once.undefined
The maximum number of Lights allowed to appear at once.
Removes a Phaser.GameObjects.Light from this Lights Manager. The Light will no longer influence the rendering of any Game Objects. The Light object itself is not destroyed; it is simply removed from the manager's active list.
The Light to remove.
This Lights Manager instance.
Set the ambient light color.
The integer RGB color of the ambient light.
This Lights Manager instance.
Shuts down the Lights Manager and clears all active Lights. This is called automatically when a Scene shuts down. The Lights Manager can be re-enabled afterwards by calling Phaser.GameObjects.LightsManager#enable.
Sort function to sort lights by distance from the camera. The sort is in reverse order, so that the furthest light is culled first.
A light entry object with a distance property representing its distance from the camera center.
A light entry object with a distance property representing its distance from the camera center.
True if a is further than b, otherwise false.
The Lights Manager is responsible for managing all of the Phaser.GameObjects.Light objects in a Scene, as well as the ambient light color that applies to all lit Game Objects.
It is created automatically by the Scene Systems and is accessed via
this.lightswithin a Scene. To use the lighting system, callthis.lights.enable()and ensure that any Game Objects you want to be affected by lighting havesetLighting(true)applied to them.The Lights Manager works in conjunction with the Light Filter (WebGL only). Game Objects rendered with this filter sample the active lights and the ambient color, and use any normal maps assigned to their textures to produce a dynamic lighting effect. Lighting has no effect in Canvas rendering.
Each Scene supports a fixed maximum number of simultaneous lights, set via the
maxLightsproperty in the game config. When more lights exist than the maximum, the manager culls the furthest lights from the camera each frame. Use Phaser.GameObjects.LightsManager#addLight to create a Light and Phaser.GameObjects.LightsManager#setAmbientColor to control the base illumination.