Adding nodes programatically

32 views
Skip to first unread message

Tim

unread,
Dec 18, 2012, 3:50:32 PM12/18/12
to sce...@googlegroups.com
I'm working on a 3d data visualization prototype.  I create a scene with the x/y/z axis as planes then programatically add data points, e.g.:

SceneJS.createScene({
type: "scene",
id: "theScene",
canvasId: "theCanvas",

nodes: [....

Then I instantiate the scene like many of the examples:

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

Finally I add data points programatically with this code:

var n = scene.findNode("disclosure-events");
var deptArr = getDisclosureEvents();
for ( var i = 0; i < deptArr.length; i++ )
{
n._targetNode.addNode(generateNode('p'+(i+1), deptArr[i]));
}

var generateNode = function(id, dept)
{
var pt = new Object();
pt.type = 'geometry';
pt.primitive = 'triangles';
pt.id = id;
pt.positions = dept.getPositions();
pt.normals = dept.getNormals();
pt.uv = null;
pt.uv2 = null;
pt.indicies = dept.getIndices();
pt.colors = dept.getColors();
return pt;
}

Finally I start the scene.  The axis show up and function like I would expect.  However the data points do not.  I suspect the scene is compiled when first instantiated and subsequent modifications ignored.

Any help would be appreciated.

(Btw, I first tried to use the geo-load service but couldn't figure out a way to add multiple nodes.)

Reply all
Reply to author
Forward
0 new messages