Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
263 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# AmbientLight | ||
|
||
Create an ambient light source which illuminates all the objects equally.Ambient light comes from all directions, adding ambient light ensures that object colors are rendered but does not show structure in 3D objects like directional and point lights do. Only one ambient light is supported. | ||
|
||
|
||
## Usage | ||
|
||
Create an ambient light source with color and intensity. | ||
```js | ||
const ambientLight= new AmbientLight({ | ||
color: [128, 128, 0], | ||
intensity: 2.0 | ||
}); | ||
``` | ||
|
||
## Methods | ||
|
||
### constructor | ||
|
||
The constructor for the `AmbientLight` class. Use this to create a new `AmbientLight`. | ||
|
||
```js | ||
const ambientLight = new AmbientLight({color, intensity}); | ||
``` | ||
|
||
* `color` - (*array*,) RGB color of ambient light source, default value is `[255, 255, 255]`. | ||
* `intensity` - (*number*) Strength of ambient light source, default value is `1.0`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# DirectionalLight | ||
|
||
Create a directional light source which emits from a specific direction.A directional light can be considered "infinitely" far away (like the Sun) and does not attenuate with distance. At most 5 directional lights can be supported. | ||
|
||
|
||
## Usage | ||
|
||
Create a directional light source with color, intensity and direction. | ||
```js | ||
const directionalLight= new DirectionalLight({ | ||
color: [128, 128, 0], | ||
intensity: 2.0, | ||
direction: [0, -100, -100] | ||
}); | ||
``` | ||
|
||
## Methods | ||
|
||
### constructor | ||
|
||
The constructor for the `DirectionalLight` class. Use this to create a new `DirectionalLight`. | ||
|
||
```js | ||
const directionalLight = new DirectionalLight({color, intensity, direction}); | ||
``` | ||
|
||
* `color` - (*array*,) RGB color of directional light source, default value is `[255, 255, 255]`. | ||
* `intensity` - (*number*) Strength of directional light source, default value is `1.0`. | ||
* `direction` - (*array*,) 3D vector specifies the direction the light comes from, default value is `[0, 0, -1]`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# PointLight | ||
|
||
Create a point light source which emits from a point in all directions.Point lights attenuation is not available. At most 5 directional lights can be supported. | ||
|
||
|
||
## Usage | ||
|
||
Create a point light source with color, intensity and position. | ||
```js | ||
const pointLight= new PointLight({ | ||
color: [128, 128, 0], | ||
intensity: 2.0, | ||
position: [0, 0, 200] | ||
}); | ||
``` | ||
|
||
## Methods | ||
|
||
### constructor | ||
|
||
The constructor for the `PointLight` class. Use this to create a new `PointLight`. | ||
|
||
```js | ||
const pointLight = new PointLight({color, intensity, position}); | ||
``` | ||
#### Parameters | ||
|
||
* `color` - (*array*,) RGB color of point light source, default value is `[255, 255, 255]`. | ||
* `intensity` - (*number*) Strength of point light source, default value is `1.0`. | ||
* `position` - (*array*,) Location of point light source, default value is `[0, 0, 1]`.Coordinate system is the same as that in [view state](/docs/api-reference/view.md#viewstate-string-object-null). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
# Guide to Using Lighting Effect | ||
|
||
A deck.gl lighting effect is a visual approximation of environment illumination based on simplified models to make rendering appear more realistic. | ||
|
||
To enable lighting in deck.gl, it is required that both the lighting effect and material instances are properly instantiated. | ||
|
||
## Constructing Lighting Effect Instance | ||
|
||
A [LightingEffect](/docs/effects/lighting-effect.md) can be instantiated with a `lights` object: | ||
|
||
```js | ||
import {AmbientLight, PointLight, DirectionalLight, LightingEffect} from '@deck.gl/core'; | ||
|
||
// create ambient light source | ||
const ambientLight = new AmbientLight({ | ||
color: [255, 255, 255], | ||
intensity: 1.0 | ||
}); | ||
// create point light source | ||
const pointLight = new PointLight({ | ||
color: [255, 255, 255], | ||
intensity: 2.0, | ||
// use coordinate system as the same as view state | ||
position: [-125, 50.5, 5000] | ||
}); | ||
// create directional light source | ||
const directionalLight = new DirectionalLight({ | ||
color: [255, 255, 255], | ||
intensity: 1.0, | ||
direction: [-3, -9, -1] | ||
}); | ||
// create lighting effect with light sources | ||
const lightingEffect = new LightingEffect({ambientLight, pointLight, directionalLight}); | ||
``` | ||
|
||
The `lights` has all the light sources that the lighting effect uses to build the visualization. Users typically specify the following types of light sources: | ||
|
||
* [AmbientLight](/docs/api-reference/lights/ambient-light.md) | ||
* [PointLight](/docs/api-reference/lights/point-light.md) | ||
* [DirectionalLight](/docs/api-reference/lights/directional-light.md) | ||
|
||
|
||
## Constructing Material Instance | ||
|
||
A material represents a lighting model specified per layer, a [PhongMaterial](http://uber.github.io/luma.gl/#/documentation/api-reference/phong-material) | ||
can be instantiated with model parameters. | ||
|
||
```js | ||
import {PhongMaterial} from '@luma.gl/core'; | ||
|
||
const material = new PhongMaterial({ | ||
ambient: 0.2, | ||
diffuse: 0.5, | ||
shininess: 32, | ||
specularColor: [255, 255, 255] | ||
}); | ||
``` | ||
|
||
|
||
## Using Material Instance | ||
|
||
To enable lighting for a layer, material prop is required. | ||
|
||
```js | ||
new GeoJsonLayer({ | ||
id: 'geojson-layer', | ||
// layer props | ||
... | ||
// lighting only applies to extruded polygons | ||
extruded: true, | ||
// specify material properties per layer | ||
material | ||
}); | ||
``` | ||
Refer to each layer's [documentation](/docs/layers/README.md) to see if the material prop is supported. | ||
|
||
## Using Effect Instance | ||
To enable lighting in deck.gl, [effects prop](/docs/api-reference/deck.md#effects-array-) is required | ||
### Pure JS | ||
|
||
```js | ||
import {Deck, LightingEffect} from '@deck.gl/core'; | ||
import {GeoJsonLayer} from '@deck.gl/layers'; | ||
|
||
const lightingEffect = new LightingEffect({ | ||
... | ||
}); | ||
|
||
const INITIAL_VIEW_STATE = { | ||
latitude: 49.254, | ||
longitude: -123.13, | ||
zoom: 11, | ||
pitch: 45 | ||
}; | ||
const deckgl = new Deck({ | ||
canvas: 'my-deck-canvas', | ||
initialViewState: INITIAL_VIEW_STATE, | ||
controller: true, | ||
// add lighting effect to deck | ||
effects: [lightingEffect], | ||
layers: [new GeoJsonLayer({ | ||
... | ||
})] | ||
}); | ||
``` | ||
|
||
### React | ||
|
||
```js | ||
import DeckGL from '@deck.gl/react'; | ||
import {LightingEffect} from '@deck.gl/core'; | ||
import {GeoJsonLayer} from '@deck.gl/layers'; | ||
|
||
const lightingEffect = new LightingEffect({ | ||
... | ||
}); | ||
|
||
const INITIAL_VIEW_STATE = { | ||
latitude: 49.254, | ||
longitude: -123.13, | ||
zoom: 11, | ||
pitch: 45 | ||
}; | ||
|
||
<DeckGL | ||
initialViewState={INITIAL_VIEW_STATE} | ||
controller={true} | ||
effects={[lightingEffect]} | ||
layers={[new GeoJsonLayer({ | ||
... | ||
})]} | ||
/> | ||
``` | ||
|
||
## Remarks | ||
|
||
* A default lighting effect is created in deck when user doesn't provide one. | ||
* A default material is created in layers which support material prop. | ||
* Lighting is only applied to extruded polygons or point clouds. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.