fix(PointCloudLayer): add TypeScript types for loaders.gl point cloud data format#10272
fix(PointCloudLayer): add TypeScript types for loaders.gl point cloud data format#10272subodhbhyri wants to merge 3 commits into
Conversation
| const DEFAULT_COLOR = [0, 0, 0, 255] as const; | ||
| const DEFAULT_NORMAL = [0, 0, 1] as const; | ||
|
|
||
| type LoadersGLAttribute = { |
There was a problem hiding this comment.
Can we not import this type from loaders?
There was a problem hiding this comment.
Good call, I imported MeshAttributes directly from @loaders.gl/schema and removed the manual type definition.
…nstead of redefining
| const DEFAULT_COLOR = [0, 0, 0, 255] as const; | ||
| const DEFAULT_NORMAL = [0, 0, 1] as const; | ||
|
|
||
| export type LoadersGLPointCloudData = { |
There was a problem hiding this comment.
If we import the type Mesh instead of MeshAttributes I think we get this.
There was a problem hiding this comment.
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.
|
Anything I can do to help bring this over the finish line? :) |
Problem
PointCloudLayerhas anormalizeDatafunction that supports the loaders.glpoint cloud data format at runtime, but the
dataprop type only acceptedLayerDataSource<DataT>, causing a TypeScript error when passing a conformingloaders.gl object.
Fixes #10219
Changes
LoadersGLAttributetype to describe a typed array attribute in the loaders.gl mesh formatLoadersGLPointCloudDatatype to describe the full loaders.gl point cloud data shapedataprop in_PointCloudLayerPropsto acceptLayerDataSource<DataT> | LoadersGLPointCloudDataTesting
PointCloudLayer#loaders.gl supportintest/modules/layers/point-cloud-layer.spec.tspassesdatano longer produces a TypeScript error