dwqdaiwenqi / React 3d Viewer
A 3D model viewer component based on react.js 一个基于react.js的组件化3d模型查看工具
Stars: ✭ 100
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to React 3d Viewer
Wechart
Create all the [ch]arts by cax or three.js - Cax 和 three.js 创造一切图[表]
Stars: ✭ 152 (+52%)
Mutual labels: 3d, webgl, threejs, html5
Sea3d
An open-source format and tools for game developers 🎮
Stars: ✭ 483 (+383%)
Mutual labels: webgl, threejs, html5
Vimeo Depth Player
A WebVR volumetric video renderer that uses color-depth based videos hosted on Vimeo.
Stars: ✭ 65 (-35%)
Mutual labels: 3d, webgl, threejs
Clay Viewer
3D model viewer with high quality rendering and glTF2.0/GLB export
Stars: ✭ 558 (+458%)
Mutual labels: 3d, webgl, viewer
Vue Gl
Vue.js components rendering 3D WebGL graphics reactively with three.js
Stars: ✭ 434 (+334%)
Mutual labels: 3d, webgl, threejs
Three Forcegraph
Force-directed graph as a ThreeJS 3d object
Stars: ✭ 84 (-16%)
Mutual labels: 3d, webgl, threejs
Plasio
Drag-n-drop In-browser LAS/LAZ point cloud viewer. http://plas.io
Stars: ✭ 349 (+249%)
Mutual labels: webgl, threejs, viewer
React Postprocessing
📬 postprocessing for react-three-fiber
Stars: ✭ 311 (+211%)
Mutual labels: 3d, webgl, threejs
Lume
Create CSS3D/WebGL applications declaratively with HTML. Give regular DOM elements shadow and lighting.
Stars: ✭ 445 (+345%)
Mutual labels: 3d, webgl, threejs
Glmaps
Data visualization examples and tutorials from scratch. 数据可视化示例代码集与新手学习教程。
Stars: ✭ 288 (+188%)
Mutual labels: 3d, webgl, threejs
React Three Editable
👀 ✏️ Edit your react-three-fiber scene with a visual editor without giving up control over your code.
Stars: ✭ 261 (+161%)
Mutual labels: 3d, webgl, threejs
Enable3d
🕹️ Standalone 3D Framework / Physics for three.js (using ammo.js) / 3D extension for Phaser 3
Stars: ✭ 271 (+171%)
Mutual labels: 3d, webgl, threejs
Webworldwind
The NASA WorldWind Javascript SDK (WebWW) includes the library and examples for creating geo-browser web applications and for embedding a 3D globe in HTML5 web pages.
Stars: ✭ 628 (+528%)
Mutual labels: 3d, webgl, html5
English| 简体中文
react-3d-viewer
A 3D model viewer component based on react.js. Demo located at https://dwqdaiwenqi.github.io/react-3d-viewer/site/
Features
- Component-Based
- Update UI using
.setState()
method - Support gltf,obj,mtl,json,dae model formats - other formats will be added in the future.
- Provied
<DirectionLight/>
and<AmbientLight/>
light components - other components will be provided in the future.
Usage
Get react-3d-viewer through npm or cdn:
npm i react-3d-viewer
Work with module bundler
import {OBJModel} from 'react-3d-viewer'
render(){
return(
<div>
<OBJModel src="./a.obj" texPath=""/>
</div>
)
}
import {Tick,MTLModel} from 'react-3d-viewer'
render(){
return(
<div>
<MTLModel
enableZoom = {false}
position={{x:0,y:-100,z:0}}
rotation={this.state.rotation}
texPath="./src/lib/model/"
mtl="./src/lib/model/freedom.mtl"
src="./src/lib/model/freedom.obj"
/>
</div>
)
}
componentWillMount(){
this.tick.animate = false
}
componentDidMount(){
this.tick = Tick(()=>{
var {rotation} = this.state
rotation.y += 0.005
this.setState({rotation})
})
}
import {DAEModel,DirectionLight } from 'react-3d-viewer'
render(){
return(
<div>
<DAEModel
src={'./src/lib/model/Ruins_dae.dae'}
onLoad={()=>{
// ...
}}
>
<DirectionLight color={0xff00ff}/>
</DAEModel>
</div>
)
}
HTML
<script src="https://unpkg.com/[email protected]/dist/scripts/react-3d-viewer.js"></script>
<script src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script>
<script src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script>
<div id="example"></div>
<script >
// It's not recommended to use this way.
ReactDOM.render(
React.createElement('div',{ style: { width: 600, margin: '0px auto' } },
React.createElement(React3DViewer.JSONModel, {
src:'./src/lib/model/kapool.js'
})
)
,document.getElementById('example'));
</script>
To view a demo,click here.
Properties
Property | Type | Default | Description |
---|---|---|---|
width | number | 500 | The width of container |
height | number | 500 | The height of container |
texPath | string | '' | Set the base path for the img file |
onLoad | function | undefined | A function to be called after the loading is successfully completed |
onProgress | function | undefined | A function to be called while the loading is in progress |
enableKeys | boolen | true | Enable or disable the use of keyboard controls |
enableRotate | boolen | true | Enable or disable horizontal and vertical rotation of the camera |
enableZoom | boolen | true | Enable or disable zooming of the camera |
enabled | boolen | true | Whether or not the controls are enabled |
src | string | undefined | The path of the file |
mtl | string | undefined | The path of the .mtl file |
anitialias | boolen | true | Whether to perform antialiasing |
position | object | {x:0,y:0,z:0} | Object's position |
rotation | object | {x:0,y:0,z:0} | Object's rotation |
How it works
The <FormatModel>
creates a camera, scene, light source and a WebGL renderer.The DOM returned by the renderer (a <canvas>
element) is added to the document and configured to fill the viewport.
Scene is rendered in real time. In the componentDidUpdate
method, the changes of props
are detected and the attributes of objects are changed.
License
MIT
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].