3D JS API reference
This reference documents every object and method available. Each section describes classes or objects as well as their properties, parameters, methods, and associated events. Many sections also include inline code examples and related resources.
The MapTiler Layer3D
can add 3D objects to your basemap with plenty of customizations from glTF/glb files! Those can be meshes, groups of meshes, point clouds and a mix of all these.
Example (create layer with some not default options)
Constructor
Creates a instance of Layer3D class. The constructor takes two arguments:
Parameters
options.minZoom
default:
0 |
Bellow this zoom level, the meshes are not visible |
---|---|
options.maxZoom
default:
22 |
Beyond this zoom level, the meshes are not visible. |
options.antialias
default:
true |
Shows the AR button if true , hide it otherwise.
|
options.ambientLightColor
default:
0xffffff (white) |
Ambient light color. |
options.ambientLightIntensity
default:
1 |
Ambient light intensity. |
Methods
To adjust the settings of the ambient light.
By default, the ambient light is white (0xffffff
) with
an intensity of 0.5
.
number
)?
: Ambient light color intensity
async Adds a mesh from a URL to a glTF of glb file.
String
)
: mesh ID (will throw if not unique)
String
)
: URL of the mesh glTF of glb file
Adds a ThreeJS mesh/Group/Object3D.
By default, the mesh will have some settings (if not overwritten by the options):
- sourceOrientation:
SourceOrientation.Y_UP
- altitude:
0
- lngLat:
[0, 0]
- heading:
0
- visible:
true
String
)
: mesh ID (will throw if not unique)
mesh
|Group
|Object3D
)
: ThreeJS mesh, Group or Object3D
Modify the settings of a mesh (scale, lntLat, etc.)
Only the settings provided in the option object will be updated, the others will be left as they already are.
String
)
: mesh ID
Clones a mesh that has a given ID (sourceId
) and
create another one with a new ID (id
).
The provided options will overwrite the settings of the source mesh.
String
)
: Source mesh ID
String
)
: new mesh ID (will throw if not unique)
Adds a point light
By default, the light will have some settings (if not overwritten by the options):
- lngLat:
[0, 0]
(null island) - altitude:
2_000_000
meters - altitudeReference:
AltitudeReference.MEAN_SEA_LEVEL
- color:
0xffffff
(white) - intensity:
75
- decay:
0.2
String
)
: a unique ID (will throw if not unique)
Modify a point light given its ID
Only the settings provided in the option object will be updated, the others will be left as they already are.
String
)
: point of light ID
Remove a mesh or point light from the scene and frees the GPU memory associated to it.
String
)
: mesh or point light ID
Removes all the meshes and point lights from the scene and frees the GPU memory associated with them.