import Element from '../Element' ; import { RenderProgram } from 'src/gl/defineProgram' ; import { DrawContext } from 'src/createScene' ; export default class GLCollection extends Element { uniforms ? : Object ; program : RenderProgram ; constructor ( program ) { super ( ) ; this . program = program ; this . uniforms = undefined ; } getBuffer ( ) { return this . program . getBuffer ( ) ; } appendBuffer ( uint8Collection , offset ) { this . program . appendBuffer ( uint8Collection , offset ) ; if ( this . scene ) this . scene . renderFrame ( ) ; } add ( vertex ) { return this . program . add ( vertex ) ; } update ( id , point ) { this . program . update ( id , point ) ; } remove ( id ) { return this . program . remove ( id ) ; } get ( id ) { return this . program . get ( id ) ; } draw ( gl , drawContext ) { if ( ! this . uniforms ) { this . uniforms = { projectionMatrix : drawContext . projection , model : this . worldModel , view : drawContext . view . matrix , modelViewProjection : this . modelViewProjection } ; } this . program . draw ( this . uniforms ) ; } dispose ( ) { super . dispose ( ) ; if ( this . program ) { this . program . dispose ( ) ; } } }