diff options
-rw-r--r-- | assets/canvas-runtime.js | 40 | ||||
-rw-r--r-- | js/io/system/ninjalibrary.json | 2 | ||||
-rwxr-xr-x | js/lib/geom/brush-stroke.js | 5 | ||||
-rwxr-xr-x | js/models/element-model.js | 4 | ||||
-rwxr-xr-x | js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js | 66 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 49 |
6 files changed, 137 insertions, 29 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index fe5f839c..feb35187 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js | |||
@@ -2107,7 +2107,40 @@ NinjaCvsRt.RuntimeBrushStroke = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
2107 | } | 2107 | } |
2108 | this._LocalPoints = newPoints.slice(0); | 2108 | this._LocalPoints = newPoints.slice(0); |
2109 | } | 2109 | } |
2110 | } | 2110 | |
2111 | // *** compute the bounding box ********* | ||
2112 | var BBoxMin = [Infinity, Infinity, Infinity]; | ||
2113 | var BBoxMax = [-Infinity, -Infinity, -Infinity]; | ||
2114 | if (numPoints === 0) { | ||
2115 | BBoxMin = [0, 0, 0]; | ||
2116 | BBoxMax = [0, 0, 0]; | ||
2117 | } else { | ||
2118 | for (var i=0;i<numPoints;i++){ | ||
2119 | var pt = this._LocalPoints[i]; | ||
2120 | for (var d = 0; d < 3; d++) { | ||
2121 | if (BBoxMin[d] > pt[d]) { | ||
2122 | BBoxMin[d] = pt[d]; | ||
2123 | } | ||
2124 | if (BBoxMax[d] < pt[d]) { | ||
2125 | BBoxMax[d] = pt[d]; | ||
2126 | } | ||
2127 | }//for every dimension d from 0 to 2 | ||
2128 | } | ||
2129 | } | ||
2130 | |||
2131 | //increase the bbox given the stroke width and the angle (in case of calligraphic brush) | ||
2132 | var bboxPadding = this._strokeWidth*0.5; | ||
2133 | for (var d = 0; d < 3; d++) { | ||
2134 | BBoxMin[d]-= bboxPadding; | ||
2135 | BBoxMax[d]+= bboxPadding; | ||
2136 | }//for every dimension d from 0 to 2 | ||
2137 | |||
2138 | //******* update the local coords so that the bbox min is at the origin ****** | ||
2139 | for (var i=0;i<numPoints;i++) { | ||
2140 | this._LocalPoints[i][0]-= BBoxMin[0]; | ||
2141 | this._LocalPoints[i][1]-= BBoxMin[1]; | ||
2142 | } | ||
2143 | }//if we need to do smoothing | ||
2111 | } | 2144 | } |
2112 | }, | 2145 | }, |
2113 | 2146 | ||
@@ -2231,7 +2264,10 @@ NinjaCvsRt.RuntimeBrushStroke = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
2231 | var disp = [brushStamp[t][0], brushStamp[t][1]]; | 2264 | var disp = [brushStamp[t][0], brushStamp[t][1]]; |
2232 | var alphaVal = 1.0; | 2265 | var alphaVal = 1.0; |
2233 | var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth; | 2266 | var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth; |
2234 | if (distFromOpaqueRegion>0) { | 2267 | if (numTraces === 1){ |
2268 | distFromOpaqueRegion = 0; | ||
2269 | } | ||
2270 | else if (distFromOpaqueRegion>0) { | ||
2235 | var transparencyFactor = distFromOpaqueRegion/maxTransparentRegionHalfWidth; | 2271 | var transparencyFactor = distFromOpaqueRegion/maxTransparentRegionHalfWidth; |
2236 | alphaVal = 1.0 - transparencyFactor;//(transparencyFactor*transparencyFactor);//the square term produces nonlinearly varying alpha values | 2272 | alphaVal = 1.0 - transparencyFactor;//(transparencyFactor*transparencyFactor);//the square term produces nonlinearly varying alpha values |
2237 | alphaVal *= 0.5; //factor that accounts for lineWidth == 2 | 2273 | alphaVal *= 0.5; //factor that accounts for lineWidth == 2 |
diff --git a/js/io/system/ninjalibrary.json b/js/io/system/ninjalibrary.json index e9df5e58..03753da9 100644 --- a/js/io/system/ninjalibrary.json +++ b/js/io/system/ninjalibrary.json | |||
@@ -1,6 +1,6 @@ | |||
1 | { | 1 | { |
2 | "libraries": [ | 2 | "libraries": [ |
3 | {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.10.0.0"}, | 3 | {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.10.0.0"}, |
4 | {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.9.0"} | 4 | {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.6.0.0"} |
5 | ] | 5 | ] |
6 | } \ No newline at end of file | 6 | } \ No newline at end of file |
diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js index d9c2ab53..0e0406dd 100755 --- a/js/lib/geom/brush-stroke.js +++ b/js/lib/geom/brush-stroke.js | |||
@@ -719,7 +719,10 @@ BrushStroke.prototype.drawToContext = function(ctx, drawStageWorldPts, stageWorl | |||
719 | var disp = [brushStamp[t][0], brushStamp[t][1]]; | 719 | var disp = [brushStamp[t][0], brushStamp[t][1]]; |
720 | var alphaVal = 1.0; | 720 | var alphaVal = 1.0; |
721 | var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth; | 721 | var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth; |
722 | if (distFromOpaqueRegion>0) { | 722 | if (numTraces === 1){ |
723 | distFromOpaqueRegion = 0; | ||
724 | } | ||
725 | else if (distFromOpaqueRegion>0) { | ||
723 | var transparencyFactor = distFromOpaqueRegion/maxTransparentRegionHalfWidth; | 726 | var transparencyFactor = distFromOpaqueRegion/maxTransparentRegionHalfWidth; |
724 | alphaVal = 1.0 - transparencyFactor;//(transparencyFactor*transparencyFactor);//the square term produces nonlinearly varying alpha values | 727 | alphaVal = 1.0 - transparencyFactor;//(transparencyFactor*transparencyFactor);//the square term produces nonlinearly varying alpha values |
725 | alphaVal *= 0.5; //factor that accounts for lineWidth == 2 | 728 | alphaVal *= 0.5; //factor that accounts for lineWidth == 2 |
diff --git a/js/models/element-model.js b/js/models/element-model.js index 76f15b21..e5a0f33a 100755 --- a/js/models/element-model.js +++ b/js/models/element-model.js | |||
@@ -91,6 +91,8 @@ var elementNameToController = function(name) { | |||
91 | return "block"; | 91 | return "block"; |
92 | } else if(name === "img") { | 92 | } else if(name === "img") { |
93 | return "image"; | 93 | return "image"; |
94 | } else if(name === "embed") { | ||
95 | return "image"; | ||
94 | } else { | 96 | } else { |
95 | return name; | 97 | return name; |
96 | } | 98 | } |
@@ -174,6 +176,8 @@ var elmo = exports.ElementModel = Montage.create(Montage, { | |||
174 | return "block"; | 176 | return "block"; |
175 | } else if(name === "img") { | 177 | } else if(name === "img") { |
176 | return "image"; | 178 | return "image"; |
179 | } else if(name === "embed") { | ||
180 | return "image"; | ||
177 | } else { | 181 | } else { |
178 | return name; | 182 | return name; |
179 | } | 183 | } |
diff --git a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js index 104d474d..f8d158ce 100755 --- a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js +++ b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js | |||
@@ -4,8 +4,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var Montage = require("montage/core/core").Montage; | 7 | var Montage = require("montage/core/core").Montage, |
8 | var Component = require("montage/ui/component").Component; | 8 | Component = require("montage/ui/component").Component; |
9 | 9 | ||
10 | exports.ThreeD = Montage.create(Component, { | 10 | exports.ThreeD = Montage.create(Component, { |
11 | 11 | ||
@@ -107,6 +107,10 @@ exports.ThreeD = Montage.create(Component, { | |||
107 | value: null | 107 | value: null |
108 | }, | 108 | }, |
109 | 109 | ||
110 | _transformCtr: { | ||
111 | value: null | ||
112 | }, | ||
113 | |||
110 | handleAction: { | 114 | handleAction: { |
111 | value: function(event) { | 115 | value: function(event) { |
112 | if(event.currentTarget.identifier === "flatten") { | 116 | if(event.currentTarget.identifier === "flatten") { |
@@ -143,10 +147,20 @@ exports.ThreeD = Montage.create(Component, { | |||
143 | value : function(prop, value, item, inGlobalMode, isChanging){ | 147 | value : function(prop, value, item, inGlobalMode, isChanging){ |
144 | if(!this._curMat) { | 148 | if(!this._curMat) { |
145 | this._curMat = this.application.ninja.elementMediator.getMatrix(item); | 149 | this._curMat = this.application.ninja.elementMediator.getMatrix(item); |
150 | // this._transformCtr = item.elementModel.props3D.m_transformCtr || [0,0,0]; | ||
151 | // TODO - Always use the center for now until we support multiple selections | ||
152 | this._transformCtr = [0,0,0]; | ||
153 | if(inGlobalMode) { | ||
154 | this._transformCtr = MathUtils.transformPoint(this._transformCtr, this._curMat); | ||
155 | } | ||
146 | } | 156 | } |
147 | 157 | ||
148 | var curMat = this._curMat; | 158 | var curMat = this._curMat, |
149 | var delta = value.value; | 159 | delta = value.value, |
160 | isRotating = false, | ||
161 | xFormMat = Matrix.I(4), | ||
162 | tMat = Matrix.I(4), | ||
163 | mat = []; | ||
150 | if(inGlobalMode) { | 164 | if(inGlobalMode) { |
151 | 165 | ||
152 | if(!this._curProp) { | 166 | if(!this._curProp) { |
@@ -156,17 +170,19 @@ exports.ThreeD = Montage.create(Component, { | |||
156 | delta -= this._curProp; | 170 | delta -= this._curProp; |
157 | } | 171 | } |
158 | 172 | ||
159 | var xFormMat = Matrix.I(4); | ||
160 | switch (prop) | 173 | switch (prop) |
161 | { | 174 | { |
162 | case "xAngle": | 175 | case "xAngle": |
163 | xFormMat = Matrix.RotationX(MathUtils.DEG_TO_RAD * delta); | 176 | xFormMat = Matrix.RotationX(MathUtils.DEG_TO_RAD * delta); |
177 | isRotating = true; | ||
164 | break; | 178 | break; |
165 | case "yAngle": | 179 | case "yAngle": |
166 | xFormMat = Matrix.RotationY(MathUtils.DEG_TO_RAD * delta); | 180 | xFormMat = Matrix.RotationY(MathUtils.DEG_TO_RAD * delta); |
181 | isRotating = true; | ||
167 | break; | 182 | break; |
168 | case "zAngle": | 183 | case "zAngle": |
169 | xFormMat = Matrix.RotationZ(MathUtils.DEG_TO_RAD * delta); | 184 | xFormMat = Matrix.RotationZ(MathUtils.DEG_TO_RAD * delta); |
185 | isRotating = true; | ||
170 | break; | 186 | break; |
171 | case "x3D": | 187 | case "x3D": |
172 | xFormMat[12] = delta; | 188 | xFormMat[12] = delta; |
@@ -179,11 +195,45 @@ exports.ThreeD = Montage.create(Component, { | |||
179 | break; | 195 | break; |
180 | } | 196 | } |
181 | 197 | ||
182 | var mat = []; | ||
183 | if(inGlobalMode) { | 198 | if(inGlobalMode) { |
184 | glmat4.multiply(xFormMat, curMat, mat); | 199 | |
200 | if(isRotating) { | ||
201 | |||
202 | // pre-translate by the transformation center | ||