How to use the gl.Primitive 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 / experiments / spring / Scene.js View on Github external
dataPos[i] = x;
            dataPos[i + 1] = y;
            dataPos[i + 2] = z;
            dataPos[i + 3] = Math.random();

            pos[count * 3 + 0] = dataPos[i];
            pos[count * 3 + 1] = dataPos[i + 1];
            pos[count * 3 + 2] = dataPos[i + 2];

            uvs[count * 2 + 0] = (count % width) / width;
            uvs[count * 2 + 1] = Math.floor(count / width) / height;

            size[count] = G.utils.random(0.5, 1);
        }
        const prim = G.Primitive.cube(1, 1, 1);
        const geom = new G.Geometry(prim);

        const uvvv = new Float32Array(prim.uvs.length);

        for (let i = 0; i < prim.uvs.length * 2; i += 2)
        {
            uvvv[count * 2 + 0] = (count % width) / width;
            uvvv[count * 2 + 1] = Math.floor(count / width) / height;
            count++;
        }
        console.log(uvvv.length);
        geom.addAttribute('cuvss', uvvv);

        // console.log(this.sphere.geometry.positions._data.length);
        // console.log(144/2);
        // console.log(Math.pow(Math.floor(Math.log2(this.sphere.geometry.positions._data.length)),2));
github JordanMachado / webgl-tools / src / experiments / particles / Scene.js View on Github external
gl_FragColor.rgb *= vec3(smoothstep(0.0, 1.0, shadow+0.65));



          `,

            },
        }));
        this.quad.scale.set(10);
        // this.quad.scale.set(2);

        this.quad.position.y = -4;
        this.quad.rotation.x = Math.PI / 180 * -90;
        this.scene.addChild(this.quad);

        this.hitarea = new G.Mesh(new G.Geometry(G.Primitive.quad(1)), new G.BasicMaterial());

        this.hitDetect = new G.HitDetect(this.hitarea, this.camera);

        this.hitarea.scale.set(10);

    // this.scene.addChild(this.hitarea);
    }
    render()
github JordanMachado / webgl-tools / src / Scene.js View on Github external
0.5, 0.0, 0.0, 0.0,
        0.0, 0.5, 0.0, 0.0,
        0.0, 0.0, 0.5, 0.0,
        0.5, 0.5, 0.5, 1.0
      );
    mat4.multiply(this.mvpDepth, biaMatrix, this.mvpDepth);


    this.controls = new OrbitalCameraControl(this.camera, 20, window);
    this.fbo = new G.FrameBuffer(gl, 1024, 1024 , { depth: true});



    this.scene = new G.Object3D();

    this.quad = new G.Mesh(new G.Geometry(G.Primitive.plane(10,10, 30, 30)), new G.BasicMaterial({
      color: G.Utils.hexToRgb(colors[1]),
      uniforms: {
        uShadowMap: this.fbo.depth,
        uShadowMatrix: this.mvpDepth,
      },
      fog: {
        density:0.04,
        gradient:2,
        color:[0,0,0]
      },
      vertex: {
        start: `
        uniform mat4 uShadowMatrix;
        varying vec4 vShadowCoord;

        `,
github JordanMachado / webgl-tools / src / experiments / particles / Scene.js View on Github external
0.5, 0.5, 0.5, 1.0
        );

        mat4.multiply(this.mvpDepth, biaMatrix, this.mvpDepth);

        this.fbo = new G.FrameBuffer(gl, 1024, 1024, { depth: true });
        this.fboHelper.attach(this.fbo.depth);
        this.fboHelper.attach(this.fbo.colors);

        this.scene = new G.Object3D();

        const system = this.system = new System(256, this);

        this.scene.addChild(system.mesh);

        this.quad = new G.Mesh(new G.Geometry(G.Primitive.plane(20, 20, 20, 20)), new G.BasicMaterial({
            color: G.Utils.hexToRgb('#ffffff'),
            uniforms: {
                uShadowMap: this.fbo.depth,
                uShadowMatrix: this.mvpDepth,
            },
            fog: {
                density: 0.02,
                gradient: 2,
                color: G.Utils.hexToRgb('#ffe1d9'),
            },

            vertex: {
                start: `
        uniform mat4 uShadowMatrix;
        varying vec4 vShadowCoord;