npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aframe-graph

v0.0.1

Published

Dynamically Connected Graphs for A-Frame

Downloads

1

Readme

Overview

A set of A-Frame components that can be used to build a graph of nodes & edges

Current focus is on tracking changes to the components (sets of connected nodes) that make up the graph. May be extended to other applications of graphs in future.

graph

Top-level component set on the a-scene to set properties of the graph. Currently just controls debug display

graph-node

Set this component on an entity that you want to appear as a node in the graph

graph-edge

Set this component on an entity that is a node in the graph, to connect it via an edge to another node. A node can have multiple edges, and can even have multiple edges to the same remote node.

Schemas

graph

| Property | Description | Default | | -------- | ------------------------------------------- | ------- | | debug | Draw lines to represent edges between nodes | false |

graph-node

This component has no properties

graph-edge

| Property | Description | Default | | -------- | ------------------------------------------------------------ | ------- | | target | A selector for the entity to connect the edge to. Both entities must have the graph-nodecomponent set on them. Edges are undirected. | none |

Events

The following events are emitted by the edge component when it is added or removed, and that results in a change to the connected components in the graph.

| Event | Description | | ------------------------- | ------------------------------------------------------------ | | graph-components-joined | Two components in the graph have been joined together into a single component. | | graph-components-split | A component in the graph has been split into two components. |

Each event includes additional detail as follows:

| Property | Description | | ---------------- | ------------------------------------------------------------ | | otherNode | The entity at the far end of the edge that was added / removed to trigger the event | | thisComponent | An array of Object3D UUIDs for the nodes in the component that this node is a member of. | | otherComponent | An array of Object3D UUIDs for the nodes in the component that the node at the other end of the added / removed edge is a member of. |

For the joined event, the data in thisComponent & otherComponent represents the state before the join. For the split event, it represents the state after the split event.

The state after the join event, or before the split event can be generated from this data by concatenating the two arrays.

Mapping Object3D UUIDs back to node entities is the responsibility of the application handling the events. One option is to maintain a scene-level object with Object3D UUIDs as keys that map back to the node entities, as done in this example.

Installation

Via CDN

<script src="https://cdn.jsdelivr.net/npm/[email protected]/index.min.js"></script>

Or via npm

npm install aframe-graph

Examples

A simple example that builds a graph between 4 nodes:

    <a-scene background="color:black" graph="debug: true">

      <a-entity id="container" position = "0 0 -4">
        <a-box id="box1" position="-1 1 0"color="red"
               graph-node
               graph-edge__2="target:#box2"
               graph-edge__3="target:#box3">
        </a-box>
        <a-box id="box2" position="1 1 0"color="green"
               graph-node
               graph-edge__1="target:#box1"
               graph-edge__3="target:#box3">
        </a-box>
        <a-box id="box3" position="-1 3 0"color="blue"
               graph-node
               graph-edge__1="target:#box1"
               graph-edge__4="target:#box4">
        </a-box>
        <a-box id="box4" position="1 3 0"color="yellow"
               graph-node
               graph-edge__1="target:#box1">
        </a-box>
      </a-entity>
    </a-scene>

View the example here.

A more complicated example, showing dynamic addition /removal of edges, and component detection can be seen here.

image-20230318092739663

Code

graph