1.0.0 • Published 6 years ago

react-three-fbx-viewer v1.0.0

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

react-three-fbx-viewer

fbx viewer with three.js for react

Only render a fbx files

##Example

Install

npm install --save react-three-fbx-viewer

Usage

import React, { Component } from 'react';
import ReactThreeFbxViewer from 'react-three-fbx-viewer';

let fbxUrl = require('./asd.fbx');

export default class App extends Component {
  onLoad(e) {
    console.log(e);
  }

  onError(e) {
    console.log(e);
  }
  render () {
    let cameraPosition = {
      x:150,
      y:300,
      z:350
    }
    return (
      <div>
        <ReactThreeFbxViewer cameraPosition={cameraPosition} url={fbxUrl} onLoading={this.onLoad} onError={this.onError}/>
      </div>
    );
  }
}

Properties

inputs

paramdescriptiontypedefault
urlurl fbx to loadString"" 
backgroundColorcolor in hexHex0x000000
angleangle of perspective camera in scenenumber45
nearnear of perspective camera in scenenumber1
farfar of perspective camera in scenenumber2000
cameraPositioncamera position in sceneObject{x: 2, y: 0, z: 10}
controlsPositioncontrol position in sceneObject{x: 0, y: 0, z: 0}

In a future, you will can choice the lights (HemisphereLight,HemisphereLight,AmbientLight, ...)

inputs

eventdescriptionreturn
onErrorreturn an errorobject error
onLoadingreturn an object with fbx is loadingobject onloading

Local development

  1. clone repo , not install.

Local development is broken into two parts.

  • First, you'll run rollup to watch your src/ module and automatically recompile it into dist/ whenever you make changes.
npm start # runs rollup with watch flag
  • The second part will be running the example/ create-react-app that's linked to the local version of your module.
# (in another tab)
cd example
npm link react-three-fbx-visor # optional if using yarn
npm start # runs create-react-app dev server

Now, anytime you make a change to your component in src/ or to the example app's example/src.

npm.io

Note: if you're using yarn, there is no need to use yarn link, as the generated module's example includes a local-link by default.

License

MIT © kappys1 - Alejandro Marcos Gutierrez

2018 © TMTFactory