How to use the gl.Mesh function in gl

To help you get started, we’ve selected a few gl 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 JordanMachado / webgl-tools / src / Scene.js View on Github external
uvsy.push(i/width);
     uvsy.push(i/width);
   }
   const position = duplicate(path)
   const directions = duplicate(path.map(x => 1), true)
   const indexBuffer = createIndices(path.length);

   const geometry = this.geometry = new G.Geometry();
   geometry.addAttribute('positions', position)
   geometry.addAttribute('directions', directions)
   geometry.addIndices(indexBuffer, true);
   geometry.addInstancedAttribute('uvys', uvsy, 1);
   geometry.addAttribute('uvs', uvs)
   geometry.addCount(uvsy.length)

   this.lines = new G.Mesh(geometry,shader);
   this.lines.position.y = 2;
   this.scene.addChild(this.lines);

   let dataPos = new Float32Array(width * height * 4);
   let count = 0;
   let row = 0;
   let lifes = [];
   for (var i = 0; i < height; i++) {
lifes.push(Math.random())
   }
   let r = Math.random()
   let rr = 1;
   for (let i = 0, l = width * height * 4; i < l; i += 4) {
     // if((count % width) / width <= 1.0/width) {

     // }
github JordanMachado / webgl-tools / src / experiments / particles / System.js View on Github external
});

        const geometry = new G.Geometry();

        geometry.addAttribute('positions', pos, true);

        geometry.addAttribute('colors', colors, true);
        geometry.addAttribute('twouvs', uvs, true);
        geometry.addAttribute('sizes', size, true);

        const normal = this.normal = new G.Texture(gl);

        normal.format = gl.RGBA;
        normal.upload(window.getAsset('img/normal.png'));

        this.mesh = new G.Mesh(
            geometry,
            new G.Shader(
                glslify('./shaders/instancing.vert'),
                glslify('./shaders/instancing.frag'), {
                    uBuffer: dataText,
                    normalTexture: normal,
                    uShadowMap: scene.fbo.depth,
                    uShadowMatrix: scene.mvpDepth,
                    toLook: [0, 0, 1],
                },
                'Particles'
            ), {
                drawType: gl.POINTS,
            });

        scene.fboHelper.attach(this.gpu.fboOut.colors);
github JordanMachado / webgl-tools / src / experiments / spring / Scene.js View on Github external
width,
            height,
            timeAdd: 0.001,

            renderer: this.webgl,
            camera: new G.OrthographicCamera(-1, 1, -1, 1, 0.1, 100),
            vs: glslify('./shaders/basic.vert'),
            fs: glslify('./shaders/sim.frag'),
            uniforms: {
                uMouse: [0, 0, 0],
            },
        });

        this.fboHelper.attach(this.gpu.fboOut.colors);

        this.sphere = new G.Mesh(geom, new G.Shader(
            `
             attribute vec3 aPosition;
             attribute vec2 aUv;
             attribute vec2 aCuvs;


             uniform mat4 projectionMatrix;
             uniform mat4 viewMatrix;
             uniform mat4 worldMatrix;
             uniform mat3 normalMatrix;

             uniform sampler2D uBuffer;


             void main() {