Giter Club home page Giter Club logo

aframe-mouse-dragndrop's Introduction

npm version jsdelivr version

aframe-mouse-dragndrop

Drag-n-drop entites using mouse cursor.

implementation

There's a new parameter in cursor component that we can use to monitor mouse interaction.

<a-scene cursor="rayOrigin: mouse"></a-scene>

Based on this feature, we can intercept the event data emitting by the cursor component. read more about cursor component

I've sperated this module into two sepearte component, track-cursor and dragndrop. And use dependencies to chain component startup. read more about component dependencies So you can add features like animation or hovering effects before draggin it.

When a draggable component is being hovered by the cursor, it will make the entity into tracking state. You can check it with

if (this.el.is("tracking")) {
  ...
}

If a draggable component is being pressed, it will enter the dragging state. Likewise you can check it with:

if (this.el.is("dragging")) {
  ...
}

If you want to do some startup/cleanup before entering/exiting these two states, be sure to listener to "stateadded"/"stateremoved" events.

usage

<a-entity dragndrop></a-entity>

After adding the component, you can drag and drop it with mouse click.

additional features

  1. When dragging the entity, look-controls on the camera will be temporary disabled.
  2. You can use mousewheel to send it further/closer when dragging.

Check out the live demo: link

Appreciate any suggestions or feedback.

aframe-mouse-dragndrop's People

Contributors

extraymond avatar robotgrrl avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.