jax 0.0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (446) hide show
  1. data/.gitignore +12 -0
  2. data/.gitmodules +3 -0
  3. data/.rvmrc +7 -0
  4. data/Gemfile +4 -0
  5. data/README.rdoc +32 -0
  6. data/Rakefile +144 -0
  7. data/bin/jax +11 -0
  8. data/builtin/shaders/basic/common.ejs +11 -0
  9. data/builtin/shaders/basic/fragment.ejs +5 -0
  10. data/builtin/shaders/basic/vertex.ejs +13 -0
  11. data/builtin/shaders/depthmap/common.ejs +1 -0
  12. data/builtin/shaders/depthmap/fragment.ejs +5 -0
  13. data/builtin/shaders/depthmap/vertex.ejs +7 -0
  14. data/builtin/shaders/fog/common.ejs +7 -0
  15. data/builtin/shaders/fog/fragment.ejs +23 -0
  16. data/builtin/shaders/fog/manifest.yml +12 -0
  17. data/builtin/shaders/fog/material.js +34 -0
  18. data/builtin/shaders/fog/vertex.ejs +10 -0
  19. data/builtin/shaders/functions/depth_map.ejs +24 -0
  20. data/builtin/shaders/functions/lights.ejs +155 -0
  21. data/builtin/shaders/lighting/common.ejs +5 -0
  22. data/builtin/shaders/lighting/fragment.ejs +34 -0
  23. data/builtin/shaders/lighting/manifest.yml +4 -0
  24. data/builtin/shaders/lighting/material.js +26 -0
  25. data/builtin/shaders/lighting/vertex.ejs +7 -0
  26. data/builtin/shaders/normal_map/common.ejs +12 -0
  27. data/builtin/shaders/normal_map/fragment.ejs +26 -0
  28. data/builtin/shaders/normal_map/manifest.yml +17 -0
  29. data/builtin/shaders/normal_map/material.js +16 -0
  30. data/builtin/shaders/normal_map/vertex.ejs +57 -0
  31. data/builtin/shaders/paraboloid-depthmap/common.ejs +6 -0
  32. data/builtin/shaders/paraboloid-depthmap/fragment.ejs +8 -0
  33. data/builtin/shaders/paraboloid-depthmap/material.js +15 -0
  34. data/builtin/shaders/paraboloid-depthmap/vertex.ejs +26 -0
  35. data/builtin/shaders/shadow_map/common.ejs +14 -0
  36. data/builtin/shaders/shadow_map/fragment.ejs +66 -0
  37. data/builtin/shaders/shadow_map/manifest.yml +1 -0
  38. data/builtin/shaders/shadow_map/material.js +26 -0
  39. data/builtin/shaders/shadow_map/vertex.ejs +46 -0
  40. data/builtin/shaders/texture/common.ejs +4 -0
  41. data/builtin/shaders/texture/fragment.ejs +11 -0
  42. data/builtin/shaders/texture/manifest.yml +17 -0
  43. data/builtin/shaders/texture/material.js +18 -0
  44. data/builtin/shaders/texture/vertex.ejs +9 -0
  45. data/guides/assets/images/book_icon.gif +0 -0
  46. data/guides/assets/images/bullet.gif +0 -0
  47. data/guides/assets/images/chapters_icon.gif +0 -0
  48. data/guides/assets/images/check_bullet.gif +0 -0
  49. data/guides/assets/images/credits_pic_blank.gif +0 -0
  50. data/guides/assets/images/edge_badge.png +0 -0
  51. data/guides/assets/images/feature_tile.gif +0 -0
  52. data/guides/assets/images/footer_tile.gif +0 -0
  53. data/guides/assets/images/getting_started/clean_passing_jasmine_suite.png +0 -0
  54. data/guides/assets/images/getting_started/rock.png +0 -0
  55. data/guides/assets/images/getting_started/rock_normal.png +0 -0
  56. data/guides/assets/images/grey_bullet.gif +0 -0
  57. data/guides/assets/images/header_backdrop.png +0 -0
  58. data/guides/assets/images/header_tile.gif +0 -0
  59. data/guides/assets/images/icons/README +5 -0
  60. data/guides/assets/images/icons/callouts/1.png +0 -0
  61. data/guides/assets/images/icons/callouts/10.png +0 -0
  62. data/guides/assets/images/icons/callouts/11.png +0 -0
  63. data/guides/assets/images/icons/callouts/12.png +0 -0
  64. data/guides/assets/images/icons/callouts/13.png +0 -0
  65. data/guides/assets/images/icons/callouts/14.png +0 -0
  66. data/guides/assets/images/icons/callouts/15.png +0 -0
  67. data/guides/assets/images/icons/callouts/2.png +0 -0
  68. data/guides/assets/images/icons/callouts/3.png +0 -0
  69. data/guides/assets/images/icons/callouts/4.png +0 -0
  70. data/guides/assets/images/icons/callouts/5.png +0 -0
  71. data/guides/assets/images/icons/callouts/6.png +0 -0
  72. data/guides/assets/images/icons/callouts/7.png +0 -0
  73. data/guides/assets/images/icons/callouts/8.png +0 -0
  74. data/guides/assets/images/icons/callouts/9.png +0 -0
  75. data/guides/assets/images/icons/caution.png +0 -0
  76. data/guides/assets/images/icons/example.png +0 -0
  77. data/guides/assets/images/icons/home.png +0 -0
  78. data/guides/assets/images/icons/important.png +0 -0
  79. data/guides/assets/images/icons/next.png +0 -0
  80. data/guides/assets/images/icons/note.png +0 -0
  81. data/guides/assets/images/icons/prev.png +0 -0
  82. data/guides/assets/images/icons/tip.png +0 -0
  83. data/guides/assets/images/icons/up.png +0 -0
  84. data/guides/assets/images/icons/warning.png +0 -0
  85. data/guides/assets/images/nav_arrow.gif +0 -0
  86. data/guides/assets/images/tab_grey.gif +0 -0
  87. data/guides/assets/images/tab_info.gif +0 -0
  88. data/guides/assets/images/tab_note.gif +0 -0
  89. data/guides/assets/images/tab_red.gif +0 -0
  90. data/guides/assets/images/tab_yellow.gif +0 -0
  91. data/guides/assets/images/tab_yellow.png +0 -0
  92. data/guides/assets/javascripts/guides.js +7 -0
  93. data/guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js +59 -0
  94. data/guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js +75 -0
  95. data/guides/assets/javascripts/syntaxhighlighter/shBrushBash.js +59 -0
  96. data/guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js +65 -0
  97. data/guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js +100 -0
  98. data/guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js +97 -0
  99. data/guides/assets/javascripts/syntaxhighlighter/shBrushCss.js +91 -0
  100. data/guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js +55 -0
  101. data/guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js +41 -0
  102. data/guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js +52 -0
  103. data/guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js +67 -0
  104. data/guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js +52 -0
  105. data/guides/assets/javascripts/syntaxhighlighter/shBrushJava.js +57 -0
  106. data/guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js +58 -0
  107. data/guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js +72 -0
  108. data/guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js +88 -0
  109. data/guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js +33 -0
  110. data/guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js +74 -0
  111. data/guides/assets/javascripts/syntaxhighlighter/shBrushPython.js +64 -0
  112. data/guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js +55 -0
  113. data/guides/assets/javascripts/syntaxhighlighter/shBrushSass.js +94 -0
  114. data/guides/assets/javascripts/syntaxhighlighter/shBrushScala.js +51 -0
  115. data/guides/assets/javascripts/syntaxhighlighter/shBrushSql.js +66 -0
  116. data/guides/assets/javascripts/syntaxhighlighter/shBrushVb.js +56 -0
  117. data/guides/assets/javascripts/syntaxhighlighter/shBrushXml.js +69 -0
  118. data/guides/assets/javascripts/syntaxhighlighter/shCore.js +17 -0
  119. data/guides/assets/stylesheets/fixes.css +16 -0
  120. data/guides/assets/stylesheets/main.css +445 -0
  121. data/guides/assets/stylesheets/print.css +52 -0
  122. data/guides/assets/stylesheets/reset.css +43 -0
  123. data/guides/assets/stylesheets/style.css +13 -0
  124. data/guides/assets/stylesheets/syntaxhighlighter/shCore.css +226 -0
  125. data/guides/assets/stylesheets/syntaxhighlighter/shCoreDefault.css +328 -0
  126. data/guides/assets/stylesheets/syntaxhighlighter/shCoreDjango.css +331 -0
  127. data/guides/assets/stylesheets/syntaxhighlighter/shCoreEclipse.css +339 -0
  128. data/guides/assets/stylesheets/syntaxhighlighter/shCoreEmacs.css +324 -0
  129. data/guides/assets/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css +328 -0
  130. data/guides/assets/stylesheets/syntaxhighlighter/shCoreMDUltra.css +324 -0
  131. data/guides/assets/stylesheets/syntaxhighlighter/shCoreMidnight.css +324 -0
  132. data/guides/assets/stylesheets/syntaxhighlighter/shCoreRDark.css +324 -0
  133. data/guides/assets/stylesheets/syntaxhighlighter/shThemeDefault.css +117 -0
  134. data/guides/assets/stylesheets/syntaxhighlighter/shThemeDjango.css +120 -0
  135. data/guides/assets/stylesheets/syntaxhighlighter/shThemeEclipse.css +128 -0
  136. data/guides/assets/stylesheets/syntaxhighlighter/shThemeEmacs.css +113 -0
  137. data/guides/assets/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css +117 -0
  138. data/guides/assets/stylesheets/syntaxhighlighter/shThemeJaxGuides.css +116 -0
  139. data/guides/assets/stylesheets/syntaxhighlighter/shThemeMDUltra.css +113 -0
  140. data/guides/assets/stylesheets/syntaxhighlighter/shThemeMidnight.css +113 -0
  141. data/guides/assets/stylesheets/syntaxhighlighter/shThemeRDark.css +113 -0
  142. data/guides/jax_guides.rb +41 -0
  143. data/guides/jax_guides/common.rb +7 -0
  144. data/guides/jax_guides/generator.rb +287 -0
  145. data/guides/jax_guides/helpers.rb +29 -0
  146. data/guides/jax_guides/indexer.rb +69 -0
  147. data/guides/jax_guides/levenshtein.rb +31 -0
  148. data/guides/jax_guides/textile_extensions.rb +61 -0
  149. data/guides/source/getting_started.textile +1171 -0
  150. data/guides/source/index.html.erb +50 -0
  151. data/guides/source/layout.html.erb +158 -0
  152. data/guides/source/lighting.textile +5 -0
  153. data/guides/source/materials.textile +5 -0
  154. data/guides/source/shaders.textile +5 -0
  155. data/guides/source/testing.textile +5 -0
  156. data/guides/w3c_validator.rb +91 -0
  157. data/jax.gems +1 -0
  158. data/jax.gemspec +40 -0
  159. data/lib/jax.rb +28 -0
  160. data/lib/jax/application.rb +92 -0
  161. data/lib/jax/application/configuration.rb +27 -0
  162. data/lib/jax/generators/app.rb +17 -0
  163. data/lib/jax/generators/app/app_generator.rb +78 -0
  164. data/lib/jax/generators/app/templates/Gemfile.tt +3 -0
  165. data/lib/jax/generators/app/templates/Rakefile +6 -0
  166. data/lib/jax/generators/app/templates/app/controllers/application_controller.js.tt +5 -0
  167. data/lib/jax/generators/app/templates/app/helpers/application_helper.js.tt +3 -0
  168. data/lib/jax/generators/app/templates/app/models/.empty_directory +0 -0
  169. data/lib/jax/generators/app/templates/app/resources/.empty_directory +0 -0
  170. data/lib/jax/generators/app/templates/app/views/.empty_directory +0 -0
  171. data/lib/jax/generators/app/templates/config/application.rb.tt +6 -0
  172. data/lib/jax/generators/app/templates/config/boot.rb +13 -0
  173. data/lib/jax/generators/app/templates/config/routes.rb.tt +5 -0
  174. data/lib/jax/generators/app/templates/public/javascripts/jax.js +7561 -0
  175. data/lib/jax/generators/app/templates/public/webgl_not_supported.html +26 -0
  176. data/lib/jax/generators/app/templates/script/jax +7 -0
  177. data/lib/jax/generators/app/templates/spec/javascripts/controllers/application_controller_spec.js +11 -0
  178. data/lib/jax/generators/app/templates/spec/javascripts/helpers/application_helper_spec.js +12 -0
  179. data/lib/jax/generators/app/templates/spec/javascripts/support/jasmine.yml +90 -0
  180. data/lib/jax/generators/app/templates/spec/javascripts/support/jasmine_config.rb +23 -0
  181. data/lib/jax/generators/app/templates/spec/javascripts/support/jasmine_runner.rb +32 -0
  182. data/lib/jax/generators/app/templates/spec/javascripts/support/spec_helpers/jax_spec_helper.js +216 -0
  183. data/lib/jax/generators/app/templates/spec/javascripts/support/spec_layout.html.erb +63 -0
  184. data/lib/jax/generators/commands.rb +81 -0
  185. data/lib/jax/generators/controller/USAGE +9 -0
  186. data/lib/jax/generators/controller/controller_generator.rb +59 -0
  187. data/lib/jax/generators/controller/templates/controller_source.js.tt +16 -0
  188. data/lib/jax/generators/controller/templates/controller_test.js.tt +11 -0
  189. data/lib/jax/generators/controller/templates/helper.js.tt +3 -0
  190. data/lib/jax/generators/controller/templates/helper_test.js.tt +12 -0
  191. data/lib/jax/generators/controller/templates/view.js.tt +4 -0
  192. data/lib/jax/generators/light_source/USAGE +14 -0
  193. data/lib/jax/generators/light_source/light_source_generator.rb +47 -0
  194. data/lib/jax/generators/light_source/templates/light.yml.tt +39 -0
  195. data/lib/jax/generators/material/USAGE +29 -0
  196. data/lib/jax/generators/material/material_generator.rb +81 -0
  197. data/lib/jax/generators/material/templates/append.yml.tt +7 -0
  198. data/lib/jax/generators/material/templates/material.yml.tt +33 -0
  199. data/lib/jax/generators/model/USAGE +5 -0
  200. data/lib/jax/generators/model/model_generator.rb +42 -0
  201. data/lib/jax/generators/model/templates/model.js.tt +11 -0
  202. data/lib/jax/generators/model/templates/test.js.tt +11 -0
  203. data/lib/jax/generators/script_jax_loader.rb +32 -0
  204. data/lib/jax/monkeypatch/jasmine.rb +3 -0
  205. data/lib/jax/monkeypatch/jasmine/config.rb +21 -0
  206. data/lib/jax/monkeypatch/jasmine/server.rb +50 -0
  207. data/lib/jax/packager.rb +58 -0
  208. data/lib/jax/packager/sprockets_template.rb +49 -0
  209. data/lib/jax/resource_compiler.rb +50 -0
  210. data/lib/jax/routes.rb +61 -0
  211. data/lib/jax/shader.rb +158 -0
  212. data/lib/jax/tasks/rake.rb +34 -0
  213. data/lib/jax/version.rb +12 -0
  214. data/public/images/brickwall.jpg +0 -0
  215. data/public/images/jacks.jpg +0 -0
  216. data/public/images/normal_map.jpg +0 -0
  217. data/public/images/rock.png +0 -0
  218. data/public/images/rockNormal.png +0 -0
  219. data/public/images/rss.png +0 -0
  220. data/public/webgl_not_supported.html +26 -0
  221. data/spec/example_app/Gemfile +1 -0
  222. data/spec/example_app/Rakefile +15 -0
  223. data/spec/example_app/app/controllers/application_controller.js +5 -0
  224. data/spec/example_app/app/controllers/courthouse_controller.js +24 -0
  225. data/spec/example_app/app/controllers/lighting_controller.js +69 -0
  226. data/spec/example_app/app/controllers/shadows_controller.js +130 -0
  227. data/spec/example_app/app/controllers/textures_controller.js +52 -0
  228. data/spec/example_app/app/helpers/application_helper.js +3 -0
  229. data/spec/example_app/app/helpers/textures_helper.js +3 -0
  230. data/spec/example_app/app/models/character.js +23 -0
  231. data/spec/example_app/app/models/door.js +10 -0
  232. data/spec/example_app/app/models/scene.js +19 -0
  233. data/spec/example_app/app/resources/characters/judge.yml +3 -0
  234. data/spec/example_app/app/resources/doors/courthouse_door.yml +5 -0
  235. data/spec/example_app/app/resources/light_sources/directional_light.yml +13 -0
  236. data/spec/example_app/app/resources/light_sources/point_light.yml +31 -0
  237. data/spec/example_app/app/resources/light_sources/spot_light.yml +15 -0
  238. data/spec/example_app/app/resources/light_sources/sun.yml +7 -0
  239. data/spec/example_app/app/resources/light_sources/textures_point.yml +34 -0
  240. data/spec/example_app/app/resources/materials/bricks.yml +36 -0
  241. data/spec/example_app/app/resources/materials/lighting_with_shadows.yml +27 -0
  242. data/spec/example_app/app/resources/scenes/courthouse.yml +4 -0
  243. data/spec/example_app/app/views/courthouse/index.js +4 -0
  244. data/spec/example_app/app/views/lighting/index.js +4 -0
  245. data/spec/example_app/app/views/shadows/index.js +6 -0
  246. data/spec/example_app/app/views/textures/index.js +4 -0
  247. data/spec/example_app/config/application.rb +6 -0
  248. data/spec/example_app/config/boot.rb +13 -0
  249. data/spec/example_app/config/routes.rb +6 -0
  250. data/spec/example_app/public/images/185__normalmap.png +0 -0
  251. data/spec/example_app/public/images/face_norm.jpg +0 -0
  252. data/spec/example_app/public/images/rock.png +0 -0
  253. data/spec/example_app/public/images/rockNormal.png +0 -0
  254. data/spec/example_app/public/images/rss.png +0 -0
  255. data/spec/example_app/public/webgl_not_supported.html +26 -0
  256. data/spec/example_app/script/jax +7 -0
  257. data/spec/example_app/spec/javascripts/controllers/textures_controller_spec.js +11 -0
  258. data/spec/example_app/spec/javascripts/helpers/application_helper_spec.js +12 -0
  259. data/spec/example_app/spec/javascripts/resources/directional_light_spec.js +16 -0
  260. data/spec/example_app/spec/javascripts/resources/point_light_spec.js +17 -0
  261. data/spec/example_app/spec/javascripts/resources/spot_light_spec.js +18 -0
  262. data/spec/example_app/spec/javascripts/support/jasmine.yml +89 -0
  263. data/spec/example_app/spec/javascripts/support/jasmine_runner.rb +32 -0
  264. data/spec/example_app/spec/javascripts/support/spec_helpers/jax_spec_helper.js +93 -0
  265. data/spec/example_app/spec/javascripts/support/spec_layout.html.erb +84 -0
  266. data/spec/generators/app_generator_spec.rb +46 -0
  267. data/spec/generators/controller_generator_spec.rb +68 -0
  268. data/spec/generators/light_generator_spec.rb +51 -0
  269. data/spec/generators/material_generator_spec.rb +35 -0
  270. data/spec/generators/model_generator_spec.rb +43 -0
  271. data/spec/javascripts/Player.js +58 -0
  272. data/spec/javascripts/helpers/SpecHelper.js +216 -0
  273. data/spec/javascripts/jax/builtin/materials/core_materials_spec.js +41 -0
  274. data/spec/javascripts/jax/builtin/materials/dual_paraboloid_spec.js +37 -0
  275. data/spec/javascripts/jax/builtin/materials/fog_spec.js +19 -0
  276. data/spec/javascripts/jax/builtin/materials/lighting_spec.js +19 -0
  277. data/spec/javascripts/jax/builtin/materials/normal_map_spec.js +19 -0
  278. data/spec/javascripts/jax/builtin/materials/shadow_map_spec.js +19 -0
  279. data/spec/javascripts/jax/builtin/materials/texture_spec.js +19 -0
  280. data/spec/javascripts/jax/builtin/meshes/cube_spec.js +10 -0
  281. data/spec/javascripts/jax/builtin/meshes/plane_spec.js +8 -0
  282. data/spec/javascripts/jax/builtin/meshes/quad_spec.js +8 -0
  283. data/spec/javascripts/jax/builtin/meshes/sphere_spec.js +8 -0
  284. data/spec/javascripts/jax/builtin/meshes/teapot_spec.js +8 -0
  285. data/spec/javascripts/jax/builtin/meshes/torus_spec.js +8 -0
  286. data/spec/javascripts/jax/compatibility_spec.js +50 -0
  287. data/spec/javascripts/jax/context_spec.js +82 -0
  288. data/spec/javascripts/jax/controller_spec.js +145 -0
  289. data/spec/javascripts/jax/core/delegation_spec.js +48 -0
  290. data/spec/javascripts/jax/core/events_spec.js +17 -0
  291. data/spec/javascripts/jax/core/matrix_stack_spec.js +28 -0
  292. data/spec/javascripts/jax/core/utils_spec.js +256 -0
  293. data/spec/javascripts/jax/helper_spec.js +33 -0
  294. data/spec/javascripts/jax/model_spec.js +87 -0
  295. data/spec/javascripts/jax/optimizations/material_limitations_spec.js +87 -0
  296. data/spec/javascripts/jax/optimizations/shaders/basic_spec.js +68 -0
  297. data/spec/javascripts/jax/prototype/extensions_spec.js +34 -0
  298. data/spec/javascripts/jax/route_set_spec.js +67 -0
  299. data/spec/javascripts/jax/view_manager_spec.js +17 -0
  300. data/spec/javascripts/jax/webgl/camera_spec.js +159 -0
  301. data/spec/javascripts/jax/webgl/framebuffer_spec.js +46 -0
  302. data/spec/javascripts/jax/webgl/lighting_spec.js +61 -0
  303. data/spec/javascripts/jax/webgl/material_spec.js +118 -0
  304. data/spec/javascripts/jax/webgl/mesh_spec.js +86 -0
  305. data/spec/javascripts/jax/webgl/shader/manifest_spec.js +60 -0
  306. data/spec/javascripts/jax/webgl/shader_chain_spec.js +192 -0
  307. data/spec/javascripts/jax/webgl/shader_spec.js +276 -0
  308. data/spec/javascripts/jax/webgl/tangent_space_spec.js +142 -0
  309. data/spec/javascripts/jax/webgl/texture_spec.js +162 -0
  310. data/spec/javascripts/jax/webgl_spec.js +5 -0
  311. data/spec/javascripts/jax/world_spec.js +88 -0
  312. data/spec/javascripts/jax_spec.js +27 -0
  313. data/spec/javascripts/support/jasmine.yml +85 -0
  314. data/spec/javascripts/support/jasmine_runner.rb +32 -0
  315. data/spec/lib/jax/routes_spec.rb +24 -0
  316. data/spec/lib/jax/shader_spec.rb +57 -0
  317. data/spec/lib/jax/tasks/jax_rake_spec.rb +79 -0
  318. data/spec/spec_helper.rb +11 -0
  319. data/spec/support/file_exist_matcher.rb +23 -0
  320. data/spec/support/spec_shell.rb +97 -0
  321. data/src/jax.js +84 -0
  322. data/src/jax/anim_frame.js +47 -0
  323. data/src/jax/builtin/all.js +7 -0
  324. data/src/jax/builtin/meshes/cube.js +62 -0
  325. data/src/jax/builtin/meshes/plane.js +36 -0
  326. data/src/jax/builtin/meshes/quad.js +80 -0
  327. data/src/jax/builtin/meshes/sphere.js +46 -0
  328. data/src/jax/builtin/meshes/teapot.js +38 -0
  329. data/src/jax/builtin/meshes/torus.js +46 -0
  330. data/src/jax/compatibility.js +140 -0
  331. data/src/jax/context.js +253 -0
  332. data/src/jax/controller.js +157 -0
  333. data/src/jax/core.js +39 -0
  334. data/src/jax/core/math.js +40 -0
  335. data/src/jax/core/matrix_stack.js +306 -0
  336. data/src/jax/core/util.js +226 -0
  337. data/src/jax/events.js +179 -0
  338. data/src/jax/geometry.js +3 -0
  339. data/src/jax/geometry/plane.js +59 -0
  340. data/src/jax/helper.js +8 -0
  341. data/src/jax/model.js +163 -0
  342. data/src/jax/prototype/class.js +78 -0
  343. data/src/jax/prototype/core.js +112 -0
  344. data/src/jax/prototype/extensions.js +124 -0
  345. data/src/jax/route_set.js +125 -0
  346. data/src/jax/vendor/ejs.js +4 -0
  347. data/src/jax/vendor/glMatrix.js +3 -0
  348. data/src/jax/view.js +37 -0
  349. data/src/jax/view_manager.js +46 -0
  350. data/src/jax/webgl.js +98 -0
  351. data/src/jax/webgl/camera.js +526 -0
  352. data/src/jax/webgl/core.js +6 -0
  353. data/src/jax/webgl/core/buffer.js +161 -0
  354. data/src/jax/webgl/core/edge.js +6 -0
  355. data/src/jax/webgl/core/events.js +25 -0
  356. data/src/jax/webgl/core/face.js +8 -0
  357. data/src/jax/webgl/core/framebuffer.js +206 -0
  358. data/src/jax/webgl/material.js +375 -0
  359. data/src/jax/webgl/mesh.js +412 -0
  360. data/src/jax/webgl/scene.js +11 -0
  361. data/src/jax/webgl/scene/frustum.js +260 -0
  362. data/src/jax/webgl/scene/light_manager.js +112 -0
  363. data/src/jax/webgl/scene/light_source.js +248 -0
  364. data/src/jax/webgl/shader.js +282 -0
  365. data/src/jax/webgl/shader/delegator.js +13 -0
  366. data/src/jax/webgl/shader/delegator/attribute.js +53 -0
  367. data/src/jax/webgl/shader/delegator/uniform.js +71 -0
  368. data/src/jax/webgl/shader/manifest.js +64 -0
  369. data/src/jax/webgl/shader/program.js +140 -0
  370. data/src/jax/webgl/shader_chain.js +256 -0
  371. data/src/jax/webgl/texture.js +312 -0
  372. data/src/jax/webgl/world.js +119 -0
  373. data/vendor/ejs/.svn/all-wcprops +17 -0
  374. data/vendor/ejs/.svn/entries +114 -0
  375. data/vendor/ejs/.svn/text-base/Eratta.txt.svn-base +3 -0
  376. data/vendor/ejs/.svn/text-base/license.txt.svn-base +21 -0
  377. data/vendor/ejs/Eratta.txt +3 -0
  378. data/vendor/ejs/example/.svn/all-wcprops +29 -0
  379. data/vendor/ejs/example/.svn/entries +164 -0
  380. data/vendor/ejs/example/.svn/prop-base/ejs.gif.svn-base +5 -0
  381. data/vendor/ejs/example/.svn/text-base/demo.html.svn-base +54 -0
  382. data/vendor/ejs/example/.svn/text-base/ejs.gif.svn-base +0 -0
  383. data/vendor/ejs/example/.svn/text-base/example.css.svn-base +31 -0
  384. data/vendor/ejs/example/.svn/text-base/example.js.svn-base +88 -0
  385. data/vendor/ejs/example/demo.html +54 -0
  386. data/vendor/ejs/example/ejs.gif +0 -0
  387. data/vendor/ejs/example/example.css +31 -0
  388. data/vendor/ejs/example/example.js +88 -0
  389. data/vendor/ejs/lib/.svn/all-wcprops +11 -0
  390. data/vendor/ejs/lib/.svn/entries +62 -0
  391. data/vendor/ejs/lib/.svn/text-base/ejs_fulljslint.js.svn-base +3774 -0
  392. data/vendor/ejs/lib/ejs_fulljslint.js +3774 -0
  393. data/vendor/ejs/license.txt +21 -0
  394. data/vendor/ejs/script/.svn/all-wcprops +17 -0
  395. data/vendor/ejs/script/.svn/entries +96 -0
  396. data/vendor/ejs/script/.svn/prop-base/yuicompressor-2.2.4.jar.svn-base +5 -0
  397. data/vendor/ejs/script/.svn/text-base/production.bat.svn-base +4 -0
  398. data/vendor/ejs/script/.svn/text-base/yuicompressor-2.2.4.jar.svn-base +0 -0
  399. data/vendor/ejs/script/production.bat +4 -0
  400. data/vendor/ejs/script/yuicompressor-2.2.4.jar +0 -0
  401. data/vendor/ejs/src/.svn/all-wcprops +17 -0
  402. data/vendor/ejs/src/.svn/entries +96 -0
  403. data/vendor/ejs/src/.svn/text-base/ejs.js.svn-base +505 -0
  404. data/vendor/ejs/src/.svn/text-base/view.js.svn-base +200 -0
  405. data/vendor/ejs/src/ejs.js +505 -0
  406. data/vendor/ejs/src/view.js +200 -0
  407. data/vendor/ejs/test/.svn/all-wcprops +23 -0
  408. data/vendor/ejs/test/.svn/entries +139 -0
  409. data/vendor/ejs/test/.svn/text-base/index.html.svn-base +18 -0
  410. data/vendor/ejs/test/.svn/text-base/setup_test.html.svn-base +44 -0
  411. data/vendor/ejs/test/.svn/text-base/sidebar.html.svn-base +28 -0
  412. data/vendor/ejs/test/included/.svn/all-wcprops +23 -0
  413. data/vendor/ejs/test/included/.svn/entries +130 -0
  414. data/vendor/ejs/test/included/.svn/text-base/prototype.js.svn-base +4184 -0
  415. data/vendor/ejs/test/included/.svn/text-base/test.css.svn-base +44 -0
  416. data/vendor/ejs/test/included/.svn/text-base/unittest.js.svn-base +564 -0
  417. data/vendor/ejs/test/included/prototype.js +4184 -0
  418. data/vendor/ejs/test/included/test.css +44 -0
  419. data/vendor/ejs/test/included/unittest.js +564 -0
  420. data/vendor/ejs/test/index.html +18 -0
  421. data/vendor/ejs/test/setup_test.html +44 -0
  422. data/vendor/ejs/test/sidebar.html +28 -0
  423. data/vendor/ejs/test/templates/.svn/all-wcprops +11 -0
  424. data/vendor/ejs/test/templates/.svn/entries +62 -0
  425. data/vendor/ejs/test/templates/.svn/text-base/test.ejs.svn-base +3 -0
  426. data/vendor/ejs/test/templates/test.ejs +3 -0
  427. data/vendor/ejs/test/tests/.svn/all-wcprops +23 -0
  428. data/vendor/ejs/test/tests/.svn/entries +130 -0
  429. data/vendor/ejs/test/tests/.svn/text-base/rendering.js.svn-base +94 -0
  430. data/vendor/ejs/test/tests/.svn/text-base/templating.js.svn-base +43 -0
  431. data/vendor/ejs/test/tests/.svn/text-base/views.js.svn-base +100 -0
  432. data/vendor/ejs/test/tests/rendering.js +94 -0
  433. data/vendor/ejs/test/tests/templating.js +43 -0
  434. data/vendor/ejs/test/tests/views.js +100 -0
  435. data/vendor/glmatrix/benchmark/js/CanvasMatrix.js +722 -0
  436. data/vendor/glmatrix/benchmark/js/EWGL_math.js +742 -0
  437. data/vendor/glmatrix/benchmark/js/mjs.js +1230 -0
  438. data/vendor/glmatrix/benchmark/matrix_benchmark.html +419 -0
  439. data/vendor/glmatrix/glMatrix-min.js +32 -0
  440. data/vendor/glmatrix/glMatrix.js +1815 -0
  441. data/vendor/glmatrix/unit tests/glMatrix-test.js +74 -0
  442. data/vendor/glmatrix/unit tests/qunit.css +119 -0
  443. data/vendor/glmatrix/unit tests/qunit.js +1069 -0
  444. data/vendor/glmatrix/unit tests/test_glMatrix.html +21 -0
  445. data/vendor/yuicompressor-2.4.2.jar +0 -0
  446. metadata +748 -0
@@ -0,0 +1,1230 @@
1
+ /* -*- Mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
2
+ /*
3
+ * Copyright (c) 2010 Mozilla Corporation
4
+ * Copyright (c) 2010 Vladimir Vukicevic
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person
7
+ * obtaining a copy of this software and associated documentation
8
+ * files (the "Software"), to deal in the Software without
9
+ * restriction, including without limitation the rights to use,
10
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the
12
+ * Software is furnished to do so, subject to the following
13
+ * conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be
16
+ * included in all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
+ * OTHER DEALINGS IN THE SOFTWARE.
26
+ */
27
+
28
+ /*
29
+ * File: mjs
30
+ *
31
+ * Vector and Matrix math utilities for JavaScript, optimized for WebGL.
32
+ */
33
+
34
+ /*
35
+ * Constant: MJS_VERSION
36
+ *
37
+ * mjs version number aa.bb.cc, encoded as an integer of the form:
38
+ * 0xaabbcc.
39
+ */
40
+ const MJS_VERSION = 0x000000;
41
+
42
+ /*
43
+ * Constant: MJS_DO_ASSERT
44
+ *
45
+ * Enables or disables runtime assertions.
46
+ *
47
+ * For potentially more performance, the assert methods can be
48
+ * commented out in each place where they are called.
49
+ */
50
+ const MJS_DO_ASSERT = true;
51
+
52
+ // Some hacks for running in both the shell and browser,
53
+ // and for supporting F32 and WebGLFloat arrays
54
+ try { WebGLFloatArray; } catch (x) { WebGLFloatArray = Float32Array; }
55
+
56
+ /*
57
+ * Constant: MJS_FLOAT_ARRAY_TYPE
58
+ *
59
+ * The base float array type. By default, WebGLFloatArray.
60
+ *
61
+ * mjs can work with any array-like elements, but if an array
62
+ * creation is requested, it will create an array of the type
63
+ * MJS_FLOAT_ARRAY_TYPE. Also, the builtin constants such as (M4x4.I)
64
+ * will be of this type.
65
+ */
66
+ const MJS_FLOAT_ARRAY_TYPE = WebGLFloatArray;
67
+ //const MJS_FLOAT_ARRAY_TYPE = Float32Array;
68
+ //const MJS_FLOAT_ARRAY_TYPE = Float64Array;
69
+ //const MJS_FLOAT_ARRAY_TYPE = Array;
70
+
71
+ if (MJS_DO_ASSERT) {
72
+ function MathUtils_assert(cond, msg) {
73
+ if (!cond)
74
+ throw "Assertion failed: " + msg;
75
+ }
76
+ } else {
77
+ function MathUtils_assert() { }
78
+ }
79
+
80
+ /*
81
+ * Class: V3
82
+ *
83
+ * Methods for working with 3-element vectors. A vector is represented by a 3-element array.
84
+ * Any valid JavaScript array type may be used, but if new
85
+ * vectors are created they are created using the configured MJS_FLOAT_ARRAY_TYPE.
86
+ */
87
+
88
+ var V3 = { };
89
+
90
+ V3._temp1 = new MJS_FLOAT_ARRAY_TYPE(3);
91
+ V3._temp2 = new MJS_FLOAT_ARRAY_TYPE(3);
92
+ V3._temp3 = new MJS_FLOAT_ARRAY_TYPE(3);
93
+
94
+ if (MJS_FLOAT_ARRAY_TYPE == Array) {
95
+ V3.x = [1.0, 0.0, 0.0];
96
+ V3.y = [0.0, 1.0, 0.0];
97
+ V3.z = [0.0, 0.0, 1.0];
98
+
99
+ V3.$ = function V3_$(x, y, z) {
100
+ return [x, y, z];
101
+ };
102
+
103
+ V3.clone = function V3_clone(a) {
104
+ //MathUtils_assert(a.length == 3, "a.length == 3");
105
+ return [a[0], a[1], a[2]];
106
+ };
107
+ } else {
108
+ V3.x = new MJS_FLOAT_ARRAY_TYPE([1.0, 0.0, 0.0]);
109
+ V3.y = new MJS_FLOAT_ARRAY_TYPE([0.0, 1.0, 0.0]);
110
+ V3.z = new MJS_FLOAT_ARRAY_TYPE([0.0, 0.0, 1.0]);
111
+
112
+ /*
113
+ * Function: V3.$
114
+ *
115
+ * Creates a new 3-element vector with the given values.
116
+ *
117
+ * Parameters:
118
+ *
119
+ * x,y,z - the 3 elements of the new vector.
120
+ *
121
+ * Returns:
122
+ *
123
+ * A new vector containing with the given argument values.
124
+ */
125
+
126
+ V3.$ = function V3_$(x, y, z) {
127
+ return new MJS_FLOAT_ARRAY_TYPE([x, y, z]);
128
+ };
129
+
130
+ /*
131
+ * Function: V3.clone
132
+ *
133
+ * Clone the given 3-element vector.
134
+ *
135
+ * Parameters:
136
+ *
137
+ * a - the 3-element vector to clone
138
+ *
139
+ * Returns:
140
+ *
141
+ * A new vector with the same values as the passed-in one.
142
+ */
143
+
144
+ V3.clone = function V3_clone(a) {
145
+ //MathUtils_assert(a.length == 3, "a.length == 3");
146
+ return new MJS_FLOAT_ARRAY_TYPE(a);
147
+ };
148
+ }
149
+
150
+ V3.u = V3.x;
151
+ V3.v = V3.y;
152
+
153
+ /*
154
+ * Function: V3.add
155
+ *
156
+ * Perform r = a + b.
157
+ *
158
+ * Parameters:
159
+ *
160
+ * a - the first vector operand
161
+ * b - the second vector operand
162
+ * r - optional vector to store the result in
163
+ *
164
+ * Returns:
165
+ *
166
+ * If r is specified, returns r after performing the operation.
167
+ * Otherwise, returns a new 3-element vector with the result.
168
+ */
169
+ V3.add = function V3_add(a, b, r) {
170
+ //MathUtils_assert(a.length == 3, "a.length == 3");
171
+ //MathUtils_assert(b.length == 3, "b.length == 3");
172
+ //MathUtils_assert(r == undefined || r.length == 3, "r == undefined || r.length == 3");
173
+
174
+ if (r == undefined)
175
+ r = new MJS_FLOAT_ARRAY_TYPE(3);
176
+ r[0] = a[0] + b[0];
177
+ r[1] = a[1] + b[1];
178
+ r[2] = a[2] + b[2];
179
+ return r;
180
+ };
181
+
182
+ /*
183
+ * Function: V3.sub
184
+ *
185
+ * Perform
186
+ * r = a - b.
187
+ *
188
+ * Parameters:
189
+ *
190
+ * a - the first vector operand
191
+ * b - the second vector operand
192
+ * r - optional vector to store the result in
193
+ *
194
+ * Returns:
195
+ *
196
+ * If r is specified, returns r after performing the operation.
197
+ * Otherwise, returns a new 3-element vector with the result.
198
+ */
199
+ V3.sub = function V3_sub(a, b, r) {
200
+ //MathUtils_assert(a.length == 3, "a.length == 3");
201
+ //MathUtils_assert(b.length == 3, "b.length == 3");
202
+ //MathUtils_assert(r == undefined || r.length == 3, "r == undefined || r.length == 3");
203
+
204
+ if (r == undefined)
205
+ r = new MJS_FLOAT_ARRAY_TYPE(3);
206
+ r[0] = a[0] - b[0];
207
+ r[1] = a[1] - b[1];
208
+ r[2] = a[2] - b[2];
209
+ return r;
210
+ };
211
+
212
+ /*
213
+ * Function: V3.neg
214
+ *
215
+ * Perform
216
+ * r = - a.
217
+ *
218
+ * Parameters:
219
+ *
220
+ * a - the vector operand
221
+ * r - optional vector to store the result in
222
+ *
223
+ * Returns:
224
+ *
225
+ * If r is specified, returns r after performing the operation.
226
+ * Otherwise, returns a new 3-element vector with the result.
227
+ */
228
+ V3.neg = function V3_neg(a, r) {
229
+ //MathUtils_assert(a.length == 3, "a.length == 3");
230
+ //MathUtils_assert(r == undefined || r.length == 3, "r == undefined || r.length == 3");
231
+
232
+ if (r == undefined)
233
+ r = new MJS_FLOAT_ARRAY_TYPE(3);
234
+ r[0] = - a[0];
235
+ r[1] = - a[1];
236
+ r[2] = - a[2];
237
+ return r;
238
+ };
239
+
240
+ /*
241
+ * Function: V3.direction
242
+ *
243
+ * Perform
244
+ * r = (a - b) / |a - b|. The result is the normalized
245
+ * direction from a to b.
246
+ *
247
+ * Parameters:
248
+ *
249
+ * a - the first vector operand
250
+ * b - the second vector operand
251
+ * r - optional vector to store the result in
252
+ *
253
+ * Returns:
254
+ *
255
+ * If r is specified, returns r after performing the operation.
256
+ * Otherwise, returns a new 3-element vector with the result.
257
+ */
258
+ V3.direction = function V3_direction(a, b, r) {
259
+ //MathUtils_assert(a.length == 3, "a.length == 3");
260
+ //MathUtils_assert(b.length == 3, "b.length == 3");
261
+ //MathUtils_assert(r == undefined || r.length == 3, "r == undefined || r.length == 3");
262
+
263
+ if (r == undefined)
264
+ r = new MJS_FLOAT_ARRAY_TYPE(3);
265
+ return V3.normalize(V3.sub(a, b, r), r);
266
+ };
267
+
268
+ /*
269
+ * Function: V3.length
270
+ *
271
+ * Perform r = |a|.
272
+ *
273
+ * Parameters:
274
+ *
275
+ * a - the vector operand
276
+ *
277
+ * Returns:
278
+ *
279
+ * The length of the given vector.
280
+ */
281
+ V3.length = function V3_length(a) {
282
+ //MathUtils_assert(a.length == 3, "a.length == 3");
283
+
284
+ return Math.sqrt(a[0]*a[0] + a[1]*a[1] + a[2]*a[2]);
285
+ };
286
+
287
+ /*
288
+ * Function: V3.lengthSquard
289
+ *
290
+ * Perform r = |a|*|a|.
291
+ *
292
+ * Parameters:
293
+ *
294
+ * a - the vector operand
295
+ *
296
+ * Returns:
297
+ *
298
+ * The square of the length of the given vector.
299
+ */
300
+ V3.lengthSquared = function V3_lengthSquared(a) {
301
+ //MathUtils_assert(a.length == 3, "a.length == 3");
302
+
303
+ return a[0]*a[0] + a[1]*a[1] + a[2]*a[2];
304
+ };
305
+
306
+ /*
307
+ * Function: V3.normalize
308
+ *
309
+ * Perform r = a / |a|.
310
+ *
311
+ * Parameters:
312
+ *
313
+ * a - the vector operand
314
+ * r - optional vector to store the result in
315
+ *
316
+ * Returns:
317
+ *
318
+ * If r is specified, returns r after performing the operation.
319
+ * Otherwise, returns a new 3-element vector with the result.
320
+ */
321
+ V3.normalize = function V3_normalize(a, r) {
322
+ //MathUtils_assert(a.length == 3, "a.length == 3");
323
+ //MathUtils_assert(r == undefined || r.length == 3, "r == undefined || r.length == 3");
324
+
325
+ if (r == undefined)
326
+ r = new MJS_FLOAT_ARRAY_TYPE(3);
327
+ var im = 1.0 / V3.length(a);
328
+ r[0] = a[0] * im;
329
+ r[1] = a[1] * im;
330
+ r[2] = a[2] * im;
331
+ return r;
332
+ };
333
+
334
+ /*
335
+ * Function: V3.scale
336
+ *
337
+ * Perform r = a * k.
338
+ *
339
+ * Parameters:
340
+ *
341
+ * a - the vector operand
342
+ * k - a scalar value
343
+ * r - optional vector to store the result in
344
+ *
345
+ * Returns:
346
+ *
347
+ * If r is specified, returns r after performing the operation.
348
+ * Otherwise, returns a new 3-element vector with the result.
349
+ */
350
+ V3.scale = function V3_scale(a, k, r) {
351
+ //MathUtils_assert(a.length == 3, "a.length == 3");
352
+ //MathUtils_assert(r == undefined || r.length == 3, "r == undefined || r.length == 3");
353
+
354
+ if (r == undefined)
355
+ r = new MJS_FLOAT_ARRAY_TYPE(3);
356
+ r[0] = a[0] * k;
357
+ r[1] = a[1] * k;
358
+ r[2] = a[2] * k;
359
+ return r;
360
+ }
361
+
362
+ /*
363
+ * Function: V3.dot
364
+ *
365
+ * Perform
366
+ * r = dot(a, b).
367
+ *
368
+ * Parameters:
369
+ *
370
+ * a - the first vector operand
371
+ * b - the second vector operand
372
+ *
373
+ * Returns:
374
+ *
375
+ * The dot product of a and b.
376
+ */
377
+ V3.dot = function V3_dot(a, b) {
378
+ //MathUtils_assert(a.length == 3, "a.length == 3");
379
+ //MathUtils_assert(b.length == 3, "b.length == 3");
380
+
381
+ return a[0] * b[0] +
382
+ a[1] * b[1] +
383
+ a[2] * b[2];
384
+ };
385
+
386
+ /*
387
+ * Function: V3.cross
388
+ *
389
+ * Perform r = a x b.
390
+ *
391
+ * Parameters:
392
+ *
393
+ * a - the first vector operand
394
+ * b - the second vector operand
395
+ * r - optional vector to store the result in
396
+ *
397
+ * Returns:
398
+ *
399
+ * If r is specified, returns r after performing the operation.
400
+ * Otherwise, returns a new 3-element vector with the result.
401
+ */
402
+ V3.cross = function V3_cross(a, b, r) {
403
+ //MathUtils_assert(a.length == 3, "a.length == 3");
404
+ //MathUtils_assert(b.length == 3, "b.length == 3");
405
+ //MathUtils_assert(r == undefined || r.length == 3, "r == undefined || r.length == 3");
406
+
407
+ if (r == undefined)
408
+ r = new MJS_FLOAT_ARRAY_TYPE(3);
409
+ r[0] = a[1]*b[2] - a[2]*b[1];
410
+ r[1] = a[2]*b[0] - a[0]*b[2];
411
+ r[2] = a[0]*b[1] - a[1]*b[0];
412
+ return r;
413
+ };
414
+
415
+ /*
416
+ * Class: M4x4
417
+ *
418
+ * Methods for working with 4x4 matrices. A matrix is represented by a 16-element array
419
+ * in column-major order. Any valid JavaScript array type may be used, but if new
420
+ * matrices are created they are created using the configured MJS_FLOAT_ARRAY_TYPE.
421
+ */
422
+
423
+ var M4x4 = { };
424
+
425
+ M4x4._temp1 = new MJS_FLOAT_ARRAY_TYPE(16);
426
+ M4x4._temp2 = new MJS_FLOAT_ARRAY_TYPE(16);
427
+
428
+ if (MJS_FLOAT_ARRAY_TYPE == Array) {
429
+ M4x4.I = [1.0, 0.0, 0.0, 0.0,
430
+ 0.0, 1.0, 0.0, 0.0,
431
+ 0.0, 0.0, 1.0, 0.0,
432
+ 0.0, 0.0, 0.0, 1.0];
433
+
434
+ M4x4.$ = function M4x4_$(m00, m01, m02, m03,
435
+ m04, m05, m06, m07,
436
+ m08, m09, m10, m11,
437
+ m12, m13, m14, m15)
438
+ {
439
+ return [m00, m01, m02, m03,
440
+ m04, m05, m06, m07,
441
+ m08, m09, m10, m11,
442
+ m12, m13, m14, m15];
443
+ };
444
+
445
+ M4x4.clone = function M4x4_clone(m) {
446
+ //MathUtils_assert(m.length == 16, "m.length == 16");
447
+ return new [m[0], m[1], m[2], m[3],
448
+ m[4], m[5], m[6], m[7],
449
+ m[8], m[9], m[10], m[11]];
450
+ };
451
+ } else {
452
+ M4x4.I = new MJS_FLOAT_ARRAY_TYPE([1.0, 0.0, 0.0, 0.0,
453
+ 0.0, 1.0, 0.0, 0.0,
454
+ 0.0, 0.0, 1.0, 0.0,
455
+ 0.0, 0.0, 0.0, 1.0]);
456
+
457
+ /*
458
+ * Function: M4x4.$
459
+ *
460
+ * Creates a new 4x4 matrix with the given values.
461
+ *
462
+ * Parameters:
463
+ *
464
+ * m00..m15 - the 16 elements of the new matrix.
465
+ *
466
+ * Returns:
467
+ *
468
+ * A new matrix filled with the given argument values.
469
+ */
470
+ M4x4.$ = function M4x4_$(m00, m01, m02, m03,
471
+ m04, m05, m06, m07,
472
+ m08, m09, m10, m11,
473
+ m12, m13, m14, m15)
474
+ {
475
+ return new MJS_FLOAT_ARRAY_TYPE([m00, m01, m02, m03,
476
+ m04, m05, m06, m07,
477
+ m08, m09, m10, m11,
478
+ m12, m13, m14, m15]);
479
+ };
480
+
481
+ /*
482
+ * Function: M4x4.clone
483
+ *
484
+ * Clone the given 4x4 matrix.
485
+ *
486
+ * Parameters:
487
+ *
488
+ * m - the 4x4 matrix to clone
489
+ *
490
+ * Returns:
491
+ *
492
+ * A new matrix with the same values as the passed-in one.
493
+ */
494
+ M4x4.clone = function M4x4_clone(m) {
495
+ //MathUtils_assert(m.length == 16, "m.length == 16");
496
+ return new MJS_FLOAT_ARRAY_TYPE(m);
497
+ };
498
+ }
499
+
500
+ M4x4.identity = M4x4.I;
501
+
502
+ /*
503
+ * Function: M4x4.topLeft3x3
504
+ *
505
+ * Return the top left 3x3 matrix from the given 4x4 matrix m.
506
+ *
507
+ * Parameters:
508
+ *
509
+ * m - the matrix
510
+ * r - optional 3x3 matrix to store the result in
511
+ *
512
+ * Returns:
513
+ *
514
+ * If r is specified, returns r after performing the operation.
515
+ * Otherwise, returns a new 3x3 matrix with the result.
516
+ */
517
+ M4x4.topLeft3x3 = function M4x4_topLeft3x3(m, r) {
518
+ //MathUtils_assert(m.length == 16, "m.length == 16");
519
+ //MathUtils_assert(r == undefined || r.length == 9, "r == undefined || r.length == 9");
520
+
521
+ if (r == undefined)
522
+ r = new MJS_FLOAT_ARRAY_TYPE(9);
523
+ r[0] = m[0]; r[1] = m[1]; r[2] = m[2];
524
+ r[3] = m[4]; r[4] = m[5]; r[5] = m[6];
525
+ r[6] = m[8]; r[7] = m[9]; r[8] = m[10];
526
+ return r;
527
+ };
528
+
529
+ /*
530
+ * Function: M4x4.inverseOrthonormal
531
+ *
532
+ * Computes the inverse of the given matrix m, assuming that
533
+ * the matrix is orthonormal.
534
+ *
535
+ * Parameters:
536
+ *
537
+ * m - the matrix
538
+ * r - optional 4x4 matrix to store the result in
539
+ *
540
+ * Returns:
541
+ *
542
+ * If r is specified, returns r after performing the operation.
543
+ * Otherwise, returns a new 4x4 matrix with the result.
544
+ */
545
+ M4x4.inverseOrthonormal = function M4x4_inverseOrthonormal(m, r) {
546
+ //MathUtils_assert(m.length == 16, "m.length == 16");
547
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
548
+ //MathUtils_assert(m != r, "m != r");
549
+
550
+ if (r == undefined)
551
+ r = new MJS_FLOAT_ARRAY_TYPE(16);
552
+ M4x4.transpose(m, r);
553
+ var t = [m[12], m[13], m[14]];
554
+ r[3] = r[7] = r[11] = 0;
555
+ r[12] = -V3.dot([r[0], r[4], r[8]], t);
556
+ r[13] = -V3.dot([r[1], r[5], r[9]], t);
557
+ r[14] = -V3.dot([r[2], r[6], r[10]], t);
558
+ return r;
559
+ }
560
+
561
+ /*
562
+ * Function: M4x4.inverseTo3x3
563
+ *
564
+ * Computes the inverse of the given matrix m, but calculates
565
+ * only the top left 3x3 values of the result.
566
+ *
567
+ * Parameters:
568
+ *
569
+ * m - the matrix
570
+ * r - optional 3x3 matrix to store the result in
571
+ *
572
+ * Returns:
573
+ *
574
+ * If r is specified, returns r after performing the operation.
575
+ * Otherwise, returns a new 3x3 matrix with the result.
576
+ */
577
+ M4x4.inverseTo3x3 = function M4x4_inverseTo3x3(m, r) {
578
+ //MathUtils_assert(m.length == 16, "m.length == 16");
579
+ //MathUtils_assert(r == undefined || r.length == 9, "r == undefined || r.length == 9");
580
+
581
+ if (r == undefined)
582
+ r = new MJS_FLOAT_ARRAY_TYPE(9);
583
+
584
+ var a11 = m[10]*m[5]-m[6]*m[9],
585
+ a21 = -m[10]*m[1]+m[2]*m[9],
586
+ a31 = m[6]*m[1]-m[2]*m[5],
587
+ a12 = -m[10]*m[4]+m[6]*m[8],
588
+ a22 = m[10]*m[0]-m[2]*m[8],
589
+ a32 = -m[6]*m[0]+m[2]*m[4],
590
+ a13 = m[9]*m[4]-m[5]*m[8],
591
+ a23 = -m[9]*m[0]+m[1]*m[8],
592
+ a33 = m[5]*m[0]-m[1]*m[4];
593
+ var det = m[0]*(a11) + m[1]*(a12) + m[2]*(a13);
594
+ if (det == 0) // no inverse
595
+ throw "matrix not invertible";
596
+ var idet = 1.0 / det;
597
+
598
+ r[0] = idet*a11;
599
+ r[1] = idet*a21;
600
+ r[2] = idet*a31;
601
+ r[3] = idet*a12;
602
+ r[4] = idet*a22;
603
+ r[5] = idet*a32;
604
+ r[6] = idet*a13;
605
+ r[7] = idet*a23;
606
+ r[8] = idet*a33;
607
+
608
+ return r;
609
+ };
610
+
611
+ /*
612
+ * Function: M4x4.makeFrustum
613
+ *
614
+ * Creates a matrix for a projection frustum with the given parameters.
615
+ *
616
+ * Parameters:
617
+ *
618
+ * left - the left coordinate of the frustum
619
+ * right- the right coordinate of the frustum
620
+ * bottom - the bottom coordinate of the frustum
621
+ * top - the top coordinate of the frustum
622
+ * znear - the near z distance of the frustum
623
+ * zfar - the far z distance of the frustum
624
+ * r - optional 4x4 matrix to store the result in
625
+ *
626
+ * Returns:
627
+ *
628
+ * If r is specified, returns r after creating the projection matrix.
629
+ * Otherwise, returns a new 4x4 matrix.
630
+ */
631
+ M4x4.makeFrustum = function M4x4_makeFrustum(left, right, bottom, top, znear, zfar, r) {
632
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
633
+
634
+ if (r == undefined)
635
+ r = new MJS_FLOAT_ARRAY_TYPE(16);
636
+
637
+ var X = 2*znear/(right-left);
638
+ var Y = 2*znear/(top-bottom);
639
+ var A = (right+left)/(right-left);
640
+ var B = (top+bottom)/(top-bottom);
641
+ var C = -(zfar+znear)/(zfar-znear);
642
+ var D = -2*zfar*znear/(zfar-znear);
643
+
644
+ r[0] = 2*znear/(right-left);
645
+ r[1] = 0;
646
+ r[2] = 0;
647
+ r[3] = 0;
648
+ r[4] = 0;
649
+ r[5] = 2*znear/(top-bottom);
650
+ r[6] = 0;
651
+ r[7] = 0;
652
+ r[8] = (right+left)/(right-left);
653
+ r[9] = (top+bottom)/(top-bottom);
654
+ r[10] = -(zfar+znear)/(zfar-znear);
655
+ r[11] = -1;
656
+ r[12] = 0;
657
+ r[13] = 0;
658
+ r[14] = -2*zfar*znear/(zfar-znear);
659
+ r[15] = 0;
660
+
661
+ return r;
662
+ };
663
+
664
+ /*
665
+ * Function: M4x4.makePerspective
666
+ *
667
+ * Creates a matrix for a perspective projection with the given parameters.
668
+ *
669
+ * Parameters:
670
+ *
671
+ * fovy - field of view in the y axis, in degrees
672
+ * aspect - aspect ratio
673
+ * znear - the near z distance of the projection
674
+ * zfar - the far z distance of the projection
675
+ * r - optional 4x4 matrix to store the result in
676
+ *
677
+ * Returns:
678
+ *
679
+ * If r is specified, returns r after creating the projection matrix.
680
+ * Otherwise, returns a new 4x4 matrix.
681
+ */
682
+ M4x4.makePerspective = function M4x4_makePerspective (fovy, aspect, znear, zfar, r) {
683
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
684
+
685
+ var ymax = znear * Math.tan(fovy * Math.PI / 360.0);
686
+ var ymin = -ymax;
687
+ var xmin = ymin * aspect;
688
+ var xmax = ymax * aspect;
689
+
690
+ return M4x4.makeFrustum(xmin, xmax, ymin, ymax, znear, zfar, r);
691
+ };
692
+
693
+ /*
694
+ * Function: M4x4.makeOrtho
695
+ *
696
+ * Creates a matrix for an orthogonal frustum projection with the given parameters.
697
+ *
698
+ * Parameters:
699
+ *
700
+ * left - the left coordinate of the frustum
701
+ * right- the right coordinate of the frustum
702
+ * bottom - the bottom coordinate of the frustum
703
+ * top - the top coordinate of the frustum
704
+ * znear - the near z distance of the frustum
705
+ * zfar - the far z distance of the frustum
706
+ * r - optional 4x4 matrix to store the result in
707
+ *
708
+ * Returns:
709
+ *
710
+ * If r is specified, returns r after creating the projection matrix.
711
+ * Otherwise, returns a new 4x4 matrix.
712
+ */
713
+ M4x4.makeOrtho = function M4x4_makeOrtho (left, right, bottom, top, znear, zfar, r) {
714
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
715
+
716
+ if (r == undefined)
717
+ r = new MJS_FLOAT_ARRAY_TYPE(16);
718
+
719
+ var tX = -(right+left)/(right-left);
720
+ var tY = -(top+bottom)/(top-bottom);
721
+ var tZ = -(zfar+znear)/(zfar-znear);
722
+ var X = 2 / (right-left);
723
+ var Y = 2 / (top-bottom);
724
+ var Z = -2 / (zfar-znear);
725
+
726
+ r[0] = 2 / (right-left);
727
+ r[1] = 0;
728
+ r[2] = 0;
729
+ r[3] = 0;
730
+ r[4] = 0;
731
+ r[5] = 2 / (top-bottom);
732
+ r[6] = 0;
733
+ r[7] = 0;
734
+ r[8] = 0;
735
+ r[9] = 0;
736
+ r[10] = -2 / (zfar-znear);
737
+ r[11] = 0;
738
+ r[12] = -(right+left)/(right-left);
739
+ r[13] = -(top+bottom)/(top-bottom);
740
+ r[14] = -(zfar+znear)/(zfar-znear);
741
+ r[15] = 0;
742
+
743
+ return r;
744
+ };
745
+
746
+ /*
747
+ * Function: M4x4.makeOrtho
748
+ *
749
+ * Creates a matrix for a 2D orthogonal frustum projection with the given parameters.
750
+ * znear and zfar are assumed to be -1 and 1, respectively.
751
+ *
752
+ * Parameters:
753
+ *
754
+ * left - the left coordinate of the frustum
755
+ * right- the right coordinate of the frustum
756
+ * bottom - the bottom coordinate of the frustum
757
+ * top - the top coordinate of the frustum
758
+ * r - optional 4x4 matrix to store the result in
759
+ *
760
+ * Returns:
761
+ *
762
+ * If r is specified, returns r after creating the projection matrix.
763
+ * Otherwise, returns a new 4x4 matrix.
764
+ */
765
+ M4x4.makeOrtho2D = function M4x4_makeOrtho2D (left, right, bottom, top, r) {
766
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
767
+
768
+ return M4x4.makeOrtho(left, right, bottom, top, -1, 1, r);
769
+ };
770
+
771
+ /*
772
+ * Function: M4x4.mul
773
+ *
774
+ * Performs r = a * b.
775
+ *
776
+ * Parameters:
777
+ *
778
+ * a - the first matrix operand
779
+ * b - the second matrix operand
780
+ * r - optional 4x4 matrix to store the result in
781
+ *
782
+ * Returns:
783
+ *
784
+ * If r is specified, returns r after performing the operation.
785
+ * Otherwise, returns a new 4x4 matrix with the result.
786
+ */
787
+ M4x4.mul = function M4x4_mul(a, b, r) {
788
+ //MathUtils_assert(a.length == 16, "a.length == 16");
789
+ //MathUtils_assert(b.length == 16, "b.length == 16");
790
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
791
+ //MathUtils_assert(a != r && b != r, "a != r && b != r");
792
+
793
+ if (r == undefined)
794
+ r = new MJS_FLOAT_ARRAY_TYPE(16);
795
+
796
+ r[0] =
797
+ b[0] * a[0] +
798
+ b[0+1] * a[4] +
799
+ b[0+2] * a[8] +
800
+ b[0+3] * a[12];
801
+ r[0+1] =
802
+ b[0] * a[1] +
803
+ b[0+1] * a[5] +
804
+ b[0+2] * a[9] +
805
+ b[0+3] * a[13];
806
+ r[0+2] =
807
+ b[0] * a[2] +
808
+ b[0+1] * a[6] +
809
+ b[0+2] * a[10] +
810
+ b[0+3] * a[14];
811
+ r[0+3] =
812
+ b[0] * a[3] +
813
+ b[0+1] * a[7] +
814
+ b[0+2] * a[11] +
815
+ b[0+3] * a[15];
816
+ r[4] =
817
+ b[4] * a[0] +
818
+ b[4+1] * a[4] +
819
+ b[4+2] * a[8] +
820
+ b[4+3] * a[12];
821
+ r[4+1] =
822
+ b[4] * a[1] +
823
+ b[4+1] * a[5] +
824
+ b[4+2] * a[9] +
825
+ b[4+3] * a[13];
826
+ r[4+2] =
827
+ b[4] * a[2] +
828
+ b[4+1] * a[6] +
829
+ b[4+2] * a[10] +
830
+ b[4+3] * a[14];
831
+ r[4+3] =
832
+ b[4] * a[3] +
833
+ b[4+1] * a[7] +
834
+ b[4+2] * a[11] +
835
+ b[4+3] * a[15];
836
+ r[8] =
837
+ b[8] * a[0] +
838
+ b[8+1] * a[4] +
839
+ b[8+2] * a[8] +
840
+ b[8+3] * a[12];
841
+ r[8+1] =
842
+ b[8] * a[1] +
843
+ b[8+1] * a[5] +
844
+ b[8+2] * a[9] +
845
+ b[8+3] * a[13];
846
+ r[8+2] =
847
+ b[8] * a[2] +
848
+ b[8+1] * a[6] +
849
+ b[8+2] * a[10] +
850
+ b[8+3] * a[14];
851
+ r[8+3] =
852
+ b[8] * a[3] +
853
+ b[8+1] * a[7] +
854
+ b[8+2] * a[11] +
855
+ b[8+3] * a[15];
856
+ r[12] =
857
+ b[12] * a[0] +
858
+ b[12+1] * a[4] +
859
+ b[12+2] * a[8] +
860
+ b[12+3] * a[12];
861
+ r[12+1] =
862
+ b[12] * a[1] +
863
+ b[12+1] * a[5] +
864
+ b[12+2] * a[9] +
865
+ b[12+3] * a[13];
866
+ r[12+2] =
867
+ b[12] * a[2] +
868
+ b[12+1] * a[6] +
869
+ b[12+2] * a[10] +
870
+ b[12+3] * a[14];
871
+ r[12+3] =
872
+ b[12] * a[3] +
873
+ b[12+1] * a[7] +
874
+ b[12+2] * a[11] +
875
+ b[12+3] * a[15];
876
+ return r;
877
+ };
878
+
879
+ /*
880
+ * Function: M4x4.makeRotate
881
+ *
882
+ * Creates a transformation matrix for rotation by angle radians about the 3-element vector axis.
883
+ *
884
+ * Parameters:
885
+ *
886
+ * angle - the angle of rotation, in radians
887
+ * axis - the axis around which the rotation is performed, a 3-element vector
888
+ * r - optional 4x4 matrix to store the result in
889
+ *
890
+ * Returns:
891
+ *
892
+ * If r is specified, returns r after creating the matrix.
893
+ * Otherwise, returns a new 4x4 matrix with the result.
894
+ */
895
+ M4x4.makeRotate = function M4x4_makeRotate(angle, axis, r) {
896
+ //MathUtils_assert(angle.length == 3, "angle.length == 3");
897
+ //MathUtils_assert(axis.length == 3, "axis.length == 3");
898
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
899
+
900
+ if (r == undefined)
901
+ r = new MJS_FLOAT_ARRAY_TYPE(16);
902
+
903
+ axis = V3.normalize(axis, V3._temp1);
904
+ var x = axis[0], y = axis[1], z = axis[2];
905
+ var c = Math.cos(angle);
906
+ var c1 = 1-c;
907
+ var s = Math.sin(angle);
908
+
909
+ r[0] = x*x*c1+c;
910
+ r[1] = y*x*c1+z*s;
911
+ r[2] = z*x*c1-y*s;
912
+ r[3] = 0;
913
+ r[4] = x*y*c1-z*s;
914
+ r[5] = y*y*c1+c;
915
+ r[6] = y*z*c1+x*s;
916
+ r[7] = 0;
917
+ r[8] = x*z*c1+y*s;
918
+ r[9] = y*z*c1-x*s;
919
+ r[10] = z*z*c1+c;
920
+ r[11] = 0;
921
+ r[12] = 0;
922
+ r[13] = 0;
923
+ r[14] = 0;
924
+ r[15] = 1;
925
+
926
+ return r;
927
+ };
928
+
929
+ /*
930
+ * Function: M4x4.rotate
931
+ *
932
+ * Concatenates a rotation of angle radians about the axis to the give matrix m.
933
+ *
934
+ * Parameters:
935
+ *
936
+ * angle - the angle of rotation, in radians
937
+ * axis - the axis around which the rotation is performed, a 3-element vector
938
+ * m - the matrix to concatenate the rotation to
939
+ * r - optional 4x4 matrix to store the result in
940
+ *
941
+ * Returns:
942
+ *
943
+ * If r is specified, returns r after performing the operation.
944
+ * Otherwise, returns a new 4x4 matrix with the result.
945
+ */
946
+ M4x4.rotate = function M4x4_rotate(angle, axis, m, r) {
947
+ //MathUtils_assert(angle.length == 3, "angle.length == 3");
948
+ //MathUtils_assert(axis.length == 3, "axis.length == 3");
949
+ //MathUtils_assert(m.length == 16, "m.length == 16");
950
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
951
+
952
+ M4x4.makeRotate(angle, axis, M4x4._temp1);
953
+ return M4x4.mul(m, M4x4._temp1, r);
954
+ };
955
+
956
+ /*
957
+ * Function: M4x4.makeScale3
958
+ *
959
+ * Creates a transformation matrix for scaling by 3 scalar values, one for
960
+ * each of the x, y, and z directions.
961
+ *
962
+ * Parameters:
963
+ *
964
+ * x - the scale for the x axis
965
+ * y - the scale for the y axis
966
+ * z - the scale for the z axis
967
+ * r - optional 4x4 matrix to store the result in
968
+ *
969
+ * Returns:
970
+ *
971
+ * If r is specified, returns r after creating the matrix.
972
+ * Otherwise, returns a new 4x4 matrix with the result.
973
+ */
974
+ M4x4.makeScale3 = function M4x4_makeScale3(x, y, z, r) {
975
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
976
+
977
+ if (r == undefined)
978
+ r = new MJS_FLOAT_ARRAY_TYPE(16);
979
+
980
+ r[0] = x;
981
+ r[1] = 0;
982
+ r[2] = 0;
983
+ r[3] = 0;
984
+ r[4] = 0;
985
+ r[5] = y;
986
+ r[6] = 0;
987
+ r[7] = 0;
988
+ r[8] = 0;
989
+ r[9] = 0;
990
+ r[10] = z;
991
+ r[11] = 0;
992
+ r[12] = 0;
993
+ r[13] = 0;
994
+ r[14] = 0;
995
+ r[15] = 1;
996
+
997
+ return r;
998
+ };
999
+
1000
+ /*
1001
+ * Function: M4x4.makeScale1
1002
+ *
1003
+ * Creates a transformation matrix for a uniform scale by a single scalar value.
1004
+ *
1005
+ * Parameters:
1006
+ *
1007
+ * k - the scale factor
1008
+ * r - optional 4x4 matrix to store the result in
1009
+ *
1010
+ * Returns:
1011
+ *
1012
+ * If r is specified, returns r after creating the matrix.
1013
+ * Otherwise, returns a new 4x4 matrix with the result.
1014
+ */
1015
+ M4x4.makeScale1 = function M4x4_makeScale1(k, r) {
1016
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
1017
+
1018
+ return M4x4.makeScale3(k, k, k, r);
1019
+ };
1020
+
1021
+ /*
1022
+ * Function: M4x4.makeScale
1023
+ *
1024
+ * Creates a transformation matrix for scaling each of the x, y, and z axes by the amount
1025
+ * given in the corresponding element of the 3-element vector.
1026
+ *
1027
+ * Parameters:
1028
+ *
1029
+ * v - the 3-element vector containing the scale factors
1030
+ * r - optional 4x4 matrix to store the result in
1031
+ *
1032
+ * Returns:
1033
+ *
1034
+ * If r is specified, returns r after creating the matrix.
1035
+ * Otherwise, returns a new 4x4 matrix with the result.
1036
+ */
1037
+ M4x4.makeScale = function M4x4_makeScale(v, r) {
1038
+ //MathUtils_assert(v.length == 3, "v.length == 3");
1039
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
1040
+
1041
+ return M4x4.makeScale3(v[0], v[1], v[2], r);
1042
+ };
1043
+
1044
+ /*
1045
+ * Function: M4x4.scale3
1046
+ */
1047
+ M4x4.scale3 = function M4x4_scale3(x, y, z, m, r) {
1048
+ //MathUtils_assert(m.length == 16, "m.length == 16");
1049
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
1050
+
1051
+ M4x4.makeScale3(x, y, z, M4x4._temp1);
1052
+ return M4x4.mul(m, M4x4._temp1, r);
1053
+ };
1054
+
1055
+ /*
1056
+ * Function: M4x4.scale1
1057
+ */
1058
+ M4x4.scale1 = function M4x4_scale1(k, m, r) {
1059
+ //MathUtils_assert(m.length == 16, "m.length == 16");
1060
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
1061
+
1062
+ M4x4.makeScale3(k, k, k, M4x4._temp1);
1063
+ return M4x4.mul(m, M4x4._temp1, r);
1064
+ };
1065
+
1066
+ /*
1067
+ * Function: M4x4.scale1
1068
+ */
1069
+ M4x4.scale = function M4x4_scale(v, m, r) {
1070
+ //MathUtils_assert(v.length == 3, "v.length == 3");
1071
+ //MathUtils_assert(m.length == 16, "m.length == 16");
1072
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
1073
+
1074
+ M4x4.makeScale3(v[0], v[1], v[2], M4x4._temp1);
1075
+ return M4x4.mul(m, M4x4._temp1, r);
1076
+ };
1077
+
1078
+ /*
1079
+ * Function: M4x4.makeTranslate3
1080
+ */
1081
+ M4x4.makeTranslate3 = function M4x4_makeTranslate3(x, y, z, r) {
1082
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
1083
+
1084
+ if (r == undefined)
1085
+ r = new MJS_FLOAT_ARRAY_TYPE(16);
1086
+
1087
+ r[0] = 1;
1088
+ r[1] = 0;
1089
+ r[2] = 0;
1090
+ r[3] = 0;
1091
+ r[4] = 0;
1092
+ r[5] = 1;
1093
+ r[6] = 0;
1094
+ r[7] = 0;
1095
+ r[8] = 0;
1096
+ r[9] = 0;
1097
+ r[10] = 1;
1098
+ r[11] = 0;
1099
+ r[12] = x;
1100
+ r[13] = y;
1101
+ r[14] = z;
1102
+ r[15] = 1;
1103
+
1104
+ return r;
1105
+ };
1106
+
1107
+ /*
1108
+ * Function: M4x4.makeTranslate1
1109
+ */
1110
+ M4x4.makeTranslate1 = function M4x4_makeTranslate1 (k, r) {
1111
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
1112
+
1113
+ return M4x4.makeTranslate3(k, k, k, r);
1114
+ };
1115
+
1116
+ /*
1117
+ * Function: M4x4.makeTranslate
1118
+ */
1119
+ M4x4.makeTranslate = function M4x4_makeTranslate (v, r) {
1120
+ //MathUtils_assert(v.length == 3, "v.length == 3");
1121
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
1122
+
1123
+ return M4x4.makeTranslate3(v[0], v[1], v[2], r);
1124
+ };
1125
+
1126
+ /*
1127
+ * Function: M4x4.translate3
1128
+ */
1129
+ M4x4.translate3 = function M4x4_translate3 (x, y, z, m, r) {
1130
+ //MathUtils_assert(m.length == 16, "m.length == 16");
1131
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
1132
+
1133
+ M4x4.makeTranslate3(x, y, z, M4x4._temp1);
1134
+ return M4x4.mul(m, M4x4._temp1, r);
1135
+ };
1136
+
1137
+ /*
1138
+ * Function: M4x4.translate1
1139
+ */
1140
+ M4x4.translate1 = function M4x4_translate1 (k, m, r) {
1141
+ //MathUtils_assert(m.length == 16, "m.length == 16");
1142
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
1143
+
1144
+ M4x4.makeTranslate3(k, k, k, M4x4._temp1);
1145
+ return M4x4.mul(m, M4x4._temp1, r);
1146
+ };
1147
+
1148
+ /*
1149
+ * Function: M4x4.translate
1150
+ */
1151
+ M4x4.translate = function M4x4_translate (v, m, r) {
1152
+ //MathUtils_assert(v.length == 3, "v.length == 3");
1153
+ //MathUtils_assert(m.length == 16, "m.length == 16");
1154
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
1155
+
1156
+ M4x4.makeTranslate3(v[0], v[1], v[2], M4x4._temp1);
1157
+ return M4x4.mul(m, M4x4._temp1, r);
1158
+ };
1159
+
1160
+ /*
1161
+ * Function: M4x4.makeLookAt
1162
+ */
1163
+ M4x4.makeLookAt = function M4x4_makeLookAt (eye, center, up, r) {
1164
+ //MathUtils_assert(eye.length == 3, "eye.length == 3");
1165
+ //MathUtils_assert(center.length == 3, "center.length == 3");
1166
+ //MathUtils_assert(up.length == 3, "up.length == 3");
1167
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
1168
+
1169
+ var z = V3.direction(eye, center, V3._temp1);
1170
+ var x = V3.normalize(V3.cross(up, z, V3._temp2), V3._temp2);
1171
+ var y = V3.normalize(V3.cross(z, x, V3._temp3), V3._temp3);
1172
+
1173
+ var tm1 = M4x4._temp1;
1174
+ var tm2 = M4x4._temp2;
1175
+
1176
+ tm1[0] = x[0];
1177
+ tm1[1] = y[0];
1178
+ tm1[2] = z[0];
1179
+ tm1[3] = 0;
1180
+ tm1[4] = x[1];
1181
+ tm1[5] = y[1];
1182
+ tm1[6] = z[1];
1183
+ tm1[7] = 0;
1184
+ tm1[8] = x[2];
1185
+ tm1[9] = y[2];
1186
+ tm1[10] = z[2];
1187
+ tm1[11] = 0;
1188
+ tm1[12] = 0;
1189
+ tm1[13] = 0;
1190
+ tm1[14] = 0;
1191
+ tm1[15] = 1;
1192
+
1193
+ tm2[0] = 1; tm2[1] = 0; tm2[2] = 0; tm2[3] = 0;
1194
+ tm2[4] = 0; tm2[5] = 1; tm2[6] = 0; tm2[7] = 0;
1195
+ tm2[8] = 0; tm2[9] = 0; tm2[10] = 1; tm2[3] = 0;
1196
+ tm2[0] = -eye[0]; tm2[1] = -eye[1]; tm2[2] = -eye[2]; tm2[3] = 0;
1197
+
1198
+ if (r == undefined)
1199
+ r = new MJS_FLOAT_ARRAY_TYPE(16);
1200
+ return M4x4.mul(tm1, tm2, r);
1201
+ };
1202
+
1203
+ /*
1204
+ * Function: M4x4.transpose
1205
+ */
1206
+ M4x4.transpose = function M4x4_transpose (m, r) {
1207
+ //MathUtils_assert(m.length == 16, "m.length == 16");
1208
+ //MathUtils_assert(r == undefined || r.length == 16, "r == undefined || r.length == 16");
1209
+
1210
+ if (m == r) {
1211
+ var tmp = 0.0;
1212
+ tmp = m[1]; m[1] = m[4]; m[4] = tmp;
1213
+ tmp = m[2]; m[2] = m[8]; m[8] = tmp;
1214
+ tmp = m[3]; m[3] = m[12]; m[12] = tmp;
1215
+ tmp = m[6]; m[6] = m[9]; m[9] = tmp;
1216
+ tmp = m[7]; m[7] = m[13]; m[13] = tmp;
1217
+ tmp = m[11]; m[11] = m[14]; m[14] = tmp;
1218
+ return m;
1219
+ }
1220
+
1221
+ if (r == undefined)
1222
+ r = new MJS_FLOAT_ARRAY_TYPE(16);
1223
+
1224
+ r[0] = m[0]; r[1] = m[4]; r[2] = m[8]; r[3] = m[12];
1225
+ r[4] = m[1]; r[5] = m[5]; r[6] = m[9]; r[7] = m[13];
1226
+ r[8] = m[2]; r[9] = m[6]; r[10] = m[10]; r[11] = m[14];
1227
+ r[12] = m[3]; r[13] = m[7]; r[14] = m[11]; r[15] = m[15];
1228
+
1229
+ return r;
1230
+ };