1.0.10 • Published 6 years ago

cesium-mouse v1.0.10

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

cesium-mouse

Simple api for adding mouse handlers for Cesium.

Dependencies

EventEmitter3

Install

npm i cesium-mouse --save

Usage

Import the module:

import CesiumMouse from 'cesium-mouse';

Add the handler for the leftdown event on the canvas element. Pay attention that the event name must be in lowercase and without the symbol '_'.

const mouse = new CesiumMouse(viewer.scene);
mouse.on('leftdown', function(event) { console.log('canvas event', event); });

To add the leftdown event handler on Entity, you must mix methods EventEmitter3 with Entity and set Entity's property 'interactable' value to true.

const entity = viewer.entities.add({
    position: Cesium.Cartesian3.fromDegrees(-80.0, 25.0),
    point: {
        pixelSize: 10,
        color: Cesium.Color.RED
    }
});
CesiumMouse.mixinEventsMethods(entity);
entity.interactable = true;
entity.on('leftdown', function(event) { console.log('entity event', event); });

List of mouse events name:

  • leftdown
  • leftclick
  • leftup
  • leftdoubleclick
  • middledown
  • middleclick
  • middleup
  • rightdown
  • rightclick
  • rightup
  • wheel
  • mousemove
  • mouseover. on the Entity
  • mouseout. on the Entity

Now you can control the event calling, pointing 'interactable' = false. Also you can subscribe on your own events and call it in any place.

entity.on('myownevent', function(event) { console.log('my own event', event); });
entity.emit('myownevent', { foo: 'bar' });

License

MIT

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago