🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@maptalks/gltf-layer

Package Overview
Dependencies
Maintainers
1
Versions
199
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@maptalks/gltf-layer

A maptalks Layer to render gltf

Source
npmnpm
Version
0.97.4
Version published
Weekly downloads
2.6K
58%
Maintainers
1
Weekly downloads
 
Created
Source

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

    ParameterTypeDefaultDescription
    nameStringshader's name
    typeStringshader's type
    configObjecta regl shader structure
    uniformsObjectnulluniforms transform to webgl shader

    Method : (static)removeShader(name)

    remove a shader from gltf layer's shader list

    ParameterTypeDefaultDescription
    nameStringshader'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

    ParameterTypeDefaultDescription
    jsonObjecJSON object

    returns :
    GLTFLayer: a new gltf layer

    Method : addGeometry(markers)

    add one or more gltf marker in gltf layer

    ParameterTypeDefaultDescription
    markersGLTFMarker | Array.one or more GLTFMarkers

    returns :
    GLTFLayer: this

    Method : removeGeometry(markers)

    remove one or more gltf marker from gltf layer

    ParameterTypeDefaultDescription
    markersGLTFMarker | 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

    ParameterTypeDefaultDescription
    optionsObjectnullexport options

    returns :
    Object: gltflayer's JSON

    Method : setStyle(layerStyle)

    set styles for gltf layer

    ParameterTypeDefaultDescription
    layerStyleObjectstyle object to set for gltflayer

    returns :
    GLTFLayer: this

    Method : getStyle()

    get gltf layer's style objects if it has set

    ParameterTypeDefaultDescription
    layerStyleObjectstyle 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

    ParameterTypeDefaultDescription
    idxNumberthe index of gltflayer's style
    symbolPropertiesObjectnulla 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

    ParameterTypeDefaultDescription
    coordinatemaptalks.Coordinatecoordinate to identify
    optionsObjectnullsome 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

    ParameterTypeDefaultDescription
    jsonObjecta JSON objec

    returns :
    GLTFMarker: a new GLTFMarker

    Method : setUrl(url)

    set a gltf model path for gltf marker

    ParameterTypeDefaultDescription
    urlStringgltf model's path

    returns :
    GLTFMarker: this

    Method : setCoordinates(coordinates)

    set coordinates for gltf marker

    ParameterTypeDefaultDescription
    coordinatesCoordinate | Array.the gltf marker's location

    returns :
    GLTFMarker: this

    Method : addTo(layer)

    add a gltf marker to gltf layer

    ParameterTypeDefaultDescription
    layerGLTFLayerthe 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

    ParameterTypeDefaultDescription
    bloomBooleanwhether 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

    ParameterTypeDefaultDescription
    shadowBooleanwhether 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

    ParameterTypeDefaultDescription
    outlineBooleanwhether 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

    ParameterTypeDefaultDescription
    idStringgltf marker's id

    Method : setId(id)

    get gltf marker's id

    Method : setShader(shader)

    set a shader for gltf marker

    ParameterTypeDefaultDescription
    shaderObjectshader's config

    returns :
    GLTFMarker : a new gltf marker

FAQs

Package last updated on 14 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts