Commit 21fbd017 authored by Gaëtan Renaudeau's avatar Gaëtan Renaudeau

Migrate client code to gl-react-core 2.0.0 (that will be renamed to gl-react)

parent 010209f6
const Shaders = require("./src/Shaders");
const View = require("./src/View");
const Uniform = require("./src/Uniform");
const Component = require("./src/ComponentDeprecated");
const createComponent = require("./src/createComponent");
module.exports = {
Shaders,
View,
Uniform,
Component,
createComponent
};
module.exports = require("./src");
const Shaders = require("./src/Shaders");
const View = require("./src/View");
const Uniform = require("./src/Uniform");
const Component = require("./src/ComponentDeprecated");
const createComponent = require("./src/createComponent");
module.exports = {
Shaders,
View,
Uniform,
Component,
createComponent
};
module.exports = require("./src");
......@@ -19,11 +19,11 @@
"author": "Project September <tech@projectseptember.com>",
"license": "MIT",
"peerDependencies": {
"react-native": ">=0.9.0"
"react-native": ">=0.13.0",
"gl-react-core": "*"
},
"dependencies": {
"invariant": "2.2.0",
"gl-react-core": "1.2.x"
"invariant": "2.2.0"
},
"devDependencies": {
"eslint": "^1.9.0",
......
const React = require("react-native");
const {createComponentDeprecated} = require("gl-react-core");
module.exports = createComponentDeprecated(React);
const {createView} = require("gl-react-core");
const {createSurface} = require("gl-react-core");
const React = require("react-native");
const Shaders = require("./Shaders");
const Uniform = require("./Uniform");
const GLCanvas = require("./GLCanvas");
const {
View,
} = React;
const renderVcontent = function (width, height, id, children, { visibleContent }) {
function renderVcontent (width, height, id, children, { visibleContent }) {
const childrenStyle = {
position: "absolute",
top: visibleContent ? 0 : height, // as a workaround for RN, we offset the content so it is not visible but still can be rasterized
......@@ -18,13 +16,13 @@ const renderVcontent = function (width, height, id, children, { visibleContent }
overflow: "hidden"
};
return <View key={id} style={childrenStyle}>{children}</View>;
};
}
const renderVGL = function (props) {
function renderVGL (props) {
return <GLCanvas ref="canvas" {...props} />;
};
}
const renderVcontainer = function ({ style, width, height }, contents, renderer) {
function renderVcontainer ({ style, width, height }, contents, renderer) {
const parentStyle = {
position: "relative",
...style,
......@@ -36,12 +34,6 @@ const renderVcontainer = function ({ style, width, height }, contents, renderer)
{contents}
{renderer}
</View>;
};
}
const GLView = createView(React, Shaders, Uniform, renderVcontainer, renderVcontent, renderVGL);
GLView.prototype.setNativeProps = function (props) {
this.refs.native.setNativeProps(props);
};
module.exports = GLView;
module.exports = createSurface(renderVcontainer, renderVcontent, renderVGL);
const {createUniform} = require("gl-react-core");
const React = require("react-native");
module.exports = createUniform(React);
const React = require("react-native");
const View = require("./View");
const {createComponent} = require("gl-react-core");
module.exports = createComponent(React, View);
const { Shaders } = require("gl-react-core");
const Surface = require("./Surface");
const { NativeModules: { RNGLContext } } = require("react-native");
// Hook Shaders to RNGLContext
Shaders.list().map(id => RNGLContext.addShader(id, Shaders.get(id)));
Shaders.on("add", (id, shader) => RNGLContext.addShader(id, shader));
module.exports = {
Surface
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment