How to use the gl.PerspectiveCamera 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
this.webgl = new G.Webgl();
    this.time = 0
    this.bgC = '#ffffff';
    this.webgl.append();
    this.webgl.clearColor(colors[0], 1)

    this.mouse = {
      x:0,
      y:0,
    }


    this.camera = new G.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 500);

    let s = 8;
    this.cameraShadow = new G.PerspectiveCamera(45, 1, 0.1, 100);
    // this.cameraShadow =  new G.OrthographicCamera(-s,s,-s,s, 1, 50);
    this.cameraShadow.lookAt([0,20,1], [0,0,0], [0,1,0]);
    this.mvpDepth = mat4.create();
    mat4.multiply(this.mvpDepth, this.cameraShadow.projection, this.cameraShadow.view)
    const biaMatrix = mat4.fromValues(
        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});
github JordanMachado / webgl-tools / src / Scene.js View on Github external
});

    window.scene = this;
    this.webgl = new G.Webgl();
    this.time = 0
    this.bgC = '#ffffff';
    this.webgl.append();
    this.webgl.clearColor(colors[0], 1)

    this.mouse = {
      x:0,
      y:0,
    }


    this.camera = new G.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 500);

    let s = 8;
    this.cameraShadow = new G.PerspectiveCamera(45, 1, 0.1, 100);
    // this.cameraShadow =  new G.OrthographicCamera(-s,s,-s,s, 1, 50);
    this.cameraShadow.lookAt([0,20,1], [0,0,0], [0,1,0]);
    this.mvpDepth = mat4.create();
    mat4.multiply(this.mvpDepth, this.cameraShadow.projection, this.cameraShadow.view)
    const biaMatrix = mat4.fromValues(
        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);
github JordanMachado / webgl-tools / src / experiments / particles / Scene.js View on Github external
constructor()
    {
        this.webgl = new G.Webgl();
        this.webgl.clearColor('#ffe1d9', 1);

        this.webgl.append();
        this.camera = new G.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 500);
        this.controls = new OrbitalCameraControl(this.camera, 20, window);
        this.controls.center = [4, 0, 0];
        this.fboHelper = new G.FBOHelper(this.webgl, 256);

        // this.cameraShadow = new G.PerspectiveCamera(45, 1, 0.1, 100);
        const s = 15;

        this.cameraShadow = new G.OrthographicCamera(-s, s, -s, s, 1, 100);
        this.cameraShadow.lookAt([0, 50, 0.1], [0, 0, 0], [0, 1, 0]);
        this.mvpDepth = mat4.create();
        mat4.multiply(this.mvpDepth, this.cameraShadow.projection, this.cameraShadow.view);
        const biaMatrix = mat4.fromValues(
            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
github JordanMachado / webgl-tools / src / experiments / spring / Scene.js View on Github external
constructor()
    {
        this.webgl = new G.Webgl();
        this.webgl.clearColor('#ffe1d9', 1);

        this.webgl.append();
        this.camera = new G.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 500);
        this.controls = new OrbitalCameraControl(this.camera, 20, window);
        this.fboHelper = new G.FBOHelper(this.webgl, 256);

        this.scene = new G.Object3D();

        const width = 2;
        const height = 3;

        const dataPos = new Float32Array(width * height * 4);
        const pos = new Float32Array(width * height * 3);
        const uvs = new Float32Array(width * height * 2);
        const colors = new Float32Array(width * height * 3);
        const size = new Float32Array(width * height * 1);

        let count = 0;