adding ray filters example/test

This commit is contained in:
ericrius1 2015-12-24 11:00:24 -08:00
parent a023a7eebd
commit e8a6fd1f05
2 changed files with 52 additions and 2 deletions

View file

@ -15,7 +15,7 @@
/*global hexToRgb */
Script.include("../../libraries/utils.js");
var scriptURL = Script.resolvePath("whiteboardEntityScript.js");
var scriptURL = Script.resolvePath("whiteboardEntityScript.js?v1" + Math.random());
var modelURL = "https://s3.amazonaws.com/hifi-public/eric/models/whiteboard.fbx";
var colorIndicatorBorderModelURL = "https://s3.amazonaws.com/hifi-public/eric/models/colorIndicatorBorder.fbx";
@ -247,4 +247,4 @@ function cleanup() {
// Uncomment this line to delete whiteboard and all associated entity on script close
//Script.scriptEnding.connect(cleanup);
Script.scriptEnding.connect(cleanup);

View file

@ -0,0 +1,50 @@
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(Camera.getOrientation())));
var whiteListBox = Entities.addEntity({
type: "Box",
color: {
red: 10,
green: 200,
blue: 10
},
dimensions: {
x: .2,
y: .2,
z: .2
},
position: center
});
var blackListBox = Entities.addEntity({
type: "Box",
color: {
red: 100,
green: 10,
blue: 10
},
dimensions: {
x: .2,
y: .2,
z: .2
},
position: Vec3.sum(center, {x: 0, y: .3, z: 0})
});
function castRay(event) {
var pickRay = Camera.computePickRay(event.x, event.y);
var pickResults = Entities.findRayIntersection(pickRay, true, [whiteListBox]);
if(pickResults.intersects) {
print("INTERSECTION");
}
}
function cleanup() {
Entities.deleteEntity(whiteListBox);
Entities.deleteEntity(blackListBox);
}
Script.scriptEnding.connect(cleanup);
Controller.mousePressEvent.connect(castRay);