Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to luma.gl@9.0.0-alpha.12 (v9-dev) #7533

Merged
merged 1 commit into from Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ocularrc.js
Expand Up @@ -7,7 +7,7 @@ const LUMA_ALIASES_LOCAL = {
'@luma.gl/debug': `${__dirname}/../luma.gl/modules/debug/src`,
'@luma.gl/engine': `${__dirname}/../luma.gl/modules/engine/src`,
'@luma.gl/webgl': `${__dirname}/../luma.gl/modules/webgl/src`,
'@luma.gl/gltools': `${__dirname}/../luma.gl/modules/gltools/src`,
'@luma.gl/webgl-legacy': `${__dirname}/../luma.gl/modules/gltools/src`,
'@luma.gl/shadertools': `${__dirname}/../luma.gl/modules/shadertools/src`,
'@luma.gl/test-utils': `${__dirname}/../luma.gl/modules/test-utils/src`,
'@luma.gl/experimental': `${__dirname}/../luma.gl/modules/experimental/src`
Expand Down
4 changes: 2 additions & 2 deletions examples/layer-browser/package.json
Expand Up @@ -11,8 +11,8 @@
"dependencies": {
"@loaders.gl/ply": "^3.2.10",
"@loaders.gl/gltf": "^3.2.10",
"@luma.gl/experimental": "9.0.0-alpha.11",
"@luma.gl/debug": "9.0.0-alpha.11",
"@luma.gl/experimental": "9.0.0-alpha.12",
"@luma.gl/debug": "9.0.0-alpha.12",
"colorbrewer": "^1.0.0",
"d3-request": "^1.0.6",
"d3-scale": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/playground/package.json
Expand Up @@ -14,7 +14,7 @@
"@loaders.gl/csv": "^3.2.10",
"@loaders.gl/draco": "^3.2.10",
"@loaders.gl/gltf": "^3.2.10",
"@luma.gl/constants": "9.0.0-alpha.11",
"@luma.gl/constants": "9.0.0-alpha.12",
"brace": "^0.11.1",
"deck.gl": "^8.8.0",
"react": "~16.9.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/webpack.config.local.js
Expand Up @@ -32,7 +32,7 @@ function makeLocalDevConfig(EXAMPLE_DIR = LIB_DIR, linkToLuma, linkToMath) {
'@luma.gl/debug': `${ROOT_DIR}/../luma.gl/modules/debug/src`,
'@luma.gl/engine': `${ROOT_DIR}/../luma.gl/modules/engine/src`,
'@luma.gl/webgl': `${ROOT_DIR}/../luma.gl/modules/webgl/src`,
'@luma.gl/gltools': `${ROOT_DIR}/../luma.gl/modules/gltools/src`,
'@luma.gl/webgl-legacy': `${ROOT_DIR}/../luma.gl/modules/gltools/src`,
'@luma.gl/shadertools': `${ROOT_DIR}/../luma.gl/modules/shadertools/src`,
'@luma.gl/experimental': `${ROOT_DIR}/../luma.gl/modules/experimental/src`
};
Expand All @@ -42,7 +42,7 @@ function makeLocalDevConfig(EXAMPLE_DIR = LIB_DIR, linkToLuma, linkToMath) {
'@luma.gl/engine': `${ROOT_DIR}/node_modules/@luma.gl/engine`,
'@luma.gl/webgl': `${ROOT_DIR}/node_modules/@luma.gl/webgl`,
'@luma.gl/webgl': `${ROOT_DIR}/node_modules/@luma.gl/webgl`,
'@luma.gl/gltools': `${ROOT_DIR}/node_modules/@luma.gl/gltools`,
'@luma.gl/webgl-legacy': `${ROOT_DIR}/node_modules/@luma.gl/gltools`,
'@luma.gl/shadertools': `${ROOT_DIR}/node_modules/@luma.gl/shadertools`,
'@luma.gl/experimental': `${ROOT_DIR}/node_modules/@luma.gl/experimental`,
// @luma.gl/experimental is not available in the root node_modules, must be imported
Expand Down
10 changes: 6 additions & 4 deletions modules/aggregation-layers/package.json
Expand Up @@ -30,16 +30,18 @@
"prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env.dev"
},
"dependencies": {
"@luma.gl/constants": "9.0.0-alpha.11",
"@luma.gl/shadertools": "9.0.0-alpha.11",
"@luma.gl/constants": "9.0.0-alpha.12",
"@luma.gl/shadertools": "9.0.0-alpha.12",
"@math.gl/web-mercator": "^3.6.2",
"d3-hexbin": "^0.2.1"
},
"peerDependencies": {
"@deck.gl/core": "^8.0.0",
"@deck.gl/layers": "^8.0.0",
"@luma.gl/api": "9.0.0-alpha.11",
"@luma.gl/core": "9.0.0-alpha.11"
"@luma.gl/api": "9.0.0-alpha.12",
"@luma.gl/core": "9.0.0-alpha.12",
"@luma.gl/engine": "9.0.0-alpha.12",
"@luma.gl/webgl-legacy": "9.0.0-alpha.12"
},
"gitHead": "13ace64fc2cee08c133afc882fc307253489a4e4"
}
2 changes: 1 addition & 1 deletion modules/aggregation-layers/src/aggregation-layer.ts
Expand Up @@ -163,7 +163,7 @@ export default abstract class AggregationLayer<

// override Composite layer private method to create AttributeManager instance
_getAttributeManager() {
return new AttributeManager(this.context.gl, {
return new AttributeManager(this.context.device, {
id: this.props.id,
stats: this.context.stats
});
Expand Down
Expand Up @@ -41,6 +41,7 @@ import {getGridOffset} from '../utils/grid-aggregation-utils';
*/
export function pointToDensityGridDataCPU(props, aggregationParams) {
const hashInfo = pointsToGridHashing(props, aggregationParams);
// @ts-expect-error
const result = getGridLayerDataFromGridHash(hashInfo);

return {
Expand Down
Expand Up @@ -28,8 +28,9 @@ import {
DefaultProps
} from '@deck.gl/core';
import GL from '@luma.gl/constants';
import {Model, CubeGeometry, Buffer} from '@luma.gl/core';
import {CubeGeometry} from '@luma.gl/engine';
import {fp64arithmetic} from '@luma.gl/shadertools';
import {Model, Buffer} from '@luma.gl/webgl-legacy';
import {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';
import type {_GPUGridLayerProps} from './gpu-grid-layer';
import vs from './gpu-grid-cell-layer-vertex.glsl';
Expand Down
Expand Up @@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import {Buffer} from '@luma.gl/core';
import {Buffer} from '@luma.gl/webgl-legacy';
import GL from '@luma.gl/constants';
import {
Accessor,
Expand Down
2 changes: 1 addition & 1 deletion modules/aggregation-layers/src/grid-aggregation-layer.ts
Expand Up @@ -20,7 +20,7 @@

import AggregationLayer, {AggregationLayerProps} from './aggregation-layer';
import GPUGridAggregator from './utils/gpu-grid-aggregation/gpu-grid-aggregator';
import {Buffer} from '@luma.gl/core';
import {Buffer} from '@luma.gl/webgl-legacy';
import {LayerContext, log, UpdateParameters} from '@deck.gl/core';
import GL from '@luma.gl/constants';
import BinSorter from './utils/bin-sorter';
Expand Down
10 changes: 6 additions & 4 deletions modules/aggregation-layers/src/heatmap-layer/heatmap-layer.ts
Expand Up @@ -36,7 +36,7 @@ import {
withParameters,
FEATURES,
hasFeatures
} from '@luma.gl/core';
} from '@luma.gl/webgl-legacy';
import {
Accessor,
AccessorFunction,
Expand Down Expand Up @@ -347,11 +347,12 @@ export default class HeatmapLayer<DataT = any, ExtraPropsT = {}> extends Aggrega
} = {};
const {dimensions} = this.state;
changeFlags.dataChanged =
this.isAttributeChanged() || // if any attribute is changed
this.isAggregationDirty(opts, {
(this.isAttributeChanged() && 'attribute changed') || // if any attribute is changed
(this.isAggregationDirty(opts, {
compareAll: true,
dimension: dimensions.data
});
}) &&
'aggregation is dirty');
changeFlags.viewportChanged = opts.changeFlags.viewportChanged;

const {zoom} = this.state;
Expand Down Expand Up @@ -390,6 +391,7 @@ export default class HeatmapLayer<DataT = any, ExtraPropsT = {}> extends Aggrega
const {device} = this.context;
const {weightsTextureSize} = this.props;

// @ts-expect-error
const textureSize = Math.min(weightsTextureSize, getParameters(device, GL.MAX_TEXTURE_SIZE));
const floatTargetSupport = hasFeatures(device, FLOAT_TARGET_FEATURES);
const {format, type} = getTextureParams({device, floatTargetSupport});
Expand Down
Expand Up @@ -20,7 +20,8 @@

import type {Device} from '@luma.gl/api';
import GL from '@luma.gl/constants';
import {Model, Geometry, Texture2D} from '@luma.gl/core';
import {Model, Texture2D} from '@luma.gl/webgl-legacy';
import {Geometry} from '@luma.gl/engine';
import {Layer, LayerContext, project32} from '@deck.gl/core';
import vs from './triangle-layer-vertex.glsl';
import fs from './triangle-layer-fragment.glsl';
Expand Down
Expand Up @@ -266,7 +266,8 @@ export default class HexagonLayer<ExtraPropsT = {}> extends AggregationLayer<
this.state = {
cpuAggregator,
aggregatorState: cpuAggregator.state,
vertices: null
vertices: null,
layerData: undefined
};
const attributeManager = this.getAttributeManager()!;
attributeManager.add({
Expand All @@ -287,6 +288,7 @@ export default class HexagonLayer<ExtraPropsT = {}> extends AggregationLayer<
if (this.state.aggregatorState.layerData !== aggregatorState.layerData) {
// if user provided custom aggregator and returns hexagonVertices,
// Need to recalculate radius and angle based on vertices
// @ts-expect-error
const {hexagonVertices} = aggregatorState.layerData || {};
this.setState({
vertices: hexagonVertices && this.convertLatLngToMeterOffset(hexagonVertices)
Expand Down
Expand Up @@ -20,8 +20,9 @@

import {Device} from '@luma.gl/api';
import GL from '@luma.gl/constants';
import {Model, Geometry, FEATURES, hasFeatures, Texture2D, DefaultProps} from '@luma.gl/core';
import {Layer, LayerProps, log, picking, UpdateParameters} from '@deck.gl/core';
import {Geometry} from '@luma.gl/engine';
import {Model, FEATURES, hasFeatures, Texture2D} from '@luma.gl/webgl-legacy';
import {Layer, LayerProps, log, picking, UpdateParameters, DefaultProps} from '@deck.gl/core';
import {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';
import vs from './screen-grid-layer-vertex.glsl';
import fs from './screen-grid-layer-fragment.glsl';
Expand All @@ -32,7 +33,9 @@ const DEFAULT_MAXCOLOR = [0, 255, 0, 255];
const COLOR_PROPS = ['minColor', 'maxColor', 'colorRange', 'colorDomain'];

const defaultProps: DefaultProps<ScreenGridCellLayerProps> = {
// @ts-expect-error
cellSizePixels: {value: 100, min: 1},
// @ts-expect-error
cellMarginPixels: {value: 2, min: 0, max: 5},

colorDomain: null,
Expand Down
Expand Up @@ -32,7 +32,7 @@ import {
DefaultProps
} from '@deck.gl/core';
import GL from '@luma.gl/constants';
import type {Texture2D} from '@luma.gl/core';
import type {Texture2D} from '@luma.gl/webgl-legacy';
import GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';
import {AGGREGATION_OPERATION, getValueFunc} from '../utils/aggregation-operation-utils';
import ScreenGridCellLayer from './screen-grid-cell-layer';
Expand Down
Expand Up @@ -91,7 +91,13 @@ export function getValueFunc(aggregation, accessor, context) {
}
}

function wrapAccessor(accessor, context = {}) {
type AccessorContext = {
data?;
index?: number;
indices?: number[];
};

function wrapAccessor(accessor, context: AccessorContext = {}) {
if (Number.isFinite(accessor)) {
return accessor;
}
Expand All @@ -101,7 +107,7 @@ function wrapAccessor(accessor, context = {}) {
};
}

export function wrapGetValueFunc(getValue, context = {}) {
export function wrapGetValueFunc(getValue, context: AccessorContext = {}) {
return pts => {
context.indices = pts.map(pt => pt.index);
return getValue(
Expand Down
8 changes: 5 additions & 3 deletions modules/aggregation-layers/src/utils/cpu-aggregator.ts
Expand Up @@ -124,7 +124,9 @@ const defaultDimensions = [
const defaultGetCellSize = props => props.cellSize;
export default class CPUAggregator {
state = {
layerData: {},
layerData: {
data: undefined
},
dimensions: {
// color: {
// getValue: null,
Expand Down Expand Up @@ -191,7 +193,7 @@ export default class CPUAggregator {
});
}

normalizeResult(result = {}) {
normalizeResult(result: {hexagons?; layerData?} = {}) {
// support previous hexagonAggregator API
if (result.hexagons) {
return {data: result.hexagons, ...result};
Expand Down Expand Up @@ -298,7 +300,7 @@ export default class CPUAggregator {
// prop: 'elevationAggregation'
// }
// }
return Object.values(dimensionStep.triggers).some(item => {
return Object.values(dimensionStep.triggers).some((item: any) => {
if (item.updateTrigger) {
// check based on updateTriggers change first
// if data has changed, always update value
Expand Down
Expand Up @@ -28,7 +28,7 @@ import {
readPixelsToBuffer,
withParameters,
clear
} from '@luma.gl/core';
} from '@luma.gl/webgl-legacy';
import {fp64arithmetic} from '@luma.gl/shadertools';
import {log, project32, _mergeShaders as mergeShaders} from '@deck.gl/core';

Expand Down Expand Up @@ -66,11 +66,15 @@ const REQUIRED_FEATURES = [
FEATURES.TEXTURE_FLOAT
];

export type GPUGridAggregatorProps = {
id?: string;
};

export default class GPUGridAggregator {
// Decode and return aggregation data of given pixel.
static getAggregationData({aggregationData, maxData, minData, maxMinData, pixelIndex}) {
const index = pixelIndex * PIXEL_SIZE;
const results = {};
const results: {cellCount?; cellWeight?; maxCellWieght?; minCellWeight?; totalCount?} = {};
if (aggregationData) {
results.cellCount = aggregationData[index + 3];
results.cellWeight = aggregationData[index];
Expand Down Expand Up @@ -148,18 +152,26 @@ export default class GPUGridAggregator {
maxFramebuffers: {},
equations: {},

shaderOptions: {},
modelDirty: false,

// common resources to be deleted
resources: {},

// results
results: {}
};

id: string;
device: Device;
_hasGPUSupport: boolean;

constructor(device: Device, opts = {}) {
this.id = opts.id || 'gpu-grid-aggregator';
gridAggregationModel;
allAggregationModel;
meanTransform;

constructor(device: Device, props: GPUGridAggregatorProps = {}) {
this.id = props.id || 'gpu-grid-aggregator';
this.device = device;

// gl_InstanceID usage in min/max calculation shaders
Expand Down Expand Up @@ -217,8 +229,8 @@ export default class GPUGridAggregator {
// Reads aggregation data into JS Array object
// For WebGL1, data is available in JS Array objects already.
// For WebGL2, data is read from Buffer objects and cached for subsequent queries.
getData(weightId) {
const data = {};
getData(weightId): {aggregationData?} {
const data: {aggregationData?} = {};
const results = this.state.results;
if (!results[weightId].aggregationData) {
// cache the results if reading from the buffer (WebGL2 path)
Expand Down Expand Up @@ -517,7 +529,7 @@ export default class GPUGridAggregator {
});
}
framebuffers[id].resize(framebufferSize);
equations[id] = EQUATION_MAP[operation] || EQUATION_MAP.SUM;
equations[id] = EQUATION_MAP[operation] || EQUATION_MAP[AGGREGATION_OPERATION.SUM];
// For min/max framebuffers will use default size 1X1
if (needMin || needMax) {
if (needMin && needMax && combineMaxMin) {
Expand Down Expand Up @@ -666,6 +678,7 @@ function getAllAggregationModel(device: Device, instanceCount) {
isInstanced: true,
instanceCount,
attributes: {
// @ts-expect-error
position: [0, 0]
}
});
Expand Down
14 changes: 12 additions & 2 deletions modules/aggregation-layers/src/utils/resource-utils.ts
@@ -1,13 +1,22 @@
import {Device} from '@luma.gl/api';
import GL from '@luma.gl/constants';
import {Framebuffer, Texture2D} from '@luma.gl/core';
import {Framebuffer, Texture2D} from '@luma.gl/webgl-legacy';

const DEFAULT_PARAMETERS = {
[GL.TEXTURE_MAG_FILTER]: GL.NEAREST,
[GL.TEXTURE_MIN_FILTER]: GL.NEAREST
};

export function getFloatTexture(device: Device, opts = {}) {
type FloatTextureOptions = {
id: string;
width?: number;
height?: number;
data?: any;
unpackFlipY?: boolean;
parameters?: Record<GL, GL>;
};

export function getFloatTexture(device: Device, opts: FloatTextureOptions) {
const {
width = 1,
height = 1,
Expand All @@ -25,6 +34,7 @@ export function getFloatTexture(device: Device, opts = {}) {
dataFormat: GL.RGBA,
width,
height,
// @ts-expect-error
unpackFlipY
});
return texture;
Expand Down
5 changes: 3 additions & 2 deletions modules/arcgis/package.json
Expand Up @@ -32,8 +32,9 @@
"peerDependencies": {
"@arcgis/core": "^4.0.0",
"@deck.gl/core": "^8.0.0",
"@luma.gl/core": "9.0.0-alpha.11",
"@luma.gl/constants": "9.0.0-alpha.11"
"@luma.gl/core": "9.0.0-alpha.12",
"@luma.gl/webgl-legacy": "9.0.0-alpha.12",
"@luma.gl/constants": "9.0.0-alpha.12"
},
"dependencies": {
"esri-loader": "^3.3.0"
Expand Down