Custom geometry using vertex arrays not rendering

20 views
Skip to first unread message

Siddharth Vaghela

unread,
Jun 8, 2012, 8:44:34 AM6/8/12
to sce...@googlegroups.com
Hi,

This is what I am trying out:

//******************************************************************
/*global variables*/
var circle_tri_fan_vert;
var circle_tri_fan_ind;
var circle_tri_fan_colors;


function hardCodedTriangles() {
circle_tri_fan_vert = new Array();
circle_tri_fan_ind = new Array();
circle_tri_fan_colors = new Array();

//first vertex
circle_tri_fan_ind.push(0);
circle_tri_fan_vert.push(1);
circle_tri_fan_vert.push(0);
circle_tri_fan_vert.push(0);
circle_tri_fan_colors.push(0.5);
circle_tri_fan_colors.push(0.5);
circle_tri_fan_colors.push(0.5);
circle_tri_fan_colors.push(1);

//second vertex
circle_tri_fan_ind.push(1);
circle_tri_fan_vert.push(-1);
circle_tri_fan_vert.push(0);
circle_tri_fan_vert.push(0);
circle_tri_fan_colors.push(0.5);
circle_tri_fan_colors.push(0.5);
circle_tri_fan_colors.push(0.5);
circle_tri_fan_colors.push(1);
//third vertex
circle_tri_fan_ind.push(2);
circle_tri_fan_vert.push(0);
circle_tri_fan_vert.push(1);
circle_tri_fan_vert.push(0);
circle_tri_fan_colors.push(0.5);
circle_tri_fan_colors.push(0.5);
circle_tri_fan_colors.push(0.5);
circle_tri_fan_colors.push(1);
}

hardCodedTriangles();

/*Create the Scenegraph for the gauge*/
SceneJS.createScene( {
id: "gauge",
canvasId: "viewport",
loggingElementId: "theLoggingDiv",
nodes: [
        {
            type: "lookAt",
            id: "my-lookat",

            eye: { z: 100 },
            look: { z: 0 },

            nodes: [
{
type: "scale",
id: "root",
x: 1,
y: 1,
z: 0,
nodes: [
{
type: "geometry",
id: "gauge_bg_circle",
primitive: "triangles",
positions: circle_tri_fan_vert,
indices: circle_tri_fan_ind,
colors: circle_tri_fan_colors
}
]
}
            ]
}
    ]



});

var canvas = document.getElementById("viewport");

var scene = SceneJS.scene("gauge");

scene.start();


//****************************************************************************

Now, SceneJS loads everything properly but does not render anything! Only one black square appears in the canvas.

can anyone help?

regards,
Siddharth

Reply all
Reply to author
Forward
0 new messages