@maptalks/gltf-layer v0.104.3
maptalks.gltf
Usage
maptalks.gltf is a maptalks layer used to rendering gltf models on map.
Install
- Install with npm:
npm install @maptalks/gltf-layer. - Use unpkg CDN:
https://unpkg.com/@maptalks/gltf-layer@0.2.0/dist/maptalks.gltf.js
Vanilla Javascript
<script type="text/javascript" src="../maptalks.gltf.js"></script>
<script>
var map = new maptalks.Map("map",{
center : [0, 0],
zoom : 15
});
var gltflayer = new maptalks.GLTFLayer('gltf').addTo(map);
var gltfMarker = new maptalks.GLTFMarker(coordinate, {
outline: true,
symbol : {
rotation: [90, 0, 0]
}
}).addTo(gltflayer);
</script>ES6
import { GLTFLayer } from 'maptalks.gltf';
import { GLTFMarker } from 'maptalks.gltf';
const map = new maptalks.Map("map",{
center : [0, 0],
zoom : 15
});
const gltflayer = new GLTFLayer('gltf').addTo(map);
const gltfMarker = new GLTFMarker(coordinate, {
outline: true,
symbol : {
rotation: [90, 0, 0]
}
}).addTo(gltflayer);API
Class : GLTFLayer
(inherited from maptalks.OverlayLayer)a layer used to renderering gltf model on map, it manages gltf markers.
Method : new GLTFLayer(id, options)
Parameter Type Default Description idString gltflayer's id optionsObject null construct options Method :
(static)registerShader(name, type, config, uniforms)register a custom shader to gltf layer | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
name| String | | shader's name | |type| String | | shader's type | |config| Object | | a regl shader structure | |uniforms| Object | null | uniforms transform to webgl shader |Method :
(static)removeShader(name)remove a shader from gltf layer's shader list | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
name| String | | shader's name |Method :
(static)getShaders()get all shaders registed to gltf layer
returns : Object: gltf layer's shader list
Method :
(static)fromJSON(json)create a GLTFLayer from s JSON object | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
json| Objec | | JSON object |returns : GLTFLayer: a new gltf layer
Method : addGeometry(markers)
add one or more gltf marker in gltf layer | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
markers| GLTFMarker | Array. | | one or more GLTFMarkers |returns : GLTFLayer: this
Method : removeGeometry(markers)
remove one or more gltf marker from gltf layer | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
markers| GLTFMarker | Array. | | one or more GLTFMarkers |Method : getModels()
get gltf layer's models
returns : Object: gltf model list
Method : toJSON(options)
convert gltflayer to a JSON object | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
options| Object | null | export options |returns : Object: gltflayer's JSON
Method : setStyle(layerStyle)
set styles for gltf layer | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
layerStyle| Object | | style object to set for gltflayer |returns : GLTFLayer: this
Method : getStyle()
get gltf layer's style objects if it has set | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
layerStyle| Object | | style object to set for gltflayer |returns : Object: layer's style object
Method : updateSymbol(idx, symbolProperties)
update a style's symbol for gltf layer by index | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
idx| Number | | the index of gltflayer's style | |symbolProperties| Object | null | a style object |Method : getGLTFUrls()
get all modle's url added to gltf layer
returns : Array: gltf model list
Method : clear()
clear all gltf markers
returns : GLTFLayer: this
Method : remove()
remove itself from map
Method : identify(coordinate, options)
_identify the gltf markers on the given coordinate | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
coordinate| maptalks.Coordinate | | coordinate to identify | |options| Object | null | some conditions |
Class : GLTFMarker
(inherited from maptalks.Marker)a gltf marker object to render gltf models
Method : new GLTFMarker(coordinates, options)
Parameter Type Default Description coordinatesmaptalks.Coordinates coordinates of the gltf marker optionsObject null construct options defined in GLTFMarker Method :
(static)fromJSON(json)create a new GLTFMarker from a JSON object | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
json| Object | | a JSON objec |returns : GLTFMarker: a new GLTFMarker
Method : setUrl(url)
set a gltf model path for gltf marker | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
url| String | | gltf model's path |returns : GLTFMarker: this
Method : setCoordinates(coordinates)
set coordinates for gltf marker | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
coordinates| Coordinate | Array. | | the gltf marker's location |returns : GLTFMarker: this
Method : addTo(layer)
add a gltf marker to gltf layer | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
layer| GLTFLayer | | the layer to add to |returns : GLTFMarker: this
Method : remove()
remove itselt from gltf layer
Method : show()
show the marker
returns : GLTFMarker: this
Method : hide()
hide the marker_
returns : GLTFMarker: this
Method : setBloom(bloom)
add a gltf marker to gltf layer | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
bloom| Boolean | | whether has bloom effect |returns : GLTFMarker: this
Method : isBloom()
if the gltf marker has bloom effect
returns : Boolean : if has bloom effect
Method : setCastShadow(shadow)
set shadow effect for gltf marker | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
shadow| Boolean | | whether has shadow effect |returns : GLTFMarker: this
Method : isCastShadow()
if the gltf marker has shadow effect
returns : Boolean : if has shadow effect
Method : setOutline(outline)
set outline effect for gltf marker | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
outline| Boolean | | whether has outline effect |returns : GLTFMarker: this
Method : isOutline()
if the gltf marker has outline effect
returns : Boolean : if has outline effect
Method : isVisible()
if the gltf marker has outline effect
returns : Boolean : if has outline effect
Method : copy()
_clone a marker by itself
returns : GLTFMarker : a new gltf marker
Method : setId(id)
set id for gltf marker | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
id| String | | gltf marker's id |Method : setId(id)
get gltf marker's id
Method : setShader(shader)
set a shader for gltf marker | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | |
shader| Object | |shader's config |returns : GLTFMarker : a new gltf marker
10 months ago
5 months ago
6 months ago
6 months ago
6 months ago
10 months ago
10 months ago
8 months ago
6 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago