# aframe-broadcast-component

> Broadcast component for A-Frame.

Latest version **0.1.0** (published 2016-05-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install aframe-broadcast-component
pnpm add aframe-broadcast-component
yarn add aframe-broadcast-component
bun add aframe-broadcast-component
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2016-05-13 |
| First published | 2016-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | Kevin Ngo |
| Maintainers | ngokevin |
| Keywords | aframe, aframe-component, aframe-vr, vr, mozvr, webvr |

## Links

- npm: https://www.npmjs.com/package/aframe-broadcast-component
- Repository: https://github.com/ngokevin/aframe-broadcast-component
- Homepage: https://github.com/ngokevin/aframe-broadcast-component#readme
- Issues: https://github.com/ngokevin/aframe-broadcast-component/issues
- npm.io page: https://npm.io/package/aframe-broadcast-component

## Dependencies (2)

- [socket.io](https://npm.io/package/socket.io.md) ^1.4.6
- [socket.io-client](https://npm.io/package/socket.io-client.md) ^1.4.6

## Recent versions

- 0.1.0 (latest) — 2016-05-13

## README

## aframe-broadcast-component

A component to send and consume entity data over WebSockets for simple
multiuser [A-Frame](https://aframe.io).

The provided server simply relays all broadcasted data through WebSockets to
the rest of the clients.

When the `broadcast` component is attached to an entity, it will emit all
specified component data, the entity ID, and the parent's ID to the WebSocket
server once every 10ms (will be adjustable later).

When another client receives that data, it uses it to create an element with
the ID if it doesn't exist, and then sync the component data to the entity with
`setAttribute`.

### Properties

| Property | Description                                          | Default Value          |
| -------- | -----------                                          | -------------          |
| send     | List of comma-delimited component names to broadcast | position, rotation     |
| url      | WebSocket server URL                                 | http://localhost:12000 |

### Usage

#### Server

There is a simple Node `socket.io` server in `server/`.

```
PORT=12000 node index.js
```

#### Browser Installation

Install and use by directly including the [browser files](dist):

```html
<head>
  <title>My A-Frame Scene</title>
  <script src="https://aframe.io/releases/0.2.0/aframe.min.js"></script>
  <script src="https://rawgit.com/ngokevin/aframe-broadcast-component/master/dist/aframe-broadcast-component.min.js"></script>
</head>

<body>
  <a-scene broadcast="http://myserver.com:12000">
    <a-entity broadcast="send: geometry, material, position, rotation"
              camera look-controls wasd-controls
              geometry="primitive: box"
              material="color: #222"
              position="0 1.8 5"></a-entity>
  </a-scene>
</body>
```

#### NPM Installation

Install via NPM:

```bash
npm install aframe-broadcast-component
```

Then register and use.

```js
require('aframe');
require('aframe-broadcast-component');
```

---
_Source: https://npm.io/package/aframe-broadcast-component · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
