npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@maptalks/gltf-layer

v0.101.1

Published

A maptalks Layer to render gltf

Downloads

972

Readme

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/[email protected]/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| | ------------- |---------- |-------------|--------- | | id | String | | gltflayer's id | | options | Object | 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| | ------------- |---------- |-------------|--------- | | coordinates | maptalks.Coordinates | | coordinates of the gltf marker | | options | Object | 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