jax 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (473) hide show
  1. data/.gitignore +4 -0
  2. data/.rvmrc +2 -3
  3. data/.travis.yml +8 -22
  4. data/README.md +2 -2
  5. data/Rakefile +128 -96
  6. data/app/assets/javascripts/jax/controller-list.js.coffee +22 -0
  7. data/app/assets/javascripts/jax/dom-helpers.js.coffee +17 -0
  8. data/app/assets/javascripts/jax/jasmine_runner.js +177 -0
  9. data/app/assets/javascripts/jax/runtime.js +6 -0
  10. data/app/assets/javascripts/jax/shader_editor.js.coffee +33 -0
  11. data/app/assets/stylesheets/jax/controller-list.css +5 -0
  12. data/app/assets/stylesheets/jax/jasmine.css +16 -0
  13. data/app/assets/stylesheets/jax/nav.css +41 -0
  14. data/app/assets/stylesheets/jax/runtime.css +47 -0
  15. data/app/assets/stylesheets/jax/shader_editor.css +3 -0
  16. data/app/assets/stylesheets/jax/suite.css +82 -0
  17. data/app/controllers/jax/suite_controller.rb +48 -0
  18. data/app/views/jax/suite/jasmine.html.erb +38 -0
  19. data/app/views/jax/suite/run_webgl.html.erb +49 -0
  20. data/app/views/jax/suite/shader_editor.html.erb +24 -0
  21. data/app/views/layouts/jax.html.erb +40 -0
  22. data/bin/jax +8 -4
  23. data/config/routes.rb +2 -0
  24. data/config.ru +5 -0
  25. data/features/rails/resources.feature +45 -0
  26. data/features/rails/shaders.feature +13 -0
  27. data/features/rails/specs.feature +24 -0
  28. data/features/runtime.feature +15 -0
  29. data/features/step_definitions/environment_steps.rb +15 -0
  30. data/features/step_definitions/response_steps.rb +13 -0
  31. data/features/step_definitions/runtime.rb +11 -0
  32. data/features/step_definitions/web_steps.rb +223 -0
  33. data/features/support/env.rb +75 -0
  34. data/features/support/paths.rb +30 -0
  35. data/features/support/rails_environment.rb +3 -0
  36. data/features/support/selectors.rb +39 -0
  37. data/features/support/setup.rb +17 -0
  38. data/jax.gemspec +22 -16
  39. data/lib/assets/javascripts/jax/anim_frame.js +64 -0
  40. data/lib/assets/javascripts/jax/application.js +16 -0
  41. data/lib/assets/javascripts/jax/builtin/all.js +21 -0
  42. data/lib/assets/javascripts/jax/builtin/meshes/cube.js +83 -0
  43. data/lib/assets/javascripts/jax/builtin/meshes/plane.js +67 -0
  44. data/lib/assets/javascripts/jax/builtin/meshes/quad.js +89 -0
  45. data/lib/assets/javascripts/jax/builtin/meshes/sphere.js +65 -0
  46. data/lib/assets/javascripts/jax/builtin/meshes/teapot.js +48 -0
  47. data/lib/assets/javascripts/jax/builtin/meshes/torus.js +64 -0
  48. data/lib/assets/javascripts/jax/compatibility.js +312 -0
  49. data/lib/assets/javascripts/jax/context.js +741 -0
  50. data/lib/assets/javascripts/jax/core/base.js +69 -0
  51. data/lib/assets/javascripts/jax/core/glMatrix_ext/mat3.js +20 -0
  52. data/lib/assets/javascripts/jax/core/glMatrix_ext/mat4.js +10 -0
  53. data/lib/assets/javascripts/jax/core/glMatrix_ext/quat4.js +148 -0
  54. data/lib/assets/javascripts/jax/core/glMatrix_ext/vec2.js +25 -0
  55. data/lib/assets/javascripts/jax/core/glMatrix_ext/vec3.js +86 -0
  56. data/lib/assets/javascripts/jax/core/glMatrix_ext/vec4.js +28 -0
  57. data/lib/assets/javascripts/jax/core/helper.js +44 -0
  58. data/lib/assets/javascripts/jax/core/math.js +61 -0
  59. data/lib/assets/javascripts/jax/core/matrix_stack.js +310 -0
  60. data/lib/assets/javascripts/jax/core/util.js +271 -0
  61. data/lib/assets/javascripts/jax/core.js +43 -0
  62. data/lib/assets/javascripts/jax/events.js +304 -0
  63. data/lib/assets/javascripts/jax/geometry/line.js +185 -0
  64. data/lib/assets/javascripts/jax/geometry/plane.js +371 -0
  65. data/lib/assets/javascripts/jax/geometry/triangle/inliner.rb +94 -0
  66. data/lib/assets/javascripts/jax/geometry/triangle/slow_tri_tri_intersect.js +20 -0
  67. data/lib/assets/javascripts/jax/geometry/triangle/tri_tri_intersect.js +281 -0
  68. data/lib/assets/javascripts/jax/geometry/triangle/tri_tri_intersect_optimized.js +564 -0
  69. data/lib/assets/javascripts/jax/geometry/triangle.js +311 -0
  70. data/lib/assets/javascripts/jax/geometry.js +14 -0
  71. data/lib/assets/javascripts/jax/mvc/controller.js +188 -0
  72. data/lib/assets/javascripts/jax/mvc/model.js +302 -0
  73. data/lib/assets/javascripts/jax/mvc/route_set.js +148 -0
  74. data/lib/assets/javascripts/jax/mvc/view.js +43 -0
  75. data/lib/assets/javascripts/jax/mvc/view_manager.js +65 -0
  76. data/lib/assets/javascripts/jax/noise.js +251 -0
  77. data/lib/assets/javascripts/jax/prototype/class.js +81 -0
  78. data/lib/assets/javascripts/jax/prototype/core.js +112 -0
  79. data/lib/assets/javascripts/jax/prototype/extensions.js +142 -0
  80. data/lib/assets/javascripts/jax/vendor/ejs.js +1 -0
  81. data/lib/assets/javascripts/jax/vendor/glMatrix.js +7 -0
  82. data/lib/assets/javascripts/jax/webgl/camera.js +697 -0
  83. data/lib/assets/javascripts/jax/webgl/cleanup.js +1 -0
  84. data/lib/assets/javascripts/jax/webgl/core/buffer.js +292 -0
  85. data/lib/assets/javascripts/jax/webgl/core/data_region.js +184 -0
  86. data/lib/assets/javascripts/jax/webgl/core/data_segment.js +255 -0
  87. data/lib/assets/javascripts/jax/webgl/core/events.js +99 -0
  88. data/lib/assets/javascripts/jax/webgl/core/framebuffer.js +316 -0
  89. data/lib/assets/javascripts/jax/webgl/core.js +6 -0
  90. data/lib/assets/javascripts/jax/webgl/material.js +381 -0
  91. data/lib/assets/javascripts/jax/webgl/mesh/normals.js +37 -0
  92. data/lib/assets/javascripts/jax/webgl/mesh/support.js +104 -0
  93. data/lib/assets/javascripts/jax/webgl/mesh/tangent_space.js +111 -0
  94. data/lib/assets/javascripts/jax/webgl/mesh.js +440 -0
  95. data/lib/assets/javascripts/jax/webgl/scene/frustum.js +422 -0
  96. data/lib/assets/javascripts/jax/webgl/scene/light_manager.js +141 -0
  97. data/lib/assets/javascripts/jax/webgl/scene/light_source.js +300 -0
  98. data/lib/assets/javascripts/jax/webgl/scene.js +16 -0
  99. data/lib/assets/javascripts/jax/webgl/shader/delegator/attribute.js +53 -0
  100. data/lib/assets/javascripts/jax/webgl/shader/delegator/uniform.js +71 -0
  101. data/lib/assets/javascripts/jax/webgl/shader/delegator.js +13 -0
  102. data/lib/assets/javascripts/jax/webgl/shader/manifest.js +70 -0
  103. data/lib/assets/javascripts/jax/webgl/shader/program.js +138 -0
  104. data/lib/assets/javascripts/jax/webgl/shader.js +299 -0
  105. data/lib/assets/javascripts/jax/webgl/shader_chain.js +267 -0
  106. data/lib/assets/javascripts/jax/webgl/texture.js +506 -0
  107. data/lib/assets/javascripts/jax/webgl/world.js +279 -0
  108. data/lib/assets/javascripts/jax/webgl.js +109 -0
  109. data/lib/assets/javascripts/jax.js +136 -0
  110. data/{builtin/app/shaders/basic/common.ejs → lib/assets/javascripts/shaders/basic/common.glsl} +0 -0
  111. data/{builtin/app/shaders/basic/fragment.ejs → lib/assets/javascripts/shaders/basic/fragment.glsl} +0 -0
  112. data/{builtin/app/shaders/basic/vertex.ejs → lib/assets/javascripts/shaders/basic/vertex.glsl} +1 -1
  113. data/{builtin/app/shaders/depthmap/common.ejs → lib/assets/javascripts/shaders/depthmap/common.glsl} +0 -0
  114. data/{builtin/app/shaders/depthmap/fragment.ejs → lib/assets/javascripts/shaders/depthmap/fragment.glsl} +1 -1
  115. data/{builtin/app → lib/assets/javascripts}/shaders/depthmap/material.js +0 -0
  116. data/{builtin/app/shaders/depthmap/vertex.ejs → lib/assets/javascripts/shaders/depthmap/vertex.glsl} +0 -0
  117. data/{builtin/app/shaders/fog/common.ejs → lib/assets/javascripts/shaders/fog/common.glsl} +0 -0
  118. data/{builtin/app/shaders/fog/fragment.ejs → lib/assets/javascripts/shaders/fog/fragment.glsl} +0 -0
  119. data/{builtin/app → lib/assets/javascripts}/shaders/fog/manifest.yml +0 -0
  120. data/{builtin/app → lib/assets/javascripts}/shaders/fog/material.js +6 -8
  121. data/{builtin/app/shaders/fog/vertex.ejs → lib/assets/javascripts/shaders/fog/vertex.glsl} +0 -0
  122. data/{builtin/app/shaders/functions/depth_map.ejs → lib/assets/javascripts/shaders/functions/depth_map.glsl} +0 -0
  123. data/{builtin/app/shaders/functions/lights.ejs → lib/assets/javascripts/shaders/functions/lights.glsl} +0 -0
  124. data/{builtin/app/shaders/functions/noise.ejs → lib/assets/javascripts/shaders/functions/noise.glsl} +0 -0
  125. data/lib/assets/javascripts/shaders/lighting/common.glsl +5 -0
  126. data/{builtin/app/shaders/lighting/fragment.ejs → lib/assets/javascripts/shaders/lighting/fragment.glsl} +0 -0
  127. data/{builtin/app → lib/assets/javascripts}/shaders/lighting/manifest.yml +0 -0
  128. data/{builtin/app → lib/assets/javascripts}/shaders/lighting/material.js +2 -4
  129. data/{builtin/app/shaders/lighting/vertex.ejs → lib/assets/javascripts/shaders/lighting/vertex.glsl} +0 -0
  130. data/{builtin/app/shaders/normal_map/common.ejs → lib/assets/javascripts/shaders/normal_map/common.glsl} +1 -1
  131. data/{builtin/app/shaders/normal_map/fragment.ejs → lib/assets/javascripts/shaders/normal_map/fragment.glsl} +0 -0
  132. data/{builtin/app → lib/assets/javascripts}/shaders/normal_map/manifest.yml +0 -0
  133. data/lib/assets/javascripts/shaders/normal_map/material.js +11 -0
  134. data/{builtin/app/shaders/normal_map/vertex.ejs → lib/assets/javascripts/shaders/normal_map/vertex.glsl} +0 -0
  135. data/{builtin/app/shaders/paraboloid/common.ejs → lib/assets/javascripts/shaders/paraboloid/common.glsl} +0 -0
  136. data/{builtin/app/shaders/paraboloid/fragment.ejs → lib/assets/javascripts/shaders/paraboloid/fragment.glsl} +0 -0
  137. data/{builtin/app → lib/assets/javascripts}/shaders/paraboloid/manifest.yml +0 -0
  138. data/{builtin/app → lib/assets/javascripts}/shaders/paraboloid/material.js +2 -4
  139. data/{builtin/app/shaders/paraboloid/vertex.ejs → lib/assets/javascripts/shaders/paraboloid/vertex.glsl} +0 -0
  140. data/{builtin/app/shaders/picking/common.ejs → lib/assets/javascripts/shaders/picking/common.glsl} +0 -0
  141. data/{builtin/app/shaders/picking/fragment.ejs → lib/assets/javascripts/shaders/picking/fragment.glsl} +0 -0
  142. data/{builtin/app → lib/assets/javascripts}/shaders/picking/material.js +2 -4
  143. data/{builtin/app/shaders/picking/vertex.ejs → lib/assets/javascripts/shaders/picking/vertex.glsl} +0 -0
  144. data/{builtin/app/shaders/shadow_map/common.ejs → lib/assets/javascripts/shaders/shadow_map/common.glsl} +2 -1
  145. data/{builtin/app/shaders/shadow_map/fragment.ejs → lib/assets/javascripts/shaders/shadow_map/fragment.glsl} +1 -1
  146. data/{builtin/app → lib/assets/javascripts}/shaders/shadow_map/manifest.yml +0 -0
  147. data/{builtin/app → lib/assets/javascripts}/shaders/shadow_map/material.js +4 -6
  148. data/{builtin/app/shaders/shadow_map/vertex.ejs → lib/assets/javascripts/shaders/shadow_map/vertex.glsl} +0 -0
  149. data/{builtin/app/shaders/texture/common.ejs → lib/assets/javascripts/shaders/texture/common.glsl} +0 -0
  150. data/{builtin/app/shaders/texture/fragment.ejs → lib/assets/javascripts/shaders/texture/fragment.glsl} +0 -0
  151. data/{builtin/app → lib/assets/javascripts}/shaders/texture/manifest.yml +0 -0
  152. data/lib/assets/javascripts/shaders/texture/material.js +17 -0
  153. data/{builtin/app/shaders/texture/vertex.ejs → lib/assets/javascripts/shaders/texture/vertex.glsl} +0 -0
  154. data/lib/generators/jax/all.rb +16 -0
  155. data/lib/generators/jax/application/application_generator.rb +48 -0
  156. data/lib/generators/jax/base/actions.rb +52 -0
  157. data/lib/generators/jax/base/coffee_generator.rb +30 -0
  158. data/lib/generators/jax/base/named_base.rb +17 -0
  159. data/lib/generators/jax/base/plugin_base.rb +108 -0
  160. data/lib/generators/jax/base/plugin_credentials.rb +99 -0
  161. data/lib/generators/jax/base/plugin_manifest.rb +75 -0
  162. data/lib/generators/jax/base/rails_base.rb +30 -0
  163. data/lib/generators/jax/base/source_root.rb +5 -0
  164. data/lib/generators/jax/controller/controller_generator.rb +37 -0
  165. data/lib/generators/jax/helper/helper_generator.rb +30 -0
  166. data/lib/generators/jax/install/install_generator.rb +27 -0
  167. data/lib/generators/jax/jax_generator.rb +13 -0
  168. data/lib/generators/jax/light/light_generator.rb +23 -0
  169. data/lib/{jax/generators → generators/jax}/material/USAGE +4 -8
  170. data/lib/generators/jax/material/material_generator.rb +112 -0
  171. data/lib/generators/jax/model/model_generator.rb +24 -0
  172. data/lib/generators/jax/plugin/plugin_generator.rb +72 -0
  173. data/lib/generators/jax/scaffold/scaffold_generator.rb +35 -0
  174. data/lib/generators/jax/shader/shader_generator.rb +38 -0
  175. data/lib/jax/commands/plugin_manager.rb +240 -0
  176. data/lib/jax/commands.rb +69 -0
  177. data/lib/jax/configuration.rb +64 -0
  178. data/lib/jax/directive_processor.rb +53 -0
  179. data/lib/jax/engine.rb +38 -54
  180. data/lib/jax/helper_methods.rb +3 -0
  181. data/lib/jax/rails/application.rb +34 -0
  182. data/lib/jax/resource_file.rb +29 -0
  183. data/lib/jax/script_loader.rb +68 -0
  184. data/lib/jax/server.rb +87 -0
  185. data/lib/jax/shader.rb +70 -172
  186. data/lib/jax/testing/rails_environment.rb +94 -0
  187. data/lib/jax/util/tar.rb +75 -0
  188. data/lib/jax/util.rb +3 -0
  189. data/lib/jax/version.rb +7 -8
  190. data/lib/jax.rb +23 -41
  191. data/spec/bin/jax_spec.rb +149 -0
  192. data/{lib/jax/generators/app/templates/app/models/.empty_directory → spec/fixtures/public/favicon.ico} +0 -0
  193. data/spec/fixtures/public/textures/brickwall.jpg +0 -0
  194. data/spec/fixtures/public/textures/jacks.jpg +0 -0
  195. data/spec/fixtures/public/textures/normal_map.jpg +0 -0
  196. data/spec/fixtures/public/textures/rock.png +0 -0
  197. data/spec/fixtures/public/textures/rock_normal.png +0 -0
  198. data/spec/fixtures/public/textures/rss.png +0 -0
  199. data/spec/generators/jax/application_generator_spec.rb +18 -0
  200. data/spec/generators/jax/controller_generator_spec.rb +102 -0
  201. data/spec/generators/jax/helper_generator_spec.rb +55 -0
  202. data/spec/generators/jax/install_generator_spec.rb +30 -0
  203. data/spec/generators/jax/jax_generator_spec.rb +21 -0
  204. data/spec/generators/jax/light_generator_spec.rb +27 -0
  205. data/spec/generators/jax/material_generator_spec.rb +62 -0
  206. data/spec/generators/jax/model_generator_spec.rb +72 -0
  207. data/spec/generators/jax/plugin_generator_spec.rb +143 -0
  208. data/spec/generators/jax/scaffold_generator_spec.rb +35 -0
  209. data/spec/generators/jax/shader_generator_spec.rb +37 -0
  210. data/spec/javascripts/helpers/jasmine_webgl_helper.js +13 -0
  211. data/{lib/jax/generators/app/templates/spec/javascripts/support/spec_helpers → spec/javascripts/helpers}/jax_spec_environment_helper.js +7 -2
  212. data/{lib/jax/generators/app/templates/spec/javascripts/support/spec_helpers → spec/javascripts/helpers}/jax_spec_helper.js +0 -0
  213. data/spec/javascripts/jax/builtin/meshes/cube_spec.js +10 -0
  214. data/spec/javascripts/jax/builtin/meshes/plane_spec.js +8 -0
  215. data/spec/javascripts/jax/builtin/meshes/quad_spec.js +8 -0
  216. data/spec/javascripts/jax/builtin/meshes/sphere_spec.js +8 -0
  217. data/spec/javascripts/jax/builtin/meshes/teapot_spec.js +8 -0
  218. data/spec/javascripts/jax/builtin/meshes/torus_spec.js +8 -0
  219. data/spec/javascripts/jax/compatibility_spec.js +46 -0
  220. data/spec/javascripts/jax/context_events_spec.js +212 -0
  221. data/spec/javascripts/jax/context_spec.js +305 -0
  222. data/spec/javascripts/jax/core/data_region_spec.js +118 -0
  223. data/spec/javascripts/jax/core/data_segment_spec.js +96 -0
  224. data/spec/javascripts/jax/core/delegation_spec.js +48 -0
  225. data/spec/javascripts/jax/core/events_spec.js +17 -0
  226. data/spec/javascripts/jax/core/glMatrix_extensions_spec.js +8 -0
  227. data/spec/javascripts/jax/core/helper_spec.js +61 -0
  228. data/spec/javascripts/jax/core/matrix_stack_spec.js +28 -0
  229. data/spec/javascripts/jax/core/utils_spec.js +275 -0
  230. data/spec/javascripts/jax/geometry/line_spec.js +20 -0
  231. data/spec/javascripts/jax/geometry/plane_spec.js +181 -0
  232. data/spec/javascripts/jax/geometry/triangle_spec.js +105 -0
  233. data/spec/javascripts/jax/mvc/controller_spec.js +156 -0
  234. data/spec/javascripts/jax/mvc/model_spec.js +93 -0
  235. data/spec/javascripts/jax/mvc/route_set_spec.js +49 -0
  236. data/spec/javascripts/jax/mvc/view_manager_spec.js +17 -0
  237. data/spec/javascripts/jax/noise_spec.js +50 -0
  238. data/spec/javascripts/jax/optimizations/material_limitations_spec.js +85 -0
  239. data/spec/javascripts/jax/optimizations/shaders/basic_spec.js +65 -0
  240. data/spec/javascripts/jax/prototype/extensions_spec.js +34 -0
  241. data/spec/javascripts/jax/webgl/camera_spec.js +237 -0
  242. data/spec/javascripts/jax/webgl/core/events_spec.js +47 -0
  243. data/spec/javascripts/jax/webgl/framebuffer_spec.js +44 -0
  244. data/spec/javascripts/jax/webgl/lighting_spec.js +108 -0
  245. data/spec/javascripts/jax/webgl/material_spec.js +117 -0
  246. data/spec/javascripts/jax/webgl/mesh_spec.js +228 -0
  247. data/spec/javascripts/jax/webgl/shader/manifest_spec.js +57 -0
  248. data/spec/javascripts/jax/webgl/shader_chain_spec.js +211 -0
  249. data/spec/javascripts/jax/webgl/shader_spec.js +276 -0
  250. data/spec/javascripts/jax/webgl/tangent_space_spec.js +142 -0
  251. data/spec/javascripts/jax/webgl/texture_spec.js +159 -0
  252. data/spec/javascripts/jax/webgl_spec.js +5 -0
  253. data/spec/javascripts/jax/world_spec.js +175 -0
  254. data/spec/javascripts/jax_spec.js +14 -0
  255. data/spec/javascripts/node/mocks/webgl.js +159 -0
  256. data/spec/javascripts/node_helper.js +51 -0
  257. data/spec/javascripts/shaders/core_materials_spec.js +38 -0
  258. data/spec/javascripts/shaders/fog_spec.js +15 -0
  259. data/spec/javascripts/shaders/lighting_spec.js +15 -0
  260. data/spec/javascripts/shaders/normal_map_spec.js +15 -0
  261. data/spec/javascripts/shaders/paraboloid_spec.js +33 -0
  262. data/spec/javascripts/shaders/preprocessor_spec.js +45 -0
  263. data/spec/javascripts/shaders/shadow_map_spec.js +15 -0
  264. data/spec/javascripts/shaders/texture_spec.js +37 -0
  265. data/spec/javascripts/suite/controller_select_spec.js.coffee +24 -0
  266. data/spec/lib/jax/commands/plugin_manager/credentials_spec.rb +56 -0
  267. data/spec/lib/jax/commands/plugin_manager/push_spec.rb +62 -0
  268. data/spec/lib/jax/commands/plugin_manager_spec.rb +204 -0
  269. data/spec/lib/jax/rails/application_spec.rb +23 -0
  270. data/spec/lib/jax/shader_spec.rb +67 -0
  271. data/spec/lib/jax/util/tar_spec.rb +26 -0
  272. data/spec/{test_helper.rb → spec_helper.rb} +37 -28
  273. data/spec/support/test_model_generator.rb +14 -0
  274. data/templates/app/Gemfile.tt +17 -0
  275. data/templates/app/Rakefile +4 -0
  276. data/templates/app/config/application.rb +16 -0
  277. data/{lib/jax/generators/app/templates → templates/app}/config/boot.rb +0 -0
  278. data/templates/app/config/environment.rb +5 -0
  279. data/templates/app/config/environments/production.rb +4 -0
  280. data/templates/app/config.ru +6 -0
  281. data/{lib/jax/generators/app/templates/app/resources → templates/app/public}/.empty_directory +0 -0
  282. data/templates/app/script/jax +8 -0
  283. data/{lib/jax/generators/app/templates/app/views → templates/app/spec}/.empty_directory +0 -0
  284. data/templates/application_controller.js.coffee.erb +3 -0
  285. data/templates/application_controller.js.erb +6 -0
  286. data/templates/application_helper.js.coffee.erb +3 -0
  287. data/templates/application_helper.js.erb +3 -0
  288. data/templates/controller.js.coffee.erb +9 -0
  289. data/templates/controller.js.erb +15 -0
  290. data/templates/controller_spec.js.coffee.erb +9 -0
  291. data/templates/controller_spec.js.erb +12 -0
  292. data/templates/helper.js.coffee.erb +2 -0
  293. data/templates/helper.js.erb +3 -0
  294. data/templates/helper_spec.js.coffee.erb +8 -0
  295. data/templates/helper_spec.js.erb +12 -0
  296. data/{lib/jax/generators/light_source/templates/light.yml.tt → templates/light_source.resource.erb} +3 -3
  297. data/{lib/jax/generators/material/templates/material.yml.tt → templates/material.resource.erb} +0 -9
  298. data/templates/model.js.coffee.erb +3 -0
  299. data/templates/model.js.erb +5 -0
  300. data/templates/model_defaults.resource.erb +5 -0
  301. data/templates/model_spec.js.coffee.erb +16 -0
  302. data/templates/model_spec.js.erb +18 -0
  303. data/{lib/jax/generators/plugin/templates/new_plugin/app → templates/new_plugin/app/assets/jax}/controllers/.empty_directory +0 -0
  304. data/{lib/jax/generators/plugin/templates/new_plugin/app → templates/new_plugin/app/assets/jax}/helpers/.empty_directory +0 -0
  305. data/{lib/jax/generators/plugin/templates/new_plugin/app → templates/new_plugin/app/assets/jax}/models/.empty_directory +0 -0
  306. data/{lib/jax/generators/plugin/templates/new_plugin/app → templates/new_plugin/app/assets/jax}/resources/.empty_directory +0 -0
  307. data/{lib/jax/generators/plugin/templates/new_plugin/app → templates/new_plugin/app/assets/jax}/views/.empty_directory +0 -0
  308. data/{lib/jax/generators/plugin/templates → templates}/new_plugin/init.rb +0 -0
  309. data/{lib/jax/generators/plugin/templates → templates}/new_plugin/install.rb +0 -0
  310. data/{lib/jax/generators/plugin/templates/new_plugin/public → templates/new_plugin/spec}/.empty_directory +0 -0
  311. data/{lib/jax/generators/plugin/templates → templates}/new_plugin/uninstall.rb +0 -0
  312. data/{lib/jax/generators/shader/templates/common.ejs.tt → templates/shader_common.glsl.erb} +0 -0
  313. data/{lib/jax/generators/shader/templates/fragment.ejs.tt → templates/shader_fragment.glsl.erb} +0 -0
  314. data/{lib/jax/generators/shader/templates/manifest.yml.tt → templates/shader_manifest.yml.erb} +0 -0
  315. data/templates/shader_material.js.coffee.erb +22 -0
  316. data/{lib/jax/generators/shader/templates/material.js.tt → templates/shader_material.js.erb} +0 -0
  317. data/templates/shader_spec.js.coffee.erb +16 -0
  318. data/{lib/jax/generators/shader/templates/spec.js.tt → templates/shader_spec.js.erb} +1 -1
  319. data/{lib/jax/generators/shader/templates/vertex.ejs.tt → templates/shader_vertex.glsl.erb} +0 -0
  320. data/templates/view.js.coffee.erb +3 -0
  321. data/{lib/jax/generators/controller/templates/view.js.tt → templates/view.js.erb} +1 -1
  322. data/vendor/assets/javascripts/ejs.js +505 -0
  323. data/vendor/assets/javascripts/glMatrix.js +1772 -0
  324. data/vendor/assets/javascripts/jasmine.js +2476 -0
  325. data/vendor/assets/stylesheets/jasmine.css +166 -0
  326. data/vendor/pdoc_template/html/assets/images/pdoc/alias.png +0 -0
  327. data/vendor/pdoc_template/html/assets/images/pdoc/class.png +0 -0
  328. data/vendor/pdoc_template/html/assets/images/pdoc/class_deprecated.png +0 -0
  329. data/vendor/pdoc_template/html/assets/images/pdoc/class_method.png +0 -0
  330. data/vendor/pdoc_template/html/assets/images/pdoc/class_property.png +0 -0
  331. data/vendor/pdoc_template/html/assets/images/pdoc/constant.png +0 -0
  332. data/vendor/pdoc_template/html/assets/images/pdoc/constructor.png +0 -0
  333. data/vendor/pdoc_template/html/assets/images/pdoc/deprecated.png +0 -0
  334. data/vendor/pdoc_template/html/assets/images/pdoc/description.png +0 -0
  335. data/vendor/pdoc_template/html/assets/images/pdoc/information.png +0 -0
  336. data/vendor/pdoc_template/html/assets/images/pdoc/instance_method.png +0 -0
  337. data/vendor/pdoc_template/html/assets/images/pdoc/instance_property.png +0 -0
  338. data/vendor/pdoc_template/html/assets/images/pdoc/method.png +0 -0
  339. data/vendor/pdoc_template/html/assets/images/pdoc/method_deprecated.png +0 -0
  340. data/vendor/pdoc_template/html/assets/images/pdoc/mixin.png +0 -0
  341. data/vendor/pdoc_template/html/assets/images/pdoc/namespace.png +0 -0
  342. data/vendor/pdoc_template/html/assets/images/pdoc/property.png +0 -0
  343. data/vendor/pdoc_template/html/assets/images/pdoc/related_to.png +0 -0
  344. data/vendor/pdoc_template/html/assets/images/pdoc/search-background.png +0 -0
  345. data/vendor/pdoc_template/html/assets/images/pdoc/section-background.png +0 -0
  346. data/vendor/pdoc_template/html/assets/images/pdoc/section.png +0 -0
  347. data/vendor/pdoc_template/html/assets/images/pdoc/selected-section-background.png +0 -0
  348. data/vendor/pdoc_template/html/assets/images/pdoc/subclass.png +0 -0
  349. data/vendor/pdoc_template/html/assets/images/pdoc/superclass.png +0 -0
  350. data/vendor/pdoc_template/html/assets/images/pdoc/utility.png +0 -0
  351. data/vendor/pdoc_template/html/assets/javascripts/pdoc/application.js +478 -0
  352. data/vendor/pdoc_template/html/assets/javascripts/pdoc/prototype.js +4874 -0
  353. data/vendor/pdoc_template/html/assets/javascripts/pdoc/tabs.js +506 -0
  354. data/vendor/pdoc_template/html/assets/stylesheets/jax.css +30 -0
  355. data/vendor/pdoc_template/html/assets/stylesheets/pdoc/api.css +681 -0
  356. data/vendor/pdoc_template/html/assets/stylesheets/pdoc/pygments.css +62 -0
  357. data/vendor/pdoc_template/html/helpers.rb +35 -0
  358. data/vendor/pdoc_template/html/index.erb +18 -0
  359. data/vendor/pdoc_template/html/item_index.js.erb +6 -0
  360. data/vendor/pdoc_template/html/layout.erb +67 -0
  361. data/vendor/pdoc_template/html/leaf.erb +22 -0
  362. data/vendor/pdoc_template/html/node.erb +30 -0
  363. data/vendor/pdoc_template/html/partials/class_relationships.erb +19 -0
  364. data/vendor/pdoc_template/html/partials/classes.erb +7 -0
  365. data/vendor/pdoc_template/html/partials/constructor.erb +5 -0
  366. data/vendor/pdoc_template/html/partials/description.erb +5 -0
  367. data/vendor/pdoc_template/html/partials/link_list.erb +1 -0
  368. data/vendor/pdoc_template/html/partials/method_signatures.erb +14 -0
  369. data/vendor/pdoc_template/html/partials/methodized_note.erb +9 -0
  370. data/vendor/pdoc_template/html/partials/mixins.erb +7 -0
  371. data/vendor/pdoc_template/html/partials/namespaces.erb +7 -0
  372. data/vendor/pdoc_template/html/partials/related_utilities.erb +5 -0
  373. data/vendor/pdoc_template/html/partials/relationships.erb +11 -0
  374. data/vendor/pdoc_template/html/partials/short_description_list.erb +7 -0
  375. data/vendor/pdoc_template/html/partials/title.erb +24 -0
  376. data/vendor/pdoc_template/html/section.erb +18 -0
  377. metadata +635 -332
  378. data/builtin/app/shaders/lighting/common.ejs +0 -5
  379. data/builtin/app/shaders/normal_map/material.js +0 -16
  380. data/builtin/app/shaders/texture/material.js +0 -18
  381. data/jax.gems +0 -1
  382. data/lib/jax/application/builtin/configurable.rb +0 -5
  383. data/lib/jax/application/builtin/configuration.rb +0 -5
  384. data/lib/jax/application/builtin.rb +0 -12
  385. data/lib/jax/application/configurable.rb +0 -19
  386. data/lib/jax/application/configuration.rb +0 -60
  387. data/lib/jax/application/railties.rb +0 -26
  388. data/lib/jax/application.rb +0 -149
  389. data/lib/jax/core_ext/kernel.rb +0 -7
  390. data/lib/jax/engine/configurable.rb +0 -19
  391. data/lib/jax/engine/configuration.rb +0 -49
  392. data/lib/jax/generators/app/app_generator.rb +0 -96
  393. data/lib/jax/generators/app/templates/Gemfile.tt +0 -3
  394. data/lib/jax/generators/app/templates/Rakefile +0 -6
  395. data/lib/jax/generators/app/templates/app/controllers/application_controller.js.tt +0 -5
  396. data/lib/jax/generators/app/templates/app/helpers/application_helper.js.tt +0 -3
  397. data/lib/jax/generators/app/templates/config/application.rb.tt +0 -6
  398. data/lib/jax/generators/app/templates/config/environment.rb.tt +0 -5
  399. data/lib/jax/generators/app/templates/config/routes.rb.tt +0 -5
  400. data/lib/jax/generators/app/templates/public/index.html.tt +0 -26
  401. data/lib/jax/generators/app/templates/public/javascripts/jax.js +0 -9462
  402. data/lib/jax/generators/app/templates/public/stylesheets/%file_name%.css.tt +0 -11
  403. data/lib/jax/generators/app/templates/public/webgl_not_supported.html +0 -26
  404. data/lib/jax/generators/app/templates/script/jax +0 -7
  405. data/lib/jax/generators/app/templates/spec/javascripts/controllers/application_controller_spec.js +0 -11
  406. data/lib/jax/generators/app/templates/spec/javascripts/helpers/application_helper_spec.js +0 -12
  407. data/lib/jax/generators/app/templates/spec/javascripts/support/jasmine.yml +0 -91
  408. data/lib/jax/generators/app/templates/spec/javascripts/support/jasmine_config.rb +0 -23
  409. data/lib/jax/generators/app/templates/spec/javascripts/support/jasmine_runner.rb +0 -32
  410. data/lib/jax/generators/app/templates/spec/javascripts/support/spec_layout.html.erb +0 -104
  411. data/lib/jax/generators/app.rb +0 -18
  412. data/lib/jax/generators/commands.rb +0 -220
  413. data/lib/jax/generators/controller/USAGE +0 -9
  414. data/lib/jax/generators/controller/controller_generator.rb +0 -66
  415. data/lib/jax/generators/controller/templates/controller_source.js.tt +0 -16
  416. data/lib/jax/generators/controller/templates/controller_test.js.tt +0 -11
  417. data/lib/jax/generators/controller/templates/helper.js.tt +0 -3
  418. data/lib/jax/generators/controller/templates/helper_test.js.tt +0 -12
  419. data/lib/jax/generators/interactions.rb +0 -56
  420. data/lib/jax/generators/light_source/USAGE +0 -14
  421. data/lib/jax/generators/light_source/light_source_generator.rb +0 -46
  422. data/lib/jax/generators/material/material_generator.rb +0 -80
  423. data/lib/jax/generators/material/templates/append.yml.tt +0 -7
  424. data/lib/jax/generators/model/USAGE +0 -5
  425. data/lib/jax/generators/model/model_generator.rb +0 -40
  426. data/lib/jax/generators/model/templates/model.js.tt +0 -11
  427. data/lib/jax/generators/model/templates/test.js.tt +0 -11
  428. data/lib/jax/generators/packager/package_generator.rb +0 -32
  429. data/lib/jax/generators/plugin/USAGE +0 -4
  430. data/lib/jax/generators/plugin/all.rb +0 -113
  431. data/lib/jax/generators/plugin/credentials.rb +0 -108
  432. data/lib/jax/generators/plugin/plugin_generator.rb +0 -72
  433. data/lib/jax/generators/plugin/plugin_manager.rb +0 -254
  434. data/lib/jax/generators/plugin/templates/new_plugin/config/routes.rb +0 -3
  435. data/lib/jax/generators/plugin/templates/new_plugin/spec/.empty_directory +0 -0
  436. data/lib/jax/generators/script_jax_loader.rb +0 -49
  437. data/lib/jax/generators/shader/USAGE +0 -4
  438. data/lib/jax/generators/shader/shader_generator.rb +0 -70
  439. data/lib/jax/monkeypatch/jasmine/config.rb +0 -45
  440. data/lib/jax/monkeypatch/jasmine/server.rb +0 -50
  441. data/lib/jax/monkeypatch/jasmine.rb +0 -3
  442. data/lib/jax/packager/sprockets_template.rb +0 -77
  443. data/lib/jax/packager.rb +0 -59
  444. data/lib/jax/plugin/manifest.rb +0 -71
  445. data/lib/jax/plugin.rb +0 -49
  446. data/lib/jax/resource_compiler.rb +0 -60
  447. data/lib/jax/routes.rb +0 -62
  448. data/lib/jax/tasks/rake.rb +0 -38
  449. data/spec/benchmark.htm +0 -93
  450. data/spec/generators/app_generator_test.rb +0 -42
  451. data/spec/generators/controller_generator_test.rb +0 -47
  452. data/spec/generators/light_generator_test.rb +0 -37
  453. data/spec/generators/material_generator_test.rb +0 -22
  454. data/spec/generators/model_generator_test.rb +0 -26
  455. data/spec/generators/plugin_generator_test.rb +0 -114
  456. data/spec/generators/plugin_manager/push_test.rb +0 -59
  457. data/spec/generators/plugin_manager_test.rb +0 -192
  458. data/spec/generators/shader_generator_test.rb +0 -38
  459. data/spec/javascripts/support/jasmine.yml +0 -85
  460. data/spec/javascripts/support/jasmine_runner.rb +0 -32
  461. data/spec/lib/jax/application_test.rb +0 -18
  462. data/spec/lib/jax/generators/plugin/credentials_test.rb +0 -72
  463. data/spec/lib/jax/packager_test.rb +0 -87
  464. data/spec/lib/jax/plugin_test.rb +0 -27
  465. data/spec/lib/jax/reloading_test.rb +0 -23
  466. data/spec/lib/jax/routes_test.rb +0 -28
  467. data/spec/lib/jax/shader_test.rb +0 -29
  468. data/spec/lib/jax/tasks/jax_rake_test.rb +0 -85
  469. data/spec/support/bases/generator_test_case.rb +0 -108
  470. data/spec/support/bases/isolated_test_case.rb +0 -148
  471. data/spec/support/file_exist_matcher.rb +0 -23
  472. data/spec/support/spec_shell.rb +0 -110
  473. data/spec/test_app.rb +0 -3
@@ -0,0 +1,251 @@
1
+ /**
2
+ * class Jax.Noise
3
+ * Constructs several textures to be used in vertex shaders involving Perlin noise.
4
+ * As of v1.1.0, Jax defines a global variable called **Jax.noise** that you can use
5
+ * instead of maintaining your own instance of +Jax.Noise+. This is both more memory
6
+ * efficient and easier to use.
7
+ *
8
+ * Example:
9
+ *
10
+ * setUniforms: function($super, context, mesh, options, uniforms) {
11
+ * $super(context, mesh, options, uniforms);
12
+ *
13
+ * Jax.noise.bind(context, uniforms);
14
+ *
15
+ * // . . .
16
+ * }
17
+ *
18
+ **/
19
+ Jax.Noise = (function() {
20
+ var perm/*[256]*/ = [151,160,137,91,90,15,
21
+ 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
22
+ 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
23
+ 88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
24
+ 77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
25
+ 102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
26
+ 135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
27
+ 5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
28
+ 223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9,
29
+ 129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
30
+ 251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
31
+ 49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254,
32
+ 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];
33
+
34
+ /* These are Ken Perlin's proposed gradients for 3D noise. I kept them for
35
+ better consistency with the reference implementation, but there is really
36
+ no need to pad this to 16 gradients for this particular implementation.
37
+ If only the "proper" first 12 gradients are used, they can be extracted
38
+ from the grad4[][] array: grad3[i][j] == grad4[i*2][j], 0<=i<=11, j=0,1,2
39
+ */
40
+ var grad3/*[16][3]*/ = [0,1,1, 0,1,-1, 0,-1,1, 0,-1,-1,
41
+ 1,0,1, 1,0,-1, -1,0,1, -1,0,-1,
42
+ 1,1,0, 1,-1,0, -1,1,0, -1,-1,0, // 12 cube edges
43
+ 1,0,-1, -1,0,-1, 0,-1,1, 0,1,1]; // 4 more to make 16
44
+
45
+ /* These are my own proposed gradients for 4D noise. They are the coordinates
46
+ of the midpoints of each of the 32 edges of a tesseract, just like the 3D
47
+ noise gradients are the midpoints of the 12 edges of a cube.
48
+ */
49
+ var grad4/*[32][4]*/ = [0,1,1,1, 0,1,1,-1, 0,1,-1,1, 0,1,-1,-1, // 32 tesseract edges
50
+ 0,-1,1,1, 0,-1,1,-1, 0,-1,-1,1, 0,-1,-1,-1,
51
+ 1,0,1,1, 1,0,1,-1, 1,0,-1,1, 1,0,-1,-1,
52
+ -1,0,1,1, -1,0,1,-1, -1,0,-1,1, -1,0,-1,-1,
53
+ 1,1,0,1, 1,1,0,-1, 1,-1,0,1, 1,-1,0,-1,
54
+ -1,1,0,1, -1,1,0,-1, -1,-1,0,1, -1,-1,0,-1,
55
+ 1,1,1,0, 1,1,-1,0, 1,-1,1,0, 1,-1,-1,0,
56
+ -1,1,1,0, -1,1,-1,0, -1,-1,1,0, -1,-1,-1,0];
57
+
58
+ /* This is a look-up table to speed up the decision on which simplex we
59
+ are in inside a cube or hypercube "cell" for 3D and 4D simplex noise.
60
+ It is used to avoid complicated nested conditionals in the GLSL code.
61
+ The table is indexed in GLSL with the results of six pair-wise
62
+ comparisons beween the components of the P=(x,y,z,w) coordinates
63
+ within a hypercube cell.
64
+ c1 = x>=y ? 32 : 0;
65
+ c2 = x>=z ? 16 : 0;
66
+ c3 = y>=z ? 8 : 0;
67
+ c4 = x>=w ? 4 : 0;
68
+ c5 = y>=w ? 2 : 0;
69
+ c6 = z>=w ? 1 : 0;
70
+ offsets = simplex[c1+c2+c3+c4+c5+c6];
71
+ o1 = step(160,offsets);
72
+ o2 = step(96,offsets);
73
+ o3 = step(32,offsets);
74
+ (For the 3D case, c4, c5, c6 and o3 are not needed.)
75
+ */
76
+ var simplex4/*[][4]*/ = [0,64,128,192, 0,64,192,128, 0,0,0,0, 0,128,192,64,
77
+ 0,0,0,0, 0,0,0,0, 0,0,0,0, 64,128,192,0,
78
+ 0,128,64,192, 0,0,0,0, 0,192,64,128, 0,192,128,64,
79
+ 0,0,0,0, 0,0,0,0, 0,0,0,0, 64,192,128,0,
80
+ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
81
+ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
82
+ 64,128,0,192, 0,0,0,0, 64,192,0,128, 0,0,0,0,
83
+ 0,0,0,0, 0,0,0,0, 128,192,0,64, 128,192,64,0,
84
+ 64,0,128,192, 64,0,192,128, 0,0,0,0, 0,0,0,0,
85
+ 0,0,0,0, 128,0,192,64, 0,0,0,0, 128,64,192,0,
86
+ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
87
+ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
88
+ 128,0,64,192, 0,0,0,0, 0,0,0,0, 0,0,0,0,
89
+ 192,0,64,128, 192,0,128,64, 0,0,0,0, 192,64,128,0,
90
+ 128,64,0,192, 0,0,0,0, 0,0,0,0, 0,0,0,0,
91
+ 192,64,0,128, 0,0,0,0, 192,128,0,64, 192,128,64,0];
92
+
93
+ var simplex_buf = null, perm_buf = null, grad_buf = null;
94
+
95
+ /*
96
+ * initPermTexture() - create and load a 2D texture for
97
+ * a combined index permutation and gradient lookup table.
98
+ * This texture is used for 2D and 3D noise, both classic and simplex.
99
+ */
100
+ function initPermTexture(context)
101
+ {
102
+ var tex = new Jax.Texture({min_filter: GL_NEAREST, mag_filter: GL_NEAREST, width:256, height:256});
103
+
104
+ if (!perm_buf) {
105
+ var pixels = new Array(256*256*4);
106
+ var i,j;
107
+ for(i = 0; i<256; i++)
108
+ for(j = 0; j<256; j++) {
109
+ var offset = (i*256+j)*4;
110
+ var value = perm[(j+perm[i]) & 0xFF];
111
+ var g = (value & 0x0F) * 3;
112
+ pixels[offset] = grad3[g+0] * 64 + 64; // Gradient x
113
+ pixels[offset+1] = grad3[g+1] * 64 + 64; // Gradient y
114
+ pixels[offset+2] = grad3[g+2] * 64 + 64; // Gradient z
115
+ pixels[offset+3] = value; // Permuted index
116
+ }
117
+ perm_buf = new Uint8Array(pixels);
118
+ }
119
+
120
+ return tex;
121
+ }
122
+
123
+ /*
124
+ * initSimplexTexture() - create and load a 1D texture for a
125
+ * simplex traversal order lookup table. This is used for simplex noise only,
126
+ * and only for 3D and 4D noise where there are more than 2 simplices.
127
+ * (3D simplex noise has 6 cases to sort out, 4D simplex noise has 24 cases.)
128
+ */
129
+ function initSimplexTexture(context)
130
+ {
131
+ // webgl doesn't support 1D so we'll simulate it with a 64x1 texture
132
+
133
+ if (!simplex_buf) simplex_buf = new Uint8Array(simplex4);
134
+ var tex = new Jax.Texture({min_filter:GL_NEAREST,mag_filter:GL_NEAREST, width:64, height:1});
135
+ return tex;
136
+ }
137
+
138
+ /*
139
+ * initGradTexture(context) - create and load a 2D texture
140
+ * for a 4D gradient lookup table. This is used for 4D noise only.
141
+ */
142
+ function initGradTexture(context)
143
+ {
144
+ var tex = new Jax.Texture({min_filter: GL_NEAREST, mag_filter: GL_NEAREST, width:256, height:256});
145
+
146
+ if (!grad_buf) {
147
+ var pixels = new Array(256*256*4);
148
+ var i,j;
149
+
150
+ for(i = 0; i<256; i++)
151
+ for(j = 0; j<256; j++) {
152
+ var offset = (i*256+j)*4;
153
+ var value = perm[(j+perm[i]) & 0xFF];
154
+ var g = (value & 0x1F) * 4;
155
+ pixels[offset] = grad4[g+0] * 64 + 64; // Gradient x
156
+ pixels[offset+1] = grad4[g+1] * 64 + 64; // Gradient y
157
+ pixels[offset+2] = grad4[g+2] * 64 + 64; // Gradient z
158
+ pixels[offset+3] = grad4[g+3] * 64 + 64; // Gradient z
159
+ }
160
+
161
+ grad_buf = new Uint8Array(pixels);
162
+ }
163
+
164
+ return tex;
165
+ }
166
+
167
+ function prepareAll(self, context) {
168
+ if (!perm_buf || !simplex_buf || !grad_buf)
169
+ throw new Error("Unknown error: one of the noise buffers is null!");
170
+
171
+ self.perm.bind(context, function() {
172
+ context.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, perm_buf);
173
+ });
174
+ self.simplex.bind(context, function() {
175
+ context.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, simplex_buf);
176
+ });
177
+ self.grad.bind(context, function() {
178
+ context.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, grad_buf);
179
+ });
180
+ }
181
+
182
+ return Jax.Class.create({
183
+ initialize: function(context) {
184
+ /**
185
+ * Jax.Noise#perm -> Jax.Texture
186
+ * A 2D texture for a combined index permutation and gradient lookup table.
187
+ * This texture is used for both 2D and 3D noise, both classic and simplex.
188
+ **/
189
+ this.perm = initPermTexture(context);
190
+
191
+ /**
192
+ * Jax.Noise#simplex -> Jax.Texture
193
+ * A 1D texture for a simplex transversal order lookup table. This is used
194
+ * for simplex noise only, and only for 3D and 4D noise where there are more
195
+ * than 2 simplices. (3D simplex noise has 6 cases to sort out, 4D simplex
196
+ * noise has 24 cases.)
197
+ *
198
+ * Note that WebGL does not support 1D textures, so this is technically a
199
+ * 2D texture with a height of 1 pixel.
200
+ **/
201
+ this.simplex = initSimplexTexture(context);
202
+
203
+ /**
204
+ * Jax.Noise#grad -> Jax.Texture
205
+ * A 2D texture for a 4D gradient lookup table. This is used for 4D noise
206
+ * only.
207
+ **/
208
+ this.grad = initGradTexture(context);
209
+
210
+ if (context) prepareAll(this, context);
211
+ },
212
+
213
+ /**
214
+ * Jax.Noise#bind(context, uniforms) -> Jax.Shader.Delegator
215
+ * - context (Jax.Context): the context to bind the noise textures to
216
+ * - uniforms (Jax.Shader.Delegator): the shader variables to bind this noise to.
217
+ *
218
+ * Binds the three noise textures to the given set of shader uniforms. This is
219
+ * intended to be used from within a shader's +material.js+ file like so:
220
+ *
221
+ * setUniforms: function($super, context, mesh, options, uniforms) {
222
+ * $super(context, mesh, options, uniforms);
223
+ *
224
+ * Jax.noise.bind(context, uniforms);
225
+ *
226
+ * // . . .
227
+ * }
228
+ *
229
+ * Returns the same uniforms delegator that was specified to begin with.
230
+ *
231
+ **/
232
+ bind: function(context, uniforms) {
233
+ if (!this.isPrepared(context)) prepareAll(this, context);
234
+ uniforms.texture('permTexture', this.perm, context);
235
+ uniforms.texture('simplexTexture', this.simplex, context);
236
+ uniforms.texture('gradTexture', this.grad, context);
237
+ },
238
+
239
+ /**
240
+ * Jax.Noise#isPrepared(context) -> Boolean
241
+ *
242
+ * Returns true if this Jax.Noise has had its textures prepared for the
243
+ * specified context.
244
+ **/
245
+ isPrepared: function(context) {
246
+ return this.perm.isValid(context);
247
+ }
248
+ });
249
+ })();
250
+
251
+ Jax.noise = new Jax.Noise();
@@ -0,0 +1,81 @@
1
+ //= require "jax/prototype/core"
2
+
3
+ /**
4
+ * Jax.Class
5
+ **/
6
+ Jax.Class = (function() {
7
+ var emptyFunction = function() { };
8
+
9
+ var IS_DONTENUM_BUGGY = (function(){
10
+ for (var p in { toString: 1 }) {
11
+ if (p === 'toString') return false;
12
+ }
13
+ return true;
14
+ })();
15
+
16
+ function subclass() {};
17
+ function create() {
18
+ var parent = null, properties = Jax.$A(arguments);
19
+ if (Object.isFunction(properties[0]))
20
+ parent = properties.shift();
21
+
22
+ function klass() {
23
+ this.initialize.apply(this, arguments);
24
+ }
25
+
26
+ Object.extend(klass, Jax.Class.Methods);
27
+ klass.superclass = parent;
28
+ klass.subclasses = [];
29
+
30
+ if (parent) {
31
+ subclass.prototype = parent.prototype;
32
+ klass.prototype = new subclass;
33
+ parent.subclasses.push(klass);
34
+ }
35
+
36
+ for (var i = 0, length = properties.length; i < length; i++)
37
+ klass.addMethods(properties[i]);
38
+
39
+ if (!klass.prototype.initialize)
40
+ klass.prototype.initialize = emptyFunction;
41
+
42
+ klass.prototype.constructor = klass;
43
+ return klass;
44
+ }
45
+
46
+ function addMethods(source) {
47
+ var ancestor = this.superclass && this.superclass.prototype,
48
+ properties = Object.keys(source);
49
+
50
+ if (IS_DONTENUM_BUGGY) {
51
+ if (source.toString != Object.prototype.toString)
52
+ properties.push("toString");
53
+ if (source.valueOf != Object.prototype.valueOf)
54
+ properties.push("valueOf");
55
+ }
56
+
57
+ for (var i = 0, length = properties.length; i < length; i++) {
58
+ var property = properties[i], value = source[property];
59
+ if (ancestor && Object.isFunction(value) &&
60
+ value.argumentNames()[0] == "$super") {
61
+ var method = value;
62
+ value = (function(m) {
63
+ return function() { return ancestor[m].apply(this, arguments); };
64
+ })(property).wrap(method);
65
+
66
+ value.valueOf = method.valueOf.bind(method);
67
+ value.toString = method.toString.bind(method);
68
+ }
69
+ this.prototype[property] = value;
70
+ }
71
+
72
+ return this;
73
+ }
74
+
75
+ return {
76
+ create: create,
77
+ Methods: {
78
+ addMethods: addMethods
79
+ }
80
+ };
81
+ })();
@@ -0,0 +1,112 @@
1
+ /*
2
+ Core functions borrowed from Prototype. I don't think these are stepping on anyone's (e.g. jQuery's) toes,
3
+ but if I find out otherwise I'll have to tweak it. The goal here is to be totally compatible with other libraries
4
+ wherever possible.
5
+ */
6
+
7
+ Jax.$A = function(iterable) {
8
+ if (!iterable) return [];
9
+ if ('toArray' in Object(iterable)) return iterable.toArray();
10
+ var length = iterable.length || 0, results = new Array(length);
11
+ while (length--) results[length] = iterable[length];
12
+ return results;
13
+ };
14
+
15
+ /* TODO find a way to avoid polluting Object. */
16
+ Object.isFunction = function(arg) { return Object.prototype.toString.call(arg) === '[object Function]'; };
17
+ Object.isUndefined = function(object) { return typeof object === "undefined"; };
18
+ Object.isArray = function(object) { return Object.prototype.toString.call(object) === '[object Array]'; };
19
+ Object.extend = function(destination, source) {
20
+ for (var property in source)
21
+ destination[property] = source[property];
22
+ return destination;
23
+ };
24
+
25
+ Object.extend(Function.prototype, (function() {
26
+ var slice = Array.prototype.slice;
27
+
28
+ function update(array, args) {
29
+ var arrayLength = array.length, length = args.length;
30
+ while (length--) array[arrayLength + length] = args[length];
31
+ return array;
32
+ }
33
+
34
+ function merge(array, args) {
35
+ array = slice.call(array, 0);
36
+ return update(array, args);
37
+ }
38
+
39
+ function argumentNames() {
40
+ var names = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1]
41
+ .replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, '')
42
+ .replace(/\s+/g, '').split(',');
43
+ return names.length == 1 && !names[0] ? [] : names;
44
+ }
45
+
46
+ function bind(context) {
47
+ if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this;
48
+ var __method = this, args = slice.call(arguments, 1);
49
+ return function() {
50
+ var a = merge(args, arguments);
51
+ return __method.apply(context, a);
52
+ }
53
+ }
54
+
55
+ function bindAsEventListener(context) {
56
+ var __method = this, args = slice.call(arguments, 1);
57
+ return function(event) {
58
+ var a = update([event || window.event], args);
59
+ return __method.apply(context, a);
60
+ }
61
+ }
62
+
63
+ function curry() {
64
+ if (!arguments.length) return this;
65
+ var __method = this, args = slice.call(arguments, 0);
66
+ return function() {
67
+ var a = merge(args, arguments);
68
+ return __method.apply(this, a);
69
+ }
70
+ }
71
+
72
+ function delay(timeout) {
73
+ var __method = this, args = slice.call(arguments, 1);
74
+ timeout = timeout * 1000;
75
+ return window.setTimeout(function() {
76
+ return __method.apply(__method, args);
77
+ }, timeout);
78
+ }
79
+
80
+ function defer() {
81
+ var args = update([0.01], arguments);
82
+ return this.delay.apply(this, args);
83
+ }
84
+
85
+ function wrap(wrapper) {
86
+ var __method = this;
87
+ return function() {
88
+ var a = update([__method.bind(this)], arguments);
89
+ return wrapper.apply(this, a);
90
+ }
91
+ }
92
+
93
+ function methodize() {
94
+ if (this._methodized) return this._methodized;
95
+ var __method = this;
96
+ return this._methodized = function() {
97
+ var a = update([this], arguments);
98
+ return __method.apply(null, a);
99
+ };
100
+ }
101
+
102
+ return {
103
+ argumentNames: argumentNames,
104
+ bind: bind,
105
+ bindAsEventListener: bindAsEventListener,
106
+ curry: curry,
107
+ delay: delay,
108
+ defer: defer,
109
+ wrap: wrap,
110
+ methodize: methodize
111
+ };
112
+ })());
@@ -0,0 +1,142 @@
1
+ //= require "jax/prototype/class"
2
+
3
+ (function() {
4
+ /*
5
+ Delegator is instantiated by the class method #delegate with _this_ and _arguments_ as arguments.
6
+ It is effectively responsible for copying a set of methods into the destination object.
7
+
8
+ @see Jax.Class.Methods#delegate
9
+ */
10
+ var Delegator = Jax.Class.create({
11
+ initialize: function(target, methods) {
12
+ this.methods = methods;
13
+ this.target = target;
14
+ },
15
+
16
+ into: function(destination, dest_klass) {
17
+ /*
18
+ yes, we're using eval in here. But as this method is only called during setup, it's probably OK for the most
19
+ part. Note the caveat that if dest_klass is omitted and the dev is using regular expressions to match method
20
+ names, we have no choice but to put an eval into the alias chain for this.target#initialize. Not ideal but I
21
+ couldn't think of a better way to make it work.
22
+ */
23
+ var methods = {};
24
+ var method_name;
25
+ var alias_chain_regexps = [];
26
+
27
+ for (var i = 0; i < this.methods.length; i++) {
28
+ if (typeof(this.methods[i]) == "string") {
29
+ /* it's not a regexp so this case is pretty straightforward */
30
+ method_name = this.methods[i];
31
+ methods[method_name] =
32
+ eval("(function() { return this."+destination+"."+method_name+".apply(this."+destination+", arguments); })");
33
+ } else if (this.methods[i].test) {
34
+ var method_regexp = this.methods[i];
35
+ /*
36
+ regexp -- this is harder because we don't know what klass _destination_ points to.
37
+ we have two choices: require an explicit klass argument, or assume the dev is prepared
38
+ to pay the overhead price of testing regexps and calling #eval within #initialize.
39
+
40
+ let's do both: if explicit klass was given, use it. Else, set up an alias chain for #initialize.
41
+ */
42
+
43
+ if (dest_klass) {
44
+ for (method_name in dest_klass.prototype) {
45
+ if (method_regexp.test(method_name)) {
46
+ methods[method_name] =
47
+ eval("(function() { return this."+destination+"."+method_name+".apply(this."+destination+", arguments); })");
48
+ }
49
+ }
50
+ } else {
51
+ alias_chain_regexps.push(method_regexp);
52
+ }
53
+ }
54
+ }
55
+
56
+ /* add known methods */
57
+ this.target.addMethods(methods);
58
+
59
+ if (alias_chain_regexps.length > 0) {
60
+ if (!this.target.alias_chain_regexps)
61
+ {
62
+ /* alias chain doesn't yet exist -- create it */
63
+ this.target.alias_chain_regexps = {};
64
+ var original_initialize_method = this.target.prototype.initialize;
65
+ var fn = "(function(){" +
66
+ "if (original_initialize_method) original_initialize_method.apply(this, arguments);" +
67
+ "var i, j, method_name, destination, method_regexp, self = this;" +
68
+
69
+ "destination = this."+destination+";" +
70
+ "for (i = 0; i < this.klass.alias_chain_regexps['"+destination+"'].length; i++) {" +
71
+ "method_regexp = this.klass.alias_chain_regexps['"+destination+"'][i];" +
72
+ "for (j in destination) {" +
73
+ "method_name = j;" +
74
+ "if (method_regexp.test(method_name)) " +
75
+ "this[method_name] = eval('(function(){return self."+destination+".'+method_name+" +
76
+ "'.apply(self."+destination+", arguments);})');" +
77
+ "}" +
78
+ "}" +
79
+ "})";
80
+
81
+ this.target.prototype.initialize = eval(fn);
82
+ }
83
+ /* else, alias chain exists; we only have to add method regexps */
84
+
85
+ this.target.alias_chain_regexps[destination] = this.target.alias_chain_regexps[destination] || [];
86
+ for (i = 0; i < alias_chain_regexps.length; i++) {
87
+ this.target.alias_chain_regexps[destination].push(alias_chain_regexps[i]);
88
+ }
89
+ }
90
+ }
91
+ });
92
+
93
+ /*
94
+ Prototype doesn't seem to have a way to add instance methods to all classes (a generic base object would have
95
+ been nice) so we have to hack it in by aliasing ::create and then replacing it.
96
+ */
97
+ Jax.Class.InstanceMethods = {
98
+ isKindOf: function(klass) {
99
+ return(this instanceof klass);
100
+ }
101
+ };
102
+
103
+ var original_create = Jax.Class.create;
104
+ Jax.Class.create = function() {
105
+ var klass = original_create.apply(Jax.Class, arguments);
106
+ klass.prototype.klass = klass;
107
+ klass.addMethods(Jax.Class.InstanceMethods);
108
+ Jax.Util.addRequestedHelpers(klass);
109
+
110
+ return klass;
111
+ };
112
+
113
+ /**
114
+ * Jax.Class.delegate() -> undefined
115
+ *
116
+ * This is a class method of all Jax classes.
117
+ *
118
+ * Delegates one or more methods into properties of the class. For instance,
119
+ * the following:
120
+ *
121
+ * MyClass.delegate("sayHello").into("person");
122
+ *
123
+ * will create a +sayHello+ method in the +MyClass+ class that internally calls
124
+ *
125
+ * this.person.sayHello(...)
126
+ *
127
+ * and returns the results.
128
+ *
129
+ * There are several other variants:
130
+ *
131
+ * klass.delegate(/regular expression/).into("property_name");
132
+ * // delegates any method name in +property_name+ that matches the expression
133
+ *
134
+ * klass.delegate("one", "two").into("property_name");
135
+ * // delegates both 'one' and 'two' methods into +property_name+
136
+ *
137
+ *
138
+ **/
139
+ Jax.Class.Methods.delegate = function() {
140
+ return new Delegator(this, arguments);
141
+ };
142
+ })();
@@ -0,0 +1 @@
1
+ //= require "ejs"
@@ -0,0 +1,7 @@
1
+ //= require "glMatrix"
2
+ //= require "jax/core/glMatrix_ext/mat3.js"
3
+ //= require "jax/core/glMatrix_ext/mat4.js"
4
+ //= require "jax/core/glMatrix_ext/quat4.js"
5
+ //= require "jax/core/glMatrix_ext/vec2.js"
6
+ //= require "jax/core/glMatrix_ext/vec3.js"
7
+ //= require "jax/core/glMatrix_ext/vec4.js"