Skip to content

A lightweight JavaScript library for loading and animating textured 3D models in WebGL.

Notifications You must be signed in to change notification settings

opencontributions/minigl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minigl

A lightweight JavaScript library for loading and animating textured 3D models in WebGL.

View a demo at minigl.pro

Alt text

An experimental, minimal plain ES2015 JavaScript WebGL library for loading and animating textured 3D models.

Example usage:

    var can = document.getElementById('can');
    var glCtx = can.getContext('webgl') || can.getContext('experimental-webgl');
    var shaders = ['webgl_demo/script_webgl/fragment.gl', 'webgl_demo/script_webgl/vertex.gl'];
    
    var webGl = new miniGL(glCtx);
    webGl.initProgram(shaders, function() {
        var drawers = this.createModel(
            ['webgl_demo/models_webgl/model_drawer.json'],
            ['webgl_demo/textures_webgl/texture_drawer.png'],
            {
                scale: {
                    x: 1,
                    y: 1,
                    z: 1
                },
                rotate: {
                    x: 0,
                    y: 0,
                    z: 0
                },
                translate: {
                    x: 0,
                    y: 0,
                    z: 0
                },
            },
            function(model) {
                if (this.rotate.y > Math.PI && model.translate.x < 1) {
                    model.translate.x += .01;
                }
                else if (model.translate.x > 0) {
                    model.translate.x -= .01;
                }
            }
        );
        this.init(function(world) {
            world.rotate.y = (performance.now() / 30000 * 2 * Math.PI) % Math.PI * 2;
        });
        this.animationLoop();
    });

About

A lightweight JavaScript library for loading and animating textured 3D models in WebGL.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published