How to use the webgl-operate.Buffer function in webgl-operate

To help you get started, we’ve selected a few webgl-operate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cginternals / webgl-operate / demos / cubescape / cubegeometry.ts View on Github external
constructor(context: Context, identifier?: string) {
        super(context, identifier);

        /* Generate identifier from constructor name if none given. */
        identifier = identifier !== undefined && identifier !== `` ? identifier : this.constructor.name;

        const vertexVBO = new Buffer(context, `${identifier}VBO`);
        this._buffers.push(vertexVBO);
        const instancesVBO = new Buffer(context, `${identifier}InstancesVBO`);
        this._buffers.push(instancesVBO);

        const indexBuffer = new Buffer(context, `${identifier}IndicesVBO`);
        this._buffers.push(indexBuffer);

    }
github cginternals / webgl-operate / demos / point-cloud / point-cloud.ts View on Github external
const particle = new Float32Array([-1.0, -1.0, +1.0, -1.0, +1.0, +1.0, -1.0, +1.0]);

        // const hypotenuse = Math.sqrt(1 + Math.pow(Math.tan(Math.PI / this._triangles), 2.0));

        // const particle = new Float32Array(2 * (2 + this._triangles));
        // particle[0] = 0.0;
        // particle[1] = 0.0;
        // for (let i = 0; i <= this._triangles; ++i) {
        //     const alpha = i * (2.0 * Math.PI / this._triangles);
        //     particle[i * 2 + 2] = Math.cos(alpha) * hypotenuse;
        //     particle[i * 2 + 3] = Math.sin(alpha) * hypotenuse;
        // }

        this._particleVBO = new Buffer(context, 'particleVBO');
        this._particleVBO.initialize(gl.ARRAY_BUFFER);
        this._particleVBO.attribEnable(this._uvLocation, 2, gl.FLOAT, false
            , 2 * floatSize, 0, true, false);
        gl2facade.vertexAttribDivisor(this._uvLocation, 0);
        this._particleVBO.data(particle, gl.STATIC_DRAW);


        this._numPointsAllocated = 1e6;
        this._numPointsToRender = 1e5;


        const positions = new Float32Array(3 * this._numPointsAllocated);
        positions.forEach((value, index, array) => array[index] = Math.random());

        this._instancesVBO = new Buffer(context, 'instancesVBO');
        this._instancesVBO.initialize(gl.ARRAY_BUFFER);
github cginternals / webgl-operate / examples / data / example-cube-geometry.ts View on Github external
constructor(context: Context, identifier?: string) {
        super(context, identifier);

        /* Generate identifier from constructor name if none given. */
        identifier = identifier !== undefined
            && identifier !== `` ? identifier : this.constructor.name;

        const vertexVBO = new Buffer(context, identifier + 'VBO');
        this._buffers.push(vertexVBO);
        const indexBuffer = new Buffer(context, identifier + 'IndicesVBO');
        this._buffers.push(indexBuffer);
    }
github cginternals / webgl-operate / demos / shadow-mapping / plane.ts View on Github external
constructor(context: Context, identifier?: string) {
        super(context, identifier);

        /* Generate identifier from constructor name if none given. */
        identifier = identifier !== undefined && identifier !== `` ? identifier : this.constructor.name;

        const vertexVBO = new Buffer(context, identifier + 'VBO');
        const indexBuffer = new Buffer(context, identifier + 'IndexBuffer');
        this._buffers.push(vertexVBO);
        this._buffers.push(indexBuffer);
    }
github cginternals / webgl-operate / demos / shadow-mapping / plane.ts View on Github external
constructor(context: Context, identifier?: string) {
        super(context, identifier);

        /* Generate identifier from constructor name if none given. */
        identifier = identifier !== undefined && identifier !== `` ? identifier : this.constructor.name;

        const vertexVBO = new Buffer(context, identifier + 'VBO');
        const indexBuffer = new Buffer(context, identifier + 'IndexBuffer');
        this._buffers.push(vertexVBO);
        this._buffers.push(indexBuffer);
    }
github cginternals / webgl-operate / demos / shadow-mapping / cube.ts View on Github external
constructor(context: Context, identifier?: string) {
        super(context, identifier);

        /* Generate identifier from constructor name if none given. */
        identifier = identifier !== undefined && identifier !== `` ? identifier : this.constructor.name;

        const vertexVBO = new Buffer(context, identifier + 'VBO');
        const indexBuffer = new Buffer(context, identifier + 'IndexBuffer');
        this._buffers.push(vertexVBO);
        this._buffers.push(indexBuffer);
    }
github cginternals / webgl-operate / demos / cubescape / cubegeometry.ts View on Github external
constructor(context: Context, identifier?: string) {
        super(context, identifier);

        /* Generate identifier from constructor name if none given. */
        identifier = identifier !== undefined && identifier !== `` ? identifier : this.constructor.name;

        const vertexVBO = new Buffer(context, `${identifier}VBO`);
        this._buffers.push(vertexVBO);
        const instancesVBO = new Buffer(context, `${identifier}InstancesVBO`);
        this._buffers.push(instancesVBO);

        const indexBuffer = new Buffer(context, `${identifier}IndicesVBO`);
        this._buffers.push(indexBuffer);

    }
github cginternals / webgl-operate / demos / shadow-mapping / cube.ts View on Github external
constructor(context: Context, identifier?: string) {
        super(context, identifier);

        /* Generate identifier from constructor name if none given. */
        identifier = identifier !== undefined && identifier !== `` ? identifier : this.constructor.name;

        const vertexVBO = new Buffer(context, identifier + 'VBO');
        const indexBuffer = new Buffer(context, identifier + 'IndexBuffer');
        this._buffers.push(vertexVBO);
        this._buffers.push(indexBuffer);
    }
github cginternals / webgl-operate / examples / data / example-cube-geometry.ts View on Github external
constructor(context: Context, identifier?: string) {
        super(context, identifier);

        /* Generate identifier from constructor name if none given. */
        identifier = identifier !== undefined
            && identifier !== `` ? identifier : this.constructor.name;

        const vertexVBO = new Buffer(context, identifier + 'VBO');
        this._buffers.push(vertexVBO);
        const indexBuffer = new Buffer(context, identifier + 'IndicesVBO');
        this._buffers.push(indexBuffer);
    }
github cginternals / webgl-operate / demos / point-cloud / point-cloud.ts View on Github external
this._particleVBO = new Buffer(context, 'particleVBO');
        this._particleVBO.initialize(gl.ARRAY_BUFFER);
        this._particleVBO.attribEnable(this._uvLocation, 2, gl.FLOAT, false
            , 2 * floatSize, 0, true, false);
        gl2facade.vertexAttribDivisor(this._uvLocation, 0);
        this._particleVBO.data(particle, gl.STATIC_DRAW);


        this._numPointsAllocated = 1e6;
        this._numPointsToRender = 1e5;


        const positions = new Float32Array(3 * this._numPointsAllocated);
        positions.forEach((value, index, array) => array[index] = Math.random());

        this._instancesVBO = new Buffer(context, 'instancesVBO');
        this._instancesVBO.initialize(gl.ARRAY_BUFFER);
        this._instancesVBO.attribEnable(this._positionLocation, 3, gl.FLOAT, false
            , 3 * floatSize, 0, true, false);
        gl2facade.vertexAttribDivisor(this._positionLocation, 1);
        this._instancesVBO.data(positions, gl.DYNAMIC_DRAW);


        const vert = new Shader(context, gl.VERTEX_SHADER, 'particle.vert');
        vert.initialize(require('./particle.vert'));
        const frag = new Shader(context, gl.FRAGMENT_SHADER, 'particle.frag');
        frag.initialize(require('./particle.frag'));


        this._program = new Program(context, 'ParticleProgram');
        this._program.initialize([vert, frag], false);