我正在尝试在react-native(0.58.3)中使用https://github.com/gre/gl-react-native和react-native-webgl,但是它不起作用,它显示出这样的错误
“[TID:com.facebook.react.JavaScript]异常 ' - [RCTCxxBridge jsContextRef]:发送到实例0x166d5740无法识别选择' 是从JS螺纹抛出”
这是我的代码
import { Shaders, Node, GLSL , GL} from 'gl-react'
import {Surface} from 'gl-react-native';
import GLImage from "gl-react-image";
import { WebGLView } from "react-native-webgl";
const shaders = Shaders.create({
Saturate: {
frag: GLSL`
precision highp float;
varying vec2 uv;
uniform sampler2D t;
uniform float contrast, saturation, brightness;
const vec3 L = vec3(0.2125, 0.7154, 0.0721);
void main() {
vec4 c = texture2D(t, uv);
vec3 brt = c.rgb * brightness;
gl_FragColor = vec4(mix(
vec3(0.5),
mix(vec3(dot(brt, L)), brt, saturation),
contrast), c.a);
}
`
}
});
export const Saturate = ({ contrast, saturation, brightness, children }) =>
<Node
shader={shaders.Saturate}
uniforms={{ contrast, saturation, brightness, t: children }}
/>;
render() {
const filter = {
contrast: 1,
saturation: 1,
brightness: 1
}
return (
<Surface style={{ width: 500, height: 500, backgroundColor: "green" }}>
<Saturate {...filter}>
{{ uri: "https://i.imgur.com/uTP9Xfr.jpg" }}
</Saturate>
</Surface>
);
}
谢谢!