Skip to content

Instantly share code, notes, and snippets.

@LorbusChris
Created November 12, 2017 17:48
Show Gist options
  • Save LorbusChris/3b311fd831613c2668241a999cc574de to your computer and use it in GitHub Desktop.
Save LorbusChris/3b311fd831613c2668241a999cc574de to your computer and use it in GitHub Desktop.
Anvaka's Fieldplay as a React Component
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