Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

refactored QuadtraticPath - filled emtpy methods

  • Loading branch information...
commit 2136216a28f8befa9873e3b23071f5b759e5d5eb 1 parent b46d7ae
Ben Beaumont authored
2  src/away3d/extrusions/utils/PathUtils.as
@@ -181,8 +181,6 @@
181 181
182 182 public static function calcCubicPosition(t:Number, ps:CubicPathSegment, out:Vector3D):Vector3D
183 183 {
184   - // (1 - t)^3*start + 3*t*(1 - t)^2*control1 + 3*t^2*(1 - t)*control2 + t^3*end
185   -
186 184 var v:Vector3D = out || new Vector3D();
187 185
188 186 const td:Number = 1 - t;
96 src/away3d/extrusions/utils/QuadraticPath.as
@@ -21,15 +21,7 @@
21 21
22 22 public function QuadraticPath(aVectors:Vector.<Vector3D> = null)
23 23 {
24   - if(aVectors!= null && aVectors.length < 3)
25   - throw new Error("Path Vector.<Vector3D> must contain at least 3 Vector3D's");
26   -
27   - _segments = new Vector.<IPathSegment>();
28   -
29   - if(aVectors != null)
30   - for(var i:int = 0; i<aVectors.length; i+=3)
31   - _segments.push( new QuadraticPathSegment(aVectors[i], aVectors[i+1], aVectors[i+2]));
32   -
  24 + pointData = aVectors;
33 25 }
34 26
35 27
@@ -142,46 +134,7 @@
142 134 {
143 135 return _segments[indice];
144 136 }
145   -
146   - /**
147   - * removes a segment in the path according to id.
148   - *
149   - * @param index int. The index in path of the to be removed curvesegment
150   - * @param join Boolean. If true previous and next segments coordinates are reconnected
151   - */
152   - public function removeSegment(index:int, join:Boolean = false):void
153   - {
154   - if(_segments.length == 0 || _segments[index ] == null )
155   - return;
156   -
157   - if(join && index < _segments.length-1 && index>0){
158   - var seg:QuadraticPathSegment = _segments[index] as QuadraticPathSegment;
159   - var prevSeg:QuadraticPathSegment = _segments[index-1] as QuadraticPathSegment;
160   - var nextSeg:QuadraticPathSegment = _segments[index+1] as QuadraticPathSegment;
161   - prevSeg.pControl.x = (prevSeg.pControl.x+seg.pControl.x)*.5;
162   - prevSeg.pControl.y = (prevSeg.pControl.y+seg.pControl.y)*.5;
163   - prevSeg.pControl.z = (prevSeg.pControl.z+seg.pControl.z)*.5;
164   - nextSeg.pControl.x = (nextSeg.pControl.x+seg.pControl.x)*.5;
165   - nextSeg.pControl.y = (nextSeg.pControl.y+seg.pControl.y)*.5;
166   - nextSeg.pControl.z = (nextSeg.pControl.z+seg.pControl.z)*.5;
167   - prevSeg.pEnd.x = (seg.pStart.x + seg.pEnd.x)*.5;
168   - prevSeg.pEnd.y = (seg.pStart.y + seg.pEnd.y)*.5;
169   - prevSeg.pEnd.z = (seg.pStart.z + seg.pEnd.z)*.5;
170   - nextSeg.pStart.x = prevSeg.pEnd.x;
171   - nextSeg.pStart.y = prevSeg.pEnd.y;
172   - nextSeg.pStart.z = prevSeg.pEnd.z;
173   -
174   - /*if(_pathDebug != null)
175   - _pathDebug.updateAnchorAt(index-1);
176   - _pathDebug.updateAnchorAt(index+1);*/
177   - }
178   -
179   - if(_segments.length > 1){
180   - _segments.splice(index, 1);
181   - } else{
182   - _segments = new Vector.<IPathSegment>();
183   - }
184   - }
  137 +
185 138
186 139 /**
187 140 * handler will smooth the path using anchors as control vector of the PathSegments
@@ -312,27 +265,70 @@
312 265
313 266 public function set pointData(data:Vector.<Vector3D>):void
314 267 {
  268 + if(data!= null && data.length < 3)
  269 + throw new Error("Path Vector.<Vector3D> must contain at least 3 Vector3D's");
  270 +
  271 + _segments = new Vector.<IPathSegment>();
  272 +
  273 + if(data != null)
  274 + for(var i:int = 0; i<data.length; i+=3)
  275 + _segments.push( new QuadraticPathSegment(data[i], data[i+1], data[i+2]));
315 276 }
316 277
317 278
318 279 public function get worldAxis():Vector3D
319 280 {
320   - return null;
  281 + return _worldAxis;
321 282 }
322 283
323 284
324 285 public function set worldAxis(value:Vector3D):void
325 286 {
  287 + _worldAxis = value;
326 288 }
327 289
328 290
329 291 public function remove(index:uint, join:Boolean = false):void
330 292 {
  293 + if(_segments.length == 0 || _segments[index ] == null )
  294 + return;
  295 +
  296 + if(join && index < _segments.length-1 && index>0){
  297 + var seg:QuadraticPathSegment = _segments[index] as QuadraticPathSegment;
  298 + var prevSeg:QuadraticPathSegment = _segments[index-1] as QuadraticPathSegment;
  299 + var nextSeg:QuadraticPathSegment = _segments[index+1] as QuadraticPathSegment;
  300 + prevSeg.pControl.x = (prevSeg.pControl.x+seg.pControl.x)*.5;
  301 + prevSeg.pControl.y = (prevSeg.pControl.y+seg.pControl.y)*.5;
  302 + prevSeg.pControl.z = (prevSeg.pControl.z+seg.pControl.z)*.5;
  303 + nextSeg.pControl.x = (nextSeg.pControl.x+seg.pControl.x)*.5;
  304 + nextSeg.pControl.y = (nextSeg.pControl.y+seg.pControl.y)*.5;
  305 + nextSeg.pControl.z = (nextSeg.pControl.z+seg.pControl.z)*.5;
  306 + prevSeg.pEnd.x = (seg.pStart.x + seg.pEnd.x)*.5;
  307 + prevSeg.pEnd.y = (seg.pStart.y + seg.pEnd.y)*.5;
  308 + prevSeg.pEnd.z = (seg.pStart.z + seg.pEnd.z)*.5;
  309 + nextSeg.pStart.x = prevSeg.pEnd.x;
  310 + nextSeg.pStart.y = prevSeg.pEnd.y;
  311 + nextSeg.pStart.z = prevSeg.pEnd.z;
  312 +
  313 + /*if(_pathDebug != null)
  314 + _pathDebug.updateAnchorAt(index-1);
  315 + _pathDebug.updateAnchorAt(index+1);*/
  316 + }
  317 +
  318 + if(_segments.length > 1){
  319 + _segments.splice(index, 1);
  320 + } else{
  321 + _segments = new Vector.<IPathSegment>();
  322 + }
331 323 }
332 324
333 325
334 326 public function dispose():void
335 327 {
  328 + while (_segments.length > 0)
  329 + _segments[0].dispose();
  330 + _segments = null;
  331 + _worldAxis = null;
336 332 }
337 333 }
338 334 }

0 comments on commit 2136216

Please sign in to comment.
Something went wrong with that request. Please try again.