0.97.4 • Published 2 months ago

@maptalks/gltf-layer v0.97.4

Weekly downloads
47
License
UNLICENSED
Repository
github
Last release
2 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.97.4

2 months ago

0.97.2

2 months ago

0.97.0

2 months ago

0.97.1

2 months ago

0.96.0

3 months ago

0.95.8

3 months ago

0.95.6

3 months ago

0.95.5

4 months ago

0.95.4

4 months ago

0.95.2

4 months ago

0.95.0

4 months ago

0.93.0

5 months ago

0.90.0

7 months ago

0.94.0

5 months ago

0.87.1

10 months ago

0.87.0

10 months ago

0.91.4

6 months ago

0.91.0

7 months ago

0.91.2

6 months ago

0.88.0

10 months ago

0.92.0

6 months ago

0.89.3

9 months ago

0.89.0

9 months ago

0.89.1

9 months ago

0.89.2

9 months ago

0.86.0

10 months ago

0.85.0

11 months ago

0.83.1

11 months ago

0.83.0

11 months ago

0.84.4

11 months ago

0.84.5

11 months ago

0.84.0

11 months ago

0.84.1

11 months ago

0.84.2

11 months ago

0.84.3

11 months ago

0.36.2

1 year ago

0.36.1

1 year ago

0.36.0

1 year ago

0.82.0

1 year ago

0.35.1

1 year ago

0.35.0

1 year ago

0.34.2

2 years ago

0.34.1

2 years ago

0.34.0

2 years ago

0.33.5

2 years ago

0.32.2

2 years ago

0.32.1

2 years ago

0.33.4

2 years ago

0.33.3

2 years ago

0.33.2

2 years ago

0.33.1

2 years ago

0.33.0

2 years ago

0.32.0

2 years ago

0.30.1

2 years ago

0.30.0

2 years ago

0.31.0

2 years ago

0.29.0

2 years ago

0.29.3

2 years ago

0.29.2

2 years ago

0.29.1

2 years ago

0.26.1

2 years ago

0.26.0

2 years ago

0.27.1

2 years ago

0.27.0

2 years ago

0.28.0

2 years ago

0.25.0

2 years ago

0.24.1

3 years ago

0.24.0

3 years ago

0.23.4

3 years ago

0.23.3

3 years ago

0.23.2

3 years ago

0.23.1

3 years ago

0.23.0

3 years ago

0.22.1

3 years ago

0.22.0

3 years ago

0.21.13

3 years ago

0.21.12

3 years ago

0.21.11

3 years ago

0.21.10

3 years ago

0.21.9

3 years ago

0.21.8

3 years ago

0.21.7

3 years ago

0.21.6

3 years ago

0.21.5

3 years ago

0.21.4

3 years ago

0.21.3

3 years ago

0.21.2

3 years ago

0.21.1

3 years ago

0.21.0

3 years ago

0.20.0

3 years ago

0.19.1

3 years ago

0.19.0

3 years ago

0.18.2

3 years ago

0.18.1

3 years ago

0.18.0

3 years ago

0.17.0

3 years ago

0.16.3

3 years ago

0.16.2

3 years ago

0.16.1

3 years ago

0.16.0

3 years ago

0.15.1

3 years ago

0.15.0

3 years ago

0.14.6

3 years ago

0.14.5

3 years ago

0.14.4

3 years ago

0.14.1

3 years ago

0.14.2

3 years ago

0.14.3

3 years ago

0.14.0

3 years ago

0.13.5

3 years ago

0.13.4

3 years ago

0.13.3

3 years ago

0.13.2

3 years ago

0.13.0

4 years ago

0.12.13

4 years ago

0.12.12

4 years ago

0.12.11

4 years ago

0.12.10

4 years ago

0.12.9

4 years ago

0.12.8

4 years ago

0.12.7

4 years ago

0.12.6

4 years ago

0.12.5

4 years ago

0.12.4

4 years ago

0.12.3

4 years ago

0.12.2

4 years ago

0.12.1

4 years ago

0.12.0

4 years ago

0.11.2

4 years ago

0.11.1

4 years ago

0.11.0

4 years ago

0.10.2

4 years ago

0.10.1

4 years ago

0.10.0

4 years ago

0.9.0

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.7.0

4 years ago

0.6.6

4 years ago

0.6.5

4 years ago

0.6.4

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.2

4 years ago

0.5.0

4 years ago

0.5.1

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago