Skip to content
This repository was archived by the owner on Feb 21, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/examples/Simple/Cube.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import React3 from 'react-three-renderer';
import THREE from 'three';

class Cube extends React.Component {

componentWillReceiveProps() {
if( window.debuggg ) {
console.log('Cube.js componentWillReceiveProps');
}
}

render() {
if( window.debuggg ) {
window.debuggg = false;
console.log('Cube.js render');
}
return (<group>
<mesh
rotation={this.props.rotation}
>
<boxGeometry
width={1}
height={1}
depth={1}
/>
<meshBasicMaterial
color={0xffff00}
/>
</mesh>
</group>);
}
}

export default Cube;
25 changes: 14 additions & 11 deletions src/examples/Simple/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';
import React3 from 'react-three-renderer';
import THREE from 'three';

import Cube from './Cube';

class Simple extends React.Component {
static propTypes = {
width: React.PropTypes.number.isRequired,
Expand Down Expand Up @@ -36,6 +38,12 @@ class Simple extends React.Component {
};
}

componentDidUpdate() {
if( window.debuggg ) {
console.log('index.js componentDidUpdate called');
}
}

render() {
const {
width,
Expand All @@ -45,6 +53,10 @@ class Simple extends React.Component {
// or you can use:
// width = window.innerWidth
// height = window.innerHeight
//
if( window.debuggg ) {
console.log('index.js wrapper render');
}

return (<React3
mainCamera="camera" // this points to the perspectiveCamera below
Expand All @@ -63,18 +75,9 @@ class Simple extends React.Component {

position={this.cameraPosition}
/>
<mesh
<Cube
rotation={this.state.cubeRotation}
>
<boxGeometry
width={1}
height={1}
depth={1}
/>
<meshBasicMaterial
color={0x00ff00}
/>
</mesh>
/>
</scene>
</React3>);
}
Expand Down