diff options
author | hwc487 | 2012-05-22 16:40:42 -0700 |
---|---|---|
committer | hwc487 | 2012-05-22 16:40:42 -0700 |
commit | 08851078e89e9d4cb8fa341fa697a91be8de8ab9 (patch) | |
tree | fee8c0d38c1c540ef00c33e728346d765a4e699c | |
parent | 50ede4afa801f53caff7939dad0408f9a0a8b744 (diff) | |
parent | 862ee363584dfba4bdd9abacbc3a3244c7ec66b5 (diff) | |
download | ninja-08851078e89e9d4cb8fa341fa697a91be8de8ab9.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Textures
Conflicts:
js/lib/geom/shape-primitive.js
js/lib/rdge/materials/linear-gradient-material.js
-rw-r--r-- | assets/canvas-runtime.js | 32 | ||||
-rwxr-xr-x | assets/shaders/linearGradient.vert.glsl | 5 | ||||
-rw-r--r-- | assets/shaders/radialGradient.vert.glsl | 4 | ||||
-rwxr-xr-x | js/document/html-document.js | 4 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 146 | ||||
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 13 | ||||
-rw-r--r-- | js/io/system/ninjalibrary.json | 2 | ||||
-rwxr-xr-x | js/lib/geom/circle.js | 124 | ||||
-rwxr-xr-x | js/lib/geom/rectangle.js | 190 | ||||
-rw-r--r-- | js/lib/geom/shape-primitive.js | 27 | ||||
-rwxr-xr-x | js/lib/rdge/materials/linear-gradient-material.js | 46 | ||||
-rwxr-xr-x | js/lib/rdge/materials/material.js | 4 | ||||
-rwxr-xr-x | js/lib/rdge/materials/radial-gradient-material.js | 64 |
13 files changed, 367 insertions, 294 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index eeafaab6..67d53963 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js | |||
@@ -878,11 +878,12 @@ NinjaCvsRt.RuntimeRectangle = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
878 | inset = Math.ceil( lw ) - 0.5; | 878 | inset = Math.ceil( lw ) - 0.5; |
879 | 879 | ||
880 | if(this._fillColor.gradientMode) { | 880 | if(this._fillColor.gradientMode) { |
881 | if(this._fillColor.gradientMode === "radial") { | 881 | if(this._fillColor.gradientMode === "radial") { |
882 | gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(w, h)/2); | 882 | var ww = w - 2*lw, hh = h - 2*lw; |
883 | } else { | 883 | gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(ww, hh)/2); |
884 | gradient = ctx.createLinearGradient(inset/2, h/2, w-inset, h/2); | 884 | } else { |
885 | } | 885 | gradient = ctx.createLinearGradient(inset, h/2, w-inset, h/2); |
886 | } | ||
886 | colors = this._fillColor.color; | 887 | colors = this._fillColor.color; |
887 | 888 | ||
888 | len = colors.length; | 889 | len = colors.length; |
@@ -912,11 +913,10 @@ NinjaCvsRt.RuntimeRectangle = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
912 | inset = Math.ceil( 0.5*lw ) - 0.5; | 913 | inset = Math.ceil( 0.5*lw ) - 0.5; |
913 | 914 | ||
914 | if(this._strokeColor.gradientMode) { | 915 | if(this._strokeColor.gradientMode) { |
915 | if(this._strokeColor.gradientMode === "radial") { | 916 | if(this._strokeColor.gradientMode === "radial") |
916 | gradient = ctx.createRadialGradient(w/2, h/2, Math.min(h, w)/2-inset, w/2, h/2, Math.max(h, w)/2); | 917 | gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(h, w)/2); |
917 | } else { | 918 | else |
918 | gradient = ctx.createLinearGradient(0, h/2, w, h/2); | 919 | gradient = ctx.createLinearGradient(0, h/2, w, h/2); |
919 | } | ||
920 | colors = this._strokeColor.color; | 920 | colors = this._strokeColor.color; |
921 | 921 | ||
922 | len = colors.length; | 922 | len = colors.length; |
@@ -1116,9 +1116,9 @@ NinjaCvsRt.RuntimeOval = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
1116 | if(this._fillColor.gradientMode) { | 1116 | if(this._fillColor.gradientMode) { |
1117 | if(this._fillColor.gradientMode === "radial") { | 1117 | if(this._fillColor.gradientMode === "radial") { |
1118 | gradient = ctx.createRadialGradient(xCtr, yCtr, 0, | 1118 | gradient = ctx.createRadialGradient(xCtr, yCtr, 0, |
1119 | xCtr, yCtr, Math.max(this._width, this._height)/2); | 1119 | xCtr, yCtr, Math.max(this._width, this._height)/2 - lineWidth); |
1120 | } else { | 1120 | } else { |
1121 | gradient = ctx.createLinearGradient(lineWidth/2, this._height/2, this._width-lineWidth, this._height/2); | 1121 | gradient = ctx.createLinearGradient(lineWidth, this._height/2, this._width-lineWidth, this._height/2); |
1122 | } | 1122 | } |
1123 | colors = this._fillColor.color; | 1123 | colors = this._fillColor.color; |
1124 | 1124 | ||
@@ -1194,7 +1194,7 @@ NinjaCvsRt.RuntimeOval = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
1194 | if (this._strokeColor) { | 1194 | if (this._strokeColor) { |
1195 | if(this._strokeColor.gradientMode) { | 1195 | if(this._strokeColor.gradientMode) { |
1196 | if(this._strokeColor.gradientMode === "radial") { | 1196 | if(this._strokeColor.gradientMode === "radial") { |
1197 | gradient = ctx.createRadialGradient(xCtr, yCtr, Math.min(xScale, yScale), | 1197 | gradient = ctx.createRadialGradient(xCtr, yCtr, 0, |
1198 | xCtr, yCtr, 0.5*Math.max(this._height, this._width)); | 1198 | xCtr, yCtr, 0.5*Math.max(this._height, this._width)); |
1199 | } else { | 1199 | } else { |
1200 | gradient = ctx.createLinearGradient(0, this._height/2, this._width, this._height/2); | 1200 | gradient = ctx.createLinearGradient(0, this._height/2, this._width, this._height/2); |
@@ -1456,6 +1456,8 @@ NinjaCvsRt.RuntimeRadialGradientMaterial = Object.create(NinjaCvsRt.RuntimeMater | |||
1456 | _colorStop3: { value: 0.6, writable: true }, | 1456 | _colorStop3: { value: 0.6, writable: true }, |
1457 | _colorStop4: { value: 1.0, writable: true }, | 1457 | _colorStop4: { value: 1.0, writable: true }, |
1458 | 1458 | ||
1459 | _textureTransform: { value: [1,0,0, 0,1,0, 0,0,1], writable: true }, | ||
1460 | |||
1459 | init: { | 1461 | init: { |
1460 | value: function(world) { | 1462 | value: function(world) { |
1461 | var material = this._materialNode; | 1463 | var material = this._materialNode; |
@@ -1477,6 +1479,8 @@ NinjaCvsRt.RuntimeRadialGradientMaterial = Object.create(NinjaCvsRt.RuntimeMater | |||
1477 | this._shader["default"].u_colorStop3.set( [this._colorStop3] ); | 1479 | this._shader["default"].u_colorStop3.set( [this._colorStop3] ); |
1478 | this._shader["default"].u_colorStop4.set( [this._colorStop4] ); | 1480 | this._shader["default"].u_colorStop4.set( [this._colorStop4] ); |
1479 | 1481 | ||
1482 | this._shader["default"].u_texTransform.set( this._textureTransform ); | ||
1483 | |||
1480 | if (this._angle !== undefined) | 1484 | if (this._angle !== undefined) |
1481 | this._shader["default"].u_cos_sin_angle.set([Math.cos(this._angle), Math.sin(this._angle)]); | 1485 | this._shader["default"].u_cos_sin_angle.set([Math.cos(this._angle), Math.sin(this._angle)]); |
1482 | } | 1486 | } |
@@ -1496,6 +1500,8 @@ NinjaCvsRt.RuntimeRadialGradientMaterial = Object.create(NinjaCvsRt.RuntimeMater | |||
1496 | this._colorStop3 = jObj.colorStop3; | 1500 | this._colorStop3 = jObj.colorStop3; |
1497 | this._colorStop4 = jObj.colorStop4; | 1501 | this._colorStop4 = jObj.colorStop4; |
1498 | 1502 | ||
1503 | this._textureTransform = jObj.textureTransform; | ||
1504 | |||
1499 | if (this._angle !== undefined) | 1505 | if (this._angle !== undefined) |
1500 | this._angle = jObj.angle; | 1506 | this._angle = jObj.angle; |
1501 | } | 1507 | } |
diff --git a/assets/shaders/linearGradient.vert.glsl b/assets/shaders/linearGradient.vert.glsl index aac9cbee..f0800812 100755 --- a/assets/shaders/linearGradient.vert.glsl +++ b/assets/shaders/linearGradient.vert.glsl | |||
@@ -37,6 +37,7 @@ uniform float u_colorStop3; | |||
37 | uniform float u_colorStop4; | 37 | uniform float u_colorStop4; |
38 | uniform vec2 u_cos_sin_angle; | 38 | uniform vec2 u_cos_sin_angle; |
39 | //uniform int u_colorCount; // currently using 4 | 39 | //uniform int u_colorCount; // currently using 4 |
40 | uniform mat3 u_texTransform; | ||
40 | 41 | ||
41 | varying vec2 v_uv; | 42 | varying vec2 v_uv; |
42 | 43 | ||
@@ -44,5 +45,7 @@ varying vec2 v_uv; | |||
44 | void main(void) | 45 | void main(void) |
45 | { | 46 | { |
46 | gl_Position = u_projMatrix * u_mvMatrix * vec4(vert,1.0) ; | 47 | gl_Position = u_projMatrix * u_mvMatrix * vec4(vert,1.0) ; |
47 | v_uv = texcoord; | 48 | //v_uv = texcoord; |
49 | vec3 tmp = u_texTransform * vec3( texcoord, 1.0); | ||
50 | v_uv = tmp.xy; | ||
48 | } | 51 | } |
diff --git a/assets/shaders/radialGradient.vert.glsl b/assets/shaders/radialGradient.vert.glsl index c3e1b50a..7994ac12 100644 --- a/assets/shaders/radialGradient.vert.glsl +++ b/assets/shaders/radialGradient.vert.glsl | |||
@@ -18,11 +18,13 @@ attribute vec2 texcoord; | |||
18 | // matrix uniforms | 18 | // matrix uniforms |
19 | uniform mat4 u_mvMatrix; | 19 | uniform mat4 u_mvMatrix; |
20 | uniform mat4 u_projMatrix; | 20 | uniform mat4 u_projMatrix; |
21 | uniform mat3 u_texTransform; | ||
21 | 22 | ||
22 | varying vec2 v_uv; | 23 | varying vec2 v_uv; |
23 | 24 | ||
24 | void main(void) | 25 | void main(void) |
25 | { | 26 | { |
26 | gl_Position = u_projMatrix * u_mvMatrix * vec4(vert,1.0) ; | 27 | gl_Position = u_projMatrix * u_mvMatrix * vec4(vert,1.0) ; |
27 | v_uv = texcoord; | 28 | vec3 tmp = u_texTransform * vec3( texcoord, 1.0); |
29 | v_uv = tmp.xy; | ||
28 | } \ No newline at end of file | 30 | } \ No newline at end of file |
diff --git a/js/document/html-document.js b/js/document/html-document.js index 9d083dd8..61223499 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -209,8 +209,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
209 | { | 209 | { |
210 | /* | 210 | /* |
211 | // Use this code to test the runtime version of WebGL | 211 | // Use this code to test the runtime version of WebGL |
212 | var cdm = new NinjaCvsRt.CanvasDataManager(); | 212 | var cvsDataMngr = Object.create(NinjaCvsRt.CanvasDataManager, {}); |
213 | cdm.loadGLData(elt, value, null ); | 213 | cvsDataMngr.loadGLData(elt, value); |
214 | */ | 214 | */ |
215 | 215 | ||
216 | // /* | 216 | // /* |
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 6766ac7f..97901d50 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js | |||
@@ -230,64 +230,22 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
230 | else | 230 | else |
231 | parentPt = [xScreen, yScreen, 0.0]; | 231 | parentPt = [xScreen, yScreen, 0.0]; |
232 | 232 | ||
233 | var eyePt = []; | 233 | if (!snap3D && this._hasDragPlane) |
234 | var vec = viewUtils.parentToChildVec(parentPt, stage, eyePt); | 234 | this.activateDragPlane(); |
235 | if (vec) | 235 | |
236 | { | 236 | var hitRec = this.snapToStage( parentPt, quadPt ); |
237 | // activate the drag working plane | 237 | |
238 | if (!snap3D && this.hasDragPlane()) | 238 | // try snapping to the 3D grid, or to the stage boundaries if the grid is not displayed |
239 | this.activateDragPlane(); | 239 | if (this.gridSnapEnabled()) |
240 | 240 | this.snapToGrid( hitRec ); | |
241 | // project to the working plane | 241 | |
242 | var currentWorkingPlane = workingPlane.slice(0); | 242 | // save the hit record |
243 | var wp = currentWorkingPlane.slice(0); | 243 | hitRecArray.push( hitRec ); |
244 | var mat = viewUtils.getMatrixFromElement(stage); | 244 | |
245 | wp = MathUtils.transformPlane(wp, mat); | 245 | // restore the original working plane |
246 | var projPt = MathUtils.vecIntersectPlane(eyePt, vec, wp); | 246 | if (!snap3D && this.hasDragPlane()) |
247 | if (projPt) | 247 | this.deactivateDragPlane(); |
248 | { | 248 | |
249 | // the local point gets stored in the coordinate space of the plane | ||
250 | var wpMat = drawUtils.getPlaneToWorldMatrix(currentWorkingPlane, MathUtils.getPointOnPlane(currentWorkingPlane)); | ||
251 | projPt[3] = 1.0; | ||
252 | //var planeToViewMat = mat.multiply(wpMat); | ||
253 | var planeToViewMat = glmat4.multiply(mat, wpMat, []); | ||
254 | //var viewToPlaneMat = planeToViewMat.inverse(); | ||
255 | var viewToPlaneMat = glmat4.inverse( planeToViewMat, [] ); | ||
256 |