Example Code


$(function()
{   
    var sc3 = require("surfacecurve-gfx");   
    
    /* 
        The scene description is a flexible, user-friendly JSON format.  It allows the scene
        to be specified "practically".  
        
        A parser produces a normalized, device-independent scene format.
        
        The renderer itself then can attach device-dependent caches to the scene as it 
        renders the objects.
     */
    var sceneDesc = 
    {
        camera :
        {
            type        : "spinning_camera",
            target      : [ 0, 0, 0 ],
            radius      : 2,
            height      : .75
        },
    
        objects : 
        [
            {
                type     : "unit_sphere",
                position : [ .5, 0, 0.0 ]
            },
        ]
    };
    
    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