mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 03:53:52 +02:00
adding ray filters example/test
This commit is contained in:
parent
a023a7eebd
commit
e8a6fd1f05
2 changed files with 52 additions and 2 deletions
|
@ -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);
|
||||
|
|
50
examples/rayPickingFilterExample.js
Normal file
50
examples/rayPickingFilterExample.js
Normal 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);
|
Loading…
Reference in a new issue