Example Code

//
// Entry-point: run at document ready
//
$(function()
{   
    // Load the surfacecurve-gfx library.  It's accessible via an exported require()
    // function
    var sc3 = require("surfacecurve-gfx");   
    
    // This is a user scene description: described to be convenient and natural
    // for specification.  It is a superset of the normalized format used internally
    // by the engine.
    //
    var sceneDesc = 
    {
        camera :
        {
            type        : "spinning_camera",
            target      : [ 0, 0, 0 ],
            radius      : 2,
            height      : .75
        },
    
        objects : [{ type : "unit_cube" }]
    };
    
    
    var engine = new sc3.Engine;
    engine.renderer = new sc3.Renderer(canvas);
    engine.renderer.loadBundle("/data/resources/shaderbuilder/shaderbuilder-bundle.json");
    engine.add("scene", sceneDesc);
        
    var dataUrl = "/data/resources/shaders/";    
    engine.renderer.loadShader(dataUrl, "diffuse-fake.vert", "simple-color.frag");
    engine.renderer.ready(function()
    {            
        var camera = _.first( engine.select(".camera") );
    
        engine.interval(function(ctx) {
            var instances = engine.select(".renderable");
            camera.update(2 * Math.PI * ctx.virttime / 5000);
            engine.renderer.renderScene(camera, instances);
        }, 1000 / 30);
    });
});

Setup