react-three-renderer
Advanced tools
Comparing version 0.0.4-alpha to 0.0.5-alpha
@@ -33,6 +33,2 @@ 'use strict'; | ||
var _reactLibReactCurrentOwner = require('react/lib/ReactCurrentOwner'); | ||
var _reactLibReactCurrentOwner2 = _interopRequireDefault(_reactLibReactCurrentOwner); | ||
var LightDescriptorBase = (function (_Object3DDescriptor) { | ||
@@ -167,3 +163,3 @@ _inherits(LightDescriptorBase, _Object3DDescriptor); | ||
(0, _fbjsLibWarning2['default'])(this._warnedAboutLightMaterialUpdate, '<' + elementType + '/> has been updated which triggered a refresh of all materials.\n This is a potentially expensive operation.\n This can happen when you add or remove a light, or add or remove any component before any lights without keys e.g.\n <object3d>\n {/* new or removed component here */}\n <ambientLight/>\n </object3d>, or update some properties of lights.\n If you would like to add components you should either add the components after the lights (recommended), e.g.\n <object3d>\n <ambientLight/>\n {/* new or removed component here */}\n </object3d>, or add a \'key\' property to the lights e.g.\n <object3d>\n {/* new or removed component here */}\n <ambientLight key="light"/>\n </object3d>.\n If you have modified a light\'s properties e.g. toggled castShadow, the materials need to be rebuilt as well.\n To acknowledge and remove this message, please add the property \'updatesRefreshAllMaterials\'\n to <' + elementType + '/> inside the render() of ' + (owner && owner.getName() || 'a component') + '.\n For more information, visit https://github.com/mrdoob/threejs/wiki/Updates .'); | ||
(0, _fbjsLibWarning2['default'])(this._warnedAboutLightMaterialUpdate, LightDescriptorBase.getDynamicWarningMessage(elementType, owner)); | ||
this._warnedAboutLightMaterialUpdate = true; | ||
@@ -176,2 +172,7 @@ } | ||
} | ||
}], [{ | ||
key: 'getDynamicWarningMessage', | ||
value: function getDynamicWarningMessage(elementType, owner) { | ||
return '<' + elementType + '/> has been updated which triggered a refresh of all materials.\n This is a potentially expensive operation.\n This can happen when you add or remove a light, or add or remove any component\n before any lights without keys e.g.\n <object3d>\n {/* new or removed component here */}\n <ambientLight/>\n </object3d>, or update some properties of lights.\n If you would like to add components you should either add the components after the lights (recommended), e.g.\n <object3d>\n <ambientLight/>\n {/* new or removed component here */}\n </object3d>, or add a \'key\' property to the lights e.g.\n <object3d>\n {/* new or removed component here */}\n <ambientLight key="light"/>\n </object3d>.\n If you have modified a light\'s properties e.g. toggled castShadow, the materials need to be rebuilt as well.\n To acknowledge and remove this message, please add the property \'updatesRefreshAllMaterials\'\n to <' + elementType + '/> inside the render() of ' + (owner && owner.getName() || 'a component') + '.\n For more information, visit https://github.com/mrdoob/threejs/wiki/Updates .'; | ||
} | ||
}]); | ||
@@ -178,0 +179,0 @@ |
@@ -47,2 +47,4 @@ 'use strict'; | ||
this.hasName(); | ||
function copyUpdate(propName) { | ||
@@ -54,2 +56,22 @@ return function (threeObject, value) { | ||
this.hasProp('position', { | ||
type: _reactLibReactPropTypes2['default'].instanceOf(_threeJs2['default'].Vector3), | ||
update: function update(threeObject, position) { | ||
threeObject.position.copy(position); | ||
if (threeObject.userData._lookAt) { | ||
threeObject.lookAt(threeObject.userData._lookAt); | ||
} | ||
}, | ||
'default': new _threeJs2['default'].Vector3() | ||
}); | ||
this.hasProp('rotation', { | ||
type: _reactLibReactPropTypes2['default'].instanceOf(_threeJs2['default'].Euler), | ||
update: function update(threeObject, rotation) { | ||
threeObject.rotation.copy(rotation); | ||
}, | ||
'default': new _threeJs2['default'].Euler() | ||
}); | ||
this.hasProp('quaternion', { | ||
@@ -110,24 +132,2 @@ type: _reactLibReactPropTypes2['default'].instanceOf(_threeJs2['default'].Quaternion), | ||
}); | ||
this.hasProp('position', { | ||
type: _reactLibReactPropTypes2['default'].instanceOf(_threeJs2['default'].Vector3), | ||
update: function update(threeObject, position) { | ||
threeObject.position.copy(position); | ||
if (threeObject.userData._lookAt) { | ||
threeObject.lookAt(threeObject.userData._lookAt); | ||
} | ||
}, | ||
'default': new _threeJs2['default'].Vector3() | ||
}); | ||
this.hasProp('rotation', { | ||
type: _reactLibReactPropTypes2['default'].instanceOf(_threeJs2['default'].Euler), | ||
update: function update(threeObject, rotation) { | ||
threeObject.rotation.copy(rotation); | ||
}, | ||
'default': new _threeJs2['default'].Euler() | ||
}); | ||
this.hasName(); | ||
} | ||
@@ -134,0 +134,0 @@ |
@@ -370,3 +370,3 @@ 'use strict'; | ||
/** | ||
* Returns the DOM node rendered by this element. | ||
* Returns the THREE.js object rendered by this element. | ||
* | ||
@@ -421,3 +421,3 @@ * @param {React.Component|THREE.Object3D} componentOrElement | ||
function React3Renderer(canvas) { | ||
function React3Renderer() { | ||
var _this = this; | ||
@@ -483,3 +483,2 @@ | ||
this._canvas = canvas; | ||
this._instancesByReactRootID = {}; | ||
@@ -961,3 +960,2 @@ this.object3DsByReactRootID = {}; | ||
delete this._canvas; | ||
delete this._instancesByReactRootID; | ||
@@ -964,0 +962,0 @@ delete this.object3DsByReactRootID; |
{ | ||
"name": "react-three-renderer", | ||
"version": "0.0.4-alpha", | ||
"version": "0.0.5-alpha", | ||
"description": "Render into a three.js canvas using React.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/React3.js", |
@@ -6,6 +6,11 @@ react-three-renderer | ||
WARNING: This is still an experimental and incomplete project, use at your own risk! | ||
> This is still an experimental and incomplete project, use at your own risk! | ||
WARNING: There's absolutely zero documentation, I will work on that whenever I can! | ||
WIKI | ||
============= | ||
[Wiki is now live!](https://github.com/toxicFork/react-three-renderer/wiki) | ||
> Work in progress! | ||
Influences | ||
@@ -12,0 +17,0 @@ ========== |
@@ -8,4 +8,2 @@ import THREE from 'three.js'; | ||
import ReactCurrentOwner from 'react/lib/ReactCurrentOwner'; | ||
class LightDescriptorBase extends Object3DDescriptor { | ||
@@ -137,5 +135,16 @@ constructor(react3Instance) { | ||
warning(this._warnedAboutLightMaterialUpdate, | ||
`<${elementType}/> has been updated which triggered a refresh of all materials. | ||
LightDescriptorBase.getDynamicWarningMessage(elementType, owner)); | ||
this._warnedAboutLightMaterialUpdate = true; | ||
} | ||
} | ||
rootInstance.allMaterialsNeedUpdate(); | ||
} | ||
} | ||
static getDynamicWarningMessage(elementType, owner) { | ||
return `<${elementType}/> has been updated which triggered a refresh of all materials. | ||
This is a potentially expensive operation. | ||
This can happen when you add or remove a light, or add or remove any component before any lights without keys e.g. | ||
This can happen when you add or remove a light, or add or remove any component | ||
before any lights without keys e.g. | ||
<object3d> | ||
@@ -157,9 +166,3 @@ {/* new or removed component here */} | ||
to <${elementType}/> inside the render() of ${owner && owner.getName() || 'a component'}. | ||
For more information, visit https://github.com/mrdoob/threejs/wiki/Updates .`); | ||
this._warnedAboutLightMaterialUpdate = true; | ||
} | ||
} | ||
rootInstance.allMaterialsNeedUpdate(); | ||
} | ||
For more information, visit https://github.com/mrdoob/threejs/wiki/Updates .`; | ||
} | ||
@@ -166,0 +169,0 @@ } |
@@ -16,2 +16,4 @@ import THREE from 'three.js'; | ||
this.hasName(); | ||
function copyUpdate(propName) { | ||
@@ -23,2 +25,22 @@ return (threeObject, value) => { | ||
this.hasProp('position', { | ||
type: PropTypes.instanceOf(THREE.Vector3), | ||
update(threeObject, position) { | ||
threeObject.position.copy(position); | ||
if (threeObject.userData._lookAt) { | ||
threeObject.lookAt(threeObject.userData._lookAt); | ||
} | ||
}, | ||
default: new THREE.Vector3(), | ||
}); | ||
this.hasProp('rotation', { | ||
type: PropTypes.instanceOf(THREE.Euler), | ||
update(threeObject, rotation) { | ||
threeObject.rotation.copy(rotation); | ||
}, | ||
default: new THREE.Euler(), | ||
}); | ||
this.hasProp('quaternion', { | ||
@@ -82,24 +104,2 @@ type: PropTypes.instanceOf(THREE.Quaternion), | ||
}); | ||
this.hasProp('position', { | ||
type: PropTypes.instanceOf(THREE.Vector3), | ||
update(threeObject, position) { | ||
threeObject.position.copy(position); | ||
if (threeObject.userData._lookAt) { | ||
threeObject.lookAt(threeObject.userData._lookAt); | ||
} | ||
}, | ||
default: new THREE.Vector3(), | ||
}); | ||
this.hasProp('rotation', { | ||
type: PropTypes.instanceOf(THREE.Euler), | ||
update(threeObject, rotation) { | ||
threeObject.rotation.copy(rotation); | ||
}, | ||
default: new THREE.Euler(), | ||
}); | ||
this.hasName(); | ||
} | ||
@@ -106,0 +106,0 @@ |
@@ -124,3 +124,3 @@ import DOMProperty from 'react/lib/DOMProperty'; | ||
/** | ||
* Returns the DOM node rendered by this element. | ||
* Returns the THREE.js object rendered by this element. | ||
* | ||
@@ -254,4 +254,3 @@ * @param {React.Component|THREE.Object3D} componentOrElement | ||
constructor(canvas) { | ||
this._canvas = canvas; | ||
constructor() { | ||
this._instancesByReactRootID = {}; | ||
@@ -776,3 +775,2 @@ this.object3DsByReactRootID = {}; | ||
delete this._canvas; | ||
delete this._instancesByReactRootID; | ||
@@ -779,0 +777,0 @@ delete this.object3DsByReactRootID; |
Sorry, the diff of this file is not supported yet
642528
14966
150