Skip to content

Instantly share code, notes, and snippets.

@DigiTec
DigiTec / harness.js
Created March 11, 2021 19:02
Sample VR WebDriver Test
const parseArgs = require('./parseArgs');
const options = parseArgs(process.argv);
const host = options.host || process.env.SHELLDRIVER_HOST || '127.0.0.1';
const port = options.port || process.env.SHELLDRIVER_PORT || '8080';
const overlayPort = options.overlayPort || process.env.SHELLDRIVER_OVERLAY_PORT || '8081';
const shellDriverFactory = require('./shell-driver/shell-driver');
const shellDriver = new shellDriverFactory.ShellDriver(host, port);
const shellDriverOverlay = new shellDriverFactory.ShellDriver(host, overlayPort);
@DigiTec
DigiTec / RequestHighestRefreshRate.js
Last active September 10, 2018 23:08
Shows how to request 72hz rendering on the Go. Can be combined with samples at https://webvr.info/samples/
// This is connected to your "Enter WebVR" button
function onVRRequestPresent () {
console.log("onVRRequestPresent begin");
// This can only be called in response to a user gesture.
var attributes = {
highRefreshRate: true,
};
vrDisplay.requestPresent([{source: webglCanvas, attributes: attributes}]).then(function () {
// Nothing to do because we're handling things in onVRPresentChange.
console.log("highRefreshRate = " + vrDisplay.getLayers()[0].attributes.highRefreshRate);
@DigiTec
DigiTec / client.js
Created April 22, 2017 22:12
Hack a ReactVR application to display two different scenes in the same page (kind of like a feed)
// Auto-generated content.
// This file contains the boilerplate to set up your React app.
// If you want to modify your application, start in "index.vr.js"
// Auto-generated content.
import {VRInstance} from 'react-vr-web';
// *** Previously vrapp was hardcoded, by adding it we can target our init
// *** and have it choose a specific component.
function init(bundle, vrapp, parent, options) {
@DigiTec
DigiTec / HTMLExampleElement.cc
Last active March 25, 2017 20:22
Chromium confessions blog entry on plumbing a bool
bool HTMLElementElement::isNewFeatureAllowed(bool defaultValue) {
KURL frame_url = document.url();
if (frame_url.host() == "example.com" || frame_url.host().endsWith(".example.com")) {
return false;
}
return defaultValue;
}
@DigiTec
DigiTec / README.md
Last active December 19, 2016 18:02
Transform a React VR CLI project into an OVRUI project. To get started `npm install -g react-vr-cli` for the React VR CLI to make new projects. Then `react-vr init PROJECT_NAME' to create a project directory with all of the React VR code. From here you can copy the below files into the root and they will automatically reference the node_modules …

Transform a React VR CLI project into an OVRUI project.

To get started npm install -g react-vr-cli for the React VR CLI to make new projects.

Then react-vr init PROJECT_NAME to create a project directory with all of the React VR code.

From here you can copy the below files into the root and they will automatically reference the node_modules versions of THREE and OVRUI.

@DigiTec
DigiTec / SimpleTextureCache.js
Created December 5, 2016 01:09
Super simple texture cache for THREE.js to avoid multiple network downloads and potentially GPU uploads
let textureLoader = {
webLoader: new THREE.TextureLoader(),
cache: {},
useCache: true,
getTexture: function (url) {
let cache = this.cache;
let webLoader = this.webLoader;
if (!cache[url]) {
cache[url] = new Promise(function (resolve, reject) {
webLoader.setCrossOrigin('Access-Control-Allow-Origin');
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<html>
<body>
<script>
var currIter;
var iters;
var execNum;
var startedExecute;
var sch = 'sched';
var schNum = sch + ' ';
var exec = 'exec';
@DigiTec
DigiTec / Potential Bug 1.cpp
Created February 15, 2016 21:31
Maybe a loophole/compiler bug in VS 2015 update 1 around static constexpr and embedding classes with vftable pointers
// Const Expr Playground.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
typedef void(*InitializeMethod)(int foo);
void InitMethod(int foo)
{
@DigiTec
DigiTec / settimeout.js
Created December 31, 2015 06:28
Source Code Links for my Blog Posting on Promises in EdgeHTML.
window.setTimeout(callback, 0); // Execute immediately!