How to use the webgl-operate.vec3.fromValues 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 / shadow-mapping / shadowmapping.ts View on Github external
meshVert.initialize(require('./mesh.vert'));
        const meshFrag = new Shader(this._context, gl.FRAGMENT_SHADER, 'mesh.frag');
        meshFrag.initialize(require('./mesh.frag'));

        this._meshProgram = new Program(this._context);
        this._meshProgram.initialize([meshVert, meshFrag]);

        this._uMeshViewMatrix = this._meshProgram.uniform('u_lightViewMatrix');
        this._uMeshProjectionMatrix = this._meshProgram.uniform('u_lightProjectionMatrix');
        this._uMeshFarPlane = this._meshProgram.uniform('u_lightFarPlane');
        this._uCameraViewProjectionMatrix = this._meshProgram.uniform('u_cameraViewProjectionMatrix');
        this._uMeshDepthTexture = this._meshProgram.uniform('u_depthTexture');

        // Setup Cameras
        this._camera = new Camera();
        this._camera.center = vec3.fromValues(0.0, 0.0, 0.0);
        vec3.normalize(this._camera.up, vec3.fromValues(-1.0, 1.0, 0.0));
        this._camera.eye = vec3.fromValues(6.0, 6.0, 0.0);
        this._camera.near = 3.0;
        this._camera.far = 32.0;

        this._light = new Camera();
        this._light.center = vec3.fromValues(0.0, 0.0, 0.0);
        vec3.normalize(this._light.up, vec3.fromValues(0.0, 1.0, -1.0));
        this._light.eye = vec3.fromValues(0.0, 6.0, 6.0);
        this._light.near = 3.0;
        this._light.far = 16.0;
        this._light.aspect = 1;

        // Setup Navigation
        this._navigation = new Navigation(callback, mouseEventProvider);
        this._navigation.camera = this._camera;
github cginternals / webgl-operate / demos / cubescape / cubescape.ts View on Github external
Texture2D,
    Wizard,
} from 'webgl-operate';

import { Demo } from '../demo';

import { CubeGeometry } from './cubegeometry';

/* spellchecker: enable */

// tslint:disable:max-classes-per-file


const _gEye = vec3.fromValues(1.0, -0.5, -1.0);
const _gCenter = vec3.fromValues(0.0, -1.0, 0.0);
const _gUp = vec3.fromValues(0.0, 1.0, 0.0);


class CubescapeRenderer extends Renderer {

    protected _defaultFBO: DefaultFramebuffer;

    protected _camera: Camera;
    protected _navigation: Navigation;

    protected _geometry: CubeGeometry;
    protected _program: Program;
    protected _uViewProjection: WebGLUniformLocation;
    protected _aVertex: GLuint;
    protected _numCubes = 256;

    protected _patches: Texture2D;
github cginternals / webgl-operate / demos / shadow-mapping / shadowmapping.ts View on Github external
this._uMeshProjectionMatrix = this._meshProgram.uniform('u_lightProjectionMatrix');
        this._uMeshFarPlane = this._meshProgram.uniform('u_lightFarPlane');
        this._uCameraViewProjectionMatrix = this._meshProgram.uniform('u_cameraViewProjectionMatrix');
        this._uMeshDepthTexture = this._meshProgram.uniform('u_depthTexture');

        // Setup Cameras
        this._camera = new Camera();
        this._camera.center = vec3.fromValues(0.0, 0.0, 0.0);
        vec3.normalize(this._camera.up, vec3.fromValues(-1.0, 1.0, 0.0));
        this._camera.eye = vec3.fromValues(6.0, 6.0, 0.0);
        this._camera.near = 3.0;
        this._camera.far = 32.0;

        this._light = new Camera();
        this._light.center = vec3.fromValues(0.0, 0.0, 0.0);
        vec3.normalize(this._light.up, vec3.fromValues(0.0, 1.0, -1.0));
        this._light.eye = vec3.fromValues(0.0, 6.0, 6.0);
        this._light.near = 3.0;
        this._light.far = 16.0;
        this._light.aspect = 1;

        // Setup Navigation
        this._navigation = new Navigation(callback, mouseEventProvider);
        this._navigation.camera = this._camera;

        // Setup Geometry
        this._cube = new Cube(this._context, 'cube');
        this._cube.initialize(0);

        this._plane = new Plane(this._context, 'plane');
        this._plane.initialize(0);
github cginternals / webgl-operate / examples / shadowmap-example.ts View on Github external
protected drawCuboids(model: WebGLUniformLocation): void {
        const gl = this._context.gl;

        const M = mat4.create();
        for (let i = 0; i < this._cuboids.length; ++i) {

            const x = i * 0.5 - 0.75;
            const y = this._cuboids[i].extent[1] * 0.5;

            mat4.fromTranslation(M, vec3.fromValues(-x, y, 0.0));
            gl.uniformMatrix4fv(model, gl.GL_FALSE, M);

            this._cuboids[i].bind();
            this._cuboids[i].draw();
        }
    }
github cginternals / webgl-operate / examples / shadowmap-multiframe-example.ts View on Github external
for (let i = 0; i < this._cuboids.length; ++i) {
            this._cuboids[i] = new CuboidGeometry(context, 'cube', true, [0.25, 0.5 + 0.5 * i, 2.0]);
            this._cuboids[i].initialize();
        }

        this._plane = new PlaneGeometry(context, 'plane');
        this._plane.initialize();
        this._plane.scale = vec2.fromValues(100, 100);

        this._ndcTriangle = new NdcFillingTriangle(this._context);
        this._ndcTriangle.initialize();


        this._camera = new Camera();
        this._camera.center = vec3.fromValues(0.0, 0.75, 0.0);
        this._camera.up = vec3.fromValues(0.0, 1.0, 0.0);
        this._camera.eye = vec3.fromValues(1.8, 2.6, 3.4);
        this._camera.near = 2.0;
        this._camera.far = 11.0;


        this._light = new Camera();
        this._light.center = vec3.fromValues(0.0, 0.0, 0.0);
        this._light.up = vec3.fromValues(0.0, 1.0, 0.0);
        this._light.eye = vec3.fromValues(-3.0, 5.0, 4.0);
        this._light.near = 3.0;
        this._light.far = 20.0;


        this._colorRenderTexture = new Texture2D(this._context, 'ColorRenderTexture');
        this._depthRenderbuffer = new Renderbuffer(this._context, 'DepthRenderbuffer');
        this._intermediateFBO = new Framebuffer(this._context, 'IntermediateFBO');
github cginternals / webgl-operate / examples / shadowmap-multiframe-example.ts View on Github external
this._cuboids = new Array(4);
        for (let i = 0; i < this._cuboids.length; ++i) {
            this._cuboids[i] = new CuboidGeometry(context, 'cube', true, [0.25, 0.5 + 0.5 * i, 2.0]);
            this._cuboids[i].initialize();
        }

        this._plane = new PlaneGeometry(context, 'plane');
        this._plane.initialize();
        this._plane.scale = vec2.fromValues(100, 100);

        this._ndcTriangle = new NdcFillingTriangle(this._context);
        this._ndcTriangle.initialize();


        this._camera = new Camera();
        this._camera.center = vec3.fromValues(0.0, 0.75, 0.0);
        this._camera.up = vec3.fromValues(0.0, 1.0, 0.0);
        this._camera.eye = vec3.fromValues(1.8, 2.6, 3.4);
        this._camera.near = 2.0;
        this._camera.far = 11.0;


        this._light = new Camera();
        this._light.center = vec3.fromValues(0.0, 0.0, 0.0);
        this._light.up = vec3.fromValues(0.0, 1.0, 0.0);
        this._light.eye = vec3.fromValues(-3.0, 5.0, 4.0);
        this._light.near = 3.0;
        this._light.far = 20.0;


        this._colorRenderTexture = new Texture2D(this._context, 'ColorRenderTexture');
        this._depthRenderbuffer = new Renderbuffer(this._context, 'DepthRenderbuffer');
github cginternals / webgl-operate / examples / shadowmap-example.ts View on Github external
this._plane = new PlaneGeometry(context, 'plane');
        this._plane.initialize();
        this._plane.scale = vec2.fromValues(100, 100);

        this._camera = new Camera();
        this._camera.center = vec3.fromValues(0.0, 0.75, 0.0);
        this._camera.up = vec3.fromValues(0.0, 1.0, 0.0);
        this._camera.eye = vec3.fromValues(1.8, 2.6, 3.4);
        this._camera.near = 2.0;
        this._camera.far = 11.0;


        this._light = new Camera();
        this._light.center = vec3.fromValues(0.0, 0.0, 0.0);
        this._light.up = vec3.fromValues(0.0, 1.0, 0.0);
        this._light.eye = vec3.fromValues(-3.0, 5.0, 4.0);
        this._light.near = 3.0;
        this._light.far = 20.0;


        const vert = new Shader(context, gl.VERTEX_SHADER, 'mesh-shadowed.vert');
        vert.initialize(require('./data/mesh-shadowed.vert'));
        const frag = new Shader(context, gl.FRAGMENT_SHADER, 'mesh-shadowed.frag');
        frag.initialize(require('./data/mesh-shadowed.frag'));

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

        this._program.attribute('a_vertex', this._cuboids[0].vertexLocation);
        this._program.attribute('a_texCoord', this._cuboids[0].uvCoordLocation);
        this._program.link();
github cginternals / webgl-operate / examples / shadowmap-multiframe-example.ts View on Github external
protected drawCuboids(model: WebGLUniformLocation): void {
        const gl = this._context.gl;

        const M = mat4.create();
        for (let i = 0; i < this._cuboids.length; ++i) {

            const x = i * 0.5 - 0.75;
            const y = this._cuboids[i].extent[1] * 0.5;

            mat4.fromTranslation(M, vec3.fromValues(-x, y, 0.0));
            gl.uniformMatrix4fv(model, gl.GL_FALSE, M);

            this._cuboids[i].bind();
            this._cuboids[i].draw();
        }
    }