Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion modules/layers/src/point-cloud-layer/point-cloud-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,18 @@ import {pointCloudUniforms, PointCloudProps} from './point-cloud-layer-uniforms'
import vs from './point-cloud-layer-vertex.glsl';
import fs from './point-cloud-layer-fragment.glsl';
import source from './point-cloud-layer.wgsl';
import type {MeshAttributes} from '@loaders.gl/schema';

const DEFAULT_COLOR = [0, 0, 0, 255] as const;
const DEFAULT_NORMAL = [0, 0, 1] as const;

export type LoadersGLPointCloudData = {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we import the type Mesh instead of MeshAttributes I think we get this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used Mesh from @loaders.gl/schema as suggested. Typed it as Partial &
{ header: {vertexCount: number}; attributes: Mesh['attributes'] }
to keep schema, topology, and mode optional since the loaders.gl point cloud format doesn't require them, while sourcing the attributes type through Mesh rather than importing MeshAttributes separately.

header: {
vertexCount: number;
};
attributes: MeshAttributes;
};

const defaultProps: DefaultProps<PointCloudLayerProps> = {
sizeUnits: 'pixels',
pointSize: {type: 'number', min: 0, value: 10}, // point radius in pixels
Expand Down Expand Up @@ -70,7 +78,7 @@ export type PointCloudLayerProps<DataT = unknown> = _PointCloudLayerProps<DataT>

/** Properties added by PointCloudLayer. */
type _PointCloudLayerProps<DataT> = {
data: LayerDataSource<DataT>;
data: LayerDataSource<DataT> | LoadersGLPointCloudData;
/**
* The units of the point size, one of `'meters'`, `'common'`, and `'pixels'`.
* @default 'pixels'
Expand Down
Loading