From 4b3a89fe8779d0111c27da2fbf1dc5d41efd6c63 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Mon, 22 Jan 2018 12:33:50 -0500 Subject: [PATCH] fix: native webvr (#45) * feat: use orbit controls when no devices are found * feat: update polyfill remove manager/boilerplate * fix: move shaders to their own files --- package-lock.json | 398 +++++++++++++++++------------------- package.json | 8 +- scripts/rollup-replace.js | 8 +- src/plugin.js | 137 +++++-------- src/rgb-fragment-shader.js | 5 + src/rgba-fragment-shader.js | 5 + src/vertex-shader.js | 5 + src/webvr-config.js | 21 -- 8 files changed, 260 insertions(+), 327 deletions(-) create mode 100644 src/rgb-fragment-shader.js create mode 100644 src/rgba-fragment-shader.js create mode 100644 src/vertex-shader.js delete mode 100644 src/webvr-config.js diff --git a/package-lock.json b/package-lock.json index 48dda590..963fd656 100644 --- a/package-lock.json +++ b/package-lock.json @@ -83,15 +83,13 @@ "dev": true }, "ajv": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", - "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", + "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", "dev": true, "requires": { "co": "4.6.0", - "fast-deep-equal": "1.0.0", - "fast-json-stable-stringify": "2.0.0", - "json-schema-traverse": "0.3.1" + "json-stable-stringify": "1.0.1" } }, "ajv-keywords": { @@ -287,9 +285,9 @@ "dev": true }, "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", + "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", "dev": true }, "async": { @@ -323,9 +321,9 @@ "dev": true }, "aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", + "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", "dev": true }, "aws4": { @@ -1062,12 +1060,12 @@ } }, "boom": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", - "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", + "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", "dev": true, "requires": { - "hoek": "4.2.0" + "hoek": "2.16.3" } }, "boundary": { @@ -1157,9 +1155,9 @@ } }, "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", + "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=", "dev": true }, "catharsis": { @@ -1358,9 +1356,9 @@ } }, "commander": { - "version": "2.12.2", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz", - "integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==", + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz", + "integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==", "dev": true }, "comment-parser": { @@ -1609,7 +1607,7 @@ "json-stringify-safe": "5.0.1", "lodash": "4.17.4", "meow": "3.7.0", - "semver": "5.4.1", + "semver": "5.5.0", "split": "1.0.1", "through2": "2.0.3" } @@ -1714,23 +1712,12 @@ } }, "cryptiles": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", - "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", + "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", "dev": true, "requires": { - "boom": "5.2.0" - }, - "dependencies": { - "boom": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", - "dev": true, - "requires": { - "hoek": "4.2.0" - } - } + "boom": "2.10.1" } }, "currently-unhandled": { @@ -1754,7 +1741,7 @@ "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", "dev": true, "requires": { - "es5-ext": "0.10.37" + "es5-ext": "0.10.38" } }, "dargs": { @@ -1773,6 +1760,14 @@ "dev": true, "requires": { "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + } } }, "date-now": { @@ -2177,9 +2172,9 @@ } }, "es5-ext": { - "version": "0.10.37", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.37.tgz", - "integrity": "sha1-DudB0Ui4AGm6J9AgOTdWryV978M=", + "version": "0.10.38", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.38.tgz", + "integrity": "sha512-jCMyePo7AXbUESwbl8Qi01VSH2piY9s/a3rSU/5w/MlTIx8HPL1xn2InGN8ejt/xulcJgnTO7vqNtOAxzYd2Kg==", "dev": true, "requires": { "es6-iterator": "2.0.3", @@ -2198,7 +2193,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-symbol": "3.1.1" } }, @@ -2209,18 +2204,13 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-iterator": "2.0.3", "es6-set": "0.1.5", "es6-symbol": "3.1.1", "event-emitter": "0.3.5" } }, - "es6-promise": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.2.tgz", - "integrity": "sha512-LSas5vsuA6Q4nEdf9wokY5/AJYXry98i0IzXsv49rYsgDGDNDPbqAYR1Pe23iFxygfbGZNR/5VrHXBCh2BhvUQ==" - }, "es6-set": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", @@ -2228,7 +2218,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-iterator": "2.0.3", "es6-symbol": "3.1.1", "event-emitter": "0.3.5" @@ -2241,7 +2231,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37" + "es5-ext": "0.10.38" } }, "es6-weak-map": { @@ -2251,7 +2241,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-iterator": "2.0.3", "es6-symbol": "3.1.1" } @@ -2469,7 +2459,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37" + "es5-ext": "0.10.38" } }, "event-stream": { @@ -2499,9 +2489,10 @@ } }, "eventemitter3": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-2.0.3.tgz", - "integrity": "sha1-teEHm1n7XhuidxwKmTvgYKWMmbo=" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-1.2.0.tgz", + "integrity": "sha1-HIaZHYFq0eUEdQ5zh0Ik7PO+xQg=", + "dev": true }, "exit": { "version": "0.1.2", @@ -2616,18 +2607,6 @@ "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", "dev": true }, - "fast-deep-equal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", - "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=", - "dev": true - }, - "fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", - "dev": true - }, "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", @@ -2772,9 +2751,9 @@ "dev": true }, "form-data": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.1.tgz", - "integrity": "sha1-b7lPvXGIUwbXPRXMSX/kzE7NRL8=", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", + "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", "dev": true, "requires": { "asynckit": "0.4.0", @@ -3812,6 +3791,14 @@ "dev": true, "requires": { "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + } } }, "git-raw-commits": { @@ -3844,7 +3831,7 @@ "dev": true, "requires": { "meow": "3.7.0", - "semver": "5.4.1" + "semver": "5.5.0" } }, "gitconfiglocal": { @@ -4018,20 +4005,16 @@ } } }, - "har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", - "dev": true - }, "har-validator": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", - "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", + "integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=", "dev": true, "requires": { - "ajv": "5.5.2", - "har-schema": "2.0.0" + "chalk": "1.1.3", + "commander": "2.13.0", + "is-my-json-valid": "2.17.1", + "pinkie-promise": "2.0.1" } }, "has": { @@ -4097,21 +4080,21 @@ "dev": true }, "hawk": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", + "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", "dev": true, "requires": { - "boom": "4.3.1", - "cryptiles": "3.1.2", - "hoek": "4.2.0", - "sntp": "2.1.0" + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" } }, "hoek": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz", - "integrity": "sha512-v0XCLxICi9nPfYrS9RL8HbYnXi9obYAeLbSP00BmnZwCK9+Ih9WOjoZ8YoHCoav2csqn4FOz4Orldsy2dmDwmQ==", + "version": "2.16.3", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", + "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", "dev": true }, "home-or-tmp": { @@ -4181,23 +4164,15 @@ "requires": { "eventemitter3": "1.2.0", "requires-port": "1.0.0" - }, - "dependencies": { - "eventemitter3": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-1.2.0.tgz", - "integrity": "sha1-HIaZHYFq0eUEdQ5zh0Ik7PO+xQg=", - "dev": true - } } }, "http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", + "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", "dev": true, "requires": { - "assert-plus": "1.0.0", + "assert-plus": "0.2.0", "jsprim": "1.4.1", "sshpk": "1.13.1" } @@ -4832,12 +4807,6 @@ "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", "dev": true }, - "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", - "dev": true - }, "json-stable-stringify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", @@ -4893,6 +4862,14 @@ "extsprintf": "1.3.0", "json-schema": "0.2.3", "verror": "1.10.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + } } }, "karma": { @@ -5438,7 +5415,7 @@ "nopt": "3.0.6", "npmlog": "4.1.2", "osenv": "0.1.4", - "request": "2.83.0", + "request": "2.79.0", "rimraf": "2.6.2", "semver": "5.3.0", "tar": "2.2.1", @@ -5454,9 +5431,9 @@ } }, "node-sass": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.5.3.tgz", - "integrity": "sha1-0JydEXlkEjnRuX/8YjH9zsU+FWg=", + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.7.2.tgz", + "integrity": "sha512-CaV+wLqZ7//Jdom5aUFCpGNoECd7BbNhjuwdsX/LkXBrHl8eb1Wjw4HvWqcFvhr5KuNgAk8i/myf/MQ1YYeroA==", "dev": true, "requires": { "async-foreach": "0.1.3", @@ -5474,9 +5451,10 @@ "nan": "2.8.0", "node-gyp": "3.6.2", "npmlog": "4.1.2", - "request": "2.83.0", + "request": "2.79.0", "sass-graph": "2.2.4", - "stdout-stream": "1.4.0" + "stdout-stream": "1.4.0", + "true-case-path": "1.0.2" } }, "node-static": { @@ -5507,7 +5485,7 @@ "requires": { "hosted-git-info": "2.5.0", "is-builtin-module": "1.0.0", - "semver": "5.4.1", + "semver": "5.5.0", "validate-npm-package-license": "3.0.1" } }, @@ -5949,12 +5927,6 @@ "through": "2.3.8" } }, - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", - "dev": true - }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -6325,39 +6297,43 @@ "dev": true }, "request": { - "version": "2.83.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz", - "integrity": "sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw==", + "version": "2.79.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.79.0.tgz", + "integrity": "sha1-Tf5b9r6LjNw3/Pk+BLZVd3InEN4=", "dev": true, "requires": { - "aws-sign2": "0.7.0", + "aws-sign2": "0.6.0", "aws4": "1.6.0", - "caseless": "0.12.0", + "caseless": "0.11.0", "combined-stream": "1.0.5", "extend": "3.0.1", "forever-agent": "0.6.1", - "form-data": "2.3.1", - "har-validator": "5.0.3", - "hawk": "6.0.2", - "http-signature": "1.2.0", + "form-data": "2.1.4", + "har-validator": "2.0.6", + "hawk": "3.1.3", + "http-signature": "1.1.1", "is-typedarray": "1.0.0", "isstream": "0.1.2", "json-stringify-safe": "5.0.1", "mime-types": "2.1.17", "oauth-sign": "0.8.2", - "performance-now": "2.1.0", - "qs": "6.5.1", - "safe-buffer": "5.1.1", + "qs": "6.3.2", "stringstream": "0.0.5", "tough-cookie": "2.3.3", - "tunnel-agent": "0.6.0", - "uuid": "3.1.0" + "tunnel-agent": "0.4.3", + "uuid": "3.2.1" }, "dependencies": { + "qs": { + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.3.2.tgz", + "integrity": "sha1-51vV9uJoEioqDgvaYwslUMFmUCw=", + "dev": true + }, "uuid": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true } } @@ -6714,11 +6690,6 @@ } } }, - "screenfull": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/screenfull/-/screenfull-3.3.2.tgz", - "integrity": "sha512-zrnT8EidEWGFkmXEa1d/YUYNvvJaMX05g4O82K+Oiy9jR6Fh3ZTsovsccJOjRJyhS0KPV7AQpDFQRAYXBl9a5A==" - }, "scss-tokenizer": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz", @@ -6730,9 +6701,9 @@ } }, "semver": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", - "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -6814,7 +6785,7 @@ "path-to-regexp": "1.7.0", "samsam": "1.3.0", "text-encoding": "0.6.4", - "type-detect": "4.0.5" + "type-detect": "4.0.6" } }, "slash": { @@ -6830,12 +6801,12 @@ "dev": true }, "sntp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", + "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", "dev": true, "requires": { - "hoek": "4.2.0" + "hoek": "2.16.3" } }, "socket.io": { @@ -7092,6 +7063,14 @@ "getpass": "0.1.7", "jsbn": "0.1.1", "tweetnacl": "0.14.5" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + } } }, "state-toggle": { @@ -7235,16 +7214,6 @@ "string-width": "2.1.1" }, "dependencies": { - "ajv": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", - "dev": true, - "requires": { - "co": "4.6.0", - "json-stable-stringify": "1.0.1" - } - }, "ansi-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", @@ -7424,6 +7393,30 @@ "integrity": "sha1-qf2LA5Swro//guBjOgo2zK1bX4Y=", "dev": true }, + "true-case-path": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/true-case-path/-/true-case-path-1.0.2.tgz", + "integrity": "sha1-fskRMJJHZsf1c74wIMNPj9/QDWI=", + "dev": true, + "requires": { + "glob": "6.0.4" + }, + "dependencies": { + "glob": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", + "integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=", + "dev": true, + "requires": { + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + } + } + }, "tsml": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/tsml/-/tsml-1.0.1.tgz", @@ -7436,13 +7429,10 @@ "dev": true }, "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz", + "integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us=", + "dev": true }, "tweetnacl": { "version": "0.14.5", @@ -7461,9 +7451,9 @@ } }, "type-detect": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.5.tgz", - "integrity": "sha512-N9IvkQslUGYGC24RkJk1ba99foK6TkwC2FHAEBlQFBP0RxQZS8ZpJuAZcwiY/w9ZJHFQb1aOXBI60OdxhTrwEQ==", + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.6.tgz", + "integrity": "sha512-qZ3bAurt2IXGPR3c57PyaSYEnQiLRwPeS60G9TahElBZsdOABo+iKYch/PhRjSTZJ5/DF08x43XMt9qec2g3ig==", "dev": true }, "type-is": { @@ -7483,12 +7473,12 @@ "dev": true }, "uglify-js": { - "version": "3.3.5", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.3.5.tgz", - "integrity": "sha512-ZebM2kgBL/UI9rKeAbsS2J0UPPv7SBy5hJNZml/YxB1zC6JK8IztcPs+cxilE4pu0li6vadVSFqiO7xFTKuSrg==", + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.3.7.tgz", + "integrity": "sha512-esJIpNQIC44EFSrbeFPhiXHy2HJ+dTcnn0Zdkn+5meuLsvoV0mFJffKlyezNIIHNfhF0NpgbifygCfEyAogIhQ==", "dev": true, "requires": { - "commander": "2.12.2", + "commander": "2.13.0", "source-map": "0.6.1" }, "dependencies": { @@ -7664,6 +7654,14 @@ "assert-plus": "1.0.0", "core-util-is": "1.0.2", "extsprintf": "1.3.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + } } }, "vfile": { @@ -7734,7 +7732,7 @@ "dev": true, "requires": { "babel-eslint": "6.1.2", - "commander": "2.12.2", + "commander": "2.13.0", "eslint": "2.13.1", "eslint-config-videojs": "3.0.1", "eslint-plugin-jsdoc": "2.4.0", @@ -7772,51 +7770,19 @@ "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=", "dev": true }, - "webvr-boilerplate": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/webvr-boilerplate/-/webvr-boilerplate-0.5.0.tgz", - "integrity": "sha1-620tFBRQUCRURPkHiNekAduU/M4=", + "webvr-polyfill": { + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/webvr-polyfill/-/webvr-polyfill-0.10.2.tgz", + "integrity": "sha512-fbHNbU/qj5T51PwZekOX+9qymY8Gn8tTCCis+dxl80TvorBN3M62/GJGhx60mY6JsI0GUtHWaFXT5DZ7+Br2PQ==", "requires": { - "es6-promise": "4.2.2", - "three": "0.89.0", - "webvr-polyfill": "0.10.2", - "webvr-ui": "0.10.0" - }, - "dependencies": { - "three": { - "version": "0.89.0", - "resolved": "https://registry.npmjs.org/three/-/three-0.89.0.tgz", - "integrity": "sha1-RELYGaYWiHG40ss3rRKiQxDBcPU=" - }, - "webvr-polyfill": { - "version": "0.10.2", - "resolved": "https://registry.npmjs.org/webvr-polyfill/-/webvr-polyfill-0.10.2.tgz", - "integrity": "sha512-fbHNbU/qj5T51PwZekOX+9qymY8Gn8tTCCis+dxl80TvorBN3M62/GJGhx60mY6JsI0GUtHWaFXT5DZ7+Br2PQ==", - "requires": { - "cardboard-vr-display": "1.0.3" - } - } + "cardboard-vr-display": "1.0.3" } }, - "webvr-polyfill": { - "version": "0.9.38", - "resolved": "https://registry.npmjs.org/webvr-polyfill/-/webvr-polyfill-0.9.38.tgz", - "integrity": "sha512-HABweqWYE0suk6P5TdHlagJK56HSecB5xKj6ZshocrxSj9UmNOCjCRv4vFYHCaFZKtuKWa8niRHVbJ3Vo7JYDg==" - }, "webvr-polyfill-dpdb": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/webvr-polyfill-dpdb/-/webvr-polyfill-dpdb-1.0.4.tgz", "integrity": "sha512-zDiwsI3zrkY60Iq/0Lko4TjePakBjwndaOzQvRPw+sX7XSvvRrpxV4Y1355VX9SkTsZxXPcw2IJF1nqlrR6yQQ==" }, - "webvr-ui": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/webvr-ui/-/webvr-ui-0.10.0.tgz", - "integrity": "sha1-YeG+OsEoUCHcrZVMo4+4YKyNiMU=", - "requires": { - "eventemitter3": "2.0.3", - "screenfull": "3.3.2" - } - }, "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", diff --git a/package.json b/package.json index 6e1d7771..42bca4d6 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "watch:js-modules": "rollup -c scripts/modules.rollup.config.js -w", "watch:js-umd": "rollup -c scripts/umd.rollup.config.js -w", "watch:test": "rollup -c scripts/test.rollup.config.js -w", - "prepublish": "npm run build", + "prepublish": "not-in-install && npm run build || in-install", "prepush": "npm run lint", "precommit": "npm run docs:toc && git add README.md" }, @@ -92,8 +92,7 @@ "global": "^4.3.2", "three": "^0.87.1", "video.js": "^6.2.7", - "webvr-boilerplate": "^0.5.0", - "webvr-polyfill": "0.9.38" + "webvr-polyfill": "^0.10.2" }, "devDependencies": { "babel-plugin-external-helpers": "^6.22.0", @@ -106,6 +105,7 @@ "doctoc": "^1.3.0", "es5-shim": "^4.5.9", "husky": "^0.13.3", + "in-publish": "^2.0.0", "jsdoc": "^3.4.3", "karma": "~1.3.0", "karma-chrome-launcher": "^2.1.1", @@ -115,7 +115,7 @@ "karma-qunit": "^1.2.1", "karma-safari-launcher": "^1.0.0", "mkdirp": "^0.5.1", - "node-sass": "4.5.3", + "node-sass": "^4.5.3", "node-static": "^0.7.9", "npm-run-all": "^4.0.2", "qunitjs": "^1.21.0", diff --git a/scripts/rollup-replace.js b/scripts/rollup-replace.js index ce8cf1cf..1b730742 100644 --- a/scripts/rollup-replace.js +++ b/scripts/rollup-replace.js @@ -6,9 +6,13 @@ export default function(options) { 'include': ['node_modules/three/examples/js/**'], 'delimiters': ['', ''], 'THREE.VRControls =': "var THREE = require('three');var VRControls;\nmodule.exports = VRControls =", - 'THREE.VREffect =': "var THREE = require('three');var VREffect;\nmodule.exports = VREffect =", 'THREE.VRControls': 'VRControls', - 'THREE.VREffect': 'VREffect' + + 'THREE.VREffect =': "var THREE = require('three');var VREffect;\nmodule.exports = VREffect =", + 'THREE.VREffect': 'VREffect', + + 'THREE.OrbitControls =': "var THREE = require('three');var OrbitControls;\nmodule.exports = OrbitControls =", + 'THREE.OrbitControls': 'OrbitControls' }, options || {})); } diff --git a/src/plugin.js b/src/plugin.js index 1d1f3c6a..c70fdfb9 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -1,20 +1,19 @@ import {version as VERSION} from '../package.json'; import window from 'global/window'; -/* THIS CONFIGURES webvr-polyfill don't change the order */ -import './webvr-config.js'; -import 'webvr-polyfill/src/main'; +import WebVRPolyfill from 'webvr-polyfill'; import videojs from 'video.js'; import * as THREE from 'three'; import VRControls from 'three/examples/js/controls/VRControls.js'; import VREffect from 'three/examples/js/effects/VREffect.js'; -import WebVRManager from 'webvr-boilerplate/build/webvr-manager'; +import OrbitControls from 'three/examples/js/controls/OrbitControls.js'; +import rgbFragmentShader from './rgb-fragment-shader'; +import rgbaFragmentShader from './rgba-fragment-shader'; +import vertexShader from './vertex-shader'; // import controls so they get regisetered with videojs import './cardboard-button'; import './big-vr-play-button'; -window.WebVRManager = WebVRManager; - const validProjections = [ '360', '360_LR', @@ -35,11 +34,6 @@ const defaults = { }; const errors = { - 'web-vr-no-devices-found': { - headline: 'No 360 devices found', - type: '360_NO_DEVICES_FOUND', - message: 'Your browser supports 360, but no 360 displays found.' - }, 'web-vr-out-of-date': { headline: '360 is out of date', type: '360_OUT_OF_DATE', @@ -106,6 +100,10 @@ class VR extends Plugin { super(player, settings); + this.polyfill_ = new WebVRPolyfill({ + TOUCH_PANNER_DISABLED: false + }); + this.options_ = settings; this.player_ = player; this.bigPlayButtonIndex_ = player.children().indexOf(player.getChild('BigPlayButton')) || 0; @@ -269,17 +267,27 @@ class VR extends Plugin { } handleVrDisplayActivate_() { - this.manager.enterVRMode_(); - this.manager.setMode_(3); + if (!this.vrDisplay) { + return; + } + this.vrDisplay.requestPresent([{source: this.renderedCanvas}]); } handleVrDisplayDeactivate_() { - if (!this.vrDisplay.isPresenting) { + if (!this.vrDisplay || !this.vrDisplay.isPresenting) { return; } this.vrDisplay.exitPresent(); } + requestAnimationFrame(fn) { + if (this.vrDisplay) { + return this.vrDisplay.requestAnimationFrame(fn); + } + + return super.requestAnimationFrame(fn); + } + togglePlay_() { if (this.player_.paused()) { this.player_.play(); @@ -296,31 +304,22 @@ class VR extends Plugin { } this.controls3d.update(); - this.manager.render(this.scene, this.camera); + this.effect.render(this.scene, this.camera); - if (!this.vrDisplay) { - this.animationFrameId_ = this.requestAnimationFrame(this.animate_); - this.camera.getWorldDirection(this.cameraVector); - return; - } - - this.animationFrameId_ = this.vrDisplay.requestAnimationFrame(this.animate_); + this.animationFrameId_ = this.requestAnimationFrame(this.animate_); - if (!window.navigator.getGamepads) { - return; - } - // Grab all gamepads - const gamepads = window.navigator.getGamepads(); + if (window.navigator.getGamepads) { + // Grab all gamepads + const gamepads = window.navigator.getGamepads(); - for (let i = 0; i < gamepads.length; ++i) { - const gamepad = gamepads[i]; + for (let i = 0; i < gamepads.length; ++i) { + const gamepad = gamepads[i]; - // Make sure gamepad is defined - if (!gamepad) { - continue; - } - // Only take input if state has changed since we checked last - if (gamepad.timestamp && !(gamepad.timestamp === this.prevTimestamps_[i])) { + // Make sure gamepad is defined + // Only take input if state has changed since we checked last + if (!gamepad || !gamepad.timestamp || gamepad.timestamp === this.prevTimestamps_[i]) { + continue; + } for (let j = 0; j < gamepad.buttons.length; ++j) { if (gamepad.buttons[j].pressed) { this.togglePlay_(); @@ -366,7 +365,6 @@ class VR extends Plugin { } this.scene = new THREE.Scene(); - this.controls3d = new VRControls(this.camera); this.videoTexture = new THREE.VideoTexture(this.getVideoEl_()); @@ -392,45 +390,17 @@ class VR extends Plugin { this.videoTexture.format = THREE.RGBFormat; } - if (this.videoTexture.format === THREE.RGBAFormat && this.videoTexture.flipY === false) { - this.movieMaterial = new THREE.ShaderMaterial({ - uniforms: { - texture: { value: this.videoTexture } - }, - vertexShader: [ - 'varying vec2 vUV;', - 'void main() {', - ' vUV = vec2( uv.x, 1.0 - uv.y );', - ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', - '}' - ].join('\n'), - fragmentShader: [ - 'uniform sampler2D texture;', - 'varying vec2 vUV;', - 'void main() {', - ' gl_FragColor = texture2D( texture, vUV ).bgra;', - '}' - ].join('\n') - }); - } else if (this.videoTexture.format === THREE.RGBFormat && this.videoTexture.flipY === false) { + if ((this.videoTexture.format === THREE.RGBAFormat || this.videoTexture.format === THREE.RGBFormat) && this.videoTexture.flipY === false) { + let fragmentShader = rgbFragmentShader; + + if (this.videoTexture.format === THREE.RGBAFormat) { + fragmentShader = rgbaFragmentShader; + } + this.movieMaterial = new THREE.ShaderMaterial({ - uniforms: { - texture: { value: this.videoTexture } - }, - vertexShader: [ - 'varying vec2 vUV;', - 'void main() {', - ' vUV = vec2( uv.x, 1.0 - uv.y );', - ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', - '}' - ].join('\n'), - fragmentShader: [ - 'uniform sampler2D texture;', - 'varying vec2 vUV;', - 'void main() {', - ' gl_FragColor = texture2D( texture, vUV );', - '}' - ].join('\n') + uniforms: {texture: {value: this.videoTexture}}, + vertexShader, + fragmentShader }); } else { this.movieMaterial = new THREE.MeshBasicMaterial({ map: this.videoTexture, overdraw: true, side: THREE.DoubleSide }); @@ -477,8 +447,6 @@ class VR extends Plugin { // Previous timestamps for gamepad updates this.prevTimestamps_ = []; - this.manager = new WebVRManager(this.renderer, this.effect, {hideButton: true}); - this.renderedCanvas = this.renderer.domElement; const debounce = function(fn, wait) { @@ -514,11 +482,12 @@ class VR extends Plugin { this.getVideoEl_().style.display = 'none'; if (window.navigator.getVRDisplays) { + this.log('VR is supported, getting vr displays'); window.navigator.getVRDisplays().then((displays) => { if (displays.length > 0) { - this.log('WebVR supported, VRDisplays found.'); + this.log('VR Displays found', displays); this.vrDisplay = displays[0]; - this.log(this.vrDisplay); + this.log('Going to use VRControls on the first one', this.vrDisplay); // Native WebVR Head Mounted Displays (HMDs) like the HTC Vive // also need the cardboard button to enter fully immersive mode @@ -526,12 +495,13 @@ class VR extends Plugin { if (!this.vrDisplay.isPolyfilled) { this.addCardboardButton_(); } - // FIREFOX doesn't report the polyfill display as a - // VRDisplay so this would error even though the video would - // work - } else if (!videojs.browser.IS_FIREFOX) { - this.triggerError_({code: 'web-vr-no-devices-found', dismiss: false}); + this.controls3d = new VRControls(this.camera); + } else { + this.log('no vr displays found going to use OrbitControls'); + this.controls3d = new OrbitControls(this.camera, this.renderedCanvas); + this.controls3d.target.set(0, 0, -1); } + this.requestAnimationFrame(this.animate_); }); } else if (window.navigator.getVRDevices) { this.triggerError_({code: 'web-vr-out-of-date', dismiss: false}); @@ -545,7 +515,6 @@ class VR extends Plugin { window.addEventListener('vrdisplayactivate', this.handleVrDisplayActivate_, true); window.addEventListener('vrdisplaydeactivate', this.handleVrDisplayDeactivate_, true); - this.animate_(); this.initialized_ = true; } diff --git a/src/rgb-fragment-shader.js b/src/rgb-fragment-shader.js new file mode 100644 index 00000000..708384a1 --- /dev/null +++ b/src/rgb-fragment-shader.js @@ -0,0 +1,5 @@ +module.exports = `uniform sampler2D texture; +varying vec2 vUV; +void main() { + gl_FragColor = texture2D(texture, vUV); +}`; diff --git a/src/rgba-fragment-shader.js b/src/rgba-fragment-shader.js new file mode 100644 index 00000000..05de9b0d --- /dev/null +++ b/src/rgba-fragment-shader.js @@ -0,0 +1,5 @@ +module.exports = `uniform sampler2D texture; +varying vec2 vUV; +void main() { + gl_FragColor = texture2D(texture, vUV).bgra; +}`; diff --git a/src/vertex-shader.js b/src/vertex-shader.js new file mode 100644 index 00000000..9aa41971 --- /dev/null +++ b/src/vertex-shader.js @@ -0,0 +1,5 @@ +module.exports = `varying vec2 vUV; +void main() { + vUV = vec2( uv.x, 1.0 - uv.y ); + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); +}`; diff --git a/src/webvr-config.js b/src/webvr-config.js deleted file mode 100644 index a321aae9..00000000 --- a/src/webvr-config.js +++ /dev/null @@ -1,21 +0,0 @@ -import window from 'global/window'; -// this is used to configure webvr-polyfill -// see https://github.com/googlevr/webvr-polyfill#configuration -const WebVRConfig = { - // TODO: - // implement controls so that thy only work when the player is in focus. - // This will require MOUSE_KEYBOARD_CONTROLS_DISABLED, and TOUCH_PANNER_DISABLED to be set to true - // and various points in the code will have to be changed. As a lot of the code - // expects some sort of controls to be set up, and when no controls are set up - // it throws an error about no vr displays being found. VrDisplays is actually referring to controls. - - // Flag to disable touch panner. In case you have your own touch controls. - // Default: true. - TOUCH_PANNER_DISABLED: false - // To disable keyboard and mouse controls, if you want to use your own - // implementation. - // Default: false. - // MOUSE_KEYBOARD_CONTROLS_DISABLED: true, -}; - -window.WebVRConfig = WebVRConfig;