Skip to content

Commit

Permalink
Merge 14efe4c into ad3f4fc
Browse files Browse the repository at this point in the history
  • Loading branch information
georgios-uber committed Jul 27, 2019
2 parents ad3f4fc + 14efe4c commit b876f91
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
15 changes: 7 additions & 8 deletions examples/website/scenegraph-layer/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,18 @@ export class App extends Component {
id: 'scenegraph-layer',
data,
pickable: true,
sizeScale: 500,
sizeScale: 250,
scenegraph: MODEL_URL,
_animations: ANIMATIONS,
sizeMinPixels: 10,
sizeMaxPixels: 100,
sizePixelsDimension: 64,
getPosition: d => [
d[DATA_INDEX.LONGITUDE] || 0,
d[DATA_INDEX.LATITUDE] || 0,
d[DATA_INDEX.GEO_ALTITUDE] || 0
],
getOrientation: d => [
this._verticalRateToAngle(d),
// TODO: Fix this direction
(d[DATA_INDEX.TRUE_TRACK] || 0) - 180,
90
],
getOrientation: d => [this._verticalRateToAngle(d), -d[DATA_INDEX.TRUE_TRACK] || 0, 90],
getTranslation: [0, 0, 0],
getScale: [1, 1, 1],
transitions: {
Expand All @@ -136,6 +134,7 @@ export class App extends Component {
const track = this.state.hoverObject[DATA_INDEX.TRUE_TRACK] || 0;
return (
<Fragment>
<div>&nbsp;</div>
<div>Unique ID: {icao24}</div>
<div>Call Sign: {callsign}</div>
<div>Country: {originCountry}</div>
Expand Down Expand Up @@ -193,7 +192,7 @@ export class App extends Component {
mapboxApiAccessToken={MAPBOX_TOKEN}
/>
</DeckGL>
{/* this._renderInfoBox() */}
{this._renderInfoBox()}
</Fragment>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ _attribute vec3 instanceTranslation;
// Uniforms
uniform float sizeScale;
uniform vec3 sizePixels;
uniform mat4 sceneModelMatrix;
// Attributes
Expand Down Expand Up @@ -66,7 +67,13 @@ void main(void) {
geometry.uv = pbr_vUV;
#endif
vec3 pos = (instanceModelMatrix * (sceneModelMatrix * POSITION).xyz) * sizeScale + instanceTranslation;
float sizeMinPixels = sizePixels.x;
float sizeMaxPixels = sizePixels.y;
float sizePixelsDimension = sizePixels.z;
float originalSize = project_size_to_pixel(sizePixelsDimension * sizeScale);
float clampSize = clamp(originalSize, sizeMinPixels, sizeMaxPixels);
vec3 pos = (instanceModelMatrix * (sceneModelMatrix * POSITION).xyz) * sizeScale * (clampSize / originalSize) + instanceTranslation;
pos = project_size(pos);
DECKGL_FILTER_SIZE(pos, geometry);
Expand Down
7 changes: 6 additions & 1 deletion modules/mesh-layers/src/scenegraph-layer/scenegraph-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const defaultProps = {
_animations: null,

sizeScale: {type: 'number', value: 1, min: 0},
sizeMinPixels: {type: 'number', min: 0, value: 0},
sizeMaxPixels: {type: 'number', min: 0, value: Number.MAX_SAFE_INTEGER},
sizePixelsDimension: {type: 'number', value: 100, min: 0},

getPosition: {type: 'accessor', value: x => x.position},
getColor: {type: 'accessor', value: DEFAULT_COLOR},

Expand Down Expand Up @@ -254,7 +258,7 @@ export default class ScenegraphLayer extends Layer {
this.state.animator.animate(context.animationProps.time);
}

const {sizeScale} = this.props;
const {sizeScale, sizeMinPixels, sizeMaxPixels, sizePixelsDimension} = this.props;
const numInstances = this.getNumInstances();
this.state.scenegraph.traverse((model, {worldMatrix}) => {
model.model.setInstanceCount(numInstances);
Expand All @@ -263,6 +267,7 @@ export default class ScenegraphLayer extends Layer {
parameters,
uniforms: {
sizeScale,
sizePixels: [sizeMinPixels, sizeMaxPixels, sizePixelsDimension],
sceneModelMatrix: worldMatrix,
// Needed for PBR (TODO: find better way to get it)
u_Camera: model.model.program.uniforms.project_uCameraPosition
Expand Down

0 comments on commit b876f91

Please sign in to comment.