GitXplorerGitXplorer
t

react-aframe

public
2 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
5af84457068795c232908dd6155f6272a26fd6a6

Fix error

ttyao1 committed 8 years ago
Unverified
25c71466f1015d0103424b743b4080628131937b

Using typeof

ttyao1 committed 8 years ago
Unverified
6754ce99260c58a2cbb59d98e99b55c2fa2eef35

Wrap Aframe components!

ttyao1 committed 8 years ago
Unverified
18812209afc7337f0a71c8b4e6ff4310ff9e8b9d

Initial commit

ttyao1 committed 8 years ago

README

The README file for this repository.

react-aframe

It is alike aframe-react, but supports more A-Frame components

aframe-react is a thin layer on top of A-Frame, which is an entity-component-system-based layer on top of three.js. It serializes objects, passed as props, to strings understandable by A-Frame components:

<Entity geometry={{primitive: 'box', width: 5}}/>
// to:
<Entity geometry="primitive: box; width: 5"/>

Installation

npm install --save react-aframe
import 'aframe';
import {Entity, Scene} from 'react-aframe';

class ExampleScene extends React.Component {
  render () {
    return (
      <Scene>
        <Entity geometry={{primitive: 'box'}} material="color: red" position={[0, 0, -5]}/>
      </Scene>
    );
  }
}

API

react-aframe ships with Scene, Entity, Animation, and those in AFRAME.components

Tha api is pretty much same, but to bind events, use event names as seen in React:

For example, onClick will add listeners for click event, and onClickCapture will add listener and also set capture to true. (the event handler name will all be lower cased and it won't add '-' for you)

You can also wrap any a-frame tags by using wrapComponent(tagName) ( omit the a- prefix)

import {wrapComponent} from 'react-aframe';
const Box = wrapComponent(box);
// Then use Box like a normal React Component