Skip to content

Commit

Permalink
Core util exports audit (visgl#1843)
Browse files Browse the repository at this point in the history
Changes to @deck.gl/core experimental exports:

| old | new |
| ---- | ---- |
| clamp | removed - import from `math.gl` instead |
| lerp | removed - import from `math.gl` instead |
| log | promoted to official API |
| get | removed |
| count | removed |
| flatten | removed |
| countVertices | removed |
| enable64bitSupport | removed - use `layer.is64bitEnabled()` instead |
| fp64ify | removed - import from `luma.gl` instead |
| fp64LowPart | removed - import from `luma.gl` instead |
  • Loading branch information
Pessimistress authored May 21, 2018
1 parent a8c1ca5 commit 8043c0f
Show file tree
Hide file tree
Showing 37 changed files with 190 additions and 391 deletions.
2 changes: 1 addition & 1 deletion docs/layers/geojson-layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Note: This accessor is only called for `Polygon` and `MultiPolygon` and `Point`

##### `getRadius` (Function|Number, optional)

* Default: `f => f.properties.radius || f => f.properties.size || 1`
* Default: `f => f.properties.radius || f.properties.size || 1`

The radius of `Point` and `MultiPoint` feature, in meters.

Expand Down
6 changes: 3 additions & 3 deletions docs/layers/solid-polygon-layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Be aware that this prop will likely be changed in a future version of deck.gl.

##### `getPolygon` (Function, optional)

* Default: `object => object.polygon || object.geometry.coordinates`
* Default: `object => object.polygon`

Like any deck.gl layer, the polygon accepts a data prop which is expected to
be an iterable container of objects, and an accessor
Expand All @@ -96,7 +96,7 @@ This accessor returns the polygon corresponding to an object in the `data` strea

##### `getFillColor` (Function|Array, optional)

* Default: `object => object.fillColor || object.properties.color || [0, 0, 0, 255]`
* Default: `object => object.fillColor || [0, 0, 0, 255]`

The rgba fill color of each object's polygon, in `r, g, b, [a]`. Each component is in the 0-255 range.

Expand All @@ -105,7 +105,7 @@ The rgba fill color of each object's polygon, in `r, g, b, [a]`. Each component

##### `getLineColor` (Function|Array, optional)

* Default: `object => object.lineColor || object.properties.color || [0, 0, 0, 255]`
* Default: `object => object.lineColor || [0, 0, 0, 255]`

The rgba stroke color of each object's polygon, in `r, g, b, [a]`. Each component is in the 0-255 range.

Expand Down
36 changes: 17 additions & 19 deletions examples/layer-browser/src/examples/core-layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import {
} from 'deck.gl';

// Demonstrate immutable support
import {experimental} from 'deck.gl';
const {get} = experimental;
import * as dataSamples from '../data-samples';
import {parseColor, setOpacity} from '../utils/color';

Expand Down Expand Up @@ -59,8 +57,8 @@ const IconLayerExample = {
sizeScale: 24,
getPosition: d => d.COORDINATES,
getColor: d => [64, 64, 72],
getIcon: d => (get(d, 'PLACEMENT') === 'SW' ? 'marker' : 'marker-warning'),
getSize: d => (get(d, 'RACKS') > 2 ? 2 : 1),
getIcon: d => (d.PLACEMENT === 'SW' ? 'marker' : 'marker-warning'),
getSize: d => (d.RACKS > 2 ? 2 : 1),
opacity: 0.8,
pickable: true
}
Expand Down Expand Up @@ -97,8 +95,8 @@ const GeoJsonLayerExtrudedExample = {
getData: () => dataSamples.choropleths,
props: {
id: 'geojsonLayer-extruded',
getElevation: f => ((get(f, 'properties.ZIP_CODE') * 10) % 127) * 10,
getFillColor: f => [0, 100, (get(f, 'properties.ZIP_CODE') * 55) % 255],
getElevation: f => ((f.properties.ZIP_CODE * 10) % 127) * 10,
getFillColor: f => [0, 100, (f.properties.ZIP_CODE * 55) % 255],
getLineColor: f => [200, 0, 80],
extruded: true,
wireframe: true,
Expand Down Expand Up @@ -141,7 +139,7 @@ const PathLayerExample = {
props: {
id: 'pathLayer',
opacity: 0.6,
getPath: f => get(f, 'path'),
getPath: f => f.path,
getColor: f => [128, 0, 0],
getWidth: f => 10,
widthMinPixels: 1,
Expand All @@ -154,7 +152,7 @@ const ScreenGridLayerExample = {
getData: () => dataSamples.points,
props: {
id: 'screenGridLayer',
getPosition: d => get(d, 'COORDINATES'),
getPosition: d => d.COORDINATES,
cellSizePixels: 40,
minColor: [0, 0, 80, 0],
maxColor: [100, 255, 0, 128],
Expand All @@ -167,9 +165,9 @@ const LineLayerExample = {
getData: () => dataSamples.routes,
props: {
id: 'lineLayer',
getSourcePosition: d => get(d, 'START'),
getTargetPosition: d => get(d, 'END'),
getColor: d => (get(d, 'SERVICE') === 'WEEKDAY' ? [255, 64, 0] : [255, 200, 0]),
getSourcePosition: d => d.START,
getTargetPosition: d => d.END,
getColor: d => (d.SERVICE === 'WEEKDAY' ? [255, 64, 0] : [255, 200, 0]),
pickable: true
}
};
Expand All @@ -179,9 +177,9 @@ const ScatterplotLayerExample = {
getData: () => dataSamples.points,
props: {
id: 'scatterplotLayer',
getPosition: d => get(d, 'COORDINATES'),
getPosition: d => d.COORDINATES,
getColor: d => [255, 128, 0],
getRadius: d => get(d, 'SPACES'),
getRadius: d => d.SPACES,
opacity: 1,
pickable: true,
radiusScale: 30,
Expand All @@ -199,8 +197,8 @@ const GridCellLayerExample = {
extruded: true,
pickable: true,
opacity: 1,
getColor: g => [245, 166, get(g, 'value') * 255, 255],
getElevation: h => get(h, 'value') * 5000,
getColor: d => [245, 166, d.value * 255, 255],
getElevation: d => d.value * 5000,
lightSettings: LIGHT_SETTINGS
}
};
Expand Down Expand Up @@ -242,7 +240,7 @@ const GridLayerExample = {
opacity: 1,
extruded: true,
pickable: true,
getPosition: d => get(d, 'COORDINATES'),
getPosition: d => d.COORDINATES,
getColorValue,
getElevationValue,
lightSettings: LIGHT_SETTINGS
Expand All @@ -259,8 +257,8 @@ const HexagonCellLayerExample = {
extruded: true,
pickable: true,
opacity: 1,
getColor: h => [48, 128, get(h, 'value') * 255, 255],
getElevation: h => get(h, 'value') * 5000,
getColor: d => [48, 128, d.value * 255, 255],
getElevation: d => d.value * 5000,
lightSettings: LIGHT_SETTINGS
}
};
Expand All @@ -277,7 +275,7 @@ const HexagonLayerExample = {
elevationScale: 1,
elevationRange: [0, 3000],
coverage: 1,
getPosition: d => get(d, 'COORDINATES'),
getPosition: d => d.COORDINATES,
getColorValue,
getElevationValue,
lightSettings: LIGHT_SETTINGS
Expand Down
8 changes: 4 additions & 4 deletions modules/core-layers/src/arc-layer/arc-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import {COORDINATE_SYSTEM, Layer, experimental} from '@deck.gl/core';
const {log, fp64LowPart, enable64bitSupport} = experimental;
import {COORDINATE_SYSTEM, Layer, log} from '@deck.gl/core';

import {GL, Model, Geometry} from 'luma.gl';
import {GL, Model, Geometry, fp64} from 'luma.gl';
const {fp64LowPart} = fp64;

import vs from './arc-layer-vertex.glsl';
import vs64 from './arc-layer-vertex-64.glsl';
Expand Down Expand Up @@ -52,7 +52,7 @@ export default class ArcLayer extends Layer {
}

getShaders() {
return enable64bitSupport(this.props)
return this.is64bitEnabled()
? {vs: vs64, fs, modules: ['project64', 'picking']}
: {vs, fs, modules: ['picking']}; // 'project' module added by default.
}
Expand Down
13 changes: 6 additions & 7 deletions modules/core-layers/src/geojson-layer/geojson-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import {CompositeLayer, experimental} from '@deck.gl/core';
const {get} = experimental;
import {CompositeLayer} from '@deck.gl/core';
import ScatterplotLayer from '../scatterplot-layer/scatterplot-layer';
import PathLayer from '../path-layer/path-layer';
// Use primitive layer to avoid "Composite Composite" layers for now
Expand Down Expand Up @@ -51,15 +50,15 @@ const defaultProps = {
fp64: false,

// Line and polygon outline color
getLineColor: f => get(f, 'properties.lineColor') || defaultLineColor,
getLineColor: f => (f.properties && f.properties.lineColor) || defaultLineColor,
// Point and polygon fill color
getFillColor: f => get(f, 'properties.fillColor') || defaultFillColor,
getFillColor: f => (f.properties && f.properties.fillColor) || defaultFillColor,
// Point radius
getRadius: f => get(f, 'properties.radius') || get(f, 'properties.size') || 1,
getRadius: f => (f.properties && (f.properties.radius || f.properties.size)) || 1,
// Line and polygon outline accessors
getLineWidth: f => get(f, 'properties.lineWidth') || 1,
getLineWidth: f => (f.properties && f.properties.lineWidth) || 1,
// Polygon extrusion accessor
getElevation: f => get(f, 'properties.elevation') || 1000,
getElevation: f => (f.properties && f.properties.elevation) || 1000,

subLayers: {
PointLayer: ScatterplotLayer,
Expand Down
10 changes: 5 additions & 5 deletions modules/core-layers/src/grid-cell-layer/grid-cell-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import {Layer, experimental} from '@deck.gl/core';
const {fp64LowPart, enable64bitSupport} = experimental;
import {GL, Model, CubeGeometry} from 'luma.gl';
import {Layer} from '@deck.gl/core';
import {GL, Model, CubeGeometry, fp64} from 'luma.gl';
const {fp64LowPart} = fp64;

import vs from './grid-cell-layer-vertex.glsl';
import fs from './grid-cell-layer-fragment.glsl';
Expand Down Expand Up @@ -56,7 +56,7 @@ export default class GridCellLayer extends Layer {
*/

getShaders() {
const projectModule = enable64bitSupport(this.props) ? 'project64' : 'project32';
const projectModule = this.is64bitEnabled() ? 'project64' : 'project32';
return {vs, fs, modules: [projectModule, 'lighting', 'picking']};
}

Expand Down Expand Up @@ -138,7 +138,7 @@ export default class GridCellLayer extends Layer {
}

calculateInstancePositions64xyLow(attribute) {
const isFP64 = enable64bitSupport(this.props);
const isFP64 = this.is64bitEnabled();
attribute.isGeneric = !isFP64;

if (!isFP64) {
Expand Down
10 changes: 5 additions & 5 deletions modules/core-layers/src/hexagon-cell-layer/hexagon-cell-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import {Layer, experimental} from '@deck.gl/core';
const {log, fp64LowPart, enable64bitSupport} = experimental;
import {GL, Model, CylinderGeometry} from 'luma.gl';
import {Layer, log} from '@deck.gl/core';
import {GL, Model, CylinderGeometry, fp64} from 'luma.gl';
const {fp64LowPart} = fp64;

import vs from './hexagon-cell-layer-vertex.glsl';
import fs from './hexagon-cell-layer-fragment.glsl';
Expand Down Expand Up @@ -72,7 +72,7 @@ export default class HexagonCellLayer extends Layer {
}

getShaders() {
const projectModule = enable64bitSupport(this.props) ? 'project64' : 'project32';
const projectModule = this.is64bitEnabled() ? 'project64' : 'project32';
return {vs, fs, modules: [projectModule, 'lighting', 'picking']};
}

Expand Down Expand Up @@ -211,7 +211,7 @@ export default class HexagonCellLayer extends Layer {
}

calculateInstancePositions64xyLow(attribute) {
const isFP64 = enable64bitSupport(this.props);
const isFP64 = this.is64bitEnabled();
attribute.isGeneric = !isFP64;

if (!isFP64) {
Expand Down
4 changes: 2 additions & 2 deletions modules/core-layers/src/hexagon-layer/hexagon-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import {CompositeLayer, experimental} from '@deck.gl/core';
import {CompositeLayer, log, experimental} from '@deck.gl/core';
import HexagonCellLayer from '../hexagon-cell-layer/hexagon-cell-layer';

const {log, BinSorter, getQuantizeScale, getLinearScale, defaultColorRange} = experimental;
const {BinSorter, getQuantizeScale, getLinearScale, defaultColorRange} = experimental;

import {pointToHexbin} from './hexagon-aggregator';

Expand Down
10 changes: 5 additions & 5 deletions modules/core-layers/src/icon-layer/icon-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import {Layer, experimental} from '@deck.gl/core';
const {fp64LowPart, enable64bitSupport} = experimental;
import {GL, Model, Geometry, Texture2D, loadTextures} from 'luma.gl';
import {Layer} from '@deck.gl/core';
import {GL, Model, Geometry, Texture2D, loadTextures, fp64} from 'luma.gl';
const {fp64LowPart} = fp64;

import vs from './icon-layer-vertex.glsl';
import fs from './icon-layer-fragment.glsl';
Expand Down Expand Up @@ -67,7 +67,7 @@ const defaultProps = {

export default class IconLayer extends Layer {
getShaders() {
const projectModule = enable64bitSupport(this.props) ? 'project64' : 'project32';
const projectModule = this.is64bitEnabled() ? 'project64' : 'project32';
return {vs, fs, modules: [projectModule, 'picking']};
}

Expand Down Expand Up @@ -240,7 +240,7 @@ export default class IconLayer extends Layer {
*/

calculateInstancePositions64xyLow(attribute) {
const isFP64 = enable64bitSupport(this.props);
const isFP64 = this.is64bitEnabled();
attribute.isGeneric = !isFP64;

if (!isFP64) {
Expand Down
10 changes: 5 additions & 5 deletions modules/core-layers/src/line-layer/line-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import {Layer, experimental} from '@deck.gl/core';
const {log, fp64LowPart, enable64bitSupport} = experimental;
import {GL, Model, Geometry} from 'luma.gl';
import {Layer, log} from '@deck.gl/core';
import {GL, Model, Geometry, fp64} from 'luma.gl';
const {fp64LowPart} = fp64;

import vs from './line-layer-vertex.glsl';
import fs from './line-layer-fragment.glsl';
Expand Down Expand Up @@ -49,7 +49,7 @@ export default class LineLayer extends Layer {
}

getShaders() {
const projectModule = enable64bitSupport(this.props) ? 'project64' : 'project32';
const projectModule = this.is64bitEnabled() ? 'project64' : 'project32';
return {vs, fs, modules: [projectModule, 'picking']};
}

Expand Down Expand Up @@ -130,7 +130,7 @@ export default class LineLayer extends Layer {
}

calculateInstanceSourceTargetPositions64xyLow(attribute) {
const isFP64 = enable64bitSupport(this.props);
const isFP64 = this.is64bitEnabled();
attribute.isGeneric = !isFP64;

if (!isFP64) {
Expand Down
8 changes: 4 additions & 4 deletions modules/core-layers/src/path-layer/path-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import {COORDINATE_SYSTEM, Layer, experimental} from '@deck.gl/core';
const {fp64LowPart, enable64bitSupport} = experimental;
import {GL, Model, Geometry} from 'luma.gl';
import {COORDINATE_SYSTEM, Layer} from '@deck.gl/core';
import {GL, Model, Geometry, fp64} from 'luma.gl';
const {fp64LowPart} = fp64;

import vs from './path-layer-vertex.glsl';
import vs64 from './path-layer-vertex-64.glsl';
Expand Down Expand Up @@ -55,7 +55,7 @@ const isClosed = path => {

export default class PathLayer extends Layer {
getShaders() {
return enable64bitSupport(this.props)
return this.is64bitEnabled()
? {vs: vs64, fs, modules: ['project64', 'picking']}
: {vs, fs, modules: ['picking']}; // 'project' module added by default.
}
Expand Down
10 changes: 5 additions & 5 deletions modules/core-layers/src/point-cloud-layer/point-cloud-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import {Layer, experimental} from '@deck.gl/core';
const {fp64LowPart, enable64bitSupport} = experimental;
import {GL, Model, Geometry} from 'luma.gl';
import {Layer} from '@deck.gl/core';
import {GL, Model, Geometry, fp64} from 'luma.gl';
const {fp64LowPart} = fp64;

import vs from './point-cloud-layer-vertex.glsl';
import fs from './point-cloud-layer-fragment.glsl';
Expand All @@ -40,7 +40,7 @@ const defaultProps = {

export default class PointCloudLayer extends Layer {
getShaders(id) {
const projectModule = enable64bitSupport(this.props) ? 'project64' : 'project32';
const projectModule = this.is64bitEnabled() ? 'project64' : 'project32';
return {vs, fs, modules: [projectModule, 'lighting', 'picking']};
}

Expand Down Expand Up @@ -120,7 +120,7 @@ export default class PointCloudLayer extends Layer {
}

calculateInstancePositions64xyLow(attribute) {
const isFP64 = enable64bitSupport(this.props);
const isFP64 = this.is64bitEnabled();
attribute.isGeneric = !isFP64;

if (!isFP64) {
Expand Down
Loading

0 comments on commit 8043c0f

Please sign in to comment.