1.6.0 • Published 10 years ago

aframe-selectable-component v1.6.0

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

Selectable component

Usage:

<a-scene>
  <a-entity selectable>
    <a-cube position="-2 0 0"></a-cube>
    <a-cube position="2 0 0"></a-cube>
  </a-entity>

  <a-camera position="0 1.8 5">
    <a-entity
      cursor="maxDistance: 30; timeout: 500"
      position="0 0 -5"
      geometry="primitive: ring; radiusInner: 0.1; radiusOuter: 0.15; segmentsTheta: 32"
      material="color: #ff7700; shader: flat">
    </a-entity>
  </a-camera>
<a-scene>

Now everything inside the first entity will be selectable. Focus the ring on it, and click, to put a bounding box around the selected entity. Fires a selected event on the element with the selectable attribute.

document.querySelector('a-entity[selectable]').addEventListener('selected', (e) => {
  console.log(e.selected);
});

Only one thing at a time can be selected, but I'm open to pull requests to allow multi-selection.

Click an element again to toggle selection.

Click anywhere else in the scene to remove the selection.

1.6.0

10 years ago

1.5.0

10 years ago

1.4.4

10 years ago

1.4.3

10 years ago

1.4.2

10 years ago

1.4.1

10 years ago

1.3.0

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.1.0

10 years ago