diff options
author | Nivesh Rajbhandari | 2012-03-27 09:32:53 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-03-27 09:32:53 -0700 |
commit | 406bbfc63f8ed42d7da105dbd068a49ff8fb5f09 (patch) | |
tree | 3a8b45f4802f002269ff1bcf596f94cee4679a07 /js/lib | |
parent | bda9f8f5829c943486f8850e68c991e83f8fb8c8 (diff) | |
parent | 309dde5a8c4599cef6a1052c1ff9ee1ad8ec5858 (diff) | |
download | ninja-406bbfc63f8ed42d7da105dbd068a49ff8fb5f09.tar.gz |
Merge branch 'refs/heads/ninja-internal' into WebGLMaterials
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/lib')
-rwxr-xr-x | js/lib/NJUtils.js | 32 | ||||
-rwxr-xr-x | js/lib/drawing/world.js | 162 | ||||
-rwxr-xr-x | js/lib/geom/circle.js | 54 | ||||
-rwxr-xr-x | js/lib/geom/geom-obj.js | 154 | ||||
-rwxr-xr-x | js/lib/geom/line.js | 44 | ||||
-rwxr-xr-x | js/lib/geom/rectangle.js | 67 | ||||
-rwxr-xr-x | js/lib/rdge/materials/bump-metal-material.js | 40 | ||||
-rw-r--r-- | js/lib/rdge/materials/cloud-material.js | 300 | ||||
-rwxr-xr-x | js/lib/rdge/materials/flat-material.js | 21 | ||||
-rw-r--r-- | js/lib/rdge/materials/julia-material.js | 6 | ||||
-rwxr-xr-x | js/lib/rdge/materials/linear-gradient-material.js | 53 | ||||
-rw-r--r-- | js/lib/rdge/materials/mandel-material.js | 6 | ||||
-rw-r--r-- | js/lib/rdge/materials/plasma-material.js | 18 | ||||
-rw-r--r-- | js/lib/rdge/materials/pulse-material.js | 44 | ||||
-rw-r--r-- | js/lib/rdge/materials/radial-blur-material.js | 57 | ||||
-rwxr-xr-x | js/lib/rdge/materials/radial-gradient-material.js | 54 | ||||
-rw-r--r-- | js/lib/rdge/materials/taper-material.js | 27 | ||||
-rw-r--r-- | js/lib/rdge/materials/twist-vert-material.js | 28 | ||||
-rwxr-xr-x | js/lib/rdge/materials/uber-material.js | 180 | ||||
-rw-r--r-- | js/lib/rdge/materials/water-material.js | 103 |
20 files changed, 1352 insertions, 98 deletions
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index cb877591..0457120b 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js | |||
@@ -99,15 +99,45 @@ exports.NJUtils = Object.create(Object.prototype, { | |||
99 | p3d.init(el, true); | 99 | p3d.init(el, true); |
100 | } | 100 | } |
101 | var shapeProps = null; | 101 | var shapeProps = null; |
102 | var pi = controller + "Pi"; | ||
103 | |||
102 | if(isShape) { | 104 | if(isShape) { |
103 | shapeProps = Montage.create(ShapeModel); | 105 | shapeProps = Montage.create(ShapeModel); |
104 | } | 106 | } |
105 | 107 | ||
108 | if(el.controller) { | ||
109 | |||
110 | var componentInfo = Montage.getInfoForObject(el.controller); | ||
111 | var componentName = componentInfo.objectName.toLowerCase(); | ||
112 | |||
113 | controller = "component"; | ||
114 | isShape = false; | ||
115 | |||
116 | switch(componentName) { | ||
117 | case "feedreader": | ||
118 | selection = "Feed Reader"; | ||
119 | pi = "FeedReaderPi"; | ||
120 | break; | ||
121 | case "map": | ||
122 | selection = "Map"; | ||
123 | pi = "MapPi"; | ||
124 | break; | ||
125 | case "youtubechannel": | ||
126 | selection = "Youtube Channel"; | ||
127 | pi = "YoutubeChannelPi"; | ||
128 | break; | ||
129 | case "picasacarousel": | ||
130 | selection = "Picasa Carousel"; | ||
131 | pi = "PicasaCarouselPi"; | ||
132 | break; | ||
133 | } | ||
134 | } | ||
135 | |||
106 | el.elementModel = Montage.create(ElementModel, { | 136 | el.elementModel = Montage.create(ElementModel, { |
107 | type: { value: el.nodeName}, | 137 | type: { value: el.nodeName}, |
108 | selection: { value: selection}, | 138 | selection: { value: selection}, |
109 | controller: { value: ControllerFactory.getController(controller)}, | 139 | controller: { value: ControllerFactory.getController(controller)}, |
110 | pi: { value: controller + "Pi"}, | 140 | pi: { value: pi}, |
111 | props3D: { value: p3d}, | 141 | props3D: { value: p3d}, |
112 | shapeModel: { value: shapeProps} | 142 | shapeModel: { value: shapeProps} |
113 | }); | 143 | }); |
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index c1ee0cd0..781695b6 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js | |||
@@ -117,6 +117,8 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { | |||
117 | 117 | ||
118 | this.getRenderer = function() { return this.renderer; }; | 118 | this.getRenderer = function() { return this.renderer; }; |
119 | 119 | ||
120 | // Flag to play/pause animation at authortime | ||
121 | this._previewAnimation = true; | ||
120 | //////////////////////////////////////////////////////////////////////////////////// | 122 | //////////////////////////////////////////////////////////////////////////////////// |
121 | // RDGE | 123 | // RDGE |
122 | // local variables | 124 | // local variables |
@@ -236,7 +238,7 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { | |||
236 | if (this._canvas.task) { | 238 | if (this._canvas.task) { |
237 | this._firstRender = false; | 239 | this._firstRender = false; |
238 | 240 | ||
239 | if (!this.hasAnimatedMaterials()) { | 241 | if (!this.hasAnimatedMaterials() || !this._previewAnimation) { |
240 | this._canvas.task.stop(); | 242 | this._canvas.task.stop(); |
241 | //this._renderCount = 10; | 243 | //this._renderCount = 10; |
242 | } | 244 | } |
@@ -363,6 +365,7 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { | |||
363 | if (this._useWebGL) { | 365 | if (this._useWebGL) { |
364 | rdgeStarted = true; | 366 | rdgeStarted = true; |
365 | this._canvas.rdgeid = this._canvas.getAttribute( "data-RDGE-id" ); | 367 | this._canvas.rdgeid = this._canvas.getAttribute( "data-RDGE-id" ); |
368 | g_Engine.unregisterCanvas( this._canvas ) | ||
366 | g_Engine.registerCanvas(this._canvas, this); | 369 | g_Engine.registerCanvas(this._canvas, this); |
367 | RDGEStart( this._canvas ); | 370 | RDGEStart( this._canvas ); |
368 | this._canvas.task.stop() | 371 | this._canvas.task.stop() |
@@ -729,6 +732,74 @@ World.prototype.getShapeFromPoint = function( offsetX, offsetY ) { | |||
729 | } | 732 | } |
730 | }; | 733 | }; |
731 | 734 | ||
735 | |||
736 | |||
737 | World.prototype.exportJSON = function() | ||
738 | { | ||
739 | // world properties | ||
740 | var worldObj = | ||
741 | { | ||
742 | 'version' : 1.1, | ||
743 | 'id' : this.getCanvas().getAttribute( "data-RDGE-id" ), | ||
744 | 'fov' : this._fov, | ||
745 | 'zNear' : this._zNear, | ||
746 | 'zFar' : this._zFar, | ||
747 | 'viewDist' : this._viewDist, | ||
748 | 'webGL' : this._useWebGL | ||
749 | }; | ||
750 | |||
751 | // RDGE scenegraph | ||
752 | if (this._useWebGL) | ||
753 | worldObj.scenedata = this.myScene.exportJSON(); | ||
754 | |||
755 | // object data | ||
756 | var strArray = []; | ||
757 | this.exportObjectsJSON( this._geomRoot, worldObj ); | ||
758 | |||
759 | // You would think that the RDGE export function | ||
760 | // would not be destructive of the data. You would be wrong... | ||
761 | // We need to rebuild everything | ||
762 | if (this._useWebGL) | ||
763 | { | ||
764 | var root = this._rootNode; | ||
765 | root.children = new Array(); | ||
766 | if (worldObj.children && (worldObj.children.length === 1)) | ||
767 | { | ||
768 | this.init(); | ||
769 | this._geomRoot = undefined; | ||
770 | this.importObjectsJSON( worldObj.children[0] ); | ||
771 | } | ||
772 | } | ||
773 | |||
774 | // convert the object to a string | ||
775 | var jStr = JSON.stringify( worldObj ); | ||
776 | |||
777 | // prepend some version information to the string. | ||
778 | // this string is also used to differentiate between JSON | ||
779 | // and pre-JSON versions of fileIO. | ||
780 | // the ending ';' in the version string is necessary | ||
781 | jStr = "v1.0;" + jStr; | ||
782 | |||
783 | return jStr; | ||
784 | } | ||
785 | |||
786 | World.prototype.exportObjectsJSON = function( obj, parentObj ) | ||
787 | { | ||
788 | if (!obj) return; | ||
789 | |||
790 | var jObj = obj.exportJSON(); | ||
791 | if (!parentObj.children) parentObj.children = []; | ||
792 | parentObj.children.push( jObj ); | ||
793 | |||
794 | if (obj.getChild()) { | ||
795 | this.exportObjectsJSON( obj.getChild (), jObj ); | ||
796 | } | ||
797 | |||
798 | if (obj.getNext()) | ||
799 | this.exportObjectsJSON( obj.getNext(), parentObj ); | ||
800 | } | ||
801 | |||
802 | /* | ||
732 | World.prototype.export = function() | 803 | World.prototype.export = function() |
733 | { | 804 | { |
734 | var exportStr = "GLWorld 1.0\n"; | 805 | var exportStr = "GLWorld 1.0\n"; |
@@ -791,6 +862,7 @@ World.prototype.exportObjects = function( obj ) { | |||
791 | 862 | ||
792 | return rtnStr; | 863 | return rtnStr; |
793 | }; | 864 | }; |
865 | */ | ||
794 | 866 | ||
795 | World.prototype.findTransformNodeByMaterial = function( materialNode, trNode ) { | 867 | World.prototype.findTransformNodeByMaterial = function( materialNode, trNode ) { |
796 | //if (trNode == null) trNode = this._ctrNode; | 868 | //if (trNode == null) trNode = this._ctrNode; |
@@ -810,17 +882,93 @@ World.prototype.findTransformNodeByMaterial = function( materialNode, trNode ) | |||
810 | return rtnNode; | 882 | return rtnNode; |
811 | }; | 883 | }; |
812 | 884 | ||
813 | World.prototype.import = function( importStr, fromToggle ) { | 885 | World.prototype.importJSON = function( jObj ) |
886 | { | ||
887 | if (jObj.webGL) | ||
888 | { | ||
889 | // start RDGE | ||
890 | rdgeStarted = true; | ||
891 | var id = this._canvas.getAttribute( "data-RDGE-id" ); | ||
892 | this._canvas.rdgeid = id; | ||
893 | g_Engine.registerCanvas(this._canvas, this); | ||
894 | RDGEStart( this._canvas ); | ||
895 | this._canvas.task.stop() | ||
896 | } | ||
897 | |||
898 | // import the objects | ||
899 | // there should be exactly one child of the parent object | ||
900 | if (jObj.children && (jObj.children.length === 1)) | ||
901 | this.importObjectsJSON( jObj.children[0] ); | ||
902 | else | ||
903 | throw new Error ("unrecoverable canvas import error - inconsistent root object: " + jObj.children ); | ||
904 | |||
905 | if (!this._useWebGL) | ||