Overview

This sample loads and displays a Blender .blend file from a URL (no preprocessing or off-line format conversion).

Future

The APIs involved need revision. They are currently in a "get it working" state.

Example Code


$(function()
{   
    var sc3 = require("surfacecurve-gfx");      
    
    var canvas = $("#canvas").get(0);
    var renderer = new sc3.Renderer(canvas, { antialias : true });
    
    var engine = new sc3.Engine;
    engine.renderer = new sc3.Renderer(canvas);
    engine.renderer.loadBundle("/data/resources/shaderbuilder/shaderbuilder-bundle.json");
                
    var url = "/data/resources/models/suzanne_subdivided.blend";
    engine.renderer._loadBinary(url, function(err, binaryArray)
    {                    
        var sceneDesc = 
        {
            camera :
            {
                type        : "spinning_camera",
                target      : [ 0, 0, .5 ],
                radius      : 3,
                height      : .5
            },    
            objects : 
            [
                { model_file : { binary : binaryArray } }
            ]
        };
                
        engine.add("scene", sceneDesc);
        
        var dataUrl = "/data/resources/shaders/";   
        engine.renderer.loadShader(dataUrl, "diffuse-fake.vert", "checker-spherical-oc.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 * Math.sin(ctx.virttime / 1500) );
                engine.renderer.renderScene(camera, instances);
            }, 1000 / 30);
        });
    });


});

Setup