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]: Technical: add types for svg-icon-layer #1796

Merged
merged 1 commit into from
Apr 29, 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
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