0.101.1 • Published 8 months ago

@maptalks/gltf-layer v0.101.1

Weekly downloads
47
License
UNLICENSED
Repository
github
Last release
8 months ago

maptalks.gltf

NPM Version Circle CI

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)

    ParameterTypeDefaultDescription
    idStringgltflayer's id
    optionsObjectnullconstruct 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)

    ParameterTypeDefaultDescription
    coordinatesmaptalks.Coordinatescoordinates of the gltf marker
    optionsObjectnullconstruct 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

0.101.1

8 months ago

0.98.3

8 months ago

0.101.0

8 months ago

0.98.1

10 months ago

0.98.2

10 months ago

0.98.0

10 months ago

0.99.0

10 months ago

0.100.0

10 months ago

0.97.4

1 year ago

0.97.2

1 year ago

0.97.0

1 year ago

0.97.1

1 year ago

0.96.0

1 year ago

0.95.8

1 year ago

0.95.6

1 year ago

0.95.5

1 year ago

0.95.4

1 year ago

0.95.2

1 year ago

0.95.0

1 year ago

0.93.0

2 years ago

0.90.0

2 years ago

0.94.0

2 years ago

0.87.1

2 years ago

0.87.0

2 years ago

0.91.4

2 years ago

0.91.0

2 years ago

0.91.2

2 years ago

0.88.0

2 years ago

0.92.0

2 years ago

0.89.3

2 years ago

0.89.0

2 years ago

0.89.1

2 years ago

0.89.2

2 years ago

0.86.0

2 years ago

0.85.0

2 years ago

0.83.1

2 years ago

0.83.0

2 years ago

0.84.4

2 years ago

0.84.5

2 years ago

0.84.0

2 years ago

0.84.1

2 years ago

0.84.2

2 years ago

0.84.3

2 years ago

0.36.2

2 years ago

0.36.1

2 years ago

0.36.0

2 years ago

0.82.0

2 years ago

0.35.1

2 years ago

0.35.0

2 years ago

0.34.2

3 years ago

0.34.1

3 years ago

0.34.0

3 years ago

0.33.5

3 years ago

0.32.2

3 years ago

0.32.1

3 years ago

0.33.4

3 years ago

0.33.3

3 years ago

0.33.2

3 years ago

0.33.1

3 years ago

0.33.0

3 years ago

0.32.0

3 years ago

0.30.1

3 years ago

0.30.0

3 years ago

0.31.0

3 years ago

0.29.0

4 years ago

0.29.3

3 years ago

0.29.2

4 years ago

0.29.1

4 years ago

0.26.1

4 years ago

0.26.0

4 years ago

0.27.1

4 years ago

0.27.0

4 years ago

0.28.0

4 years ago

0.25.0

4 years ago

0.24.1

4 years ago

0.24.0

4 years ago

0.23.4

4 years ago

0.23.3

4 years ago

0.23.2

4 years ago

0.23.1

4 years ago

0.23.0

4 years ago

0.22.1

4 years ago

0.22.0

4 years ago

0.21.13

4 years ago

0.21.12

4 years ago

0.21.11

4 years ago

0.21.10

4 years ago

0.21.9

4 years ago

0.21.8

4 years ago

0.21.7

4 years ago

0.21.6

4 years ago

0.21.5

4 years ago

0.21.4

4 years ago

0.21.3

4 years ago

0.21.2

4 years ago

0.21.1

4 years ago

0.21.0

4 years ago

0.20.0

4 years ago

0.19.1

4 years ago

0.19.0

4 years ago

0.18.2

4 years ago

0.18.1

4 years ago

0.18.0

4 years ago

0.17.0

4 years ago

0.16.3

4 years ago

0.16.2

4 years ago

0.16.1

4 years ago

0.16.0

4 years ago

0.15.1

4 years ago

0.15.0

4 years ago

0.14.6

4 years ago

0.14.5

4 years ago

0.14.4

4 years ago

0.14.1

5 years ago

0.14.2

5 years ago

0.14.3

5 years ago

0.14.0

5 years ago

0.13.5

5 years ago

0.13.4

5 years ago

0.13.3

5 years ago

0.13.2

5 years ago

0.13.0

5 years ago

0.12.13

5 years ago

0.12.12

5 years ago

0.12.11

5 years ago

0.12.10

5 years ago

0.12.9

5 years ago

0.12.8

5 years ago

0.12.7

5 years ago

0.12.6

5 years ago

0.12.5

5 years ago

0.12.4

5 years ago

0.12.3

5 years ago

0.12.2

5 years ago

0.12.1

5 years ago

0.12.0

5 years ago

0.11.2

5 years ago

0.11.1

5 years ago

0.11.0

5 years ago

0.10.2

5 years ago

0.10.1

5 years ago

0.10.0

5 years ago

0.9.0

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.6.6

5 years ago

0.6.5

5 years ago

0.6.4

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.2

5 years ago

0.5.0

5 years ago

0.5.1

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago