Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/whitestormjs/react-whs

WhitestormJS React integration ⚛
https://github.com/whitestormjs/react-whs

components integration react reactjs whitestormjs whitestormjs-react whs

Last synced: 2 months ago
JSON representation

WhitestormJS React integration ⚛

Awesome Lists containing this project

README

        

![](http://i.imgur.com/MJmzMdb.png)

# react-whs [![Build Status](https://img.shields.io/travis/WhitestormJS/react-whs.svg?style=flat-square)](https://travis-ci.org/WhitestormJS/react-whs) [![NPM Version](https://img.shields.io/npm/v/react-whs.svg?style=flat-square)](https://www.npmjs.com/package/react-whs)

> Go to [WhitestormJS/whitestorm.js](https://github.com/WhitestormJS/whitestorm.js)

## Usage

Try with **React** on [**Codepen**](http://codepen.io/sasha240100/pen/dNqKMd?editors=1010):

```javascript
import React, {Component} from 'react';
import {App, Sphere} from 'react-whs';

export class Application extends Component {
render() {
return (



)
}
}
```

### Children

```javascript
import React, {Component} from 'react';
import {App, Sphere} from 'react-whs';

export class Application extends Component {
render() {
return (





)
}
}
```

## How whs components can be transformed to react components

### Custom components (that are not included in whs lib)

> Simply include `@reactify` decorator.

```javascript
import React, {Component} from 'react';
import * as THREE from 'three';
import {MeshComponent} from 'whs/src/core/MeshComponent';

import {reactify} from 'react-whs';

@reactify
export default class BasicSphere extends MeshComponent {
build() {
return new THREE.Mesh(
new THREE.SphereGeometry(3, 16, 16),
new THREE.MeshBasicMaterial({color: 0xff0000}) // red
);
}
}
```

### Get reference to Component/App to work with them in js
For **App** use `refApp`.

For **any component (Mesh, Light, Camera, ...)** use `refComponent`.

```javascript
import React, {Component} from 'react';
import {App, Sphere} from 'react-whs';

export class Application extends Component {
render() {
return (
{
console.log(app); // will log this WHS.App object
}}
]}>
{
console.log(component); // will log this WHS.Sphere object
}}
/>

)
}
}
```

### Properties/params syntax
> To see how to make whs components work in react see previous note (Custom components)

WHS:

```javascript
const component = new MyComponent({
parameter1: value1,
parameter2: value2,
position: new THREE.Vector3(x, y, z)
});

component.addTo(app);
```

React:

```javascript
class MyComponentSyntaxExample {
render() {
return (

)
}
}
```