Skip to content

Instantly share code, notes, and snippets.

@birarda
Created July 17, 2015 22:19
Show Gist options
  • Save birarda/02eda8377a70fa916222 to your computer and use it in GitHub Desktop.
Save birarda/02eda8377a70fa916222 to your computer and use it in GitHub Desktop.
manyConnections.js
//
// manyConnections.js
// examples/utilities/diagnostics
//
// Created by Stephen Birarda on 05/08/15.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// This script is made for load testing HF servers. It connects to the HF servers and sends/receives data.
// Run this on an assignment-client.
//
var count = 0;
var yawDirection = -1;
var yaw = 45;
var yawMax = 70;
var yawMin = 20;
var vantagePoint = {x: 5000, y: 500, z: 5000};
var isLocal = false;
// set up our EntityViewer with a position and orientation
var orientation = Quat.fromPitchYawRollDegrees(0, yaw, 0);
EntityViewer.setPosition(vantagePoint);
EntityViewer.setOrientation(orientation);
EntityViewer.queryOctree();
Agent.isListeningToAudioStream = true;
Agent.isAvatar = true;
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function keepLooking(deltaTime) {
count++;
if (count % getRandomInt(5, 15) == 0) {
yaw += yawDirection;
orientation = Quat.fromPitchYawRollDegrees(0, yaw, 0);
if (yaw > yawMax || yaw < yawMin) {
yawDirection = yawDirection * -1;
}
EntityViewer.setOrientation(orientation);
EntityViewer.queryOctree();
}
}
// register the call back so it fires before each data send
Script.update.connect(keepLooking);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment