強火で進め

このブログではプログラム関連の記事を中心に書いてます。

Senchaが作成したWebGL向けのライブラリ「PhiloGL」


Ext JSフレームワークなどで知られるSenchaがWebGL向けのライブラリ「PhiloGL」を作成したみたいです。

PhiloGL
http://www.sencha.com/blog/introducing-philogl-a-webgl-javascript-library-from-sencha-labs/

ライセンスはMITライセンス。

プログラムの記述方法はこの様になるみたいです。

//Create application
PhiloGL('canvasId', {
    camera: {
        position: {
            x: 0, y: 0, z: -7
        }
    },
    scene: {
        lights: {
            enable: true,
            ambient: { r: 0.5, g: 0.5, b: 0.5 },
            directional: {
                color: { r: 0.7, g: 0.7, b: 0.9 },
                direction: { x: 1, y: 1, z: 1 }
            }
        }
    },
    textures: {
        src: ['moon.gif']
    },
    events: {
        onClick: function(e) {
            /* write event handler here */
        }
    },
    onError: function() {
        alert("There was an error creating the app.");
    },
    onLoad: function(app) {
        //Do things with the application...
        //Add object to the scene
        scene.add(moon)
        //Animate
        setInterval(draw, 1000/60);
        //Draw the scene
        function draw() {
            //render moon
            scene.render();
        }
    }
});

少ないコード量&直感的に分り易い作りになっていて中々使えるライブラリな気がします。

Learning WebGLで公開されているサンプルをPhiloGLに移植したものこちらに公開されています。まずはこの様な小さいサイズのサンプルのコードを読んで使い方を理解するのが良いでしょう。

PhiloGL: A WebGL Framework for Data Visualization, Creative Coding and Game Development
http://senchalabs.github.com/philogl/lessons.html