Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@deck.gl/extensions

Package Overview
Dependencies
Maintainers
7
Versions
365
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deck.gl/extensions - npm Package Compare versions

Comparing version 9.0.0-beta.10 to 9.0.0-beta.11

6

dist/collision-filter/collision-filter-effect.d.ts
import { Device, Framebuffer, Texture } from '@luma.gl/core';
import type { Effect, Layer, PreRenderOptions } from '@deck.gl/core';
import type { Effect, EffectContext, Layer, PreRenderOptions } from '@deck.gl/core';
export default class CollisionFilterEffect implements Effect {

@@ -8,2 +8,3 @@ id: string;

order: number;
private context?;
private channels;

@@ -14,3 +15,4 @@ private collisionFilterPass?;

private lastViewport?;
preRender(device: Device, { effects: allEffects, layers, layerFilter, viewports, onViewportActive, views, isPicking, preRenderStats }: PreRenderOptions): void;
setup(context: EffectContext): void;
preRender({ effects: allEffects, layers, layerFilter, viewports, onViewportActive, views, isPicking, preRenderStats }: PreRenderOptions): void;
private _render;

@@ -17,0 +19,0 @@ /**

import { equals } from '@math.gl/core';
import { _deepEqual as deepEqual } from '@deck.gl/core';
import CollisionFilterPass from "./collision-filter-pass.js";
import MaskEffect from "../mask/mask-effect.js";
// Factor by which to downscale Collision FBO relative to canvas

@@ -16,6 +15,11 @@ const DOWNSCALE = 2;

}
preRender(device, { effects: allEffects, layers, layerFilter, viewports, onViewportActive, views, isPicking, preRenderStats = {} }) {
if (!this.dummyCollisionMap) {
this.dummyCollisionMap = device.createTexture({ width: 1, height: 1 });
}
setup(context) {
this.context = context;
const { device } = context;
this.dummyCollisionMap = device.createTexture({ width: 1, height: 1 });
this.collisionFilterPass = new CollisionFilterPass(device, { id: 'default-collision-filter' });
}
preRender({ effects: allEffects, layers, layerFilter, viewports, onViewportActive, views, isPicking, preRenderStats = {} }) {
// This can only be called in preRender() after setup() where context is populated
const { device } = this.context;
if (isPicking) {

@@ -32,7 +36,4 @@ // Do not update on picking pass

}
if (!this.collisionFilterPass) {
this.collisionFilterPass = new CollisionFilterPass(device, { id: 'default-collision-filter' });
}
// Detect if mask has rendered. TODO: better dependency system for Effects
const effects = allEffects?.filter(e => e.constructor === MaskEffect);
const effects = allEffects?.filter(e => e.useInPicking && preRenderStats[e.id]);
const maskEffectRendered = preRenderStats['mask-effect']?.didRender;

@@ -39,0 +40,0 @@ // Collect layers to render

import { Framebuffer } from '@luma.gl/core';
import { _LayersPass as LayersPass, LayersPassRenderOptions } from '@deck.gl/core';
import { Layer, _LayersPass as LayersPass, LayersPassRenderOptions, Viewport } from '@deck.gl/core';
type CollisionFilterPassRenderOptions = LayersPassRenderOptions & {};
export default class CollisionFilterPass extends LayersPass {
renderCollisionMap(target: Framebuffer, options: CollisionFilterPassRenderOptions): any;
renderCollisionMap(target: Framebuffer, options: CollisionFilterPassRenderOptions): void;
protected getLayerParameters(layer: Layer, layerIndex: number, viewport: Viewport): any;
getModuleParameters(): {

@@ -7,0 +8,0 @@ drawToCollisionMap: boolean;

@@ -6,10 +6,8 @@ import { _LayersPass as LayersPass } from '@deck.gl/core';

const clearColor = [0, 0, 0, 0];
return this.device.withParametersWebGL({
scissorTest: true,
scissor: [padding, padding, target.width - 2 * padding, target.height - 2 * padding],
blend: false,
depthTest: true,
depthRange: [0, 1]
}, () => this.render({ ...options, clearColor, target, pass: 'collision' }));
const scissorRect = [padding, padding, target.width - 2 * padding, target.height - 2 * padding];
this.render({ ...options, clearColor, scissorRect, target, pass: 'collision' });
}
getLayerParameters(layer, layerIndex, viewport) {
return { ...layer.props.parameters, blend: false, depthRange: [0, 1], depthTest: true };
}
getModuleParameters() {

@@ -16,0 +14,0 @@ // Draw picking colors into collision FBO

@@ -59,11 +59,11 @@ import type { Layer, LayerContext, Accessor, UpdateParameters } from '@deck.gl/core';

/**
* The size of the category filter (number of columns to filter by). The category filter can show/hide data based on 1-4 properties of each object.
* @default 1
* The size of the category filter (number of columns to filter by). The category filter can show/hide data based on 1-4 properties of each object. Set to `0` to disable category filtering.
* @default 0
*/
categorySize?: 1 | 2 | 3 | 4;
categorySize?: 0 | 1 | 2 | 3 | 4;
/**
* The size of the filter (number of columns to filter by). The data filter can show/hide data based on 1-4 numeric properties of each object.
* The size of the filter (number of columns to filter by). The data filter can show/hide data based on 1-4 numeric properties of each object. Set to `0` to disable numeric filtering.
* @default 1
*/
filterSize?: 1 | 2 | 3 | 4;
filterSize?: 0 | 1 | 2 | 3 | 4;
/**

@@ -70,0 +70,0 @@ * Use 64-bit precision instead of 32-bit.

@@ -35,3 +35,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

const defaultOptions = {
categorySize: 1,
categorySize: 0,
filterSize: 1,

@@ -56,11 +56,12 @@ fp64: false,

const { categorySize, filterSize, fp64 } = extension.opts;
return {
modules: [fp64 ? shaderModule64 : shaderModule],
defines: {
DATACATEGORY_TYPE: DATA_TYPE_FROM_SIZE[categorySize],
DATACATEGORY_CHANNELS: categorySize,
DATAFILTER_TYPE: DATA_TYPE_FROM_SIZE[filterSize],
DATAFILTER_DOUBLE: Boolean(fp64)
}
};
const defines = {};
if (categorySize) {
defines.DATACATEGORY_TYPE = DATA_TYPE_FROM_SIZE[categorySize];
defines.DATACATEGORY_CHANNELS = categorySize;
}
if (filterSize) {
defines.DATAFILTER_TYPE = DATA_TYPE_FROM_SIZE[filterSize];
defines.DATAFILTER_DOUBLE = Boolean(fp64);
}
return { modules: [fp64 ? shaderModule64 : shaderModule], defines };
}

@@ -71,32 +72,38 @@ initializeState(context, extension) {

if (attributeManager) {
attributeManager.add({
filterValues: {
size: filterSize,
type: fp64 ? 'float64' : 'float32',
accessor: 'getFilterValue',
shaderAttributes: {
filterValues: {
divisor: 0
},
instanceFilterValues: {
divisor: 1
if (filterSize) {
attributeManager.add({
filterValues: {
size: filterSize,
type: fp64 ? 'float64' : 'float32',
accessor: 'getFilterValue',
shaderAttributes: {
filterValues: {
divisor: 0
},
instanceFilterValues: {
divisor: 1
}
}
}
},
filterCategoryValues: {
size: categorySize,
accessor: 'getFilterCategory',
transform: categorySize === 1
? d => extension._getCategoryKey.call(this, d, 0)
: d => d.map((x, i) => extension._getCategoryKey.call(this, x, i)),
shaderAttributes: {
filterCategoryValues: {
divisor: 0
},
instanceFilterCategoryValues: {
divisor: 1
});
}
if (categorySize) {
attributeManager.add({
filterCategoryValues: {
size: categorySize,
accessor: 'getFilterCategory',
transform: categorySize === 1
? d => extension._getCategoryKey.call(this, d, 0)
: d => d.map((x, i) => extension._getCategoryKey.call(this, x, i)),
shaderAttributes: {
filterCategoryValues: {
divisor: 0
},
instanceFilterCategoryValues: {
divisor: 1
}
}
}
}
});
});
}
}

@@ -139,3 +146,3 @@ const { device } = this.context;

// attributeManager must be defined for filterModel to be set
attributeManager.attributes.filterValues.needsUpdate() ||
attributeManager.attributes.filterValues?.needsUpdate() ||
attributeManager.attributes.filterCategoryValues?.needsUpdate() ||

@@ -185,3 +192,3 @@ props.filterEnabled !== oldProps.filterEnabled ||

filterModel.setAttributes({
...filterValues.getValue(),
...filterValues?.getValue(),
...filterCategoryValues?.getValue(),

@@ -188,0 +195,0 @@ ...filterIndices?.getValue()

import type { ShaderModule } from '@luma.gl/shadertools';
import type { DataFilterExtensionProps } from "./data-filter-extension.js";
export type Defines = {
/**
* Primitive type of parameter used for category filtering. If undefined, category filtering disabled.
*/
DATACATEGORY_TYPE?: 'float' | 'vec2' | 'vec3' | 'vec4';
/**
* Number of category filtering channels. Must match dimension of `DATACATEGORY_TYPE`
*/
DATACATEGORY_CHANNELS?: 1 | 2 | 3 | 4;
/**
* Primitive type of parameter used for numeric filtering. If undefined, numeric filtering disabled.
*/
DATAFILTER_TYPE?: 'float' | 'vec2' | 'vec3' | 'vec4';
/**
* Enable 64-bit precision in numeric filter.
*/
DATAFILTER_DOUBLE?: boolean;
/**
* Numeric filter attribute
*/
DATAFILTER_ATTRIB?: 'filterValues' | 'instanceFilterValues';
/**
* Numeric filter attribute (low bits). Only used when `DATAFILTER_DOUBLE = true`
*/
DATAFILTER_ATTRIB_64LOW?: 'filterValues64Low' | 'instanceFilterValues64Low';
/**
* Category filter attribute
*/
DATACATEGORY_ATTRIB?: 'filterCategoryValues' | 'instanceFilterCategoryValues';
};
type DataFilterModuleSettings = {

@@ -4,0 +34,0 @@ extensions: any[];

import { glsl } from "../utils/syntax-tags.js";
/*
* data filter shader module
*/
const vs = `
uniform bool filter_useSoftMargin;
uniform bool filter_enabled;
uniform bool filter_transformSize;
uniform ivec4 filter_categoryBitMask;
#ifdef DATAFILTER_TYPE
uniform DATAFILTER_TYPE filter_min;

@@ -10,14 +12,8 @@ uniform DATAFILTER_TYPE filter_softMin;

uniform DATAFILTER_TYPE filter_max;
uniform bool filter_useSoftMargin;
uniform bool filter_enabled;
uniform bool filter_transformSize;
uniform ivec4 filter_categoryBitMask;
#ifdef NON_INSTANCED_MODEL
#define DATAFILTER_ATTRIB filterValues
#define DATAFILTER_ATTRIB_64LOW filterValues64Low
#define DATACATEGORY_ATTRIB filterCategoryValues
#else
#define DATAFILTER_ATTRIB instanceFilterValues
#define DATAFILTER_ATTRIB_64LOW instanceFilterValues64Low
#define DATACATEGORY_ATTRIB instanceFilterCategoryValues
#endif

@@ -30,3 +26,11 @@ in DATAFILTER_TYPE DATAFILTER_ATTRIB;

#endif
#endif
#ifdef DATACATEGORY_TYPE
#ifdef NON_INSTANCED_MODEL
#define DATACATEGORY_ATTRIB filterCategoryValues
#else
#define DATACATEGORY_ATTRIB instanceFilterCategoryValues
#endif
in DATACATEGORY_TYPE DATACATEGORY_ATTRIB;
#endif
out float dataFilter_value;

@@ -45,9 +49,16 @@ float dataFilter_reduceValue(float value) {

}
void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax, DATACATEGORY_TYPE category) {
if (filter_enabled) {
#ifdef DATAFILTER_TYPE
void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax) {
if (filter_useSoftMargin) {
dataFilter_value = dataFilter_reduceValue(
smoothstep(filter_min, filter_softMin, valueFromMin) *
(1.0 - smoothstep(filter_softMax, filter_max, valueFromMax))
DATAFILTER_TYPE leftInRange = mix(
smoothstep(filter_min, filter_softMin, valueFromMin),
step(filter_min, valueFromMin),
step(filter_softMin, filter_min)
);
DATAFILTER_TYPE rightInRange = mix(
1.0 - smoothstep(filter_softMax, filter_max, valueFromMax),
step(valueFromMax, filter_max),
step(filter_max, filter_softMax)
);
dataFilter_value = dataFilter_reduceValue(leftInRange * rightInRange);
} else {

@@ -58,2 +69,6 @@ dataFilter_value = dataFilter_reduceValue(

}
}
#endif
#ifdef DATACATEGORY_ATTRIB
void dataFilter_setCategoryValue(DATACATEGORY_TYPE category) {
#if DATACATEGORY_CHANNELS == 1

@@ -78,6 +93,4 @@ int dataFilter_masks = filter_categoryBitMask[int(category / 32.0)];

#endif
} else {
dataFilter_value = 1.0;
}
}
#endif
`;

@@ -144,11 +157,18 @@ const fs = `

'vs:#main-start': `
dataFilter_value = 1.0;
if (filter_enabled) {
#ifdef DATAFILTER_ATTRIB
#ifdef DATAFILTER_DOUBLE
dataFilter_setValue(
DATAFILTER_ATTRIB - filter_min64High + DATAFILTER_ATTRIB_64LOW,
DATAFILTER_ATTRIB - filter_max64High + DATAFILTER_ATTRIB_64LOW,
DATACATEGORY_ATTRIB
DATAFILTER_ATTRIB - filter_max64High + DATAFILTER_ATTRIB_64LOW
);
#else
dataFilter_setValue(DATAFILTER_ATTRIB, DATAFILTER_ATTRIB, DATACATEGORY_ATTRIB);
dataFilter_setValue(DATAFILTER_ATTRIB, DATAFILTER_ATTRIB);
#endif
#endif
#ifdef DATACATEGORY_ATTRIB
dataFilter_setCategoryValue(DATACATEGORY_ATTRIB);
#endif
}
`,

@@ -155,0 +175,0 @@ 'vs:#main-end': `

@@ -1,7 +0,7 @@

import { Effect, PreRenderOptions, CoordinateSystem } from '@deck.gl/core';
import type { Device, Texture } from '@luma.gl/core';
import { Effect, EffectContext, PreRenderOptions, CoordinateSystem } from '@deck.gl/core';
import type { Texture } from '@luma.gl/core';
import { Bounds } from "../utils/projection-utils.js";
type Mask = {
/** The channel index */
index: number;
index: 0 | 1 | 2 | 3;
bounds: Bounds;

@@ -25,3 +25,4 @@ coordinateOrigin: [number, number, number];

private lastViewport?;
preRender(device: Device, { layers, layerFilter, viewports, onViewportActive, views, isPicking }: PreRenderOptions): MaskPreRenderStats;
setup({ device }: EffectContext): void;
preRender({ layers, layerFilter, viewports, onViewportActive, views, isPicking }: PreRenderOptions): MaskPreRenderStats;
private _renderChannel;

@@ -28,0 +29,0 @@ /**

@@ -15,10 +15,12 @@ import { log } from '@deck.gl/core';

}
preRender(device, { layers, layerFilter, viewports, onViewportActive, views, isPicking }) {
setup({ device }) {
this.dummyMaskMap = device.createTexture({
width: 1,
height: 1
});
this.maskPass = new MaskPass(device, { id: 'default-mask' });
this.maskMap = this.maskPass.maskMap;
}
preRender({ layers, layerFilter, viewports, onViewportActive, views, isPicking }) {
let didRender = false;
if (!this.dummyMaskMap) {
this.dummyMaskMap = device.createTexture({
width: 1,
height: 1
});
}
if (isPicking) {

@@ -35,6 +37,2 @@ // Do not update on picking pass

this.masks = {};
if (!this.maskPass) {
this.maskPass = new MaskPass(device, { id: 'default-mask' });
this.maskMap = this.maskPass.maskMap;
}
// Map layers to channels

@@ -41,0 +39,0 @@ const channelMap = this._sortMaskChannels(maskLayers);

import type { Device, Framebuffer, Texture } from '@luma.gl/core';
import { _LayersPass as LayersPass, LayersPassRenderOptions } from '@deck.gl/core';
import { Layer, _LayersPass as LayersPass, LayersPassRenderOptions, Viewport } from '@deck.gl/core';
type MaskPassRenderOptions = LayersPassRenderOptions & {
/** The channel to render into, 0:red, 1:green, 2:blue, 3:alpha */
channel: number;
channel: 0 | 1 | 2 | 3;
};

@@ -14,3 +14,45 @@ export default class MaskPass extends LayersPass {

});
render(options: MaskPassRenderOptions): any;
render(options: MaskPassRenderOptions): void;
protected getLayerParameters(layer: Layer<{}>, layerIndex: number, viewport: Viewport): {
cullMode?: import("@luma.gl/core").CullMode | undefined;
frontFace?: import("@luma.gl/core").FrontFace | undefined;
depthBias?: number | undefined;
depthBiasSlopeScale?: number | undefined;
depthBiasClamp?: number | undefined;
unclippedDepth?: boolean | undefined;
provokingVertex?: "first" | "last" | undefined;
polygonMode?: "fill" | "line" | undefined;
polygonOffsetLine?: boolean | undefined;
clipDistance0?: boolean | undefined;
clipDistance1?: boolean | undefined;
clipDistance2?: boolean | undefined;
clipDistance3?: boolean | undefined;
clipDistance4?: boolean | undefined;
clipDistance5?: boolean | undefined;
clipDistance6?: boolean | undefined;
clipDistance7?: boolean | undefined;
topology?: import("@luma.gl/core").PrimitiveTopology | undefined;
stripIndexFormat?: import("@luma.gl/core").IndexFormat | undefined;
depthWriteEnabled?: boolean | undefined;
depthCompare?: import("@luma.gl/core").CompareFunction | undefined;
depthFormat?: import("@luma.gl/core").DepthStencilTextureFormat | undefined;
stencilReadMask?: number | undefined;
stencilWriteMask?: number | undefined;
stencilCompare?: import("@luma.gl/core").CompareFunction | undefined;
stencilPassOperation?: import("@luma.gl/core").StencilOperation | undefined;
stencilFailOperation?: import("@luma.gl/core").StencilOperation | undefined;
stencilDepthFailOperation?: import("@luma.gl/core").StencilOperation | undefined;
blendColorOperation?: import("@luma.gl/core").BlendOperation | undefined;
blendColorSrcFactor?: import("@luma.gl/core").BlendFactor | undefined;
blendColorDstFactor?: import("@luma.gl/core").BlendFactor | undefined;
blendAlphaOperation?: import("@luma.gl/core").BlendOperation | undefined;
blendAlphaSrcFactor?: import("@luma.gl/core").BlendFactor | undefined;
blendAlphaDstFactor?: import("@luma.gl/core").BlendFactor | undefined;
colorMask?: number | undefined;
sampleCount?: number | undefined;
sampleMask?: number | undefined;
sampleAlphaToCoverageEnabled?: boolean | undefined;
blend: boolean;
depthTest: boolean;
};
shouldDrawLayer(layer: any): any;

@@ -17,0 +59,0 @@ delete(): void;

@@ -1,3 +0,10 @@

import { GL } from '@luma.gl/constants';
import { _LayersPass as LayersPass } from '@deck.gl/core';
const MASK_BLENDING = {
blendColorOperation: 'subtract',
blendColorSrcFactor: 'zero',
blendColorDstFactor: 'one',
blendAlphaOperation: 'subtract',
blendAlphaSrcFactor: 'zero',
blendAlphaDstFactor: 'one'
};
export default class MaskPass extends LayersPass {

@@ -26,12 +33,13 @@ constructor(device, props) {

render(options) {
const colorMask = [false, false, false, false];
colorMask[options.channel] = true;
const colorMask = 2 ** options.channel;
const clearColor = [255, 255, 255, 255];
return this.device.withParametersWebGL({
super.render({ ...options, clearColor, colorMask, target: this.fbo, pass: 'mask' });
}
getLayerParameters(layer, layerIndex, viewport) {
return {
...layer.props.parameters,
blend: true,
blendFunc: [0, 1],
blendEquation: 32778,
colorMask,
depthTest: false
}, () => super.render({ ...options, clearColor, target: this.fbo, pass: 'mask' }));
depthTest: false,
...MASK_BLENDING
};
}

@@ -38,0 +46,0 @@ shouldDrawLayer(layer) {

@@ -109,4 +109,5 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

}
result[geometrySize - 1] = 0;
return result;
}
}

@@ -137,3 +137,4 @@ import { createRenderTarget } from "./utils.js";

this.pickingFbo = createRenderTarget(this.targetLayer.context.device, {
id: `${this.id}-picking`
id: `${this.id}-picking`,
interpolate: false
});

@@ -140,0 +141,0 @@ }

@@ -1,4 +0,3 @@

import { Device } from '@luma.gl/core';
import { TerrainModuleSettings } from "./shader-module.js";
import type { Effect, PreRenderOptions, Layer } from '@deck.gl/core';
import type { Effect, EffectContext, PreRenderOptions, Layer } from '@deck.gl/core';
/** Class to manage terrain effect */

@@ -21,6 +20,6 @@ export declare class TerrainEffect implements Effect {

private terrainCovers;
initialize(device: Device): void;
preRender(device: Device, opts: PreRenderOptions): void;
setup({ device, deck }: EffectContext): void;
preRender(opts: PreRenderOptions): void;
getModuleParameters(layer: Layer): Omit<TerrainModuleSettings, 'picking'>;
cleanup(): void;
cleanup({ deck }: EffectContext): void;
private _updateHeightMap;

@@ -27,0 +26,0 @@ private _updateTerrainCovers;

@@ -1,2 +0,2 @@

import { log, getShaderAssembler } from '@deck.gl/core';
import { log } from '@deck.gl/core';
import { terrainModule } from "./shader-module.js";

@@ -20,3 +20,3 @@ import { TerrainCover } from "./terrain-cover.js";

}
initialize(device) {
setup({ device, deck }) {
this.dummyHeightMap = device.createTexture({

@@ -35,15 +35,5 @@ width: 1,

}
getShaderAssembler().addDefaultModule(terrainModule);
deck._addDefaultShaderModule(terrainModule);
}
preRender(device, opts) {
if (!this.dummyHeightMap) {
// First time this effect is in use, initialize resources and register the shader module
this.initialize(device);
for (const layer of opts.layers) {
// Force the terrain layer (and its descendents) to rebuild their models with the new shader
if (layer.props.operation.includes('terrain')) {
layer.setChangeFlags({ extensionsChanged: true });
}
}
}
preRender(opts) {
// @ts-expect-error pickZ only defined in picking pass

@@ -86,3 +76,3 @@ if (opts.pickZ) {

}
cleanup() {
cleanup({ deck }) {
if (this.dummyHeightMap) {

@@ -100,3 +90,3 @@ this.dummyHeightMap.delete();

this.terrainCovers.clear();
getShaderAssembler().removeDefaultModule(terrainModule);
deck._removeDefaultShaderModule(terrainModule);
}

@@ -103,0 +93,0 @@ _updateHeightMap(terrainLayers, viewport, opts) {

@@ -10,3 +10,45 @@ import { Layer, Viewport, _LayersPass as LayersPass, LayersPassRenderOptions } from '@deck.gl/core';

renderTerrainCover(terrainCover: TerrainCover, opts: Partial<TerrainPassRenderOptions>): void;
protected getLayerParameters(layer: Layer<{}>, layerIndex: number, viewport: Viewport): {
cullMode?: import("@luma.gl/core").CullMode | undefined;
frontFace?: import("@luma.gl/core").FrontFace | undefined;
depthBias?: number | undefined;
depthBiasSlopeScale?: number | undefined;
depthBiasClamp?: number | undefined;
unclippedDepth?: boolean | undefined;
provokingVertex?: "first" | "last" | undefined;
polygonMode?: "fill" | "line" | undefined;
polygonOffsetLine?: boolean | undefined;
clipDistance0?: boolean | undefined;
clipDistance1?: boolean | undefined;
clipDistance2?: boolean | undefined;
clipDistance3?: boolean | undefined;
clipDistance4?: boolean | undefined;
clipDistance5?: boolean | undefined;
clipDistance6?: boolean | undefined;
clipDistance7?: boolean | undefined;
topology?: import("@luma.gl/core").PrimitiveTopology | undefined;
stripIndexFormat?: import("@luma.gl/core").IndexFormat | undefined;
depthWriteEnabled?: boolean | undefined;
depthCompare?: import("@luma.gl/core").CompareFunction | undefined;
depthFormat?: import("@luma.gl/core").DepthStencilTextureFormat | undefined;
stencilReadMask?: number | undefined;
stencilWriteMask?: number | undefined;
stencilCompare?: import("@luma.gl/core").CompareFunction | undefined;
stencilPassOperation?: import("@luma.gl/core").StencilOperation | undefined;
stencilFailOperation?: import("@luma.gl/core").StencilOperation | undefined;
stencilDepthFailOperation?: import("@luma.gl/core").StencilOperation | undefined;
blendColorOperation?: import("@luma.gl/core").BlendOperation | undefined;
blendColorSrcFactor?: import("@luma.gl/core").BlendFactor | undefined;
blendColorDstFactor?: import("@luma.gl/core").BlendFactor | undefined;
blendAlphaOperation?: import("@luma.gl/core").BlendOperation | undefined;
blendAlphaSrcFactor?: import("@luma.gl/core").BlendFactor | undefined;
blendAlphaDstFactor?: import("@luma.gl/core").BlendFactor | undefined;
colorMask?: number | undefined;
sampleCount?: number | undefined;
sampleMask?: number | undefined;
sampleAlphaToCoverageEnabled?: boolean | undefined;
blend: boolean;
depthTest: boolean;
};
}
//# sourceMappingURL=terrain-pass.d.ts.map

@@ -1,3 +0,10 @@

import { GL } from '@luma.gl/constants';
import { _LayersPass as LayersPass } from '@deck.gl/core';
const TERRAIN_BLENDING = {
blendColorOperation: 'max',
blendColorSrcFactor: 'one',
blendColorDstFactor: 'one',
blendAlphaOperation: 'max',
blendAlphaSrcFactor: 'one',
blendAlphaDstFactor: 'one'
};
/** Renders textures used by the TerrainEffect render pass */

@@ -25,9 +32,3 @@ export class TerrainPass extends LayersPass {

target.resize(viewport);
this.device.withParametersWebGL({
clearColor: [0, 0, 0, 0],
blend: true,
blendFunc: [1, 1],
blendEquation: 32776,
depthTest: false
}, () => this.render({
this.render({
...opts,

@@ -38,4 +39,5 @@ target,

viewports: [viewport],
effects: []
}));
effects: [],
clearColor: [0, 0, 0, 0]
});
}

@@ -51,6 +53,3 @@ renderTerrainCover(terrainCover, opts) {

target.resize(viewport);
this.device.withParametersWebGL({
clearColor: [0, 0, 0, 0],
depthTest: false
}, () => this.render({
this.render({
...opts,

@@ -61,5 +60,14 @@ target,

effects: [],
viewports: [viewport]
}));
viewports: [viewport],
clearColor: [0, 0, 0, 0]
});
}
getLayerParameters(layer, layerIndex, viewport) {
return {
...layer.props.parameters,
blend: true,
depthTest: false,
...(layer.props.operation.includes('terrain') && TERRAIN_BLENDING)
};
}
}

@@ -42,5 +42,3 @@ import { _PickLayersPass as PickLayersPass } from '@deck.gl/core';

target.resize(viewport);
this.device.withParametersWebGL({
depthTest: false
}, () => this.render({
this.render({
...opts,

@@ -57,12 +55,15 @@ pickingFBO: target,

pickZ: false
}));
});
}
getLayerParameters(layer, layerIndex, viewport) {
let parameters;
if (this.drawParameters[layer.id]) {
return this.drawParameters[layer.id];
parameters = this.drawParameters[layer.id];
}
const parameters = super.getLayerParameters(layer, layerIndex, viewport);
parameters.blend = true;
return parameters;
else {
parameters = super.getLayerParameters(layer, layerIndex, viewport);
parameters.blend = true;
}
return { ...parameters, depthTest: false };
}
}

@@ -5,3 +5,4 @@ import type { Device } from '@luma.gl/core';

float?: boolean;
interpolate?: boolean;
}): import("@luma.gl/core").Framebuffer;
//# sourceMappingURL=utils.d.ts.map

@@ -7,2 +7,3 @@ import { GL } from '@luma.gl/constants';

device.createTexture({
id: opts.id,
...(opts.float && {

@@ -13,8 +14,11 @@ format: 'rgba32float',

mipmaps: false,
sampler: {
minFilter: 'linear',
magFilter: 'linear',
addressModeU: 'clamp-to-edge',
addressModeV: 'clamp-to-edge'
}
sampler: opts.interpolate === false
? {
minFilter: 'nearest',
magFilter: 'nearest'
}
: {
minFilter: 'linear',
magFilter: 'linear'
}
})

@@ -21,0 +25,0 @@ ]

@@ -6,3 +6,3 @@ {

"type": "module",
"version": "9.0.0-beta.10",
"version": "9.0.0-beta.11",
"publishConfig": {

@@ -42,4 +42,4 @@ "access": "public"

"dependencies": {
"@luma.gl/constants": "^9.0.4",
"@luma.gl/shadertools": "^9.0.4",
"@luma.gl/constants": "^9.0.11",
"@luma.gl/shadertools": "^9.0.11",
"@math.gl/core": "^4.0.0"

@@ -49,6 +49,6 @@ },

"@deck.gl/core": "^9.0.0-beta",
"@luma.gl/core": "^9.0.4",
"@luma.gl/engine": "^9.0.4"
"@luma.gl/core": "^9.0.0",
"@luma.gl/engine": "^9.0.0"
},
"gitHead": "6c44f602069374cd21268ff279c5bf818c905ff7"
"gitHead": "d8a3f5bdb644f85caba9d5c1e74baff8f8a3d439"
}
import {Device, Framebuffer, Texture} from '@luma.gl/core';
import {equals} from '@math.gl/core';
import {_deepEqual as deepEqual} from '@deck.gl/core';
import type {Effect, Layer, PreRenderOptions, Viewport} from '@deck.gl/core';
import type {Effect, EffectContext, Layer, PreRenderOptions, Viewport} from '@deck.gl/core';
import CollisionFilterPass from './collision-filter-pass';
import MaskEffect, {MaskPreRenderStats} from '../mask/mask-effect';
import {MaskPreRenderStats} from '../mask/mask-effect';
// import {debugFBO} from '../utils/debug';

@@ -30,2 +30,3 @@

private context?: EffectContext;
private channels: Record<string, RenderInfo> = {};

@@ -37,19 +38,22 @@ private collisionFilterPass?: CollisionFilterPass;

preRender(
device: Device,
{
effects: allEffects,
layers,
layerFilter,
viewports,
onViewportActive,
views,
isPicking,
preRenderStats = {}
}: PreRenderOptions
): void {
if (!this.dummyCollisionMap) {
this.dummyCollisionMap = device.createTexture({width: 1, height: 1});
}
setup(context: EffectContext) {
this.context = context;
const {device} = context;
this.dummyCollisionMap = device.createTexture({width: 1, height: 1});
this.collisionFilterPass = new CollisionFilterPass(device, {id: 'default-collision-filter'});
}
preRender({
effects: allEffects,
layers,
layerFilter,
viewports,
onViewportActive,
views,
isPicking,
preRenderStats = {}
}: PreRenderOptions): void {
// This can only be called in preRender() after setup() where context is populated
const {device} = this.context!;
if (isPicking) {

@@ -69,8 +73,4 @@ // Do not update on picking pass

if (!this.collisionFilterPass) {
this.collisionFilterPass = new CollisionFilterPass(device, {id: 'default-collision-filter'});
}
// Detect if mask has rendered. TODO: better dependency system for Effects
const effects = allEffects?.filter(e => e.constructor === MaskEffect);
const effects = allEffects?.filter(e => e.useInPicking && preRenderStats[e.id]);
const maskEffectRendered = (preRenderStats['mask-effect'] as MaskPreRenderStats)?.didRender;

@@ -77,0 +77,0 @@

import {Framebuffer} from '@luma.gl/core';
import {_LayersPass as LayersPass, LayersPassRenderOptions} from '@deck.gl/core';
import {Layer, _LayersPass as LayersPass, LayersPassRenderOptions, Viewport} from '@deck.gl/core';

@@ -10,15 +10,11 @@ type CollisionFilterPassRenderOptions = LayersPassRenderOptions & {};

const clearColor = [0, 0, 0, 0];
const scissorRect = [padding, padding, target.width - 2 * padding, target.height - 2 * padding];
return this.device.withParametersWebGL(
{
scissorTest: true,
scissor: [padding, padding, target.width - 2 * padding, target.height - 2 * padding],
blend: false,
depthTest: true,
depthRange: [0, 1]
},
() => this.render({...options, clearColor, target, pass: 'collision'})
);
this.render({...options, clearColor, scissorRect, target, pass: 'collision'});
}
protected getLayerParameters(layer: Layer, layerIndex: number, viewport: Viewport): any {
return {...layer.props.parameters, blend: false, depthRange: [0, 1], depthTest: true};
}
getModuleParameters() {

@@ -25,0 +21,0 @@ // Draw picking colors into collision FBO

@@ -25,3 +25,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import {_deepEqual as deepEqual, LayerExtension, log} from '@deck.gl/core';
import {shaderModule, shaderModule64} from './shader-module';
import {Defines, shaderModule, shaderModule64} from './shader-module';
import * as aggregator from './aggregator';

@@ -100,11 +100,11 @@

/**
* The size of the category filter (number of columns to filter by). The category filter can show/hide data based on 1-4 properties of each object.
* @default 1
* The size of the category filter (number of columns to filter by). The category filter can show/hide data based on 1-4 properties of each object. Set to `0` to disable category filtering.
* @default 0
*/
categorySize?: 1 | 2 | 3 | 4;
categorySize?: 0 | 1 | 2 | 3 | 4;
/**
* The size of the filter (number of columns to filter by). The data filter can show/hide data based on 1-4 numeric properties of each object.
* The size of the filter (number of columns to filter by). The data filter can show/hide data based on 1-4 numeric properties of each object. Set to `0` to disable numeric filtering.
* @default 1
*/
filterSize?: 1 | 2 | 3 | 4;
filterSize?: 0 | 1 | 2 | 3 | 4;
/**

@@ -123,3 +123,3 @@ * Use 64-bit precision instead of 32-bit.

const defaultOptions: Required<DataFilterExtensionOptions> = {
categorySize: 1,
categorySize: 0,
filterSize: 1,

@@ -131,6 +131,6 @@ fp64: false,

const DATA_TYPE_FROM_SIZE = {
1: 'float',
2: 'vec2',
3: 'vec3',
4: 'vec4'
1: 'float' as const,
2: 'vec2' as const,
3: 'vec3' as const,
4: 'vec4' as const
};

@@ -151,12 +151,13 @@

const {categorySize, filterSize, fp64} = extension.opts;
const defines: Defines = {};
if (categorySize) {
defines.DATACATEGORY_TYPE = DATA_TYPE_FROM_SIZE[categorySize];
defines.DATACATEGORY_CHANNELS = categorySize;
}
if (filterSize) {
defines.DATAFILTER_TYPE = DATA_TYPE_FROM_SIZE[filterSize];
defines.DATAFILTER_DOUBLE = Boolean(fp64);
}
return {
modules: [fp64 ? shaderModule64 : shaderModule],
defines: {
DATACATEGORY_TYPE: DATA_TYPE_FROM_SIZE[categorySize],
DATACATEGORY_CHANNELS: categorySize,
DATAFILTER_TYPE: DATA_TYPE_FROM_SIZE[filterSize],
DATAFILTER_DOUBLE: Boolean(fp64)
}
};
return {modules: [fp64 ? shaderModule64 : shaderModule], defines};
}

@@ -169,33 +170,40 @@

if (attributeManager) {
attributeManager.add({
filterValues: {
size: filterSize,
type: fp64 ? 'float64' : 'float32',
accessor: 'getFilterValue',
shaderAttributes: {
filterValues: {
divisor: 0
},
instanceFilterValues: {
divisor: 1
if (filterSize) {
attributeManager.add({
filterValues: {
size: filterSize,
type: fp64 ? 'float64' : 'float32',
accessor: 'getFilterValue',
shaderAttributes: {
filterValues: {
divisor: 0
},
instanceFilterValues: {
divisor: 1
}
}
}
},
filterCategoryValues: {
size: categorySize,
accessor: 'getFilterCategory',
transform:
categorySize === 1
? d => extension._getCategoryKey.call(this, d, 0)
: d => d.map((x, i) => extension._getCategoryKey.call(this, x, i)),
shaderAttributes: {
filterCategoryValues: {
divisor: 0
},
instanceFilterCategoryValues: {
divisor: 1
});
}
if (categorySize) {
attributeManager.add({
filterCategoryValues: {
size: categorySize,
accessor: 'getFilterCategory',
transform:
categorySize === 1
? d => extension._getCategoryKey.call(this, d, 0)
: d => d.map((x, i) => extension._getCategoryKey.call(this, x, i)),
shaderAttributes: {
filterCategoryValues: {
divisor: 0
},
instanceFilterCategoryValues: {
divisor: 1
}
}
}
}
});
});
}
}

@@ -249,3 +257,3 @@

// attributeManager must be defined for filterModel to be set
attributeManager!.attributes.filterValues.needsUpdate() ||
attributeManager!.attributes.filterValues?.needsUpdate() ||
attributeManager!.attributes.filterCategoryValues?.needsUpdate() ||

@@ -304,3 +312,3 @@ props.filterEnabled !== oldProps.filterEnabled ||

filterModel.setAttributes({
...filterValues.getValue(),
...filterValues?.getValue(),
...filterCategoryValues?.getValue(),

@@ -307,0 +315,0 @@ ...filterIndices?.getValue()

@@ -8,7 +8,39 @@ import type {ShaderModule} from '@luma.gl/shadertools';

*/
export type Defines = {
// Defines passed externally
/**
* Primitive type of parameter used for category filtering. If undefined, category filtering disabled.
*/
DATACATEGORY_TYPE?: 'float' | 'vec2' | 'vec3' | 'vec4';
/**
* Number of category filtering channels. Must match dimension of `DATACATEGORY_TYPE`
*/
DATACATEGORY_CHANNELS?: 1 | 2 | 3 | 4;
/**
* Primitive type of parameter used for numeric filtering. If undefined, numeric filtering disabled.
*/
DATAFILTER_TYPE?: 'float' | 'vec2' | 'vec3' | 'vec4';
/**
* Enable 64-bit precision in numeric filter.
*/
DATAFILTER_DOUBLE?: boolean;
// Defines derived in shader
/**
* Numeric filter attribute
*/
DATAFILTER_ATTRIB?: 'filterValues' | 'instanceFilterValues';
/**
* Numeric filter attribute (low bits). Only used when `DATAFILTER_DOUBLE = true`
*/
DATAFILTER_ATTRIB_64LOW?: 'filterValues64Low' | 'instanceFilterValues64Low';
/**
* Category filter attribute
*/
DATACATEGORY_ATTRIB?: 'filterCategoryValues' | 'instanceFilterCategoryValues';
};
const vs = glsl`
uniform DATAFILTER_TYPE filter_min;
uniform DATAFILTER_TYPE filter_softMin;
uniform DATAFILTER_TYPE filter_softMax;
uniform DATAFILTER_TYPE filter_max;
uniform bool filter_useSoftMargin;

@@ -19,20 +51,34 @@ uniform bool filter_enabled;

#ifdef NON_INSTANCED_MODEL
#define DATAFILTER_ATTRIB filterValues
#define DATAFILTER_ATTRIB_64LOW filterValues64Low
#define DATACATEGORY_ATTRIB filterCategoryValues
#else
#define DATAFILTER_ATTRIB instanceFilterValues
#define DATAFILTER_ATTRIB_64LOW instanceFilterValues64Low
#define DATACATEGORY_ATTRIB instanceFilterCategoryValues
#ifdef DATAFILTER_TYPE
uniform DATAFILTER_TYPE filter_min;
uniform DATAFILTER_TYPE filter_softMin;
uniform DATAFILTER_TYPE filter_softMax;
uniform DATAFILTER_TYPE filter_max;
#ifdef NON_INSTANCED_MODEL
#define DATAFILTER_ATTRIB filterValues
#define DATAFILTER_ATTRIB_64LOW filterValues64Low
#else
#define DATAFILTER_ATTRIB instanceFilterValues
#define DATAFILTER_ATTRIB_64LOW instanceFilterValues64Low
#endif
in DATAFILTER_TYPE DATAFILTER_ATTRIB;
#ifdef DATAFILTER_DOUBLE
in DATAFILTER_TYPE DATAFILTER_ATTRIB_64LOW;
uniform DATAFILTER_TYPE filter_min64High;
uniform DATAFILTER_TYPE filter_max64High;
#endif
#endif
in DATAFILTER_TYPE DATAFILTER_ATTRIB;
#ifdef DATAFILTER_DOUBLE
in DATAFILTER_TYPE DATAFILTER_ATTRIB_64LOW;
uniform DATAFILTER_TYPE filter_min64High;
uniform DATAFILTER_TYPE filter_max64High;
#ifdef DATACATEGORY_TYPE
#ifdef NON_INSTANCED_MODEL
#define DATACATEGORY_ATTRIB filterCategoryValues
#else
#define DATACATEGORY_ATTRIB instanceFilterCategoryValues
#endif
in DATACATEGORY_TYPE DATACATEGORY_ATTRIB;
#endif
in DATACATEGORY_TYPE DATACATEGORY_ATTRIB;

@@ -53,9 +99,19 @@ out float dataFilter_value;

}
void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax, DATACATEGORY_TYPE category) {
if (filter_enabled) {
#ifdef DATAFILTER_TYPE
void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax) {
if (filter_useSoftMargin) {
dataFilter_value = dataFilter_reduceValue(
smoothstep(filter_min, filter_softMin, valueFromMin) *
(1.0 - smoothstep(filter_softMax, filter_max, valueFromMax))
// smoothstep results are undefined if edge0 ≥ edge1
// Fallback to ignore filterSoftRange if it is truncated by filterRange
DATAFILTER_TYPE leftInRange = mix(
smoothstep(filter_min, filter_softMin, valueFromMin),
step(filter_min, valueFromMin),
step(filter_softMin, filter_min)
);
DATAFILTER_TYPE rightInRange = mix(
1.0 - smoothstep(filter_softMax, filter_max, valueFromMax),
step(valueFromMax, filter_max),
step(filter_max, filter_softMax)
);
dataFilter_value = dataFilter_reduceValue(leftInRange * rightInRange);
} else {

@@ -66,14 +122,18 @@ dataFilter_value = dataFilter_reduceValue(

}
}
#endif
#ifdef DATACATEGORY_ATTRIB
void dataFilter_setCategoryValue(DATACATEGORY_TYPE category) {
#if DATACATEGORY_CHANNELS == 1 // One 128-bit mask
int dataFilter_masks = filter_categoryBitMask[int(category / 32.0)];
int dataFilter_masks = filter_categoryBitMask[int(category / 32.0)];
#elif DATACATEGORY_CHANNELS == 2 // Two 64-bit masks
ivec2 dataFilter_masks = ivec2(
filter_categoryBitMask[int(category.x / 32.0)],
filter_categoryBitMask[int(category.y / 32.0) + 2]
);
ivec2 dataFilter_masks = ivec2(
filter_categoryBitMask[int(category.x / 32.0)],
filter_categoryBitMask[int(category.y / 32.0) + 2]
);
#elif DATACATEGORY_CHANNELS == 3 // Three 32-bit masks
ivec3 dataFilter_masks = filter_categoryBitMask.xyz;
ivec3 dataFilter_masks = filter_categoryBitMask.xyz;
#else // Four 32-bit masks
ivec4 dataFilter_masks = filter_categoryBitMask;
ivec4 dataFilter_masks = filter_categoryBitMask;
#endif

@@ -86,10 +146,8 @@

#if DATACATEGORY_CHANNELS == 1
if(dataFilter_bits == 0.0) dataFilter_value = 0.0;
if(dataFilter_bits == 0.0) dataFilter_value = 0.0;
#else
if(any(equal(dataFilter_bits, DATACATEGORY_TYPE(0.0)))) dataFilter_value = 0.0;
#endif
} else {
dataFilter_value = 1.0;
}
}
#endif
`;

@@ -171,11 +229,19 @@

'vs:#main-start': glsl`
#ifdef DATAFILTER_DOUBLE
dataFilter_setValue(
DATAFILTER_ATTRIB - filter_min64High + DATAFILTER_ATTRIB_64LOW,
DATAFILTER_ATTRIB - filter_max64High + DATAFILTER_ATTRIB_64LOW,
DATACATEGORY_ATTRIB
);
#else
dataFilter_setValue(DATAFILTER_ATTRIB, DATAFILTER_ATTRIB, DATACATEGORY_ATTRIB);
#endif
dataFilter_value = 1.0;
if (filter_enabled) {
#ifdef DATAFILTER_ATTRIB
#ifdef DATAFILTER_DOUBLE
dataFilter_setValue(
DATAFILTER_ATTRIB - filter_min64High + DATAFILTER_ATTRIB_64LOW,
DATAFILTER_ATTRIB - filter_max64High + DATAFILTER_ATTRIB_64LOW
);
#else
dataFilter_setValue(DATAFILTER_ATTRIB, DATAFILTER_ATTRIB);
#endif
#endif
#ifdef DATACATEGORY_ATTRIB
dataFilter_setCategoryValue(DATACATEGORY_ATTRIB);
#endif
}
`,

@@ -182,0 +248,0 @@

@@ -1,3 +0,11 @@

import {Layer, Viewport, Effect, PreRenderOptions, CoordinateSystem, log} from '@deck.gl/core';
import type {Device, Texture} from '@luma.gl/core';
import {
Layer,
Viewport,
Effect,
EffectContext,
PreRenderOptions,
CoordinateSystem,
log
} from '@deck.gl/core';
import type {Texture} from '@luma.gl/core';
import {equals} from '@math.gl/core';

@@ -10,3 +18,3 @@ import MaskPass from './mask-pass';

/** The channel index */
index: number;
index: 0 | 1 | 2 | 3;
bounds: Bounds;

@@ -19,3 +27,3 @@ coordinateOrigin: [number, number, number];

id: string;
index: number;
index: 0 | 1 | 2 | 3;
layers: Layer[];

@@ -47,13 +55,21 @@ bounds: Bounds | null;

preRender(
device: Device,
{layers, layerFilter, viewports, onViewportActive, views, isPicking}: PreRenderOptions
): MaskPreRenderStats {
setup({device}: EffectContext) {
this.dummyMaskMap = device.createTexture({
width: 1,
height: 1
});
this.maskPass = new MaskPass(device, {id: 'default-mask'});
this.maskMap = this.maskPass.maskMap;
}
preRender({
layers,
layerFilter,
viewports,
onViewportActive,
views,
isPicking
}: PreRenderOptions): MaskPreRenderStats {
let didRender = false;
if (!this.dummyMaskMap) {
this.dummyMaskMap = device.createTexture({
width: 1,
height: 1
});
}

@@ -73,7 +89,2 @@ if (isPicking) {

if (!this.maskPass) {
this.maskPass = new MaskPass(device, {id: 'default-mask'});
this.maskMap = this.maskPass.maskMap;
}
// Map layers to channels

@@ -80,0 +91,0 @@ const channelMap = this._sortMaskChannels(maskLayers);

@@ -1,10 +0,18 @@

import type {Device, Framebuffer, Texture} from '@luma.gl/core';
import {GL} from '@luma.gl/constants';
import {_LayersPass as LayersPass, LayersPassRenderOptions} from '@deck.gl/core';
import type {Device, Framebuffer, RenderPipelineParameters, Texture} from '@luma.gl/core';
import {Layer, _LayersPass as LayersPass, LayersPassRenderOptions, Viewport} from '@deck.gl/core';
type MaskPassRenderOptions = LayersPassRenderOptions & {
/** The channel to render into, 0:red, 1:green, 2:blue, 3:alpha */
channel: number;
channel: 0 | 1 | 2 | 3;
};
const MASK_BLENDING: RenderPipelineParameters = {
blendColorOperation: 'subtract',
blendColorSrcFactor: 'zero',
blendColorDstFactor: 'one',
blendAlphaOperation: 'subtract',
blendAlphaSrcFactor: 'zero',
blendAlphaDstFactor: 'one'
};
export default class MaskPass extends LayersPass {

@@ -40,16 +48,14 @@ maskMap: Texture;

render(options: MaskPassRenderOptions) {
const colorMask = [false, false, false, false];
colorMask[options.channel] = true;
const colorMask = 2 ** options.channel;
const clearColor = [255, 255, 255, 255];
super.render({...options, clearColor, colorMask, target: this.fbo, pass: 'mask'});
}
return this.device.withParametersWebGL(
{
blend: true,
blendFunc: [GL.ZERO, GL.ONE],
blendEquation: GL.FUNC_SUBTRACT,
colorMask,
depthTest: false
},
() => super.render({...options, clearColor, target: this.fbo, pass: 'mask'})
);
protected getLayerParameters(layer: Layer<{}>, layerIndex: number, viewport: Viewport) {
return {
...layer.props.parameters,
blend: true,
depthTest: false,
...MASK_BLENDING
};
}

@@ -56,0 +62,0 @@

@@ -180,4 +180,5 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

}
result[geometrySize - 1] = 0;
return result;
}
}

@@ -177,3 +177,4 @@ import {Framebuffer} from '@luma.gl/core';

this.pickingFbo = createRenderTarget(this.targetLayer.context.device, {
id: `${this.id}-picking`
id: `${this.id}-picking`,
interpolate: false
});

@@ -180,0 +181,0 @@ }

@@ -1,3 +0,3 @@

import {Device, Texture} from '@luma.gl/core';
import {log, getShaderAssembler} from '@deck.gl/core';
import {Texture} from '@luma.gl/core';
import {log} from '@deck.gl/core';

@@ -10,3 +10,3 @@ import {terrainModule, TerrainModuleSettings} from './shader-module';

import type {Effect, PreRenderOptions, Layer, Viewport} from '@deck.gl/core';
import type {Effect, EffectContext, PreRenderOptions, Layer, Viewport} from '@deck.gl/core';

@@ -32,3 +32,3 @@ /** Class to manage terrain effect */

initialize(device: Device) {
setup({device, deck}: EffectContext) {
this.dummyHeightMap = device.createTexture({

@@ -48,17 +48,6 @@ width: 1,

getShaderAssembler().addDefaultModule(terrainModule);
deck._addDefaultShaderModule(terrainModule);
}
preRender(device: Device, opts: PreRenderOptions): void {
if (!this.dummyHeightMap) {
// First time this effect is in use, initialize resources and register the shader module
this.initialize(device);
for (const layer of opts.layers) {
// Force the terrain layer (and its descendents) to rebuild their models with the new shader
if (layer.props.operation.includes('terrain')) {
layer.setChangeFlags({extensionsChanged: true});
}
}
}
preRender(opts: PreRenderOptions): void {
// @ts-expect-error pickZ only defined in picking pass

@@ -112,3 +101,3 @@ if (opts.pickZ) {

cleanup(): void {
cleanup({deck}: EffectContext): void {
if (this.dummyHeightMap) {

@@ -129,3 +118,3 @@ this.dummyHeightMap.delete();

getShaderAssembler().removeDefaultModule(terrainModule);
deck._removeDefaultShaderModule(terrainModule);
}

@@ -132,0 +121,0 @@

@@ -1,2 +0,2 @@

import {GL} from '@luma.gl/constants';
import {RenderPipelineParameters} from '@luma.gl/core';
import {Layer, Viewport, _LayersPass as LayersPass, LayersPassRenderOptions} from '@deck.gl/core';

@@ -8,2 +8,11 @@ import type {HeightMapBuilder} from './height-map-builder';

const TERRAIN_BLENDING: RenderPipelineParameters = {
blendColorOperation: 'max',
blendColorSrcFactor: 'one',
blendColorDstFactor: 'one',
blendAlphaOperation: 'max',
blendAlphaSrcFactor: 'one',
blendAlphaDstFactor: 'one'
};
/** Renders textures used by the TerrainEffect render pass */

@@ -36,20 +45,11 @@ export class TerrainPass extends LayersPass {

this.device.withParametersWebGL(
{
clearColor: [0, 0, 0, 0],
blend: true,
blendFunc: [GL.ONE, GL.ONE],
blendEquation: GL.MAX,
depthTest: false
},
() =>
this.render({
...opts,
target,
pass: 'terrain-height-map',
layers: opts.layers!,
viewports: [viewport],
effects: []
})
);
this.render({
...opts,
target,
pass: 'terrain-height-map',
layers: opts.layers!,
viewports: [viewport],
effects: [],
clearColor: [0, 0, 0, 0]
});
}

@@ -69,18 +69,21 @@

this.device.withParametersWebGL(
{
clearColor: [0, 0, 0, 0],
depthTest: false
},
() =>
this.render({
...opts,
target,
pass: `terrain-cover-${terrainCover.id}`,
layers,
effects: [],
viewports: [viewport]
})
);
this.render({
...opts,
target,
pass: `terrain-cover-${terrainCover.id}`,
layers,
effects: [],
viewports: [viewport],
clearColor: [0, 0, 0, 0]
});
}
protected getLayerParameters(layer: Layer<{}>, layerIndex: number, viewport: Viewport) {
return {
...layer.props.parameters,
blend: true,
depthTest: false,
...(layer.props.operation.includes('terrain') && TERRAIN_BLENDING)
};
}
}

@@ -56,31 +56,27 @@ import {

this.device.withParametersWebGL(
{
depthTest: false
},
() =>
this.render({
...opts,
pickingFBO: target,
pass: `terrain-cover-picking-${terrainCover.id}`,
layers,
effects: [],
viewports: [viewport],
// Disable the default culling because TileLayer would cull sublayers based on the screen viewport,
// not the viewport of the terrain cover. Culling is already done by `terrainCover.filterLayers`
cullRect: undefined,
deviceRect: viewport,
pickZ: false
})
);
this.render({
...opts,
pickingFBO: target,
pass: `terrain-cover-picking-${terrainCover.id}`,
layers,
effects: [],
viewports: [viewport],
// Disable the default culling because TileLayer would cull sublayers based on the screen viewport,
// not the viewport of the terrain cover. Culling is already done by `terrainCover.filterLayers`
cullRect: undefined,
deviceRect: viewport,
pickZ: false
});
}
protected getLayerParameters(layer: Layer, layerIndex: number, viewport: Viewport): any {
let parameters: any;
if (this.drawParameters[layer.id]) {
return this.drawParameters[layer.id];
parameters = this.drawParameters[layer.id];
} else {
parameters = super.getLayerParameters(layer, layerIndex, viewport);
parameters.blend = true;
}
const parameters = super.getLayerParameters(layer, layerIndex, viewport);
parameters.blend = true;
return parameters;
return {...parameters, depthTest: false};
}
}

@@ -9,2 +9,3 @@ import type {Device} from '@luma.gl/core';

float?: boolean;
interpolate?: boolean;
}

@@ -16,2 +17,3 @@ ) {

device.createTexture({
id: opts.id,
...(opts.float && {

@@ -22,8 +24,12 @@ format: 'rgba32float',

mipmaps: false,
sampler: {
minFilter: 'linear',
magFilter: 'linear',
addressModeU: 'clamp-to-edge',
addressModeV: 'clamp-to-edge'
}
sampler:
opts.interpolate === false
? {
minFilter: 'nearest',
magFilter: 'nearest'
}
: {
minFilter: 'linear',
magFilter: 'linear'
}
})

@@ -30,0 +36,0 @@ ]

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc