-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.osx.js
76 lines (68 loc) · 1.77 KB
/
index.osx.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* @flow */
'use strict';
import React, {View, Text, Dimensions} from 'react-native-desktop';
import GL from 'gl-react';
import { Surface } from "gl-react-native";
import shaders, {lightShaderText} from './shaders';
const HelloWorld = GL.createComponent(({time, resolution}) =>
<GL.Node shader={shaders.light} uniforms={{ time, resolution }}/>,
{ displayName: "HelloGL" }
);
class RNGLDesktop extends React.Component {
constructor() {
super();
this.state = {
time: 0
}
}
componentDidMount() {
this.play();
}
play() {
const loop = t => {
this.setState({ time: this.state.time + 0.01});
requestAnimationFrame(loop);
};
loop();
}
render() {
const { width, height } = Dimensions.get('window');
return (
<View style={{flex: 1}}>
<Surface
width={width}
height={height}
opaque={false}
>
<HelloWorld
time= {this.state.time}
resolution = {[width, height]} />
</Surface>
{ /* <GL.View
shader={shaders.light}
opaque={true}
width={width}
height={height}
/> */}
<View style={{position: 'absolute', top: 50, left: 100, flex: 1, backgroundColor: 'transparent'}}>
<Text style={{fontFamily: 'Monaco', color: '#ccc', fontSize: 10}}>{lightShaderText}</Text>
</View>
</View>
);
// <GL.View
// shader={shaders.light}
// opaque={true}
// width={width}
// height={height}
// uniforms={{
// time: this.state.time,
// resolution: [width, height]
// }}
// />
}
}
const styles = {
textWrapper: {
}
}
React.AppRegistry.registerComponent('RNGLDesktop', () => RNGLDesktop);