From ac05c6d4c322a64d229a0d0c4290f035873311d0 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 7 Feb 2014 15:21:16 -0800 Subject: [PATCH] add example code --- examples/rayPickExample.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/rayPickExample.js diff --git a/examples/rayPickExample.js b/examples/rayPickExample.js new file mode 100644 index 0000000000..1c79d7cd6a --- /dev/null +++ b/examples/rayPickExample.js @@ -0,0 +1,31 @@ +// +// rayPickExample.js +// hifi +// +// Created by Brad Hefta-Gaub on 2/6/14. +// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// +// This is an example script that demonstrates use of the Camera class +// +// + +function mouseMoveEvent(event) { + print("mouseMoveEvent event.x,y=" + event.x + ", " + event.y); + var pickRay = Camera.computePickRay(event.x, event.y); + print("called Camera.computePickRay()"); + print("computePickRay origin=" + pickRay.origin.x + ", " + pickRay.origin.y + ", " + pickRay.origin.z); + print("computePickRay direction=" + pickRay.direction.x + ", " + pickRay.direction.y + ", " + pickRay.direction.z); + var pickRay = Camera.computePickRay(event.x, event.y); + var intersection = Voxels.findRayIntersection(pickRay); + if (intersection.intersects) { + print("intersection voxel.red/green/blue=" + intersection.voxel.red + ", " + + intersection.voxel.green + ", " + intersection.voxel.blue); + } +} + +Controller.mouseMoveEvent.connect(mouseMoveEvent); + +function scriptEnding() { +} +Script.scriptEnding.connect(scriptEnding); +