Permalink
Browse files

Adds several optimizations by caching Vectors.

To minimize calls to new Vector, we're caching and reusing
vectors for specific functions like forceApply(). Removed
unnecessary css rules and stopped tracking /docs and /public.
Now tracking /lib.

Increments version number to 0.0.5
  • Loading branch information...
1 parent 824ecf1 commit 09bbc34e39154f4d3be3f74cd96def1450f57edd @vinceallen vinceallen committed Dec 1, 2012
Showing with 38,056 additions and 31,059 deletions.
  1. +2 −1 .gitignore
  2. +10 −0 README.markdown
  3. +1 −1 build.properties
  4. +6 −3 build.xml
  5. +28 −19 build/backup/flora.0.0.4.js
  6. +5,256 −0 build/backup/flora.0.0.5.js
  7. +145 −0 build/backup/flora.min.0.0.5.js
  8. +3,253 −0 build/backup/floraDOM.0.0.5.js
  9. +61 −43 build/flora.js
  10. +81 −80 build/flora.min.js
  11. +14 −8 build/floraDOM.js
  12. +55 −54 build/floraDOM.min.js
  13. +3 −3 css/build/backup/flora.0.0.4.css
  14. +273 −0 css/build/backup/flora.0.0.5.css
  15. +2 −2 css/build/backup/flora.min.0.0.4.css
  16. +4 −4 ...build/backup/{flora.min.0.0.4.css~bb7e243df5a5abdf5b8bfb87f1c7b1e0be1c1237 → flora.min.0.0.5.css}
  17. +4 −7 css/build/flora.css
  18. +4 −4 css/build/flora.min.css
  19. +1 −4 css/src/flora.css
  20. +4 −7 dev/css/flora.css
  21. +1 −17 dev/flap.html
  22. +1 −1 dev/js/flap.js
  23. +61 −43 dev/js/flora.js
  24. +14 −8 dev/js/floraDOM.js
  25. +1 −1 dev/js/spin.js
  26. +1 −3 dev/spin.html
  27. +1 −1 dev/sticks.html
  28. +0 −732 docs/files.html
  29. +0 −498 docs/index.html
  30. +0 −1,390 docs/symbols/Agent.html
  31. +0 −435 docs/symbols/Attractor.html
  32. +0 −496 docs/symbols/BorderPalette.html
  33. +0 −394 docs/symbols/Camera.html
  34. +0 −485 docs/symbols/Caption.html
  35. +0 −429 docs/symbols/Cold.html
  36. +0 −550 docs/symbols/ColorPalette.html
  37. +0 −543 docs/symbols/ColorTable.html
  38. +0 −469 docs/symbols/Connector.html
  39. +0 −911 docs/symbols/Element.html
  40. +0 −898 docs/symbols/ElementList.html
  41. +0 −577 docs/symbols/FeatureDetector.html
  42. +0 −469 docs/symbols/FlowField.html
  43. +0 −430 docs/symbols/FlowFieldMarker.html
  44. +0 −429 docs/symbols/Food.html
  45. +0 −429 docs/symbols/Heat.html
  46. +0 −479 docs/symbols/InputMenu.html
  47. +0 −591 docs/symbols/Interface.html
  48. +0 −429 docs/symbols/Light.html
  49. +0 −435 docs/symbols/Liquid.html
  50. +0 −534 docs/symbols/Oscillator.html
  51. +0 −429 docs/symbols/Oxygen.html
  52. +0 −469 docs/symbols/Particle.html
  53. +0 −435 docs/symbols/ParticleSystem.html
  54. +0 −423 docs/symbols/Point.html
  55. +0 −429 docs/symbols/Predator.html
  56. +0 −435 docs/symbols/Repeller.html
  57. +0 −619 docs/symbols/Sensor.html
  58. +0 −382 docs/symbols/SimplexNoise.html
  59. +0 −444 docs/symbols/StatsDisplay.html
  60. +0 −540 docs/symbols/System.html
  61. +0 −1,156 docs/symbols/Universe.html
  62. +0 −1,067 docs/symbols/Utils.html
  63. +0 −1,417 docs/symbols/Vector.html
  64. +0 −559 docs/symbols/Walker.html
  65. +0 −736 docs/symbols/World.html
  66. +0 −321 docs/symbols/_global_.html
  67. +0 −773 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_agent.js.html
  68. +0 −44 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_attractor.js.html
  69. +0 −73 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_borderpalette.js.html
  70. +0 −29 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_camera.js.html
  71. +0 −81 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_caption.js.html
  72. +0 −42 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_cold.js.html
  73. +0 −179 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_colorpalette.js.html
  74. +0 −121 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_colortable.js.html
  75. +0 −63 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_config.js.html
  76. +0 −60 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_connector.js.html
  77. +0 −330 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_element.js.html
  78. +0 −213 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_elementlist.js.html
  79. +0 −139 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_featuredetector.js.html
  80. +0 −89 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_flowfield.js.html
  81. +0 −70 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_flowfieldmarker.js.html
  82. +0 −42 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_food.js.html
  83. +0 −42 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_heat.js.html
  84. +0 −100 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_inputmenu.js.html
  85. +0 −124 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_interface.js.html
  86. +0 −42 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_light.js.html
  87. +0 −44 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_liquid.js.html
  88. +0 −119 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_oscillator.js.html
  89. +0 −42 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_oxygen.js.html
  90. +0 −99 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_particle.js.html
  91. +0 −89 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_particlesystem.js.html
  92. +0 −41 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_point.js.html
  93. +0 −42 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_predator.js.html
  94. +0 −44 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_repeller.js.html
  95. +0 −26 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_requestanimframe.js.html
  96. +0 −236 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_sensor.js.html
  97. +0 −216 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_simplexnoise.js.html
  98. +0 −184 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_statsdisplay.js.html
  99. +0 −140 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_system.js.html
  100. +0 −512 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_universe.js.html
  101. +0 −281 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_utils.js.html
  102. +0 −280 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_vector.js.html
  103. +0 −163 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_walker.js.html
  104. +0 −260 docs/symbols/src/_Users_vinceall_Sites_FloraJS_src_world.js.html
  105. +4 −4 examples/css/flora.min.css
  106. +81 −80 examples/js/flora.min.js
  107. +55 −54 examples/js/floraDOM.min.js
  108. BIN lib/compiler.jar
  109. +9,390 −0 lib/csslint-rhino.js
  110. +8 −0 lib/csslint/options.properties
  111. BIN lib/js.jar
  112. +183 −0 lib/jsdoc-toolkit/README.txt
  113. +33 −0 lib/jsdoc-toolkit/app/frame.js
  114. +102 −0 lib/jsdoc-toolkit/app/frame/Chain.js
  115. +144 −0 lib/jsdoc-toolkit/app/frame/Dumper.js
  116. +84 −0 lib/jsdoc-toolkit/app/frame/Hash.js
  117. +173 −0 lib/jsdoc-toolkit/app/frame/Link.js
  118. +10 −0 lib/jsdoc-toolkit/app/frame/Namespace.js
  119. +134 −0 lib/jsdoc-toolkit/app/frame/Opt.js
  120. +26 −0 lib/jsdoc-toolkit/app/frame/Reflection.js
  121. +93 −0 lib/jsdoc-toolkit/app/frame/String.js
  122. +129 −0 lib/jsdoc-toolkit/app/frame/Testrun.js
  123. +26 −0 lib/jsdoc-toolkit/app/handlers/FOODOC.js
  124. +26 −0 lib/jsdoc-toolkit/app/handlers/XMLDOC.js
  125. +159 −0 lib/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js
  126. +16 −0 lib/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js
  127. +292 −0 lib/jsdoc-toolkit/app/handlers/XMLDOC/XMLParse.js
  128. +106 −0 lib/jsdoc-toolkit/app/lib/JSDOC.js
  129. +204 −0 lib/jsdoc-toolkit/app/lib/JSDOC/DocComment.js
  130. +294 −0 lib/jsdoc-toolkit/app/lib/JSDOC/DocTag.js
  131. +140 −0 lib/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js
  132. +109 −0 lib/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js
  133. +144 −0 lib/jsdoc-toolkit/app/lib/JSDOC/Lang.js
  134. +146 −0 lib/jsdoc-toolkit/app/lib/JSDOC/Parser.js
  135. +33 −0 lib/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js
  136. +644 −0 lib/jsdoc-toolkit/app/lib/JSDOC/Symbol.js
  137. +243 −0 lib/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js
  138. +41 −0 lib/jsdoc-toolkit/app/lib/JSDOC/TextStream.js
  139. +18 −0 lib/jsdoc-toolkit/app/lib/JSDOC/Token.js
  140. +332 −0 lib/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js
  141. +133 −0 lib/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js
  142. +32 −0 lib/jsdoc-toolkit/app/lib/JSDOC/Util.js
  143. +507 −0 lib/jsdoc-toolkit/app/lib/JSDOC/Walker.js
  144. +111 −0 lib/jsdoc-toolkit/app/main.js
  145. +20 −0 lib/jsdoc-toolkit/app/plugins/commentSrcJson.js
  146. +16 −0 lib/jsdoc-toolkit/app/plugins/frameworkPrototype.js
  147. +10 −0 lib/jsdoc-toolkit/app/plugins/functionCall.js
  148. +62 −0 lib/jsdoc-toolkit/app/plugins/publishSrcHilite.js
  149. +10 −0 lib/jsdoc-toolkit/app/plugins/symbolLink.js
  150. +31 −0 lib/jsdoc-toolkit/app/plugins/tagParamConfig.js
  151. +43 −0 lib/jsdoc-toolkit/app/plugins/tagSynonyms.js
  152. +348 −0 lib/jsdoc-toolkit/app/run.js
  153. +144 −0 lib/jsdoc-toolkit/app/t/TestDoc.js
  154. +13 −0 lib/jsdoc-toolkit/app/t/runner.js
  155. +342 −0 lib/jsdoc-toolkit/app/test.js
  156. +24 −0 lib/jsdoc-toolkit/app/test/addon.js
  157. +14 −0 lib/jsdoc-toolkit/app/test/anon_inner.js
  158. +31 −0 lib/jsdoc-toolkit/app/test/augments.js
  159. +26 −0 lib/jsdoc-toolkit/app/test/augments2.js
  160. +46 −0 lib/jsdoc-toolkit/app/test/borrows.js
  161. +23 −0 lib/jsdoc-toolkit/app/test/borrows2.js
  162. +22 −0 lib/jsdoc-toolkit/app/test/config.js
  163. +18 −0 lib/jsdoc-toolkit/app/test/constructs.js
  164. +10 −0 lib/jsdoc-toolkit/app/test/encoding.js
  165. +12 −0 lib/jsdoc-toolkit/app/test/encoding_other.js
  166. +54 −0 lib/jsdoc-toolkit/app/test/event.js
  167. +14 −0 lib/jsdoc-toolkit/app/test/exports.js
  168. +39 −0 lib/jsdoc-toolkit/app/test/functions_anon.js
  169. +33 −0 lib/jsdoc-toolkit/app/test/functions_nested.js
  170. +13 −0 lib/jsdoc-toolkit/app/test/global.js
  171. +25 −0 lib/jsdoc-toolkit/app/test/globals.js
  172. +10 −0 lib/jsdoc-toolkit/app/test/ignore.js
  173. +16 −0 lib/jsdoc-toolkit/app/test/inner.js
  174. +477 −0 lib/jsdoc-toolkit/app/test/jsdoc_test.js
  175. +33 −0 lib/jsdoc-toolkit/app/test/lend.js
  176. +19 −0 lib/jsdoc-toolkit/app/test/memberof.js
  177. +38 −0 lib/jsdoc-toolkit/app/test/memberof2.js
  178. +33 −0 lib/jsdoc-toolkit/app/test/memberof3.js
  179. +17 −0 lib/jsdoc-toolkit/app/test/memberof_constructor.js
  180. +17 −0 lib/jsdoc-toolkit/app/test/module.js
  181. +25 −0 lib/jsdoc-toolkit/app/test/multi_methods.js
  182. +19 −0 lib/jsdoc-toolkit/app/test/name.js
  183. +23 −0 lib/jsdoc-toolkit/app/test/namespace_nested.js
  184. +13 −0 lib/jsdoc-toolkit/app/test/nocode.js
  185. +20 −0 lib/jsdoc-toolkit/app/test/oblit_anon.js
  186. +20 −0 lib/jsdoc-toolkit/app/test/overview.js
  187. +37 −0 lib/jsdoc-toolkit/app/test/param_inline.js
  188. +8 −0 lib/jsdoc-toolkit/app/test/params_optional.js
  189. +17 −0 lib/jsdoc-toolkit/app/test/prototype.js
  190. +9 −0 lib/jsdoc-toolkit/app/test/prototype_nested.js
  191. +13 −0 lib/jsdoc-toolkit/app/test/prototype_oblit.js
  192. +24 −0 lib/jsdoc-toolkit/app/test/prototype_oblit_constructor.js
  193. +10 −0 lib/jsdoc-toolkit/app/test/public.js
  194. +5 −0 lib/jsdoc-toolkit/app/test/scripts/code.js
  195. +5 −0 lib/jsdoc-toolkit/app/test/scripts/notcode.txt
  196. +42 −0 lib/jsdoc-toolkit/app/test/shared.js
  197. +2 −0 lib/jsdoc-toolkit/app/test/shared2.js
  198. +22 −0 lib/jsdoc-toolkit/app/test/shortcuts.js
  199. +13 −0 lib/jsdoc-toolkit/app/test/static_this.js
  200. +31 −0 lib/jsdoc-toolkit/app/test/synonyms.js
  201. +23 −0 lib/jsdoc-toolkit/app/test/tosource.js
  202. +14 −0 lib/jsdoc-toolkit/app/test/variable_redefine.js
  203. +124 −0 lib/jsdoc-toolkit/changes.txt
  204. +31 −0 lib/jsdoc-toolkit/conf/sample.conf
  205. +36 −0 lib/jsdoc-toolkit/java/build.xml
  206. +36 −0 lib/jsdoc-toolkit/java/build_1.4.xml
  207. BIN lib/jsdoc-toolkit/java/classes/js.jar
  208. +21 −0 lib/jsdoc-toolkit/java/src/JsDebugRun.java
  209. +21 −0 lib/jsdoc-toolkit/java/src/JsRun.java
  210. BIN lib/jsdoc-toolkit/jsdebug.jar
  211. BIN lib/jsdoc-toolkit/jsrun.jar
  212. +52 −0 lib/jsdoc-toolkit/jsrun.sh
  213. +17 −0 lib/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl
  214. +56 −0 lib/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl
  215. +649 −0 lib/jsdoc-toolkit/templates/jsdoc/class.tmpl
  216. +39 −0 lib/jsdoc-toolkit/templates/jsdoc/index.tmpl
  217. +201 −0 lib/jsdoc-toolkit/templates/jsdoc/publish.js
  218. +162 −0 lib/jsdoc-toolkit/templates/jsdoc/static/default.css
  219. +2 −0 lib/jsdoc-toolkit/templates/jsdoc/static/header.html
  220. +19 −0 lib/jsdoc-toolkit/templates/jsdoc/static/index.html
  221. +35 −0 lib/jsdoc-toolkit/templates/jsdoc/symbol.tmpl
  222. +4,917 −0 lib/jshint.js
  223. BIN lib/phantomjs/phantomjs
  224. +102 −0 lib/phantomjs/run-jasmine.js
  225. +35 −0 lib/rhino-shim.js
  226. +0 −41 public/braitenberg_vehicle1_ALIVE.html
  227. +0 −41 public/braitenberg_vehicle2a_COWARD.html
  228. +0 −41 public/braitenberg_vehicle2b_AGGRESSIVE.html
  229. +0 −41 public/braitenberg_vehicle3a_LOVES.html
  230. +0 −41 public/braitenberg_vehicle3b_EXPLORER.html
  231. +0 −48 public/braitenberg_vehicle3c_VALUES.html
  232. +0 −198 public/css/braitenberg.css
  233. +0 −63 public/css/flora.min.css
  234. +0 −42 public/flap.html
  235. +0 −557 public/js/braitenberg.js
  236. +0 −61 public/js/braitenberg_vehicle1_ALIVE.js
  237. +0 −57 public/js/braitenberg_vehicle2a_COWARD.js
  238. +0 −60 public/js/braitenberg_vehicle2b_AGGRESSIVE.js
  239. +0 −57 public/js/braitenberg_vehicle3a_LOVES.js
  240. +0 −57 public/js/braitenberg_vehicle3b_EXPLORER.js
  241. +0 −74 public/js/braitenberg_vehicle3c_VALUES.js
  242. +0 −101 public/js/flap.js
  243. +0 −144 public/js/flora.min.js
  244. +0 −153 public/js/particles1_CURIOUS.js
  245. +0 −47 public/js/particles2_SMOTHER.js
  246. +0 −46 public/js/particles3_FLIRT.js
  247. +0 −123 public/js/spin.js
  248. +0 −26 public/particles1_CURIOUS.html
  249. +0 −26 public/particles2_SMOTHER.html
  250. +0 −26 public/particles3_FLIRT.html
  251. +0 −28 public/spin.html
  252. +43 −35 src/agent.js
  253. +8 −0 src/element.js
  254. +4 −6 src/vector.js
  255. +5,256 −0 tests/lib/flora.js
View
@@ -2,8 +2,9 @@
###########
bak/
demos/
-lib/
experimental/
+docs/
+public/
# FILES #
#########
View
@@ -512,3 +512,13 @@ The following examples implement advanced functions of FloraJS.
* updated tests
* tracking /lib
* add spin demo
+
+0.0.5
+* stopped tracking /docs - run build.release to generate docs
+* stopped tracking /public
+* added applyForceVector to cache Agent.applyForce() vector
+* added followDesiredVelocity to cache Agent.follow() desired velocity vector
+* added separateSumForceVector to cache Agent.separate() sum force vector
+* added alignSumForceVector to cache Agent.align() sum force vector
+* remove unnecessary style rules
+* increased total agents in flocking demos
View
@@ -1,6 +1,6 @@
projectName = FloraJS
buildName = flora
-version = 0.0.4
+version = 0.0.5
src.dir = ./src
build.dir = ./build
examples.dir = ./examples
View
@@ -312,7 +312,7 @@
<!-- Bake for release: the final step -->
<target name="bakeRelease">
- <!-- Adds the license to the raw minified file. -->
+ <!-- Adds the license to the raw minified js file. -->
<concat destfile="${build.dir}/${buildName}.min.js" fixlastline="yes" eol="lf">
<header trimleading="yes">/*
%PROJECTNAME%
@@ -325,7 +325,7 @@
<filelist dir="${build.dir}" files="${buildName}.raw.min.js"/>
<footer trimleading="yes"></footer>
</concat>
- <!-- Adds the license to the raw minified floraDOM file. -->
+ <!-- Adds the license to the raw minified floraDOM js file. -->
<concat destfile="${build.dir}/floraDOM.min.js" fixlastline="yes" eol="lf">
<header trimleading="yes">/*
%PROJECTNAME% | DOM Renderer
@@ -337,7 +337,7 @@
<filelist dir="${build.dir}" files="floraDOM.raw.min.js"/>
<footer trimleading="yes"></footer>
</concat>
- <!-- CSS - Adds the license to the raw minified file. -->
+ <!-- CSS - Adds the license to the raw minified css file. -->
<concat destfile="${cssBuild.dir}/${buildName}.min.css" fixlastline="yes" eol="lf">
<header trimleading="yes">/*
%PROJECTNAME%
@@ -354,10 +354,12 @@
<!-- the version number found in build.properties. -->
<replaceregexp match="%VERSION%" replace="${version}" flags="g" byline="true">
<fileset dir="${build.dir}" includes="**/*"/>
+ <fileset dir="${cssBuild.dir}" includes="**/*"/>
</replaceregexp>
<!-- Searches for %PROJECTNAME% in the build directory and replaces with the project name -->
<replaceregexp match="%PROJECTNAME%" replace="${projectName}" flags="g" byline="true">
<fileset dir="${build.dir}" includes="**/*"/>
+ <fileset dir="${cssBuild.dir}" includes="**/*"/>
</replaceregexp>
<delete file="${build.dir}/${buildName}.raw.min.js"/>
<delete file="${build.dir}/${buildName}DOM.raw.min.js"/>
@@ -469,6 +471,7 @@
<copy file="${dev.dir}/js/particles3_FLIRT.js" tofile="${public.dir}/js/particles3_FLIRT.js" overwrite="true"/>
<copy file="${dev.dir}/particles3_FLIRT.html" tofile="${public.dir}/particles3_FLIRT.html" overwrite="true"/>
+ <!-- change refs in public.dir to point to the minified file -->
<fileset id="public.fileset" dir="${public.dir}" includes="**/*.html" />
<replaceregexp match="flora.js" replace="flora.min.js" flags="g" byline="true">
@@ -25,7 +25,7 @@ THE SOFTWARE.
*/
/* Version: 0.0.4 */
/* Simplex noise by Sean McCullough banksean@gmail.com */
-/* Build time: November 25, 2012 06:32:43 */
+/* Build time: November 29, 2012 09:58:09 */
/** @namespace */
var Flora = {}, exports = Flora;
@@ -2540,6 +2540,8 @@ function Element(opt_options) {
this.borderRadius = options.borderRadius || null;
this.boxShadow = options.boxShadow || null;
+ this.applyForceVector = new exports.Vector();
+
// set sensors
this.sensors = options.sensors || [];
@@ -3110,10 +3112,15 @@ Agent.prototype.applyForce = function(force) {
'use strict';
// F = M * A
- var f = force.clone(); // make a copy of the force so the original force vector is not altered by dividing by mass; could also use static method
+ //var f = force.clone(); // make a copy of the force so the original force vector is not altered by dividing by mass; could also use static method
+ //f.div(this.mass);
+ //this.acceleration.add(f);
+
+ this.applyForceVector.x = force.x;
+ this.applyForceVector.y = force.y;
- f.div(this.mass);
- this.acceleration.add(f);
+ this.applyForceVector.div(this.mass);
+ this.acceleration.add(this.applyForceVector);
};
/**
@@ -3139,13 +3146,15 @@ Agent.prototype.seek = function(target) {
desiredVelocity.mult(this.maxSpeed);
}
- var steer = exports.Vector.VectorSub(desiredVelocity, this.velocity);
- steer.limit(this.maxSteeringForce);
- return steer;
+ desiredVelocity.sub(this.velocity);
+ desiredVelocity.limit(this.maxSteeringForce);
+
+ return desiredVelocity;
};
/**
* Calculates a steering force to apply to an object following another object.
+ * Agents with flow fields will use this method to calculate a steering force.
*
* @param {Object} target The object to follow.
* @returns {Object} The force to apply.
@@ -3157,10 +3166,10 @@ Agent.prototype.follow = function(target) {
var desiredVelocity = target.location.clone();
desiredVelocity.mult(this.maxSpeed);
+ desiredVelocity.sub(this.velocity);
+ desiredVelocity.limit(this.maxSteeringForce);
- var steer = exports.Vector.VectorSub(desiredVelocity, this.velocity);
- steer.limit(this.maxSteeringForce);
- return steer;
+ return desiredVelocity;
};
/**
@@ -3209,9 +3218,9 @@ Agent.prototype.separate = function(elements) {
sum.div(count);
sum.normalize();
sum.mult(this.maxSpeed);
- steer = exports.Vector.VectorSub(sum, this.velocity);
- steer.limit(this.maxSteeringForce);
- return steer;
+ sum.sub(this.velocity);
+ sum.limit(this.maxSteeringForce);
+ return sum;
}
return new exports.Vector();
};
@@ -3248,9 +3257,9 @@ Agent.prototype.align = function(elements) {
sum.div(count);
sum.normalize();
sum.mult(this.maxSpeed);
- steer = exports.Vector.VectorSub(sum, this.velocity);
- steer.limit(this.maxSteeringForce);
- return steer;
+ sum.sub(this.velocity);
+ sum.limit(this.maxSteeringForce);
+ return sum;
}
return new exports.Vector();
};
@@ -3288,9 +3297,9 @@ Agent.prototype.cohesion = function(elements) {
desiredVelocity = exports.Vector.VectorSub(sum, this.location);
desiredVelocity.normalize();
desiredVelocity.mult(this.maxSpeed);
- steer = exports.Vector.VectorSub(desiredVelocity, this.velocity);
- steer.limit(this.maxSteeringForce);
- return steer;
+ desiredVelocity.sub(this.velocity);
+ desiredVelocity.limit(this.maxSteeringForce);
+ return desiredVelocity;
}
return new exports.Vector();
};
Oops, something went wrong.

0 comments on commit 09bbc34

Please sign in to comment.