From 08b7b86c3ed2efc28a7c792a67e58490ac59d89f Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 26 Feb 2014 13:55:16 -0800 Subject: [PATCH] next pass at seeing voxels --- examples/seeingVoxelsExample.js | 63 +++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 examples/seeingVoxelsExample.js diff --git a/examples/seeingVoxelsExample.js b/examples/seeingVoxelsExample.js new file mode 100644 index 0000000000..46e06d201d --- /dev/null +++ b/examples/seeingVoxelsExample.js @@ -0,0 +1,63 @@ +// +// seeingVoxelsExample.js +// hifi +// +// Created by Brad Hefta-Gaub on 2/26/14 +// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// +// This is an example script +// + +var count = 0; +var yawDirection = -1; +var yaw = 45; +var yawMax = 70; +var yawMin = 20; + +var isLocal = true; + +// set up our VoxelViewer with a position and orientation +var orientation = Quat.fromPitchYawRoll(0, yaw, 0); + +if (isLocal) { + MyAvatar.position = {x: 10, y: 0, z: 10}; + MyAvatar.orientation = orientation; +} else { + VoxelViewer.setPosition({x: 10, y: 0, z: 10}); + VoxelViewer.setOrientation(orientation); + VoxelViewer.queryOctree(); + Agent.isAvatar = true; +} + +function keepLooking() { + //print("count =" + count); + count++; + if (count % 10 == 0) { + yaw += yawDirection; + orientation = Quat.fromPitchYawRoll(0, yaw, 0); + if (yaw > yawMax || yaw < yawMin) { + yawDirection = yawDirection * -1; + } + + print("calling VoxelViewer.queryOctree()... count=" + count + " yaw=" + yaw); + + if (isLocal) { + MyAvatar.orientation = orientation; + } else { + VoxelViewer.setOrientation(orientation); + VoxelViewer.queryOctree(); + } + + } +} + +function scriptEnding() { + print("SCRIPT ENDNG!!!\n"); +} + +// register the call back so it fires before each data send +Script.willSendVisualDataCallback.connect(keepLooking); + +// register our scriptEnding callback +Script.scriptEnding.connect(scriptEnding); +