module import { NodeDisplayData } from "../../../types" ; import { floatColor } from "../../../utils" ; import vertexShaderSource from "../shaders/node.fast.vert.glsl" ; import fragmentShaderSource from "../shaders/node.fast.frag.glsl" ; import { AbstractNodeProgram } from "./common/node" ; import { RenderParams } from "./common/program" ; const POINTS = 1 , ATTRIBUTES = 4 ; export default class NodeFastProgram extends AbstractNodeProgram { constructor ( gl ) { super ( gl , vertexShaderSource , fragmentShaderSource , POINTS , ATTRIBUTES ) ; this . bind ( ) ; } process ( data , hidden , offset ) { const array = this . array ; let i = offset * POINTS * ATTRIBUTES ; if ( hidden ) { array [ i ++ ] = 0 ; array [ i ++ ] = 0 ; array [ i ++ ] = 0 ; array [ i ++ ] = 0 ; return ; } const color = floatColor ( data . color ) ; array [ i ++ ] = data . x ; array [ i ++ ] = data . y ; array [ i ++ ] = data . size ; array [ i ] = color ; } render ( params ) { if ( this . hasNothingToRender ( ) ) return ; const gl = this . gl ; const program = this . program ; gl . useProgram ( program ) ; gl . uniform1f ( this . ratioLocation , 1 / Math . sqrt ( params . ratio ) ) ; gl . uniform1f ( this . scaleLocation , params . scalingRatio ) ; gl . uniformMatrix3fv ( this . matrixLocation , false , params . matrix ) ; gl . drawArrays ( gl . POINTS , 0 , this . array . length / ATTRIBUTES ) ; } }