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,279 @@
|
|
1
|
+
//= require "jax/webgl/scene"
|
2
|
+
|
3
|
+
/**
|
4
|
+
* class Jax.World
|
5
|
+
*
|
6
|
+
* A +Jax.World+ represents a scene in the graphics engine. All objects to be rendered (or at least,
|
7
|
+
* all objects that you do not want to manually control!) should be added to the world. Each instance
|
8
|
+
* of +Jax.Context+ has its own +Jax.World+, and the currently-active +Jax.World+ is delegated into
|
9
|
+
* controllers and views as the +this.world+ property.
|
10
|
+
*
|
11
|
+
**/
|
12
|
+
Jax.World = (function() {
|
13
|
+
function getPickBuffer(self) {
|
14
|
+
if (self.pickBuffer) return self.pickBuffer;
|
15
|
+
return self.pickBuffer = new Jax.Framebuffer({
|
16
|
+
width:self.context.canvas.width,
|
17
|
+
height:self.context.canvas.height
|
18
|
+
});
|
19
|
+
}
|
20
|
+
|
21
|
+
return Jax.Class.create({
|
22
|
+
initialize: function(context) {
|
23
|
+
this.context = context;
|
24
|
+
this.lighting = new Jax.Scene.LightManager(context);
|
25
|
+
this.objects = [];
|
26
|
+
},
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Jax.World#addLightSource(light) -> Jax.Scene.LightSource
|
30
|
+
* - light (Jax.Scene.LightSource): the instance of Jax.Scene.LightSource to add to this world.
|
31
|
+
*
|
32
|
+
* Adds the light to the world and then returns the light itself unchanged.
|
33
|
+
**/
|
34
|
+
addLightSource: function(light) { this.lighting.add(light); },
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Jax.World#addObject(object) -> Jax.Model
|
38
|
+
* - object (Jax.Model): the instance of Jax.Model to add to this world.
|
39
|
+
*
|
40
|
+
* Adds the model to the world and then returns the model itself unchanged.
|
41
|
+
*
|
42
|
+
**/
|
43
|
+
addObject: function(object) {
|
44
|
+
this.objects.push(object);
|
45
|
+
if (object.isLit() || object.isShadowCaster())
|
46
|
+
this.lighting.addObject(object);
|
47
|
+
return object;
|
48
|
+
},
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Jax.World#getObject(index) -> Jax.Model
|
52
|
+
* - index (Number): the world index of this object
|
53
|
+
*
|
54
|
+
* Returns the object with the specified world index, or undefined.
|
55
|
+
**/
|
56
|
+
getObject: function(index) { return this.objects[index]; },
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Jax.World#removeObject(object_or_index) -> Jax.Model
|
60
|
+
* - object_or_index (Number|Jax.Model): the model instance to remove, or its world index
|
61
|
+
*
|
62
|
+
* If the model or its index cannot be found, nothing happens and the return value is undefined.
|
63
|
+
* Otherwise, the object is removed from this World and then returned.
|
64
|
+
**/
|
65
|
+
removeObject: function(object_or_index) {
|
66
|
+
if (this.objects[object_or_index]) {
|
67
|
+
var obj = this.objects[object_or_index];
|
68
|
+
this.objects.splice(object_or_index, 1);
|
69
|
+
this.lighting.removeObject(obj);
|
70
|
+
return obj;
|
71
|
+
}
|
72
|
+
else
|
73
|
+
for (var i = 0; i < this.objects.length; i++)
|
74
|
+
if (this.objects[i] == object_or_index)
|
75
|
+
{
|
76
|
+
this.objects.splice(i, 1);
|
77
|
+
this.lighting.removeObject(this.objects[i]);
|
78
|
+
return this.objects[i];
|
79
|
+
}
|
80
|
+
},
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Jax.World#pickRegionalIndices(x1, y1, x2, y2[, ary]) -> Array
|
84
|
+
* - x1 (Number): the screen X coordinate of the first corner of the 2D rectangle within which to pick
|
85
|
+
* - y1 (Number): the screen Y coordinate of the first corner of the 2D rectangle within which to pick
|
86
|
+
* - x2 (Number): the screen X coordinate of the second corner of the 2D rectangle within which to pick
|
87
|
+
* - y2 (Number): the screen Y coordinate of the second corner of the 2D rectangle within which to pick
|
88
|
+
* - ary (Array): an optional array to populate. A new one will be created if this is not specified.
|
89
|
+
* (Note: the array's contents will be cleared.)
|
90
|
+
*
|
91
|
+
* Picks all visible object indices within the specified rectangular regions and returns them as elements in
|
92
|
+
* an array.
|
93
|
+
*
|
94
|
+
* An object's index matches its position in the world's object list. That is, the following code is
|
95
|
+
* valid:
|
96
|
+
*
|
97
|
+
* this.world.getObjects(this.world.pickRegionalIDs(0,0, 100,100));
|
98
|
+
*
|
99
|
+
**/
|
100
|
+
pickRegionalIndices: function(x1, y1, x2, y2, ary) {
|
101
|
+
var w = Math.abs(x2 - x1), h = Math.abs(y2 - y1);
|
102
|
+
if (ary) ary.clear();
|
103
|
+
else ary = new Array();
|
104
|
+
var world = this, pickBuffer = getPickBuffer(this), context = this.context;
|
105
|
+
console.log(w*h*4);
|
106
|
+
var data = new Uint8Array(w*h*4);
|
107
|
+
|
108
|
+
pickBuffer.bind(context, function() {
|
109
|
+
pickBuffer.viewport(context);
|
110
|
+
context.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
111
|
+
context.glDisable(GL_BLEND);
|
112
|
+
world.render({material:"picking"});
|
113
|
+
// read it back in
|
114
|
+
context.glReadPixels(x1, y1, w, h, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
115
|
+
if (data.data) data = data.data;
|
116
|
+
});
|
117
|
+
|
118
|
+
// restore the visible viewport and blending
|
119
|
+
context.glViewport(0, 0, context.canvas.width, context.canvas.height);
|
120
|
+
context.glEnable(GL_BLEND);
|
121
|
+
|
122
|
+
var index;
|
123
|
+
for (var i = 2; i < data.length; i += 4) {
|
124
|
+
if (data[i] > 0) { // blue key exists, we've found an object
|
125
|
+
index = Jax.Util.decodePickingColor(data[i-2], data[i-1], data[i], data[i+1]);
|
126
|
+
if (index != undefined) {
|
127
|
+
ary.push(index);
|
128
|
+
}
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
return ary;
|
133
|
+
},
|
134
|
+
|
135
|
+
/**
|
136
|
+
* Jax.World#pickRegion(x1, y1, x2, y2) -> Array
|
137
|
+
* - x1 (Number): the screen X coordinate of the first corner of the 2D rectangle within which to pick
|
138
|
+
* - y1 (Number): the screen Y coordinate of the first corner of the 2D rectangle within which to pick
|
139
|
+
* - x2 (Number): the screen X coordinate of the second corner of the 2D rectangle within which to pick
|
140
|
+
* - y2 (Number): the screen Y coordinate of the second corner of the 2D rectangle within which to pick
|
141
|
+
* - ary (Array): an optional array to populate. A new one will be created if this is not specified.
|
142
|
+
* (Note: the array's contents will be cleared.)
|
143
|
+
*
|
144
|
+
* Picks all visible objects within the specified rectangular regions and returns them as elements in
|
145
|
+
* an array.
|
146
|
+
**/
|
147
|
+
pickRegion: function(x1, y1, x2, y2, ary) {
|
148
|
+
var result = this.pickRegionalIndices(x1, y1, x2, y2);
|
149
|
+
for (var i = 0; i < result.length; i++)
|
150
|
+
result[i] = this.getObject(i);
|
151
|
+
return result;
|
152
|
+
},
|
153
|
+
|
154
|
+
/**
|
155
|
+
* Jax.World#pickIndex(x, y) -> Number | undefined
|
156
|
+
* - x (Number): the screen X coordinate to pick at
|
157
|
+
* - y (Number): the screen Y coordinate to pick at
|
158
|
+
*
|
159
|
+
* Picks the visible object at the specified position and returns its index as used by
|
160
|
+
* +Jax.World#getObject+. If no object is visible at the given position, the special value
|
161
|
+
* +undefined+ is returned.
|
162
|
+
**/
|
163
|
+
pickIndex: function(x, y) {
|
164
|
+
this._pick_ary = this._pick_ary || new Array();
|
165
|
+
var result = this.pickRegionalIndices(x, y, x+1, y+1, this._pick_ary)[0];
|
166
|
+
return result;
|
167
|
+
},
|
168
|
+
|
169
|
+
/**
|
170
|
+
* Jax.World#pick(x, y) -> Jax.Model | undefined
|
171
|
+
* - x (Number): the screen X coordinate to pick at
|
172
|
+
* - y (Number): the screen Y coordinate to pick at
|
173
|
+
*
|
174
|
+
* Picks the visible object at the specified position and returns it. If no object is visible
|
175
|
+
* at the given position, the special value +undefined+ is returned.
|
176
|
+
**/
|
177
|
+
pick: function(x, y) {
|
178
|
+
var index = this.pickIndex(x, y);
|
179
|
+
if (index != undefined) {
|
180
|
+
return this.getObject(index);
|
181
|
+
}
|
182
|
+
return index;
|
183
|
+
},
|
184
|
+
|
185
|
+
/**
|
186
|
+
* Jax.World#countObjects() -> Number
|
187
|
+
* Returns the number of objects currently registered with this World.
|
188
|
+
**/
|
189
|
+
countObjects: function() {
|
190
|
+
return this.objects.length;
|
191
|
+
},
|
192
|
+
|
193
|
+
/**
|
194
|
+
* Jax.World#getShadowCasters() -> Array
|
195
|
+
*
|
196
|
+
* Returns an array of all known shadow-casters in this World.
|
197
|
+
**/
|
198
|
+
getShadowCasters: function() { return this.lighting.getShadowCasters(); },
|
199
|
+
|
200
|
+
/**
|
201
|
+
* Jax.World#render([options]) -> Jax.World
|
202
|
+
*
|
203
|
+
* Renders this World to its Jax context. Options, if specified, are delegated
|
204
|
+
* to the individual models to be rendered.
|
205
|
+
*
|
206
|
+
* Prior to rendering, this function assigns the blend function to
|
207
|
+
* (+GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA+).
|
208
|
+
*
|
209
|
+
* This function determines whether light sources are to have an effect on the
|
210
|
+
* render pass. If so, the world's +Jax.LightManager+ instance is invoked to
|
211
|
+
* render the objects; otherwise, the objects are rendered directly with the
|
212
|
+
* +unlit+ option set to +true+.
|
213
|
+
**/
|
214
|
+
render: function(options) {
|
215
|
+
var i;
|
216
|
+
|
217
|
+
/* this.current_pass is used by the material */
|
218
|
+
|
219
|
+
this.context.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
220
|
+
var unlit = Jax.Util.normalizeOptions(options, {unlit:true});
|
221
|
+
|
222
|
+
if (this.lighting.isEnabled() && (!unlit.material || (unlit.material.supportsLighting && unlit.material.supportsLighting()))) {
|
223
|
+
/* illumination pass */
|
224
|
+
this.context.current_pass = Jax.Scene.ILLUMINATION_PASS;
|
225
|
+
this.lighting.illuminate(this.context, options);
|
226
|
+
|
227
|
+
/* ambient pass - unlit objects only because lit objects get ambient+diffuse+specular in one pass */
|
228
|
+
this.context.current_pass = Jax.Scene.AMBIENT_PASS;
|
229
|
+
for (i = 0; i < this.objects.length; i++)
|
230
|
+
if (!this.objects[i].isLit()) {
|
231
|
+
unlit.model_index = i;
|
232
|
+
this.objects[i].render(this.context, unlit);
|
233
|
+
}
|
234
|
+
} else {
|
235
|
+
this.context.current_pass = Jax.Scene.AMBIENT_PASS;
|
236
|
+
for (i = 0; i < this.objects.length; i++) {
|
237
|
+
unlit.model_index = i;
|
238
|
+
this.objects[i].render(this.context, unlit);
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
return this;
|
243
|
+
},
|
244
|
+
|
245
|
+
/**
|
246
|
+
* Jax.World#update(timechange) -> Jax.World
|
247
|
+
* - timechange (Number): the number of seconds to have passed since the last
|
248
|
+
* call to +Jax.World#update+.
|
249
|
+
*
|
250
|
+
* Updates each object in the world, passing the +timechange+ argument into
|
251
|
+
* the objects' respective +update+ functions (if they have one).
|
252
|
+
**/
|
253
|
+
update: function(timechange) {
|
254
|
+
for (var i = this.objects.length-1; i >= 0; i--)
|
255
|
+
if (this.objects[i].update)
|
256
|
+
this.objects[i].update(timechange);
|
257
|
+
return this;
|
258
|
+
},
|
259
|
+
|
260
|
+
/**
|
261
|
+
* Jax.World#dispose() -> Jax.World
|
262
|
+
*
|
263
|
+
* Disposes of this world by removing all references to its objects and
|
264
|
+
* reinitializing its +Jax.Scene.LightManager+ instance. Note that the
|
265
|
+
* individual objects are not disposed; this is left as a task for either
|
266
|
+
* the developer or the JavaScript garbage collector. The reason for this
|
267
|
+
* is because it is impossible for Jax.World to know whether the objects
|
268
|
+
* in question are in use by other Worlds.
|
269
|
+
**/
|
270
|
+
dispose: function() {
|
271
|
+
var i, o;
|
272
|
+
|
273
|
+
for (i = this.objects.length-1; i >= 0; i--)
|
274
|
+
(o = this.objects.pop());// && o.dispose();
|
275
|
+
|
276
|
+
this.lighting = new Jax.Scene.LightManager(this.context);
|
277
|
+
}
|
278
|
+
});
|
279
|
+
})();
|
@@ -0,0 +1,109 @@
|
|
1
|
+
/*
|
2
|
+
This file will set up WebGL constants as globals prefixed with GL_, and will add
|
3
|
+
a new global called GL_METHODS. This will later be used for method delegation
|
4
|
+
within Jax.Context.
|
5
|
+
*/
|
6
|
+
|
7
|
+
//= require "jax/vendor/glMatrix"
|
8
|
+
//= require_self
|
9
|
+
/*
|
10
|
+
all files in the webgl/ subdirectory will have access to a temporary GL context,
|
11
|
+
via `Jax.getGlobal()['GL']`, which will be unloaded after they have been loaded into memory.
|
12
|
+
*/
|
13
|
+
//= require "jax/webgl/shader_chain"
|
14
|
+
//= require "jax/webgl/material"
|
15
|
+
//= require "jax/webgl/mesh"
|
16
|
+
//= require "jax/webgl/camera"
|
17
|
+
//= require "jax/webgl/world"
|
18
|
+
//= require "jax/webgl/texture"
|
19
|
+
//= require "jax/webgl/cleanup"
|
20
|
+
|
21
|
+
Jax.getGlobal()['WEBGL_CONTEXT_NAME'] = "experimental-webgl";
|
22
|
+
Jax.getGlobal()['WEBGL_CONTEXT_OPTIONS'] = {stencil:true};
|
23
|
+
Jax.getGlobal()['GL_METHODS'] = {};
|
24
|
+
|
25
|
+
(function() {
|
26
|
+
var canvas = document.createElement("canvas");
|
27
|
+
canvas.setAttribute("id", "temporary-internal-use");
|
28
|
+
// canvas.style.display = "block";
|
29
|
+
|
30
|
+
// var body = document.getElementsByTagName("body")[0], temporaryBody = false;
|
31
|
+
// if (!body)
|
32
|
+
// {
|
33
|
+
// temporaryBody = true;
|
34
|
+
// body = document.createElement("body");
|
35
|
+
// document.getElementsByTagName("html")[0].appendChild(body);
|
36
|
+
// }
|
37
|
+
// body.appendChild(canvas);
|
38
|
+
|
39
|
+
try {
|
40
|
+
var gl = canvas.getContext(WEBGL_CONTEXT_NAME);
|
41
|
+
} catch(e) {
|
42
|
+
// these are now handled by the Context upon initialization.
|
43
|
+
// document.location.pathname = "/webgl_not_supported.html";
|
44
|
+
// throw new Error("WebGL is disabled or is not supported by this browser!");
|
45
|
+
gl = null;
|
46
|
+
}
|
47
|
+
|
48
|
+
if (gl) {
|
49
|
+
for (var method_name in gl)
|
50
|
+
{
|
51
|
+
if (typeof(gl[method_name]) == "function")
|
52
|
+
{
|
53
|
+
var camelized_method_name = method_name.substring(1, method_name.length);
|
54
|
+
camelized_method_name = "gl" + method_name.substring(0, 1).toUpperCase() + camelized_method_name;
|
55
|
+
|
56
|
+
/* we'll add a layer here to check for render errors, only in development mode */
|
57
|
+
/* FIXME Chrome has serious performance issues related to gl.getError(). Disabling under Chrome for now. */
|
58
|
+
var func = "(function "+camelized_method_name+"() {"
|
59
|
+
+ " var result;"
|
60
|
+
+ " if ("+(method_name == 'getError')+" || Jax.environment == Jax.PRODUCTION)"
|
61
|
+
+ " result = this.gl."+method_name+".apply(this.gl, arguments);"
|
62
|
+
+ " else {"
|
63
|
+
+ " try { "
|
64
|
+
+ " result = this.gl."+method_name+".apply(this.gl, arguments);"
|
65
|
+
+ " if ("+(navigator.userAgent.toLowerCase().indexOf('chrome') == -1)+")"
|
66
|
+
+ " this.checkForRenderErrors();"
|
67
|
+
+ " } catch(e) { "
|
68
|
+
+ " var args = [], i;"
|
69
|
+
+ " for (i = 0; i < arguments.length; i++) args.push(arguments[i]);"
|
70
|
+
+ " try { args = JSON.stringify(args); } catch(jsonErr) { args = args.toString(); }"
|
71
|
+
+ " if (!e.stack) e = new Error(e.toString());"
|
72
|
+
+ " this.handleRenderError('"+method_name+"', args, e);"
|
73
|
+
+ " }"
|
74
|
+
+ " }"
|
75
|
+
+ " return result;"
|
76
|
+
+ "})";
|
77
|
+
|
78
|
+
GL_METHODS[camelized_method_name] = eval("("+func+")");
|
79
|
+
}
|
80
|
+
else
|
81
|
+
{
|
82
|
+
/* define the GL enums Jax.getGlobal()ly so we don't need a context to reference them */
|
83
|
+
if (!/[a-z]/.test(method_name)) // no lowercase letters
|
84
|
+
Jax.getGlobal()[('GL_'+method_name)] = gl[method_name];
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
/* define some extra Jax.getGlobal()s that the above didn't generate */
|
89
|
+
// Jax.getGlobal()['GL_MAX_VERTEX_ATTRIBS'] = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
|
90
|
+
Jax.getGlobal()['GL_DEPTH_COMPONENT'] = gl.DEPTH_COMPONENT || gl.DEPTH_COMPONENT16;
|
91
|
+
Jax.getGlobal()['GL_TEXTURES'] = [];
|
92
|
+
for (i = 0; i < 32; i++) Jax.getGlobal()['GL_TEXTURES'][i] = gl["TEXTURE"+i];
|
93
|
+
Jax.getGlobal()['GL_MAX_ACTIVE_TEXTURES'] = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
|
94
|
+
}
|
95
|
+
|
96
|
+
Jax.getGlobal()['GL'] = gl;
|
97
|
+
|
98
|
+
Jax.getGlobal()['WEBGL_CLEANUP'] = function() {
|
99
|
+
/* clean up after ourselves */
|
100
|
+
// if (temporaryBody)
|
101
|
+
// body.parentNode.removeChild(body);
|
102
|
+
// else
|
103
|
+
// body.removeChild(canvas);
|
104
|
+
|
105
|
+
// remove the temporary GL context that will no longer be used
|
106
|
+
delete Jax.getGlobal()['GL'];
|
107
|
+
delete Jax.getGlobal()['WEBGL_CLEANUP'];
|
108
|
+
};
|
109
|
+
})();
|
@@ -0,0 +1,136 @@
|
|
1
|
+
//= require "jax/core/base"
|
2
|
+
//= require "jax/compatibility"
|
3
|
+
//= require "jax/core"
|
4
|
+
//= require "jax/anim_frame"
|
5
|
+
//= require "jax/prototype/extensions"
|
6
|
+
//= require "jax/mvc/model"
|
7
|
+
//= require "jax/mvc/controller"
|
8
|
+
//= require "jax/mvc/view_manager"
|
9
|
+
//= require "jax/mvc/route_set"
|
10
|
+
//= require "jax/mvc/view"
|
11
|
+
//= require "jax/context"
|
12
|
+
//= require "jax/noise"
|
13
|
+
//= require "jax/builtin/all.js"
|
14
|
+
|
15
|
+
Jax.shaders = {};
|
16
|
+
Jax._shader_data = {};
|
17
|
+
|
18
|
+
Jax.import_shader_code = function(shader_name, shader_type) {
|
19
|
+
var constant_name = "__import_"+shader_name+"_"+shader_type+"__";
|
20
|
+
return "#ifndef "+constant_name+"\n" +
|
21
|
+
"#define "+constant_name+" 1\n" +
|
22
|
+
Jax.shader_data(shader_name)[shader_type] +
|
23
|
+
"#endif\n"
|
24
|
+
};
|
25
|
+
|
26
|
+
// Finds or creates the named shader descriptor in +Jax.shaders+. This is used by
|
27
|
+
// `Jax::Shader` in Ruby.
|
28
|
+
Jax.shader_data = function(name) {
|
29
|
+
Jax._shader_data[name] = Jax._shader_data[name] || {"name":name};
|
30
|
+
return Jax._shader_data[name];
|
31
|
+
};
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Jax.views -> Jax.ViewManager
|
35
|
+
**/
|
36
|
+
Jax.views = new Jax.ViewManager();
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Jax.routes -> Jax.RouteSet
|
40
|
+
**/
|
41
|
+
Jax.routes = new Jax.RouteSet();
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Jax.loaded -> Boolean
|
45
|
+
* True after Jax has been loaded.
|
46
|
+
**/
|
47
|
+
Jax.loaded = true;
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Jax.render_speed -> Number
|
51
|
+
* Target number of milliseconds to wait between frames.
|
52
|
+
* This is not a guaranteed number in JavaScript, just a target. Most notably,
|
53
|
+
* system performance issues can drive the framerate down regardless of the
|
54
|
+
* target refresh rate.
|
55
|
+
*
|
56
|
+
* Defaults to 16, for a target rate of 60 frames per second.
|
57
|
+
**/
|
58
|
+
Jax.render_speed = 16;
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Jax.update_speed -> Number
|
62
|
+
* Target number of milliseconds to wait between updates.
|
63
|
+
* This is not a guaranteed number in JavaScript, just a target. Most notably,
|
64
|
+
* system performance issues can drive the framerate down regardless of the
|
65
|
+
* target refresh rate.
|
66
|
+
*
|
67
|
+
* Defaults to 33, for a target rate of 30 updates per second.
|
68
|
+
**/
|
69
|
+
Jax.update_speed = 33;
|
70
|
+
|
71
|
+
|
72
|
+
/**
|
73
|
+
* Jax.max_lights -> Number
|
74
|
+
*
|
75
|
+
* If set, Jax will raise an error whenever more than this number of light sources
|
76
|
+
* are activated at one time.
|
77
|
+
*
|
78
|
+
* By default, there is no limit to the number of lights Jax can support. (This
|
79
|
+
* property is undefined by default.)
|
80
|
+
**/
|
81
|
+
Jax.max_lights = undefined;
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Jax.uptime -> Number
|
85
|
+
*
|
86
|
+
* The amount of time the Jax subsystem has been running, in seconds. This is updated
|
87
|
+
* whether any contexts are active or not. It is used for tracking update intervals
|
88
|
+
* and framerates, so that individual Jax contexts are not constantly spawning new
|
89
|
+
* Date() instances (which then have to be garbage collected).
|
90
|
+
**/
|
91
|
+
Jax.uptime = 0.0;
|
92
|
+
Jax.uptime_tracker = new Date();
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Jax.shutdown() -> undefined
|
96
|
+
*
|
97
|
+
* Causes all Jax contexts to be disposed.
|
98
|
+
**/
|
99
|
+
Jax.shutdown = function() {
|
100
|
+
if (Jax.uptime_interval) clearInterval(Jax.uptime_interval);
|
101
|
+
Jax.uptime_interval = null;
|
102
|
+
Jax.SHUTDOWN_IN_PROGRESS = true;
|
103
|
+
};
|
104
|
+
|
105
|
+
/**
|
106
|
+
* Jax.restart() -> undefined
|
107
|
+
*
|
108
|
+
* Restarts the Jax subsystem after a prior call to Jax.shutdown().
|
109
|
+
**/
|
110
|
+
Jax.restart = function() {
|
111
|
+
Jax.SHUTDOWN_IN_PROGRESS = false;
|
112
|
+
/* TODO: verify : is setInterval better for updates, or should be we using requestAnimFrame? */
|
113
|
+
if (!Jax.uptime_interval)
|
114
|
+
Jax.uptime_interval = setInterval(function() { Jax.uptime = (new Date() - Jax.uptime_tracker) / 1000; }, 33);
|
115
|
+
};
|
116
|
+
|
117
|
+
// start 'er up!
|
118
|
+
Jax.restart();
|
119
|
+
|
120
|
+
/*
|
121
|
+
FIXME Resource manager looks for an object in the global namespace, so using Jax.Scene.LightSource
|
122
|
+
instead of just LightSource results in a broken resource load.
|
123
|
+
*/
|
124
|
+
var LightSource = Jax.Scene.LightSource;
|
125
|
+
var Material = Jax.Material;
|
126
|
+
|
127
|
+
|
128
|
+
/* Export globals into 'exports' for CommonJS */
|
129
|
+
if (typeof(exports) != "undefined") {
|
130
|
+
exports.Jax = Jax;
|
131
|
+
exports.mat4 = mat4;
|
132
|
+
exports.mat3 = mat3;
|
133
|
+
exports.vec3 = vec3;
|
134
|
+
exports.glMatrixArrayType = glMatrixArrayType;
|
135
|
+
exports.quat4 = quat4;
|
136
|
+
}
|
data/{builtin/app/shaders/basic/common.ejs → lib/assets/javascripts/shaders/basic/common.glsl}
RENAMED
File without changes
|
data/{builtin/app/shaders/basic/fragment.ejs → lib/assets/javascripts/shaders/basic/fragment.glsl}
RENAMED
File without changes
|
data/{builtin/app/shaders/depthmap/common.ejs → lib/assets/javascripts/shaders/depthmap/common.glsl}
RENAMED
File without changes
|
File without changes
|
data/{builtin/app/shaders/depthmap/vertex.ejs → lib/assets/javascripts/shaders/depthmap/vertex.glsl}
RENAMED
File without changes
|
File without changes
|
data/{builtin/app/shaders/fog/fragment.ejs → lib/assets/javascripts/shaders/fog/fragment.glsl}
RENAMED
File without changes
|
File without changes
|
@@ -22,13 +22,11 @@ Jax.Material.Fog = Jax.Class.create(Jax.Material, {
|
|
22
22
|
$super(options);
|
23
23
|
},
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
uniforms.set('Density', this.density);
|
32
|
-
uniforms.set('FogColor', this.color);
|
25
|
+
setVariables: function(context, mesh, options, vars) {
|
26
|
+
vars.set('End', this.end);
|
27
|
+
vars.set('Scale', 1.0 / (this.end - this.start));
|
28
|
+
vars.set('Algorithm', this.algorithm);
|
29
|
+
vars.set('Density', this.density);
|
30
|
+
vars.set('FogColor', this.color);
|
33
31
|
}
|
34
32
|
});
|
File without changes
|
File without changes
|
File without changes
|
data/{builtin/app/shaders/functions/noise.ejs → lib/assets/javascripts/shaders/functions/noise.glsl}
RENAMED
File without changes
|
File without changes
|
File without changes
|
@@ -3,11 +3,9 @@ Jax.Material.Lighting = Jax.Class.create(Jax.Material, {
|
|
3
3
|
$super(Jax.Util.normalizeOptions(options, {shader: "lighting"}));
|
4
4
|
},
|
5
5
|
|
6
|
-
|
7
|
-
$super(context, mesh, options, uniforms);
|
8
|
-
|
6
|
+
setVariables: function(context, mesh, options, vars) {
|
9
7
|
var light = context.world.lighting.getLight();
|
10
|
-
|
8
|
+
vars.set({
|
11
9
|
LIGHTING_ENABLED: context.world.lighting.isEnabled() && !(options.unlit),
|
12
10
|
LIGHT_POSITION: light.getPosition(),
|
13
11
|
LIGHT_DIRECTION: light.getDirection(),
|
data/{builtin/app/shaders/lighting/vertex.ejs → lib/assets/javascripts/shaders/lighting/vertex.glsl}
RENAMED
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Jax.Material.NormalMap = Jax.Class.create(Jax.Material, {
|
2
|
+
initialize: function($super, map) {
|
3
|
+
this.map = Jax.Material.Texture.normalizeTexture(map);
|
4
|
+
$super({shader:"normal_map"});
|
5
|
+
},
|
6
|
+
|
7
|
+
setVariables: function(context, mesh, options, vars) {
|
8
|
+
vars.texture('NormalMap', this.map, context);
|
9
|
+
vars.set('VERTEX_TANGENT', mesh.getTangentBuffer());
|
10
|
+
}
|
11
|
+
});
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -3,10 +3,8 @@ Jax.Material.Paraboloid = Jax.Class.create(Jax.Material, {
|
|
3
3
|
$super(Jax.Util.normalizeOptions(options, {shader:"paraboloid"}));
|
4
4
|
},
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
uniforms.set({
|
6
|
+
setVariables: function(context, mesh, options, vars) {
|
7
|
+
vars.set({
|
10
8
|
DP_SHADOW_NEAR: 0.1, //c.world.lighting.getLight().getDPShadowNear() || 0.1;}},
|
11
9
|
DP_SHADOW_FAR: 500,//c.world.lighting.getLight().getDPShadowFar() || 500;}},
|
12
10
|
DP_DIRECTION: options && options.direction || 1
|
File without changes
|