Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/debug mode #399

Merged
merged 3 commits into from
May 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ yarn build
- `mobile` - Force mobile mode
- `no_stats` - Disable performance stats
- `vr_entry_type` - Either "gearvr" or "daydream". Used internally to force a VR entry type
- `disable_telemetry` - If `true` disables Sentry telemetry.
- `log_filter` - A `debug` style filter for setting the logging level.
- `debug` - If `true` performs verbose logging of Janus and NAF traffic.

## Additional Resources

Expand Down
20 changes: 19 additions & 1 deletion src/hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { patchWebGLRenderingContext } from "./utils/webgl";
patchWebGLRenderingContext();

import "aframe-xr";
import debug from "debug";
import "./vendor/GLTFLoader";
import "networked-aframe/src/index";
import "naf-janus-adapter";
Expand Down Expand Up @@ -129,11 +130,19 @@ function qsTruthy(param) {
}

const isBotMode = qsTruthy("bot");
const isTelemetryDisabled = qsTruthy("disable_telemetry");
const isDebug = qsTruthy("debug");
const logFilter = qs["log_filter"] || (isDebug && "naf-janus-adapter:*");

if (!isBotMode) {
if (!isBotMode && !isTelemetryDisabled) {
registerTelemetry();
}

// NOTE: this needs to happen after a-frame's `utils/debug.js` file has been eval'ed because it overwrites any prior debug settings :/
if (logFilter) {
debug.enable(logFilter);
}

disableiOSZoom();

AFRAME.registerInputBehaviour("trackpad_dpad4", trackpad_dpad4);
Expand Down Expand Up @@ -240,6 +249,10 @@ const onReady = async () => {
serverURL: process.env.JANUS_SERVER
});

if (isDebug) {
scene.setAttribute("networked-scene", { debug: true });
}

scene.setAttribute("stats-plus", false);

if (isMobile || qsTruthy("mobile")) {
Expand Down Expand Up @@ -310,12 +323,17 @@ const onReady = async () => {
scene.components["networked-scene"].connect().catch(connectError => {
// hacky until we get return codes
const isFull = connectError.error && connectError.error.msg.match(/\bfull\b/i);
console.error(connectError);
remountUI({ roomUnavailableReason: isFull ? "full" : "connect_error" });
exitScene();

return;
});

if (isDebug) {
NAF.connection.adapter.session.options.verbose = true;
}

if (isBotMode) {
playerRig.setAttribute("avatar-replay", {
camera: "#player-camera",
Expand Down