Created
November 12, 2017 17:48
-
-
Save LorbusChris/3b311fd831613c2668241a999cc574de to your computer and use it in GitHub Desktop.
Anvaka's Fieldplay as a React Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import initScene from './lib/scene' | |
class Fieldplay extends Component { | |
constructor(props, context) { | |
super(props, context) | |
} | |
componentDidMount() { | |
const canvas = this.canvas | |
const ctxOptions = {antialiasing: false } | |
const gl = canvas.getContext('webgl', ctxOptions) || | |
canvas.getContext('experimental-webgl', ctxOptions) | |
if (gl) { | |
window.webgGLEnabled = true | |
var scene = initScene(gl) | |
scene.start() | |
} else { | |
window.webgGLEnabled = false | |
} | |
} | |
render() { | |
return ( | |
<canvas ref={(c) => {this.canvas = c}} width={640} height={640} /> | |
) | |
} | |
} | |
export default Fieldplay |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment