XML Feeds

.

[javascript-dev] Re: Re: Strange "undefined" problem using screentoworld...

Anthony Palomba apalomba at austin.rr.com
Mon May 19 11:16:02 MDT 2008


Okay here is an example...

test.pat...

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 320 91 39 9109513 random;
#P message 240 91 55 9109513 not_correct;
#P user jsui 240 137 64 64 1 0 0 test.js;
#P message 182 91 37 9109513 correct;
#P connect 3 0 1 0;
#P connect 2 0 1 0;
#P connect 0 0 1 0;
#P window clipboard copycount 4;






test.js...

////////////////////////////////////////////////////////////////////////////////////////////
// Outlet/Inlet declarations

// Set number if inlets (jsui method)
inlets = 1;

// Set number if outlets (jsui method)
outlets = 1;


////////////////////////////////////////////////////////////////////////////////////////////
// global code
sketch.default3d();

var NodeList = new Array(); 
NodeList[0] = new Node();

////////////////////////////////////////////////////////////////////////////////////////////
// functions

function correct() 
{	
	post("NodeGraph dump: ", NodeList.length, "nodes.
");				
	for(var i = 0; i < NodeList.length; i++)
	{
		post("node", i, ": ", NodeList[i].x, NodeList[i].y, NodeList[i].z, "
");				}


	NodeList[0].x = 0.0;
	NodeList[0].y = 0.0
	NodeList[0].z = 1.0;


	post("NodeGraph dump: ", NodeList.length, "nodes.
");				
	for(var i = 0; i < NodeList.length; i++)
	{
		post("node", i, ": ", NodeList[i].x, NodeList[i].y, NodeList[i].z, "
");		
	}	

}

function not_correct() 
{	
	post("NodeGraph dump: ", NodeList.length, "nodes.
");				
	for(var i = 0; i < NodeList.length; i++)
	{
		post("node", i, ": ", NodeList[i].x, NodeList[i].y, NodeList[i].z, "
");				}


	wxyz = sketch.screentoworld(100/2,100/2);	
	post("wxyz =", wxyz, "
");
	NodeList[0].x = wxyz.x;
	NodeList[0].y = wxyz.y;
	//this.NodeList[0].x = 0.0;
	//this.NodeList[0].y = 0.0
	NodeList[0].z = 1.0;


	post("NodeGraph dump: ", NodeList.length, "nodes.
");				
	for(var i = 0; i < NodeList.length; i++)
	{
		post("node", i, ": ", NodeList[i].x, NodeList[i].y, NodeList[i].z, "
");		
	}	

}


function random() 
{	

	NodeList[0].x = (Math.random()-0.5)*2;
	NodeList[0].y = (Math.random()-0.5)*2;
	NodeList[0].z = (Math.random()-0.5)*2;

	post("NodeGraph dump: ", NodeList.length, "nodes.
");				
	for(var i = 0; i < NodeList.length; i++)
	{
		post("node", i, ": ", NodeList[i].x, NodeList[i].y, NodeList[i].z, "
");		
	}	

}
/////////////////////////////////////////////////////////////////////////////////////////////////
// Node Class

//  Node Constructor
function Node(id)
{
	post("Node Constructor...
");
	//this.x = (Math.random()-0.5)*2;
	//this.y = (Math.random()-0.5)*2;
	//this.z = (Math.random()-0.5)*2;
	this.x = (Math.random()-0.5)*2;
	this.y = (Math.random()-0.5)*2;
	this.z = (Math.random()-0.5)*2;
	this.r = 0.0;
	this.Data = 0.0;
	this.Text = ""; 
}

// Node member Variables:
Node.prototype.x = 0.0;
Node.prototype.y = 0.0;
Node.prototype.z = 0.0;
Node.prototype.r = 0.0;
Node.prototype.g = 0.0;
Node.prototype.b = 0.0;
Node.prototype.radius = 0.0;
Node.prototype.Data = 0.0;
Node.prototype.Text = ""; 



More information about the javascript-dev mailing list