From 39e2fb7c49a8c908c8a59ba00bb265495ba4eb7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Mon, 24 Aug 2015 14:32:00 +0200 Subject: [PATCH] rename 'passes' to 'data' with a object tree structure --- src/GLCanvas.js | 21 ++++++++++----------- src/View.js | 9 +++++---- src/core/createView.js | 24 +++++++++++++++++------- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/GLCanvas.js b/src/GLCanvas.js index 55d20f0..9381e39 100644 --- a/src/GLCanvas.js +++ b/src/GLCanvas.js @@ -29,12 +29,11 @@ class GLCanvas extends Component { } render () { - const { width, height, style } = this.props; + const { width, height } = this.props; const { devicePixelRatio } = this.state; const styles = { width: width+"px", - height: height+"px", - ...style + height: height+"px" }; return { - this.syncUniforms(this.props.passes[0]); + this.syncUniforms(this.props.data); }); this._images[src] = image; } @@ -271,7 +270,7 @@ class GLCanvas extends Component { if (!shader) return; const props = this.props; - this.syncTargetUniforms(props.passes[0]); + this.syncTargetUniforms(props.data); // Bind the textures for (const uniformName in this._textures) { @@ -285,7 +284,7 @@ class GLCanvas extends Component { GLCanvas.propTypes = { width: PropTypes.number.isRequired, height: PropTypes.number.isRequired, - passes: PropTypes.array.isRequired + data: PropTypes.object.isRequired }; module.exports = GLCanvas; diff --git a/src/View.js b/src/View.js index 0ef1495..ecb7a25 100644 --- a/src/View.js +++ b/src/View.js @@ -17,15 +17,16 @@ const renderVtarget = function (style, width, height, id, target) { return
{target}
; }; -const renderVGL = function (props, passes) { +const renderVGL = function (props, width, height, data) { return ; }; -const renderVcontainer = function (props, targets, renderer) { - const { style, width, height } = props; +const renderVcontainer = function (style, width, height, targets, renderer) { if (targets) { const parentStyle = { ...style, diff --git a/src/core/createView.js b/src/core/createView.js index d0f44b4..6a52719 100644 --- a/src/core/createView.js +++ b/src/core/createView.js @@ -23,8 +23,11 @@ module.exports = function (React, Shaders, Target, renderVcontainer, renderVtarg class GLView extends Component { render() { const props = this.props; - const { width, height, children, shader, uniforms: uniformsOriginal } = props; + const { style, width, height, children, shader, uniforms: uniformsOriginal } = props; const cleanedProps = { ...props }; + delete cleanedProps.style; + delete cleanedProps.width; + delete cleanedProps.height; delete cleanedProps.shader; delete cleanedProps.uniforms; delete cleanedProps.children; @@ -40,10 +43,11 @@ module.exports = function (React, Shaders, Target, renderVcontainer, renderVtarg uniforms[key] = value; } - const passes = [ - { shader, uniforms: uniforms }, - [] // children passes - ]; + const data = { + shader, + uniforms, + children: [] + }; let targetId = 0; let targets = []; @@ -65,9 +69,15 @@ module.exports = function (React, Shaders, Target, renderVcontainer, renderVtarg }); return renderVcontainer( - cleanedProps, + style, + width, + height, targets, - renderVGL(cleanedProps, passes) + renderVGL( + cleanedProps, + width, + height, + data) ); } }