1.0.1 • Published 4 years ago

threeact v1.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

threeact

Threeact is a dead simple React component for hosting a THREE.js scene. Threeact is not for creating actual scenes using React components, a la react-webgl. It simply takes care of some of the boilerplate around creating your canvas and THREE.js scene and wrapping it in a React component.

NPM JavaScript Style Guide

Install

npm install --save threeact

Usage

import React from 'react';
import * as THREE from 'three';
import Threeact from 'threeact';

const Example = () => (
  <Threeact
    onReady={({ scene }) => {
      // Set up your scene, add geometry, etc...
      this.cube = new THREE.Mesh(
        new THREE.CubeGeometry(2, 2, 2),
        new THREE.MeshNormalMaterial()
      );
      scene.add(this.cube);
    }}
    beforeRenderFrame={({ renderer, scene, camera }) => {
      // make any updates before each frame is rendered
      this.cube.rotation.x += 0.02;
      this.cube.rotation.y -= 0.01;
      this.cube.rotation.z += 0.03;
    }}
    afterRenderFrame={({ renderer, scene, camera }) => {
      // make any updates after each frame is rendered
    }}
    showStats={true /* optionally show diagnostic and perf overlays */}
  />
);

License

MIT © gpascale

1.0.1

4 years ago

1.0.0

4 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.0

9 years ago