Skip to content

Commit

Permalink
Fix PointCloud sizeUnits as "meters" (#4421)
Browse files Browse the repository at this point in the history
  • Loading branch information
twojtasz committed Mar 25, 2020
1 parent 9bdd6b7 commit 73cc764
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/layers/src/point-cloud-layer/point-cloud-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default class PointCloudLayer extends Layer {
const {viewport} = this.context;
const {pointSize, sizeUnits} = this.props;

const sizeMultiplier = sizeUnits === 'meters' ? viewport.distanceScales.pixelsPerMeter[2] : 1;
const sizeMultiplier = sizeUnits === 'meters' ? 1 / viewport.metersPerPixel : 1;

this.state.model
.setUniforms(
Expand Down
22 changes: 22 additions & 0 deletions test/modules/layers/point-cloud-layer.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import test from 'tape-catch';
import {testLayer} from '@deck.gl/test-utils';
import {equals} from 'math.gl';

import {PointCloudLayer} from '@deck.gl/layers';

Expand Down Expand Up @@ -32,6 +33,27 @@ test('PointCloudLayer#loaders.gl support', t => {
'used external attribute'
);
}
},
{
updateProps: {
sizeUnits: 'meters'
},
onAfterUpdate: ({layer}) => {
const uniforms = layer.state.model.getUniforms();
t.ok(
equals(uniforms.radiusPixels, 0.000255808143),
'radiusPixels correct for sizeUnits "meters"'
);
}
},
{
updateProps: {
sizeUnits: 'pixels'
},
onAfterUpdate: ({layer}) => {
const uniforms = layer.state.model.getUniforms();
t.is(uniforms.radiusPixels, 10, 'radiusPixels is correct for sizeUnits "pixels"');
}
}
];

Expand Down

0 comments on commit 73cc764

Please sign in to comment.