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,255 @@
|
|
1
|
+
/**
|
2
|
+
* class Jax.DataSegment
|
3
|
+
*
|
4
|
+
* Returned by the mapping functions in +Jax.DataRegion+, Jax.DataSegment wraps
|
5
|
+
* around the typed arrays maintained by that class. It is intended to look
|
6
|
+
* and feel just like the underlying object and you can use it as such.
|
7
|
+
*
|
8
|
+
* The purpose of Jax.DataSegment is to provide a handle to the data segments
|
9
|
+
* maintained by Jax.DataRegion, because the underlying typed arrays may be
|
10
|
+
* reinitialized at any time as the data region itself is adjusted.
|
11
|
+
*
|
12
|
+
* You can also create data "groups" to further organize the data.
|
13
|
+
* An example would be to group a Float32Array into sets of 3
|
14
|
+
* for use as (X, Y, Z) vertex information:
|
15
|
+
*
|
16
|
+
* var vertexData = new Jax.DataSegment(Float32Array, [0,1,0, -1,0,0, 1,0,0]);
|
17
|
+
* var vertices = vertexData.group(3);
|
18
|
+
* for (var i = 0; i < vertices.length; i++) {
|
19
|
+
* var vertex = vertices[i].array;
|
20
|
+
* var x = vertex[0], y = vertex[1], z = vertex[2];
|
21
|
+
* // . . .
|
22
|
+
* }
|
23
|
+
*
|
24
|
+
**/
|
25
|
+
Jax.DataSegment = (function() {
|
26
|
+
var DataGroup = Jax.Class.create({
|
27
|
+
initialize: function(raw, size) {
|
28
|
+
this.raw = raw;
|
29
|
+
this.type = raw.type;
|
30
|
+
this.size = size;
|
31
|
+
this.length = 0;
|
32
|
+
},
|
33
|
+
|
34
|
+
push: function(seg) { this[this.length] = seg; this.length++; return seg; },
|
35
|
+
pop: function() { this.length--; var ret = this[this.length]; delete this[this.length]; return ret; },
|
36
|
+
getRawData: function() { return this.raw; }
|
37
|
+
});
|
38
|
+
|
39
|
+
function populateGroup(self, group, size) {
|
40
|
+
var i, j, bytes = self.type.BYTES_PER_ELEMENT, len = 0, buf;
|
41
|
+
for (i = 0; i < self.array.length; i += size) {
|
42
|
+
if (buf = group[len]) {
|
43
|
+
// update existing group
|
44
|
+
buf.setArray(new self.type(self.buffer, self.byteOffset + i*bytes, size));
|
45
|
+
}
|
46
|
+
else {
|
47
|
+
// create new group
|
48
|
+
buf = new Jax.DataSegment(self.type, self.buffer, self.byteOffset + i*bytes, size);
|
49
|
+
group.push(buf);
|
50
|
+
}
|
51
|
+
len++;
|
52
|
+
}
|
53
|
+
// remove any groups remaining after data truncation
|
54
|
+
while (group.length > len) group.pop();
|
55
|
+
}
|
56
|
+
|
57
|
+
var klass = Jax.Class.create({
|
58
|
+
/**
|
59
|
+
* new Jax.DataSegment(type, buffer, byteOffset, length)
|
60
|
+
* - type (Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array): the typed array type
|
61
|
+
* - buffer (ArrayBuffer): the array buffer containing at least enough bytes to contain this data segment
|
62
|
+
* - byteOffset (Number): the offset into the ArrayBuffer of the first byte of this segment
|
63
|
+
* - length (Number): the length in elements (not bytes) of this segment
|
64
|
+
*
|
65
|
+
* This class is not intended to be instantiated directly, although there's
|
66
|
+
* nothing technically keeping you from doing so. It is preferred that you
|
67
|
+
* make use of +Jax.DataRegion+.
|
68
|
+
*
|
69
|
+
**/
|
70
|
+
initialize: function(type, buffer, byteOffset, length) {
|
71
|
+
this.type = type;
|
72
|
+
this.groups = [];
|
73
|
+
try {
|
74
|
+
if (arguments.length == 2)
|
75
|
+
if (buffer instanceof this.type) this.setArray(buffer);
|
76
|
+
else this.setArray(new type(buffer));
|
77
|
+
else if (arguments.length == 1)
|
78
|
+
this.setArray(type);
|
79
|
+
else
|
80
|
+
this.setArray(new type(buffer, byteOffset, length));
|
81
|
+
} catch(e) {
|
82
|
+
throw new Error("Error: "+e+" while constructing segment from "+
|
83
|
+
"("+type+", "+buffer+"["+buffer.byteLength+"], "+byteOffset+", "+length+")");
|
84
|
+
}
|
85
|
+
},
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Jax.DataSegment#setArray(buf) -> Jax.DataSegment
|
89
|
+
* - buf (Array): The array whose values to assign. Can be any array or enumeration
|
90
|
+
* compatible with the #set method exposed by the Typed Arrays specification.
|
91
|
+
*
|
92
|
+
* Assigns the given buffer to the +array+ property of this data segment. Note that this
|
93
|
+
* assumes the reference of the given buffer; that is, further changes to the buffer will
|
94
|
+
* be reflected directly within this data segment and any data groups attached to it.
|
95
|
+
*
|
96
|
+
* Returns this data segment.
|
97
|
+
**/
|
98
|
+
setArray: function(buf) {
|
99
|
+
// if (this.length)
|
100
|
+
// for (var i = 0; i < this.length; i++)
|
101
|
+
// delete this[i];
|
102
|
+
|
103
|
+
/**
|
104
|
+
* Jax.DataSegment#array -> Array
|
105
|
+
* the underlying typed array which contains the segment data.
|
106
|
+
**/
|
107
|
+
this.array = buf;
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Jax.DataSegment#length -> Number
|
111
|
+
* the length of the underlying typed array in elements. This property
|
112
|
+
* can only be changed via a call to +Jax.DataSegment#setArray+.
|
113
|
+
**/
|
114
|
+
this.length = buf.length;
|
115
|
+
|
116
|
+
/**
|
117
|
+
* Jax.DataSegment#buffer -> ArrayBuffer
|
118
|
+
* the underlying raw data buffer
|
119
|
+
**/
|
120
|
+
this.buffer = buf.buffer;
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Jax.DataSegment#byteOffset -> Number
|
124
|
+
* the offset in bytes into the +buffer+ at which this data segment begins
|
125
|
+
**/
|
126
|
+
this.byteOffset = buf.byteOffset;
|
127
|
+
|
128
|
+
/**
|
129
|
+
* Jax.DataSegment#byteLength -> Number
|
130
|
+
* the number of bytes in the +buffer+ that this data segment contains
|
131
|
+
**/
|
132
|
+
this.byteLength = buf.byteLength;
|
133
|
+
|
134
|
+
// define index setters/getters
|
135
|
+
// var self = this;
|
136
|
+
// for (var i = 0; i < buf.length; i++) {
|
137
|
+
// Object.defineProperty(self, i, (function() {
|
138
|
+
// var j = i;
|
139
|
+
// return {
|
140
|
+
// configurable: true,
|
141
|
+
// enumerable: true,
|
142
|
+
// get: function() { return self.array[j]; },
|
143
|
+
// set: function(v) { return self.array[j] = v; }
|
144
|
+
// }
|
145
|
+
// })());
|
146
|
+
// }
|
147
|
+
|
148
|
+
// update groups
|
149
|
+
for (var i = 0; i < this.groups.length; i++) {
|
150
|
+
var group = this.groups[i];
|
151
|
+
var size = group.size;
|
152
|
+
populateGroup(this, group, size);
|
153
|
+
}
|
154
|
+
|
155
|
+
return this;
|
156
|
+
},
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Jax.DataSegment#group(size) -> Array<Jax.DataSegment>
|
160
|
+
* - size (Number): the size, in array elements, of each group
|
161
|
+
*
|
162
|
+
* Creates a new view of this array laid out in the form of a 2D array.
|
163
|
+
* Each top-level element of the group contains a new instance of +Jax.DataSegment+,
|
164
|
+
* which in turn contains an +array+ property of exactly +size+ elements.
|
165
|
+
*
|
166
|
+
* This is useful for organizing a data segment into a more convenient structure,
|
167
|
+
* for instance, grouping a raw set of Float values into 3-dimensional Vertices:
|
168
|
+
*
|
169
|
+
* var segment = region.map(Float32Array, [1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
170
|
+
* var vertices = segment.group(3);
|
171
|
+
* //=> vertices now contains 3 segments containing 3 floats each
|
172
|
+
*
|
173
|
+
* for (var i = 0; i < vertices.length; i++) {
|
174
|
+
* var vertex = vertices[i].array;
|
175
|
+
* var x = vertices[0], y = vertices[1], z = vertices[2];
|
176
|
+
* // . . .
|
177
|
+
* }
|
178
|
+
*
|
179
|
+
* The group still points to the same physical memory as the segment it is
|
180
|
+
* derived from; therefore, changes to the parent segment will be immediately
|
181
|
+
* reflected within the group.
|
182
|
+
*
|
183
|
+
* The number of elements in the parent segment must be divisible by +size+. Otherwise,
|
184
|
+
* an error is raised.
|
185
|
+
**/
|
186
|
+
group: function(size) {
|
187
|
+
if (this.array.length % size != 0)
|
188
|
+
throw new Error("Data segment size "+this.array.length+" is not divisible by group size "+size);
|
189
|
+
var group = new DataGroup(this, size);
|
190
|
+
populateGroup(this, group, size);
|
191
|
+
this.groups.push(group);
|
192
|
+
return group;
|
193
|
+
},
|
194
|
+
|
195
|
+
/**
|
196
|
+
* Jax.DataSegment#removeGroup(group) -> Jax.DataSegment
|
197
|
+
* - group (Jax.DataSegment): the group to be removed
|
198
|
+
*
|
199
|
+
* See +Jax.DataSegment#group+.
|
200
|
+
*
|
201
|
+
* When a group is created, its parent segment maintains a handle to it. This way,
|
202
|
+
* if the underlying array belonging to the parent segment is replaced with a
|
203
|
+
* completely different array (a common occurrance when a Jax.DataRegion needs
|
204
|
+
* to reallocate a new block of memory), the parent segment can notify its groups
|
205
|
+
* that their arrays, in turn, must also be replaced.
|
206
|
+
*
|
207
|
+
* This has the unfortunate side effect of maintaining a reference to the group
|
208
|
+
* even after it has outlived its usefulness. If you are done using a group,
|
209
|
+
* the JavaScript garbage collector cannot recapture the group unless you first
|
210
|
+
* remove it from its parent data segment.
|
211
|
+
*
|
212
|
+
* After the removal, this data segment is returned.
|
213
|
+
**/
|
214
|
+
removeGroup: function(group) {
|
215
|
+
var index;
|
216
|
+
if (typeof(group) == 'number') index = group;
|
217
|
+
else index = this.groups.indexOf(group);
|
218
|
+
|
219
|
+
if (index != -1)
|
220
|
+
this.groups.splice(index, 1);
|
221
|
+
return this;
|
222
|
+
},
|
223
|
+
|
224
|
+
/**
|
225
|
+
* Jax.DataSegment#set(array[, offset]) -> void
|
226
|
+
* - array (Array): any enumerable or array that is compatible with the Typed Arrays specification
|
227
|
+
* - offset (Number): an optional offset, in elements, into this data segment to begin copying the array
|
228
|
+
*
|
229
|
+
* Copies the data from +array+ into the +array+ property of this data segment, per the
|
230
|
+
* Typed Arrays specification.
|
231
|
+
**/
|
232
|
+
set: function(i, v) {
|
233
|
+
this.array.set.apply(this.array, arguments);
|
234
|
+
},
|
235
|
+
|
236
|
+
/**
|
237
|
+
* Jax.DataSegment#subarray(begin, end) -> Jax.DataSegment
|
238
|
+
* - begin (Number): the start of the subarray, inclusive
|
239
|
+
* - end (Number): the end of the subarray, exclusive
|
240
|
+
*
|
241
|
+
* Constructs a new data segment from a subarray of this data segment with the specified range.
|
242
|
+
* This is effectively similar to calling the +subarray+ method of a typed array.
|
243
|
+
*
|
244
|
+
**/
|
245
|
+
subarray: function(begin, end) {
|
246
|
+
return new Jax.DataSegment(this.type, this.array.subarray(begin, end));
|
247
|
+
},
|
248
|
+
|
249
|
+
toString: function() {
|
250
|
+
return "{array:"+this.array.toString()+"}";
|
251
|
+
}
|
252
|
+
});
|
253
|
+
|
254
|
+
return klass;
|
255
|
+
})();
|
@@ -0,0 +1,99 @@
|
|
1
|
+
/**
|
2
|
+
* Jax.Events
|
3
|
+
*
|
4
|
+
* Generic event listener functionality which is added to a number of Jax objects
|
5
|
+
* by default.
|
6
|
+
**/
|
7
|
+
Jax.Events = (function() {
|
8
|
+
return {
|
9
|
+
/**
|
10
|
+
* mixin Jax.Events.Methods
|
11
|
+
*
|
12
|
+
* Methods which can be added to potential event emitters.
|
13
|
+
**/
|
14
|
+
Methods: {
|
15
|
+
/**
|
16
|
+
* Jax.Events.Methods#getEventListeners(type) -> Array
|
17
|
+
* - type (String): the type of event to retrieve listeners for.
|
18
|
+
*
|
19
|
+
* Returns an array containing all event listeners associated with the specified
|
20
|
+
* event type.
|
21
|
+
**/
|
22
|
+
getEventListeners: function(name) {
|
23
|
+
this.event_listeners = this.event_listeners || {};
|
24
|
+
return this.event_listeners[name] = this.event_listeners[name] || {length:0};
|
25
|
+
},
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Jax.Events.Methods#addEventListener(type, callback) -> Number
|
29
|
+
* - type (String): the type of event to listen for.
|
30
|
+
* - callback (Function): the callback function to receive the event
|
31
|
+
*
|
32
|
+
* Adds the specified callback to the list of event listeners to be called
|
33
|
+
* when the given event type is fired.
|
34
|
+
*
|
35
|
+
* Returns the numeric array index of the listener to be added.
|
36
|
+
**/
|
37
|
+
addEventListener: function(name, callback) {
|
38
|
+
var ary = this.getEventListeners(name);
|
39
|
+
var index = ary.length++;
|
40
|
+
ary[index] = callback;
|
41
|
+
return index;
|
42
|
+
},
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Jax.Events.Methods#removeEventListener(type, index) -> Function | undefined
|
46
|
+
* - type (String): the type of event to remove the listener from.
|
47
|
+
* - index (Number): the numeric index of the callback to be removed.
|
48
|
+
*
|
49
|
+
* Removes the callback represented by the index (as returned by
|
50
|
+
* Jax.Events.Methods#addEventListener) from the event listener of
|
51
|
+
* the specified type. Other event types are unaffected, even if they
|
52
|
+
* contain the exact same callback function.
|
53
|
+
*
|
54
|
+
* Returns the original callback function, or undefined if it was not found.
|
55
|
+
**/
|
56
|
+
removeEventListener: function(name, index) {
|
57
|
+
if (!name || index == undefined) throw new Error("both event type and listener index are required");
|
58
|
+
var ary = this.getEventListeners(name);
|
59
|
+
var func = ary[index];
|
60
|
+
if (ary[index]) delete ary[index];
|
61
|
+
// ary.splice(index, 1);
|
62
|
+
return func;
|
63
|
+
},
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Jax.Events.Methods#fireEvent(type[, event]) -> undefined
|
67
|
+
* - type (String): the type of event to fire
|
68
|
+
* - event (Object): an optional object to be passed as an argument
|
69
|
+
* to the event listeners.
|
70
|
+
*
|
71
|
+
* Fires an event. All listeners monitoring the specified event type
|
72
|
+
* will receive the event object as an argument. If specified, the
|
73
|
+
* event object's +type+ property is automatically assigned to the
|
74
|
+
* specified type unless the object already has a +type+ property.
|
75
|
+
* Examples:
|
76
|
+
*
|
77
|
+
* this.addEventListener('loaded', function(obj) { alert(obj.type); });
|
78
|
+
* this.fireEvent('loaded', { });
|
79
|
+
* // "loaded"
|
80
|
+
*
|
81
|
+
* this.addEventListener('loaded', function(obj) { alert(obj.type); });
|
82
|
+
* this.fireEvent('loaded', {type:'none'});
|
83
|
+
* // "none"
|
84
|
+
*
|
85
|
+
* Note that the callback is fired using +call+, so the +this+ object
|
86
|
+
* within a callback will represent the object that fired the event.
|
87
|
+
*
|
88
|
+
**/
|
89
|
+
fireEvent: function(name, event_object) {
|
90
|
+
var listeners = this.getEventListeners(name);
|
91
|
+
if (event_object && event_object.type == undefined)
|
92
|
+
event_object.type = name;
|
93
|
+
for (var i in listeners)
|
94
|
+
if (i == 'length') continue;
|
95
|
+
else listeners[i].call(this, event_object);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
};
|
99
|
+
})();
|
@@ -0,0 +1,316 @@
|
|
1
|
+
/**
|
2
|
+
* class Jax.Framebuffer
|
3
|
+
*
|
4
|
+
* Used for rendering images off-screen and capturing the result.
|
5
|
+
**/
|
6
|
+
Jax.Framebuffer = (function() {
|
7
|
+
function build(context, self) {
|
8
|
+
var handle = context.glCreateFramebuffer();
|
9
|
+
var width = self.options.width, height = self.options.height;
|
10
|
+
|
11
|
+
self.setHandle(context, handle);
|
12
|
+
context.glBindFramebuffer(GL_FRAMEBUFFER, handle);
|
13
|
+
|
14
|
+
// depth and stencil attachment
|
15
|
+
if (self.options.depth && self.options.stencil) {
|
16
|
+
handle.depthstencilbuffer = context.glCreateRenderbuffer();
|
17
|
+
context.glBindRenderbuffer(GL_RENDERBUFFER, handle.depthstencilbuffer);
|
18
|
+
context.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, width, height);
|
19
|
+
context.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, handle.depthstencilbuffer);
|
20
|
+
context.glBindRenderbuffer(GL_RENDERBUFFER, null);
|
21
|
+
}
|
22
|
+
|
23
|
+
// depth attachment
|
24
|
+
if (self.options.depth && !self.options.stencil) {
|
25
|
+
handle.depthbuffer = context.glCreateRenderbuffer();
|
26
|
+
context.glBindRenderbuffer(GL_RENDERBUFFER, handle.depthbuffer);
|
27
|
+
context.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
|
28
|
+
context.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, handle.depthbuffer);
|
29
|
+
context.glBindRenderbuffer(GL_RENDERBUFFER, null);
|
30
|
+
}
|
31
|
+
|
32
|
+
// stencil attachment
|
33
|
+
if (self.options.stencil && !self.options.depth) {
|
34
|
+
handle.stencilbuffer = context.glCreateRenderbuffer();
|
35
|
+
context.glBindRenderbuffer(GL_RENDERBUFFER, handle.stencilbuffer);
|
36
|
+
context.glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, width, height);
|
37
|
+
context.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, handle.stencilbuffer);
|
38
|
+
context.glBindRenderbuffer(GL_RENDERBUFFER, null);
|
39
|
+
}
|
40
|
+
|
41
|
+
// texture attachments
|
42
|
+
handle.textures = [];
|
43
|
+
var attachment = GL_COLOR_ATTACHMENT0;
|
44
|
+
for (var i = 0; i < self.options.colors.length; i++) {
|
45
|
+
var format = self.options.colors[i];
|
46
|
+
var texture_options = {
|
47
|
+
format:GL_RGBA,
|
48
|
+
width:width,
|
49
|
+
height:height,
|
50
|
+
min_filter:GL_LINEAR,
|
51
|
+
mag_filter:GL_LINEAR,
|
52
|
+
wrap_s:GL_CLAMP_TO_EDGE,
|
53
|
+
wrap_t:GL_CLAMP_TO_EDGE,
|
54
|
+
generate_mipmap:false
|
55
|
+
};
|
56
|
+
if (typeof(format) != "number") { texture_options = Jax.Util.normalizeOptions(format, texture_options); }
|
57
|
+
else { texture_options.format = format; }
|
58
|
+
handle.textures[i] = new Jax.Texture(texture_options);
|
59
|
+
|
60
|
+
if (handle.textures[i].getTarget() == GL_TEXTURE_2D)
|
61
|
+
context.glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, handle.textures[i].getHandle(context), 0);
|
62
|
+
else
|
63
|
+
context.glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
64
|
+
handle.textures[i].getHandle(context), 0);
|
65
|
+
|
66
|
+
attachment++;
|
67
|
+
}
|
68
|
+
|
69
|
+
checkStatus(context, self);
|
70
|
+
}
|
71
|
+
|
72
|
+
function checkStatus(context, self) {
|
73
|
+
var status = context.glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
74
|
+
self.unbind(context);
|
75
|
+
switch(status) {
|
76
|
+
case GL_FRAMEBUFFER_COMPLETE:
|
77
|
+
// success!
|
78
|
+
break;
|
79
|
+
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
80
|
+
throw new Error("Jax.Framebuffer: one or more attachments is incomplete. (GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT)");
|
81
|
+
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
|
82
|
+
throw new Error("Jax.Framebuffer: there are no images attached to the framebuffer. (GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT)");
|
83
|
+
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
|
84
|
+
throw new Error("Jax.Framebuffer: all attachments must have the same dimensions. (GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS)");
|
85
|
+
case GL_FRAMEBUFFER_UNSUPPORTED:
|
86
|
+
throw new Error("Jax.Framebuffer: the requested framebuffer layout is unsupported on this hardware. (GL_FRAMEBUFFER_UNSUPPORTED)");
|
87
|
+
case (Jax.getGlobal()['GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER'] || 0x8cdb):
|
88
|
+
// a cryptic error that is not in the WebGL spec. Took me way too long to figure this out and I'm still not
|
89
|
+
// sure why it happens...
|
90
|
+
// but it seems to crop up primarily when no textures are attached.
|
91
|
+
// from opengl (not webgl) spec: The value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT must not be NONE for any
|
92
|
+
// color attachment point(s) named by DRAW_BUFFER.
|
93
|
+
throw new Error("Jax.Framebuffer: make sure the framebuffer has at least 1 texture attachment. (GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER)");
|
94
|
+
default:
|
95
|
+
var which;
|
96
|
+
for (which in context.gl)
|
97
|
+
if (context.gl[which] == status)
|
98
|
+
throw new Error("Jax.Framebuffer: an unknown error occurred. ("+status+" - "+which+")");
|
99
|
+
throw new Error("Jax.Framebuffer: an unknown error occurred. ("+status+")");
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
return Jax.Class.create({
|
104
|
+
/**
|
105
|
+
* new Jax.Framebuffer([options])
|
106
|
+
* - options (Object): a generic object containing the following optional properties:
|
107
|
+
*
|
108
|
+
* * colors: an array of color formats such as GL_RGBA, GL_RGB, etc. The _colors_ array may
|
109
|
+
* be empty if no color attachments are needed. Defaults to [GL_RGBA] unless _color_
|
110
|
+
* is specified.
|
111
|
+
*
|
112
|
+
* Alternatively, an options object can be used. This object will be passed into
|
113
|
+
* Jax.Texture().
|
114
|
+
*
|
115
|
+
* * color: optionally, in place of a colors array, a single color format as above. If both
|
116
|
+
* _color_ and _colors_ are specified, _color_ is simply added to the _colors_ array.
|
117
|
+
* * depth: true if a depth attachment is required, false otherwise. Defaults to false.
|
118
|
+
* * stencil: true if a stencil attachment is required, false otherwise. Defaults to false.
|
119
|
+
* * width: the width of the render and color buffers. All render and color buffers for a given
|
120
|
+
* framebuffer must have the same width. Defaults to 512.
|
121
|
+
* * height: the height of the render and color buffers. All render and color buffers for a given
|
122
|
+
* framebuffer must have the same height. Defaults to 512.
|
123
|
+
*
|
124
|
+
**/
|
125
|
+
initialize: function(options) {
|
126
|
+
var defaults = {
|
127
|
+
depth: false,
|
128
|
+
stencil: false,
|
129
|
+
width:512,
|
130
|
+
height:512
|
131
|
+
};
|
132
|
+
if (!(options && (options.color || options.colors))) defaults.colors = [GL_RGBA];
|
133
|
+
|
134
|
+
this.handles = {};
|
135
|
+
this.options = options = Jax.Util.normalizeOptions(options, defaults);
|
136
|
+
if (options.color != undefined) {
|
137
|
+
if (options.colors != undefined) options.colors.push(options.color);
|
138
|
+
else options.colors = [options.color];
|
139
|
+
delete options.color;
|
140
|
+
}
|
141
|
+
},
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Jax.Framebuffer#cubeFace(context, texIndex, faceEnum[, callback]) -> Jax.Framebuffer
|
145
|
+
* - context (Jax.Context): a Jax context
|
146
|
+
* - texIndex (number): the index of the cube map texture
|
147
|
+
* - faceEnum (enum): the cube map face to bind
|
148
|
+
* - callback (function): an optional callback. If given, the framebuffer will be automatically unbound
|
149
|
+
* after the callback returns. Otherwise, the framebuffer will remain bound.
|
150
|
+
*
|
151
|
+
* For cube map framebuffers only, this will bind the specified cube map face to its color buffer position.
|
152
|
+
* The faceEnum can be any of the following face enums:
|
153
|
+
*
|
154
|
+
* 0: GL_TEXTURE_CUBE_MAP_POSITIVE_X
|
155
|
+
* 1: GL_TEXTURE_CUBE_MAP_NEGATIVE_X
|
156
|
+
* 2: GL_TEXTURE_CUBE_MAP_POSITIVE_Y
|
157
|
+
* 3: GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
|
158
|
+
* 4: GL_TEXTURE_CUBE_MAP_POSITIVE_Z
|
159
|
+
* 5: GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
|
160
|
+
*
|
161
|
+
* Example:
|
162
|
+
*
|
163
|
+
* fb.bindCubeFace(context, 0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, function() {
|
164
|
+
* // render to +X cube face
|
165
|
+
* });
|
166
|
+
* fb.bindCubeFace(context, 0, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, function() {
|
167
|
+
* // render to -Z cube face
|
168
|
+
* });
|
169
|
+
**/
|
170
|
+
bindCubeFace: function(context, texIndex, faceEnum, callback) {
|
171
|
+
if (!this.getHandle(context)) build(context, this);
|
172
|
+
var texture = this.getHandle(context).textures[texIndex];
|
173
|
+
if (texture.options.target != GL_TEXTURE_CUBE_MAP)
|
174
|
+
throw new Error("Texture at index "+texIndex+" is not a cube map!");
|
175
|
+
|
176
|
+
this.bind(context);
|
177
|
+
context.glFramebufferTexture2D(GL_FRAMEBUFFER, window['GL_COLOR_ATTACHMENT'+texIndex],
|
178
|
+
faceEnum, texture.getHandle(context), 0);
|
179
|
+
|
180
|
+
if (callback) {
|
181
|
+
callback();
|
182
|
+
this.unbind(context);
|
183
|
+
}
|
184
|
+
|
185
|
+
return this;
|
186
|
+
},
|
187
|
+
|
188
|
+
/**
|
189
|
+
* Jax.Framebuffer#bind(context[, callback]) -> Jax.Framebuffer
|
190
|
+
* - context (Jax.Context): the context to bind this framebuffer to
|
191
|
+
* - callback (Function): an optional callback. If given, the framebuffer will
|
192
|
+
* be automatically unbound after the function returns.
|
193
|
+
*
|
194
|
+
* If a callback is not specified, the framebuffer will be bound and then returned.
|
195
|
+
* Otherwise, the framebuffer will be bound; the callback will be called; then the
|
196
|
+
* framebuffer will be automatically unbound prior to returning the framebuffer
|
197
|
+
* itself.
|
198
|
+
*
|
199
|
+
**/
|
200
|
+
bind: function(context, callback) {
|
201
|
+
if (!this.getHandle(context)) build(context, this);
|
202
|
+
context.glBindFramebuffer(GL_FRAMEBUFFER, this.getHandle(context));
|
203
|
+
|
204
|
+
if (callback) {
|
205
|
+
callback.call(this);
|
206
|
+
this.unbind(context);
|
207
|
+
}
|
208
|
+
|
209
|
+
return this;
|
210
|
+
},
|
211
|
+
|
212
|
+
/**
|
213
|
+
* Jax.Framebuffer#unbind(context) -> Jax.Framebuffer
|
214
|
+
* - context (Jax.Context): the context to bind this framebuffer to
|
215
|
+
*
|
216
|
+
* Unbinds this framebuffer from the specified context. Note that this is
|
217
|
+
* unnecessary if Jax.Framebuffer#bind() was called with a callback.
|
218
|
+
**/
|
219
|
+
unbind: function(context) {
|
220
|
+
context.glBindFramebuffer(GL_FRAMEBUFFER, null);
|
221
|
+
return this;
|
222
|
+
},
|
223
|
+
|
224
|
+
/**
|
225
|
+
* Jax.Framebuffer#viewport(context) -> Jax.Framebuffer
|
226
|
+
* - context (Jax.Context): the context to set the viewport for
|
227
|
+
*
|
228
|
+
* Sets the viewport up for this framebuffer within the specified context
|
229
|
+
* according to the +width+ and +height+ options given for this framebuffer.
|
230
|
+
*
|
231
|
+
**/
|
232
|
+
viewport: function(context) {
|
233
|
+
context.glViewport(0,0,this.options.width,this.options.height);
|
234
|
+
return this;
|
235
|
+
},
|
236
|
+
|
237
|
+
/**
|
238
|
+
* Jax.Framebuffer#getTexture(context[, index]) -> Jax.Texture
|
239
|
+
* - context (Jax.Context): the context to retrieve the texture for
|
240
|
+
* - index (Number): the numeric index of the texture to retrieve.
|
241
|
+
* Defaults to 0.
|
242
|
+
*
|
243
|
+
* Returns the specified instance of Jax.Texture associated with this
|
244
|
+
* framebuffer and the specified context. If index is not given, the
|
245
|
+
* first texture available is returned.
|
246
|
+
**/
|
247
|
+
getTexture: function(context, index) {
|
248
|
+
return this.getHandle(context) && this.getHandle(context).textures[index];
|
249
|
+
},
|
250
|
+
|
251
|
+
/**
|
252
|
+
* Jax.Framebuffer#getTextureHandle(context[, index]) -> WebGLTexture
|
253
|
+
* - context (Jax.Context): the context to retrieve the texture handle for
|
254
|
+
* - index (Number): the numeric index of the texture handle to retrieve.
|
255
|
+
* Defaults to 0.
|
256
|
+
*
|
257
|
+
* Returns the WebGL texture handle associated with this
|
258
|
+
* framebuffer and the specified context. If index is not given, the
|
259
|
+
* first texture available is returned.
|
260
|
+
*
|
261
|
+
* This is equivalent to:
|
262
|
+
*
|
263
|
+
* framebuffer.getTexture(context, index).getHandle(context);
|
264
|
+
*
|
265
|
+
**/
|
266
|
+
getTextureHandle: function(context, index) {
|
267
|
+
return this.getTexture(context, index).getHandle(context);
|
268
|
+
},
|
269
|
+
|
270
|
+
/** deprecated
|
271
|
+
* Jax.Framebuffer#getTextureBuffer(context, index) -> Jax.Texture
|
272
|
+
*
|
273
|
+
* This method is deprecated. See Jax.Framebuffer#getTexture instead.
|
274
|
+
**/
|
275
|
+
getTextureBuffer: function(context, index) {
|
276
|
+
alert("Jax.Framebuffer#getTextureBuffer(context, index) is deprecated.\n"+
|
277
|
+
"Please use Jax.Framebuffer#getTexture(context, index) instead.\n\n"+
|
278
|
+
"Stack trace:\n\n"+
|
279
|
+
(new Error().stack || "(unavailable)"));
|
280
|
+
return this.getTexture(context, index);
|
281
|
+
},
|
282
|
+
|
283
|
+
/** deprecated
|
284
|
+
* Jax.Framebuffer#getTextureBufferHandle(context, index) -> WebGLTexture
|
285
|
+
*
|
286
|
+
* This method is deprecated. See Jax.Framebuffer#getTextureHandle instead.
|
287
|
+
**/
|
288
|
+
getTextureBufferHandle: function(context, index) {
|
289
|
+
alert("Jax.Framebuffer#getTextureBufferHandle(context, index) is deprecated.\n"+
|
290
|
+
"Please use Jax.Framebuffer#getTextureHandle(context, index) instead.\n\n"+
|
291
|
+
"Stack trace:\n\n"+
|
292
|
+
(new Error().stack || "(unavailable)"));
|
293
|
+
return this.getTextureHandle(context, index);
|
294
|
+
},
|
295
|
+
|
296
|
+
/**
|
297
|
+
* Jax.Framebuffer#getHandle(context) -> WebGLFramebuffer | undefined
|
298
|
+
* - context (Jax.Context): the context the requested framebuffer handle is associated with
|
299
|
+
*
|
300
|
+
* Returns the WebGLFramebuffer handle associated with the specified context.
|
301
|
+
**/
|
302
|
+
getHandle: function(context) { return this.handles[context.id]; },
|
303
|
+
|
304
|
+
/**
|
305
|
+
* Jax.Framebuffer#getHandle(context, handle) -> Jax.Framebuffer
|
306
|
+
* - context (Jax.Context): the context the requested framebuffer handle is associated with
|
307
|
+
* - handle (WebGLFramebuffer): the WebGL framebuffer handle to use for the specified context
|
308
|
+
*
|
309
|
+
* Assigns the specified handle to be used for the given context. This is a permanent
|
310
|
+
* assignment unless this method is called again.
|
311
|
+
*
|
312
|
+
* Returns this instance of Jax.Framebuffer.
|
313
|
+
**/
|
314
|
+
setHandle: function(context, handle) { this.handles[context.id] = handle; return this; }
|
315
|
+
});
|
316
|
+
})();
|