Skip to content
Open
Changes from 1 commit
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
20 changes: 19 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 @@ -30,6 +30,24 @@ import source from './point-cloud-layer.wgsl';
const DEFAULT_COLOR = [0, 0, 0, 255] as const;
const DEFAULT_NORMAL = [0, 0, 1] as const;

type LoadersGLAttribute = {
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.

Can we not import this type from loaders?

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.

Good call, I imported MeshAttributes directly from @loaders.gl/schema and removed the manual type definition.

size: number;
value: ArrayBufferView;
type?: number;
};

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: {
POSITION?: LoadersGLAttribute;
NORMAL?: LoadersGLAttribute;
COLOR_0?: LoadersGLAttribute;
[key: string]: LoadersGLAttribute | undefined;
};
};

const defaultProps: DefaultProps<PointCloudLayerProps> = {
sizeUnits: 'pixels',
pointSize: {type: 'number', min: 0, value: 10}, // point radius in pixels
Expand Down Expand Up @@ -70,7 +88,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