Sha256: 8e07e6a4f79bcf0c27868654d888c7e8aa4363b56aad63179d76b584b6410d79

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

//= require "application_controller"

var PickingController = (function() {
  return Jax.Controller.create("picking", ApplicationController, {
    index: function() {
      function mesh() { return new Jax.Mesh.Sphere({size: 1.0}); };

      ofront       = this.world.addObject(new Jax.Model({position:[ 0.0, 0.0,-5],mesh:mesh()}));
      otopleft     = this.world.addObject(new Jax.Model({position:[-2.5, 2.5,-5],mesh:mesh()}));
      otopright    = this.world.addObject(new Jax.Model({position:[ 2.5, 2.5,-5],mesh:mesh()}));
      obottomleft  = this.world.addObject(new Jax.Model({position:[-2.5,-2.5,-5],mesh:mesh()}));
      obottomright = this.world.addObject(new Jax.Model({position:[ 2.5,-2.5,-5],mesh:mesh()}));
    },
    
    mouse_pressed: function(e) { alert(e.x+" "+e.y); },

    mouse_moved: function(evt) {
      var obj = this.world.pick(evt.x, evt.y);
      if (obj) {
        if (this.current_obj && obj != this.current_obj) {
          this.current_obj.mesh.setColor(1,1,1,1);
        }
        obj.mesh.setColor(1,0,0,1);
      } else {
        if (this.current_obj) {
          this.current_obj.mesh.setColor(1,1,1,1);
        }
      }
      this.current_obj = obj;
    }
  });
})();

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jax-0.0.0.9 spec/example_app/app/controllers/picking_controller.js
jax-0.0.0.8 spec/example_app/app/controllers/picking_controller.js
jax-0.0.0.7 spec/example_app/app/controllers/picking_controller.js
jax-0.0.0.6 spec/example_app/app/controllers/picking_controller.js