Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function Raycast(origin, direction , radius, callback):Dynamic{
- // cube containing origin point
- var x = Math.floor(origin[0]);
- var y = Math.floor(origin[1]);
- var z = Math.floor(origin[2]);
- // break out direction vector
- var dx = direction[0];
- var dy = direction[1];
- var dz = direction[2];
- //direction to increment x,y,z when stepping
- var stepx = sign(dx);
- var stepy = sign(dy);
- var stepz = sign(dz);
- //The initial values depend on the fractional
- // part of the origin.
- var tMaxX = intbound(origin[0],dx);
- var tMaxy = intbound(origin[1],dy);
- var tMaxz = intbound(origin[2],dz);
- // the change in t when taking a step(always positive)
- var tDeltaX = stepx/dx;
- var tDeltaY = stepy/dy;
- var tDeltaz = stepz/dz;
- //buffer for face callback
- var face = new Vec3();
- //avoid infinite loop
- if (dx == 0 && dy == 0 && dz == 0){
- return ("test");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement