About

Work-in-progress.

Example Code


$(function()
{   
    var sc3 = require("surfacecurve-gfx");   

    var sceneDesc = 
    {
        camera :
        {
            type        : "spinning_camera",
            target      : [ 0, 0, 0 ],
            radius      : 2,
            height      : .75
        },
        materials :
        {
            "@urls" : 
            {
                base : "/data/resources/shaderbuilder/materials/",
                list :
                [
                    "checker-simple",
                    "checker-nested"
                ]
            },        
            "simple" : {
                diffuse : { color : [ .2, .2, .7 ] }
            },           
        },
        objects : 
        [
            { sphere : {
                position : [ -1.25, 0, 0.0 ],
                material : "simple"
            }},
            { sphere : {
                position : [ 0, 0, 0.0 ],
                material : "checker-simple"
            }},
            { sphere : {
                position : [ 1.25, 0, 0.0 ],
                material : "checker-nested"
            }},
        ]
    };
    
    var canvas = $("#canvas").get(0);
    
    // Create and configure the engine
    var engine = new sc3.Engine;
    engine.renderer = new sc3.Renderer(canvas);
    engine.renderer.loadBundle("/data/resources/shaderbuilder/shaderbuilder-bundle.json");
    
    // Load the database
    engine.add("scene", sceneDesc);
    
    
    // Begin rendering once the data is loaded and the engine is ready
    engine.renderer.ready(function() 
    {        
        var camera = _.first( engine.select(".camera") );
        
        engine.interval(function(ctx) {
            var instances = engine.select(".renderable");
            camera.update(ctx.realtime * Math.PI / 3000);
            engine.renderer.renderScene(camera, instances);
        }, 1000 / 30);
        
    });
});

Setup