Skip to content

Instantly share code, notes, and snippets.

@MiladNazeri
Last active October 10, 2017 13:45
Show Gist options
  • Save MiladNazeri/7f66318aaf07795d99a806572ee38148 to your computer and use it in GitHub Desktop.
Save MiladNazeri/7f66318aaf07795d99a806572ee38148 to your computer and use it in GitHub Desktop.
Helper to capture data in a script
//trying to find ou issues with sim performance.
//Chris Collins 1/14/2017
(function() {
var _this = this;
// The url of the macro
var STAT_GOOGLE_SCRIPT_URL = "https://script.google.com/macros/s/AKfycbxxphmPhZHAL9rwckMPrJp6bOsJYRiRCeLZkefyINnGZaxA8cY/exec";
// Send the data every:
var SEND_EVERY = 5000; // 5 seconds
function sendStats() {
Stats.forceUpdateStats();
var req = new XMLHttpRequest();
req.open("POST", STAT_GOOGLE_SCRIPT_URL, false);
req.send(JSON.stringify({
username: GlobalServices.username,
location: Window.location.hostname,
framerate: Stats.renderrate,
simrate: Stats.presentrate,
ping: {
audio: Stats.audioPing,
avatar: Stats.avatarPing,
entities: Stats.entitiesPing,
asset: Stats.assetPing
},
position: Camera.position,
yaw: Stats.yaw,
rotation:
Camera.orientation.x + ',' +
Camera.orientation.y + ',' +
Camera.orientation.z + ',' +
Camera.orientation.w,
packetloss: {
audioUpstream: 0,
audioDownstream: 0
}
}));
print(req.status);
print(req.responseText);
}
Script.setInterval(sendStats, SEND_EVERY);
sendStats();
_this.enterEntity = function(entityID) {
print('I am inside');
//send data once
sendStats();
};
_this.leaveEntity = function(entityID) {
print('I am outside');
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment