jax 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rvmrc +2 -3
- data/.travis.yml +8 -22
- data/README.md +2 -2
- data/Rakefile +128 -96
- data/app/assets/javascripts/jax/controller-list.js.coffee +22 -0
- data/app/assets/javascripts/jax/dom-helpers.js.coffee +17 -0
- data/app/assets/javascripts/jax/jasmine_runner.js +177 -0
- data/app/assets/javascripts/jax/runtime.js +6 -0
- data/app/assets/javascripts/jax/shader_editor.js.coffee +33 -0
- data/app/assets/stylesheets/jax/controller-list.css +5 -0
- data/app/assets/stylesheets/jax/jasmine.css +16 -0
- data/app/assets/stylesheets/jax/nav.css +41 -0
- data/app/assets/stylesheets/jax/runtime.css +47 -0
- data/app/assets/stylesheets/jax/shader_editor.css +3 -0
- data/app/assets/stylesheets/jax/suite.css +82 -0
- data/app/controllers/jax/suite_controller.rb +48 -0
- data/app/views/jax/suite/jasmine.html.erb +38 -0
- data/app/views/jax/suite/run_webgl.html.erb +49 -0
- data/app/views/jax/suite/shader_editor.html.erb +24 -0
- data/app/views/layouts/jax.html.erb +40 -0
- data/bin/jax +8 -4
- data/config/routes.rb +2 -0
- data/config.ru +5 -0
- data/features/rails/resources.feature +45 -0
- data/features/rails/shaders.feature +13 -0
- data/features/rails/specs.feature +24 -0
- data/features/runtime.feature +15 -0
- data/features/step_definitions/environment_steps.rb +15 -0
- data/features/step_definitions/response_steps.rb +13 -0
- data/features/step_definitions/runtime.rb +11 -0
- data/features/step_definitions/web_steps.rb +223 -0
- data/features/support/env.rb +75 -0
- data/features/support/paths.rb +30 -0
- data/features/support/rails_environment.rb +3 -0
- data/features/support/selectors.rb +39 -0
- data/features/support/setup.rb +17 -0
- data/jax.gemspec +22 -16
- data/lib/assets/javascripts/jax/anim_frame.js +64 -0
- data/lib/assets/javascripts/jax/application.js +16 -0
- data/lib/assets/javascripts/jax/builtin/all.js +21 -0
- data/lib/assets/javascripts/jax/builtin/meshes/cube.js +83 -0
- data/lib/assets/javascripts/jax/builtin/meshes/plane.js +67 -0
- data/lib/assets/javascripts/jax/builtin/meshes/quad.js +89 -0
- data/lib/assets/javascripts/jax/builtin/meshes/sphere.js +65 -0
- data/lib/assets/javascripts/jax/builtin/meshes/teapot.js +48 -0
- data/lib/assets/javascripts/jax/builtin/meshes/torus.js +64 -0
- data/lib/assets/javascripts/jax/compatibility.js +312 -0
- data/lib/assets/javascripts/jax/context.js +741 -0
- data/lib/assets/javascripts/jax/core/base.js +69 -0
- data/lib/assets/javascripts/jax/core/glMatrix_ext/mat3.js +20 -0
- data/lib/assets/javascripts/jax/core/glMatrix_ext/mat4.js +10 -0
- data/lib/assets/javascripts/jax/core/glMatrix_ext/quat4.js +148 -0
- data/lib/assets/javascripts/jax/core/glMatrix_ext/vec2.js +25 -0
- data/lib/assets/javascripts/jax/core/glMatrix_ext/vec3.js +86 -0
- data/lib/assets/javascripts/jax/core/glMatrix_ext/vec4.js +28 -0
- data/lib/assets/javascripts/jax/core/helper.js +44 -0
- data/lib/assets/javascripts/jax/core/math.js +61 -0
- data/lib/assets/javascripts/jax/core/matrix_stack.js +310 -0
- data/lib/assets/javascripts/jax/core/util.js +271 -0
- data/lib/assets/javascripts/jax/core.js +43 -0
- data/lib/assets/javascripts/jax/events.js +304 -0
- data/lib/assets/javascripts/jax/geometry/line.js +185 -0
- data/lib/assets/javascripts/jax/geometry/plane.js +371 -0
- data/lib/assets/javascripts/jax/geometry/triangle/inliner.rb +94 -0
- data/lib/assets/javascripts/jax/geometry/triangle/slow_tri_tri_intersect.js +20 -0
- data/lib/assets/javascripts/jax/geometry/triangle/tri_tri_intersect.js +281 -0
- data/lib/assets/javascripts/jax/geometry/triangle/tri_tri_intersect_optimized.js +564 -0
- data/lib/assets/javascripts/jax/geometry/triangle.js +311 -0
- data/lib/assets/javascripts/jax/geometry.js +14 -0
- data/lib/assets/javascripts/jax/mvc/controller.js +188 -0
- data/lib/assets/javascripts/jax/mvc/model.js +302 -0
- data/lib/assets/javascripts/jax/mvc/route_set.js +148 -0
- data/lib/assets/javascripts/jax/mvc/view.js +43 -0
- data/lib/assets/javascripts/jax/mvc/view_manager.js +65 -0
- data/lib/assets/javascripts/jax/noise.js +251 -0
- data/lib/assets/javascripts/jax/prototype/class.js +81 -0
- data/lib/assets/javascripts/jax/prototype/core.js +112 -0
- data/lib/assets/javascripts/jax/prototype/extensions.js +142 -0
- data/lib/assets/javascripts/jax/vendor/ejs.js +1 -0
- data/lib/assets/javascripts/jax/vendor/glMatrix.js +7 -0
- data/lib/assets/javascripts/jax/webgl/camera.js +697 -0
- data/lib/assets/javascripts/jax/webgl/cleanup.js +1 -0
- data/lib/assets/javascripts/jax/webgl/core/buffer.js +292 -0
- data/lib/assets/javascripts/jax/webgl/core/data_region.js +184 -0
- data/lib/assets/javascripts/jax/webgl/core/data_segment.js +255 -0
- data/lib/assets/javascripts/jax/webgl/core/events.js +99 -0
- data/lib/assets/javascripts/jax/webgl/core/framebuffer.js +316 -0
- data/lib/assets/javascripts/jax/webgl/core.js +6 -0
- data/lib/assets/javascripts/jax/webgl/material.js +381 -0
- data/lib/assets/javascripts/jax/webgl/mesh/normals.js +37 -0
- data/lib/assets/javascripts/jax/webgl/mesh/support.js +104 -0
- data/lib/assets/javascripts/jax/webgl/mesh/tangent_space.js +111 -0
- data/lib/assets/javascripts/jax/webgl/mesh.js +440 -0
- data/lib/assets/javascripts/jax/webgl/scene/frustum.js +422 -0
- data/lib/assets/javascripts/jax/webgl/scene/light_manager.js +141 -0
- data/lib/assets/javascripts/jax/webgl/scene/light_source.js +300 -0
- data/lib/assets/javascripts/jax/webgl/scene.js +16 -0
- data/lib/assets/javascripts/jax/webgl/shader/delegator/attribute.js +53 -0
- data/lib/assets/javascripts/jax/webgl/shader/delegator/uniform.js +71 -0
- data/lib/assets/javascripts/jax/webgl/shader/delegator.js +13 -0
- data/lib/assets/javascripts/jax/webgl/shader/manifest.js +70 -0
- data/lib/assets/javascripts/jax/webgl/shader/program.js +138 -0
- data/lib/assets/javascripts/jax/webgl/shader.js +299 -0
- data/lib/assets/javascripts/jax/webgl/shader_chain.js +267 -0
- data/lib/assets/javascripts/jax/webgl/texture.js +506 -0
- data/lib/assets/javascripts/jax/webgl/world.js +279 -0
- data/lib/assets/javascripts/jax/webgl.js +109 -0
- data/lib/assets/javascripts/jax.js +136 -0
- data/{builtin/app/shaders/basic/common.ejs → lib/assets/javascripts/shaders/basic/common.glsl} +0 -0
- data/{builtin/app/shaders/basic/fragment.ejs → lib/assets/javascripts/shaders/basic/fragment.glsl} +0 -0
- data/{builtin/app/shaders/basic/vertex.ejs → lib/assets/javascripts/shaders/basic/vertex.glsl} +1 -1
- data/{builtin/app/shaders/depthmap/common.ejs → lib/assets/javascripts/shaders/depthmap/common.glsl} +0 -0
- data/{builtin/app/shaders/depthmap/fragment.ejs → lib/assets/javascripts/shaders/depthmap/fragment.glsl} +1 -1
- data/{builtin/app → lib/assets/javascripts}/shaders/depthmap/material.js +0 -0
- data/{builtin/app/shaders/depthmap/vertex.ejs → lib/assets/javascripts/shaders/depthmap/vertex.glsl} +0 -0
- data/{builtin/app/shaders/fog/common.ejs → lib/assets/javascripts/shaders/fog/common.glsl} +0 -0
- data/{builtin/app/shaders/fog/fragment.ejs → lib/assets/javascripts/shaders/fog/fragment.glsl} +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/fog/manifest.yml +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/fog/material.js +6 -8
- data/{builtin/app/shaders/fog/vertex.ejs → lib/assets/javascripts/shaders/fog/vertex.glsl} +0 -0
- data/{builtin/app/shaders/functions/depth_map.ejs → lib/assets/javascripts/shaders/functions/depth_map.glsl} +0 -0
- data/{builtin/app/shaders/functions/lights.ejs → lib/assets/javascripts/shaders/functions/lights.glsl} +0 -0
- data/{builtin/app/shaders/functions/noise.ejs → lib/assets/javascripts/shaders/functions/noise.glsl} +0 -0
- data/lib/assets/javascripts/shaders/lighting/common.glsl +5 -0
- data/{builtin/app/shaders/lighting/fragment.ejs → lib/assets/javascripts/shaders/lighting/fragment.glsl} +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/lighting/manifest.yml +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/lighting/material.js +2 -4
- data/{builtin/app/shaders/lighting/vertex.ejs → lib/assets/javascripts/shaders/lighting/vertex.glsl} +0 -0
- data/{builtin/app/shaders/normal_map/common.ejs → lib/assets/javascripts/shaders/normal_map/common.glsl} +1 -1
- data/{builtin/app/shaders/normal_map/fragment.ejs → lib/assets/javascripts/shaders/normal_map/fragment.glsl} +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/normal_map/manifest.yml +0 -0
- data/lib/assets/javascripts/shaders/normal_map/material.js +11 -0
- data/{builtin/app/shaders/normal_map/vertex.ejs → lib/assets/javascripts/shaders/normal_map/vertex.glsl} +0 -0
- data/{builtin/app/shaders/paraboloid/common.ejs → lib/assets/javascripts/shaders/paraboloid/common.glsl} +0 -0
- data/{builtin/app/shaders/paraboloid/fragment.ejs → lib/assets/javascripts/shaders/paraboloid/fragment.glsl} +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/paraboloid/manifest.yml +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/paraboloid/material.js +2 -4
- data/{builtin/app/shaders/paraboloid/vertex.ejs → lib/assets/javascripts/shaders/paraboloid/vertex.glsl} +0 -0
- data/{builtin/app/shaders/picking/common.ejs → lib/assets/javascripts/shaders/picking/common.glsl} +0 -0
- data/{builtin/app/shaders/picking/fragment.ejs → lib/assets/javascripts/shaders/picking/fragment.glsl} +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/picking/material.js +2 -4
- data/{builtin/app/shaders/picking/vertex.ejs → lib/assets/javascripts/shaders/picking/vertex.glsl} +0 -0
- data/{builtin/app/shaders/shadow_map/common.ejs → lib/assets/javascripts/shaders/shadow_map/common.glsl} +2 -1
- data/{builtin/app/shaders/shadow_map/fragment.ejs → lib/assets/javascripts/shaders/shadow_map/fragment.glsl} +1 -1
- data/{builtin/app → lib/assets/javascripts}/shaders/shadow_map/manifest.yml +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/shadow_map/material.js +4 -6
- data/{builtin/app/shaders/shadow_map/vertex.ejs → lib/assets/javascripts/shaders/shadow_map/vertex.glsl} +0 -0
- data/{builtin/app/shaders/texture/common.ejs → lib/assets/javascripts/shaders/texture/common.glsl} +0 -0
- data/{builtin/app/shaders/texture/fragment.ejs → lib/assets/javascripts/shaders/texture/fragment.glsl} +0 -0
- data/{builtin/app → lib/assets/javascripts}/shaders/texture/manifest.yml +0 -0
- data/lib/assets/javascripts/shaders/texture/material.js +17 -0
- data/{builtin/app/shaders/texture/vertex.ejs → lib/assets/javascripts/shaders/texture/vertex.glsl} +0 -0
- data/lib/generators/jax/all.rb +16 -0
- data/lib/generators/jax/application/application_generator.rb +48 -0
- data/lib/generators/jax/base/actions.rb +52 -0
- data/lib/generators/jax/base/coffee_generator.rb +30 -0
- data/lib/generators/jax/base/named_base.rb +17 -0
- data/lib/generators/jax/base/plugin_base.rb +108 -0
- data/lib/generators/jax/base/plugin_credentials.rb +99 -0
- data/lib/generators/jax/base/plugin_manifest.rb +75 -0
- data/lib/generators/jax/base/rails_base.rb +30 -0
- data/lib/generators/jax/base/source_root.rb +5 -0
- data/lib/generators/jax/controller/controller_generator.rb +37 -0
- data/lib/generators/jax/helper/helper_generator.rb +30 -0
- data/lib/generators/jax/install/install_generator.rb +27 -0
- data/lib/generators/jax/jax_generator.rb +13 -0
- data/lib/generators/jax/light/light_generator.rb +23 -0
- data/lib/{jax/generators → generators/jax}/material/USAGE +4 -8
- data/lib/generators/jax/material/material_generator.rb +112 -0
- data/lib/generators/jax/model/model_generator.rb +24 -0
- data/lib/generators/jax/plugin/plugin_generator.rb +72 -0
- data/lib/generators/jax/scaffold/scaffold_generator.rb +35 -0
- data/lib/generators/jax/shader/shader_generator.rb +38 -0
- data/lib/jax/commands/plugin_manager.rb +240 -0
- data/lib/jax/commands.rb +69 -0
- data/lib/jax/configuration.rb +64 -0
- data/lib/jax/directive_processor.rb +53 -0
- data/lib/jax/engine.rb +38 -54
- data/lib/jax/helper_methods.rb +3 -0
- data/lib/jax/rails/application.rb +34 -0
- data/lib/jax/resource_file.rb +29 -0
- data/lib/jax/script_loader.rb +68 -0
- data/lib/jax/server.rb +87 -0
- data/lib/jax/shader.rb +70 -172
- data/lib/jax/testing/rails_environment.rb +94 -0
- data/lib/jax/util/tar.rb +75 -0
- data/lib/jax/util.rb +3 -0
- data/lib/jax/version.rb +7 -8
- data/lib/jax.rb +23 -41
- data/spec/bin/jax_spec.rb +149 -0
- data/{lib/jax/generators/app/templates/app/models/.empty_directory → spec/fixtures/public/favicon.ico} +0 -0
- data/spec/fixtures/public/textures/brickwall.jpg +0 -0
- data/spec/fixtures/public/textures/jacks.jpg +0 -0
- data/spec/fixtures/public/textures/normal_map.jpg +0 -0
- data/spec/fixtures/public/textures/rock.png +0 -0
- data/spec/fixtures/public/textures/rock_normal.png +0 -0
- data/spec/fixtures/public/textures/rss.png +0 -0
- data/spec/generators/jax/application_generator_spec.rb +18 -0
- data/spec/generators/jax/controller_generator_spec.rb +102 -0
- data/spec/generators/jax/helper_generator_spec.rb +55 -0
- data/spec/generators/jax/install_generator_spec.rb +30 -0
- data/spec/generators/jax/jax_generator_spec.rb +21 -0
- data/spec/generators/jax/light_generator_spec.rb +27 -0
- data/spec/generators/jax/material_generator_spec.rb +62 -0
- data/spec/generators/jax/model_generator_spec.rb +72 -0
- data/spec/generators/jax/plugin_generator_spec.rb +143 -0
- data/spec/generators/jax/scaffold_generator_spec.rb +35 -0
- data/spec/generators/jax/shader_generator_spec.rb +37 -0
- data/spec/javascripts/helpers/jasmine_webgl_helper.js +13 -0
- data/{lib/jax/generators/app/templates/spec/javascripts/support/spec_helpers → spec/javascripts/helpers}/jax_spec_environment_helper.js +7 -2
- data/{lib/jax/generators/app/templates/spec/javascripts/support/spec_helpers → spec/javascripts/helpers}/jax_spec_helper.js +0 -0
- data/spec/javascripts/jax/builtin/meshes/cube_spec.js +10 -0
- data/spec/javascripts/jax/builtin/meshes/plane_spec.js +8 -0
- data/spec/javascripts/jax/builtin/meshes/quad_spec.js +8 -0
- data/spec/javascripts/jax/builtin/meshes/sphere_spec.js +8 -0
- data/spec/javascripts/jax/builtin/meshes/teapot_spec.js +8 -0
- data/spec/javascripts/jax/builtin/meshes/torus_spec.js +8 -0
- data/spec/javascripts/jax/compatibility_spec.js +46 -0
- data/spec/javascripts/jax/context_events_spec.js +212 -0
- data/spec/javascripts/jax/context_spec.js +305 -0
- data/spec/javascripts/jax/core/data_region_spec.js +118 -0
- data/spec/javascripts/jax/core/data_segment_spec.js +96 -0
- data/spec/javascripts/jax/core/delegation_spec.js +48 -0
- data/spec/javascripts/jax/core/events_spec.js +17 -0
- data/spec/javascripts/jax/core/glMatrix_extensions_spec.js +8 -0
- data/spec/javascripts/jax/core/helper_spec.js +61 -0
- data/spec/javascripts/jax/core/matrix_stack_spec.js +28 -0
- data/spec/javascripts/jax/core/utils_spec.js +275 -0
- data/spec/javascripts/jax/geometry/line_spec.js +20 -0
- data/spec/javascripts/jax/geometry/plane_spec.js +181 -0
- data/spec/javascripts/jax/geometry/triangle_spec.js +105 -0
- data/spec/javascripts/jax/mvc/controller_spec.js +156 -0
- data/spec/javascripts/jax/mvc/model_spec.js +93 -0
- data/spec/javascripts/jax/mvc/route_set_spec.js +49 -0
- data/spec/javascripts/jax/mvc/view_manager_spec.js +17 -0
- data/spec/javascripts/jax/noise_spec.js +50 -0
- data/spec/javascripts/jax/optimizations/material_limitations_spec.js +85 -0
- data/spec/javascripts/jax/optimizations/shaders/basic_spec.js +65 -0
- data/spec/javascripts/jax/prototype/extensions_spec.js +34 -0
- data/spec/javascripts/jax/webgl/camera_spec.js +237 -0
- data/spec/javascripts/jax/webgl/core/events_spec.js +47 -0
- data/spec/javascripts/jax/webgl/framebuffer_spec.js +44 -0
- data/spec/javascripts/jax/webgl/lighting_spec.js +108 -0
- data/spec/javascripts/jax/webgl/material_spec.js +117 -0
- data/spec/javascripts/jax/webgl/mesh_spec.js +228 -0
- data/spec/javascripts/jax/webgl/shader/manifest_spec.js +57 -0
- data/spec/javascripts/jax/webgl/shader_chain_spec.js +211 -0
- data/spec/javascripts/jax/webgl/shader_spec.js +276 -0
- data/spec/javascripts/jax/webgl/tangent_space_spec.js +142 -0
- data/spec/javascripts/jax/webgl/texture_spec.js +159 -0
- data/spec/javascripts/jax/webgl_spec.js +5 -0
- data/spec/javascripts/jax/world_spec.js +175 -0
- data/spec/javascripts/jax_spec.js +14 -0
- data/spec/javascripts/node/mocks/webgl.js +159 -0
- data/spec/javascripts/node_helper.js +51 -0
- data/spec/javascripts/shaders/core_materials_spec.js +38 -0
- data/spec/javascripts/shaders/fog_spec.js +15 -0
- data/spec/javascripts/shaders/lighting_spec.js +15 -0
- data/spec/javascripts/shaders/normal_map_spec.js +15 -0
- data/spec/javascripts/shaders/paraboloid_spec.js +33 -0
- data/spec/javascripts/shaders/preprocessor_spec.js +45 -0
- data/spec/javascripts/shaders/shadow_map_spec.js +15 -0
- data/spec/javascripts/shaders/texture_spec.js +37 -0
- data/spec/javascripts/suite/controller_select_spec.js.coffee +24 -0
- data/spec/lib/jax/commands/plugin_manager/credentials_spec.rb +56 -0
- data/spec/lib/jax/commands/plugin_manager/push_spec.rb +62 -0
- data/spec/lib/jax/commands/plugin_manager_spec.rb +204 -0
- data/spec/lib/jax/rails/application_spec.rb +23 -0
- data/spec/lib/jax/shader_spec.rb +67 -0
- data/spec/lib/jax/util/tar_spec.rb +26 -0
- data/spec/{test_helper.rb → spec_helper.rb} +37 -28
- data/spec/support/test_model_generator.rb +14 -0
- data/templates/app/Gemfile.tt +17 -0
- data/templates/app/Rakefile +4 -0
- data/templates/app/config/application.rb +16 -0
- data/{lib/jax/generators/app/templates → templates/app}/config/boot.rb +0 -0
- data/templates/app/config/environment.rb +5 -0
- data/templates/app/config/environments/production.rb +4 -0
- data/templates/app/config.ru +6 -0
- data/{lib/jax/generators/app/templates/app/resources → templates/app/public}/.empty_directory +0 -0
- data/templates/app/script/jax +8 -0
- data/{lib/jax/generators/app/templates/app/views → templates/app/spec}/.empty_directory +0 -0
- data/templates/application_controller.js.coffee.erb +3 -0
- data/templates/application_controller.js.erb +6 -0
- data/templates/application_helper.js.coffee.erb +3 -0
- data/templates/application_helper.js.erb +3 -0
- data/templates/controller.js.coffee.erb +9 -0
- data/templates/controller.js.erb +15 -0
- data/templates/controller_spec.js.coffee.erb +9 -0
- data/templates/controller_spec.js.erb +12 -0
- data/templates/helper.js.coffee.erb +2 -0
- data/templates/helper.js.erb +3 -0
- data/templates/helper_spec.js.coffee.erb +8 -0
- data/templates/helper_spec.js.erb +12 -0
- data/{lib/jax/generators/light_source/templates/light.yml.tt → templates/light_source.resource.erb} +3 -3
- data/{lib/jax/generators/material/templates/material.yml.tt → templates/material.resource.erb} +0 -9
- data/templates/model.js.coffee.erb +3 -0
- data/templates/model.js.erb +5 -0
- data/templates/model_defaults.resource.erb +5 -0
- data/templates/model_spec.js.coffee.erb +16 -0
- data/templates/model_spec.js.erb +18 -0
- data/{lib/jax/generators/plugin/templates/new_plugin/app → templates/new_plugin/app/assets/jax}/controllers/.empty_directory +0 -0
- data/{lib/jax/generators/plugin/templates/new_plugin/app → templates/new_plugin/app/assets/jax}/helpers/.empty_directory +0 -0
- data/{lib/jax/generators/plugin/templates/new_plugin/app → templates/new_plugin/app/assets/jax}/models/.empty_directory +0 -0
- data/{lib/jax/generators/plugin/templates/new_plugin/app → templates/new_plugin/app/assets/jax}/resources/.empty_directory +0 -0
- data/{lib/jax/generators/plugin/templates/new_plugin/app → templates/new_plugin/app/assets/jax}/views/.empty_directory +0 -0
- data/{lib/jax/generators/plugin/templates → templates}/new_plugin/init.rb +0 -0
- data/{lib/jax/generators/plugin/templates → templates}/new_plugin/install.rb +0 -0
- data/{lib/jax/generators/plugin/templates/new_plugin/public → templates/new_plugin/spec}/.empty_directory +0 -0
- data/{lib/jax/generators/plugin/templates → templates}/new_plugin/uninstall.rb +0 -0
- data/{lib/jax/generators/shader/templates/common.ejs.tt → templates/shader_common.glsl.erb} +0 -0
- data/{lib/jax/generators/shader/templates/fragment.ejs.tt → templates/shader_fragment.glsl.erb} +0 -0
- data/{lib/jax/generators/shader/templates/manifest.yml.tt → templates/shader_manifest.yml.erb} +0 -0
- data/templates/shader_material.js.coffee.erb +22 -0
- data/{lib/jax/generators/shader/templates/material.js.tt → templates/shader_material.js.erb} +0 -0
- data/templates/shader_spec.js.coffee.erb +16 -0
- data/{lib/jax/generators/shader/templates/spec.js.tt → templates/shader_spec.js.erb} +1 -1
- data/{lib/jax/generators/shader/templates/vertex.ejs.tt → templates/shader_vertex.glsl.erb} +0 -0
- data/templates/view.js.coffee.erb +3 -0
- data/{lib/jax/generators/controller/templates/view.js.tt → templates/view.js.erb} +1 -1
- data/vendor/assets/javascripts/ejs.js +505 -0
- data/vendor/assets/javascripts/glMatrix.js +1772 -0
- data/vendor/assets/javascripts/jasmine.js +2476 -0
- data/vendor/assets/stylesheets/jasmine.css +166 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/alias.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/class.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/class_deprecated.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/class_method.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/class_property.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/constant.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/constructor.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/deprecated.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/description.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/information.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/instance_method.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/instance_property.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/method.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/method_deprecated.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/mixin.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/namespace.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/property.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/related_to.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/search-background.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/section-background.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/section.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/selected-section-background.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/subclass.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/superclass.png +0 -0
- data/vendor/pdoc_template/html/assets/images/pdoc/utility.png +0 -0
- data/vendor/pdoc_template/html/assets/javascripts/pdoc/application.js +478 -0
- data/vendor/pdoc_template/html/assets/javascripts/pdoc/prototype.js +4874 -0
- data/vendor/pdoc_template/html/assets/javascripts/pdoc/tabs.js +506 -0
- data/vendor/pdoc_template/html/assets/stylesheets/jax.css +30 -0
- data/vendor/pdoc_template/html/assets/stylesheets/pdoc/api.css +681 -0
- data/vendor/pdoc_template/html/assets/stylesheets/pdoc/pygments.css +62 -0
- data/vendor/pdoc_template/html/helpers.rb +35 -0
- data/vendor/pdoc_template/html/index.erb +18 -0
- data/vendor/pdoc_template/html/item_index.js.erb +6 -0
- data/vendor/pdoc_template/html/layout.erb +67 -0
- data/vendor/pdoc_template/html/leaf.erb +22 -0
- data/vendor/pdoc_template/html/node.erb +30 -0
- data/vendor/pdoc_template/html/partials/class_relationships.erb +19 -0
- data/vendor/pdoc_template/html/partials/classes.erb +7 -0
- data/vendor/pdoc_template/html/partials/constructor.erb +5 -0
- data/vendor/pdoc_template/html/partials/description.erb +5 -0
- data/vendor/pdoc_template/html/partials/link_list.erb +1 -0
- data/vendor/pdoc_template/html/partials/method_signatures.erb +14 -0
- data/vendor/pdoc_template/html/partials/methodized_note.erb +9 -0
- data/vendor/pdoc_template/html/partials/mixins.erb +7 -0
- data/vendor/pdoc_template/html/partials/namespaces.erb +7 -0
- data/vendor/pdoc_template/html/partials/related_utilities.erb +5 -0
- data/vendor/pdoc_template/html/partials/relationships.erb +11 -0
- data/vendor/pdoc_template/html/partials/short_description_list.erb +7 -0
- data/vendor/pdoc_template/html/partials/title.erb +24 -0
- data/vendor/pdoc_template/html/section.erb +18 -0
- metadata +635 -332
- data/builtin/app/shaders/lighting/common.ejs +0 -5
- data/builtin/app/shaders/normal_map/material.js +0 -16
- data/builtin/app/shaders/texture/material.js +0 -18
- data/jax.gems +0 -1
- data/lib/jax/application/builtin/configurable.rb +0 -5
- data/lib/jax/application/builtin/configuration.rb +0 -5
- data/lib/jax/application/builtin.rb +0 -12
- data/lib/jax/application/configurable.rb +0 -19
- data/lib/jax/application/configuration.rb +0 -60
- data/lib/jax/application/railties.rb +0 -26
- data/lib/jax/application.rb +0 -149
- data/lib/jax/core_ext/kernel.rb +0 -7
- data/lib/jax/engine/configurable.rb +0 -19
- data/lib/jax/engine/configuration.rb +0 -49
- data/lib/jax/generators/app/app_generator.rb +0 -96
- data/lib/jax/generators/app/templates/Gemfile.tt +0 -3
- data/lib/jax/generators/app/templates/Rakefile +0 -6
- data/lib/jax/generators/app/templates/app/controllers/application_controller.js.tt +0 -5
- data/lib/jax/generators/app/templates/app/helpers/application_helper.js.tt +0 -3
- data/lib/jax/generators/app/templates/config/application.rb.tt +0 -6
- data/lib/jax/generators/app/templates/config/environment.rb.tt +0 -5
- data/lib/jax/generators/app/templates/config/routes.rb.tt +0 -5
- data/lib/jax/generators/app/templates/public/index.html.tt +0 -26
- data/lib/jax/generators/app/templates/public/javascripts/jax.js +0 -9462
- data/lib/jax/generators/app/templates/public/stylesheets/%file_name%.css.tt +0 -11
- data/lib/jax/generators/app/templates/public/webgl_not_supported.html +0 -26
- data/lib/jax/generators/app/templates/script/jax +0 -7
- data/lib/jax/generators/app/templates/spec/javascripts/controllers/application_controller_spec.js +0 -11
- data/lib/jax/generators/app/templates/spec/javascripts/helpers/application_helper_spec.js +0 -12
- data/lib/jax/generators/app/templates/spec/javascripts/support/jasmine.yml +0 -91
- data/lib/jax/generators/app/templates/spec/javascripts/support/jasmine_config.rb +0 -23
- data/lib/jax/generators/app/templates/spec/javascripts/support/jasmine_runner.rb +0 -32
- data/lib/jax/generators/app/templates/spec/javascripts/support/spec_layout.html.erb +0 -104
- data/lib/jax/generators/app.rb +0 -18
- data/lib/jax/generators/commands.rb +0 -220
- data/lib/jax/generators/controller/USAGE +0 -9
- data/lib/jax/generators/controller/controller_generator.rb +0 -66
- data/lib/jax/generators/controller/templates/controller_source.js.tt +0 -16
- data/lib/jax/generators/controller/templates/controller_test.js.tt +0 -11
- data/lib/jax/generators/controller/templates/helper.js.tt +0 -3
- data/lib/jax/generators/controller/templates/helper_test.js.tt +0 -12
- data/lib/jax/generators/interactions.rb +0 -56
- data/lib/jax/generators/light_source/USAGE +0 -14
- data/lib/jax/generators/light_source/light_source_generator.rb +0 -46
- data/lib/jax/generators/material/material_generator.rb +0 -80
- data/lib/jax/generators/material/templates/append.yml.tt +0 -7
- data/lib/jax/generators/model/USAGE +0 -5
- data/lib/jax/generators/model/model_generator.rb +0 -40
- data/lib/jax/generators/model/templates/model.js.tt +0 -11
- data/lib/jax/generators/model/templates/test.js.tt +0 -11
- data/lib/jax/generators/packager/package_generator.rb +0 -32
- data/lib/jax/generators/plugin/USAGE +0 -4
- data/lib/jax/generators/plugin/all.rb +0 -113
- data/lib/jax/generators/plugin/credentials.rb +0 -108
- data/lib/jax/generators/plugin/plugin_generator.rb +0 -72
- data/lib/jax/generators/plugin/plugin_manager.rb +0 -254
- data/lib/jax/generators/plugin/templates/new_plugin/config/routes.rb +0 -3
- data/lib/jax/generators/plugin/templates/new_plugin/spec/.empty_directory +0 -0
- data/lib/jax/generators/script_jax_loader.rb +0 -49
- data/lib/jax/generators/shader/USAGE +0 -4
- data/lib/jax/generators/shader/shader_generator.rb +0 -70
- data/lib/jax/monkeypatch/jasmine/config.rb +0 -45
- data/lib/jax/monkeypatch/jasmine/server.rb +0 -50
- data/lib/jax/monkeypatch/jasmine.rb +0 -3
- data/lib/jax/packager/sprockets_template.rb +0 -77
- data/lib/jax/packager.rb +0 -59
- data/lib/jax/plugin/manifest.rb +0 -71
- data/lib/jax/plugin.rb +0 -49
- data/lib/jax/resource_compiler.rb +0 -60
- data/lib/jax/routes.rb +0 -62
- data/lib/jax/tasks/rake.rb +0 -38
- data/spec/benchmark.htm +0 -93
- data/spec/generators/app_generator_test.rb +0 -42
- data/spec/generators/controller_generator_test.rb +0 -47
- data/spec/generators/light_generator_test.rb +0 -37
- data/spec/generators/material_generator_test.rb +0 -22
- data/spec/generators/model_generator_test.rb +0 -26
- data/spec/generators/plugin_generator_test.rb +0 -114
- data/spec/generators/plugin_manager/push_test.rb +0 -59
- data/spec/generators/plugin_manager_test.rb +0 -192
- data/spec/generators/shader_generator_test.rb +0 -38
- data/spec/javascripts/support/jasmine.yml +0 -85
- data/spec/javascripts/support/jasmine_runner.rb +0 -32
- data/spec/lib/jax/application_test.rb +0 -18
- data/spec/lib/jax/generators/plugin/credentials_test.rb +0 -72
- data/spec/lib/jax/packager_test.rb +0 -87
- data/spec/lib/jax/plugin_test.rb +0 -27
- data/spec/lib/jax/reloading_test.rb +0 -23
- data/spec/lib/jax/routes_test.rb +0 -28
- data/spec/lib/jax/shader_test.rb +0 -29
- data/spec/lib/jax/tasks/jax_rake_test.rb +0 -85
- data/spec/support/bases/generator_test_case.rb +0 -108
- data/spec/support/bases/isolated_test_case.rb +0 -148
- data/spec/support/file_exist_matcher.rb +0 -23
- data/spec/support/spec_shell.rb +0 -110
- data/spec/test_app.rb +0 -3
@@ -0,0 +1,310 @@
|
|
1
|
+
//= require "../vendor/glMatrix"
|
2
|
+
//= require "../prototype/class"
|
3
|
+
|
4
|
+
/**
|
5
|
+
* class Jax.MatrixStack
|
6
|
+
*
|
7
|
+
* A matrix stack, obviously. Every Jax.Context allocates its own matrix stack, so you probably
|
8
|
+
* shouldn't have to instantiate this directly. Calls to methods of the same name on Jax.Context
|
9
|
+
* are delegated into its own matrix stack, so you're really calling these methods.
|
10
|
+
*
|
11
|
+
* Note that for performance reasons, whenever you call get[Some]Matrix(), the matrix instance
|
12
|
+
* itself is returned instead of a copy of the instance. That gives you the power to make changes
|
13
|
+
* directly to the matrix, instead of doing them via the stack. For instance, instead of calling
|
14
|
+
* Jax.MatrixStack#loadMatrix(), you could just as easily call mat4#set() using one of the
|
15
|
+
* matrices here as an argument. *However*, in doing so you will lose the auto-updating of other
|
16
|
+
* matrices, so you must be very careful about how you modify matrices.
|
17
|
+
*
|
18
|
+
* For example, it would be very easy to use mat4.multiply() to change the model matrix. In doing
|
19
|
+
* so, the inverse model matrix would no longer be accurate. This could lead to very
|
20
|
+
* difficult-to-debug situations.
|
21
|
+
*
|
22
|
+
* When in doubt, it is _strongly_ recommended to use the various matrix methods found in
|
23
|
+
* Jax.MatrixStack to modify the matrices here. This will keep all related matrices up-to-date.
|
24
|
+
**/
|
25
|
+
Jax.MatrixStack = (function() {
|
26
|
+
var MODEL = 1, VIEW = 2, PROJECTION = 3;
|
27
|
+
|
28
|
+
function updateMVP(self) {
|
29
|
+
mat4.multiply(self.getProjectionMatrix(), self.getModelViewMatrix(), self.getModelViewProjectionMatrix());
|
30
|
+
}
|
31
|
+
|
32
|
+
function updateModelView(self) {
|
33
|
+
mat4.multiply(self.getInverseViewMatrix(), self.getModelMatrix(), self.getModelViewMatrix());
|
34
|
+
mat4.inverse(self.getModelViewMatrix(), self.getInverseModelViewMatrix());
|
35
|
+
updateMVP(self);
|
36
|
+
}
|
37
|
+
|
38
|
+
function updateNormal(self) {
|
39
|
+
mat4.toMat3(self.getInverseModelViewMatrix(), self.getNormalMatrix());
|
40
|
+
mat3.transpose(self.getNormalMatrix());
|
41
|
+
}
|
42
|
+
|
43
|
+
function mMatrixUpdated(self) {
|
44
|
+
mat4.inverse(self.getModelMatrix(), self.getInverseModelMatrix());
|
45
|
+
updateModelView(self);
|
46
|
+
updateNormal(self);
|
47
|
+
}
|
48
|
+
|
49
|
+
function vMatrixUpdated(self) {
|
50
|
+
mat4.inverse(self.getViewMatrix(), self.getInverseViewMatrix());
|
51
|
+
updateModelView(self);
|
52
|
+
updateNormal(self);
|
53
|
+
}
|
54
|
+
|
55
|
+
function pMatrixUpdated(self) {
|
56
|
+
mat4.inverse(self.getProjectionMatrix(), self.getInverseProjectionMatrix());
|
57
|
+
updateMVP(self);
|
58
|
+
}
|
59
|
+
|
60
|
+
function loadMatrix(self, which, values) {
|
61
|
+
switch(which) {
|
62
|
+
case MODEL:
|
63
|
+
mat4.set(values, self.getModelMatrix());
|
64
|
+
mMatrixUpdated(self);
|
65
|
+
break;
|
66
|
+
case VIEW:
|
67
|
+
mat4.set(values, self.getViewMatrix());
|
68
|
+
vMatrixUpdated(self);
|
69
|
+
break;
|
70
|
+
case PROJECTION:
|
71
|
+
mat4.set(values, self.getProjectionMatrix());
|
72
|
+
pMatrixUpdated(self);
|
73
|
+
break;
|
74
|
+
default: throw new Error("programming error: matrix ID not understood: "+which);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
function multMatrix(self, which, values) {
|
79
|
+
switch(which) {
|
80
|
+
case MODEL:
|
81
|
+
mat4.multiply(self.getModelMatrix(), values, self.getModelMatrix());
|
82
|
+
mMatrixUpdated(self);
|
83
|
+
break;
|
84
|
+
case VIEW:
|
85
|
+
mat4.multiply(self.getViewMatrix(), values, self.getViewMatrix());
|
86
|
+
vMatrixUpdated(self);
|
87
|
+
break;
|
88
|
+
case PROJECTION:
|
89
|
+
mat4.multiply(self.getProjectionMatrix(), values, self.getProjectionMatrix());
|
90
|
+
pMatrixUpdated(self);
|
91
|
+
break;
|
92
|
+
default: throw new Error("programming error: matrix ID not understood: "+which);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
/*
|
97
|
+
iterates through each matrix stack in self.matrices and pushes a new matrix onto the stack.
|
98
|
+
If the new matrix level already has a matrix, it is used; otherwise, a new one is allocated.
|
99
|
+
Then, the current level's matrix values are copied into the next level's matrix.
|
100
|
+
*/
|
101
|
+
function pushMatrix(self) {
|
102
|
+
var current;
|
103
|
+
var stack;
|
104
|
+
var current_depth = self.depth;
|
105
|
+
var type;
|
106
|
+
|
107
|
+
self.depth++;
|
108
|
+
for (var i in self.matrices) {
|
109
|
+
stack = self.matrices[i];
|
110
|
+
current = stack[current_depth];
|
111
|
+
type = (current.length == 9 ? mat3 : mat4);
|
112
|
+
stack[self.depth] = stack[self.depth] || type.create();
|
113
|
+
type.set(current, stack[self.depth]);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
return Jax.Class.create({
|
118
|
+
/**
|
119
|
+
* Jax.MatrixStack#push() -> Jax.MatrixStack
|
120
|
+
*
|
121
|
+
* Saves the state of all current matrices, so that further operations won't affect them directly.
|
122
|
+
* If another set of matrices already exist, they are used; otherwise, a new set is allocated.
|
123
|
+
* After a new set of matrices has been secured, all current values are copied into the new set.
|
124
|
+
*
|
125
|
+
* See also Jax.MatrixStack#pop()
|
126
|
+
**/
|
127
|
+
push: function() { pushMatrix(this); return this; },
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Jax.MatrixStack#pop() -> Jax.MatrixStack
|
131
|
+
*
|
132
|
+
* Reverts back to an earlier matrix stack, effectively undoing any changes that have been made
|
133
|
+
* since the most recent call to Jax.MatrixStack#push().
|
134
|
+
*
|
135
|
+
* See also Jax.MatrixStack#push()
|
136
|
+
**/
|
137
|
+
pop: function() { this.depth--; return this; },
|
138
|
+
|
139
|
+
/**
|
140
|
+
* Jax.MatrixStack#reset() -> Jax.MatrixStack
|
141
|
+
*
|
142
|
+
* Resets the stack depth to zero, effectively undoing all calls to #push().
|
143
|
+
**/
|
144
|
+
reset: function() { this.depth = 0; return this; },
|
145
|
+
|
146
|
+
/**
|
147
|
+
* Jax.MatrixStack#loadModelMatrix(matr) -> Jax.MatrixStack
|
148
|
+
* - matr (mat4): the new matrix values
|
149
|
+
*
|
150
|
+
* Replaces the current model matrix with the specified one.
|
151
|
+
* Updates the inverse model matrix, the modelview matrix, the inverse modelview matrix and the normal matrix.
|
152
|
+
**/
|
153
|
+
loadModelMatrix: function(values) { loadMatrix(this, MODEL, values); return this; },
|
154
|
+
|
155
|
+
/**
|
156
|
+
* Jax.MatrixStack#loadViewMatrix(matr) -> Jax.MatrixStack
|
157
|
+
* - matr (mat4): the new matrix values
|
158
|
+
*
|
159
|
+
* Replaces the current view matrix with the specified one.
|
160
|
+
* Updates the inverse view matrix, the modelview matrix, the inverse modelview matrix and the normal matrix.
|
161
|
+
**/
|
162
|
+
loadViewMatrix: function(values) { loadMatrix(this, VIEW, values); return this; },
|
163
|
+
|
164
|
+
/**
|
165
|
+
* Jax.MatrixStack#loadProjectionMatrix(matr) -> Jax.MatrixStack
|
166
|
+
* - matr (mat4): the new matrix values
|
167
|
+
*
|
168
|
+
* Replaces the current projection matrix with the specified one.
|
169
|
+
* Updates the inverse projection matrix.
|
170
|
+
**/
|
171
|
+
loadProjectionMatrix: function(values) { loadMatrix(this, PROJECTION, values); return this; },
|
172
|
+
|
173
|
+
/**
|
174
|
+
* Jax.MatrixStack#multModelMatrix(matr) -> Jax.MatrixStack
|
175
|
+
* - matr (mat4): the matrix values
|
176
|
+
*
|
177
|
+
* Multiplies the current model matrix with the specified one.
|
178
|
+
* Updates the inverse model matrix, the modelview matrix, the inverse modelview matrix and the normal matrix.
|
179
|
+
**/
|
180
|
+
multModelMatrix: function(values) { multMatrix(this, MODEL, values); return this; },
|
181
|
+
|
182
|
+
/**
|
183
|
+
* Jax.MatrixStack#multViewMatrix(matr) -> Jax.MatrixStack
|
184
|
+
* - matr (mat4): the matrix values
|
185
|
+
*
|
186
|
+
* Multiplies the current view matrix with the specified one.
|
187
|
+
* Updates the inverse view matrix, the modelview matrix, the inverse modelview matrix and the normal matrix.
|
188
|
+
**/
|
189
|
+
multViewMatrix: function(values) { multMatrix(this, VIEW, values); return this; },
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Jax.MatrixStack#multProjectionMatrix(matr) -> Jax.MatrixStack
|
193
|
+
* - matr (mat4): the matrix values
|
194
|
+
*
|
195
|
+
* Multiplies the current projection matrix with the specified one.
|
196
|
+
* Updates the inverse projection matrix.
|
197
|
+
**/
|
198
|
+
multProjectionMatrix: function(values) { multMatrix(this, PROJECTION, values); return this; },
|
199
|
+
|
200
|
+
/**
|
201
|
+
* Jax.MatrixStack#getModelMatrix() -> mat4
|
202
|
+
*
|
203
|
+
* the local model transformation matrix. Most models will manipulate this matrix. Multiplying an object-space
|
204
|
+
* coordinate by this matrix will result in a world-space coordinate.
|
205
|
+
**/
|
206
|
+
getModelMatrix: function() { return this.matrices.model[this.depth]; },
|
207
|
+
|
208
|
+
/**
|
209
|
+
* Jax.MatrixStack#getInverseModelMatrix() -> mat4
|
210
|
+
*
|
211
|
+
* the opposite of the local model transformation matrix. Multiplying a point in world space against this matrix
|
212
|
+
* will result in an object relative to the current object space.
|
213
|
+
**/
|
214
|
+
getInverseModelMatrix: function() { return this.matrices.inverse_model[this.depth]; },
|
215
|
+
|
216
|
+
/**
|
217
|
+
* Jax.MatrixStack#getNormalMatrix() -> mat3
|
218
|
+
*
|
219
|
+
* the inverse transpose of the modelview matrix. See
|
220
|
+
* http://www.lighthouse3d.com/tutorials/glsl-tutorial/the-normal-matrix/
|
221
|
+
* for a good writeup of where and how this matrix is useful. Multiplying a 3D _directional_ (not _positional)
|
222
|
+
* vector against this matrix will result in a 3D _directional_ vector in eye space.
|
223
|
+
**/
|
224
|
+
getNormalMatrix: function() { return this.matrices.normal[this.depth]; },
|
225
|
+
|
226
|
+
/**
|
227
|
+
* Jax.MatrixStack#getViewMatrix() -> mat4
|
228
|
+
*
|
229
|
+
* aka the camera matrix. Multiplying a point in eye space (e.g. relative to the camera) against the view matrix
|
230
|
+
* results in a point in world space.
|
231
|
+
**/
|
232
|
+
getViewMatrix: function() { return this.matrices.view[this.depth]; },
|
233
|
+
|
234
|
+
/**
|
235
|
+
* Jax.MatrixStack#getInverseViewMatrix() -> mat4
|
236
|
+
*
|
237
|
+
* the opposite of the camera matrix. Multiplying a point in world space against this matrix
|
238
|
+
* will result in a point in eye space (relative to camera).
|
239
|
+
**/
|
240
|
+
getInverseViewMatrix: function() { return this.matrices.inverse_view[this.depth]; },
|
241
|
+
|
242
|
+
/**
|
243
|
+
* Jax.MatrixStack#getModelViewMatrix() -> mat4
|
244
|
+
*
|
245
|
+
* the only matrix OpenGL actually cares about, the modelview matrix. A combination of both model and view
|
246
|
+
* matrices, equivalent to mat4.multiply(view, model). (OpenGL matrix operations are read from right-to-left.)
|
247
|
+
*
|
248
|
+
* Multiplying a point in object space by this matrix will effectively skip the world space transformation,
|
249
|
+
* resulting in a coordinate placed directly into eye space. This has the obvious advantage of being faster
|
250
|
+
* than performing the operation in two steps (model and then view).
|
251
|
+
**/
|
252
|
+
getModelViewMatrix: function() { return this.matrices.modelview[this.depth]; },
|
253
|
+
|
254
|
+
/**
|
255
|
+
* Jax.MatrixStack#getInverseModelViewMatrix() -> mat4
|
256
|
+
*
|
257
|
+
* The opposite of the modelview matrix. Multiplying an eye-space coordinate by this matrix results in an
|
258
|
+
* object-space coordinate.
|
259
|
+
**/
|
260
|
+
getInverseModelViewMatrix: function() { return this.matrices.inverse_modelview[this.depth]; },
|
261
|
+
|
262
|
+
/**
|
263
|
+
* Jax.MatrixStack#getProjectionMatrix() -> mat4
|
264
|
+
*
|
265
|
+
* aka the screen matrix. Multiplying a point in eye space against the projection matrix results in a 4D
|
266
|
+
* vector in clip space. Dividing clip coordinates (XYZ) by the 4th component (W) yields a 3D vector in
|
267
|
+
* normalized device coordinates, where all components are in the range [-1,1]. These points are ultimately
|
268
|
+
* multiplied by screen dimensions to find a pixel position.
|
269
|
+
**/
|
270
|
+
getProjectionMatrix: function() { return this.matrices.projection[this.depth]; },
|
271
|
+
|
272
|
+
/**
|
273
|
+
* Jax.MatrixStack#getModelViewProjectionMatrix() -> mat4
|
274
|
+
*
|
275
|
+
* Returns the model, view and projection matrices combined into one.
|
276
|
+
**/
|
277
|
+
getModelViewProjectionMatrix: function() { return this.matrices.modelview_projection[this.depth]; },
|
278
|
+
|
279
|
+
/**
|
280
|
+
* Jax.MatrixStack#getInverseProjectionMatrix() -> mat4
|
281
|
+
*
|
282
|
+
* the opposite of the projection matrix. Multiplying a 4D vector in normalized device coordinates by
|
283
|
+
* its 4th component will result in clip space coordinates. Multiplying these clip space coordinates by the inverse
|
284
|
+
* projection matrix will result in a point in eye space, relative to the camera.
|
285
|
+
**/
|
286
|
+
getInverseProjectionMatrix: function() { return this.matrices.inverse_projection[this.depth]; },
|
287
|
+
|
288
|
+
initialize: function() {
|
289
|
+
this.depth = 0;
|
290
|
+
|
291
|
+
this.matrices = {
|
292
|
+
/* matrix depth, essentially the array index representing the current level in the stack. */
|
293
|
+
model: [mat4.create()],
|
294
|
+
inverse_model: [mat4.create()],
|
295
|
+
normal: [mat3.create()],
|
296
|
+
view: [mat4.create()],
|
297
|
+
inverse_view: [mat4.create()],
|
298
|
+
modelview: [mat4.create()],
|
299
|
+
inverse_modelview: [mat4.create()],
|
300
|
+
projection: [mat4.create()],
|
301
|
+
inverse_projection: [mat4.create()],
|
302
|
+
modelview_projection: [mat4.create()]
|
303
|
+
};
|
304
|
+
|
305
|
+
this.loadModelMatrix(mat4.IDENTITY);
|
306
|
+
this.loadViewMatrix(mat4.IDENTITY);
|
307
|
+
this.loadProjectionMatrix(mat4.IDENTITY); // there's no known data about the viewport at this time.
|
308
|
+
}
|
309
|
+
});
|
310
|
+
})();
|
@@ -0,0 +1,271 @@
|
|
1
|
+
/**
|
2
|
+
* class Array
|
3
|
+
* A standard JavaScript array.
|
4
|
+
**/
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Jax.Util
|
8
|
+
* Contains general-purpose utility and helper functions
|
9
|
+
**/
|
10
|
+
Jax.Util = {
|
11
|
+
findMaterial: function(name_or_instance) {
|
12
|
+
if (typeof(name_or_instance) == "string")
|
13
|
+
return Jax.Material.find(name_or_instance);
|
14
|
+
else if (name_or_instance.isKindOf && name_or_instance.isKindOf(Jax.Material))
|
15
|
+
return name_or_instance;
|
16
|
+
|
17
|
+
throw new Error("Material must be an instance of Jax.Material, or "+
|
18
|
+
"a string representing a material in the Jax material registry");
|
19
|
+
},
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Jax.Util.decodePickingColor(red, green, blue, alpha) -> Number
|
23
|
+
*
|
24
|
+
* Performs the reverse of the 'picking' shader by restoring a number
|
25
|
+
* that was previously encoded into the four color channels.
|
26
|
+
**/
|
27
|
+
decodePickingColor: function(red, green, blue, alpha) {
|
28
|
+
/* blue is a key. It is always max. So if it's 1, we're dealing with floats; else, bytes. */
|
29
|
+
if (blue == 1.0) {
|
30
|
+
red *= 255;
|
31
|
+
green *= 255;
|
32
|
+
}
|
33
|
+
return red * 256 + green;
|
34
|
+
},
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Jax.Util.vectorize(object) -> vec3
|
38
|
+
* - object (Object): any Object
|
39
|
+
*
|
40
|
+
* Analyzes the input object and returns a vec3 based on its contents. Input can be any of the following:
|
41
|
+
* * a vec3
|
42
|
+
* * an array
|
43
|
+
* * an object with {x, y, z} properties
|
44
|
+
* * an object with {0, 1, 2} properties
|
45
|
+
* * a string delimited with any combination of commas, spaces and/or tab characters. Examples:
|
46
|
+
* "x,y,z"
|
47
|
+
* "x y z"
|
48
|
+
* "x, y, z"
|
49
|
+
* "x\ty\tz"
|
50
|
+
* "x, \ty, \tz"
|
51
|
+
**/
|
52
|
+
vectorize: function(data) {
|
53
|
+
if (data) {
|
54
|
+
var res = [];//vec3.create();
|
55
|
+
if (typeof(data) == "string") {
|
56
|
+
var components = data.split(/[,\s]+/);
|
57
|
+
if (components.length >= 2) {
|
58
|
+
for (var i = 0; i < components.length; i++)
|
59
|
+
res[i] = parseFloat(components[i]);
|
60
|
+
}
|
61
|
+
return res;
|
62
|
+
}
|
63
|
+
if (data.length && data.length >= 3) return vec3.set(data, res);
|
64
|
+
else if (data.length == 2) return [data[0], data[1]];
|
65
|
+
if ((res[0] = data.x) != undefined && (res[1] = data.y) != undefined) {
|
66
|
+
if (data.z != undefined) res[2] = data.z;
|
67
|
+
return res;
|
68
|
+
}
|
69
|
+
if ((res[0] = data[0]) != undefined && (res[1] = data[1]) != undefined) {
|
70
|
+
if (data[2] != undefined) res[2] = data[2];
|
71
|
+
return res;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
throw new Error("Input argument for Jax.Util.vectorize not recognized: "+JSON.stringify(data));
|
75
|
+
},
|
76
|
+
|
77
|
+
/**
|
78
|
+
* Jax.Util.colorize(object) -> vec4
|
79
|
+
* - object (Object): any Object
|
80
|
+
*
|
81
|
+
* Analyzes the input object and returns a 4-component color vector based on its contents. Input can be any of the
|
82
|
+
* following:
|
83
|
+
* * an array
|
84
|
+
* * an object with {r, g, b, a} properties
|
85
|
+
* * an object with {0, 1, 2, 3} properties
|
86
|
+
* * a string delimited with any combination of commas, spaces and/or tab characters. Examples:
|
87
|
+
* "r,g,b,a"
|
88
|
+
* "r g b a"
|
89
|
+
* "r, g, b, a"
|
90
|
+
* "r\tg\tb\ta"
|
91
|
+
* "r, \tg, \tb, \ta"
|
92
|
+
*
|
93
|
+
* In all cases, if the alpha component is omitted, it defaults to 1.0.
|
94
|
+
**/
|
95
|
+
colorize: function(data) {
|
96
|
+
if (data) {
|
97
|
+
var res = [0,0,0,0];
|
98
|
+
|
99
|
+
if (typeof(data) == "string") {
|
100
|
+
var components = data.split(/[,\s]+/);
|
101
|
+
if (components.length >= 3) {
|
102
|
+
for (var i = 0; i < 4; i++)
|
103
|
+
if (components.length <= i)
|
104
|
+
res[i] = 1.0;
|
105
|
+
else
|
106
|
+
res[i] = parseFloat(components[i]);
|
107
|
+
}
|
108
|
+
return res;
|
109
|
+
}
|
110
|
+
if (data.length && data.length >= 3) {
|
111
|
+
res[0] = data[0];
|
112
|
+
res[1] = data[1];
|
113
|
+
res[2] = data[2];
|
114
|
+
if ((res[3] = data[3]) == undefined) res[3] = 1.0;
|
115
|
+
else res[3] = 1.0;
|
116
|
+
return res;
|
117
|
+
}
|
118
|
+
if ((res[0] = data.r) != undefined && (res[1] = data.g) != undefined && (res[2] = data.b) != undefined) {
|
119
|
+
if ((res[3] = data.a) == undefined) res[3] = 1.0;
|
120
|
+
return res;
|
121
|
+
}
|
122
|
+
if ((res[0] = data.red) != undefined && (res[1] = data.green) != undefined && (res[2] = data.blue) != undefined) {
|
123
|
+
if ((res[3] = data.alpha) == undefined) res[3] = 1.0;
|
124
|
+
return res;
|
125
|
+
}
|
126
|
+
if ((res[0] = data[0]) != undefined && (res[1] = data[1]) != undefined && (res[2] = data[2]) != undefined) {
|
127
|
+
if ((res[3] = data[3]) == undefined) res[3] = 1.0;
|
128
|
+
return res;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
throw new Error("Input argument for Jax.Util.colorize not recognized: "+JSON.stringify(data));
|
132
|
+
},
|
133
|
+
|
134
|
+
/**
|
135
|
+
* Jax.Util.properties(object) -> Array
|
136
|
+
* - object (Object): any Object
|
137
|
+
*
|
138
|
+
* Returns an array containing the names of all properties in the specified object.
|
139
|
+
**/
|
140
|
+
properties: function(object) {
|
141
|
+
var arr = [];
|
142
|
+
for (var i in object)
|
143
|
+
arr.push(i);
|
144
|
+
return arr;
|
145
|
+
},
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Jax.Util.merge(incoming, outgoing) -> outgoing
|
149
|
+
* Merges the two objects by copying all properties from _incoming_ into _outgoing_, replacing
|
150
|
+
* any properties that already exist. _outgoing_ will retain any properties that do not exist
|
151
|
+
* in _incoming_.
|
152
|
+
**/
|
153
|
+
merge: function(src, dst) {
|
154
|
+
if (!src) return;
|
155
|
+
var i, j, n;
|
156
|
+
|
157
|
+
function doComparison(i) {
|
158
|
+
if (src[i] == null) dst[i] = null;
|
159
|
+
else if (src[i].klass) dst[i] = src[i];
|
160
|
+
else if (Object.isArray(src[i])) Jax.Util.merge(src[i], dst[i] = dst[i] || []);
|
161
|
+
else if (typeof(src[i]) == "object") {
|
162
|
+
if (Object.isArray(dst[i])) {
|
163
|
+
n = {};
|
164
|
+
for (j = 0; j < dst[i].length; j++) n[j] = dst[i][j];
|
165
|
+
dst[i] = n;
|
166
|
+
}
|
167
|
+
Jax.Util.merge(src[i], dst[i] = dst[i] || {});
|
168
|
+
}
|
169
|
+
else dst[i] = src[i];
|
170
|
+
}
|
171
|
+
|
172
|
+
if (Object.isArray(src)) for (i = 0; i < src.length; i++) doComparison(i);
|
173
|
+
else for (i in src) doComparison(i);
|
174
|
+
|
175
|
+
return dst;
|
176
|
+
},
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Jax.Util.normalizeOptions(incoming, defaults) -> Object
|
180
|
+
* Receives incoming and formats it into a generic Object with a structure representing the given defaults.
|
181
|
+
* The returned object is always a brand-new object, to avoid polluting original incoming object.
|
182
|
+
* If the object contains a Jax.Class instance, that actual object is copied over. All other objects
|
183
|
+
* are cloned into brand-new objects.
|
184
|
+
**/
|
185
|
+
normalizeOptions: function(incoming, defaults) {
|
186
|
+
var result = {};
|
187
|
+
Jax.Util.merge(defaults, result);
|
188
|
+
Jax.Util.merge(incoming, result);
|
189
|
+
return result;
|
190
|
+
},
|
191
|
+
|
192
|
+
/**
|
193
|
+
* Jax.Util.sizeofFormat(glEnum) -> Number
|
194
|
+
*
|
195
|
+
* Returns the byte size of an array consisting of this type of element.
|
196
|
+
*
|
197
|
+
* Example:
|
198
|
+
*
|
199
|
+
* Jax.Util.sizeofFormat(GL_RGB)
|
200
|
+
* //=> 3
|
201
|
+
*
|
202
|
+
* If this isn't a recognized format, it is passed off to Jax.Util.enumName and an error is thrown.
|
203
|
+
**/
|
204
|
+
sizeofFormat: function(glEnum) {
|
205
|
+
switch(glEnum) {
|
206
|
+
case GL_ALPHA: return 1; // alpha component only
|
207
|
+
case GL_LUMINANCE: return 1; // luminance component only
|
208
|
+
case GL_RGB: return 3; // RGB triplet
|
209
|
+
case GL_RGBA: return 4; // all 4 components
|
210
|
+
case GL_LUMINANCE_ALPHA: return 2; // luminance/alpha pair
|
211
|
+
}
|
212
|
+
throw new Error("Unrecognized format: "+Jax.Util.enumName(glEnum));
|
213
|
+
},
|
214
|
+
|
215
|
+
/**
|
216
|
+
* Jax.Util.enumName(glEnum) -> String
|
217
|
+
* - glEnum (GLenum): a WebGL enumeration, presumably numeric.
|
218
|
+
*
|
219
|
+
* Returns the name of the enumeration prefixed with "GL_" that shares a value with the passed-in enum.
|
220
|
+
*
|
221
|
+
* If the enum can't be found (this happens sometimes when an enum crops up that isn't in the WebGL spec),
|
222
|
+
* then a string containing both the decimal and hexadecimal form of this enum is returned:
|
223
|
+
*
|
224
|
+
* "(unrecognized enum: 36059 [0x8cdb])"
|
225
|
+
*
|
226
|
+
* This is primarily for debugging and error reporting.
|
227
|
+
**/
|
228
|
+
enumName: function(glEnum) {
|
229
|
+
var global = Jax.getGlobal();
|
230
|
+
for (var i in global) {
|
231
|
+
if (i.indexOf("GL_") == 0 && global[i] == glEnum)
|
232
|
+
return i;
|
233
|
+
}
|
234
|
+
return "(unrecognized enum: "+glEnum+" [0x"+parseInt(glEnum).toString(16)+"])";
|
235
|
+
},
|
236
|
+
|
237
|
+
/**
|
238
|
+
* Jax.Util.addRequestedHelpers(klass) -> Array
|
239
|
+
* - klass (Jax.Class): A class into which to mix the helpers.
|
240
|
+
*
|
241
|
+
* First, if +ApplicationHelper+ is defined, it is automatically mixed into the specified class.
|
242
|
+
*
|
243
|
+
* Then, the class is searched for a #helpers method; if it exists, it is expected to return an array of
|
244
|
+
* Helpers (created with +Jax.Helper.create({...})+ ). Each element in the array returned by #helpers is
|
245
|
+
* then mixed into the class.
|
246
|
+
*
|
247
|
+
* An array of all helpers that were just mixed into the target class is returned.
|
248
|
+
*
|
249
|
+
* As of Jax v1.1.0, you may also set the array of helpers directly on the +helpers+ property
|
250
|
+
* of a class, instead of defining a function.
|
251
|
+
**/
|
252
|
+
addRequestedHelpers: function(klass) {
|
253
|
+
var helpers = [];
|
254
|
+
if (typeof(ApplicationHelper) != "undefined") {
|
255
|
+
helpers.push(ApplicationHelper);
|
256
|
+
klass.addMethods(ApplicationHelper);
|
257
|
+
}
|
258
|
+
if (klass.prototype.helpers) {
|
259
|
+
var helper_array;
|
260
|
+
if (typeof(klass.prototype.helpers) == "function")
|
261
|
+
helper_array = klass.prototype.helpers.call(klass);
|
262
|
+
else helper_array = klass.prototype.helpers;
|
263
|
+
|
264
|
+
for (var i = 0; i < helper_array.length; i++) {
|
265
|
+
helpers.push(helper_array[i]);
|
266
|
+
klass.addMethods(helper_array[i]);
|
267
|
+
}
|
268
|
+
}
|
269
|
+
return helpers;
|
270
|
+
}
|
271
|
+
};
|
@@ -0,0 +1,43 @@
|
|
1
|
+
//= require "jax/vendor/ejs"
|
2
|
+
//= require "jax/vendor/glMatrix"
|
3
|
+
//= require "jax/prototype/class"
|
4
|
+
//= require "jax/core/helper"
|
5
|
+
//= require "jax/core/math"
|
6
|
+
//= require "jax/core/util"
|
7
|
+
//= require "jax/core/matrix_stack"
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Global#debugAssert(expr[, msg]) -> undefined
|
11
|
+
* a global debugAssert method that will do nothing in production, and fail if expr is false
|
12
|
+
* in any other run mode. If msg is given, an error with that message is raised. Otherwise,
|
13
|
+
* a more generic error is raised.
|
14
|
+
**/
|
15
|
+
window.debugAssert = function(expr, msg) {
|
16
|
+
if (Jax.environment != Jax.PRODUCTION && !expr)
|
17
|
+
{
|
18
|
+
var error = new Error(msg || "debugAssert failed");
|
19
|
+
if (error.stack) error = new Error((msg || "debugAssert failed")+"\n\n"+error.stack);
|
20
|
+
throw error;
|
21
|
+
}
|
22
|
+
};
|
23
|
+
|
24
|
+
// If glMatrixArrayType isn't simply Array, then most browsers (FF, Chrome) have a pretty
|
25
|
+
// crappy implementation of toString() that actually tells you nothing about the array's
|
26
|
+
// contents. This makes the #toString method a little more Array-like.
|
27
|
+
//
|
28
|
+
// Ex: "[Float32Array: -100,-100,-100]"
|
29
|
+
if (glMatrixArrayType.prototype.toString != Array.prototype.toString) {
|
30
|
+
glMatrixArrayType.prototype.toString = function() {
|
31
|
+
var s = "["+glMatrixArrayType.name+": ";
|
32
|
+
var d = false;
|
33
|
+
for (var i in this) {
|
34
|
+
if (parseInt(i) == i) {
|
35
|
+
if (d) s += ",";
|
36
|
+
s += this[i];
|
37
|
+
d = true;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
s += "]";
|
41
|
+
return s;
|
42
|
+
}
|
43
|
+
}
|