Skip to content

Commit

Permalink
add types for svg-icon-layer
Browse files Browse the repository at this point in the history
Signed-off-by: Daria Terekhova <daria.terekhova@actionengine.com>
  • Loading branch information
dariaterekhova-actionengine committed Apr 21, 2022
1 parent 7ada98a commit db26dc0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import {ScatterplotLayer} from '@deck.gl/layers';
import {ScatterplotLayer, ScatterplotLayerProps} from '@deck.gl/layers';
import {Geometry, Model} from '@luma.gl/core';
import GL from '@luma.gl/constants';

const DEFAULT_POS = [-1, -1, 0, -1, 1, 0, 1, 1, 0, 1, -1, 0];
export default class ScatterplotIconLayer extends ScatterplotLayer {
_getModel(gl) {

export interface ScatterplotIconLayerProps extends ScatterplotLayerProps<any> {
iconGeometry: number;
}

export default class ScatterplotIconLayer extends ScatterplotLayer<any, ScatterplotIconLayerProps> {
_getModel(gl: WebGLRenderingContext) {
// use default scatterplot shaders
const shaders = this.getShaders();
const shaders = this.getShaders(undefined);

const {iconGeometry} = this.props;

Expand All @@ -49,6 +54,7 @@ export default class ScatterplotIconLayer extends ScatterplotLayer {
id: this.props.id,
geometry,
isInstanced: true,
// @ts-ignore
shaderCache: this.context.shaderCache
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,23 @@
// THE SOFTWARE.

import {CompositeLayer} from '@deck.gl/core';
import {CompositeLayerProps} from '@deck.gl/core/lib/composite-layer';
import ScatterplotIconLayer from './scatterplot-icon-layer';

// default icon geometry is a square
const DEFAULT_ICON_GEOMETRY = [1, 1, 0, 1, -1, 0, -1, -1, 0, -1, -1, 0, -1, 1, 0, 1, 1, 0];

const defaultProps = {
getIconGeometry: iconId => DEFAULT_ICON_GEOMETRY,
getIcon: d => d.icon
getIconGeometry: (iconId: string) => DEFAULT_ICON_GEOMETRY,
getIcon: (d: {icon: string}) => d.icon
};

export default class SvgIconLayer extends CompositeLayer {
export interface SvgIconLayerProps extends CompositeLayerProps<any> {
getIconGeometry: (i: string) => number[];
getIcon: (d: {icon: string}) => string;
}

export default class SvgIconLayer extends CompositeLayer<any, SvgIconLayerProps> {
// Must be defined
initializeState() {
this.state = {
Expand Down

0 comments on commit db26dc0

Please sign in to comment.