Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

scenevr/selectable-component

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A-frame component for selecting one entity (useful for editors)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.