0.102.1 • Published 10 months ago

@maptalks/transform-control v0.102.1

Weekly downloads
37
License
UNLICENSED
Repository
github
Last release
10 months ago

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)

    ParameterTypeDefaultDescription
    idStringtransform control's id
    optionsObjectnullconstruct 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 |

0.102.1

10 months ago

0.102.0

10 months ago

0.101.0

10 months ago

0.99.0

1 year ago

0.100.0

1 year ago

0.98.5

12 months ago

0.98.1

1 year ago

0.98.2

1 year ago

0.98.3

1 year ago

0.98.4

1 year ago

0.98.0

1 year ago

0.97.4

1 year ago

0.97.2

1 year ago

0.97.0

2 years ago

0.97.1

2 years ago

0.96.0

2 years ago

0.95.8

2 years ago

0.95.6

2 years ago

0.95.5

2 years ago

0.95.4

2 years ago

0.95.2

2 years ago

0.95.0

2 years ago

0.87.0

2 years ago

0.91.4

2 years ago

0.91.0

2 years ago

0.93.0

2 years ago

0.91.2

2 years ago

0.88.0

2 years ago

0.90.0

2 years ago

0.92.0

2 years ago

0.94.0

2 years ago

0.89.3

2 years ago

0.87.1

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.83.1

2 years ago

0.85.0

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.82.0

2 years ago

0.8.0

2 years ago

0.7.0

3 years ago

0.6.1

3 years ago

0.6.0

4 years ago

0.5.7

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.20

4 years ago

0.3.19

4 years ago

0.3.18

4 years ago

0.3.17

4 years ago

0.3.16

5 years ago

0.3.15

5 years ago

0.3.14

5 years ago

0.3.13

5 years ago

0.3.12

5 years ago

0.3.11

5 years ago

0.3.10

5 years ago

0.3.9

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago