From 4b83774cdbfbf30add9a8fa2f11b1c4ff35179fa Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 26 Apr 2012 12:50:57 -0700 Subject: canvas interaction --- assets/canvas-runtime.js | 110 +++++++++++++++++++++++++++++++---------------- 1 file changed, 74 insertions(+), 36 deletions(-) (limited to 'assets') diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index ee9f24a4..b2db2cbd 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js @@ -116,7 +116,8 @@ NinjaCvsRt.GLRuntime = function ( canvas, jObj, assetPath ) this._aspect = canvas.width/canvas.height; - this._geomRoot = null; + //this._geomRoot = null; + this._rootChildren = []; // all "live" materials this._materials = []; @@ -152,26 +153,36 @@ NinjaCvsRt.GLRuntime = function ( canvas, jObj, assetPath ) this.loadScene = function() { var jObj = this._jObj; - if (!jObj.children || (jObj.children.length != 1)) + if (!jObj.children) // || (jObj.children.length != 1)) throw new Error( "ill-formed JSON for runtime load: " + jObj ); - var root = jObj.children[0]; + var nChildren = jObj.children.length; // parse the data + var child; if (jObj.scenedata) { this._useWebGL = true; var rdgeStr = jObj.scenedata; this.myScene.importJSON( rdgeStr ); - this.importObjects( root ); - this.linkMaterials( this._geomRoot ); + for (var i=0; i 0.001) - ctx.quadraticCurveTo( inset, height-inset, inset+rad, height-inset ); + ctx.quadraticCurveTo( inset+xOff, height-inset+yOff, inset+rad+xOff, height-inset+yOff ); // do the bottom of the rectangle pt = [width - inset, height - inset]; rad = brRad - inset; if (rad < 0) rad = 0; pt[0] -= rad; - ctx.lineTo( pt[0], pt[1] ); + ctx.lineTo( pt[0]+xOff, pt[1]+yOff ); // get the bottom right arc if (rad > 0.001) - ctx.quadraticCurveTo( width-inset, height-inset, width-inset, height-inset-rad ); + ctx.quadraticCurveTo( width-inset+xOff, height-inset+yOff, width-inset+xOff, height-inset-rad+yOff ); // get the right of the rectangle pt = [width - inset, inset]; rad = trRad - inset; if (rad < 0) rad = 0; pt[1] += rad; - ctx.lineTo( pt[0], pt[1] ); + ctx.lineTo( pt[0]+xOff, pt[1]+yOff ); // do the top right corner if (rad > 0.001) - ctx.quadraticCurveTo( width-inset, inset, width-inset-rad, inset ); + ctx.quadraticCurveTo( width-inset+xOff, inset+yOff, width-inset-rad+xOff, inset+yOff ); // do the top of the rectangle pt = [inset, inset]; rad = tlRad - inset; if (rad < 0) rad = 0; pt[0] += rad; - ctx.lineTo( pt[0], pt[1] ); + ctx.lineTo( pt[0]+xOff, pt[1]+yOff); // do the top left corner if (rad > 0.001) - ctx.quadraticCurveTo( inset, inset, inset, inset+rad ); + ctx.quadraticCurveTo( inset+xOff, inset+yOff, inset+xOff, inset+rad+yOff ); else - ctx.lineTo( inset, 2*inset ); + ctx.lineTo( inset+xOff, 2*inset+yOff ); } }; -- cgit v1.2.3