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
1 parent
3f47a95
commit ba77287
Showing
9 changed files
with
114 additions
and
27 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,17 @@ | ||
import PointLight from './point-light'; | ||
import {getUniformsFromViewport} from '../../shaderlib/project/viewport-uniforms'; | ||
|
||
export default class CameraLight extends PointLight { | ||
getProjectedLight({layer}) { | ||
const viewport = layer.context.viewport; | ||
const {coordinateSystem, coordinateOrigin, modelMatrix} = layer.props; | ||
const {project_uCameraPosition} = getUniformsFromViewport({ | ||
viewport, | ||
modelMatrix, | ||
coordinateSystem, | ||
coordinateOrigin | ||
}); | ||
this.projectedLight.position = project_uCameraPosition; | ||
return this.projectedLight; | ||
} | ||
} |
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,7 @@ | ||
import {DirectionalLight as BaseDirectionalLight} from '@luma.gl/core'; | ||
|
||
export default class DirectionalLight extends BaseDirectionalLight { | ||
getProjectedLight() { | ||
return this; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {PointLight as BasePointLight} from '@luma.gl/core'; | ||
import {projectPosition} from '../../shaderlib/project/project-functions'; | ||
import {COORDINATE_SYSTEM} from '../../lib'; | ||
|
||
export default class PointLight extends BasePointLight { | ||
constructor(props) { | ||
super(props); | ||
this.projectedLight = new BasePointLight(props); | ||
} | ||
|
||
getProjectedLight({layer}) { | ||
const viewport = layer.context.viewport; | ||
const {coordinateSystem, coordinateOrigin} = layer.props; | ||
const position = projectPosition(this.position, { | ||
viewport, | ||
coordinateSystem, | ||
coordinateOrigin, | ||
fromCoordinateSystem: viewport.isGeospatial | ||
? COORDINATE_SYSTEM.LNGLAT | ||
: COORDINATE_SYSTEM.IDENTITY, | ||
fromCoordinateOrigin: [0, 0, 0] | ||
}); | ||
this.projectedLight.position = position; | ||
return this.projectedLight; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './lighting-effect.spec'; |
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,39 @@ | ||
import test from 'tape-catch'; | ||
import LightingEffect from '@deck.gl/core/effects/lighting/lighting-effect'; | ||
import {experimental} from '@deck.gl/core'; | ||
const {CameraLight} = experimental; | ||
|
||
import {MapView, PolygonLayer} from 'deck.gl'; | ||
import * as FIXTURES from 'deck.gl-test/data'; | ||
|
||
test('LightingEffect#constructor', t => { | ||
const lightingEffect = new LightingEffect(); | ||
t.ok(lightingEffect, 'Lighting effect created'); | ||
t.ok(lightingEffect.ambientLight, 'Default ambient light created'); | ||
t.equal(lightingEffect.directionalLights.length, 2, 'Default directional lights created'); | ||
t.end(); | ||
}); | ||
|
||
test('LightingEffect#CameraLight', t => { | ||
const cameraLight = new CameraLight(); | ||
const lightEffect = new LightingEffect({cameraLight}); | ||
|
||
const viewport = new MapView().makeViewport({ | ||
width: 100, | ||
height: 100, | ||
viewState: {longitude: -122, latitude: 37, zoom: 13} | ||
}); | ||
|
||
const layer = new PolygonLayer({ | ||
data: FIXTURES.polygons.slice(0, 3), | ||
getPolygon: f => f, | ||
getFillColor: (f, {index}) => [index, 0, 0] | ||
}); | ||
|
||
layer.context = {viewport}; | ||
|
||
const projectedLights = lightEffect.getProjectedPointLights(layer); | ||
t.ok(projectedLights[0], 'Camera light is ok'); | ||
t.deepEqual(projectedLights[0].position, [0, 0, 150], 'Camera light projection is ok'); | ||
t.end(); | ||
}); |
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 |
---|---|---|
|
@@ -27,3 +27,4 @@ import './shaderlib'; | |
import './transitions'; | ||
import './experimental'; | ||
import './passes'; | ||
import './effects'; |