Example #1
0
exports.raycast = function(test){
    var ray = new Ray({
        mode: Ray.CLOSEST,
        from: [0,0],
        to: [10,0]
    });

    var capsule = new Capsule({ length: 1, radius: 0.5 });
    var result = new RaycastResult();
    capsule.raycast(result, ray, [1,0], Math.PI / 2);

    test.done();
};
Example #2
0
exports.raycast = function(test){
    var ray = new Ray({
        mode: Ray.CLOSEST,
        from: [0,0],
        to: [10,0]
    });

    var shape = new Plane();
    var result = new RaycastResult();
    shape.raycast(result, ray, [1,0], Math.PI / 2);

    test.done();
};
Example #3
0
exports.raycast = function(test){
    var ray = new Ray({
		mode: Ray.CLOSEST,
        from: [-10,0],
        to: [10,0]
    });

    var shape = new Circle({ radius: 0.5 });
    var result = new RaycastResult();
    shape.raycast(result, ray, [0,0], 0);
    test.equal(result.normal[0], -1);
    test.equal(result.normal[1], 0);

    test.done();
};
exports.raycast = function(test){
    var ray = new Ray({
        mode: Ray.CLOSEST,
        from: [0,0],
        to: [10,0]
    });

    var w = 1,
        h = 1;
    var shape = new Convex({ vertices: [
        [-w/2,-h/2],
        [ w/2,-h/2],
        [ w/2, h/2],
        [-w/2, h/2],
    ]});
    var result = new RaycastResult();
    shape.raycast(result, ray, [1,0], Math.PI / 2);

    test.done();
};