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/transform-control

v0.102.2

Published

a plugin to control model's translate、rotation and scale

Downloads

826

Readme

maptalks.TransformControl

NPM Version

Usage

transform-control a plugin to control model's translate、rotation and scale.

Install

  • Install with npm: npm install @maptalks/transform-control.
  • Use unpkg CDN: https://unpkg.com/@maptalks/transform-control/dist/transform-control.js

Vanilla Javascript

<script type="text/javascript" src="../maptalks.transform-control.js"></script>
<script>
var map = new maptalks.Map("map",{
    center : [0, 0],
    zoom   :  15
});
var transformControl = new maptalks.TransformControl();
transformControl.addTo(map);
transformControl.on('transforming', e => {
    //get translate、rotation、scale
    const translate = e.translate;
    const rotation = e.rotation;
    const scale = e.scale;
});
</script>

ES6

import TransfromControl from '@maptalks/transform-control';

const map = new maptalks.Map("map",{
    center : [0, 0],
    zoom   :  15
});
const transformControl = new maptalks.TransformControl();
transformControl.addTo(map);
transformControl.on('transforming', e => {
    const target = e.target;
    target.setTRS(e.translate, e.rotation, e.scale);
});
transformControl.on('positionchange', e => {
    const target = e.target;
    target.setCoordinates(e.coordinate);
});

API

  • Class : TransformControl(inherited from maptalks.Eventable)

    transform control's constructor.

    Method : new TransformControl(options)

    | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | | id | String | | transform control's id | | options | Object | null | construct options |

    Method : addTo(map)

    add the control to a map | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | | map | maptalks.Map | | a map to add |

    returns : TransformControl: this

    Method : remove()

    remove the control from map

    Method : transform(target)

    specify a target to transform | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | | target | GLTFMarker | Mesh | null | the target to transform |

    Method : getTransformTarget()

    get the current tranforming target

    returns : Object: the transforming target object

    Method : enable()

    enable the control

    returns : TransformControl: return this

    Method : disable()

    disable the control, when disable the control, it will be not available TransformControl: return this

    Method : isEnbale()

    whether the control is enable Boolean: true or false

    Event : transforming

    when transforming the target, it will trigger transforming event | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | | target | GLTFMarker | | the target to transform | | action | String | | transforming action, includes xy-translatex-translatey-translatez-translatez-rotatescale | | type | GLTFMarker | | event type name | | translate | Array | | current translate when transforming | | scale | Array | | current scale when transforming | | rotation | Array | | current rotation when transforming |

    Event : positionchange

    when changing target's position, it will trigger positionchange event | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | | target | GLTFMarker | | the target to transform | | action | String | | transforming action, includes xy-translatex-translatey-translatez-translatez-rotatescale | | type | GLTFMarker | | event type name | | coordinate | Array | | current coordinate when changing target's position |

    Event : transformend

    when endding the transform task, it will trigger transformend event | Parameter | Type | Default | Description| | ------------- |---------- |-------------|--------- | | target | GLTFMarker | | the target to be transformed | | action | String | | current action | | type | GLTFMarker | | event type name |