diff --git a/examples/painting/whiteboard/whiteboardSpawner.js b/examples/painting/whiteboard/whiteboardSpawner.js index f3005495ec..1d0f21c026 100644 --- a/examples/painting/whiteboard/whiteboardSpawner.js +++ b/examples/painting/whiteboard/whiteboardSpawner.js @@ -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); diff --git a/examples/rayPickingFilterExample.js b/examples/rayPickingFilterExample.js new file mode 100644 index 0000000000..f434d21ab9 --- /dev/null +++ b/examples/rayPickingFilterExample.js @@ -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); \ No newline at end of file