This repository was archived by the owner on Feb 21, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import React3 from 'react-three-renderer' ;
3+ import THREE from 'three' ;
4+
5+ class Cube extends React . Component {
6+
7+ componentWillReceiveProps ( ) {
8+ if ( window . debuggg ) {
9+ console . log ( 'Cube.js componentWillReceiveProps' ) ;
10+ }
11+ }
12+
13+ render ( ) {
14+ if ( window . debuggg ) {
15+ window . debuggg = false ;
16+ console . log ( 'Cube.js render' ) ;
17+ }
18+ return ( < group >
19+ < mesh
20+ rotation = { this . props . rotation }
21+ >
22+ < boxGeometry
23+ width = { 1 }
24+ height = { 1 }
25+ depth = { 1 }
26+ />
27+ < meshBasicMaterial
28+ color = { 0xffff00 }
29+ />
30+ </ mesh >
31+ </ group > ) ;
32+ }
33+ }
34+
35+ export default Cube ;
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import React from 'react';
22import React3 from 'react-three-renderer' ;
33import THREE from 'three' ;
44
5+ import Cube from './Cube' ;
6+
57class Simple extends React . Component {
68 static propTypes = {
79 width : React . PropTypes . number . isRequired ,
@@ -36,6 +38,12 @@ class Simple extends React.Component {
3638 } ;
3739 }
3840
41+ componentDidUpdate ( ) {
42+ if ( window . debuggg ) {
43+ console . log ( 'index.js componentDidUpdate called' ) ;
44+ }
45+ }
46+
3947 render ( ) {
4048 const {
4149 width,
@@ -45,6 +53,10 @@ class Simple extends React.Component {
4553 // or you can use:
4654 // width = window.innerWidth
4755 // height = window.innerHeight
56+ //
57+ if ( window . debuggg ) {
58+ console . log ( 'index.js wrapper render' ) ;
59+ }
4860
4961 return ( < React3
5062 mainCamera = "camera" // this points to the perspectiveCamera below
@@ -63,18 +75,9 @@ class Simple extends React.Component {
6375
6476 position = { this . cameraPosition }
6577 />
66- < mesh
78+ < Cube
6779 rotation = { this . state . cubeRotation }
68- >
69- < boxGeometry
70- width = { 1 }
71- height = { 1 }
72- depth = { 1 }
73- />
74- < meshBasicMaterial
75- color = { 0x00ff00 }
76- />
77- </ mesh >
80+ />
7881 </ scene >
7982 </ React3 > ) ;
8083 }
You can’t perform that action at this time.
0 commit comments