Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion lonboard/experimental/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
unexpected behavior when using them.
"""

from ._layer import ArcLayer, TextLayer, TripsLayer
from ._layer import ArcLayer, SimpleMeshLayer, TextLayer, TripsLayer

__all__ = [
"ArcLayer",
"SimpleMeshLayer",
"TextLayer",
"TripsLayer",
]
15 changes: 14 additions & 1 deletion lonboard/experimental/_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from arro3.core import DataType, Scalar

from lonboard._constants import EXTENSION_NAME, MIN_INTEGER_FLOAT32
from lonboard._layer import BaseArrowLayer
from lonboard._layer import BaseArrowLayer, BaseLayer
from lonboard._utils import timestamp_max_physical_value, timestamp_start_offset
from lonboard.experimental.traits import TimestampAccessor
from lonboard.traits import (
Expand Down Expand Up @@ -176,6 +176,19 @@ def __init__(
)


class SimpleMeshLayer(BaseLayer):
"""SimpleMeshLayer."""

def __init__(self, **kwargs) -> None:
super().__init__(**kwargs) # type: ignore

_layer_type = t.Unicode("simple-mesh").tag(sync=True)

positions = PointAccessor(None, allow_none=True)
normals = PointAccessor(None, allow_none=True)
tex_coords = PointAccessor(None, allow_none=True)


class TextLayer(BaseArrowLayer):
"""Render text labels at given coordinates."""

Expand Down
18 changes: 4 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@deck.gl/core": "^9.1.14",
"@deck.gl/extensions": "^9.1.14",
"@deck.gl/layers": "^9.1.14",
"@deck.gl/mesh-layers": "^9.1.14",
"@deck.gl/react": "^9.1.14",
"@geoarrow/deck.gl-layers": "^0.3.1",
"@babel/runtime": "^7.28.4",
Expand Down
80 changes: 80 additions & 0 deletions src/model/layer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SimpleMeshLayer, SimpleMeshLayerProps } from "@deck.gl/mesh-layers";
import {
GeoArrowArcLayer,
GeoArrowColumnLayer,
Expand Down Expand Up @@ -772,6 +773,81 @@ export class SolidPolygonModel extends BaseArrowLayerModel {
}
}

type MeshPositions = {
value: Float32Array;
size: number;
};

type MeshNormals = {
value: Float32Array;
size: number;
};

type MeshTexCoords = {
value: Float32Array;
size: number;
};

const DUMMY_DATA: number[] = [1];

export class SimpleMeshModel extends BaseLayerModel {
static layerType = "simple-mesh";

protected positions!: MeshPositions;
protected normals!: MeshNormals;
protected texCoords!: MeshTexCoords;

protected sizeScale: SimpleMeshLayerProps["sizeScale"];
protected wireframe: SimpleMeshLayerProps["wireframe"];
// protected material: SimpleMeshLayerProps["material"];
// protected getPosition: SimpleMeshLayerProps["getPosition"] | null;
// protected getColor: SimpleMeshLayerProps["getColor"] | null;
// protected getOrientation: SimpleMeshLayerProps["getOrientation"] | null;
// protected getScale: SimpleMeshLayerProps["getScale"] | null;
// protected getTranslation: SimpleMeshLayerProps["getTranslation"] | null;

constructor(model: WidgetModel, updateStateCallback: () => void) {
super(model, updateStateCallback);

this.initVectorizedAccessor("positions", "positions");
this.initVectorizedAccessor("normals", "normals");
this.initVectorizedAccessor("tex_coords", "texCoords");

this.initRegularAttribute("size_scale", "sizeScale");
this.initRegularAttribute("wireframe", "wireframe");
}

layerProps(): Omit<SimpleMeshLayerProps, "id"> {
return {
data: DUMMY_DATA,
mesh: {
positions: this.positions,
normals: this.normals,
texCoords: this.texCoords,
},
...(isDefined(this.sizeScale) && { sizeScale: this.sizeScale }),
...(isDefined(this.wireframe) && { wireframe: this.wireframe }),
// ...(isDefined(this.material) && { material: this.material }),
// ...(isDefined(this.getPosition) && { getPosition: this.getPosition }),
// ...(isDefined(this.getColor) && { getColor: this.getColor }),
// ...(isDefined(this.getOrientation) && {
// getOrientation: this.getOrientation,
// }),
// ...(isDefined(this.getScale) && { getScale: this.getScale }),
// ...(isDefined(this.getTranslation) && {
// getTranslation: this.getTranslation,
// }),
};
}

render(): SimpleMeshLayer {
return new SimpleMeshLayer({
...this.baseLayerProps(),
...this.layerProps(),
});
}
}

export class TextModel extends BaseArrowLayerModel {
static layerType = "text";

Expand Down Expand Up @@ -1025,6 +1101,10 @@ export async function initializeLayer(
layerModel = new SolidPolygonModel(model, updateStateCallback);
break;

case SimpleMeshModel.layerType:
layerModel = new SimpleMeshModel(model, updateStateCallback);
break;

case TextModel.layerType:
layerModel = new TextModel(model, updateStateCallback);
break;
Expand Down
Loading