aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md18
-rw-r--r--assets/shaders/radialBlur.frag.glsl75
-rwxr-xr-xjs/helper-classes/3D/StageLine.js187
-rwxr-xr-xjs/helper-classes/3D/math-utils.js9
-rwxr-xr-xjs/lib/rdge/materials/material.js2
-rw-r--r--js/lib/rdge/materials/taper-material.js2
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js2
7 files changed, 254 insertions, 41 deletions
diff --git a/README.md b/README.md
index ada4ce7e..4609102b 100644
--- a/README.md
+++ b/README.md
@@ -21,17 +21,17 @@ If you're already familiar with using Git, GitHub, you can clone master branch o
215. Load unpacked extension... and browse to your cloned master branch. 215. Load unpacked extension... and browse to your cloned master branch.
226. Copy Ninja app ID from the Extensions page under the app name. 226. Copy Ninja app ID from the Extensions page under the app name.
237. On Windows: 237. On Windows:
24 Click Start menu icon and type regedit 24 Click Start menu icon and type regedit.
25 Browse to HKEY_CURRENT_USER/Software/Motorola Mobility/Ninja Local Cloud/Options 25 Browse to HKEY_CURRENT_USER/Software/Motorola Mobility/Ninja Local Cloud/Options.
26 Right click and select New > String value 26 Right click and select New > String value.
27 Type 'Local Ninja Origin' no quotes 27 Type 'Local Ninja Origin' no quotes.
28 Double click on Local Ninja Origin and paste in the ID copied in step 6 in the Value data field. Close Registry Editor. 28 Double click on Local Ninja Origin and paste in the Ninja app ID copied in step 6 from the Chrome extensions page in the Value data field. Close Registry Editor.
298. On Mac: 298. On Mac:
30 Launch Finder. 30 Launch Finder.
31 Double click on /Library/Preferences/com.MotorolaMobility.Ninja-Local-Cloud.plist 31 Double click on /Users/\<user\>/Library/Preferences/com.MotorolaMobility.Ninja-Local-Cloud.plist.
32 Click on Add Child Type 'Local Ninja Origin' no quotes 32 Click on Add Child Type 'Local Ninja Origin' no quotes.
33 For value, paste in the ID copied in step 6. 33 For value, paste in the Ninja app ID copied in step 6 from the Chrome extensions page.
34 Save (File > Save or Cmd S) Close Property List Editor 34 Save (File > Save or Cmd S) Close Property List Editor.
359. Quit Ninja Local Cloud 359. Quit Ninja Local Cloud
3610. Launch Ninja Local Cloud 3610. Launch Ninja Local Cloud
3711. Click Copy button to copy the Ninja Local Cloud URL. 3711. Click Copy button to copy the Ninja Local Cloud URL.
diff --git a/assets/shaders/radialBlur.frag.glsl b/assets/shaders/radialBlur.frag.glsl
new file mode 100644
index 00000000..953e6f07
--- /dev/null
+++ b/assets/shaders/radialBlur.frag.glsl
@@ -0,0 +1,75 @@
1
2/* <copyright>
3Copyright (c) 2012, Motorola Mobility LLC.
4All Rights Reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8
9* Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11
12* Redistributions in binary form must reproduce the above copyright notice,
13 this list of conditions and the following disclaimer in the documentation
14 and/or other materials provided with the distribution.
15
16* Neither the name of Motorola Mobility LLC nor the names of its
17 contributors may be used to endorse or promote products derived from this
18 software without specific prior written permission.
19
20THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30POSSIBILITY OF SUCH DAMAGE.
31</copyright> */
32
33#ifdef GL_ES
34precision highp float;
35#endif
36
37uniform vec2 u_resolution;
38uniform float u_time;
39uniform float u_speed;
40uniform sampler2D u_tex0;
41
42
43void main(void)
44{
45 vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy;
46 vec2 s = p;
47
48 float time = u_time * u_speed;
49 float c1 = 1.1*time, c2 = 1.2*time, c3 = 0.6+1.1*time;
50 float sc3 = sin(c3), st = sin(time);
51
52 const float iterCount = 40.0;
53 const int iIterCount = int( iterCount );
54
55 vec3 sum = vec3(0.0);
56 vec2 delta = -p/iterCount;
57 vec2 uv;
58 for( int i=0; i<iIterCount; i++ )
59 {
60 vec2 q = vec2( sin(c1 + s.x), sin(c2 + s.y) );
61 float a = atan(q.y,q.x);
62 float rsq = abs(dot(q,q)) + 1.0;
63 uv.x = st + s.x*rsq;
64 uv.y = sc3 + s.y*rsq;
65 vec3 res = texture2D(u_tex0, uv*.5).xyz;
66
67 res = smoothstep(0.1,1.0,res*res);
68 sum += res;
69 s += delta;
70 }
71 sum /= iterCount;
72 float r = 1.5/(1.0+dot(p,p));
73
74 gl_FragColor = vec4( sum*r, 1.0);
75} \ No newline at end of file
diff --git a/js/helper-classes/3D/StageLine.js b/js/helper-classes/3D/StageLine.js
index 5aaa325a..f9abc5ce 100755
--- a/js/helper-classes/3D/StageLine.js
+++ b/js/helper-classes/3D/StageLine.js
@@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
34// The line class represents a line intersected with all planes on the scene 34// The line class represents a line intersected with all planes on the scene
35/////////////////////////////////////////////////////////////////////// 35///////////////////////////////////////////////////////////////////////
36var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; 36var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils;
37var viewUtils = require( "js/helper-classes/3D/view-utils").ViewUtils;
37var LinePlaneIntersectRec = require("js/helper-classes/3D/LinePlaneIntersectRec").LinePlaneIntersectRec; 38var LinePlaneIntersectRec = require("js/helper-classes/3D/LinePlaneIntersectRec").LinePlaneIntersectRec;
38 39
39var StageLine = exports.StageLine = Object.create(Object.prototype, { 40var StageLine = exports.StageLine = Object.create(Object.prototype, {
@@ -96,7 +97,7 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, {
96 if (minPt[2] > plane.getZMax()) return; 97 if (minPt[2] > plane.getZMax()) return;
97 98
98 // get the boundary points for the plane 99 // get the boundary points for the plane
99 var boundaryPts = plane.getBoundaryPoints(); 100 var boundaryPts = plane.getBoundaryPoints().slice();
100 101
101 // get the points and direction vector for the current line 102 // get the points and direction vector for the current line
102 var pt0 = this.getPoint0(), pt1 = this.getPoint1(); 103 var pt0 = this.getPoint0(), pt1 = this.getPoint1();
@@ -115,7 +116,8 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, {
115 116
116 // see if the intersection point is contained in the bounds 117 // see if the intersection point is contained in the bounds
117 //var contains = this.boundaryContainsPoint( boundaryPts, plane.isBackFacing(), pt ); 118 //var contains = this.boundaryContainsPoint( boundaryPts, plane.isBackFacing(), pt );
118 var contains = MathUtils.boundaryContainsPoint( boundaryPts, pt, plane.isBackFacing() ); 119 var onEdge = [];
120 var contains = MathUtils.boundaryContainsPoint( boundaryPts, pt, plane.isBackFacing(), onEdge );
119 if (contains == MathUtils.INSIDE) 121 if (contains == MathUtils.INSIDE)
120 { 122 {
121 // add the intersection 123 // add the intersection
@@ -130,23 +132,40 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, {
130 { 132 {
131 if (MathUtils.fpCmp(t,1.0) < 0) 133 if (MathUtils.fpCmp(t,1.0) < 0)
132 { 134 {
133 // take the dot product between the line and the normal to the plane 135 // determine if the intersection is on a front side (no intersection) of the polygons
134 // to determine the change in visibility 136 //var ctr = [ 0.5*(boundaryPts[0][0] + boundaryPts[2][0]), 0.5*(boundaryPts[0][1] + boundaryPts[2][1]), 0.5*(boundaryPts[0][2] + boundaryPts[2][2]) ];
135 var vec = vecUtils.vecSubtract( 3, pt1, pt0 ); 137 //var vec = vecUtils.vecSubtract(3, pt, ctr );
136 var dot = vecUtils.vecDot( 3, vec, plane.getPlaneEq() ); 138 if (this.edgeGoesBehindPlane( plane, boundaryPts, onEdge[0], onEdge[1], pt0, pt1 ))
137 var sign = MathUtils.fpSign( dot );
138 if (sign == 0)
139 throw new Error( "coplanar intersection being treated as not coplanar" );
140 if (!plane.isBackFacing())
141 { 139 {
142 if (sign < 0) 140 this.addIntersection( plane, t, 1 );
143 this.addIntersection( plane, t, 1 );
144 } 141 }
145 else 142 else if (this.edgeGoesBehindPlane( plane, boundaryPts, onEdge[0], onEdge[1], pt1, pt0 ))
146 { 143 {
147 if (sign > 0) 144 this.addIntersection( plane, t, -1 );
148 this.addIntersection( plane, t, -1 ); 145 }
146
147 /*
148 if ( !this.edgeIsFrontFacing(boundaryPts, planeEq, plane.isBackFacing(), onEdge[0], onEdge[1]) )
149 {
150 // take the dot product between the line and the normal to the plane
151 // to determine the change in visibility
152 var vec = vecUtils.vecSubtract( 3, pt1, pt0 );
153 var dot = vecUtils.vecDot( 3, vec, planeEq );
154 var sign = MathUtils.fpSign( dot );
155 if (sign == 0)
156 throw new Error( "coplanar intersection being treated as not coplanar" );
157 if (!plane.isBackFacing())
158 {
159 if (sign < 0)
160 this.addIntersection( plane, t, 1 );
161 }
162 else
163 {
164 if (sign > 0)
165 this.addIntersection( plane, t, -1 );
166 }
149 } 167 }
168 */
150 } 169 }
151 } 170 }
152 } 171 }
@@ -208,18 +227,122 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, {
208 } 227 }
209 }, 228 },
210 229
230 edgeGoesBehindPlane:
231 {
232 value: function( plane, boundaryPts, iEdge, t, lPt0, lPt1 )
233 {
234 var rtnVal = false;
235
236 if ( MathUtils.fpCmp(t,1.0) == 0 )
237 {
238 iEdge = (iEdge + 1) % 4;
239 t = 0.0;
240 }
241
242 // boundary points (line points: lPt0, lPt1)
243 var bPt0, bPt1, bPt2, bVec, bVec0, bVec1, lVec, d;
244