Skip to content

Instantly share code, notes, and snippets.

@nat-n
Created February 12, 2012 21:26
Show Gist options
  • Save nat-n/1810908 to your computer and use it in GitHub Desktop.
Save nat-n/1810908 to your computer and use it in GitHub Desktop.
Jax controller trying to use the coldet plugin
Jax.Controller.create "Mybsp", ApplicationController,
index: ->
sphere = new Jax.Mesh.Sphere
this.ball1 = new Jax.Model({ mesh:sphere })
this.ball2 = new Jax.Model({ mesh:sphere, position:[0,5,0] })
this.ball1.bsp = new BSP
this.ball2.bsp = new BSP
this.ball1.bsp.addMesh(sphere)
this.ball2.bsp.addMesh(sphere)
this.ball1.bsp.finalize()
this.ball2.bsp.finalize()
this.world.addObject(this.ball1)
this.world.addObject(this.ball2)
# matrix used to transform from ball2's object space into ball1's object space
mat = mat4.inverse(this.ball1.camera.getTransformationMatrix(), mat4.create())
mat4.multiply(mat, this.ball2.camera.getTransformationMatrix(), mat)
if (this.ball1.bsp.collide(this.ball2.bsp, mat))
# collision! turn both balls red
this.ball1.mesh.setColor(1,0,0,1)
this.ball2.mesh.setColor(1,0,0,1)
else
# no collision, turn them white
this.ball1.mesh.setColor(1,1,1,1)
this.ball2.mesh.setColor(1,1,1,1)
@nat-n
Copy link
Author

nat-n commented Feb 12, 2012

produces the following error:
ReferenceError: BSP is not defined
at klass.index (http://127.0.0.1:3000/assets/controllers/mybsp_controller.js?body=1:14:28)
at klass.fireAction (http://127.0.0.1:3000/assets/jax/mvc/controller.js?body=1:89:29)
at Function.invoke (http://127.0.0.1:3000/assets/jax/mvc/controller.js?body=1:131:16)
at klass.dispatch (http://127.0.0.1:3000/assets/jax/mvc/route_set.js?body=1:146:31)
at klass.redirectTo (http://127.0.0.1:3000/assets/jax/context.js?body=1:455:48)
at HTMLAnchorElement. (http://127.0.0.1:3000/assets/jax/controller-list.js?body=1:12:15)
at HTMLAnchorElement. (http://127.0.0.1:3000/assets/jquery.js?body=1:3257:9)
at HTMLAnchorElement. (http://127.0.0.1:3000/assets/jquery.js?body=1:2876:28)
Jax.Class.create.handleErrorcontext.js:708
Jax.Class.create.redirectTocontext.js:484
controllercontroller-list.js:12
jQuery.event.dispatchjquery.js:3257
jQuery.event.add.elemData.handle.eventHandlejquery.js:2876
context.js:712
Uncaught ReferenceError: BSP is not defined
Jax.Class.create.handleErrorcontext.js:712
Jax.Class.create.redirectTocontext.js:484
controllercontroller-list.js:12
jQuery.event.dispatchjquery.js:3257
jQuery.event.add.elemData.handle.eventHandlejquery.js:2876

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment