SimpleMeshLayer renders multiple instances of a single 3D mesh with per-instance transformations, colors, and materials. It's designed for efficient rendering of many instances of the same geometry with WebGL instancing.
import { SimpleMeshLayer } from "@deck.gl/mesh-layers";
import type { SimpleMeshLayerProps } from "@deck.gl/mesh-layers";class SimpleMeshLayer<DataT = any, ExtraPropsT extends {} = {}> extends Layer<
ExtraPropsT & Required<SimpleMeshLayerProps<DataT>>
> {
constructor(props: SimpleMeshLayerProps<DataT> & ExtraPropsT);
static readonly layerName: "SimpleMeshLayer";
static readonly defaultProps: DefaultProps<SimpleMeshLayerProps>;
}interface SimpleMeshLayerProps<DataT = unknown> extends LayerProps {
// Data and mesh
data: LayerDataSource<DataT>;
mesh: string | Mesh | Promise<Mesh> | null;
// Styling
texture?: string | TextureSource | Promise<TextureSource>;
textureParameters?: SamplerProps | null;
material?: Material;
wireframe?: boolean;
sizeScale?: number;
// Accessors
getPosition?: Accessor<DataT, Position>;
getColor?: Accessor<DataT, Color>;
getOrientation?: Accessor<DataT, Orientation>;
getScale?: Accessor<DataT, Scale>;
getTranslation?: Accessor<DataT, Translation>;
getTransformMatrix?: Accessor<DataT, number[]>;
// Advanced
_instanced?: boolean;
}LayerDataSource<DataT>string | Mesh | Promise<Mesh> | nullstring | TextureSource | Promise<TextureSource> (optional)SamplerProps | null (optional)Material (optional, default: true)boolean (optional, default: false)number (optional, default: 1)Accessor<DataT, Position> (optional, default: x => x.position)[x, y, z]Accessor<DataT, Color> (optional, default: [0, 0, 0, 255])[r, g, b, a]. Mixed with vertex colors if mesh contains them. Ignored if texture is providedAccessor<DataT, Orientation> (optional, default: [0, 0, 0])[pitch, yaw, roll] in degreesAccessor<DataT, Scale> (optional, default: [1, 1, 1])[x, y, z]Accessor<DataT, Translation> (optional, default: [0, 0, 0])[x, y, z] in metersAccessor<DataT, number[]> (optional, default: [])getOrientation, getScale, and getTranslationboolean (optional, default: true)false, treats mesh positions as deltas of world coordinates instead of meter offsetsclass SimpleMeshLayer<DataT, ExtraPropsT> {
// Layer state
get isLoaded(): boolean;
getBounds(): [number[], number[]] | null;
// Rendering
getShaders(): ShaderModule;
initializeState(): void;
updateState(params: UpdateParameters<this>): void;
finalizeState(context: LayerContext): void;
draw(opts: {uniforms: any}): void;
}import { SimpleMeshLayer } from "@deck.gl/mesh-layers";
import { CubeGeometry } from "@luma.gl/engine";
const data = [
{position: [0, 0, 0], color: [255, 0, 0, 255]},
{position: [100, 100, 0], color: [0, 255, 0, 255]},
{position: [-100, 50, 100], color: [0, 0, 255, 255]}
];
const layer = new SimpleMeshLayer({
id: 'simple-mesh',
data,
mesh: new CubeGeometry(),
getPosition: d => d.position,
getColor: d => d.color,
sizeScale: 50
});import { SimpleMeshLayer } from "@deck.gl/mesh-layers";
import { COORDINATE_SYSTEM } from "@deck.gl/core";
const data = [
{
pos: [-122.4, 37.8, 0],
orientation: [0, 45, 0], // yaw 45 degrees
scale: [1, 1, 2] // stretched vertically
}
];
const layer = new SimpleMeshLayer({
id: 'transformed-mesh',
data,
mesh: '/path/to/model.obj',
getPosition: d => d.pos,
getOrientation: d => d.orientation,
getScale: d => d.scale,
coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS
});const layer = new SimpleMeshLayer({
id: 'textured-mesh',
data: myData,
mesh: myGeometry,
texture: '/path/to/texture.jpg',
textureParameters: {
[GL.TEXTURE_MIN_FILTER]: GL.LINEAR_MIPMAP_LINEAR,
[GL.TEXTURE_MAG_FILTER]: GL.LINEAR
},
getPosition: d => d.coordinates,
getColor: [255, 255, 255, 255] // use original texture colors
});import { Material } from "@deck.gl/core";
const layer = new SimpleMeshLayer({
id: 'material-mesh',
data: myData,
mesh: myGeometry,
material: new Material({
ambient: 0.35,
diffuse: 0.6,
shininess: 32,
specularColor: [30, 30, 30]
}),
getPosition: d => d.position
});SimpleMeshLayer supports all deck.gl coordinate systems:
The _instanced property affects how mesh vertex positions are interpreted:
true (default): Mesh positions are meter offsets from anchorfalse: Mesh positions are coordinate deltas (experimental)