The Mesh Layer renders a number of arbitrary geometries. For example, a fleet of 3d cars each with a position and an orientation over the map.
import DeckGL from 'deck.gl';
import {MeshLayer} from '@deck.gl/experimental-layers';
import {CubeGeometry} from 'luma.gl'
const App = ({data, viewport}) => {
/**
* Data format:
* [
* {
* position: [-122.45, 37.7],
* angle: 0,
* color: [255, 0, 0]
* },
* {
* position: [-122.46, 37.73],
* angle: 90,
* color: [0, 255, 0]
* },
* ...
* ]
*/
const layer = new MeshLayer({
id: 'mesh-layer',
data,
sizeScale: 100,
texture: 'texture.png',
mesh: new CubeGeometry()
});
return (<DeckGL {...viewport} layers={[layer]} />);
};
mesh
(Geometry|Object)The geometry to render for each data object. Can be a luma.gl Geometry instance, or an object of attributes.
The following attributes are expected:
positions
(Float32Array) - 3d vertex offset from the object center, in metersnormals
(Float32Array) - 3d nomalstexCoords
(Float32Array) - 2d texture coordinatestexture
(Texture2D|Image|String, optional)null
.The texture of the geometries. Can be either a luma.gl Texture2D instance, an HTMLImageElement, or a url string to the texture image.
If texture
is supplied, texture is used to render the geometries. Otherwise, object color obtained via the getColor
accessor is used.
sizeScale
(Number, optional)1
.Multiplier to scale each geometry by.
getPosition
(Function, optional)object => object.position
This accessor returns the center position corresponding to an object in the data
stream.
getYaw
(Function, optional)object => object.yaw || object.angle || 0
The yaw (heading) in degrees of each object.
getPitch
(Function, optional)object => object.pitch || 0
The pitch (elevation) in degrees of each object.
getRoll
(Function, optional)object => object.roll || 0
The roll (bank) in degrees of each object.
See Euler angles.
getScale
(Function, optional)object => object.scale || [1, 1, 1]
Scaling factor on the mesh along each axis.
getTranslation
(Function, optional)object => object.translation || [0, 0, 0]
Translation of the mesh along each axis. Offset from the center position given by getPosition
getMatrix
(Function, optional)object => null
Explicitly define a 4x4 column-major model matrix for the mesh. If provided, will override
getYaw
, getPitch
, getRoll
, getScale
, getTranslation
.
getColor
(Function|Array, optional)[0, 0, 0, 255]
The color of each object. Only used if texture
is empty.
fp64
(Boolean, optional)false
Whether the layer should be rendered in high-precision 64-bit mode
lightSettings
(Object, optional)TO BE REPLACED
With @deck.gl/mesh-layers