diff options
Diffstat (limited to 'js/helper-classes')
31 files changed, 1381 insertions, 170 deletions
diff --git a/js/helper-classes/3D/math-utils.js b/js/helper-classes/3D/math-utils.js index 562a6e73..2f0283a9 100755 --- a/js/helper-classes/3D/math-utils.js +++ b/js/helper-classes/3D/math-utils.js | |||
@@ -729,7 +729,10 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { | |||
729 | // the area of the polygon is the length of the normal | 729 | // the area of the polygon is the length of the normal |
730 | var area = VecUtils.vecMag(3, normal ); | 730 | var area = VecUtils.vecMag(3, normal ); |
731 | if (this.fpSign(area) != 0) | 731 | if (this.fpSign(area) != 0) |
732 | vec3.scale(normal, 1.0/area); | 732 | { |
733 | //vec3.scale(normal, 1.0/area); | ||
734 | normal = VecUtils.vecNormalize(3, normal, 1.0); | ||
735 | } | ||
733 | 736 | ||
734 | return normal; | 737 | return normal; |
735 | } | 738 | } |
diff --git a/js/helper-classes/RDGE/runtime/CanvasDataManager.js b/js/helper-classes/RDGE/runtime/CanvasDataManager.js index 4985fc9a..efbfe4db 100644 --- a/js/helper-classes/RDGE/runtime/CanvasDataManager.js +++ b/js/helper-classes/RDGE/runtime/CanvasDataManager.js | |||
@@ -12,7 +12,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
12 | /////////////////////////////////////////////////////////////////////// | 12 | /////////////////////////////////////////////////////////////////////// |
13 | function CanvasDataManager() | 13 | function CanvasDataManager() |
14 | { | 14 | { |
15 | this.loadGLData = function(root, valueArray) | 15 | this.loadGLData = function(root, valueArray, NinjaUtils) |
16 | { | 16 | { |
17 | var value = valueArray; | 17 | var value = valueArray; |
18 | var nWorlds = value.length; | 18 | var nWorlds = value.length; |
@@ -29,31 +29,7 @@ function CanvasDataManager() | |||
29 | var canvas = this.findCanvasWithID( id, root ); | 29 | var canvas = this.findCanvasWithID( id, root ); |
30 | if (canvas) | 30 | if (canvas) |
31 | { | 31 | { |
32 | var loadForAuthoring = true; | 32 | var rt = new GLRuntime( canvas, importStr ); |
33 | var index = importStr.indexOf( "scenedata: " ); | ||
34 | if (index >= 0) loadForAuthoring = false; | ||
35 | |||
36 | if (loadForAuthoring) | ||
37 | { | ||
38 | if (!canvas.elementModel) | ||
39 | { | ||
40 | NJUtils.makeElementModel(canvas, "Canvas", "shape", true); | ||
41 | } | ||
42 | |||
43 | if (canvas.elementModel) | ||
44 | { | ||
45 | if (canvas.elementModel.shapeModel.GLWorld) | ||
46 | canvas.elementModel.shapeModel.GLWorld.clearTree(); | ||
47 | |||
48 | var world = new GLWorld( canvas ); | ||
49 | canvas.elementModel.shapeModel.GLWorld = world; | ||
50 | world.import( importStr ); | ||
51 | } | ||
52 | } | ||
53 | else | ||
54 | { | ||
55 | var rt = new GLRuntime( canvas, importStr ); | ||
56 | } | ||
57 | } | 33 | } |
58 | } | 34 | } |
59 | } | 35 | } |
@@ -64,7 +40,7 @@ function CanvasDataManager() | |||
64 | { | 40 | { |
65 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) | 41 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) |
66 | { | 42 | { |
67 | var data = elt.elementModel.shapeModel.GLWorld.export(); | 43 | var data = elt.elementModel.shapeModel.GLWorld.export( true ); |
68 | dataArray.push( data ); | 44 | dataArray.push( data ); |
69 | } | 45 | } |
70 | 46 | ||
@@ -90,7 +66,8 @@ function CanvasDataManager() | |||
90 | for (var i=0; i<nKids; i++) | 66 | for (var i=0; i<nKids; i++) |
91 | { | 67 | { |
92 | var child = elt.children[i]; | 68 | var child = elt.children[i]; |
93 | this.findCanvasWithID( id, child ); | 69 | var foundElt = this.findCanvasWithID( id, child ); |
70 | if (foundElt) return foundElt; | ||
94 | } | 71 | } |
95 | } | 72 | } |
96 | } | 73 | } |
diff --git a/js/helper-classes/RDGE/runtime/GLRuntime.js b/js/helper-classes/RDGE/runtime/GLRuntime.js index 5c99be02..58cb4e33 100644 --- a/js/helper-classes/RDGE/runtime/GLRuntime.js +++ b/js/helper-classes/RDGE/runtime/GLRuntime.js | |||
@@ -16,6 +16,7 @@ function GLRuntime( canvas, importStr ) | |||
16 | // Instance variables | 16 | // Instance variables |
17 | /////////////////////////////////////////////////////////////////////// | 17 | /////////////////////////////////////////////////////////////////////// |
18 | this._canvas = canvas; | 18 | this._canvas = canvas; |
19 | this._context = null; | ||
19 | this._importStr = importStr; | 20 | this._importStr = importStr; |
20 | 21 | ||
21 | this.renderer = null; | 22 | this.renderer = null; |
@@ -25,15 +26,40 @@ function GLRuntime( canvas, importStr ) | |||
25 | this._rootNode = null; | 26 | this._rootNode = null; |
26 | 27 | ||
27 | this._firstRender = true; | 28 | this._firstRender = true; |
29 | this._initialized = false; | ||
30 | |||
31 | this._useWebGL = false; | ||
32 | |||
33 | // view parameters | ||
34 | this._fov = 45.0; | ||
35 | this._zNear = 0.1; | ||
36 | this._zFar = 100.0; | ||
37 | this._viewDist = 5.0; | ||
38 | |||
39 | this._aspect = canvas.width/canvas.height; | ||
40 | |||
41 | this._geomRoot; | ||
42 | |||
43 | // all "live" materials | ||
44 | this._materials = []; | ||
28 | 45 | ||
29 | /////////////////////////////////////////////////////////////////////// | 46 | /////////////////////////////////////////////////////////////////////// |
30 | // initialization code | 47 | // accessors |
31 | /////////////////////////////////////////////////////////////////////// | 48 | /////////////////////////////////////////////////////////////////////// |
32 | var id = canvas.getAttribute( "data-RDGE-id" ); | 49 | this.getZNear = function() { return this._zNear; } |
33 | canvas.rdgeid = id; | 50 | this.getZFar = function() { return this._zFar; } |
34 | g_Engine.registerCanvas(canvas, this); | 51 | this.getFOV = function() { return this._fov; } |
35 | RDGEStart( canvas ); | 52 | this.getAspect = function() { return this._aspect; } |
53 | this.getViewDistance = function() { return this._viewDist; } | ||
54 | |||
55 | this.get2DContext = function() { return this._context; } | ||
36 | 56 | ||
57 | this.getViewportWidth = function() { return this._canvas.width; } | ||
58 | this.getViewportHeight = function() { return this._canvas.height; } | ||
59 | |||
60 | /////////////////////////////////////////////////////////////////////// | ||
61 | // accessors | ||
62 | /////////////////////////////////////////////////////////////////////// | ||
37 | this.loadScene = function() | 63 | this.loadScene = function() |
38 | { | 64 | { |
39 | // parse the data | 65 | // parse the data |
@@ -41,6 +67,8 @@ function GLRuntime( canvas, importStr ) | |||
41 | var index = importStr.indexOf( "scenedata: " ); | 67 | var index = importStr.indexOf( "scenedata: " ); |
42 | if (index >= 0) | 68 | if (index >= 0) |
43 | { | 69 | { |
70 |