diff --git a/360-photos.html b/360-photos.html index 892e5cd66..80f7f51e6 100644 --- a/360-photos.html +++ b/360-photos.html @@ -25,27 +25,12 @@ - - - + + 360 Photos - - - - - - - - - - -
@@ -59,22 +44,26 @@

- diff --git a/controller-state.html b/controller-state.html new file mode 100644 index 000000000..eb2771efe --- /dev/null +++ b/controller-state.html @@ -0,0 +1,368 @@ + + + + + + + + + + + + Controller State + + + + +
+
+ Controller State +

+ This sample demonstrates using XRInputSource Gamepad button presses + to change box color and joystick/touchpad input to move boxes in 2 + dimensions. + Back +

+
+
+ + + \ No newline at end of file diff --git a/explainer.html b/explainer.html index df122075f..105d9f569 100644 --- a/explainer.html +++ b/explainer.html @@ -9,6 +9,9 @@ + + + diff --git a/fallback-rendering.html b/fallback-rendering.html deleted file mode 100644 index 9f9b2d1aa..000000000 --- a/fallback-rendering.html +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - - - - - - - Fallback Rendering - - - - - - - - - - - - - - - -
-
- Fallback Rendering -

- This sample demonstrates a way to fallback to rendering the scene when - WebXR isn't available. - Back -

-
-
- - - diff --git a/favicon-32x32.png b/favicon-32x32.png index 2c6895444..c60d102c2 100644 Binary files a/favicon-32x32.png and b/favicon-32x32.png differ diff --git a/favicon-96x96.png b/favicon-96x96.png index 1f538066d..c004ab3bd 100644 Binary files a/favicon-96x96.png and b/favicon-96x96.png differ diff --git a/favicon.ico b/favicon.ico index 6f5f7be09..14ddec13c 100644 Binary files a/favicon.ico and b/favicon.ico differ diff --git a/framebuffer-scaling.html b/framebuffer-scaling.html index f876cf9bd..68a2f1f6d 100644 --- a/framebuffer-scaling.html +++ b/framebuffer-scaling.html @@ -25,26 +25,12 @@ - - - + + Framebuffer Scaling - - - - - - - - - -
@@ -69,17 +55,20 @@

Click 'Enter XR' to see content

- diff --git a/xr-presentation.html b/immersive-vr-session.html similarity index 77% rename from xr-presentation.html rename to immersive-vr-session.html index 1adc81b24..6e33600aa 100644 --- a/xr-presentation.html +++ b/immersive-vr-session.html @@ -25,36 +25,21 @@ + + - - - - XR Presentation + Immersive VR Session - - - - - - - - - - -
- XR Presentation + Immersive VR Session

- This sample demonstrates how to present a simple WebGL scene to a - XRDevice. The scene is not rendered to the page prior to XR - presentation, nor is it mirrored during presentation. + This sample demonstrates how to use an 'immersive-vr' XRSession to + present a simple WebGL scene to an XR device. The scene is not + rendered to the page. Back

@@ -62,17 +47,20 @@

Click 'Enter XR' to see content

- diff --git a/index.html b/index.html index 8c813e3a4..579b22c34 100644 --- a/index.html +++ b/index.html @@ -74,14 +74,8 @@ font-size: 0.8em; } - .annoying-warning { - background: #fdd; - color: red; - padding: 0 1em; - margin: 1em 0; - border: thick red; - border-style: solid; - border-radius: 1em; + .wordmark img { + width: 70%; } @@ -96,11 +90,15 @@
-

WebXR

+

+ + WebXR Logo + +

Sample Pages

@@ -108,31 +106,15 @@

Sample Pages

Sample pages demonstrating how to use various aspects of the WebXR API.
Learn More

-
-

WARNING: The WebXR Device API spec is undergoing rapid development at this time. - These samples are not guaranteed to reflect the current state of the API or run on any browser until the specification has stablized.

- -

If the samples are not working for you, please DON'T FILE BUG REPORTS for this repository or in other issue trackers. This is - expected to happen until this notice is removed.

-
- + + diff --git a/input-selection.html b/input-selection.html index 25742b65c..7163715b9 100644 --- a/input-selection.html +++ b/input-selection.html @@ -25,27 +25,12 @@ - - - + + Input Selection - - - - - - - - - - -
@@ -58,70 +43,56 @@

- diff --git a/input-tracking.html b/input-tracking.html index 4baa8b17e..bf956e0ca 100644 --- a/input-tracking.html +++ b/input-tracking.html @@ -25,27 +25,12 @@ - - - + + Input Tracking - - - - - - - - - - -
@@ -59,22 +44,28 @@

- diff --git a/js/cottontail/.eslintrc.json b/js/cottontail/.eslintrc.json deleted file mode 100644 index d6719c99d..000000000 --- a/js/cottontail/.eslintrc.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": ["eslint:recommended","google"], - "parserOptions": { - "sourceType": "module" - }, - "env": { - "browser": true, - "es6": true - }, - "globals": { - "XRWebGLLayer": true - }, - "rules": { - "max-len": [2,120], - "valid-jsdoc": [0, {}], - "require-jsdoc": [0, {}], - "no-console": 0, - "guard-for-in": 0 - } -} diff --git a/js/cottontail/.gitignore b/js/cottontail/.gitignore deleted file mode 100644 index ccb2c800f..000000000 --- a/js/cottontail/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules/ -package-lock.json \ No newline at end of file diff --git a/js/cottontail/LICENSE.md b/js/cottontail/LICENSE.md deleted file mode 100644 index 3180b1bce..000000000 --- a/js/cottontail/LICENSE.md +++ /dev/null @@ -1,18 +0,0 @@ -Copyright 2018 The Immersive Web Community Group - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/js/cottontail/README.md b/js/cottontail/README.md deleted file mode 100644 index 54bb914d2..000000000 --- a/js/cottontail/README.md +++ /dev/null @@ -1,47 +0,0 @@ -Cottontail -========================================== -A simple WebGL renderering framework optimised for demonstrating WebXR concepts. - -Cottontail does two things well and not much else: - -1) Loading and Rendering GLTF 2.0 files. -2) Optimising for WebXR-style rendering. - -However it explicitly goes out of it's way to NOT wrap much, if any, WebXR -functionality. This is because arguably it's sole purpose in life is to enable -the WebXR samples, who's sole purpose in life is to provide easy-to-follow code -snippets demonstrating the API use and thus anything this code did to hide the -WebXR API's direct use is counter productive. - -Using Cottontail for your own projects is very much not recommended, as you will -almost certainly be better served by one of the other more popular frameworks -out there. - -**About the name:** I wanted something that evoked XR imagery without being too -heavy handed about it. The "White Rabbit" is prominent symbol in multiple peices -of media about virtual worlds, such as the movie _The Matrix_ and the novel -_Rainbows End_, which has a particularly heavy focus on AR/MR. So I liked the -idea of riffing off of that. It's also nice (though unintended) bonus that the -Daydream logo looks a bit like a stylized rabbit tail. Finally, it's based on -some code that I started on Easter day, 2017. - -The real world may rest on the back of a giant tortise, but I propose -that the virtual one is bunnies all the way down. ;) - -Building --------- -Cottontail can be used directly by any browser with good JavaScript modules -support, but to ensure widest compatibility (and shorter download times) using -a version compiled into a single file is recommended. To build first install the -[node.js](https://nodejs.org/en/) dependencies with: - - `npm install` - -Then build with: - - `npm run build-all` - -For faster development iteration you can also have the project rebuild with any -code changes automatically by running: - - `npm run watch` diff --git a/js/cottontail/TODOs.md b/js/cottontail/TODOs.md deleted file mode 100644 index 102aac3c3..000000000 --- a/js/cottontail/TODOs.md +++ /dev/null @@ -1,15 +0,0 @@ -Cottontail TODOs -================ - - - Make texture upload use of `ImageBitmaps` when available - - Generally reduce use of GL enums at user level - - Clean up `Scene` logic, maybe rename to `WebXRSampleScene`? - - Node cloning has issues, doesn't handle renderer changes. - -Nice to haves -------------- - - - Support GLTF skeletal animations - - Support Draco compression - - "Floaties" - - HTML-to-texture for captions. (SVG?) \ No newline at end of file diff --git a/js/cottontail/build/cottontail.debug.js b/js/cottontail/build/cottontail.debug.js deleted file mode 100644 index fe26cdc20..000000000 --- a/js/cottontail/build/cottontail.debug.js +++ /dev/null @@ -1,15198 +0,0 @@ -/*! - * Copyright 2018 The Immersive Web Community Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define([], factory); - else { - var a = factory(); - for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; - } -})(window, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = "./src/cottontail.js"); -/******/ }) -/************************************************************************/ -/******/ ({ - -/***/ "./node_modules/gl-matrix/src/gl-matrix/common.js": -/*!********************************************************!*\ - !*** ./node_modules/gl-matrix/src/gl-matrix/common.js ***! - \********************************************************/ -/*! exports provided: EPSILON, ARRAY_TYPE, RANDOM, setMatrixArrayType, toRadian, equals */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EPSILON", function() { return EPSILON; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ARRAY_TYPE", function() { return ARRAY_TYPE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RANDOM", function() { return RANDOM; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setMatrixArrayType", function() { return setMatrixArrayType; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toRadian", function() { return toRadian; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; }); -/** - * Common utilities - * @module glMatrix - */ - -// Configuration Constants -const EPSILON = 0.000001; -let ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array; -const RANDOM = Math.random; - -/** - * Sets the type of array used when creating new vectors and matrices - * - * @param {Type} type Array type, such as Float32Array or Array - */ -function setMatrixArrayType(type) { - ARRAY_TYPE = type; -} - -const degree = Math.PI / 180; - -/** - * Convert Degree To Radian - * - * @param {Number} a Angle in Degrees - */ -function toRadian(a) { - return a * degree; -} - -/** - * Tests whether or not the arguments have approximately the same value, within an absolute - * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less - * than or equal to 1.0, and a relative tolerance is used for larger values) - * - * @param {Number} a The first number to test. - * @param {Number} b The second number to test. - * @returns {Boolean} True if the numbers are approximately equal, false otherwise. - */ -function equals(a, b) { - return Math.abs(a - b) <= EPSILON*Math.max(1.0, Math.abs(a), Math.abs(b)); -} - - -/***/ }), - -/***/ "./node_modules/gl-matrix/src/gl-matrix/mat2.js": -/*!******************************************************!*\ - !*** ./node_modules/gl-matrix/src/gl-matrix/mat2.js ***! - \******************************************************/ -/*! exports provided: create, clone, copy, identity, fromValues, set, transpose, invert, adjoint, determinant, multiply, rotate, scale, fromRotation, fromScaling, str, frob, LDU, add, subtract, exactEquals, equals, multiplyScalar, multiplyScalarAndAdd, mul, sub */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return identity; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transpose", function() { return transpose; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "invert", function() { return invert; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "adjoint", function() { return adjoint; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determinant", function() { return determinant; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotate", function() { return rotate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotation", function() { return fromRotation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromScaling", function() { return fromScaling; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "frob", function() { return frob; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LDU", function() { return LDU; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subtract", function() { return subtract; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalar", function() { return multiplyScalar; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalarAndAdd", function() { return multiplyScalarAndAdd; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; }); -/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/src/gl-matrix/common.js"); - - -/** - * 2x2 Matrix - * @module mat2 - */ - -/** - * Creates a new identity mat2 - * - * @returns {mat2} a new 2x2 matrix - */ -function create() { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](4); - if(_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) { - out[1] = 0; - out[2] = 0; - } - out[0] = 1; - out[3] = 1; - return out; -} - -/** - * Creates a new mat2 initialized with values from an existing matrix - * - * @param {mat2} a matrix to clone - * @returns {mat2} a new 2x2 matrix - */ -function clone(a) { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](4); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - return out; -} - -/** - * Copy the values from one mat2 to another - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the source matrix - * @returns {mat2} out - */ -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - return out; -} - -/** - * Set a mat2 to the identity matrix - * - * @param {mat2} out the receiving matrix - * @returns {mat2} out - */ -function identity(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; - return out; -} - -/** - * Create a new mat2 with the given values - * - * @param {Number} m00 Component in column 0, row 0 position (index 0) - * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m10 Component in column 1, row 0 position (index 2) - * @param {Number} m11 Component in column 1, row 1 position (index 3) - * @returns {mat2} out A new 2x2 matrix - */ -function fromValues(m00, m01, m10, m11) { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](4); - out[0] = m00; - out[1] = m01; - out[2] = m10; - out[3] = m11; - return out; -} - -/** - * Set the components of a mat2 to the given values - * - * @param {mat2} out the receiving matrix - * @param {Number} m00 Component in column 0, row 0 position (index 0) - * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m10 Component in column 1, row 0 position (index 2) - * @param {Number} m11 Component in column 1, row 1 position (index 3) - * @returns {mat2} out - */ -function set(out, m00, m01, m10, m11) { - out[0] = m00; - out[1] = m01; - out[2] = m10; - out[3] = m11; - return out; -} - -/** - * Transpose the values of a mat2 - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the source matrix - * @returns {mat2} out - */ -function transpose(out, a) { - // If we are transposing ourselves we can skip a few steps but have to cache - // some values - if (out === a) { - let a1 = a[1]; - out[1] = a[2]; - out[2] = a1; - } else { - out[0] = a[0]; - out[1] = a[2]; - out[2] = a[1]; - out[3] = a[3]; - } - - return out; -} - -/** - * Inverts a mat2 - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the source matrix - * @returns {mat2} out - */ -function invert(out, a) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - - // Calculate the determinant - let det = a0 * a3 - a2 * a1; - - if (!det) { - return null; - } - det = 1.0 / det; - - out[0] = a3 * det; - out[1] = -a1 * det; - out[2] = -a2 * det; - out[3] = a0 * det; - - return out; -} - -/** - * Calculates the adjugate of a mat2 - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the source matrix - * @returns {mat2} out - */ -function adjoint(out, a) { - // Caching this value is nessecary if out == a - let a0 = a[0]; - out[0] = a[3]; - out[1] = -a[1]; - out[2] = -a[2]; - out[3] = a0; - - return out; -} - -/** - * Calculates the determinant of a mat2 - * - * @param {mat2} a the source matrix - * @returns {Number} determinant of a - */ -function determinant(a) { - return a[0] * a[3] - a[2] * a[1]; -} - -/** - * Multiplies two mat2's - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the first operand - * @param {mat2} b the second operand - * @returns {mat2} out - */ -function multiply(out, a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - out[0] = a0 * b0 + a2 * b1; - out[1] = a1 * b0 + a3 * b1; - out[2] = a0 * b2 + a2 * b3; - out[3] = a1 * b2 + a3 * b3; - return out; -} - -/** - * Rotates a mat2 by the given angle - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2} out - */ -function rotate(out, a, rad) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - let s = Math.sin(rad); - let c = Math.cos(rad); - out[0] = a0 * c + a2 * s; - out[1] = a1 * c + a3 * s; - out[2] = a0 * -s + a2 * c; - out[3] = a1 * -s + a3 * c; - return out; -} - -/** - * Scales the mat2 by the dimensions in the given vec2 - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the matrix to rotate - * @param {vec2} v the vec2 to scale the matrix by - * @returns {mat2} out - **/ -function scale(out, a, v) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - let v0 = v[0], v1 = v[1]; - out[0] = a0 * v0; - out[1] = a1 * v0; - out[2] = a2 * v1; - out[3] = a3 * v1; - return out; -} - -/** - * Creates a matrix from a given angle - * This is equivalent to (but much faster than): - * - * mat2.identity(dest); - * mat2.rotate(dest, dest, rad); - * - * @param {mat2} out mat2 receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2} out - */ -function fromRotation(out, rad) { - let s = Math.sin(rad); - let c = Math.cos(rad); - out[0] = c; - out[1] = s; - out[2] = -s; - out[3] = c; - return out; -} - -/** - * Creates a matrix from a vector scaling - * This is equivalent to (but much faster than): - * - * mat2.identity(dest); - * mat2.scale(dest, dest, vec); - * - * @param {mat2} out mat2 receiving operation result - * @param {vec2} v Scaling vector - * @returns {mat2} out - */ -function fromScaling(out, v) { - out[0] = v[0]; - out[1] = 0; - out[2] = 0; - out[3] = v[1]; - return out; -} - -/** - * Returns a string representation of a mat2 - * - * @param {mat2} a matrix to represent as a string - * @returns {String} string representation of the matrix - */ -function str(a) { - return 'mat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')'; -} - -/** - * Returns Frobenius norm of a mat2 - * - * @param {mat2} a the matrix to calculate Frobenius norm of - * @returns {Number} Frobenius norm - */ -function frob(a) { - return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2))) -} - -/** - * Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix - * @param {mat2} L the lower triangular matrix - * @param {mat2} D the diagonal matrix - * @param {mat2} U the upper triangular matrix - * @param {mat2} a the input matrix to factorize - */ - -function LDU(L, D, U, a) { - L[2] = a[2]/a[0]; - U[0] = a[0]; - U[1] = a[1]; - U[3] = a[3] - L[2] * U[1]; - return [L, D, U]; -} - -/** - * Adds two mat2's - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the first operand - * @param {mat2} b the second operand - * @returns {mat2} out - */ -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - out[3] = a[3] + b[3]; - return out; -} - -/** - * Subtracts matrix b from matrix a - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the first operand - * @param {mat2} b the second operand - * @returns {mat2} out - */ -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - out[3] = a[3] - b[3]; - return out; -} - -/** - * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) - * - * @param {mat2} a The first matrix. - * @param {mat2} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. - */ -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; -} - -/** - * Returns whether or not the matrices have approximately the same elements in the same position. - * - * @param {mat2} a The first matrix. - * @param {mat2} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. - */ -function equals(a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - return (Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && - Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && - Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && - Math.abs(a3 - b3) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a3), Math.abs(b3))); -} - -/** - * Multiply each element of the matrix by a scalar. - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the matrix to scale - * @param {Number} b amount to scale the matrix's elements by - * @returns {mat2} out - */ -function multiplyScalar(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; - return out; -} - -/** - * Adds two mat2's after multiplying each element of the second operand by a scalar value. - * - * @param {mat2} out the receiving vector - * @param {mat2} a the first operand - * @param {mat2} b the second operand - * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat2} out - */ -function multiplyScalarAndAdd(out, a, b, scale) { - out[0] = a[0] + (b[0] * scale); - out[1] = a[1] + (b[1] * scale); - out[2] = a[2] + (b[2] * scale); - out[3] = a[3] + (b[3] * scale); - return out; -} - -/** - * Alias for {@link mat2.multiply} - * @function - */ -const mul = multiply; - -/** - * Alias for {@link mat2.subtract} - * @function - */ -const sub = subtract; - - -/***/ }), - -/***/ "./node_modules/gl-matrix/src/gl-matrix/mat2d.js": -/*!*******************************************************!*\ - !*** ./node_modules/gl-matrix/src/gl-matrix/mat2d.js ***! - \*******************************************************/ -/*! exports provided: create, clone, copy, identity, fromValues, set, invert, determinant, multiply, rotate, scale, translate, fromRotation, fromScaling, fromTranslation, str, frob, add, subtract, multiplyScalar, multiplyScalarAndAdd, exactEquals, equals, mul, sub */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return identity; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "invert", function() { return invert; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determinant", function() { return determinant; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotate", function() { return rotate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "translate", function() { return translate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotation", function() { return fromRotation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromScaling", function() { return fromScaling; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromTranslation", function() { return fromTranslation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "frob", function() { return frob; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subtract", function() { return subtract; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalar", function() { return multiplyScalar; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalarAndAdd", function() { return multiplyScalarAndAdd; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; }); -/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/src/gl-matrix/common.js"); - - -/** - * 2x3 Matrix - * @module mat2d - * - * @description - * A mat2d contains six elements defined as: - *
- * [a, c, tx,
- *  b, d, ty]
- * 
- * This is a short form for the 3x3 matrix: - *
- * [a, c, tx,
- *  b, d, ty,
- *  0, 0, 1]
- * 
- * The last row is ignored so the array is shorter and operations are faster. - */ - -/** - * Creates a new identity mat2d - * - * @returns {mat2d} a new 2x3 matrix - */ -function create() { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](6); - if(_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) { - out[1] = 0; - out[2] = 0; - out[4] = 0; - out[5] = 0; - } - out[0] = 1; - out[3] = 1; - return out; -} - -/** - * Creates a new mat2d initialized with values from an existing matrix - * - * @param {mat2d} a matrix to clone - * @returns {mat2d} a new 2x3 matrix - */ -function clone(a) { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](6); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - return out; -} - -/** - * Copy the values from one mat2d to another - * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the source matrix - * @returns {mat2d} out - */ -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - return out; -} - -/** - * Set a mat2d to the identity matrix - * - * @param {mat2d} out the receiving matrix - * @returns {mat2d} out - */ -function identity(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; - out[4] = 0; - out[5] = 0; - return out; -} - -/** - * Create a new mat2d with the given values - * - * @param {Number} a Component A (index 0) - * @param {Number} b Component B (index 1) - * @param {Number} c Component C (index 2) - * @param {Number} d Component D (index 3) - * @param {Number} tx Component TX (index 4) - * @param {Number} ty Component TY (index 5) - * @returns {mat2d} A new mat2d - */ -function fromValues(a, b, c, d, tx, ty) { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](6); - out[0] = a; - out[1] = b; - out[2] = c; - out[3] = d; - out[4] = tx; - out[5] = ty; - return out; -} - -/** - * Set the components of a mat2d to the given values - * - * @param {mat2d} out the receiving matrix - * @param {Number} a Component A (index 0) - * @param {Number} b Component B (index 1) - * @param {Number} c Component C (index 2) - * @param {Number} d Component D (index 3) - * @param {Number} tx Component TX (index 4) - * @param {Number} ty Component TY (index 5) - * @returns {mat2d} out - */ -function set(out, a, b, c, d, tx, ty) { - out[0] = a; - out[1] = b; - out[2] = c; - out[3] = d; - out[4] = tx; - out[5] = ty; - return out; -} - -/** - * Inverts a mat2d - * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the source matrix - * @returns {mat2d} out - */ -function invert(out, a) { - let aa = a[0], ab = a[1], ac = a[2], ad = a[3]; - let atx = a[4], aty = a[5]; - - let det = aa * ad - ab * ac; - if(!det){ - return null; - } - det = 1.0 / det; - - out[0] = ad * det; - out[1] = -ab * det; - out[2] = -ac * det; - out[3] = aa * det; - out[4] = (ac * aty - ad * atx) * det; - out[5] = (ab * atx - aa * aty) * det; - return out; -} - -/** - * Calculates the determinant of a mat2d - * - * @param {mat2d} a the source matrix - * @returns {Number} determinant of a - */ -function determinant(a) { - return a[0] * a[3] - a[1] * a[2]; -} - -/** - * Multiplies two mat2d's - * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the first operand - * @param {mat2d} b the second operand - * @returns {mat2d} out - */ -function multiply(out, a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5]; - out[0] = a0 * b0 + a2 * b1; - out[1] = a1 * b0 + a3 * b1; - out[2] = a0 * b2 + a2 * b3; - out[3] = a1 * b2 + a3 * b3; - out[4] = a0 * b4 + a2 * b5 + a4; - out[5] = a1 * b4 + a3 * b5 + a5; - return out; -} - -/** - * Rotates a mat2d by the given angle - * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2d} out - */ -function rotate(out, a, rad) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; - let s = Math.sin(rad); - let c = Math.cos(rad); - out[0] = a0 * c + a2 * s; - out[1] = a1 * c + a3 * s; - out[2] = a0 * -s + a2 * c; - out[3] = a1 * -s + a3 * c; - out[4] = a4; - out[5] = a5; - return out; -} - -/** - * Scales the mat2d by the dimensions in the given vec2 - * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the matrix to translate - * @param {vec2} v the vec2 to scale the matrix by - * @returns {mat2d} out - **/ -function scale(out, a, v) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; - let v0 = v[0], v1 = v[1]; - out[0] = a0 * v0; - out[1] = a1 * v0; - out[2] = a2 * v1; - out[3] = a3 * v1; - out[4] = a4; - out[5] = a5; - return out; -} - -/** - * Translates the mat2d by the dimensions in the given vec2 - * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the matrix to translate - * @param {vec2} v the vec2 to translate the matrix by - * @returns {mat2d} out - **/ -function translate(out, a, v) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; - let v0 = v[0], v1 = v[1]; - out[0] = a0; - out[1] = a1; - out[2] = a2; - out[3] = a3; - out[4] = a0 * v0 + a2 * v1 + a4; - out[5] = a1 * v0 + a3 * v1 + a5; - return out; -} - -/** - * Creates a matrix from a given angle - * This is equivalent to (but much faster than): - * - * mat2d.identity(dest); - * mat2d.rotate(dest, dest, rad); - * - * @param {mat2d} out mat2d receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2d} out - */ -function fromRotation(out, rad) { - let s = Math.sin(rad), c = Math.cos(rad); - out[0] = c; - out[1] = s; - out[2] = -s; - out[3] = c; - out[4] = 0; - out[5] = 0; - return out; -} - -/** - * Creates a matrix from a vector scaling - * This is equivalent to (but much faster than): - * - * mat2d.identity(dest); - * mat2d.scale(dest, dest, vec); - * - * @param {mat2d} out mat2d receiving operation result - * @param {vec2} v Scaling vector - * @returns {mat2d} out - */ -function fromScaling(out, v) { - out[0] = v[0]; - out[1] = 0; - out[2] = 0; - out[3] = v[1]; - out[4] = 0; - out[5] = 0; - return out; -} - -/** - * Creates a matrix from a vector translation - * This is equivalent to (but much faster than): - * - * mat2d.identity(dest); - * mat2d.translate(dest, dest, vec); - * - * @param {mat2d} out mat2d receiving operation result - * @param {vec2} v Translation vector - * @returns {mat2d} out - */ -function fromTranslation(out, v) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; - out[4] = v[0]; - out[5] = v[1]; - return out; -} - -/** - * Returns a string representation of a mat2d - * - * @param {mat2d} a matrix to represent as a string - * @returns {String} string representation of the matrix - */ -function str(a) { - return 'mat2d(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + - a[3] + ', ' + a[4] + ', ' + a[5] + ')'; -} - -/** - * Returns Frobenius norm of a mat2d - * - * @param {mat2d} a the matrix to calculate Frobenius norm of - * @returns {Number} Frobenius norm - */ -function frob(a) { - return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + 1)) -} - -/** - * Adds two mat2d's - * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the first operand - * @param {mat2d} b the second operand - * @returns {mat2d} out - */ -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - out[3] = a[3] + b[3]; - out[4] = a[4] + b[4]; - out[5] = a[5] + b[5]; - return out; -} - -/** - * Subtracts matrix b from matrix a - * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the first operand - * @param {mat2d} b the second operand - * @returns {mat2d} out - */ -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - out[3] = a[3] - b[3]; - out[4] = a[4] - b[4]; - out[5] = a[5] - b[5]; - return out; -} - -/** - * Multiply each element of the matrix by a scalar. - * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the matrix to scale - * @param {Number} b amount to scale the matrix's elements by - * @returns {mat2d} out - */ -function multiplyScalar(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; - out[4] = a[4] * b; - out[5] = a[5] * b; - return out; -} - -/** - * Adds two mat2d's after multiplying each element of the second operand by a scalar value. - * - * @param {mat2d} out the receiving vector - * @param {mat2d} a the first operand - * @param {mat2d} b the second operand - * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat2d} out - */ -function multiplyScalarAndAdd(out, a, b, scale) { - out[0] = a[0] + (b[0] * scale); - out[1] = a[1] + (b[1] * scale); - out[2] = a[2] + (b[2] * scale); - out[3] = a[3] + (b[3] * scale); - out[4] = a[4] + (b[4] * scale); - out[5] = a[5] + (b[5] * scale); - return out; -} - -/** - * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) - * - * @param {mat2d} a The first matrix. - * @param {mat2d} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. - */ -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5]; -} - -/** - * Returns whether or not the matrices have approximately the same elements in the same position. - * - * @param {mat2d} a The first matrix. - * @param {mat2d} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. - */ -function equals(a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5]; - return (Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && - Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && - Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && - Math.abs(a3 - b3) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a3), Math.abs(b3)) && - Math.abs(a4 - b4) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a4), Math.abs(b4)) && - Math.abs(a5 - b5) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a5), Math.abs(b5))); -} - -/** - * Alias for {@link mat2d.multiply} - * @function - */ -const mul = multiply; - -/** - * Alias for {@link mat2d.subtract} - * @function - */ -const sub = subtract; - - -/***/ }), - -/***/ "./node_modules/gl-matrix/src/gl-matrix/mat3.js": -/*!******************************************************!*\ - !*** ./node_modules/gl-matrix/src/gl-matrix/mat3.js ***! - \******************************************************/ -/*! exports provided: create, fromMat4, clone, copy, fromValues, set, identity, transpose, invert, adjoint, determinant, multiply, translate, rotate, scale, fromTranslation, fromRotation, fromScaling, fromMat2d, fromQuat, normalFromMat4, projection, str, frob, add, subtract, multiplyScalar, multiplyScalarAndAdd, exactEquals, equals, mul, sub */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromMat4", function() { return fromMat4; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return identity; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transpose", function() { return transpose; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "invert", function() { return invert; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "adjoint", function() { return adjoint; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determinant", function() { return determinant; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "translate", function() { return translate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotate", function() { return rotate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromTranslation", function() { return fromTranslation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotation", function() { return fromRotation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromScaling", function() { return fromScaling; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromMat2d", function() { return fromMat2d; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromQuat", function() { return fromQuat; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalFromMat4", function() { return normalFromMat4; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "projection", function() { return projection; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "frob", function() { return frob; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subtract", function() { return subtract; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalar", function() { return multiplyScalar; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalarAndAdd", function() { return multiplyScalarAndAdd; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; }); -/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/src/gl-matrix/common.js"); - - -/** - * 3x3 Matrix - * @module mat3 - */ - -/** - * Creates a new identity mat3 - * - * @returns {mat3} a new 3x3 matrix - */ -function create() { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](9); - if(_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) { - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[5] = 0; - out[6] = 0; - out[7] = 0; - } - out[0] = 1; - out[4] = 1; - out[8] = 1; - return out; -} - -/** - * Copies the upper-left 3x3 values into the given mat3. - * - * @param {mat3} out the receiving 3x3 matrix - * @param {mat4} a the source 4x4 matrix - * @returns {mat3} out - */ -function fromMat4(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[4]; - out[4] = a[5]; - out[5] = a[6]; - out[6] = a[8]; - out[7] = a[9]; - out[8] = a[10]; - return out; -} - -/** - * Creates a new mat3 initialized with values from an existing matrix - * - * @param {mat3} a matrix to clone - * @returns {mat3} a new 3x3 matrix - */ -function clone(a) { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](9); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - return out; -} - -/** - * Copy the values from one mat3 to another - * - * @param {mat3} out the receiving matrix - * @param {mat3} a the source matrix - * @returns {mat3} out - */ -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - return out; -} - -/** - * Create a new mat3 with the given values - * - * @param {Number} m00 Component in column 0, row 0 position (index 0) - * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m02 Component in column 0, row 2 position (index 2) - * @param {Number} m10 Component in column 1, row 0 position (index 3) - * @param {Number} m11 Component in column 1, row 1 position (index 4) - * @param {Number} m12 Component in column 1, row 2 position (index 5) - * @param {Number} m20 Component in column 2, row 0 position (index 6) - * @param {Number} m21 Component in column 2, row 1 position (index 7) - * @param {Number} m22 Component in column 2, row 2 position (index 8) - * @returns {mat3} A new mat3 - */ -function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](9); - out[0] = m00; - out[1] = m01; - out[2] = m02; - out[3] = m10; - out[4] = m11; - out[5] = m12; - out[6] = m20; - out[7] = m21; - out[8] = m22; - return out; -} - -/** - * Set the components of a mat3 to the given values - * - * @param {mat3} out the receiving matrix - * @param {Number} m00 Component in column 0, row 0 position (index 0) - * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m02 Component in column 0, row 2 position (index 2) - * @param {Number} m10 Component in column 1, row 0 position (index 3) - * @param {Number} m11 Component in column 1, row 1 position (index 4) - * @param {Number} m12 Component in column 1, row 2 position (index 5) - * @param {Number} m20 Component in column 2, row 0 position (index 6) - * @param {Number} m21 Component in column 2, row 1 position (index 7) - * @param {Number} m22 Component in column 2, row 2 position (index 8) - * @returns {mat3} out - */ -function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { - out[0] = m00; - out[1] = m01; - out[2] = m02; - out[3] = m10; - out[4] = m11; - out[5] = m12; - out[6] = m20; - out[7] = m21; - out[8] = m22; - return out; -} - -/** - * Set a mat3 to the identity matrix - * - * @param {mat3} out the receiving matrix - * @returns {mat3} out - */ -function identity(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 1; - out[5] = 0; - out[6] = 0; - out[7] = 0; - out[8] = 1; - return out; -} - -/** - * Transpose the values of a mat3 - * - * @param {mat3} out the receiving matrix - * @param {mat3} a the source matrix - * @returns {mat3} out - */ -function transpose(out, a) { - // If we are transposing ourselves we can skip a few steps but have to cache some values - if (out === a) { - let a01 = a[1], a02 = a[2], a12 = a[5]; - out[1] = a[3]; - out[2] = a[6]; - out[3] = a01; - out[5] = a[7]; - out[6] = a02; - out[7] = a12; - } else { - out[0] = a[0]; - out[1] = a[3]; - out[2] = a[6]; - out[3] = a[1]; - out[4] = a[4]; - out[5] = a[7]; - out[6] = a[2]; - out[7] = a[5]; - out[8] = a[8]; - } - - return out; -} - -/** - * Inverts a mat3 - * - * @param {mat3} out the receiving matrix - * @param {mat3} a the source matrix - * @returns {mat3} out - */ -function invert(out, a) { - let a00 = a[0], a01 = a[1], a02 = a[2]; - let a10 = a[3], a11 = a[4], a12 = a[5]; - let a20 = a[6], a21 = a[7], a22 = a[8]; - - let b01 = a22 * a11 - a12 * a21; - let b11 = -a22 * a10 + a12 * a20; - let b21 = a21 * a10 - a11 * a20; - - // Calculate the determinant - let det = a00 * b01 + a01 * b11 + a02 * b21; - - if (!det) { - return null; - } - det = 1.0 / det; - - out[0] = b01 * det; - out[1] = (-a22 * a01 + a02 * a21) * det; - out[2] = (a12 * a01 - a02 * a11) * det; - out[3] = b11 * det; - out[4] = (a22 * a00 - a02 * a20) * det; - out[5] = (-a12 * a00 + a02 * a10) * det; - out[6] = b21 * det; - out[7] = (-a21 * a00 + a01 * a20) * det; - out[8] = (a11 * a00 - a01 * a10) * det; - return out; -} - -/** - * Calculates the adjugate of a mat3 - * - * @param {mat3} out the receiving matrix - * @param {mat3} a the source matrix - * @returns {mat3} out - */ -function adjoint(out, a) { - let a00 = a[0], a01 = a[1], a02 = a[2]; - let a10 = a[3], a11 = a[4], a12 = a[5]; - let a20 = a[6], a21 = a[7], a22 = a[8]; - - out[0] = (a11 * a22 - a12 * a21); - out[1] = (a02 * a21 - a01 * a22); - out[2] = (a01 * a12 - a02 * a11); - out[3] = (a12 * a20 - a10 * a22); - out[4] = (a00 * a22 - a02 * a20); - out[5] = (a02 * a10 - a00 * a12); - out[6] = (a10 * a21 - a11 * a20); - out[7] = (a01 * a20 - a00 * a21); - out[8] = (a00 * a11 - a01 * a10); - return out; -} - -/** - * Calculates the determinant of a mat3 - * - * @param {mat3} a the source matrix - * @returns {Number} determinant of a - */ -function determinant(a) { - let a00 = a[0], a01 = a[1], a02 = a[2]; - let a10 = a[3], a11 = a[4], a12 = a[5]; - let a20 = a[6], a21 = a[7], a22 = a[8]; - - return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); -} - -/** - * Multiplies two mat3's - * - * @param {mat3} out the receiving matrix - * @param {mat3} a the first operand - * @param {mat3} b the second operand - * @returns {mat3} out - */ -function multiply(out, a, b) { - let a00 = a[0], a01 = a[1], a02 = a[2]; - let a10 = a[3], a11 = a[4], a12 = a[5]; - let a20 = a[6], a21 = a[7], a22 = a[8]; - - let b00 = b[0], b01 = b[1], b02 = b[2]; - let b10 = b[3], b11 = b[4], b12 = b[5]; - let b20 = b[6], b21 = b[7], b22 = b[8]; - - out[0] = b00 * a00 + b01 * a10 + b02 * a20; - out[1] = b00 * a01 + b01 * a11 + b02 * a21; - out[2] = b00 * a02 + b01 * a12 + b02 * a22; - - out[3] = b10 * a00 + b11 * a10 + b12 * a20; - out[4] = b10 * a01 + b11 * a11 + b12 * a21; - out[5] = b10 * a02 + b11 * a12 + b12 * a22; - - out[6] = b20 * a00 + b21 * a10 + b22 * a20; - out[7] = b20 * a01 + b21 * a11 + b22 * a21; - out[8] = b20 * a02 + b21 * a12 + b22 * a22; - return out; -} - -/** - * Translate a mat3 by the given vector - * - * @param {mat3} out the receiving matrix - * @param {mat3} a the matrix to translate - * @param {vec2} v vector to translate by - * @returns {mat3} out - */ -function translate(out, a, v) { - let a00 = a[0], a01 = a[1], a02 = a[2], - a10 = a[3], a11 = a[4], a12 = a[5], - a20 = a[6], a21 = a[7], a22 = a[8], - x = v[0], y = v[1]; - - out[0] = a00; - out[1] = a01; - out[2] = a02; - - out[3] = a10; - out[4] = a11; - out[5] = a12; - - out[6] = x * a00 + y * a10 + a20; - out[7] = x * a01 + y * a11 + a21; - out[8] = x * a02 + y * a12 + a22; - return out; -} - -/** - * Rotates a mat3 by the given angle - * - * @param {mat3} out the receiving matrix - * @param {mat3} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat3} out - */ -function rotate(out, a, rad) { - let a00 = a[0], a01 = a[1], a02 = a[2], - a10 = a[3], a11 = a[4], a12 = a[5], - a20 = a[6], a21 = a[7], a22 = a[8], - - s = Math.sin(rad), - c = Math.cos(rad); - - out[0] = c * a00 + s * a10; - out[1] = c * a01 + s * a11; - out[2] = c * a02 + s * a12; - - out[3] = c * a10 - s * a00; - out[4] = c * a11 - s * a01; - out[5] = c * a12 - s * a02; - - out[6] = a20; - out[7] = a21; - out[8] = a22; - return out; -}; - -/** - * Scales the mat3 by the dimensions in the given vec2 - * - * @param {mat3} out the receiving matrix - * @param {mat3} a the matrix to rotate - * @param {vec2} v the vec2 to scale the matrix by - * @returns {mat3} out - **/ -function scale(out, a, v) { - let x = v[0], y = v[1]; - - out[0] = x * a[0]; - out[1] = x * a[1]; - out[2] = x * a[2]; - - out[3] = y * a[3]; - out[4] = y * a[4]; - out[5] = y * a[5]; - - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - return out; -} - -/** - * Creates a matrix from a vector translation - * This is equivalent to (but much faster than): - * - * mat3.identity(dest); - * mat3.translate(dest, dest, vec); - * - * @param {mat3} out mat3 receiving operation result - * @param {vec2} v Translation vector - * @returns {mat3} out - */ -function fromTranslation(out, v) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 1; - out[5] = 0; - out[6] = v[0]; - out[7] = v[1]; - out[8] = 1; - return out; -} - -/** - * Creates a matrix from a given angle - * This is equivalent to (but much faster than): - * - * mat3.identity(dest); - * mat3.rotate(dest, dest, rad); - * - * @param {mat3} out mat3 receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat3} out - */ -function fromRotation(out, rad) { - let s = Math.sin(rad), c = Math.cos(rad); - - out[0] = c; - out[1] = s; - out[2] = 0; - - out[3] = -s; - out[4] = c; - out[5] = 0; - - out[6] = 0; - out[7] = 0; - out[8] = 1; - return out; -} - -/** - * Creates a matrix from a vector scaling - * This is equivalent to (but much faster than): - * - * mat3.identity(dest); - * mat3.scale(dest, dest, vec); - * - * @param {mat3} out mat3 receiving operation result - * @param {vec2} v Scaling vector - * @returns {mat3} out - */ -function fromScaling(out, v) { - out[0] = v[0]; - out[1] = 0; - out[2] = 0; - - out[3] = 0; - out[4] = v[1]; - out[5] = 0; - - out[6] = 0; - out[7] = 0; - out[8] = 1; - return out; -} - -/** - * Copies the values from a mat2d into a mat3 - * - * @param {mat3} out the receiving matrix - * @param {mat2d} a the matrix to copy - * @returns {mat3} out - **/ -function fromMat2d(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = 0; - - out[3] = a[2]; - out[4] = a[3]; - out[5] = 0; - - out[6] = a[4]; - out[7] = a[5]; - out[8] = 1; - return out; -} - -/** -* Calculates a 3x3 matrix from the given quaternion -* -* @param {mat3} out mat3 receiving operation result -* @param {quat} q Quaternion to create matrix from -* -* @returns {mat3} out -*/ -function fromQuat(out, q) { - let x = q[0], y = q[1], z = q[2], w = q[3]; - let x2 = x + x; - let y2 = y + y; - let z2 = z + z; - - let xx = x * x2; - let yx = y * x2; - let yy = y * y2; - let zx = z * x2; - let zy = z * y2; - let zz = z * z2; - let wx = w * x2; - let wy = w * y2; - let wz = w * z2; - - out[0] = 1 - yy - zz; - out[3] = yx - wz; - out[6] = zx + wy; - - out[1] = yx + wz; - out[4] = 1 - xx - zz; - out[7] = zy - wx; - - out[2] = zx - wy; - out[5] = zy + wx; - out[8] = 1 - xx - yy; - - return out; -} - -/** -* Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix -* -* @param {mat3} out mat3 receiving operation result -* @param {mat4} a Mat4 to derive the normal matrix from -* -* @returns {mat3} out -*/ -function normalFromMat4(out, a) { - let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - - let b00 = a00 * a11 - a01 * a10; - let b01 = a00 * a12 - a02 * a10; - let b02 = a00 * a13 - a03 * a10; - let b03 = a01 * a12 - a02 * a11; - let b04 = a01 * a13 - a03 * a11; - let b05 = a02 * a13 - a03 * a12; - let b06 = a20 * a31 - a21 * a30; - let b07 = a20 * a32 - a22 * a30; - let b08 = a20 * a33 - a23 * a30; - let b09 = a21 * a32 - a22 * a31; - let b10 = a21 * a33 - a23 * a31; - let b11 = a22 * a33 - a23 * a32; - - // Calculate the determinant - let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - - if (!det) { - return null; - } - det = 1.0 / det; - - out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - - out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - - out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - - return out; -} - -/** - * Generates a 2D projection matrix with the given bounds - * - * @param {mat3} out mat3 frustum matrix will be written into - * @param {number} width Width of your gl context - * @param {number} height Height of gl context - * @returns {mat3} out - */ -function projection(out, width, height) { - out[0] = 2 / width; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = -2 / height; - out[5] = 0; - out[6] = -1; - out[7] = 1; - out[8] = 1; - return out; -} - -/** - * Returns a string representation of a mat3 - * - * @param {mat3} a matrix to represent as a string - * @returns {String} string representation of the matrix - */ -function str(a) { - return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + - a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + - a[6] + ', ' + a[7] + ', ' + a[8] + ')'; -} - -/** - * Returns Frobenius norm of a mat3 - * - * @param {mat3} a the matrix to calculate Frobenius norm of - * @returns {Number} Frobenius norm - */ -function frob(a) { - return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2))) -} - -/** - * Adds two mat3's - * - * @param {mat3} out the receiving matrix - * @param {mat3} a the first operand - * @param {mat3} b the second operand - * @returns {mat3} out - */ -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - out[3] = a[3] + b[3]; - out[4] = a[4] + b[4]; - out[5] = a[5] + b[5]; - out[6] = a[6] + b[6]; - out[7] = a[7] + b[7]; - out[8] = a[8] + b[8]; - return out; -} - -/** - * Subtracts matrix b from matrix a - * - * @param {mat3} out the receiving matrix - * @param {mat3} a the first operand - * @param {mat3} b the second operand - * @returns {mat3} out - */ -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - out[3] = a[3] - b[3]; - out[4] = a[4] - b[4]; - out[5] = a[5] - b[5]; - out[6] = a[6] - b[6]; - out[7] = a[7] - b[7]; - out[8] = a[8] - b[8]; - return out; -} - - - -/** - * Multiply each element of the matrix by a scalar. - * - * @param {mat3} out the receiving matrix - * @param {mat3} a the matrix to scale - * @param {Number} b amount to scale the matrix's elements by - * @returns {mat3} out - */ -function multiplyScalar(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; - out[4] = a[4] * b; - out[5] = a[5] * b; - out[6] = a[6] * b; - out[7] = a[7] * b; - out[8] = a[8] * b; - return out; -} - -/** - * Adds two mat3's after multiplying each element of the second operand by a scalar value. - * - * @param {mat3} out the receiving vector - * @param {mat3} a the first operand - * @param {mat3} b the second operand - * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat3} out - */ -function multiplyScalarAndAdd(out, a, b, scale) { - out[0] = a[0] + (b[0] * scale); - out[1] = a[1] + (b[1] * scale); - out[2] = a[2] + (b[2] * scale); - out[3] = a[3] + (b[3] * scale); - out[4] = a[4] + (b[4] * scale); - out[5] = a[5] + (b[5] * scale); - out[6] = a[6] + (b[6] * scale); - out[7] = a[7] + (b[7] * scale); - out[8] = a[8] + (b[8] * scale); - return out; -} - -/** - * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) - * - * @param {mat3} a The first matrix. - * @param {mat3} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. - */ -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && - a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && - a[6] === b[6] && a[7] === b[7] && a[8] === b[8]; -} - -/** - * Returns whether or not the matrices have approximately the same elements in the same position. - * - * @param {mat3} a The first matrix. - * @param {mat3} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. - */ -function equals(a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7], a8 = a[8]; - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8]; - return (Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && - Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && - Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && - Math.abs(a3 - b3) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a3), Math.abs(b3)) && - Math.abs(a4 - b4) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a4), Math.abs(b4)) && - Math.abs(a5 - b5) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a5), Math.abs(b5)) && - Math.abs(a6 - b6) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a6), Math.abs(b6)) && - Math.abs(a7 - b7) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a7), Math.abs(b7)) && - Math.abs(a8 - b8) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a8), Math.abs(b8))); -} - -/** - * Alias for {@link mat3.multiply} - * @function - */ -const mul = multiply; - -/** - * Alias for {@link mat3.subtract} - * @function - */ -const sub = subtract; - - -/***/ }), - -/***/ "./node_modules/gl-matrix/src/gl-matrix/mat4.js": -/*!******************************************************!*\ - !*** ./node_modules/gl-matrix/src/gl-matrix/mat4.js ***! - \******************************************************/ -/*! exports provided: create, clone, copy, fromValues, set, identity, transpose, invert, adjoint, determinant, multiply, translate, scale, rotate, rotateX, rotateY, rotateZ, fromTranslation, fromScaling, fromRotation, fromXRotation, fromYRotation, fromZRotation, fromRotationTranslation, fromQuat2, getTranslation, getScaling, getRotation, fromRotationTranslationScale, fromRotationTranslationScaleOrigin, fromQuat, frustum, perspective, perspectiveFromFieldOfView, ortho, lookAt, targetTo, str, frob, add, subtract, multiplyScalar, multiplyScalarAndAdd, exactEquals, equals, mul, sub */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return identity; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transpose", function() { return transpose; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "invert", function() { return invert; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "adjoint", function() { return adjoint; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determinant", function() { return determinant; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "translate", function() { return translate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotate", function() { return rotate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateX", function() { return rotateX; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateY", function() { return rotateY; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateZ", function() { return rotateZ; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromTranslation", function() { return fromTranslation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromScaling", function() { return fromScaling; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotation", function() { return fromRotation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromXRotation", function() { return fromXRotation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromYRotation", function() { return fromYRotation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromZRotation", function() { return fromZRotation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotationTranslation", function() { return fromRotationTranslation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromQuat2", function() { return fromQuat2; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTranslation", function() { return getTranslation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getScaling", function() { return getScaling; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getRotation", function() { return getRotation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotationTranslationScale", function() { return fromRotationTranslationScale; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotationTranslationScaleOrigin", function() { return fromRotationTranslationScaleOrigin; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromQuat", function() { return fromQuat; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "frustum", function() { return frustum; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "perspective", function() { return perspective; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "perspectiveFromFieldOfView", function() { return perspectiveFromFieldOfView; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ortho", function() { return ortho; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lookAt", function() { return lookAt; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "targetTo", function() { return targetTo; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "frob", function() { return frob; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subtract", function() { return subtract; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalar", function() { return multiplyScalar; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalarAndAdd", function() { return multiplyScalarAndAdd; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; }); -/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/src/gl-matrix/common.js"); - - -/** - * 4x4 Matrix
Format: column-major, when typed out it looks like row-major
The matrices are being post multiplied. - * @module mat4 - */ - -/** - * Creates a new identity mat4 - * - * @returns {mat4} a new 4x4 matrix - */ -function create() { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](16); - if(_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) { - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - } - out[0] = 1; - out[5] = 1; - out[10] = 1; - out[15] = 1; - return out; -} - -/** - * Creates a new mat4 initialized with values from an existing matrix - * - * @param {mat4} a matrix to clone - * @returns {mat4} a new 4x4 matrix - */ -function clone(a) { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](16); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - return out; -} - -/** - * Copy the values from one mat4 to another - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the source matrix - * @returns {mat4} out - */ -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - return out; -} - -/** - * Create a new mat4 with the given values - * - * @param {Number} m00 Component in column 0, row 0 position (index 0) - * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m02 Component in column 0, row 2 position (index 2) - * @param {Number} m03 Component in column 0, row 3 position (index 3) - * @param {Number} m10 Component in column 1, row 0 position (index 4) - * @param {Number} m11 Component in column 1, row 1 position (index 5) - * @param {Number} m12 Component in column 1, row 2 position (index 6) - * @param {Number} m13 Component in column 1, row 3 position (index 7) - * @param {Number} m20 Component in column 2, row 0 position (index 8) - * @param {Number} m21 Component in column 2, row 1 position (index 9) - * @param {Number} m22 Component in column 2, row 2 position (index 10) - * @param {Number} m23 Component in column 2, row 3 position (index 11) - * @param {Number} m30 Component in column 3, row 0 position (index 12) - * @param {Number} m31 Component in column 3, row 1 position (index 13) - * @param {Number} m32 Component in column 3, row 2 position (index 14) - * @param {Number} m33 Component in column 3, row 3 position (index 15) - * @returns {mat4} A new mat4 - */ -function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](16); - out[0] = m00; - out[1] = m01; - out[2] = m02; - out[3] = m03; - out[4] = m10; - out[5] = m11; - out[6] = m12; - out[7] = m13; - out[8] = m20; - out[9] = m21; - out[10] = m22; - out[11] = m23; - out[12] = m30; - out[13] = m31; - out[14] = m32; - out[15] = m33; - return out; -} - -/** - * Set the components of a mat4 to the given values - * - * @param {mat4} out the receiving matrix - * @param {Number} m00 Component in column 0, row 0 position (index 0) - * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m02 Component in column 0, row 2 position (index 2) - * @param {Number} m03 Component in column 0, row 3 position (index 3) - * @param {Number} m10 Component in column 1, row 0 position (index 4) - * @param {Number} m11 Component in column 1, row 1 position (index 5) - * @param {Number} m12 Component in column 1, row 2 position (index 6) - * @param {Number} m13 Component in column 1, row 3 position (index 7) - * @param {Number} m20 Component in column 2, row 0 position (index 8) - * @param {Number} m21 Component in column 2, row 1 position (index 9) - * @param {Number} m22 Component in column 2, row 2 position (index 10) - * @param {Number} m23 Component in column 2, row 3 position (index 11) - * @param {Number} m30 Component in column 3, row 0 position (index 12) - * @param {Number} m31 Component in column 3, row 1 position (index 13) - * @param {Number} m32 Component in column 3, row 2 position (index 14) - * @param {Number} m33 Component in column 3, row 3 position (index 15) - * @returns {mat4} out - */ -function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { - out[0] = m00; - out[1] = m01; - out[2] = m02; - out[3] = m03; - out[4] = m10; - out[5] = m11; - out[6] = m12; - out[7] = m13; - out[8] = m20; - out[9] = m21; - out[10] = m22; - out[11] = m23; - out[12] = m30; - out[13] = m31; - out[14] = m32; - out[15] = m33; - return out; -} - - -/** - * Set a mat4 to the identity matrix - * - * @param {mat4} out the receiving matrix - * @returns {mat4} out - */ -function identity(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - return out; -} - -/** - * Transpose the values of a mat4 - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the source matrix - * @returns {mat4} out - */ -function transpose(out, a) { - // If we are transposing ourselves we can skip a few steps but have to cache some values - if (out === a) { - let a01 = a[1], a02 = a[2], a03 = a[3]; - let a12 = a[6], a13 = a[7]; - let a23 = a[11]; - - out[1] = a[4]; - out[2] = a[8]; - out[3] = a[12]; - out[4] = a01; - out[6] = a[9]; - out[7] = a[13]; - out[8] = a02; - out[9] = a12; - out[11] = a[14]; - out[12] = a03; - out[13] = a13; - out[14] = a23; - } else { - out[0] = a[0]; - out[1] = a[4]; - out[2] = a[8]; - out[3] = a[12]; - out[4] = a[1]; - out[5] = a[5]; - out[6] = a[9]; - out[7] = a[13]; - out[8] = a[2]; - out[9] = a[6]; - out[10] = a[10]; - out[11] = a[14]; - out[12] = a[3]; - out[13] = a[7]; - out[14] = a[11]; - out[15] = a[15]; - } - - return out; -} - -/** - * Inverts a mat4 - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the source matrix - * @returns {mat4} out - */ -function invert(out, a) { - let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - - let b00 = a00 * a11 - a01 * a10; - let b01 = a00 * a12 - a02 * a10; - let b02 = a00 * a13 - a03 * a10; - let b03 = a01 * a12 - a02 * a11; - let b04 = a01 * a13 - a03 * a11; - let b05 = a02 * a13 - a03 * a12; - let b06 = a20 * a31 - a21 * a30; - let b07 = a20 * a32 - a22 * a30; - let b08 = a20 * a33 - a23 * a30; - let b09 = a21 * a32 - a22 * a31; - let b10 = a21 * a33 - a23 * a31; - let b11 = a22 * a33 - a23 * a32; - - // Calculate the determinant - let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - - if (!det) { - return null; - } - det = 1.0 / det; - - out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; - out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; - out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; - out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; - out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; - out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; - out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; - - return out; -} - -/** - * Calculates the adjugate of a mat4 - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the source matrix - * @returns {mat4} out - */ -function adjoint(out, a) { - let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - - out[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22)); - out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); - out[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12)); - out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); - out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); - out[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22)); - out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); - out[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12)); - out[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21)); - out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); - out[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11)); - out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); - out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); - out[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21)); - out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); - out[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); - return out; -} - -/** - * Calculates the determinant of a mat4 - * - * @param {mat4} a the source matrix - * @returns {Number} determinant of a - */ -function determinant(a) { - let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - - let b00 = a00 * a11 - a01 * a10; - let b01 = a00 * a12 - a02 * a10; - let b02 = a00 * a13 - a03 * a10; - let b03 = a01 * a12 - a02 * a11; - let b04 = a01 * a13 - a03 * a11; - let b05 = a02 * a13 - a03 * a12; - let b06 = a20 * a31 - a21 * a30; - let b07 = a20 * a32 - a22 * a30; - let b08 = a20 * a33 - a23 * a30; - let b09 = a21 * a32 - a22 * a31; - let b10 = a21 * a33 - a23 * a31; - let b11 = a22 * a33 - a23 * a32; - - // Calculate the determinant - return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; -} - -/** - * Multiplies two mat4s - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the first operand - * @param {mat4} b the second operand - * @returns {mat4} out - */ -function multiply(out, a, b) { - let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - - // Cache only the current line of the second matrix - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - out[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30; - out[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31; - out[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32; - out[3] = b0*a03 + b1*a13 + b2*a23 + b3*a33; - - b0 = b[4]; b1 = b[5]; b2 = b[6]; b3 = b[7]; - out[4] = b0*a00 + b1*a10 + b2*a20 + b3*a30; - out[5] = b0*a01 + b1*a11 + b2*a21 + b3*a31; - out[6] = b0*a02 + b1*a12 + b2*a22 + b3*a32; - out[7] = b0*a03 + b1*a13 + b2*a23 + b3*a33; - - b0 = b[8]; b1 = b[9]; b2 = b[10]; b3 = b[11]; - out[8] = b0*a00 + b1*a10 + b2*a20 + b3*a30; - out[9] = b0*a01 + b1*a11 + b2*a21 + b3*a31; - out[10] = b0*a02 + b1*a12 + b2*a22 + b3*a32; - out[11] = b0*a03 + b1*a13 + b2*a23 + b3*a33; - - b0 = b[12]; b1 = b[13]; b2 = b[14]; b3 = b[15]; - out[12] = b0*a00 + b1*a10 + b2*a20 + b3*a30; - out[13] = b0*a01 + b1*a11 + b2*a21 + b3*a31; - out[14] = b0*a02 + b1*a12 + b2*a22 + b3*a32; - out[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33; - return out; -} - -/** - * Translate a mat4 by the given vector - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the matrix to translate - * @param {vec3} v vector to translate by - * @returns {mat4} out - */ -function translate(out, a, v) { - let x = v[0], y = v[1], z = v[2]; - let a00, a01, a02, a03; - let a10, a11, a12, a13; - let a20, a21, a22, a23; - - if (a === out) { - out[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; - out[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; - out[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; - out[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; - } else { - a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3]; - a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7]; - a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11]; - - out[0] = a00; out[1] = a01; out[2] = a02; out[3] = a03; - out[4] = a10; out[5] = a11; out[6] = a12; out[7] = a13; - out[8] = a20; out[9] = a21; out[10] = a22; out[11] = a23; - - out[12] = a00 * x + a10 * y + a20 * z + a[12]; - out[13] = a01 * x + a11 * y + a21 * z + a[13]; - out[14] = a02 * x + a12 * y + a22 * z + a[14]; - out[15] = a03 * x + a13 * y + a23 * z + a[15]; - } - - return out; -} - -/** - * Scales the mat4 by the dimensions in the given vec3 not using vectorization - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the matrix to scale - * @param {vec3} v the vec3 to scale the matrix by - * @returns {mat4} out - **/ -function scale(out, a, v) { - let x = v[0], y = v[1], z = v[2]; - - out[0] = a[0] * x; - out[1] = a[1] * x; - out[2] = a[2] * x; - out[3] = a[3] * x; - out[4] = a[4] * y; - out[5] = a[5] * y; - out[6] = a[6] * y; - out[7] = a[7] * y; - out[8] = a[8] * z; - out[9] = a[9] * z; - out[10] = a[10] * z; - out[11] = a[11] * z; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - return out; -} - -/** - * Rotates a mat4 by the given angle around the given axis - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @param {vec3} axis the axis to rotate around - * @returns {mat4} out - */ -function rotate(out, a, rad, axis) { - let x = axis[0], y = axis[1], z = axis[2]; - let len = Math.sqrt(x * x + y * y + z * z); - let s, c, t; - let a00, a01, a02, a03; - let a10, a11, a12, a13; - let a20, a21, a22, a23; - let b00, b01, b02; - let b10, b11, b12; - let b20, b21, b22; - - if (len < _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]) { return null; } - - len = 1 / len; - x *= len; - y *= len; - z *= len; - - s = Math.sin(rad); - c = Math.cos(rad); - t = 1 - c; - - a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3]; - a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7]; - a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11]; - - // Construct the elements of the rotation matrix - b00 = x * x * t + c; b01 = y * x * t + z * s; b02 = z * x * t - y * s; - b10 = x * y * t - z * s; b11 = y * y * t + c; b12 = z * y * t + x * s; - b20 = x * z * t + y * s; b21 = y * z * t - x * s; b22 = z * z * t + c; - - // Perform rotation-specific matrix multiplication - out[0] = a00 * b00 + a10 * b01 + a20 * b02; - out[1] = a01 * b00 + a11 * b01 + a21 * b02; - out[2] = a02 * b00 + a12 * b01 + a22 * b02; - out[3] = a03 * b00 + a13 * b01 + a23 * b02; - out[4] = a00 * b10 + a10 * b11 + a20 * b12; - out[5] = a01 * b10 + a11 * b11 + a21 * b12; - out[6] = a02 * b10 + a12 * b11 + a22 * b12; - out[7] = a03 * b10 + a13 * b11 + a23 * b12; - out[8] = a00 * b20 + a10 * b21 + a20 * b22; - out[9] = a01 * b20 + a11 * b21 + a21 * b22; - out[10] = a02 * b20 + a12 * b21 + a22 * b22; - out[11] = a03 * b20 + a13 * b21 + a23 * b22; - - if (a !== out) { // If the source and destination differ, copy the unchanged last row - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - } - return out; -} - -/** - * Rotates a matrix by the given angle around the X axis - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out - */ -function rotateX(out, a, rad) { - let s = Math.sin(rad); - let c = Math.cos(rad); - let a10 = a[4]; - let a11 = a[5]; - let a12 = a[6]; - let a13 = a[7]; - let a20 = a[8]; - let a21 = a[9]; - let a22 = a[10]; - let a23 = a[11]; - - if (a !== out) { // If the source and destination differ, copy the unchanged rows - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - } - - // Perform axis-specific matrix multiplication - out[4] = a10 * c + a20 * s; - out[5] = a11 * c + a21 * s; - out[6] = a12 * c + a22 * s; - out[7] = a13 * c + a23 * s; - out[8] = a20 * c - a10 * s; - out[9] = a21 * c - a11 * s; - out[10] = a22 * c - a12 * s; - out[11] = a23 * c - a13 * s; - return out; -} - -/** - * Rotates a matrix by the given angle around the Y axis - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out - */ -function rotateY(out, a, rad) { - let s = Math.sin(rad); - let c = Math.cos(rad); - let a00 = a[0]; - let a01 = a[1]; - let a02 = a[2]; - let a03 = a[3]; - let a20 = a[8]; - let a21 = a[9]; - let a22 = a[10]; - let a23 = a[11]; - - if (a !== out) { // If the source and destination differ, copy the unchanged rows - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - } - - // Perform axis-specific matrix multiplication - out[0] = a00 * c - a20 * s; - out[1] = a01 * c - a21 * s; - out[2] = a02 * c - a22 * s; - out[3] = a03 * c - a23 * s; - out[8] = a00 * s + a20 * c; - out[9] = a01 * s + a21 * c; - out[10] = a02 * s + a22 * c; - out[11] = a03 * s + a23 * c; - return out; -} - -/** - * Rotates a matrix by the given angle around the Z axis - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out - */ -function rotateZ(out, a, rad) { - let s = Math.sin(rad); - let c = Math.cos(rad); - let a00 = a[0]; - let a01 = a[1]; - let a02 = a[2]; - let a03 = a[3]; - let a10 = a[4]; - let a11 = a[5]; - let a12 = a[6]; - let a13 = a[7]; - - if (a !== out) { // If the source and destination differ, copy the unchanged last row - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - } - - // Perform axis-specific matrix multiplication - out[0] = a00 * c + a10 * s; - out[1] = a01 * c + a11 * s; - out[2] = a02 * c + a12 * s; - out[3] = a03 * c + a13 * s; - out[4] = a10 * c - a00 * s; - out[5] = a11 * c - a01 * s; - out[6] = a12 * c - a02 * s; - out[7] = a13 * c - a03 * s; - return out; -} - -/** - * Creates a matrix from a vector translation - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.translate(dest, dest, vec); - * - * @param {mat4} out mat4 receiving operation result - * @param {vec3} v Translation vector - * @returns {mat4} out - */ -function fromTranslation(out, v) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = v[0]; - out[13] = v[1]; - out[14] = v[2]; - out[15] = 1; - return out; -} - -/** - * Creates a matrix from a vector scaling - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.scale(dest, dest, vec); - * - * @param {mat4} out mat4 receiving operation result - * @param {vec3} v Scaling vector - * @returns {mat4} out - */ -function fromScaling(out, v) { - out[0] = v[0]; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = v[1]; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = v[2]; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - return out; -} - -/** - * Creates a matrix from a given angle around a given axis - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.rotate(dest, dest, rad, axis); - * - * @param {mat4} out mat4 receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @param {vec3} axis the axis to rotate around - * @returns {mat4} out - */ -function fromRotation(out, rad, axis) { - let x = axis[0], y = axis[1], z = axis[2]; - let len = Math.sqrt(x * x + y * y + z * z); - let s, c, t; - - if (len < _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]) { return null; } - - len = 1 / len; - x *= len; - y *= len; - z *= len; - - s = Math.sin(rad); - c = Math.cos(rad); - t = 1 - c; - - // Perform rotation-specific matrix multiplication - out[0] = x * x * t + c; - out[1] = y * x * t + z * s; - out[2] = z * x * t - y * s; - out[3] = 0; - out[4] = x * y * t - z * s; - out[5] = y * y * t + c; - out[6] = z * y * t + x * s; - out[7] = 0; - out[8] = x * z * t + y * s; - out[9] = y * z * t - x * s; - out[10] = z * z * t + c; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - return out; -} - -/** - * Creates a matrix from the given angle around the X axis - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.rotateX(dest, dest, rad); - * - * @param {mat4} out mat4 receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out - */ -function fromXRotation(out, rad) { - let s = Math.sin(rad); - let c = Math.cos(rad); - - // Perform axis-specific matrix multiplication - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = c; - out[6] = s; - out[7] = 0; - out[8] = 0; - out[9] = -s; - out[10] = c; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - return out; -} - -/** - * Creates a matrix from the given angle around the Y axis - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.rotateY(dest, dest, rad); - * - * @param {mat4} out mat4 receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out - */ -function fromYRotation(out, rad) { - let s = Math.sin(rad); - let c = Math.cos(rad); - - // Perform axis-specific matrix multiplication - out[0] = c; - out[1] = 0; - out[2] = -s; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = s; - out[9] = 0; - out[10] = c; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - return out; -} - -/** - * Creates a matrix from the given angle around the Z axis - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.rotateZ(dest, dest, rad); - * - * @param {mat4} out mat4 receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out - */ -function fromZRotation(out, rad) { - let s = Math.sin(rad); - let c = Math.cos(rad); - - // Perform axis-specific matrix multiplication - out[0] = c; - out[1] = s; - out[2] = 0; - out[3] = 0; - out[4] = -s; - out[5] = c; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - return out; -} - -/** - * Creates a matrix from a quaternion rotation and vector translation - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.translate(dest, vec); - * let quatMat = mat4.create(); - * quat4.toMat4(quat, quatMat); - * mat4.multiply(dest, quatMat); - * - * @param {mat4} out mat4 receiving operation result - * @param {quat4} q Rotation quaternion - * @param {vec3} v Translation vector - * @returns {mat4} out - */ -function fromRotationTranslation(out, q, v) { - // Quaternion math - let x = q[0], y = q[1], z = q[2], w = q[3]; - let x2 = x + x; - let y2 = y + y; - let z2 = z + z; - - let xx = x * x2; - let xy = x * y2; - let xz = x * z2; - let yy = y * y2; - let yz = y * z2; - let zz = z * z2; - let wx = w * x2; - let wy = w * y2; - let wz = w * z2; - - out[0] = 1 - (yy + zz); - out[1] = xy + wz; - out[2] = xz - wy; - out[3] = 0; - out[4] = xy - wz; - out[5] = 1 - (xx + zz); - out[6] = yz + wx; - out[7] = 0; - out[8] = xz + wy; - out[9] = yz - wx; - out[10] = 1 - (xx + yy); - out[11] = 0; - out[12] = v[0]; - out[13] = v[1]; - out[14] = v[2]; - out[15] = 1; - - return out; -} - -/** - * Creates a new mat4 from a dual quat. - * - * @param {mat4} out Matrix - * @param {quat2} a Dual Quaternion - * @returns {mat4} mat4 receiving operation result - */ -function fromQuat2(out, a) { - let translation = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](3); - let bx = -a[0], by = -a[1], bz = -a[2], bw = a[3], - ax = a[4], ay = a[5], az = a[6], aw = a[7]; - - let magnitude = bx * bx + by * by + bz * bz + bw * bw; - //Only scale if it makes sense - if (magnitude > 0) { - translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude; - translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude; - translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude; - } else { - translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2; - translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2; - translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2; - } - fromRotationTranslation(out, a, translation); - return out; -} - -/** - * Returns the translation vector component of a transformation - * matrix. If a matrix is built with fromRotationTranslation, - * the returned vector will be the same as the translation vector - * originally supplied. - * @param {vec3} out Vector to receive translation component - * @param {mat4} mat Matrix to be decomposed (input) - * @return {vec3} out - */ -function getTranslation(out, mat) { - out[0] = mat[12]; - out[1] = mat[13]; - out[2] = mat[14]; - - return out; -} - -/** - * Returns the scaling factor component of a transformation - * matrix. If a matrix is built with fromRotationTranslationScale - * with a normalized Quaternion paramter, the returned vector will be - * the same as the scaling vector - * originally supplied. - * @param {vec3} out Vector to receive scaling factor component - * @param {mat4} mat Matrix to be decomposed (input) - * @return {vec3} out - */ -function getScaling(out, mat) { - let m11 = mat[0]; - let m12 = mat[1]; - let m13 = mat[2]; - let m21 = mat[4]; - let m22 = mat[5]; - let m23 = mat[6]; - let m31 = mat[8]; - let m32 = mat[9]; - let m33 = mat[10]; - - out[0] = Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13); - out[1] = Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23); - out[2] = Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33); - - return out; -} - -/** - * Returns a quaternion representing the rotational component - * of a transformation matrix. If a matrix is built with - * fromRotationTranslation, the returned quaternion will be the - * same as the quaternion originally supplied. - * @param {quat} out Quaternion to receive the rotation component - * @param {mat4} mat Matrix to be decomposed (input) - * @return {quat} out - */ -function getRotation(out, mat) { - // Algorithm taken from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm - let trace = mat[0] + mat[5] + mat[10]; - let S = 0; - - if (trace > 0) { - S = Math.sqrt(trace + 1.0) * 2; - out[3] = 0.25 * S; - out[0] = (mat[6] - mat[9]) / S; - out[1] = (mat[8] - mat[2]) / S; - out[2] = (mat[1] - mat[4]) / S; - } else if ((mat[0] > mat[5]) && (mat[0] > mat[10])) { - S = Math.sqrt(1.0 + mat[0] - mat[5] - mat[10]) * 2; - out[3] = (mat[6] - mat[9]) / S; - out[0] = 0.25 * S; - out[1] = (mat[1] + mat[4]) / S; - out[2] = (mat[8] + mat[2]) / S; - } else if (mat[5] > mat[10]) { - S = Math.sqrt(1.0 + mat[5] - mat[0] - mat[10]) * 2; - out[3] = (mat[8] - mat[2]) / S; - out[0] = (mat[1] + mat[4]) / S; - out[1] = 0.25 * S; - out[2] = (mat[6] + mat[9]) / S; - } else { - S = Math.sqrt(1.0 + mat[10] - mat[0] - mat[5]) * 2; - out[3] = (mat[1] - mat[4]) / S; - out[0] = (mat[8] + mat[2]) / S; - out[1] = (mat[6] + mat[9]) / S; - out[2] = 0.25 * S; - } - - return out; -} - -/** - * Creates a matrix from a quaternion rotation, vector translation and vector scale - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.translate(dest, vec); - * let quatMat = mat4.create(); - * quat4.toMat4(quat, quatMat); - * mat4.multiply(dest, quatMat); - * mat4.scale(dest, scale) - * - * @param {mat4} out mat4 receiving operation result - * @param {quat4} q Rotation quaternion - * @param {vec3} v Translation vector - * @param {vec3} s Scaling vector - * @returns {mat4} out - */ -function fromRotationTranslationScale(out, q, v, s) { - // Quaternion math - let x = q[0], y = q[1], z = q[2], w = q[3]; - let x2 = x + x; - let y2 = y + y; - let z2 = z + z; - - let xx = x * x2; - let xy = x * y2; - let xz = x * z2; - let yy = y * y2; - let yz = y * z2; - let zz = z * z2; - let wx = w * x2; - let wy = w * y2; - let wz = w * z2; - let sx = s[0]; - let sy = s[1]; - let sz = s[2]; - - out[0] = (1 - (yy + zz)) * sx; - out[1] = (xy + wz) * sx; - out[2] = (xz - wy) * sx; - out[3] = 0; - out[4] = (xy - wz) * sy; - out[5] = (1 - (xx + zz)) * sy; - out[6] = (yz + wx) * sy; - out[7] = 0; - out[8] = (xz + wy) * sz; - out[9] = (yz - wx) * sz; - out[10] = (1 - (xx + yy)) * sz; - out[11] = 0; - out[12] = v[0]; - out[13] = v[1]; - out[14] = v[2]; - out[15] = 1; - - return out; -} - -/** - * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.translate(dest, vec); - * mat4.translate(dest, origin); - * let quatMat = mat4.create(); - * quat4.toMat4(quat, quatMat); - * mat4.multiply(dest, quatMat); - * mat4.scale(dest, scale) - * mat4.translate(dest, negativeOrigin); - * - * @param {mat4} out mat4 receiving operation result - * @param {quat4} q Rotation quaternion - * @param {vec3} v Translation vector - * @param {vec3} s Scaling vector - * @param {vec3} o The origin vector around which to scale and rotate - * @returns {mat4} out - */ -function fromRotationTranslationScaleOrigin(out, q, v, s, o) { - // Quaternion math - let x = q[0], y = q[1], z = q[2], w = q[3]; - let x2 = x + x; - let y2 = y + y; - let z2 = z + z; - - let xx = x * x2; - let xy = x * y2; - let xz = x * z2; - let yy = y * y2; - let yz = y * z2; - let zz = z * z2; - let wx = w * x2; - let wy = w * y2; - let wz = w * z2; - - let sx = s[0]; - let sy = s[1]; - let sz = s[2]; - - let ox = o[0]; - let oy = o[1]; - let oz = o[2]; - - let out0 = (1 - (yy + zz)) * sx; - let out1 = (xy + wz) * sx; - let out2 = (xz - wy) * sx; - let out4 = (xy - wz) * sy; - let out5 = (1 - (xx + zz)) * sy; - let out6 = (yz + wx) * sy; - let out8 = (xz + wy) * sz; - let out9 = (yz - wx) * sz; - let out10 = (1 - (xx + yy)) * sz; - - out[0] = out0; - out[1] = out1; - out[2] = out2; - out[3] = 0; - out[4] = out4; - out[5] = out5; - out[6] = out6; - out[7] = 0; - out[8] = out8; - out[9] = out9; - out[10] = out10; - out[11] = 0; - out[12] = v[0] + ox - (out0 * ox + out4 * oy + out8 * oz); - out[13] = v[1] + oy - (out1 * ox + out5 * oy + out9 * oz); - out[14] = v[2] + oz - (out2 * ox + out6 * oy + out10 * oz); - out[15] = 1; - - return out; -} - -/** - * Calculates a 4x4 matrix from the given quaternion - * - * @param {mat4} out mat4 receiving operation result - * @param {quat} q Quaternion to create matrix from - * - * @returns {mat4} out - */ -function fromQuat(out, q) { - let x = q[0], y = q[1], z = q[2], w = q[3]; - let x2 = x + x; - let y2 = y + y; - let z2 = z + z; - - let xx = x * x2; - let yx = y * x2; - let yy = y * y2; - let zx = z * x2; - let zy = z * y2; - let zz = z * z2; - let wx = w * x2; - let wy = w * y2; - let wz = w * z2; - - out[0] = 1 - yy - zz; - out[1] = yx + wz; - out[2] = zx - wy; - out[3] = 0; - - out[4] = yx - wz; - out[5] = 1 - xx - zz; - out[6] = zy + wx; - out[7] = 0; - - out[8] = zx + wy; - out[9] = zy - wx; - out[10] = 1 - xx - yy; - out[11] = 0; - - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - - return out; -} - -/** - * Generates a frustum matrix with the given bounds - * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {Number} left Left bound of the frustum - * @param {Number} right Right bound of the frustum - * @param {Number} bottom Bottom bound of the frustum - * @param {Number} top Top bound of the frustum - * @param {Number} near Near bound of the frustum - * @param {Number} far Far bound of the frustum - * @returns {mat4} out - */ -function frustum(out, left, right, bottom, top, near, far) { - let rl = 1 / (right - left); - let tb = 1 / (top - bottom); - let nf = 1 / (near - far); - out[0] = (near * 2) * rl; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = (near * 2) * tb; - out[6] = 0; - out[7] = 0; - out[8] = (right + left) * rl; - out[9] = (top + bottom) * tb; - out[10] = (far + near) * nf; - out[11] = -1; - out[12] = 0; - out[13] = 0; - out[14] = (far * near * 2) * nf; - out[15] = 0; - return out; -} - -/** - * Generates a perspective projection matrix with the given bounds. - * Passing null/undefined/no value for far will generate infinite projection matrix. - * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {number} fovy Vertical field of view in radians - * @param {number} aspect Aspect ratio. typically viewport width/height - * @param {number} near Near bound of the frustum - * @param {number} far Far bound of the frustum, can be null or Infinity - * @returns {mat4} out - */ -function perspective(out, fovy, aspect, near, far) { - let f = 1.0 / Math.tan(fovy / 2), nf; - out[0] = f / aspect; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = f; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[11] = -1; - out[12] = 0; - out[13] = 0; - out[15] = 0; - if (far != null && far !== Infinity) { - nf = 1 / (near - far); - out[10] = (far + near) * nf; - out[14] = (2 * far * near) * nf; - } else { - out[10] = -1; - out[14] = -2 * near; - } - return out; -} - -/** - * Generates a perspective projection matrix with the given field of view. - * This is primarily useful for generating projection matrices to be used - * with the still experiemental WebVR API. - * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees - * @param {number} near Near bound of the frustum - * @param {number} far Far bound of the frustum - * @returns {mat4} out - */ -function perspectiveFromFieldOfView(out, fov, near, far) { - let upTan = Math.tan(fov.upDegrees * Math.PI/180.0); - let downTan = Math.tan(fov.downDegrees * Math.PI/180.0); - let leftTan = Math.tan(fov.leftDegrees * Math.PI/180.0); - let rightTan = Math.tan(fov.rightDegrees * Math.PI/180.0); - let xScale = 2.0 / (leftTan + rightTan); - let yScale = 2.0 / (upTan + downTan); - - out[0] = xScale; - out[1] = 0.0; - out[2] = 0.0; - out[3] = 0.0; - out[4] = 0.0; - out[5] = yScale; - out[6] = 0.0; - out[7] = 0.0; - out[8] = -((leftTan - rightTan) * xScale * 0.5); - out[9] = ((upTan - downTan) * yScale * 0.5); - out[10] = far / (near - far); - out[11] = -1.0; - out[12] = 0.0; - out[13] = 0.0; - out[14] = (far * near) / (near - far); - out[15] = 0.0; - return out; -} - -/** - * Generates a orthogonal projection matrix with the given bounds - * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {number} left Left bound of the frustum - * @param {number} right Right bound of the frustum - * @param {number} bottom Bottom bound of the frustum - * @param {number} top Top bound of the frustum - * @param {number} near Near bound of the frustum - * @param {number} far Far bound of the frustum - * @returns {mat4} out - */ -function ortho(out, left, right, bottom, top, near, far) { - let lr = 1 / (left - right); - let bt = 1 / (bottom - top); - let nf = 1 / (near - far); - out[0] = -2 * lr; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = -2 * bt; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 2 * nf; - out[11] = 0; - out[12] = (left + right) * lr; - out[13] = (top + bottom) * bt; - out[14] = (far + near) * nf; - out[15] = 1; - return out; -} - -/** - * Generates a look-at matrix with the given eye position, focal point, and up axis. - * If you want a matrix that actually makes an object look at another object, you should use targetTo instead. - * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {vec3} eye Position of the viewer - * @param {vec3} center Point the viewer is looking at - * @param {vec3} up vec3 pointing up - * @returns {mat4} out - */ -function lookAt(out, eye, center, up) { - let x0, x1, x2, y0, y1, y2, z0, z1, z2, len; - let eyex = eye[0]; - let eyey = eye[1]; - let eyez = eye[2]; - let upx = up[0]; - let upy = up[1]; - let upz = up[2]; - let centerx = center[0]; - let centery = center[1]; - let centerz = center[2]; - - if (Math.abs(eyex - centerx) < _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] && - Math.abs(eyey - centery) < _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] && - Math.abs(eyez - centerz) < _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]) { - return identity(out); - } - - z0 = eyex - centerx; - z1 = eyey - centery; - z2 = eyez - centerz; - - len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); - z0 *= len; - z1 *= len; - z2 *= len; - - x0 = upy * z2 - upz * z1; - x1 = upz * z0 - upx * z2; - x2 = upx * z1 - upy * z0; - len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); - if (!len) { - x0 = 0; - x1 = 0; - x2 = 0; - } else { - len = 1 / len; - x0 *= len; - x1 *= len; - x2 *= len; - } - - y0 = z1 * x2 - z2 * x1; - y1 = z2 * x0 - z0 * x2; - y2 = z0 * x1 - z1 * x0; - - len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); - if (!len) { - y0 = 0; - y1 = 0; - y2 = 0; - } else { - len = 1 / len; - y0 *= len; - y1 *= len; - y2 *= len; - } - - out[0] = x0; - out[1] = y0; - out[2] = z0; - out[3] = 0; - out[4] = x1; - out[5] = y1; - out[6] = z1; - out[7] = 0; - out[8] = x2; - out[9] = y2; - out[10] = z2; - out[11] = 0; - out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); - out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); - out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); - out[15] = 1; - - return out; -} - -/** - * Generates a matrix that makes something look at something else. - * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {vec3} eye Position of the viewer - * @param {vec3} center Point the viewer is looking at - * @param {vec3} up vec3 pointing up - * @returns {mat4} out - */ -function targetTo(out, eye, target, up) { - let eyex = eye[0], - eyey = eye[1], - eyez = eye[2], - upx = up[0], - upy = up[1], - upz = up[2]; - - let z0 = eyex - target[0], - z1 = eyey - target[1], - z2 = eyez - target[2]; - - let len = z0*z0 + z1*z1 + z2*z2; - if (len > 0) { - len = 1 / Math.sqrt(len); - z0 *= len; - z1 *= len; - z2 *= len; - } - - let x0 = upy * z2 - upz * z1, - x1 = upz * z0 - upx * z2, - x2 = upx * z1 - upy * z0; - - len = x0*x0 + x1*x1 + x2*x2; - if (len > 0) { - len = 1 / Math.sqrt(len); - x0 *= len; - x1 *= len; - x2 *= len; - } - - out[0] = x0; - out[1] = x1; - out[2] = x2; - out[3] = 0; - out[4] = z1 * x2 - z2 * x1; - out[5] = z2 * x0 - z0 * x2; - out[6] = z0 * x1 - z1 * x0; - out[7] = 0; - out[8] = z0; - out[9] = z1; - out[10] = z2; - out[11] = 0; - out[12] = eyex; - out[13] = eyey; - out[14] = eyez; - out[15] = 1; - return out; -}; - -/** - * Returns a string representation of a mat4 - * - * @param {mat4} a matrix to represent as a string - * @returns {String} string representation of the matrix - */ -function str(a) { - return 'mat4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + - a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + - a[8] + ', ' + a[9] + ', ' + a[10] + ', ' + a[11] + ', ' + - a[12] + ', ' + a[13] + ', ' + a[14] + ', ' + a[15] + ')'; -} - -/** - * Returns Frobenius norm of a mat4 - * - * @param {mat4} a the matrix to calculate Frobenius norm of - * @returns {Number} Frobenius norm - */ -function frob(a) { - return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2) + Math.pow(a[9], 2) + Math.pow(a[10], 2) + Math.pow(a[11], 2) + Math.pow(a[12], 2) + Math.pow(a[13], 2) + Math.pow(a[14], 2) + Math.pow(a[15], 2) )) -} - -/** - * Adds two mat4's - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the first operand - * @param {mat4} b the second operand - * @returns {mat4} out - */ -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - out[3] = a[3] + b[3]; - out[4] = a[4] + b[4]; - out[5] = a[5] + b[5]; - out[6] = a[6] + b[6]; - out[7] = a[7] + b[7]; - out[8] = a[8] + b[8]; - out[9] = a[9] + b[9]; - out[10] = a[10] + b[10]; - out[11] = a[11] + b[11]; - out[12] = a[12] + b[12]; - out[13] = a[13] + b[13]; - out[14] = a[14] + b[14]; - out[15] = a[15] + b[15]; - return out; -} - -/** - * Subtracts matrix b from matrix a - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the first operand - * @param {mat4} b the second operand - * @returns {mat4} out - */ -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - out[3] = a[3] - b[3]; - out[4] = a[4] - b[4]; - out[5] = a[5] - b[5]; - out[6] = a[6] - b[6]; - out[7] = a[7] - b[7]; - out[8] = a[8] - b[8]; - out[9] = a[9] - b[9]; - out[10] = a[10] - b[10]; - out[11] = a[11] - b[11]; - out[12] = a[12] - b[12]; - out[13] = a[13] - b[13]; - out[14] = a[14] - b[14]; - out[15] = a[15] - b[15]; - return out; -} - -/** - * Multiply each element of the matrix by a scalar. - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the matrix to scale - * @param {Number} b amount to scale the matrix's elements by - * @returns {mat4} out - */ -function multiplyScalar(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; - out[4] = a[4] * b; - out[5] = a[5] * b; - out[6] = a[6] * b; - out[7] = a[7] * b; - out[8] = a[8] * b; - out[9] = a[9] * b; - out[10] = a[10] * b; - out[11] = a[11] * b; - out[12] = a[12] * b; - out[13] = a[13] * b; - out[14] = a[14] * b; - out[15] = a[15] * b; - return out; -} - -/** - * Adds two mat4's after multiplying each element of the second operand by a scalar value. - * - * @param {mat4} out the receiving vector - * @param {mat4} a the first operand - * @param {mat4} b the second operand - * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat4} out - */ -function multiplyScalarAndAdd(out, a, b, scale) { - out[0] = a[0] + (b[0] * scale); - out[1] = a[1] + (b[1] * scale); - out[2] = a[2] + (b[2] * scale); - out[3] = a[3] + (b[3] * scale); - out[4] = a[4] + (b[4] * scale); - out[5] = a[5] + (b[5] * scale); - out[6] = a[6] + (b[6] * scale); - out[7] = a[7] + (b[7] * scale); - out[8] = a[8] + (b[8] * scale); - out[9] = a[9] + (b[9] * scale); - out[10] = a[10] + (b[10] * scale); - out[11] = a[11] + (b[11] * scale); - out[12] = a[12] + (b[12] * scale); - out[13] = a[13] + (b[13] * scale); - out[14] = a[14] + (b[14] * scale); - out[15] = a[15] + (b[15] * scale); - return out; -} - -/** - * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) - * - * @param {mat4} a The first matrix. - * @param {mat4} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. - */ -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && - a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && - a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] && - a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15]; -} - -/** - * Returns whether or not the matrices have approximately the same elements in the same position. - * - * @param {mat4} a The first matrix. - * @param {mat4} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. - */ -function equals(a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - let a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7]; - let a8 = a[8], a9 = a[9], a10 = a[10], a11 = a[11]; - let a12 = a[12], a13 = a[13], a14 = a[14], a15 = a[15]; - - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - let b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7]; - let b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11]; - let b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15]; - - return (Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && - Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && - Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && - Math.abs(a3 - b3) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a3), Math.abs(b3)) && - Math.abs(a4 - b4) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a4), Math.abs(b4)) && - Math.abs(a5 - b5) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a5), Math.abs(b5)) && - Math.abs(a6 - b6) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a6), Math.abs(b6)) && - Math.abs(a7 - b7) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a7), Math.abs(b7)) && - Math.abs(a8 - b8) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a8), Math.abs(b8)) && - Math.abs(a9 - b9) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a9), Math.abs(b9)) && - Math.abs(a10 - b10) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a10), Math.abs(b10)) && - Math.abs(a11 - b11) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a11), Math.abs(b11)) && - Math.abs(a12 - b12) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a12), Math.abs(b12)) && - Math.abs(a13 - b13) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a13), Math.abs(b13)) && - Math.abs(a14 - b14) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a14), Math.abs(b14)) && - Math.abs(a15 - b15) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a15), Math.abs(b15))); -} - -/** - * Alias for {@link mat4.multiply} - * @function - */ -const mul = multiply; - -/** - * Alias for {@link mat4.subtract} - * @function - */ -const sub = subtract; - - -/***/ }), - -/***/ "./node_modules/gl-matrix/src/gl-matrix/quat.js": -/*!******************************************************!*\ - !*** ./node_modules/gl-matrix/src/gl-matrix/quat.js ***! - \******************************************************/ -/*! exports provided: create, identity, setAxisAngle, getAxisAngle, multiply, rotateX, rotateY, rotateZ, calculateW, slerp, random, invert, conjugate, fromMat3, fromEuler, str, clone, fromValues, copy, set, add, mul, scale, dot, lerp, length, len, squaredLength, sqrLen, normalize, exactEquals, equals, rotationTo, sqlerp, setAxes */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return identity; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setAxisAngle", function() { return setAxisAngle; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAxisAngle", function() { return getAxisAngle; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateX", function() { return rotateX; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateY", function() { return rotateY; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateZ", function() { return rotateZ; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "calculateW", function() { return calculateW; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "slerp", function() { return slerp; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "random", function() { return random; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "invert", function() { return invert; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "conjugate", function() { return conjugate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromMat3", function() { return fromMat3; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromEuler", function() { return fromEuler; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dot", function() { return dot; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lerp", function() { return lerp; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "length", function() { return length; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "len", function() { return len; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredLength", function() { return squaredLength; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrLen", function() { return sqrLen; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalize", function() { return normalize; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotationTo", function() { return rotationTo; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqlerp", function() { return sqlerp; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setAxes", function() { return setAxes; }); -/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/src/gl-matrix/common.js"); -/* harmony import */ var _mat3_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mat3.js */ "./node_modules/gl-matrix/src/gl-matrix/mat3.js"); -/* harmony import */ var _vec3_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vec3.js */ "./node_modules/gl-matrix/src/gl-matrix/vec3.js"); -/* harmony import */ var _vec4_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vec4.js */ "./node_modules/gl-matrix/src/gl-matrix/vec4.js"); - - - - - -/** - * Quaternion - * @module quat - */ - -/** - * Creates a new identity quat - * - * @returns {quat} a new quaternion - */ -function create() { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](4); - if(_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - } - out[3] = 1; - return out; -} - -/** - * Set a quat to the identity quaternion - * - * @param {quat} out the receiving quaternion - * @returns {quat} out - */ -function identity(out) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 1; - return out; -} - -/** - * Sets a quat from the given angle and rotation axis, - * then returns it. - * - * @param {quat} out the receiving quaternion - * @param {vec3} axis the axis around which to rotate - * @param {Number} rad the angle in radians - * @returns {quat} out - **/ -function setAxisAngle(out, axis, rad) { - rad = rad * 0.5; - let s = Math.sin(rad); - out[0] = s * axis[0]; - out[1] = s * axis[1]; - out[2] = s * axis[2]; - out[3] = Math.cos(rad); - return out; -} - -/** - * Gets the rotation axis and angle for a given - * quaternion. If a quaternion is created with - * setAxisAngle, this method will return the same - * values as providied in the original parameter list - * OR functionally equivalent values. - * Example: The quaternion formed by axis [0, 0, 1] and - * angle -90 is the same as the quaternion formed by - * [0, 0, 1] and 270. This method favors the latter. - * @param {vec3} out_axis Vector receiving the axis of rotation - * @param {quat} q Quaternion to be decomposed - * @return {Number} Angle, in radians, of the rotation - */ -function getAxisAngle(out_axis, q) { - let rad = Math.acos(q[3]) * 2.0; - let s = Math.sin(rad / 2.0); - if (s > _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]) { - out_axis[0] = q[0] / s; - out_axis[1] = q[1] / s; - out_axis[2] = q[2] / s; - } else { - // If s is zero, return any axis (no rotation - axis does not matter) - out_axis[0] = 1; - out_axis[1] = 0; - out_axis[2] = 0; - } - return rad; -} - -/** - * Multiplies two quat's - * - * @param {quat} out the receiving quaternion - * @param {quat} a the first operand - * @param {quat} b the second operand - * @returns {quat} out - */ -function multiply(out, a, b) { - let ax = a[0], ay = a[1], az = a[2], aw = a[3]; - let bx = b[0], by = b[1], bz = b[2], bw = b[3]; - - out[0] = ax * bw + aw * bx + ay * bz - az * by; - out[1] = ay * bw + aw * by + az * bx - ax * bz; - out[2] = az * bw + aw * bz + ax * by - ay * bx; - out[3] = aw * bw - ax * bx - ay * by - az * bz; - return out; -} - -/** - * Rotates a quaternion by the given angle about the X axis - * - * @param {quat} out quat receiving operation result - * @param {quat} a quat to rotate - * @param {number} rad angle (in radians) to rotate - * @returns {quat} out - */ -function rotateX(out, a, rad) { - rad *= 0.5; - - let ax = a[0], ay = a[1], az = a[2], aw = a[3]; - let bx = Math.sin(rad), bw = Math.cos(rad); - - out[0] = ax * bw + aw * bx; - out[1] = ay * bw + az * bx; - out[2] = az * bw - ay * bx; - out[3] = aw * bw - ax * bx; - return out; -} - -/** - * Rotates a quaternion by the given angle about the Y axis - * - * @param {quat} out quat receiving operation result - * @param {quat} a quat to rotate - * @param {number} rad angle (in radians) to rotate - * @returns {quat} out - */ -function rotateY(out, a, rad) { - rad *= 0.5; - - let ax = a[0], ay = a[1], az = a[2], aw = a[3]; - let by = Math.sin(rad), bw = Math.cos(rad); - - out[0] = ax * bw - az * by; - out[1] = ay * bw + aw * by; - out[2] = az * bw + ax * by; - out[3] = aw * bw - ay * by; - return out; -} - -/** - * Rotates a quaternion by the given angle about the Z axis - * - * @param {quat} out quat receiving operation result - * @param {quat} a quat to rotate - * @param {number} rad angle (in radians) to rotate - * @returns {quat} out - */ -function rotateZ(out, a, rad) { - rad *= 0.5; - - let ax = a[0], ay = a[1], az = a[2], aw = a[3]; - let bz = Math.sin(rad), bw = Math.cos(rad); - - out[0] = ax * bw + ay * bz; - out[1] = ay * bw - ax * bz; - out[2] = az * bw + aw * bz; - out[3] = aw * bw - az * bz; - return out; -} - -/** - * Calculates the W component of a quat from the X, Y, and Z components. - * Assumes that quaternion is 1 unit in length. - * Any existing W component will be ignored. - * - * @param {quat} out the receiving quaternion - * @param {quat} a quat to calculate W component of - * @returns {quat} out - */ -function calculateW(out, a) { - let x = a[0], y = a[1], z = a[2]; - - out[0] = x; - out[1] = y; - out[2] = z; - out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z)); - return out; -} - -/** - * Performs a spherical linear interpolation between two quat - * - * @param {quat} out the receiving quaternion - * @param {quat} a the first operand - * @param {quat} b the second operand - * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat} out - */ -function slerp(out, a, b, t) { - // benchmarks: - // http://jsperf.com/quaternion-slerp-implementations - let ax = a[0], ay = a[1], az = a[2], aw = a[3]; - let bx = b[0], by = b[1], bz = b[2], bw = b[3]; - - let omega, cosom, sinom, scale0, scale1; - - // calc cosine - cosom = ax * bx + ay * by + az * bz + aw * bw; - // adjust signs (if necessary) - if ( cosom < 0.0 ) { - cosom = -cosom; - bx = - bx; - by = - by; - bz = - bz; - bw = - bw; - } - // calculate coefficients - if ( (1.0 - cosom) > _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] ) { - // standard case (slerp) - omega = Math.acos(cosom); - sinom = Math.sin(omega); - scale0 = Math.sin((1.0 - t) * omega) / sinom; - scale1 = Math.sin(t * omega) / sinom; - } else { - // "from" and "to" quaternions are very close - // ... so we can do a linear interpolation - scale0 = 1.0 - t; - scale1 = t; - } - // calculate final values - out[0] = scale0 * ax + scale1 * bx; - out[1] = scale0 * ay + scale1 * by; - out[2] = scale0 * az + scale1 * bz; - out[3] = scale0 * aw + scale1 * bw; - - return out; -} - -/** - * Generates a random quaternion - * - * @param {quat} out the receiving quaternion - * @returns {quat} out - */ -function random(out) { - // Implementation of http://planning.cs.uiuc.edu/node198.html - // TODO: Calling random 3 times is probably not the fastest solution - let u1 = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"](); - let u2 = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"](); - let u3 = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"](); - - let sqrt1MinusU1 = Math.sqrt(1 - u1); - let sqrtU1 = Math.sqrt(u1); - - out[0] = sqrt1MinusU1 * Math.sin(2.0 * Math.PI * u2); - out[1] = sqrt1MinusU1 * Math.cos(2.0 * Math.PI * u2); - out[2] = sqrtU1 * Math.sin(2.0 * Math.PI * u3); - out[3] = sqrtU1 * Math.cos(2.0 * Math.PI * u3); - return out; -} - -/** - * Calculates the inverse of a quat - * - * @param {quat} out the receiving quaternion - * @param {quat} a quat to calculate inverse of - * @returns {quat} out - */ -function invert(out, a) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - let dot = a0*a0 + a1*a1 + a2*a2 + a3*a3; - let invDot = dot ? 1.0/dot : 0; - - // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 - - out[0] = -a0*invDot; - out[1] = -a1*invDot; - out[2] = -a2*invDot; - out[3] = a3*invDot; - return out; -} - -/** - * Calculates the conjugate of a quat - * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result. - * - * @param {quat} out the receiving quaternion - * @param {quat} a quat to calculate conjugate of - * @returns {quat} out - */ -function conjugate(out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - out[2] = -a[2]; - out[3] = a[3]; - return out; -} - -/** - * Creates a quaternion from the given 3x3 rotation matrix. - * - * NOTE: The resultant quaternion is not normalized, so you should be sure - * to renormalize the quaternion yourself where necessary. - * - * @param {quat} out the receiving quaternion - * @param {mat3} m rotation matrix - * @returns {quat} out - * @function - */ -function fromMat3(out, m) { - // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes - // article "Quaternion Calculus and Fast Animation". - let fTrace = m[0] + m[4] + m[8]; - let fRoot; - - if ( fTrace > 0.0 ) { - // |w| > 1/2, may as well choose w > 1/2 - fRoot = Math.sqrt(fTrace + 1.0); // 2w - out[3] = 0.5 * fRoot; - fRoot = 0.5/fRoot; // 1/(4w) - out[0] = (m[5]-m[7])*fRoot; - out[1] = (m[6]-m[2])*fRoot; - out[2] = (m[1]-m[3])*fRoot; - } else { - // |w| <= 1/2 - let i = 0; - if ( m[4] > m[0] ) - i = 1; - if ( m[8] > m[i*3+i] ) - i = 2; - let j = (i+1)%3; - let k = (i+2)%3; - - fRoot = Math.sqrt(m[i*3+i]-m[j*3+j]-m[k*3+k] + 1.0); - out[i] = 0.5 * fRoot; - fRoot = 0.5 / fRoot; - out[3] = (m[j*3+k] - m[k*3+j]) * fRoot; - out[j] = (m[j*3+i] + m[i*3+j]) * fRoot; - out[k] = (m[k*3+i] + m[i*3+k]) * fRoot; - } - - return out; -} - -/** - * Creates a quaternion from the given euler angle x, y, z. - * - * @param {quat} out the receiving quaternion - * @param {x} Angle to rotate around X axis in degrees. - * @param {y} Angle to rotate around Y axis in degrees. - * @param {z} Angle to rotate around Z axis in degrees. - * @returns {quat} out - * @function - */ -function fromEuler(out, x, y, z) { - let halfToRad = 0.5 * Math.PI / 180.0; - x *= halfToRad; - y *= halfToRad; - z *= halfToRad; - - let sx = Math.sin(x); - let cx = Math.cos(x); - let sy = Math.sin(y); - let cy = Math.cos(y); - let sz = Math.sin(z); - let cz = Math.cos(z); - - out[0] = sx * cy * cz - cx * sy * sz; - out[1] = cx * sy * cz + sx * cy * sz; - out[2] = cx * cy * sz - sx * sy * cz; - out[3] = cx * cy * cz + sx * sy * sz; - - return out; -} - -/** - * Returns a string representation of a quatenion - * - * @param {quat} a vector to represent as a string - * @returns {String} string representation of the vector - */ -function str(a) { - return 'quat(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')'; -} - -/** - * Creates a new quat initialized with values from an existing quaternion - * - * @param {quat} a quaternion to clone - * @returns {quat} a new quaternion - * @function - */ -const clone = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["clone"]; - -/** - * Creates a new quat initialized with the given values - * - * @param {Number} x X component - * @param {Number} y Y component - * @param {Number} z Z component - * @param {Number} w W component - * @returns {quat} a new quaternion - * @function - */ -const fromValues = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["fromValues"]; - -/** - * Copy the values from one quat to another - * - * @param {quat} out the receiving quaternion - * @param {quat} a the source quaternion - * @returns {quat} out - * @function - */ -const copy = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["copy"]; - -/** - * Set the components of a quat to the given values - * - * @param {quat} out the receiving quaternion - * @param {Number} x X component - * @param {Number} y Y component - * @param {Number} z Z component - * @param {Number} w W component - * @returns {quat} out - * @function - */ -const set = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["set"]; - -/** - * Adds two quat's - * - * @param {quat} out the receiving quaternion - * @param {quat} a the first operand - * @param {quat} b the second operand - * @returns {quat} out - * @function - */ -const add = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["add"]; - -/** - * Alias for {@link quat.multiply} - * @function - */ -const mul = multiply; - -/** - * Scales a quat by a scalar number - * - * @param {quat} out the receiving vector - * @param {quat} a the vector to scale - * @param {Number} b amount to scale the vector by - * @returns {quat} out - * @function - */ -const scale = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["scale"]; - -/** - * Calculates the dot product of two quat's - * - * @param {quat} a the first operand - * @param {quat} b the second operand - * @returns {Number} dot product of a and b - * @function - */ -const dot = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["dot"]; - -/** - * Performs a linear interpolation between two quat's - * - * @param {quat} out the receiving quaternion - * @param {quat} a the first operand - * @param {quat} b the second operand - * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat} out - * @function - */ -const lerp = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["lerp"]; - -/** - * Calculates the length of a quat - * - * @param {quat} a vector to calculate length of - * @returns {Number} length of a - */ -const length = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["length"]; - -/** - * Alias for {@link quat.length} - * @function - */ -const len = length; - -/** - * Calculates the squared length of a quat - * - * @param {quat} a vector to calculate squared length of - * @returns {Number} squared length of a - * @function - */ -const squaredLength = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["squaredLength"]; - -/** - * Alias for {@link quat.squaredLength} - * @function - */ -const sqrLen = squaredLength; - -/** - * Normalize a quat - * - * @param {quat} out the receiving quaternion - * @param {quat} a quaternion to normalize - * @returns {quat} out - * @function - */ -const normalize = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["normalize"]; - -/** - * Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===) - * - * @param {quat} a The first quaternion. - * @param {quat} b The second quaternion. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ -const exactEquals = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["exactEquals"]; - -/** - * Returns whether or not the quaternions have approximately the same elements in the same position. - * - * @param {quat} a The first vector. - * @param {quat} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ -const equals = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["equals"]; - -/** - * Sets a quaternion to represent the shortest rotation from one - * vector to another. - * - * Both vectors are assumed to be unit length. - * - * @param {quat} out the receiving quaternion. - * @param {vec3} a the initial vector - * @param {vec3} b the destination vector - * @returns {quat} out - */ -const rotationTo = (function() { - let tmpvec3 = _vec3_js__WEBPACK_IMPORTED_MODULE_2__["create"](); - let xUnitVec3 = _vec3_js__WEBPACK_IMPORTED_MODULE_2__["fromValues"](1,0,0); - let yUnitVec3 = _vec3_js__WEBPACK_IMPORTED_MODULE_2__["fromValues"](0,1,0); - - return function(out, a, b) { - let dot = _vec3_js__WEBPACK_IMPORTED_MODULE_2__["dot"](a, b); - if (dot < -0.999999) { - _vec3_js__WEBPACK_IMPORTED_MODULE_2__["cross"](tmpvec3, xUnitVec3, a); - if (_vec3_js__WEBPACK_IMPORTED_MODULE_2__["len"](tmpvec3) < 0.000001) - _vec3_js__WEBPACK_IMPORTED_MODULE_2__["cross"](tmpvec3, yUnitVec3, a); - _vec3_js__WEBPACK_IMPORTED_MODULE_2__["normalize"](tmpvec3, tmpvec3); - setAxisAngle(out, tmpvec3, Math.PI); - return out; - } else if (dot > 0.999999) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 1; - return out; - } else { - _vec3_js__WEBPACK_IMPORTED_MODULE_2__["cross"](tmpvec3, a, b); - out[0] = tmpvec3[0]; - out[1] = tmpvec3[1]; - out[2] = tmpvec3[2]; - out[3] = 1 + dot; - return normalize(out, out); - } - }; -})(); - -/** - * Performs a spherical linear interpolation with two control points - * - * @param {quat} out the receiving quaternion - * @param {quat} a the first operand - * @param {quat} b the second operand - * @param {quat} c the third operand - * @param {quat} d the fourth operand - * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat} out - */ -const sqlerp = (function () { - let temp1 = create(); - let temp2 = create(); - - return function (out, a, b, c, d, t) { - slerp(temp1, a, d, t); - slerp(temp2, b, c, t); - slerp(out, temp1, temp2, 2 * t * (1 - t)); - - return out; - }; -}()); - -/** - * Sets the specified quaternion with values corresponding to the given - * axes. Each axis is a vec3 and is expected to be unit length and - * perpendicular to all other specified axes. - * - * @param {vec3} view the vector representing the viewing direction - * @param {vec3} right the vector representing the local "right" direction - * @param {vec3} up the vector representing the local "up" direction - * @returns {quat} out - */ -const setAxes = (function() { - let matr = _mat3_js__WEBPACK_IMPORTED_MODULE_1__["create"](); - - return function(out, view, right, up) { - matr[0] = right[0]; - matr[3] = right[1]; - matr[6] = right[2]; - - matr[1] = up[0]; - matr[4] = up[1]; - matr[7] = up[2]; - - matr[2] = -view[0]; - matr[5] = -view[1]; - matr[8] = -view[2]; - - return normalize(out, fromMat3(out, matr)); - }; -})(); - - -/***/ }), - -/***/ "./node_modules/gl-matrix/src/gl-matrix/quat2.js": -/*!*******************************************************!*\ - !*** ./node_modules/gl-matrix/src/gl-matrix/quat2.js ***! - \*******************************************************/ -/*! exports provided: create, clone, fromValues, fromRotationTranslationValues, fromRotationTranslation, fromTranslation, fromRotation, fromMat4, copy, identity, set, getReal, getDual, setReal, setDual, getTranslation, translate, rotateX, rotateY, rotateZ, rotateByQuatAppend, rotateByQuatPrepend, rotateAroundAxis, add, multiply, mul, scale, dot, lerp, invert, conjugate, length, len, squaredLength, sqrLen, normalize, str, exactEquals, equals */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotationTranslationValues", function() { return fromRotationTranslationValues; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotationTranslation", function() { return fromRotationTranslation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromTranslation", function() { return fromTranslation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotation", function() { return fromRotation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromMat4", function() { return fromMat4; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return identity; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getReal", function() { return getReal; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getDual", function() { return getDual; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setReal", function() { return setReal; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setDual", function() { return setDual; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTranslation", function() { return getTranslation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "translate", function() { return translate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateX", function() { return rotateX; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateY", function() { return rotateY; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateZ", function() { return rotateZ; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateByQuatAppend", function() { return rotateByQuatAppend; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateByQuatPrepend", function() { return rotateByQuatPrepend; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateAroundAxis", function() { return rotateAroundAxis; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dot", function() { return dot; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lerp", function() { return lerp; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "invert", function() { return invert; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "conjugate", function() { return conjugate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "length", function() { return length; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "len", function() { return len; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredLength", function() { return squaredLength; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrLen", function() { return sqrLen; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalize", function() { return normalize; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; }); -/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/src/gl-matrix/common.js"); -/* harmony import */ var _quat_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./quat.js */ "./node_modules/gl-matrix/src/gl-matrix/quat.js"); -/* harmony import */ var _mat4_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./mat4.js */ "./node_modules/gl-matrix/src/gl-matrix/mat4.js"); - - - - -/** - * Dual Quaternion
- * Format: [real, dual]
- * Quaternion format: XYZW
- * Make sure to have normalized dual quaternions, otherwise the functions may not work as intended.
- * @module quat2 - */ - - -/** - * Creates a new identity dual quat - * - * @returns {quat2} a new dual quaternion [real -> rotation, dual -> translation] - */ -function create() { - let dq = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](8); - if(_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) { - dq[0] = 0; - dq[1] = 0; - dq[2] = 0; - dq[4] = 0; - dq[5] = 0; - dq[6] = 0; - dq[7] = 0; - } - dq[3] = 1; - return dq; -} - -/** - * Creates a new quat initialized with values from an existing quaternion - * - * @param {quat2} a dual quaternion to clone - * @returns {quat2} new dual quaternion - * @function - */ -function clone(a) { - let dq = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](8); - dq[0] = a[0]; - dq[1] = a[1]; - dq[2] = a[2]; - dq[3] = a[3]; - dq[4] = a[4]; - dq[5] = a[5]; - dq[6] = a[6]; - dq[7] = a[7]; - return dq; -} - -/** - * Creates a new dual quat initialized with the given values - * - * @param {Number} x1 X component - * @param {Number} y1 Y component - * @param {Number} z1 Z component - * @param {Number} w1 W component - * @param {Number} x2 X component - * @param {Number} y2 Y component - * @param {Number} z2 Z component - * @param {Number} w2 W component - * @returns {quat2} new dual quaternion - * @function - */ -function fromValues(x1, y1, z1, w1, x2, y2, z2, w2) { - let dq = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](8); - dq[0] = x1; - dq[1] = y1; - dq[2] = z1; - dq[3] = w1; - dq[4] = x2; - dq[5] = y2; - dq[6] = z2; - dq[7] = w2; - return dq; -} - -/** - * Creates a new dual quat from the given values (quat and translation) - * - * @param {Number} x1 X component - * @param {Number} y1 Y component - * @param {Number} z1 Z component - * @param {Number} w1 W component - * @param {Number} x2 X component (translation) - * @param {Number} y2 Y component (translation) - * @param {Number} z2 Z component (translation) - * @returns {quat2} new dual quaternion - * @function - */ -function fromRotationTranslationValues(x1, y1, z1, w1, x2, y2, z2) { - let dq = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](8); - dq[0] = x1; - dq[1] = y1; - dq[2] = z1; - dq[3] = w1; - let ax = x2 * 0.5, - ay = y2 * 0.5, - az = z2 * 0.5; - dq[4] = ax * w1 + ay * z1 - az * y1; - dq[5] = ay * w1 + az * x1 - ax * z1; - dq[6] = az * w1 + ax * y1 - ay * x1; - dq[7] = -ax * x1 - ay * y1 - az * z1; - return dq; -} - -/** - * Creates a dual quat from a quaternion and a translation - * - * @param {quat2} dual quaternion receiving operation result - * @param {quat} q quaternion - * @param {vec3} t tranlation vector - * @returns {quat2} dual quaternion receiving operation result - * @function - */ -function fromRotationTranslation(out, q, t) { - let ax = t[0] * 0.5, - ay = t[1] * 0.5, - az = t[2] * 0.5, - bx = q[0], - by = q[1], - bz = q[2], - bw = q[3]; - out[0] = bx; - out[1] = by; - out[2] = bz; - out[3] = bw; - out[4] = ax * bw + ay * bz - az * by; - out[5] = ay * bw + az * bx - ax * bz; - out[6] = az * bw + ax * by - ay * bx; - out[7] = -ax * bx - ay * by - az * bz; - return out; -} - -/** - * Creates a dual quat from a translation - * - * @param {quat2} dual quaternion receiving operation result - * @param {vec3} t translation vector - * @returns {quat2} dual quaternion receiving operation result - * @function - */ -function fromTranslation(out, t) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 1; - out[4] = t[0] * 0.5; - out[5] = t[1] * 0.5; - out[6] = t[2] * 0.5; - out[7] = 0; - return out; -} - -/** - * Creates a dual quat from a quaternion - * - * @param {quat2} dual quaternion receiving operation result - * @param {quat} q the quaternion - * @returns {quat2} dual quaternion receiving operation result - * @function - */ -function fromRotation(out, q) { - out[0] = q[0]; - out[1] = q[1]; - out[2] = q[2]; - out[3] = q[3]; - out[4] = 0; - out[5] = 0; - out[6] = 0; - out[7] = 0; - return out; -} - -/** - * Creates a new dual quat from a matrix (4x4) - * - * @param {quat2} out the dual quaternion - * @param {mat4} a the matrix - * @returns {quat2} dual quat receiving operation result - * @function - */ -function fromMat4(out, a) { - //TODO Optimize this - let outer = _quat_js__WEBPACK_IMPORTED_MODULE_1__["create"](); - _mat4_js__WEBPACK_IMPORTED_MODULE_2__["getRotation"](outer, a); - let t = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](3); - _mat4_js__WEBPACK_IMPORTED_MODULE_2__["getTranslation"](t, a); - fromRotationTranslation(out, outer, t); - return out; -} - -/** - * Copy the values from one dual quat to another - * - * @param {quat2} out the receiving dual quaternion - * @param {quat2} a the source dual quaternion - * @returns {quat2} out - * @function - */ -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - return out; -} - -/** - * Set a dual quat to the identity dual quaternion - * - * @param {quat2} out the receiving quaternion - * @returns {quat2} out - */ -function identity(out) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 1; - out[4] = 0; - out[5] = 0; - out[6] = 0; - out[7] = 0; - return out; -} - -/** - * Set the components of a dual quat to the given values - * - * @param {quat2} out the receiving quaternion - * @param {Number} x1 X component - * @param {Number} y1 Y component - * @param {Number} z1 Z component - * @param {Number} w1 W component - * @param {Number} x2 X component - * @param {Number} y2 Y component - * @param {Number} z2 Z component - * @param {Number} w2 W component - * @returns {quat2} out - * @function - */ -function set(out, x1, y1, z1, w1, x2, y2, z2, w2) { - out[0] = x1; - out[1] = y1; - out[2] = z1; - out[3] = w1; - - out[4] = x2; - out[5] = y2; - out[6] = z2; - out[7] = w2; - return out; -} - -/** - * Gets the real part of a dual quat - * @param {quat} out real part - * @param {quat2} a Dual Quaternion - * @return {quat} real part - */ -const getReal = _quat_js__WEBPACK_IMPORTED_MODULE_1__["copy"]; - -/** - * Gets the dual part of a dual quat - * @param {quat} out dual part - * @param {quat2} a Dual Quaternion - * @return {quat} dual part - */ -function getDual(out, a) { - out[0] = a[4]; - out[1] = a[5]; - out[2] = a[6]; - out[3] = a[7]; - return out; -} - -/** - * Set the real component of a dual quat to the given quaternion - * - * @param {quat2} out the receiving quaternion - * @param {quat} q a quaternion representing the real part - * @returns {quat2} out - * @function - */ -const setReal = _quat_js__WEBPACK_IMPORTED_MODULE_1__["copy"]; - -/** - * Set the dual component of a dual quat to the given quaternion - * - * @param {quat2} out the receiving quaternion - * @param {quat} q a quaternion representing the dual part - * @returns {quat2} out - * @function - */ -function setDual(out, q) { - out[4] = q[0]; - out[5] = q[1]; - out[6] = q[2]; - out[7] = q[3]; - return out; -} - -/** - * Gets the translation of a normalized dual quat - * @param {vec3} out translation - * @param {quat2} a Dual Quaternion to be decomposed - * @return {vec3} translation - */ -function getTranslation(out, a) { - let ax = a[4], - ay = a[5], - az = a[6], - aw = a[7], - bx = -a[0], - by = -a[1], - bz = -a[2], - bw = a[3]; - out[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2; - out[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2; - out[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2; - return out; -} - -/** - * Translates a dual quat by the given vector - * - * @param {quat2} out the receiving dual quaternion - * @param {quat2} a the dual quaternion to translate - * @param {vec3} v vector to translate by - * @returns {quat2} out - */ -function translate(out, a, v) { - let ax1 = a[0], - ay1 = a[1], - az1 = a[2], - aw1 = a[3], - bx1 = v[0] * 0.5, - by1 = v[1] * 0.5, - bz1 = v[2] * 0.5, - ax2 = a[4], - ay2 = a[5], - az2 = a[6], - aw2 = a[7]; - out[0] = ax1; - out[1] = ay1; - out[2] = az1; - out[3] = aw1; - out[4] = aw1 * bx1 + ay1 * bz1 - az1 * by1 + ax2; - out[5] = aw1 * by1 + az1 * bx1 - ax1 * bz1 + ay2; - out[6] = aw1 * bz1 + ax1 * by1 - ay1 * bx1 + az2; - out[7] = -ax1 * bx1 - ay1 * by1 - az1 * bz1 + aw2; - return out; -} - -/** - * Rotates a dual quat around the X axis - * - * @param {quat2} out the receiving dual quaternion - * @param {quat2} a the dual quaternion to rotate - * @param {number} rad how far should the rotation be - * @returns {quat2} out - */ -function rotateX(out, a, rad) { - let bx = -a[0], - by = -a[1], - bz = -a[2], - bw = a[3], - ax = a[4], - ay = a[5], - az = a[6], - aw = a[7], - ax1 = ax * bw + aw * bx + ay * bz - az * by, - ay1 = ay * bw + aw * by + az * bx - ax * bz, - az1 = az * bw + aw * bz + ax * by - ay * bx, - aw1 = aw * bw - ax * bx - ay * by - az * bz; - _quat_js__WEBPACK_IMPORTED_MODULE_1__["rotateX"](out, a, rad); - bx = out[0]; - by = out[1]; - bz = out[2]; - bw = out[3]; - out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; - out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; - out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; - out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; - return out; -} - -/** - * Rotates a dual quat around the Y axis - * - * @param {quat2} out the receiving dual quaternion - * @param {quat2} a the dual quaternion to rotate - * @param {number} rad how far should the rotation be - * @returns {quat2} out - */ -function rotateY(out, a, rad) { - let bx = -a[0], - by = -a[1], - bz = -a[2], - bw = a[3], - ax = a[4], - ay = a[5], - az = a[6], - aw = a[7], - ax1 = ax * bw + aw * bx + ay * bz - az * by, - ay1 = ay * bw + aw * by + az * bx - ax * bz, - az1 = az * bw + aw * bz + ax * by - ay * bx, - aw1 = aw * bw - ax * bx - ay * by - az * bz; - _quat_js__WEBPACK_IMPORTED_MODULE_1__["rotateY"](out, a, rad); - bx = out[0]; - by = out[1]; - bz = out[2]; - bw = out[3]; - out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; - out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; - out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; - out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; - return out; -} - -/** - * Rotates a dual quat around the Z axis - * - * @param {quat2} out the receiving dual quaternion - * @param {quat2} a the dual quaternion to rotate - * @param {number} rad how far should the rotation be - * @returns {quat2} out - */ -function rotateZ(out, a, rad) { - let bx = -a[0], - by = -a[1], - bz = -a[2], - bw = a[3], - ax = a[4], - ay = a[5], - az = a[6], - aw = a[7], - ax1 = ax * bw + aw * bx + ay * bz - az * by, - ay1 = ay * bw + aw * by + az * bx - ax * bz, - az1 = az * bw + aw * bz + ax * by - ay * bx, - aw1 = aw * bw - ax * bx - ay * by - az * bz; - _quat_js__WEBPACK_IMPORTED_MODULE_1__["rotateZ"](out, a, rad); - bx = out[0]; - by = out[1]; - bz = out[2]; - bw = out[3]; - out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; - out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; - out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; - out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; - return out; -} - -/** - * Rotates a dual quat by a given quaternion (a * q) - * - * @param {quat2} out the receiving dual quaternion - * @param {quat2} a the dual quaternion to rotate - * @param {quat} q quaternion to rotate by - * @returns {quat2} out - */ -function rotateByQuatAppend(out, a, q) { - let qx = q[0], - qy = q[1], - qz = q[2], - qw = q[3], - ax = a[0], - ay = a[1], - az = a[2], - aw = a[3]; - - out[0] = ax * qw + aw * qx + ay * qz - az * qy; - out[1] = ay * qw + aw * qy + az * qx - ax * qz; - out[2] = az * qw + aw * qz + ax * qy - ay * qx; - out[3] = aw * qw - ax * qx - ay * qy - az * qz; - ax = a[4]; - ay = a[5]; - az = a[6]; - aw = a[7]; - out[4] = ax * qw + aw * qx + ay * qz - az * qy; - out[5] = ay * qw + aw * qy + az * qx - ax * qz; - out[6] = az * qw + aw * qz + ax * qy - ay * qx; - out[7] = aw * qw - ax * qx - ay * qy - az * qz; - return out; -} - -/** - * Rotates a dual quat by a given quaternion (q * a) - * - * @param {quat2} out the receiving dual quaternion - * @param {quat} q quaternion to rotate by - * @param {quat2} a the dual quaternion to rotate - * @returns {quat2} out - */ -function rotateByQuatPrepend(out, q, a) { - let qx = q[0], - qy = q[1], - qz = q[2], - qw = q[3], - bx = a[0], - by = a[1], - bz = a[2], - bw = a[3]; - - out[0] = qx * bw + qw * bx + qy * bz - qz * by; - out[1] = qy * bw + qw * by + qz * bx - qx * bz; - out[2] = qz * bw + qw * bz + qx * by - qy * bx; - out[3] = qw * bw - qx * bx - qy * by - qz * bz; - bx = a[4]; - by = a[5]; - bz = a[6]; - bw = a[7]; - out[4] = qx * bw + qw * bx + qy * bz - qz * by; - out[5] = qy * bw + qw * by + qz * bx - qx * bz; - out[6] = qz * bw + qw * bz + qx * by - qy * bx; - out[7] = qw * bw - qx * bx - qy * by - qz * bz; - return out; -} - -/** - * Rotates a dual quat around a given axis. Does the normalisation automatically - * - * @param {quat2} out the receiving dual quaternion - * @param {quat2} a the dual quaternion to rotate - * @param {vec3} axis the axis to rotate around - * @param {Number} rad how far the rotation should be - * @returns {quat2} out - */ -function rotateAroundAxis(out, a, axis, rad) { - //Special case for rad = 0 - if (Math.abs(rad) < _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]) { - return copy(out, a); - } - let axisLength = Math.sqrt(axis[0] * axis[0] + axis[1] * axis[1] + axis[2] * axis[2]); - - rad = rad * 0.5; - let s = Math.sin(rad); - let bx = s * axis[0] / axisLength; - let by = s * axis[1] / axisLength; - let bz = s * axis[2] / axisLength; - let bw = Math.cos(rad); - - let ax1 = a[0], - ay1 = a[1], - az1 = a[2], - aw1 = a[3]; - out[0] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; - out[1] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; - out[2] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; - out[3] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; - - let ax = a[4], - ay = a[5], - az = a[6], - aw = a[7]; - out[4] = ax * bw + aw * bx + ay * bz - az * by; - out[5] = ay * bw + aw * by + az * bx - ax * bz; - out[6] = az * bw + aw * bz + ax * by - ay * bx; - out[7] = aw * bw - ax * bx - ay * by - az * bz; - - return out; -} - -/** - * Adds two dual quat's - * - * @param {quat2} out the receiving dual quaternion - * @param {quat2} a the first operand - * @param {quat2} b the second operand - * @returns {quat2} out - * @function - */ -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - out[3] = a[3] + b[3]; - out[4] = a[4] + b[4]; - out[5] = a[5] + b[5]; - out[6] = a[6] + b[6]; - out[7] = a[7] + b[7]; - return out; -} - -/** - * Multiplies two dual quat's - * - * @param {quat2} out the receiving dual quaternion - * @param {quat2} a the first operand - * @param {quat2} b the second operand - * @returns {quat2} out - */ -function multiply(out, a, b) { - let ax0 = a[0], - ay0 = a[1], - az0 = a[2], - aw0 = a[3], - bx1 = b[4], - by1 = b[5], - bz1 = b[6], - bw1 = b[7], - ax1 = a[4], - ay1 = a[5], - az1 = a[6], - aw1 = a[7], - bx0 = b[0], - by0 = b[1], - bz0 = b[2], - bw0 = b[3]; - out[0] = ax0 * bw0 + aw0 * bx0 + ay0 * bz0 - az0 * by0; - out[1] = ay0 * bw0 + aw0 * by0 + az0 * bx0 - ax0 * bz0; - out[2] = az0 * bw0 + aw0 * bz0 + ax0 * by0 - ay0 * bx0; - out[3] = aw0 * bw0 - ax0 * bx0 - ay0 * by0 - az0 * bz0; - out[4] = ax0 * bw1 + aw0 * bx1 + ay0 * bz1 - az0 * by1 + ax1 * bw0 + aw1 * bx0 + ay1 * bz0 - az1 * by0; - out[5] = ay0 * bw1 + aw0 * by1 + az0 * bx1 - ax0 * bz1 + ay1 * bw0 + aw1 * by0 + az1 * bx0 - ax1 * bz0; - out[6] = az0 * bw1 + aw0 * bz1 + ax0 * by1 - ay0 * bx1 + az1 * bw0 + aw1 * bz0 + ax1 * by0 - ay1 * bx0; - out[7] = aw0 * bw1 - ax0 * bx1 - ay0 * by1 - az0 * bz1 + aw1 * bw0 - ax1 * bx0 - ay1 * by0 - az1 * bz0; - return out; -} - -/** - * Alias for {@link quat2.multiply} - * @function - */ -const mul = multiply; - -/** - * Scales a dual quat by a scalar number - * - * @param {quat2} out the receiving dual quat - * @param {quat2} a the dual quat to scale - * @param {Number} b amount to scale the dual quat by - * @returns {quat2} out - * @function - */ -function scale(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; - out[4] = a[4] * b; - out[5] = a[5] * b; - out[6] = a[6] * b; - out[7] = a[7] * b; - return out; -} - -/** - * Calculates the dot product of two dual quat's (The dot product of the real parts) - * - * @param {quat2} a the first operand - * @param {quat2} b the second operand - * @returns {Number} dot product of a and b - * @function - */ -const dot = _quat_js__WEBPACK_IMPORTED_MODULE_1__["dot"]; - -/** - * Performs a linear interpolation between two dual quats's - * NOTE: The resulting dual quaternions won't always be normalized (The error is most noticeable when t = 0.5) - * - * @param {quat2} out the receiving dual quat - * @param {quat2} a the first operand - * @param {quat2} b the second operand - * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat2} out - */ -function lerp(out, a, b, t) { - let mt = 1 - t; - if (dot(a, b) < 0) t = -t; - - out[0] = a[0] * mt + b[0] * t; - out[1] = a[1] * mt + b[1] * t; - out[2] = a[2] * mt + b[2] * t; - out[3] = a[3] * mt + b[3] * t; - out[4] = a[4] * mt + b[4] * t; - out[5] = a[5] * mt + b[5] * t; - out[6] = a[6] * mt + b[6] * t; - out[7] = a[7] * mt + b[7] * t; - - return out; -} - -/** - * Calculates the inverse of a dual quat. If they are normalized, conjugate is cheaper - * - * @param {quat2} out the receiving dual quaternion - * @param {quat2} a dual quat to calculate inverse of - * @returns {quat2} out - */ -function invert(out, a) { - let sqlen = squaredLength(a); - out[0] = -a[0] / sqlen; - out[1] = -a[1] / sqlen; - out[2] = -a[2] / sqlen; - out[3] = a[3] / sqlen; - out[4] = -a[4] / sqlen; - out[5] = -a[5] / sqlen; - out[6] = -a[6] / sqlen; - out[7] = a[7] / sqlen; - return out; -} - -/** - * Calculates the conjugate of a dual quat - * If the dual quaternion is normalized, this function is faster than quat2.inverse and produces the same result. - * - * @param {quat2} out the receiving quaternion - * @param {quat2} a quat to calculate conjugate of - * @returns {quat2} out - */ -function conjugate(out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - out[2] = -a[2]; - out[3] = a[3]; - out[4] = -a[4]; - out[5] = -a[5]; - out[6] = -a[6]; - out[7] = a[7]; - return out; -} - -/** - * Calculates the length of a dual quat - * - * @param {quat2} a dual quat to calculate length of - * @returns {Number} length of a - * @function - */ -const length = _quat_js__WEBPACK_IMPORTED_MODULE_1__["length"]; - -/** - * Alias for {@link quat2.length} - * @function - */ -const len = length; - -/** - * Calculates the squared length of a dual quat - * - * @param {quat2} a dual quat to calculate squared length of - * @returns {Number} squared length of a - * @function - */ -const squaredLength = _quat_js__WEBPACK_IMPORTED_MODULE_1__["squaredLength"]; - -/** - * Alias for {@link quat2.squaredLength} - * @function - */ -const sqrLen = squaredLength; - -/** - * Normalize a dual quat - * - * @param {quat2} out the receiving dual quaternion - * @param {quat2} a dual quaternion to normalize - * @returns {quat2} out - * @function - */ -function normalize(out, a) { - let magnitude = squaredLength(a); - if (magnitude > 0) { - magnitude = Math.sqrt(magnitude); - - let a0 = a[0] / magnitude; - let a1 = a[1] / magnitude; - let a2 = a[2] / magnitude; - let a3 = a[3] / magnitude; - - let b0 = a[4]; - let b1 = a[5]; - let b2 = a[6]; - let b3 = a[7]; - - let a_dot_b = (a0 * b0) + (a1 * b1) + (a2 * b2) + (a3 * b3); - - out[0] = a0; - out[1] = a1; - out[2] = a2; - out[3] = a3; - - out[4] = (b0 - (a0 * a_dot_b)) / magnitude; - out[5] = (b1 - (a1 * a_dot_b)) / magnitude; - out[6] = (b2 - (a2 * a_dot_b)) / magnitude; - out[7] = (b3 - (a3 * a_dot_b)) / magnitude; - } - return out; -} - -/** - * Returns a string representation of a dual quatenion - * - * @param {quat2} a dual quaternion to represent as a string - * @returns {String} string representation of the dual quat - */ -function str(a) { - return 'quat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + - a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ')'; -} - -/** - * Returns whether or not the dual quaternions have exactly the same elements in the same position (when compared with ===) - * - * @param {quat2} a the first dual quaternion. - * @param {quat2} b the second dual quaternion. - * @returns {Boolean} true if the dual quaternions are equal, false otherwise. - */ -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && - a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7]; -} - -/** - * Returns whether or not the dual quaternions have approximately the same elements in the same position. - * - * @param {quat2} a the first dual quat. - * @param {quat2} b the second dual quat. - * @returns {Boolean} true if the dual quats are equal, false otherwise. - */ -function equals(a, b) { - let a0 = a[0], - a1 = a[1], - a2 = a[2], - a3 = a[3], - a4 = a[4], - a5 = a[5], - a6 = a[6], - a7 = a[7]; - let b0 = b[0], - b1 = b[1], - b2 = b[2], - b3 = b[3], - b4 = b[4], - b5 = b[5], - b6 = b[6], - b7 = b[7]; - return (Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && - Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && - Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && - Math.abs(a3 - b3) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && - Math.abs(a4 - b4) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && - Math.abs(a5 - b5) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && - Math.abs(a6 - b6) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && - Math.abs(a7 - b7) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a7), Math.abs(b7))); -} - - -/***/ }), - -/***/ "./node_modules/gl-matrix/src/gl-matrix/vec2.js": -/*!******************************************************!*\ - !*** ./node_modules/gl-matrix/src/gl-matrix/vec2.js ***! - \******************************************************/ -/*! exports provided: create, clone, fromValues, copy, set, add, subtract, multiply, divide, ceil, floor, min, max, round, scale, scaleAndAdd, distance, squaredDistance, length, squaredLength, negate, inverse, normalize, dot, cross, lerp, random, transformMat2, transformMat2d, transformMat3, transformMat4, rotate, angle, str, exactEquals, equals, len, sub, mul, div, dist, sqrDist, sqrLen, forEach */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subtract", function() { return subtract; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "divide", function() { return divide; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ceil", function() { return ceil; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "floor", function() { return floor; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "min", function() { return min; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "max", function() { return max; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "round", function() { return round; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scaleAndAdd", function() { return scaleAndAdd; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "distance", function() { return distance; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredDistance", function() { return squaredDistance; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "length", function() { return length; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredLength", function() { return squaredLength; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "negate", function() { return negate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "inverse", function() { return inverse; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalize", function() { return normalize; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dot", function() { return dot; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cross", function() { return cross; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lerp", function() { return lerp; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "random", function() { return random; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformMat2", function() { return transformMat2; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformMat2d", function() { return transformMat2d; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformMat3", function() { return transformMat3; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformMat4", function() { return transformMat4; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotate", function() { return rotate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "angle", function() { return angle; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "len", function() { return len; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "div", function() { return div; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dist", function() { return dist; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrDist", function() { return sqrDist; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrLen", function() { return sqrLen; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "forEach", function() { return forEach; }); -/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/src/gl-matrix/common.js"); - - -/** - * 2 Dimensional Vector - * @module vec2 - */ - -/** - * Creates a new, empty vec2 - * - * @returns {vec2} a new 2D vector - */ -function create() { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](2); - if(_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) { - out[0] = 0; - out[1] = 0; - } - return out; -} - -/** - * Creates a new vec2 initialized with values from an existing vector - * - * @param {vec2} a vector to clone - * @returns {vec2} a new 2D vector - */ -function clone(a) { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](2); - out[0] = a[0]; - out[1] = a[1]; - return out; -} - -/** - * Creates a new vec2 initialized with the given values - * - * @param {Number} x X component - * @param {Number} y Y component - * @returns {vec2} a new 2D vector - */ -function fromValues(x, y) { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](2); - out[0] = x; - out[1] = y; - return out; -} - -/** - * Copy the values from one vec2 to another - * - * @param {vec2} out the receiving vector - * @param {vec2} a the source vector - * @returns {vec2} out - */ -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - return out; -} - -/** - * Set the components of a vec2 to the given values - * - * @param {vec2} out the receiving vector - * @param {Number} x X component - * @param {Number} y Y component - * @returns {vec2} out - */ -function set(out, x, y) { - out[0] = x; - out[1] = y; - return out; -} - -/** - * Adds two vec2's - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {vec2} out - */ -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - return out; -} - -/** - * Subtracts vector b from vector a - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {vec2} out - */ -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - return out; -} - -/** - * Multiplies two vec2's - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {vec2} out - */ -function multiply(out, a, b) { - out[0] = a[0] * b[0]; - out[1] = a[1] * b[1]; - return out; -} - -/** - * Divides two vec2's - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {vec2} out - */ -function divide(out, a, b) { - out[0] = a[0] / b[0]; - out[1] = a[1] / b[1]; - return out; -} - -/** - * Math.ceil the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {vec2} a vector to ceil - * @returns {vec2} out - */ -function ceil(out, a) { - out[0] = Math.ceil(a[0]); - out[1] = Math.ceil(a[1]); - return out; -} - -/** - * Math.floor the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {vec2} a vector to floor - * @returns {vec2} out - */ -function floor(out, a) { - out[0] = Math.floor(a[0]); - out[1] = Math.floor(a[1]); - return out; -} - -/** - * Returns the minimum of two vec2's - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {vec2} out - */ -function min(out, a, b) { - out[0] = Math.min(a[0], b[0]); - out[1] = Math.min(a[1], b[1]); - return out; -} - -/** - * Returns the maximum of two vec2's - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {vec2} out - */ -function max(out, a, b) { - out[0] = Math.max(a[0], b[0]); - out[1] = Math.max(a[1], b[1]); - return out; -} - -/** - * Math.round the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {vec2} a vector to round - * @returns {vec2} out - */ -function round (out, a) { - out[0] = Math.round(a[0]); - out[1] = Math.round(a[1]); - return out; -} - -/** - * Scales a vec2 by a scalar number - * - * @param {vec2} out the receiving vector - * @param {vec2} a the vector to scale - * @param {Number} b amount to scale the vector by - * @returns {vec2} out - */ -function scale(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - return out; -} - -/** - * Adds two vec2's after scaling the second operand by a scalar value - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @param {Number} scale the amount to scale b by before adding - * @returns {vec2} out - */ -function scaleAndAdd(out, a, b, scale) { - out[0] = a[0] + (b[0] * scale); - out[1] = a[1] + (b[1] * scale); - return out; -} - -/** - * Calculates the euclidian distance between two vec2's - * - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {Number} distance between a and b - */ -function distance(a, b) { - var x = b[0] - a[0], - y = b[1] - a[1]; - return Math.sqrt(x*x + y*y); -} - -/** - * Calculates the squared euclidian distance between two vec2's - * - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {Number} squared distance between a and b - */ -function squaredDistance(a, b) { - var x = b[0] - a[0], - y = b[1] - a[1]; - return x*x + y*y; -} - -/** - * Calculates the length of a vec2 - * - * @param {vec2} a vector to calculate length of - * @returns {Number} length of a - */ -function length(a) { - var x = a[0], - y = a[1]; - return Math.sqrt(x*x + y*y); -} - -/** - * Calculates the squared length of a vec2 - * - * @param {vec2} a vector to calculate squared length of - * @returns {Number} squared length of a - */ -function squaredLength (a) { - var x = a[0], - y = a[1]; - return x*x + y*y; -} - -/** - * Negates the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {vec2} a vector to negate - * @returns {vec2} out - */ -function negate(out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - return out; -} - -/** - * Returns the inverse of the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {vec2} a vector to invert - * @returns {vec2} out - */ -function inverse(out, a) { - out[0] = 1.0 / a[0]; - out[1] = 1.0 / a[1]; - return out; -} - -/** - * Normalize a vec2 - * - * @param {vec2} out the receiving vector - * @param {vec2} a vector to normalize - * @returns {vec2} out - */ -function normalize(out, a) { - var x = a[0], - y = a[1]; - var len = x*x + y*y; - if (len > 0) { - //TODO: evaluate use of glm_invsqrt here? - len = 1 / Math.sqrt(len); - out[0] = a[0] * len; - out[1] = a[1] * len; - } - return out; -} - -/** - * Calculates the dot product of two vec2's - * - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {Number} dot product of a and b - */ -function dot(a, b) { - return a[0] * b[0] + a[1] * b[1]; -} - -/** - * Computes the cross product of two vec2's - * Note that the cross product must by definition produce a 3D vector - * - * @param {vec3} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {vec3} out - */ -function cross(out, a, b) { - var z = a[0] * b[1] - a[1] * b[0]; - out[0] = out[1] = 0; - out[2] = z; - return out; -} - -/** - * Performs a linear interpolation between two vec2's - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec2} out - */ -function lerp(out, a, b, t) { - var ax = a[0], - ay = a[1]; - out[0] = ax + t * (b[0] - ax); - out[1] = ay + t * (b[1] - ay); - return out; -} - -/** - * Generates a random vector with the given scale - * - * @param {vec2} out the receiving vector - * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned - * @returns {vec2} out - */ -function random(out, scale) { - scale = scale || 1.0; - var r = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]() * 2.0 * Math.PI; - out[0] = Math.cos(r) * scale; - out[1] = Math.sin(r) * scale; - return out; -} - -/** - * Transforms the vec2 with a mat2 - * - * @param {vec2} out the receiving vector - * @param {vec2} a the vector to transform - * @param {mat2} m matrix to transform with - * @returns {vec2} out - */ -function transformMat2(out, a, m) { - var x = a[0], - y = a[1]; - out[0] = m[0] * x + m[2] * y; - out[1] = m[1] * x + m[3] * y; - return out; -} - -/** - * Transforms the vec2 with a mat2d - * - * @param {vec2} out the receiving vector - * @param {vec2} a the vector to transform - * @param {mat2d} m matrix to transform with - * @returns {vec2} out - */ -function transformMat2d(out, a, m) { - var x = a[0], - y = a[1]; - out[0] = m[0] * x + m[2] * y + m[4]; - out[1] = m[1] * x + m[3] * y + m[5]; - return out; -} - -/** - * Transforms the vec2 with a mat3 - * 3rd vector component is implicitly '1' - * - * @param {vec2} out the receiving vector - * @param {vec2} a the vector to transform - * @param {mat3} m matrix to transform with - * @returns {vec2} out - */ -function transformMat3(out, a, m) { - var x = a[0], - y = a[1]; - out[0] = m[0] * x + m[3] * y + m[6]; - out[1] = m[1] * x + m[4] * y + m[7]; - return out; -} - -/** - * Transforms the vec2 with a mat4 - * 3rd vector component is implicitly '0' - * 4th vector component is implicitly '1' - * - * @param {vec2} out the receiving vector - * @param {vec2} a the vector to transform - * @param {mat4} m matrix to transform with - * @returns {vec2} out - */ -function transformMat4(out, a, m) { - let x = a[0]; - let y = a[1]; - out[0] = m[0] * x + m[4] * y + m[12]; - out[1] = m[1] * x + m[5] * y + m[13]; - return out; -} - -/** - * Rotate a 2D vector - * @param {vec2} out The receiving vec2 - * @param {vec2} a The vec2 point to rotate - * @param {vec2} b The origin of the rotation - * @param {Number} c The angle of rotation - * @returns {vec2} out - */ -function rotate(out, a, b, c) { - //Translate point to the origin - let p0 = a[0] - b[0], - p1 = a[1] - b[1], - sinC = Math.sin(c), - cosC = Math.cos(c); - - //perform rotation and translate to correct position - out[0] = p0*cosC - p1*sinC + b[0]; - out[1] = p0*sinC + p1*cosC + b[1]; - - return out; -} - -/** - * Get the angle between two 2D vectors - * @param {vec2} a The first operand - * @param {vec2} b The second operand - * @returns {Number} The angle in radians - */ -function angle(a, b) { - let x1 = a[0], - y1 = a[1], - x2 = b[0], - y2 = b[1]; - - let len1 = x1*x1 + y1*y1; - if (len1 > 0) { - //TODO: evaluate use of glm_invsqrt here? - len1 = 1 / Math.sqrt(len1); - } - - let len2 = x2*x2 + y2*y2; - if (len2 > 0) { - //TODO: evaluate use of glm_invsqrt here? - len2 = 1 / Math.sqrt(len2); - } - - let cosine = (x1 * x2 + y1 * y2) * len1 * len2; - - - if(cosine > 1.0) { - return 0; - } - else if(cosine < -1.0) { - return Math.PI; - } else { - return Math.acos(cosine); - } -} - -/** - * Returns a string representation of a vector - * - * @param {vec2} a vector to represent as a string - * @returns {String} string representation of the vector - */ -function str(a) { - return 'vec2(' + a[0] + ', ' + a[1] + ')'; -} - -/** - * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===) - * - * @param {vec2} a The first vector. - * @param {vec2} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1]; -} - -/** - * Returns whether or not the vectors have approximately the same elements in the same position. - * - * @param {vec2} a The first vector. - * @param {vec2} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ -function equals(a, b) { - let a0 = a[0], a1 = a[1]; - let b0 = b[0], b1 = b[1]; - return (Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && - Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1))); -} - -/** - * Alias for {@link vec2.length} - * @function - */ -const len = length; - -/** - * Alias for {@link vec2.subtract} - * @function - */ -const sub = subtract; - -/** - * Alias for {@link vec2.multiply} - * @function - */ -const mul = multiply; - -/** - * Alias for {@link vec2.divide} - * @function - */ -const div = divide; - -/** - * Alias for {@link vec2.distance} - * @function - */ -const dist = distance; - -/** - * Alias for {@link vec2.squaredDistance} - * @function - */ -const sqrDist = squaredDistance; - -/** - * Alias for {@link vec2.squaredLength} - * @function - */ -const sqrLen = squaredLength; - -/** - * Perform some operation over an array of vec2s. - * - * @param {Array} a the array of vectors to iterate over - * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed - * @param {Number} offset Number of elements to skip at the beginning of the array - * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array - * @param {Function} fn Function to call for each vector in the array - * @param {Object} [arg] additional argument to pass to fn - * @returns {Array} a - * @function - */ -const forEach = (function() { - let vec = create(); - - return function(a, stride, offset, count, fn, arg) { - let i, l; - if(!stride) { - stride = 2; - } - - if(!offset) { - offset = 0; - } - - if(count) { - l = Math.min((count * stride) + offset, a.length); - } else { - l = a.length; - } - - for(i = offset; i < l; i += stride) { - vec[0] = a[i]; vec[1] = a[i+1]; - fn(vec, vec, arg); - a[i] = vec[0]; a[i+1] = vec[1]; - } - - return a; - }; -})(); - - -/***/ }), - -/***/ "./node_modules/gl-matrix/src/gl-matrix/vec3.js": -/*!******************************************************!*\ - !*** ./node_modules/gl-matrix/src/gl-matrix/vec3.js ***! - \******************************************************/ -/*! exports provided: create, clone, length, fromValues, copy, set, add, subtract, multiply, divide, ceil, floor, min, max, round, scale, scaleAndAdd, distance, squaredDistance, squaredLength, negate, inverse, normalize, dot, cross, lerp, hermite, bezier, random, transformMat4, transformMat3, transformQuat, rotateX, rotateY, rotateZ, angle, str, exactEquals, equals, sub, mul, div, dist, sqrDist, len, sqrLen, forEach */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "length", function() { return length; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subtract", function() { return subtract; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "divide", function() { return divide; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ceil", function() { return ceil; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "floor", function() { return floor; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "min", function() { return min; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "max", function() { return max; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "round", function() { return round; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scaleAndAdd", function() { return scaleAndAdd; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "distance", function() { return distance; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredDistance", function() { return squaredDistance; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredLength", function() { return squaredLength; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "negate", function() { return negate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "inverse", function() { return inverse; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalize", function() { return normalize; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dot", function() { return dot; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cross", function() { return cross; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lerp", function() { return lerp; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hermite", function() { return hermite; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bezier", function() { return bezier; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "random", function() { return random; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformMat4", function() { return transformMat4; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformMat3", function() { return transformMat3; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformQuat", function() { return transformQuat; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateX", function() { return rotateX; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateY", function() { return rotateY; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateZ", function() { return rotateZ; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "angle", function() { return angle; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "div", function() { return div; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dist", function() { return dist; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrDist", function() { return sqrDist; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "len", function() { return len; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrLen", function() { return sqrLen; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "forEach", function() { return forEach; }); -/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/src/gl-matrix/common.js"); - - -/** - * 3 Dimensional Vector - * @module vec3 - */ - -/** - * Creates a new, empty vec3 - * - * @returns {vec3} a new 3D vector - */ -function create() { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](3); - if(_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - } - return out; -} - -/** - * Creates a new vec3 initialized with values from an existing vector - * - * @param {vec3} a vector to clone - * @returns {vec3} a new 3D vector - */ -function clone(a) { - var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](3); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - return out; -} - -/** - * Calculates the length of a vec3 - * - * @param {vec3} a vector to calculate length of - * @returns {Number} length of a - */ -function length(a) { - let x = a[0]; - let y = a[1]; - let z = a[2]; - return Math.sqrt(x*x + y*y + z*z); -} - -/** - * Creates a new vec3 initialized with the given values - * - * @param {Number} x X component - * @param {Number} y Y component - * @param {Number} z Z component - * @returns {vec3} a new 3D vector - */ -function fromValues(x, y, z) { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](3); - out[0] = x; - out[1] = y; - out[2] = z; - return out; -} - -/** - * Copy the values from one vec3 to another - * - * @param {vec3} out the receiving vector - * @param {vec3} a the source vector - * @returns {vec3} out - */ -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - return out; -} - -/** - * Set the components of a vec3 to the given values - * - * @param {vec3} out the receiving vector - * @param {Number} x X component - * @param {Number} y Y component - * @param {Number} z Z component - * @returns {vec3} out - */ -function set(out, x, y, z) { - out[0] = x; - out[1] = y; - out[2] = z; - return out; -} - -/** - * Adds two vec3's - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {vec3} out - */ -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - return out; -} - -/** - * Subtracts vector b from vector a - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {vec3} out - */ -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - return out; -} - -/** - * Multiplies two vec3's - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {vec3} out - */ -function multiply(out, a, b) { - out[0] = a[0] * b[0]; - out[1] = a[1] * b[1]; - out[2] = a[2] * b[2]; - return out; -} - -/** - * Divides two vec3's - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {vec3} out - */ -function divide(out, a, b) { - out[0] = a[0] / b[0]; - out[1] = a[1] / b[1]; - out[2] = a[2] / b[2]; - return out; -} - -/** - * Math.ceil the components of a vec3 - * - * @param {vec3} out the receiving vector - * @param {vec3} a vector to ceil - * @returns {vec3} out - */ -function ceil(out, a) { - out[0] = Math.ceil(a[0]); - out[1] = Math.ceil(a[1]); - out[2] = Math.ceil(a[2]); - return out; -} - -/** - * Math.floor the components of a vec3 - * - * @param {vec3} out the receiving vector - * @param {vec3} a vector to floor - * @returns {vec3} out - */ -function floor(out, a) { - out[0] = Math.floor(a[0]); - out[1] = Math.floor(a[1]); - out[2] = Math.floor(a[2]); - return out; -} - -/** - * Returns the minimum of two vec3's - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {vec3} out - */ -function min(out, a, b) { - out[0] = Math.min(a[0], b[0]); - out[1] = Math.min(a[1], b[1]); - out[2] = Math.min(a[2], b[2]); - return out; -} - -/** - * Returns the maximum of two vec3's - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {vec3} out - */ -function max(out, a, b) { - out[0] = Math.max(a[0], b[0]); - out[1] = Math.max(a[1], b[1]); - out[2] = Math.max(a[2], b[2]); - return out; -} - -/** - * Math.round the components of a vec3 - * - * @param {vec3} out the receiving vector - * @param {vec3} a vector to round - * @returns {vec3} out - */ -function round(out, a) { - out[0] = Math.round(a[0]); - out[1] = Math.round(a[1]); - out[2] = Math.round(a[2]); - return out; -} - -/** - * Scales a vec3 by a scalar number - * - * @param {vec3} out the receiving vector - * @param {vec3} a the vector to scale - * @param {Number} b amount to scale the vector by - * @returns {vec3} out - */ -function scale(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - return out; -} - -/** - * Adds two vec3's after scaling the second operand by a scalar value - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @param {Number} scale the amount to scale b by before adding - * @returns {vec3} out - */ -function scaleAndAdd(out, a, b, scale) { - out[0] = a[0] + (b[0] * scale); - out[1] = a[1] + (b[1] * scale); - out[2] = a[2] + (b[2] * scale); - return out; -} - -/** - * Calculates the euclidian distance between two vec3's - * - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {Number} distance between a and b - */ -function distance(a, b) { - let x = b[0] - a[0]; - let y = b[1] - a[1]; - let z = b[2] - a[2]; - return Math.sqrt(x*x + y*y + z*z); -} - -/** - * Calculates the squared euclidian distance between two vec3's - * - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {Number} squared distance between a and b - */ -function squaredDistance(a, b) { - let x = b[0] - a[0]; - let y = b[1] - a[1]; - let z = b[2] - a[2]; - return x*x + y*y + z*z; -} - -/** - * Calculates the squared length of a vec3 - * - * @param {vec3} a vector to calculate squared length of - * @returns {Number} squared length of a - */ -function squaredLength(a) { - let x = a[0]; - let y = a[1]; - let z = a[2]; - return x*x + y*y + z*z; -} - -/** - * Negates the components of a vec3 - * - * @param {vec3} out the receiving vector - * @param {vec3} a vector to negate - * @returns {vec3} out - */ -function negate(out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - out[2] = -a[2]; - return out; -} - -/** - * Returns the inverse of the components of a vec3 - * - * @param {vec3} out the receiving vector - * @param {vec3} a vector to invert - * @returns {vec3} out - */ -function inverse(out, a) { - out[0] = 1.0 / a[0]; - out[1] = 1.0 / a[1]; - out[2] = 1.0 / a[2]; - return out; -} - -/** - * Normalize a vec3 - * - * @param {vec3} out the receiving vector - * @param {vec3} a vector to normalize - * @returns {vec3} out - */ -function normalize(out, a) { - let x = a[0]; - let y = a[1]; - let z = a[2]; - let len = x*x + y*y + z*z; - if (len > 0) { - //TODO: evaluate use of glm_invsqrt here? - len = 1 / Math.sqrt(len); - out[0] = a[0] * len; - out[1] = a[1] * len; - out[2] = a[2] * len; - } - return out; -} - -/** - * Calculates the dot product of two vec3's - * - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {Number} dot product of a and b - */ -function dot(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; -} - -/** - * Computes the cross product of two vec3's - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {vec3} out - */ -function cross(out, a, b) { - let ax = a[0], ay = a[1], az = a[2]; - let bx = b[0], by = b[1], bz = b[2]; - - out[0] = ay * bz - az * by; - out[1] = az * bx - ax * bz; - out[2] = ax * by - ay * bx; - return out; -} - -/** - * Performs a linear interpolation between two vec3's - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out - */ -function lerp(out, a, b, t) { - let ax = a[0]; - let ay = a[1]; - let az = a[2]; - out[0] = ax + t * (b[0] - ax); - out[1] = ay + t * (b[1] - ay); - out[2] = az + t * (b[2] - az); - return out; -} - -/** - * Performs a hermite interpolation with two control points - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @param {vec3} c the third operand - * @param {vec3} d the fourth operand - * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out - */ -function hermite(out, a, b, c, d, t) { - let factorTimes2 = t * t; - let factor1 = factorTimes2 * (2 * t - 3) + 1; - let factor2 = factorTimes2 * (t - 2) + t; - let factor3 = factorTimes2 * (t - 1); - let factor4 = factorTimes2 * (3 - 2 * t); - - out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; - out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; - out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; - - return out; -} - -/** - * Performs a bezier interpolation with two control points - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @param {vec3} c the third operand - * @param {vec3} d the fourth operand - * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out - */ -function bezier(out, a, b, c, d, t) { - let inverseFactor = 1 - t; - let inverseFactorTimesTwo = inverseFactor * inverseFactor; - let factorTimes2 = t * t; - let factor1 = inverseFactorTimesTwo * inverseFactor; - let factor2 = 3 * t * inverseFactorTimesTwo; - let factor3 = 3 * factorTimes2 * inverseFactor; - let factor4 = factorTimes2 * t; - - out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; - out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; - out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; - - return out; -} - -/** - * Generates a random vector with the given scale - * - * @param {vec3} out the receiving vector - * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned - * @returns {vec3} out - */ -function random(out, scale) { - scale = scale || 1.0; - - let r = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]() * 2.0 * Math.PI; - let z = (_common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]() * 2.0) - 1.0; - let zScale = Math.sqrt(1.0-z*z) * scale; - - out[0] = Math.cos(r) * zScale; - out[1] = Math.sin(r) * zScale; - out[2] = z * scale; - return out; -} - -/** - * Transforms the vec3 with a mat4. - * 4th vector component is implicitly '1' - * - * @param {vec3} out the receiving vector - * @param {vec3} a the vector to transform - * @param {mat4} m matrix to transform with - * @returns {vec3} out - */ -function transformMat4(out, a, m) { - let x = a[0], y = a[1], z = a[2]; - let w = m[3] * x + m[7] * y + m[11] * z + m[15]; - w = w || 1.0; - out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w; - out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w; - out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w; - return out; -} - -/** - * Transforms the vec3 with a mat3. - * - * @param {vec3} out the receiving vector - * @param {vec3} a the vector to transform - * @param {mat3} m the 3x3 matrix to transform with - * @returns {vec3} out - */ -function transformMat3(out, a, m) { - let x = a[0], y = a[1], z = a[2]; - out[0] = x * m[0] + y * m[3] + z * m[6]; - out[1] = x * m[1] + y * m[4] + z * m[7]; - out[2] = x * m[2] + y * m[5] + z * m[8]; - return out; -} - -/** - * Transforms the vec3 with a quat - * Can also be used for dual quaternions. (Multiply it with the real part) - * - * @param {vec3} out the receiving vector - * @param {vec3} a the vector to transform - * @param {quat} q quaternion to transform with - * @returns {vec3} out - */ -function transformQuat(out, a, q) { - // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed - let qx = q[0], qy = q[1], qz = q[2], qw = q[3]; - let x = a[0], y = a[1], z = a[2]; - // var qvec = [qx, qy, qz]; - // var uv = vec3.cross([], qvec, a); - let uvx = qy * z - qz * y, - uvy = qz * x - qx * z, - uvz = qx * y - qy * x; - // var uuv = vec3.cross([], qvec, uv); - let uuvx = qy * uvz - qz * uvy, - uuvy = qz * uvx - qx * uvz, - uuvz = qx * uvy - qy * uvx; - // vec3.scale(uv, uv, 2 * w); - let w2 = qw * 2; - uvx *= w2; - uvy *= w2; - uvz *= w2; - // vec3.scale(uuv, uuv, 2); - uuvx *= 2; - uuvy *= 2; - uuvz *= 2; - // return vec3.add(out, a, vec3.add(out, uv, uuv)); - out[0] = x + uvx + uuvx; - out[1] = y + uvy + uuvy; - out[2] = z + uvz + uuvz; - return out; -} - -/** - * Rotate a 3D vector around the x-axis - * @param {vec3} out The receiving vec3 - * @param {vec3} a The vec3 point to rotate - * @param {vec3} b The origin of the rotation - * @param {Number} c The angle of rotation - * @returns {vec3} out - */ -function rotateX(out, a, b, c){ - let p = [], r=[]; - //Translate point to the origin - p[0] = a[0] - b[0]; - p[1] = a[1] - b[1]; - p[2] = a[2] - b[2]; - - //perform rotation - r[0] = p[0]; - r[1] = p[1]*Math.cos(c) - p[2]*Math.sin(c); - r[2] = p[1]*Math.sin(c) + p[2]*Math.cos(c); - - //translate to correct position - out[0] = r[0] + b[0]; - out[1] = r[1] + b[1]; - out[2] = r[2] + b[2]; - - return out; -} - -/** - * Rotate a 3D vector around the y-axis - * @param {vec3} out The receiving vec3 - * @param {vec3} a The vec3 point to rotate - * @param {vec3} b The origin of the rotation - * @param {Number} c The angle of rotation - * @returns {vec3} out - */ -function rotateY(out, a, b, c){ - let p = [], r=[]; - //Translate point to the origin - p[0] = a[0] - b[0]; - p[1] = a[1] - b[1]; - p[2] = a[2] - b[2]; - - //perform rotation - r[0] = p[2]*Math.sin(c) + p[0]*Math.cos(c); - r[1] = p[1]; - r[2] = p[2]*Math.cos(c) - p[0]*Math.sin(c); - - //translate to correct position - out[0] = r[0] + b[0]; - out[1] = r[1] + b[1]; - out[2] = r[2] + b[2]; - - return out; -} - -/** - * Rotate a 3D vector around the z-axis - * @param {vec3} out The receiving vec3 - * @param {vec3} a The vec3 point to rotate - * @param {vec3} b The origin of the rotation - * @param {Number} c The angle of rotation - * @returns {vec3} out - */ -function rotateZ(out, a, b, c){ - let p = [], r=[]; - //Translate point to the origin - p[0] = a[0] - b[0]; - p[1] = a[1] - b[1]; - p[2] = a[2] - b[2]; - - //perform rotation - r[0] = p[0]*Math.cos(c) - p[1]*Math.sin(c); - r[1] = p[0]*Math.sin(c) + p[1]*Math.cos(c); - r[2] = p[2]; - - //translate to correct position - out[0] = r[0] + b[0]; - out[1] = r[1] + b[1]; - out[2] = r[2] + b[2]; - - return out; -} - -/** - * Get the angle between two 3D vectors - * @param {vec3} a The first operand - * @param {vec3} b The second operand - * @returns {Number} The angle in radians - */ -function angle(a, b) { - let tempA = fromValues(a[0], a[1], a[2]); - let tempB = fromValues(b[0], b[1], b[2]); - - normalize(tempA, tempA); - normalize(tempB, tempB); - - let cosine = dot(tempA, tempB); - - if(cosine > 1.0) { - return 0; - } - else if(cosine < -1.0) { - return Math.PI; - } else { - return Math.acos(cosine); - } -} - -/** - * Returns a string representation of a vector - * - * @param {vec3} a vector to represent as a string - * @returns {String} string representation of the vector - */ -function str(a) { - return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')'; -} - -/** - * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) - * - * @param {vec3} a The first vector. - * @param {vec3} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2]; -} - -/** - * Returns whether or not the vectors have approximately the same elements in the same position. - * - * @param {vec3} a The first vector. - * @param {vec3} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ -function equals(a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2]; - let b0 = b[0], b1 = b[1], b2 = b[2]; - return (Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && - Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && - Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2))); -} - -/** - * Alias for {@link vec3.subtract} - * @function - */ -const sub = subtract; - -/** - * Alias for {@link vec3.multiply} - * @function - */ -const mul = multiply; - -/** - * Alias for {@link vec3.divide} - * @function - */ -const div = divide; - -/** - * Alias for {@link vec3.distance} - * @function - */ -const dist = distance; - -/** - * Alias for {@link vec3.squaredDistance} - * @function - */ -const sqrDist = squaredDistance; - -/** - * Alias for {@link vec3.length} - * @function - */ -const len = length; - -/** - * Alias for {@link vec3.squaredLength} - * @function - */ -const sqrLen = squaredLength; - -/** - * Perform some operation over an array of vec3s. - * - * @param {Array} a the array of vectors to iterate over - * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed - * @param {Number} offset Number of elements to skip at the beginning of the array - * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array - * @param {Function} fn Function to call for each vector in the array - * @param {Object} [arg] additional argument to pass to fn - * @returns {Array} a - * @function - */ -const forEach = (function() { - let vec = create(); - - return function(a, stride, offset, count, fn, arg) { - let i, l; - if(!stride) { - stride = 3; - } - - if(!offset) { - offset = 0; - } - - if(count) { - l = Math.min((count * stride) + offset, a.length); - } else { - l = a.length; - } - - for(i = offset; i < l; i += stride) { - vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2]; - fn(vec, vec, arg); - a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2]; - } - - return a; - }; -})(); - - -/***/ }), - -/***/ "./node_modules/gl-matrix/src/gl-matrix/vec4.js": -/*!******************************************************!*\ - !*** ./node_modules/gl-matrix/src/gl-matrix/vec4.js ***! - \******************************************************/ -/*! exports provided: create, clone, fromValues, copy, set, add, subtract, multiply, divide, ceil, floor, min, max, round, scale, scaleAndAdd, distance, squaredDistance, length, squaredLength, negate, inverse, normalize, dot, lerp, random, transformMat4, transformQuat, str, exactEquals, equals, sub, mul, div, dist, sqrDist, len, sqrLen, forEach */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subtract", function() { return subtract; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "divide", function() { return divide; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ceil", function() { return ceil; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "floor", function() { return floor; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "min", function() { return min; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "max", function() { return max; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "round", function() { return round; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scaleAndAdd", function() { return scaleAndAdd; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "distance", function() { return distance; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredDistance", function() { return squaredDistance; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "length", function() { return length; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredLength", function() { return squaredLength; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "negate", function() { return negate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "inverse", function() { return inverse; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalize", function() { return normalize; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dot", function() { return dot; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lerp", function() { return lerp; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "random", function() { return random; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformMat4", function() { return transformMat4; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformQuat", function() { return transformQuat; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "div", function() { return div; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dist", function() { return dist; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrDist", function() { return sqrDist; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "len", function() { return len; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrLen", function() { return sqrLen; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "forEach", function() { return forEach; }); -/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/src/gl-matrix/common.js"); - - -/** - * 4 Dimensional Vector - * @module vec4 - */ - -/** - * Creates a new, empty vec4 - * - * @returns {vec4} a new 4D vector - */ -function create() { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](4); - if(_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 0; - } - return out; -} - -/** - * Creates a new vec4 initialized with values from an existing vector - * - * @param {vec4} a vector to clone - * @returns {vec4} a new 4D vector - */ -function clone(a) { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](4); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - return out; -} - -/** - * Creates a new vec4 initialized with the given values - * - * @param {Number} x X component - * @param {Number} y Y component - * @param {Number} z Z component - * @param {Number} w W component - * @returns {vec4} a new 4D vector - */ -function fromValues(x, y, z, w) { - let out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](4); - out[0] = x; - out[1] = y; - out[2] = z; - out[3] = w; - return out; -} - -/** - * Copy the values from one vec4 to another - * - * @param {vec4} out the receiving vector - * @param {vec4} a the source vector - * @returns {vec4} out - */ -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - return out; -} - -/** - * Set the components of a vec4 to the given values - * - * @param {vec4} out the receiving vector - * @param {Number} x X component - * @param {Number} y Y component - * @param {Number} z Z component - * @param {Number} w W component - * @returns {vec4} out - */ -function set(out, x, y, z, w) { - out[0] = x; - out[1] = y; - out[2] = z; - out[3] = w; - return out; -} - -/** - * Adds two vec4's - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {vec4} out - */ -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - out[3] = a[3] + b[3]; - return out; -} - -/** - * Subtracts vector b from vector a - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {vec4} out - */ -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - out[3] = a[3] - b[3]; - return out; -} - -/** - * Multiplies two vec4's - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {vec4} out - */ -function multiply(out, a, b) { - out[0] = a[0] * b[0]; - out[1] = a[1] * b[1]; - out[2] = a[2] * b[2]; - out[3] = a[3] * b[3]; - return out; -} - -/** - * Divides two vec4's - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {vec4} out - */ -function divide(out, a, b) { - out[0] = a[0] / b[0]; - out[1] = a[1] / b[1]; - out[2] = a[2] / b[2]; - out[3] = a[3] / b[3]; - return out; -} - -/** - * Math.ceil the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {vec4} a vector to ceil - * @returns {vec4} out - */ -function ceil(out, a) { - out[0] = Math.ceil(a[0]); - out[1] = Math.ceil(a[1]); - out[2] = Math.ceil(a[2]); - out[3] = Math.ceil(a[3]); - return out; -} - -/** - * Math.floor the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {vec4} a vector to floor - * @returns {vec4} out - */ -function floor(out, a) { - out[0] = Math.floor(a[0]); - out[1] = Math.floor(a[1]); - out[2] = Math.floor(a[2]); - out[3] = Math.floor(a[3]); - return out; -} - -/** - * Returns the minimum of two vec4's - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {vec4} out - */ -function min(out, a, b) { - out[0] = Math.min(a[0], b[0]); - out[1] = Math.min(a[1], b[1]); - out[2] = Math.min(a[2], b[2]); - out[3] = Math.min(a[3], b[3]); - return out; -} - -/** - * Returns the maximum of two vec4's - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {vec4} out - */ -function max(out, a, b) { - out[0] = Math.max(a[0], b[0]); - out[1] = Math.max(a[1], b[1]); - out[2] = Math.max(a[2], b[2]); - out[3] = Math.max(a[3], b[3]); - return out; -} - -/** - * Math.round the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {vec4} a vector to round - * @returns {vec4} out - */ -function round(out, a) { - out[0] = Math.round(a[0]); - out[1] = Math.round(a[1]); - out[2] = Math.round(a[2]); - out[3] = Math.round(a[3]); - return out; -} - -/** - * Scales a vec4 by a scalar number - * - * @param {vec4} out the receiving vector - * @param {vec4} a the vector to scale - * @param {Number} b amount to scale the vector by - * @returns {vec4} out - */ -function scale(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; - return out; -} - -/** - * Adds two vec4's after scaling the second operand by a scalar value - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @param {Number} scale the amount to scale b by before adding - * @returns {vec4} out - */ -function scaleAndAdd(out, a, b, scale) { - out[0] = a[0] + (b[0] * scale); - out[1] = a[1] + (b[1] * scale); - out[2] = a[2] + (b[2] * scale); - out[3] = a[3] + (b[3] * scale); - return out; -} - -/** - * Calculates the euclidian distance between two vec4's - * - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {Number} distance between a and b - */ -function distance(a, b) { - let x = b[0] - a[0]; - let y = b[1] - a[1]; - let z = b[2] - a[2]; - let w = b[3] - a[3]; - return Math.sqrt(x*x + y*y + z*z + w*w); -} - -/** - * Calculates the squared euclidian distance between two vec4's - * - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {Number} squared distance between a and b - */ -function squaredDistance(a, b) { - let x = b[0] - a[0]; - let y = b[1] - a[1]; - let z = b[2] - a[2]; - let w = b[3] - a[3]; - return x*x + y*y + z*z + w*w; -} - -/** - * Calculates the length of a vec4 - * - * @param {vec4} a vector to calculate length of - * @returns {Number} length of a - */ -function length(a) { - let x = a[0]; - let y = a[1]; - let z = a[2]; - let w = a[3]; - return Math.sqrt(x*x + y*y + z*z + w*w); -} - -/** - * Calculates the squared length of a vec4 - * - * @param {vec4} a vector to calculate squared length of - * @returns {Number} squared length of a - */ -function squaredLength(a) { - let x = a[0]; - let y = a[1]; - let z = a[2]; - let w = a[3]; - return x*x + y*y + z*z + w*w; -} - -/** - * Negates the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {vec4} a vector to negate - * @returns {vec4} out - */ -function negate(out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - out[2] = -a[2]; - out[3] = -a[3]; - return out; -} - -/** - * Returns the inverse of the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {vec4} a vector to invert - * @returns {vec4} out - */ -function inverse(out, a) { - out[0] = 1.0 / a[0]; - out[1] = 1.0 / a[1]; - out[2] = 1.0 / a[2]; - out[3] = 1.0 / a[3]; - return out; -} - -/** - * Normalize a vec4 - * - * @param {vec4} out the receiving vector - * @param {vec4} a vector to normalize - * @returns {vec4} out - */ -function normalize(out, a) { - let x = a[0]; - let y = a[1]; - let z = a[2]; - let w = a[3]; - let len = x*x + y*y + z*z + w*w; - if (len > 0) { - len = 1 / Math.sqrt(len); - out[0] = x * len; - out[1] = y * len; - out[2] = z * len; - out[3] = w * len; - } - return out; -} - -/** - * Calculates the dot product of two vec4's - * - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {Number} dot product of a and b - */ -function dot(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; -} - -/** - * Performs a linear interpolation between two vec4's - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec4} out - */ -function lerp(out, a, b, t) { - let ax = a[0]; - let ay = a[1]; - let az = a[2]; - let aw = a[3]; - out[0] = ax + t * (b[0] - ax); - out[1] = ay + t * (b[1] - ay); - out[2] = az + t * (b[2] - az); - out[3] = aw + t * (b[3] - aw); - return out; -} - -/** - * Generates a random vector with the given scale - * - * @param {vec4} out the receiving vector - * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned - * @returns {vec4} out - */ -function random(out, scale) { - scale = scale || 1.0; - - // Marsaglia, George. Choosing a Point from the Surface of a - // Sphere. Ann. Math. Statist. 43 (1972), no. 2, 645--646. - // http://projecteuclid.org/euclid.aoms/1177692644; - var v1, v2, v3, v4; - var s1, s2; - do { - v1 = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]() * 2 - 1; - v2 = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]() * 2 - 1; - s1 = v1 * v1 + v2 * v2; - } while (s1 >= 1); - do { - v3 = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]() * 2 - 1; - v4 = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]() * 2 - 1; - s2 = v3 * v3 + v4 * v4; - } while (s2 >= 1); - - var d = Math.sqrt((1 - s1) / s2); - out[0] = scale * v1; - out[1] = scale * v2; - out[2] = scale * v3 * d; - out[3] = scale * v4 * d; - return out; -} - -/** - * Transforms the vec4 with a mat4. - * - * @param {vec4} out the receiving vector - * @param {vec4} a the vector to transform - * @param {mat4} m matrix to transform with - * @returns {vec4} out - */ -function transformMat4(out, a, m) { - let x = a[0], y = a[1], z = a[2], w = a[3]; - out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w; - out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w; - out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w; - out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w; - return out; -} - -/** - * Transforms the vec4 with a quat - * - * @param {vec4} out the receiving vector - * @param {vec4} a the vector to transform - * @param {quat} q quaternion to transform with - * @returns {vec4} out - */ -function transformQuat(out, a, q) { - let x = a[0], y = a[1], z = a[2]; - let qx = q[0], qy = q[1], qz = q[2], qw = q[3]; - - // calculate quat * vec - let ix = qw * x + qy * z - qz * y; - let iy = qw * y + qz * x - qx * z; - let iz = qw * z + qx * y - qy * x; - let iw = -qx * x - qy * y - qz * z; - - // calculate result * inverse quat - out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy; - out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz; - out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx; - out[3] = a[3]; - return out; -} - -/** - * Returns a string representation of a vector - * - * @param {vec4} a vector to represent as a string - * @returns {String} string representation of the vector - */ -function str(a) { - return 'vec4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')'; -} - -/** - * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) - * - * @param {vec4} a The first vector. - * @param {vec4} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; -} - -/** - * Returns whether or not the vectors have approximately the same elements in the same position. - * - * @param {vec4} a The first vector. - * @param {vec4} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ -function equals(a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - return (Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && - Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && - Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && - Math.abs(a3 - b3) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]*Math.max(1.0, Math.abs(a3), Math.abs(b3))); -} - -/** - * Alias for {@link vec4.subtract} - * @function - */ -const sub = subtract; - -/** - * Alias for {@link vec4.multiply} - * @function - */ -const mul = multiply; - -/** - * Alias for {@link vec4.divide} - * @function - */ -const div = divide; - -/** - * Alias for {@link vec4.distance} - * @function - */ -const dist = distance; - -/** - * Alias for {@link vec4.squaredDistance} - * @function - */ -const sqrDist = squaredDistance; - -/** - * Alias for {@link vec4.length} - * @function - */ -const len = length; - -/** - * Alias for {@link vec4.squaredLength} - * @function - */ -const sqrLen = squaredLength; - -/** - * Perform some operation over an array of vec4s. - * - * @param {Array} a the array of vectors to iterate over - * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed - * @param {Number} offset Number of elements to skip at the beginning of the array - * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array - * @param {Function} fn Function to call for each vector in the array - * @param {Object} [arg] additional argument to pass to fn - * @returns {Array} a - * @function - */ -const forEach = (function() { - let vec = create(); - - return function(a, stride, offset, count, fn, arg) { - let i, l; - if(!stride) { - stride = 4; - } - - if(!offset) { - offset = 0; - } - - if(count) { - l = Math.min((count * stride) + offset, a.length); - } else { - l = a.length; - } - - for(i = offset; i < l; i += stride) { - vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2]; vec[3] = a[i+3]; - fn(vec, vec, arg); - a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2]; a[i+3] = vec[3]; - } - - return a; - }; -})(); - - -/***/ }), - -/***/ "./src/core/material.js": -/*!******************************!*\ - !*** ./src/core/material.js ***! - \******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -exports.stateToBlendFunc = stateToBlendFunc; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -// Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var GL = WebGLRenderingContext; // For enums - -var CAP = exports.CAP = { - // Enable caps - CULL_FACE: 0x001, - BLEND: 0x002, - DEPTH_TEST: 0x004, - STENCIL_TEST: 0x008, - COLOR_MASK: 0x010, - DEPTH_MASK: 0x020, - STENCIL_MASK: 0x040 -}; - -var MAT_STATE = exports.MAT_STATE = { - CAPS_RANGE: 0x000000FF, - BLEND_SRC_SHIFT: 8, - BLEND_SRC_RANGE: 0x00000F00, - BLEND_DST_SHIFT: 12, - BLEND_DST_RANGE: 0x0000F000, - BLEND_FUNC_RANGE: 0x0000FF00, - DEPTH_FUNC_SHIFT: 16, - DEPTH_FUNC_RANGE: 0x000F0000 -}; - -var RENDER_ORDER = exports.RENDER_ORDER = { - // Render opaque objects first. - OPAQUE: 0, - - // Render the sky after all opaque object to save fill rate. - SKY: 1, - - // Render transparent objects next so that the opaqe objects show through. - TRANSPARENT: 2, - - // Finally render purely additive effects like pointer rays so that they - // can render without depth mask. - ADDITIVE: 3, - - // Render order will be picked based on the material properties. - DEFAULT: 4 -}; - -function stateToBlendFunc(state, mask, shift) { - var value = (state & mask) >> shift; - switch (value) { - case 0: - case 1: - return value; - default: - return value - 2 + GL.SRC_COLOR; - } -} - -var MaterialState = exports.MaterialState = function () { - function MaterialState() { - _classCallCheck(this, MaterialState); - - this._state = CAP.CULL_FACE | CAP.DEPTH_TEST | CAP.COLOR_MASK | CAP.DEPTH_MASK; - - // Use a fairly commonly desired blend func as the default. - this.blendFuncSrc = GL.SRC_ALPHA; - this.blendFuncDst = GL.ONE_MINUS_SRC_ALPHA; - - this.depthFunc = GL.LESS; - } - - _createClass(MaterialState, [{ - key: "cullFace", - get: function get() { - return !!(this._state & CAP.CULL_FACE); - }, - set: function set(value) { - if (value) { - this._state |= CAP.CULL_FACE; - } else { - this._state &= ~CAP.CULL_FACE; - } - } - }, { - key: "blend", - get: function get() { - return !!(this._state & CAP.BLEND); - }, - set: function set(value) { - if (value) { - this._state |= CAP.BLEND; - } else { - this._state &= ~CAP.BLEND; - } - } - }, { - key: "depthTest", - get: function get() { - return !!(this._state & CAP.DEPTH_TEST); - }, - set: function set(value) { - if (value) { - this._state |= CAP.DEPTH_TEST; - } else { - this._state &= ~CAP.DEPTH_TEST; - } - } - }, { - key: "stencilTest", - get: function get() { - return !!(this._state & CAP.STENCIL_TEST); - }, - set: function set(value) { - if (value) { - this._state |= CAP.STENCIL_TEST; - } else { - this._state &= ~CAP.STENCIL_TEST; - } - } - }, { - key: "colorMask", - get: function get() { - return !!(this._state & CAP.COLOR_MASK); - }, - set: function set(value) { - if (value) { - this._state |= CAP.COLOR_MASK; - } else { - this._state &= ~CAP.COLOR_MASK; - } - } - }, { - key: "depthMask", - get: function get() { - return !!(this._state & CAP.DEPTH_MASK); - }, - set: function set(value) { - if (value) { - this._state |= CAP.DEPTH_MASK; - } else { - this._state &= ~CAP.DEPTH_MASK; - } - } - }, { - key: "depthFunc", - get: function get() { - return ((this._state & MAT_STATE.DEPTH_FUNC_RANGE) >> MAT_STATE.DEPTH_FUNC_SHIFT) + GL.NEVER; - }, - set: function set(value) { - value = value - GL.NEVER; - this._state &= ~MAT_STATE.DEPTH_FUNC_RANGE; - this._state |= value << MAT_STATE.DEPTH_FUNC_SHIFT; - } - }, { - key: "stencilMask", - get: function get() { - return !!(this._state & CAP.STENCIL_MASK); - }, - set: function set(value) { - if (value) { - this._state |= CAP.STENCIL_MASK; - } else { - this._state &= ~CAP.STENCIL_MASK; - } - } - }, { - key: "blendFuncSrc", - get: function get() { - return stateToBlendFunc(this._state, MAT_STATE.BLEND_SRC_RANGE, MAT_STATE.BLEND_SRC_SHIFT); - }, - set: function set(value) { - switch (value) { - case 0: - case 1: - break; - default: - value = value - GL.SRC_COLOR + 2; - } - this._state &= ~MAT_STATE.BLEND_SRC_RANGE; - this._state |= value << MAT_STATE.BLEND_SRC_SHIFT; - } - }, { - key: "blendFuncDst", - get: function get() { - return stateToBlendFunc(this._state, MAT_STATE.BLEND_DST_RANGE, MAT_STATE.BLEND_DST_SHIFT); - }, - set: function set(value) { - switch (value) { - case 0: - case 1: - break; - default: - value = value - GL.SRC_COLOR + 2; - } - this._state &= ~MAT_STATE.BLEND_DST_RANGE; - this._state |= value << MAT_STATE.BLEND_DST_SHIFT; - } - }]); - - return MaterialState; -}(); - -var MaterialSampler = function () { - function MaterialSampler(uniformName) { - _classCallCheck(this, MaterialSampler); - - this._uniformName = uniformName; - this._texture = null; - } - - _createClass(MaterialSampler, [{ - key: "texture", - get: function get() { - return this._texture; - }, - set: function set(value) { - this._texture = value; - } - }]); - - return MaterialSampler; -}(); - -var MaterialUniform = function () { - function MaterialUniform(uniformName, defaultValue, length) { - _classCallCheck(this, MaterialUniform); - - this._uniformName = uniformName; - this._value = defaultValue; - this._length = length; - if (!this._length) { - if (defaultValue instanceof Array) { - this._length = defaultValue.length; - } else { - this._length = 1; - } - } - } - - _createClass(MaterialUniform, [{ - key: "value", - get: function get() { - return this._value; - }, - set: function set(value) { - this._value = value; - } - }]); - - return MaterialUniform; -}(); - -var Material = exports.Material = function () { - function Material() { - _classCallCheck(this, Material); - - this.state = new MaterialState(); - this.renderOrder = RENDER_ORDER.DEFAULT; - this._samplers = []; - this._uniforms = []; - } - - _createClass(Material, [{ - key: "defineSampler", - value: function defineSampler(uniformName) { - var sampler = new MaterialSampler(uniformName); - this._samplers.push(sampler); - return sampler; - } - }, { - key: "defineUniform", - value: function defineUniform(uniformName) { - var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - var length = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - - var uniform = new MaterialUniform(uniformName, defaultValue, length); - this._uniforms.push(uniform); - return uniform; - } - }, { - key: "getProgramDefines", - value: function getProgramDefines(renderPrimitive) { - return {}; - } - }, { - key: "materialName", - get: function get() { - return null; - } - }, { - key: "vertexSource", - get: function get() { - return null; - } - }, { - key: "fragmentSource", - get: function get() { - return null; - } - }]); - - return Material; -}(); - -/***/ }), - -/***/ "./src/core/node.js": -/*!**************************!*\ - !*** ./src/core/node.js ***! - \**************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Node = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var _ray = __webpack_require__(/*! ../math/ray.js */ "./src/math/ray.js"); - -var _glMatrix = __webpack_require__(/*! ../math/gl-matrix.js */ "./src/math/gl-matrix.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var DEFAULT_TRANSLATION = new Float32Array([0, 0, 0]); -var DEFAULT_ROTATION = new Float32Array([0, 0, 0, 1]); -var DEFAULT_SCALE = new Float32Array([1, 1, 1]); - -var tmpRayMatrix = _glMatrix.mat4.create(); - -var Node = exports.Node = function () { - function Node() { - _classCallCheck(this, Node); - - this.name = null; // Only for debugging - this.children = []; - this.parent = null; - this.visible = true; - this.selectable = false; - - this._matrix = null; - - this._dirtyTRS = false; - this._translation = null; - this._rotation = null; - this._scale = null; - - this._dirtyWorldMatrix = false; - this._worldMatrix = null; - - this._activeFrameId = -1; - this._hoverFrameId = -1; - this._renderPrimitives = null; - this._renderer = null; - - this._selectHandler = null; - } - - _createClass(Node, [{ - key: '_setRenderer', - value: function _setRenderer(renderer) { - if (this._renderer == renderer) { - return; - } - - if (this._renderer) { - // Changing the renderer removes any previously attached renderPrimitives - // from a different renderer. - this.clearRenderPrimitives(); - } - - this._renderer = renderer; - if (renderer) { - this.onRendererChanged(renderer); - - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = this.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var child = _step.value; - - child._setRenderer(renderer); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - } - } - }, { - key: 'onRendererChanged', - value: function onRendererChanged(renderer) {} - // Override in other node types to respond to changes in the renderer. - - - // Create a clone of this node and all of it's children. Does not duplicate - // RenderPrimitives, the cloned nodes will be treated as new instances of the - // geometry. - - }, { - key: 'clone', - value: function clone() { - var _this = this; - - var cloneNode = new Node(); - cloneNode.name = this.name; - cloneNode.visible = this.visible; - cloneNode._renderer = this._renderer; - - cloneNode._dirtyTRS = this._dirtyTRS; - - if (this._translation) { - cloneNode._translation = _glMatrix.vec3.create(); - _glMatrix.vec3.copy(cloneNode._translation, this._translation); - } - - if (this._rotation) { - cloneNode._rotation = _glMatrix.quat.create(); - _glMatrix.quat.copy(cloneNode._rotation, this._rotation); - } - - if (this._scale) { - cloneNode._scale = _glMatrix.vec3.create(); - _glMatrix.vec3.copy(cloneNode._scale, this._scale); - } - - // Only copy the matrices if they're not already dirty. - if (!cloneNode._dirtyTRS && this._matrix) { - cloneNode._matrix = _glMatrix.mat4.create(); - _glMatrix.mat4.copy(cloneNode._matrix, this._matrix); - } - - cloneNode._dirtyWorldMatrix = this._dirtyWorldMatrix; - if (!cloneNode._dirtyWorldMatrix && this._worldMatrix) { - cloneNode._worldMatrix = _glMatrix.mat4.create(); - _glMatrix.mat4.copy(cloneNode._worldMatrix, this._worldMatrix); - } - - this.waitForComplete().then(function () { - if (_this._renderPrimitives) { - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; - - try { - for (var _iterator2 = _this._renderPrimitives[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var primitive = _step2.value; - - cloneNode.addRenderPrimitive(primitive); - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } - } - - var _iteratorNormalCompletion3 = true; - var _didIteratorError3 = false; - var _iteratorError3 = undefined; - - try { - for (var _iterator3 = _this.children[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { - var child = _step3.value; - - cloneNode.addNode(child.clone()); - } - } catch (err) { - _didIteratorError3 = true; - _iteratorError3 = err; - } finally { - try { - if (!_iteratorNormalCompletion3 && _iterator3.return) { - _iterator3.return(); - } - } finally { - if (_didIteratorError3) { - throw _iteratorError3; - } - } - } - }); - - return cloneNode; - } - }, { - key: 'markActive', - value: function markActive(frameId) { - if (this.visible && this._renderPrimitives) { - this._activeFrameId = frameId; - var _iteratorNormalCompletion4 = true; - var _didIteratorError4 = false; - var _iteratorError4 = undefined; - - try { - for (var _iterator4 = this._renderPrimitives[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { - var primitive = _step4.value; - - primitive.markActive(frameId); - } - } catch (err) { - _didIteratorError4 = true; - _iteratorError4 = err; - } finally { - try { - if (!_iteratorNormalCompletion4 && _iterator4.return) { - _iterator4.return(); - } - } finally { - if (_didIteratorError4) { - throw _iteratorError4; - } - } - } - } - - var _iteratorNormalCompletion5 = true; - var _didIteratorError5 = false; - var _iteratorError5 = undefined; - - try { - for (var _iterator5 = this.children[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { - var child = _step5.value; - - if (child.visible) { - child.markActive(frameId); - } - } - } catch (err) { - _didIteratorError5 = true; - _iteratorError5 = err; - } finally { - try { - if (!_iteratorNormalCompletion5 && _iterator5.return) { - _iterator5.return(); - } - } finally { - if (_didIteratorError5) { - throw _iteratorError5; - } - } - } - } - }, { - key: 'addNode', - value: function addNode(value) { - if (!value || value.parent == this) { - return; - } - - if (value.parent) { - value.parent.removeNode(value); - } - value.parent = this; - - this.children.push(value); - - if (this._renderer) { - value._setRenderer(this._renderer); - } - } - }, { - key: 'removeNode', - value: function removeNode(value) { - var i = this.children.indexOf(value); - if (i > -1) { - this.children.splice(i, 1); - value.parent = null; - } - } - }, { - key: 'clearNodes', - value: function clearNodes() { - var _iteratorNormalCompletion6 = true; - var _didIteratorError6 = false; - var _iteratorError6 = undefined; - - try { - for (var _iterator6 = this.children[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) { - var child = _step6.value; - - child.parent = null; - } - } catch (err) { - _didIteratorError6 = true; - _iteratorError6 = err; - } finally { - try { - if (!_iteratorNormalCompletion6 && _iterator6.return) { - _iterator6.return(); - } - } finally { - if (_didIteratorError6) { - throw _iteratorError6; - } - } - } - - this.children = []; - } - }, { - key: 'setMatrixDirty', - value: function setMatrixDirty() { - if (!this._dirtyWorldMatrix) { - this._dirtyWorldMatrix = true; - var _iteratorNormalCompletion7 = true; - var _didIteratorError7 = false; - var _iteratorError7 = undefined; - - try { - for (var _iterator7 = this.children[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) { - var child = _step7.value; - - child.setMatrixDirty(); - } - } catch (err) { - _didIteratorError7 = true; - _iteratorError7 = err; - } finally { - try { - if (!_iteratorNormalCompletion7 && _iterator7.return) { - _iterator7.return(); - } - } finally { - if (_didIteratorError7) { - throw _iteratorError7; - } - } - } - } - } - }, { - key: '_updateLocalMatrix', - value: function _updateLocalMatrix() { - if (!this._matrix) { - this._matrix = _glMatrix.mat4.create(); - } - - if (this._dirtyTRS) { - this._dirtyTRS = false; - _glMatrix.mat4.fromRotationTranslationScale(this._matrix, this._rotation || DEFAULT_ROTATION, this._translation || DEFAULT_TRANSLATION, this._scale || DEFAULT_SCALE); - } - - return this._matrix; - } - }, { - key: 'waitForComplete', - value: function waitForComplete() { - var _this2 = this; - - var childPromises = []; - var _iteratorNormalCompletion8 = true; - var _didIteratorError8 = false; - var _iteratorError8 = undefined; - - try { - for (var _iterator8 = this.children[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) { - var child = _step8.value; - - childPromises.push(child.waitForComplete()); - } - } catch (err) { - _didIteratorError8 = true; - _iteratorError8 = err; - } finally { - try { - if (!_iteratorNormalCompletion8 && _iterator8.return) { - _iterator8.return(); - } - } finally { - if (_didIteratorError8) { - throw _iteratorError8; - } - } - } - - if (this._renderPrimitives) { - var _iteratorNormalCompletion9 = true; - var _didIteratorError9 = false; - var _iteratorError9 = undefined; - - try { - for (var _iterator9 = this._renderPrimitives[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) { - var primitive = _step9.value; - - childPromises.push(primitive.waitForComplete()); - } - } catch (err) { - _didIteratorError9 = true; - _iteratorError9 = err; - } finally { - try { - if (!_iteratorNormalCompletion9 && _iterator9.return) { - _iterator9.return(); - } - } finally { - if (_didIteratorError9) { - throw _iteratorError9; - } - } - } - } - return Promise.all(childPromises).then(function () { - return _this2; - }); - } - }, { - key: 'addRenderPrimitive', - value: function addRenderPrimitive(primitive) { - if (!this._renderPrimitives) { - this._renderPrimitives = [primitive]; - } else { - this._renderPrimitives.push(primitive); - } - primitive._instances.push(this); - } - }, { - key: 'removeRenderPrimitive', - value: function removeRenderPrimitive(primitive) { - if (!this._renderPrimitives) { - return; - } - - var index = this._renderPrimitives._instances.indexOf(primitive); - if (index > -1) { - this._renderPrimitives._instances.splice(index, 1); - - index = primitive._instances.indexOf(this); - if (index > -1) { - primitive._instances.splice(index, 1); - } - - if (!this._renderPrimitives.length) { - this._renderPrimitives = null; - } - } - } - }, { - key: 'clearRenderPrimitives', - value: function clearRenderPrimitives() { - if (this._renderPrimitives) { - var _iteratorNormalCompletion10 = true; - var _didIteratorError10 = false; - var _iteratorError10 = undefined; - - try { - for (var _iterator10 = this._renderPrimitives[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) { - var primitive = _step10.value; - - var index = primitive._instances.indexOf(this); - if (index > -1) { - primitive._instances.splice(index, 1); - } - } - } catch (err) { - _didIteratorError10 = true; - _iteratorError10 = err; - } finally { - try { - if (!_iteratorNormalCompletion10 && _iterator10.return) { - _iterator10.return(); - } - } finally { - if (_didIteratorError10) { - throw _iteratorError10; - } - } - } - - this._renderPrimitives = null; - } - } - }, { - key: '_hitTestSelectableNode', - value: function _hitTestSelectableNode(ray) { - if (this._renderPrimitives) { - var localRay = null; - var _iteratorNormalCompletion11 = true; - var _didIteratorError11 = false; - var _iteratorError11 = undefined; - - try { - for (var _iterator11 = this._renderPrimitives[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) { - var primitive = _step11.value; - - if (primitive._min) { - if (!localRay) { - _glMatrix.mat4.invert(tmpRayMatrix, this.worldMatrix); - _glMatrix.mat4.multiply(tmpRayMatrix, tmpRayMatrix, ray.transformMatrix); - localRay = new _ray.Ray(tmpRayMatrix); - } - var intersection = localRay.intersectsAABB(primitive._min, primitive._max); - if (intersection) { - _glMatrix.vec3.transformMat4(intersection, intersection, this.worldMatrix); - return intersection; - } - } - } - } catch (err) { - _didIteratorError11 = true; - _iteratorError11 = err; - } finally { - try { - if (!_iteratorNormalCompletion11 && _iterator11.return) { - _iterator11.return(); - } - } finally { - if (_didIteratorError11) { - throw _iteratorError11; - } - } - } - } - var _iteratorNormalCompletion12 = true; - var _didIteratorError12 = false; - var _iteratorError12 = undefined; - - try { - for (var _iterator12 = this.children[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) { - var child = _step12.value; - - var _intersection = child._hitTestSelectableNode(ray); - if (_intersection) { - return _intersection; - } - } - } catch (err) { - _didIteratorError12 = true; - _iteratorError12 = err; - } finally { - try { - if (!_iteratorNormalCompletion12 && _iterator12.return) { - _iterator12.return(); - } - } finally { - if (_didIteratorError12) { - throw _iteratorError12; - } - } - } - - return null; - } - }, { - key: 'hitTest', - value: function hitTest(ray) { - if (this.selectable && this.visible) { - var intersection = this._hitTestSelectableNode(ray); - - if (intersection) { - var origin = _glMatrix.vec3.fromValues(ray.origin.x, ray.origin.y, ray.origin.z); - return { - node: this, - intersection: intersection, - distance: _glMatrix.vec3.distance(origin, intersection) - }; - } - return null; - } - - var result = null; - var _iteratorNormalCompletion13 = true; - var _didIteratorError13 = false; - var _iteratorError13 = undefined; - - try { - for (var _iterator13 = this.children[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) { - var child = _step13.value; - - var childResult = child.hitTest(ray); - if (childResult) { - if (!result || result.distance > childResult.distance) { - result = childResult; - } - } - } - } catch (err) { - _didIteratorError13 = true; - _iteratorError13 = err; - } finally { - try { - if (!_iteratorNormalCompletion13 && _iterator13.return) { - _iterator13.return(); - } - } finally { - if (_didIteratorError13) { - throw _iteratorError13; - } - } - } - - return result; - } - }, { - key: 'onSelect', - value: function onSelect(value) { - this._selectHandler = value; - } - }, { - key: 'handleSelect', - - - // Called when a selectable node is selected. - value: function handleSelect() { - if (this._selectHandler) { - this._selectHandler(); - } - } - - // Called when a selectable element is pointed at. - - }, { - key: 'onHoverStart', - value: function onHoverStart() {} - - // Called when a selectable element is no longer pointed at. - - }, { - key: 'onHoverEnd', - value: function onHoverEnd() {} - }, { - key: '_update', - value: function _update(timestamp, frameDelta) { - this.onUpdate(timestamp, frameDelta); - - var _iteratorNormalCompletion14 = true; - var _didIteratorError14 = false; - var _iteratorError14 = undefined; - - try { - for (var _iterator14 = this.children[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) { - var child = _step14.value; - - child._update(timestamp, frameDelta); - } - } catch (err) { - _didIteratorError14 = true; - _iteratorError14 = err; - } finally { - try { - if (!_iteratorNormalCompletion14 && _iterator14.return) { - _iterator14.return(); - } - } finally { - if (_didIteratorError14) { - throw _iteratorError14; - } - } - } - } - - // Called every frame so that the nodes can animate themselves - - }, { - key: 'onUpdate', - value: function onUpdate(timestamp, frameDelta) {} - }, { - key: 'matrix', - set: function set(value) { - if (value) { - if (!this._matrix) { - this._matrix = _glMatrix.mat4.create(); - } - _glMatrix.mat4.copy(this._matrix, value); - } else { - this._matrix = null; - } - this.setMatrixDirty(); - this._dirtyTRS = false; - this._translation = null; - this._rotation = null; - this._scale = null; - }, - get: function get() { - this.setMatrixDirty(); - - return this._updateLocalMatrix(); - } - }, { - key: 'worldMatrix', - get: function get() { - if (!this._worldMatrix) { - this._dirtyWorldMatrix = true; - this._worldMatrix = _glMatrix.mat4.create(); - } - - if (this._dirtyWorldMatrix || this._dirtyTRS) { - if (this.parent) { - // TODO: Some optimizations that could be done here if the node matrix - // is an identity matrix. - _glMatrix.mat4.mul(this._worldMatrix, this.parent.worldMatrix, this._updateLocalMatrix()); - } else { - _glMatrix.mat4.copy(this._worldMatrix, this._updateLocalMatrix()); - } - this._dirtyWorldMatrix = false; - } - - return this._worldMatrix; - } - - // TODO: Decompose matrix when fetching these? - - }, { - key: 'translation', - set: function set(value) { - if (value != null) { - this._dirtyTRS = true; - this.setMatrixDirty(); - } - this._translation = value; - }, - get: function get() { - this._dirtyTRS = true; - this.setMatrixDirty(); - if (!this._translation) { - this._translation = _glMatrix.vec3.clone(DEFAULT_TRANSLATION); - } - return this._translation; - } - }, { - key: 'rotation', - set: function set(value) { - if (value != null) { - this._dirtyTRS = true; - this.setMatrixDirty(); - } - this._rotation = value; - }, - get: function get() { - this._dirtyTRS = true; - this.setMatrixDirty(); - if (!this._rotation) { - this._rotation = _glMatrix.quat.clone(DEFAULT_ROTATION); - } - return this._rotation; - } - }, { - key: 'scale', - set: function set(value) { - if (value != null) { - this._dirtyTRS = true; - this.setMatrixDirty(); - } - this._scale = value; - }, - get: function get() { - this._dirtyTRS = true; - this.setMatrixDirty(); - if (!this._scale) { - this._scale = _glMatrix.vec3.clone(DEFAULT_SCALE); - } - return this._scale; - } - }, { - key: 'renderPrimitives', - get: function get() { - return this._renderPrimitives; - } - }, { - key: 'selectHandler', - get: function get() { - return this._selectHandler; - } - }]); - - return Node; -}(); - -/***/ }), - -/***/ "./src/core/primitive.js": -/*!*******************************!*\ - !*** ./src/core/primitive.js ***! - \*******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Primitive = exports.PrimitiveAttribute = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _glMatrix = __webpack_require__(/*! ../math/gl-matrix.js */ "./src/math/gl-matrix.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var PrimitiveAttribute = exports.PrimitiveAttribute = function PrimitiveAttribute(name, buffer, componentCount, componentType, stride, byteOffset) { - _classCallCheck(this, PrimitiveAttribute); - - this.name = name; - this.buffer = buffer; - this.componentCount = componentCount || 3; - this.componentType = componentType || 5126; // gl.FLOAT; - this.stride = stride || 0; - this.byteOffset = byteOffset || 0; - this.normalized = false; -}; - -var Primitive = exports.Primitive = function () { - function Primitive(attributes, elementCount, mode) { - _classCallCheck(this, Primitive); - - this.attributes = attributes || []; - this.elementCount = elementCount || 0; - this.mode = mode || 4; // gl.TRIANGLES; - this.indexBuffer = null; - this.indexByteOffset = 0; - this.indexType = 0; - this._min = null; - this._max = null; - } - - _createClass(Primitive, [{ - key: 'setIndexBuffer', - value: function setIndexBuffer(indexBuffer, byteOffset, indexType) { - this.indexBuffer = indexBuffer; - this.indexByteOffset = byteOffset || 0; - this.indexType = indexType || 5123; // gl.UNSIGNED_SHORT; - } - }, { - key: 'setBounds', - value: function setBounds(min, max) { - this._min = _glMatrix.vec3.clone(min); - this._max = _glMatrix.vec3.clone(max); - } - }]); - - return Primitive; -}(); - -/***/ }), - -/***/ "./src/core/program.js": -/*!*****************************!*\ - !*** ./src/core/program.js ***! - \*****************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -// Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var Program = exports.Program = function () { - function Program(gl, vertSrc, fragSrc, attribMap, defines) { - _classCallCheck(this, Program); - - this._gl = gl; - this.program = gl.createProgram(); - this.attrib = null; - this.uniform = null; - this.defines = {}; - - this._firstUse = true; - this._nextUseCallbacks = []; - - var definesString = ''; - if (defines) { - for (var define in defines) { - this.defines[define] = defines[define]; - definesString += '#define ' + define + ' ' + defines[define] + '\n'; - } - } - - this._vertShader = gl.createShader(gl.VERTEX_SHADER); - gl.attachShader(this.program, this._vertShader); - gl.shaderSource(this._vertShader, definesString + vertSrc); - gl.compileShader(this._vertShader); - - this._fragShader = gl.createShader(gl.FRAGMENT_SHADER); - gl.attachShader(this.program, this._fragShader); - gl.shaderSource(this._fragShader, definesString + fragSrc); - gl.compileShader(this._fragShader); - - if (attribMap) { - this.attrib = {}; - for (var attribName in attribMap) { - gl.bindAttribLocation(this.program, attribMap[attribName], attribName); - this.attrib[attribName] = attribMap[attribName]; - } - } - - gl.linkProgram(this.program); - } - - _createClass(Program, [{ - key: 'onNextUse', - value: function onNextUse(callback) { - this._nextUseCallbacks.push(callback); - } - }, { - key: 'use', - value: function use() { - var gl = this._gl; - - // If this is the first time the program has been used do all the error checking and - // attrib/uniform querying needed. - if (this._firstUse) { - this._firstUse = false; - if (!gl.getProgramParameter(this.program, gl.LINK_STATUS)) { - if (!gl.getShaderParameter(this._vertShader, gl.COMPILE_STATUS)) { - console.error('Vertex shader compile error: ' + gl.getShaderInfoLog(this._vertShader)); - } else if (!gl.getShaderParameter(this._fragShader, gl.COMPILE_STATUS)) { - console.error('Fragment shader compile error: ' + gl.getShaderInfoLog(this._fragShader)); - } else { - console.error('Program link error: ' + gl.getProgramInfoLog(this.program)); - } - gl.deleteProgram(this.program); - this.program = null; - } else { - if (!this.attrib) { - this.attrib = {}; - var attribCount = gl.getProgramParameter(this.program, gl.ACTIVE_ATTRIBUTES); - for (var i = 0; i < attribCount; i++) { - var attribInfo = gl.getActiveAttrib(this.program, i); - this.attrib[attribInfo.name] = gl.getAttribLocation(this.program, attribInfo.name); - } - } - - this.uniform = {}; - var uniformCount = gl.getProgramParameter(this.program, gl.ACTIVE_UNIFORMS); - var uniformName = ''; - for (var _i = 0; _i < uniformCount; _i++) { - var uniformInfo = gl.getActiveUniform(this.program, _i); - uniformName = uniformInfo.name.replace('[0]', ''); - this.uniform[uniformName] = gl.getUniformLocation(this.program, uniformName); - } - } - gl.deleteShader(this._vertShader); - gl.deleteShader(this._fragShader); - } - - gl.useProgram(this.program); - - if (this._nextUseCallbacks.length) { - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = this._nextUseCallbacks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var callback = _step.value; - - callback(this); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - - this._nextUseCallbacks = []; - } - } - }]); - - return Program; -}(); - -/***/ }), - -/***/ "./src/core/renderer.js": -/*!******************************!*\ - !*** ./src/core/renderer.js ***! - \******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Renderer = exports.RenderTexture = exports.RenderView = exports.ATTRIB_MASK = exports.ATTRIB = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -exports.createWebGLContext = createWebGLContext; - -var _material = __webpack_require__(/*! ./material.js */ "./src/core/material.js"); - -var _node = __webpack_require__(/*! ./node.js */ "./src/core/node.js"); - -var _program = __webpack_require__(/*! ./program.js */ "./src/core/program.js"); - -var _texture = __webpack_require__(/*! ./texture.js */ "./src/core/texture.js"); - -var _glMatrix = __webpack_require__(/*! ../math/gl-matrix.js */ "./src/math/gl-matrix.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var ATTRIB = exports.ATTRIB = { - POSITION: 1, - NORMAL: 2, - TANGENT: 3, - TEXCOORD_0: 4, - TEXCOORD_1: 5, - COLOR_0: 6 -}; - -var ATTRIB_MASK = exports.ATTRIB_MASK = { - POSITION: 0x0001, - NORMAL: 0x0002, - TANGENT: 0x0004, - TEXCOORD_0: 0x0008, - TEXCOORD_1: 0x0010, - COLOR_0: 0x0020 -}; - -var GL = WebGLRenderingContext; // For enums - -var DEF_LIGHT_DIR = new Float32Array([-0.1, -1.0, -0.2]); -var DEF_LIGHT_COLOR = new Float32Array([3.0, 3.0, 3.0]); - -var PRECISION_REGEX = new RegExp('precision (lowp|mediump|highp) float;'); - -var VERTEX_SHADER_SINGLE_ENTRY = '\nuniform mat4 PROJECTION_MATRIX, VIEW_MATRIX, MODEL_MATRIX;\n\nvoid main() {\n gl_Position = vertex_main(PROJECTION_MATRIX, VIEW_MATRIX, MODEL_MATRIX);\n}\n'; - -var VERTEX_SHADER_MULTI_ENTRY = '\n#ERROR Multiview rendering is not implemented\nvoid main() {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n}\n'; - -var FRAGMENT_SHADER_ENTRY = '\nvoid main() {\n gl_FragColor = fragment_main();\n}\n'; - -function isPowerOfTwo(n) { - return (n & n - 1) === 0; -} - -// Creates a WebGL context and initializes it with some common default state. -function createWebGLContext(glAttribs) { - glAttribs = glAttribs || { alpha: false }; - - var webglCanvas = document.createElement('canvas'); - var contextTypes = glAttribs.webgl2 ? ['webgl2'] : ['webgl', 'experimental-webgl']; - var context = null; - - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = contextTypes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var contextType = _step.value; - - context = webglCanvas.getContext(contextType, glAttribs); - if (context) { - break; - } - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - - if (!context) { - var webglType = glAttribs.webgl2 ? 'WebGL 2' : 'WebGL'; - console.error('This browser does not support ' + webglType + '.'); - return null; - } - - return context; -} - -var RenderView = exports.RenderView = function () { - function RenderView(projectionMatrix, viewMatrix) { - var viewport = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; - var eye = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'left'; - - _classCallCheck(this, RenderView); - - this.projectionMatrix = projectionMatrix; - this.viewMatrix = viewMatrix; - this.viewport = viewport; - // If an eye isn't given the left eye is assumed. - this._eye = eye; - this._eyeIndex = eye == 'left' ? 0 : 1; - } - - _createClass(RenderView, [{ - key: 'eye', - get: function get() { - return this._eye; - }, - set: function set(value) { - this._eye = value; - this._eyeIndex = value == 'left' ? 0 : 1; - } - }, { - key: 'eyeIndex', - get: function get() { - return this._eyeIndex; - } - }]); - - return RenderView; -}(); - -var RenderBuffer = function () { - function RenderBuffer(target, usage, buffer) { - var _this = this; - - var length = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; - - _classCallCheck(this, RenderBuffer); - - this._target = target; - this._usage = usage; - this._length = length; - if (buffer instanceof Promise) { - this._buffer = null; - this._promise = buffer.then(function (buffer) { - _this._buffer = buffer; - return _this; - }); - } else { - this._buffer = buffer; - this._promise = Promise.resolve(this); - } - } - - _createClass(RenderBuffer, [{ - key: 'waitForComplete', - value: function waitForComplete() { - return this._promise; - } - }]); - - return RenderBuffer; -}(); - -var RenderPrimitiveAttribute = function RenderPrimitiveAttribute(primitiveAttribute) { - _classCallCheck(this, RenderPrimitiveAttribute); - - this._attrib_index = ATTRIB[primitiveAttribute.name]; - this._componentCount = primitiveAttribute.componentCount; - this._componentType = primitiveAttribute.componentType; - this._stride = primitiveAttribute.stride; - this._byteOffset = primitiveAttribute.byteOffset; - this._normalized = primitiveAttribute.normalized; -}; - -var RenderPrimitiveAttributeBuffer = function RenderPrimitiveAttributeBuffer(buffer) { - _classCallCheck(this, RenderPrimitiveAttributeBuffer); - - this._buffer = buffer; - this._attributes = []; -}; - -var RenderPrimitive = function () { - function RenderPrimitive(primitive) { - _classCallCheck(this, RenderPrimitive); - - this._activeFrameId = 0; - this._instances = []; - this._material = null; - - this.setPrimitive(primitive); - } - - _createClass(RenderPrimitive, [{ - key: 'setPrimitive', - value: function setPrimitive(primitive) { - this._mode = primitive.mode; - this._elementCount = primitive.elementCount; - this._promise = null; - this._vao = null; - this._complete = false; - this._attributeBuffers = []; - this._attributeMask = 0; - - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; - - try { - for (var _iterator2 = primitive.attributes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var attribute = _step2.value; - - this._attributeMask |= ATTRIB_MASK[attribute.name]; - var renderAttribute = new RenderPrimitiveAttribute(attribute); - var foundBuffer = false; - var _iteratorNormalCompletion3 = true; - var _didIteratorError3 = false; - var _iteratorError3 = undefined; - - try { - for (var _iterator3 = this._attributeBuffers[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { - var attributeBuffer = _step3.value; - - if (attributeBuffer._buffer == attribute.buffer) { - attributeBuffer._attributes.push(renderAttribute); - foundBuffer = true; - break; - } - } - } catch (err) { - _didIteratorError3 = true; - _iteratorError3 = err; - } finally { - try { - if (!_iteratorNormalCompletion3 && _iterator3.return) { - _iterator3.return(); - } - } finally { - if (_didIteratorError3) { - throw _iteratorError3; - } - } - } - - if (!foundBuffer) { - var _attributeBuffer = new RenderPrimitiveAttributeBuffer(attribute.buffer); - _attributeBuffer._attributes.push(renderAttribute); - this._attributeBuffers.push(_attributeBuffer); - } - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } - - this._indexBuffer = null; - this._indexByteOffset = 0; - this._indexType = 0; - - if (primitive.indexBuffer) { - this._indexByteOffset = primitive.indexByteOffset; - this._indexType = primitive.indexType; - this._indexBuffer = primitive.indexBuffer; - } - - if (primitive._min) { - this._min = _glMatrix.vec3.clone(primitive._min); - this._max = _glMatrix.vec3.clone(primitive._max); - } else { - this._min = null; - this._max = null; - } - - if (this._material != null) { - this.waitForComplete(); // To flip the _complete flag. - } - } - }, { - key: 'setRenderMaterial', - value: function setRenderMaterial(material) { - this._material = material; - this._promise = null; - this._complete = false; - - if (this._material != null) { - this.waitForComplete(); // To flip the _complete flag. - } - } - }, { - key: 'markActive', - value: function markActive(frameId) { - if (this._complete && this._activeFrameId != frameId) { - if (this._material) { - if (!this._material.markActive(frameId)) { - return; - } - } - this._activeFrameId = frameId; - } - } - }, { - key: 'waitForComplete', - value: function waitForComplete() { - var _this2 = this; - - if (!this._promise) { - if (!this._material) { - return Promise.reject('RenderPrimitive does not have a material'); - } - - var completionPromises = []; - - var _iteratorNormalCompletion4 = true; - var _didIteratorError4 = false; - var _iteratorError4 = undefined; - - try { - for (var _iterator4 = this._attributeBuffers[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { - var attributeBuffer = _step4.value; - - if (!attributeBuffer._buffer._buffer) { - completionPromises.push(attributeBuffer._buffer._promise); - } - } - } catch (err) { - _didIteratorError4 = true; - _iteratorError4 = err; - } finally { - try { - if (!_iteratorNormalCompletion4 && _iterator4.return) { - _iterator4.return(); - } - } finally { - if (_didIteratorError4) { - throw _iteratorError4; - } - } - } - - if (this._indexBuffer && !this._indexBuffer._buffer) { - completionPromises.push(this._indexBuffer._promise); - } - - this._promise = Promise.all(completionPromises).then(function () { - _this2._complete = true; - return _this2; - }); - } - return this._promise; - } - }, { - key: 'samplers', - get: function get() { - return this._material._samplerDictionary; - } - }, { - key: 'uniforms', - get: function get() { - return this._material._uniform_dictionary; - } - }]); - - return RenderPrimitive; -}(); - -var RenderTexture = exports.RenderTexture = function () { - function RenderTexture(texture) { - _classCallCheck(this, RenderTexture); - - this._texture = texture; - this._complete = false; - this._activeFrameId = 0; - this._activeCallback = null; - } - - _createClass(RenderTexture, [{ - key: 'markActive', - value: function markActive(frameId) { - if (this._activeCallback && this._activeFrameId != frameId) { - this._activeFrameId = frameId; - this._activeCallback(this); - } - } - }]); - - return RenderTexture; -}(); - -var inverseMatrix = _glMatrix.mat4.create(); - -function setCap(gl, glEnum, cap, prevState, state) { - var change = (state & cap) - (prevState & cap); - if (!change) { - return; - } - - if (change > 0) { - gl.enable(glEnum); - } else { - gl.disable(glEnum); - } -} - -var RenderMaterialSampler = function () { - function RenderMaterialSampler(renderer, materialSampler, index) { - _classCallCheck(this, RenderMaterialSampler); - - this._renderer = renderer; - this._uniformName = materialSampler._uniformName; - this._renderTexture = renderer._getRenderTexture(materialSampler._texture); - this._index = index; - } - - _createClass(RenderMaterialSampler, [{ - key: 'texture', - set: function set(value) { - this._renderTexture = this._renderer._getRenderTexture(value); - } - }]); - - return RenderMaterialSampler; -}(); - -var RenderMaterialUniform = function () { - function RenderMaterialUniform(materialUniform) { - _classCallCheck(this, RenderMaterialUniform); - - this._uniformName = materialUniform._uniformName; - this._uniform = null; - this._length = materialUniform._length; - if (materialUniform._value instanceof Array) { - this._value = new Float32Array(materialUniform._value); - } else { - this._value = new Float32Array([materialUniform._value]); - } - } - - _createClass(RenderMaterialUniform, [{ - key: 'value', - set: function set(value) { - if (this._value.length == 1) { - this._value[0] = value; - } else { - for (var i = 0; i < this._value.length; ++i) { - this._value[i] = value[i]; - } - } - } - }]); - - return RenderMaterialUniform; -}(); - -var RenderMaterial = function () { - function RenderMaterial(renderer, material, program) { - _classCallCheck(this, RenderMaterial); - - this._program = program; - this._state = material.state._state; - this._activeFrameId = 0; - this._completeForActiveFrame = false; - - this._samplerDictionary = {}; - this._samplers = []; - for (var i = 0; i < material._samplers.length; ++i) { - var renderSampler = new RenderMaterialSampler(renderer, material._samplers[i], i); - this._samplers.push(renderSampler); - this._samplerDictionary[renderSampler._uniformName] = renderSampler; - } - - this._uniform_dictionary = {}; - this._uniforms = []; - var _iteratorNormalCompletion5 = true; - var _didIteratorError5 = false; - var _iteratorError5 = undefined; - - try { - for (var _iterator5 = material._uniforms[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { - var uniform = _step5.value; - - var renderUniform = new RenderMaterialUniform(uniform); - this._uniforms.push(renderUniform); - this._uniform_dictionary[renderUniform._uniformName] = renderUniform; - } - } catch (err) { - _didIteratorError5 = true; - _iteratorError5 = err; - } finally { - try { - if (!_iteratorNormalCompletion5 && _iterator5.return) { - _iterator5.return(); - } - } finally { - if (_didIteratorError5) { - throw _iteratorError5; - } - } - } - - this._firstBind = true; - - this._renderOrder = material.renderOrder; - if (this._renderOrder == _material.RENDER_ORDER.DEFAULT) { - if (this._state & _material.CAP.BLEND) { - this._renderOrder = _material.RENDER_ORDER.TRANSPARENT; - } else { - this._renderOrder = _material.RENDER_ORDER.OPAQUE; - } - } - } - - _createClass(RenderMaterial, [{ - key: 'bind', - value: function bind(gl) { - // First time we do a binding, cache the uniform locations and remove - // unused uniforms from the list. - if (this._firstBind) { - for (var i = 0; i < this._samplers.length;) { - var sampler = this._samplers[i]; - if (!this._program.uniform[sampler._uniformName]) { - this._samplers.splice(i, 1); - continue; - } - ++i; - } - - for (var _i = 0; _i < this._uniforms.length;) { - var uniform = this._uniforms[_i]; - uniform._uniform = this._program.uniform[uniform._uniformName]; - if (!uniform._uniform) { - this._uniforms.splice(_i, 1); - continue; - } - ++_i; - } - this._firstBind = false; - } - - var _iteratorNormalCompletion6 = true; - var _didIteratorError6 = false; - var _iteratorError6 = undefined; - - try { - for (var _iterator6 = this._samplers[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) { - var _sampler = _step6.value; - - gl.activeTexture(gl.TEXTURE0 + _sampler._index); - if (_sampler._renderTexture && _sampler._renderTexture._complete) { - gl.bindTexture(gl.TEXTURE_2D, _sampler._renderTexture._texture); - } else { - gl.bindTexture(gl.TEXTURE_2D, null); - } - } - } catch (err) { - _didIteratorError6 = true; - _iteratorError6 = err; - } finally { - try { - if (!_iteratorNormalCompletion6 && _iterator6.return) { - _iterator6.return(); - } - } finally { - if (_didIteratorError6) { - throw _iteratorError6; - } - } - } - - var _iteratorNormalCompletion7 = true; - var _didIteratorError7 = false; - var _iteratorError7 = undefined; - - try { - for (var _iterator7 = this._uniforms[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) { - var _uniform = _step7.value; - - switch (_uniform._length) { - case 1: - gl.uniform1fv(_uniform._uniform, _uniform._value);break; - case 2: - gl.uniform2fv(_uniform._uniform, _uniform._value);break; - case 3: - gl.uniform3fv(_uniform._uniform, _uniform._value);break; - case 4: - gl.uniform4fv(_uniform._uniform, _uniform._value);break; - } - } - } catch (err) { - _didIteratorError7 = true; - _iteratorError7 = err; - } finally { - try { - if (!_iteratorNormalCompletion7 && _iterator7.return) { - _iterator7.return(); - } - } finally { - if (_didIteratorError7) { - throw _iteratorError7; - } - } - } - } - }, { - key: 'markActive', - value: function markActive(frameId) { - if (this._activeFrameId != frameId) { - this._activeFrameId = frameId; - this._completeForActiveFrame = true; - for (var i = 0; i < this._samplers.length; ++i) { - var sampler = this._samplers[i]; - if (sampler._renderTexture) { - if (!sampler._renderTexture._complete) { - this._completeForActiveFrame = false; - break; - } - sampler._renderTexture.markActive(frameId); - } - } - } - return this._completeForActiveFrame; - } - - // Material State fetchers - - }, { - key: '_capsDiff', - - - // Only really for use from the renderer - value: function _capsDiff(otherState) { - return otherState & _material.MAT_STATE.CAPS_RANGE ^ this._state & _material.MAT_STATE.CAPS_RANGE; - } - }, { - key: '_blendDiff', - value: function _blendDiff(otherState) { - if (!(this._state & _material.CAP.BLEND)) { - return 0; - } - return otherState & _material.MAT_STATE.BLEND_FUNC_RANGE ^ this._state & _material.MAT_STATE.BLEND_FUNC_RANGE; - } - }, { - key: '_depthFuncDiff', - value: function _depthFuncDiff(otherState) { - if (!(this._state & _material.CAP.DEPTH_TEST)) { - return 0; - } - return otherState & _material.MAT_STATE.DEPTH_FUNC_RANGE ^ this._state & _material.MAT_STATE.DEPTH_FUNC_RANGE; - } - }, { - key: 'cullFace', - get: function get() { - return !!(this._state & _material.CAP.CULL_FACE); - } - }, { - key: 'blend', - get: function get() { - return !!(this._state & _material.CAP.BLEND); - } - }, { - key: 'depthTest', - get: function get() { - return !!(this._state & _material.CAP.DEPTH_TEST); - } - }, { - key: 'stencilTest', - get: function get() { - return !!(this._state & _material.CAP.STENCIL_TEST); - } - }, { - key: 'colorMask', - get: function get() { - return !!(this._state & _material.CAP.COLOR_MASK); - } - }, { - key: 'depthMask', - get: function get() { - return !!(this._state & _material.CAP.DEPTH_MASK); - } - }, { - key: 'stencilMask', - get: function get() { - return !!(this._state & _material.CAP.STENCIL_MASK); - } - }, { - key: 'depthFunc', - get: function get() { - return ((this._state & _material.MAT_STATE.DEPTH_FUNC_RANGE) >> _material.MAT_STATE.DEPTH_FUNC_SHIFT) + GL.NEVER; - } - }, { - key: 'blendFuncSrc', - get: function get() { - return (0, _material.stateToBlendFunc)(this._state, _material.MAT_STATE.BLEND_SRC_RANGE, _material.MAT_STATE.BLEND_SRC_SHIFT); - } - }, { - key: 'blendFuncDst', - get: function get() { - return (0, _material.stateToBlendFunc)(this._state, _material.MAT_STATE.BLEND_DST_RANGE, _material.MAT_STATE.BLEND_DST_SHIFT); - } - }]); - - return RenderMaterial; -}(); - -var Renderer = exports.Renderer = function () { - function Renderer(gl) { - _classCallCheck(this, Renderer); - - this._gl = gl || createWebGLContext(); - this._frameId = 0; - this._programCache = {}; - this._textureCache = {}; - this._renderPrimitives = Array(_material.RENDER_ORDER.DEFAULT); - this._cameraPositions = []; - - this._vaoExt = gl.getExtension('OES_vertex_array_object'); - - var fragHighPrecision = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT); - this._defaultFragPrecision = fragHighPrecision.precision > 0 ? 'highp' : 'mediump'; - - this._depthMaskNeedsReset = false; - this._colorMaskNeedsReset = false; - - this._globalLightColor = _glMatrix.vec3.clone(DEF_LIGHT_COLOR); - this._globalLightDir = _glMatrix.vec3.clone(DEF_LIGHT_DIR); - } - - _createClass(Renderer, [{ - key: 'createRenderBuffer', - value: function createRenderBuffer(target, data) { - var usage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : GL.STATIC_DRAW; - - var gl = this._gl; - var glBuffer = gl.createBuffer(); - - if (data instanceof Promise) { - var renderBuffer = new RenderBuffer(target, usage, data.then(function (data) { - gl.bindBuffer(target, glBuffer); - gl.bufferData(target, data, usage); - renderBuffer._length = data.byteLength; - return glBuffer; - })); - return renderBuffer; - } else { - gl.bindBuffer(target, glBuffer); - gl.bufferData(target, data, usage); - return new RenderBuffer(target, usage, glBuffer, data.byteLength); - } - } - }, { - key: 'updateRenderBuffer', - value: function updateRenderBuffer(buffer, data) { - var _this3 = this; - - var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - - if (buffer._buffer) { - var gl = this._gl; - gl.bindBuffer(buffer._target, buffer._buffer); - if (offset == 0 && buffer._length == data.byteLength) { - gl.bufferData(buffer._target, data, buffer._usage); - } else { - gl.bufferSubData(buffer._target, offset, data); - } - } else { - buffer.waitForComplete().then(function (buffer) { - _this3.updateRenderBuffer(buffer, data, offset); - }); - } - } - }, { - key: 'createRenderPrimitive', - value: function createRenderPrimitive(primitive, material) { - var renderPrimitive = new RenderPrimitive(primitive); - - var program = this._getMaterialProgram(material, renderPrimitive); - var renderMaterial = new RenderMaterial(this, material, program); - renderPrimitive.setRenderMaterial(renderMaterial); - - if (!this._renderPrimitives[renderMaterial._renderOrder]) { - this._renderPrimitives[renderMaterial._renderOrder] = []; - } - - this._renderPrimitives[renderMaterial._renderOrder].push(renderPrimitive); - - return renderPrimitive; - } - }, { - key: 'createMesh', - value: function createMesh(primitive, material) { - var meshNode = new _node.Node(); - meshNode.addRenderPrimitive(this.createRenderPrimitive(primitive, material)); - return meshNode; - } - }, { - key: 'drawViews', - value: function drawViews(views, rootNode) { - if (!rootNode) { - return; - } - - var gl = this._gl; - this._frameId++; - - rootNode.markActive(this._frameId); - - // If there's only one view then flip the algorithm a bit so that we're only - // setting the viewport once. - if (views.length == 1 && views[0].viewport) { - var vp = views[0].viewport; - this._gl.viewport(vp.x, vp.y, vp.width, vp.height); - } - - // Get the positions of the 'camera' for each view matrix. - for (var i = 0; i < views.length; ++i) { - _glMatrix.mat4.invert(inverseMatrix, views[i].viewMatrix); - - if (this._cameraPositions.length <= i) { - this._cameraPositions.push(_glMatrix.vec3.create()); - } - var cameraPosition = this._cameraPositions[i]; - _glMatrix.vec3.set(cameraPosition, 0, 0, 0); - _glMatrix.vec3.transformMat4(cameraPosition, cameraPosition, inverseMatrix); - } - - // Draw each set of render primitives in order - var _iteratorNormalCompletion8 = true; - var _didIteratorError8 = false; - var _iteratorError8 = undefined; - - try { - for (var _iterator8 = this._renderPrimitives[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) { - var renderPrimitives = _step8.value; - - if (renderPrimitives && renderPrimitives.length) { - this._drawRenderPrimitiveSet(views, renderPrimitives); - } - } - } catch (err) { - _didIteratorError8 = true; - _iteratorError8 = err; - } finally { - try { - if (!_iteratorNormalCompletion8 && _iterator8.return) { - _iterator8.return(); - } - } finally { - if (_didIteratorError8) { - throw _iteratorError8; - } - } - } - - if (this._vaoExt) { - this._vaoExt.bindVertexArrayOES(null); - } - - if (this._depthMaskNeedsReset) { - gl.depthMask(true); - } - if (this._colorMaskNeedsReset) { - gl.colorMask(true, true, true, true); - } - } - }, { - key: '_drawRenderPrimitiveSet', - value: function _drawRenderPrimitiveSet(views, renderPrimitives) { - var gl = this._gl; - var program = null; - var material = null; - var attribMask = 0; - - // Loop through every primitive known to the renderer. - var _iteratorNormalCompletion9 = true; - var _didIteratorError9 = false; - var _iteratorError9 = undefined; - - try { - for (var _iterator9 = renderPrimitives[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) { - var primitive = _step9.value; - - // Skip over those that haven't been marked as active for this frame. - if (primitive._activeFrameId != this._frameId) { - continue; - } - - // Bind the primitive material's program if it's different than the one we - // were using for the previous primitive. - // TODO: The ording of this could be more efficient. - if (program != primitive._material._program) { - program = primitive._material._program; - program.use(); - - if (program.uniform.LIGHT_DIRECTION) { - gl.uniform3fv(program.uniform.LIGHT_DIRECTION, this._globalLightDir); - } - - if (program.uniform.LIGHT_COLOR) { - gl.uniform3fv(program.uniform.LIGHT_COLOR, this._globalLightColor); - } - - if (views.length == 1) { - gl.uniformMatrix4fv(program.uniform.PROJECTION_MATRIX, false, views[0].projectionMatrix); - gl.uniformMatrix4fv(program.uniform.VIEW_MATRIX, false, views[0].viewMatrix); - gl.uniform3fv(program.uniform.CAMERA_POSITION, this._cameraPositions[0]); - gl.uniform1i(program.uniform.EYE_INDEX, views[0].eyeIndex); - } - } - - if (material != primitive._material) { - this._bindMaterialState(primitive._material, material); - primitive._material.bind(gl, program, material); - material = primitive._material; - } - - if (this._vaoExt) { - if (primitive._vao) { - this._vaoExt.bindVertexArrayOES(primitive._vao); - } else { - primitive._vao = this._vaoExt.createVertexArrayOES(); - this._vaoExt.bindVertexArrayOES(primitive._vao); - this._bindPrimitive(primitive); - } - } else { - this._bindPrimitive(primitive, attribMask); - attribMask = primitive._attributeMask; - } - - for (var i = 0; i < views.length; ++i) { - var view = views[i]; - if (views.length > 1) { - if (view.viewport) { - var vp = view.viewport; - gl.viewport(vp.x, vp.y, vp.width, vp.height); - } - gl.uniformMatrix4fv(program.uniform.PROJECTION_MATRIX, false, view.projectionMatrix); - gl.uniformMatrix4fv(program.uniform.VIEW_MATRIX, false, view.viewMatrix); - gl.uniform3fv(program.uniform.CAMERA_POSITION, this._cameraPositions[i]); - gl.uniform1i(program.uniform.EYE_INDEX, view.eyeIndex); - } - - var _iteratorNormalCompletion10 = true; - var _didIteratorError10 = false; - var _iteratorError10 = undefined; - - try { - for (var _iterator10 = primitive._instances[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) { - var instance = _step10.value; - - if (instance._activeFrameId != this._frameId) { - continue; - } - - gl.uniformMatrix4fv(program.uniform.MODEL_MATRIX, false, instance.worldMatrix); - - if (primitive._indexBuffer) { - gl.drawElements(primitive._mode, primitive._elementCount, primitive._indexType, primitive._indexByteOffset); - } else { - gl.drawArrays(primitive._mode, 0, primitive._elementCount); - } - } - } catch (err) { - _didIteratorError10 = true; - _iteratorError10 = err; - } finally { - try { - if (!_iteratorNormalCompletion10 && _iterator10.return) { - _iterator10.return(); - } - } finally { - if (_didIteratorError10) { - throw _iteratorError10; - } - } - } - } - } - } catch (err) { - _didIteratorError9 = true; - _iteratorError9 = err; - } finally { - try { - if (!_iteratorNormalCompletion9 && _iterator9.return) { - _iterator9.return(); - } - } finally { - if (_didIteratorError9) { - throw _iteratorError9; - } - } - } - } - }, { - key: '_getRenderTexture', - value: function _getRenderTexture(texture) { - var _this4 = this; - - if (!texture) { - return null; - } - - var key = texture.textureKey; - if (!key) { - throw new Error('Texure does not have a valid key'); - } - - if (key in this._textureCache) { - return this._textureCache[key]; - } else { - var gl = this._gl; - var textureHandle = gl.createTexture(); - - var renderTexture = new RenderTexture(textureHandle); - this._textureCache[key] = renderTexture; - - if (texture instanceof _texture.DataTexture) { - gl.bindTexture(gl.TEXTURE_2D, textureHandle); - gl.texImage2D(gl.TEXTURE_2D, 0, texture.format, texture.width, texture.height, 0, texture.format, texture._type, texture._data); - this._setSamplerParameters(texture); - renderTexture._complete = true; - } else { - texture.waitForComplete().then(function () { - gl.bindTexture(gl.TEXTURE_2D, textureHandle); - gl.texImage2D(gl.TEXTURE_2D, 0, texture.format, texture.format, gl.UNSIGNED_BYTE, texture.source); - _this4._setSamplerParameters(texture); - renderTexture._complete = true; - - if (texture instanceof _texture.VideoTexture) { - // Once the video starts playing, set a callback to update it's - // contents each frame. - texture._video.addEventListener('playing', function () { - renderTexture._activeCallback = function () { - if (!texture._video.paused && !texture._video.waiting) { - gl.bindTexture(gl.TEXTURE_2D, textureHandle); - gl.texImage2D(gl.TEXTURE_2D, 0, texture.format, texture.format, gl.UNSIGNED_BYTE, texture.source); - } - }; - }); - } - }); - } - - return renderTexture; - } - } - }, { - key: '_setSamplerParameters', - value: function _setSamplerParameters(texture) { - var gl = this._gl; - - var sampler = texture.sampler; - var powerOfTwo = isPowerOfTwo(texture.width) && isPowerOfTwo(texture.height); - var mipmap = powerOfTwo && texture.mipmap; - if (mipmap) { - gl.generateMipmap(gl.TEXTURE_2D); - } - - var minFilter = sampler.minFilter || (mipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR); - var wrapS = sampler.wrapS || (powerOfTwo ? gl.REPEAT : gl.CLAMP_TO_EDGE); - var wrapT = sampler.wrapT || (powerOfTwo ? gl.REPEAT : gl.CLAMP_TO_EDGE); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, sampler.magFilter || gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT); - } - }, { - key: '_getProgramKey', - value: function _getProgramKey(name, defines) { - var key = name + ':'; - - for (var define in defines) { - key += define + '=' + defines[define] + ','; - } - - return key; - } - }, { - key: '_getMaterialProgram', - value: function _getMaterialProgram(material, renderPrimitive) { - var _this5 = this; - - var materialName = material.materialName; - var vertexSource = material.vertexSource; - var fragmentSource = material.fragmentSource; - - // These should always be defined for every material - if (materialName == null) { - throw new Error('Material does not have a name'); - } - if (vertexSource == null) { - throw new Error('Material "' + materialName + '" does not have a vertex source'); - } - if (fragmentSource == null) { - throw new Error('Material "' + materialName + '" does not have a fragment source'); - } - - var defines = material.getProgramDefines(renderPrimitive); - var key = this._getProgramKey(materialName, defines); - - if (key in this._programCache) { - return this._programCache[key]; - } else { - var multiview = false; // Handle this dynamically later - var fullVertexSource = vertexSource; - fullVertexSource += multiview ? VERTEX_SHADER_MULTI_ENTRY : VERTEX_SHADER_SINGLE_ENTRY; - - var precisionMatch = fragmentSource.match(PRECISION_REGEX); - var fragPrecisionHeader = precisionMatch ? '' : 'precision ' + this._defaultFragPrecision + ' float;\n'; - - var fullFragmentSource = fragPrecisionHeader + fragmentSource; - fullFragmentSource += FRAGMENT_SHADER_ENTRY; - - var program = new _program.Program(this._gl, fullVertexSource, fullFragmentSource, ATTRIB, defines); - this._programCache[key] = program; - - program.onNextUse(function (program) { - // Bind the samplers to the right texture index. This is constant for - // the lifetime of the program. - for (var i = 0; i < material._samplers.length; ++i) { - var sampler = material._samplers[i]; - var uniform = program.uniform[sampler._uniformName]; - if (uniform) { - _this5._gl.uniform1i(uniform, i); - } - } - }); - - return program; - } - } - }, { - key: '_bindPrimitive', - value: function _bindPrimitive(primitive, attribMask) { - var gl = this._gl; - - // If the active attributes have changed then update the active set. - if (attribMask != primitive._attributeMask) { - for (var attrib in ATTRIB) { - if (primitive._attributeMask & ATTRIB_MASK[attrib]) { - gl.enableVertexAttribArray(ATTRIB[attrib]); - } else { - gl.disableVertexAttribArray(ATTRIB[attrib]); - } - } - } - - // Bind the primitive attributes and indices. - var _iteratorNormalCompletion11 = true; - var _didIteratorError11 = false; - var _iteratorError11 = undefined; - - try { - for (var _iterator11 = primitive._attributeBuffers[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) { - var attributeBuffer = _step11.value; - - gl.bindBuffer(gl.ARRAY_BUFFER, attributeBuffer._buffer._buffer); - var _iteratorNormalCompletion12 = true; - var _didIteratorError12 = false; - var _iteratorError12 = undefined; - - try { - for (var _iterator12 = attributeBuffer._attributes[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) { - var _attrib = _step12.value; - - gl.vertexAttribPointer(_attrib._attrib_index, _attrib._componentCount, _attrib._componentType, _attrib._normalized, _attrib._stride, _attrib._byteOffset); - } - } catch (err) { - _didIteratorError12 = true; - _iteratorError12 = err; - } finally { - try { - if (!_iteratorNormalCompletion12 && _iterator12.return) { - _iterator12.return(); - } - } finally { - if (_didIteratorError12) { - throw _iteratorError12; - } - } - } - } - } catch (err) { - _didIteratorError11 = true; - _iteratorError11 = err; - } finally { - try { - if (!_iteratorNormalCompletion11 && _iterator11.return) { - _iterator11.return(); - } - } finally { - if (_didIteratorError11) { - throw _iteratorError11; - } - } - } - - if (primitive._indexBuffer) { - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, primitive._indexBuffer._buffer); - } else { - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null); - } - } - }, { - key: '_bindMaterialState', - value: function _bindMaterialState(material) { - var prevMaterial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - - var gl = this._gl; - - var state = material._state; - var prevState = prevMaterial ? prevMaterial._state : ~state; - - // Return early if both materials use identical state - if (state == prevState) { - return; - } - - // Any caps bits changed? - if (material._capsDiff(prevState)) { - setCap(gl, gl.CULL_FACE, _material.CAP.CULL_FACE, prevState, state); - setCap(gl, gl.BLEND, _material.CAP.BLEND, prevState, state); - setCap(gl, gl.DEPTH_TEST, _material.CAP.DEPTH_TEST, prevState, state); - setCap(gl, gl.STENCIL_TEST, _material.CAP.STENCIL_TEST, prevState, state); - - var colorMaskChange = (state & _material.CAP.COLOR_MASK) - (prevState & _material.CAP.COLOR_MASK); - if (colorMaskChange) { - var mask = colorMaskChange > 1; - this._colorMaskNeedsReset = !mask; - gl.colorMask(mask, mask, mask, mask); - } - - var depthMaskChange = (state & _material.CAP.DEPTH_MASK) - (prevState & _material.CAP.DEPTH_MASK); - if (depthMaskChange) { - this._depthMaskNeedsReset = !(depthMaskChange > 1); - gl.depthMask(depthMaskChange > 1); - } - - var stencilMaskChange = (state & _material.CAP.STENCIL_MASK) - (prevState & _material.CAP.STENCIL_MASK); - if (stencilMaskChange) { - gl.stencilMask(stencilMaskChange > 1); - } - } - - // Blending enabled and blend func changed? - if (material._blendDiff(prevState)) { - gl.blendFunc(material.blendFuncSrc, material.blendFuncDst); - } - - // Depth testing enabled and depth func changed? - if (material._depthFuncDiff(prevState)) { - gl.depthFunc(material.depthFunc); - } - } - }, { - key: 'gl', - get: function get() { - return this._gl; - } - }, { - key: 'globalLightColor', - set: function set(value) { - _glMatrix.vec3.copy(this._globalLightColor, value); - }, - get: function get() { - return _glMatrix.vec3.clone(this._globalLightColor); - } - }, { - key: 'globalLightDir', - set: function set(value) { - _glMatrix.vec3.copy(this._globalLightDir, value); - }, - get: function get() { - return _glMatrix.vec3.clone(this._globalLightDir); - } - }]); - - return Renderer; -}(); - -/***/ }), - -/***/ "./src/core/texture.js": -/*!*****************************!*\ - !*** ./src/core/texture.js ***! - \*****************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -// Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var GL = WebGLRenderingContext; // For enums - -var TextureSampler = exports.TextureSampler = function TextureSampler() { - _classCallCheck(this, TextureSampler); - - this.minFilter = null; - this.magFilter = null; - this.wrapS = null; - this.wrapT = null; -}; - -var Texture = exports.Texture = function () { - function Texture() { - _classCallCheck(this, Texture); - - this.sampler = new TextureSampler(); - this.mipmap = true; - // TODO: Anisotropy - } - - _createClass(Texture, [{ - key: 'format', - get: function get() { - return GL.RGBA; - } - }, { - key: 'width', - get: function get() { - return 0; - } - }, { - key: 'height', - get: function get() { - return 0; - } - }, { - key: 'textureKey', - get: function get() { - return null; - } - }]); - - return Texture; -}(); - -var ImageTexture = exports.ImageTexture = function (_Texture) { - _inherits(ImageTexture, _Texture); - - function ImageTexture(img) { - _classCallCheck(this, ImageTexture); - - var _this = _possibleConstructorReturn(this, (ImageTexture.__proto__ || Object.getPrototypeOf(ImageTexture)).call(this)); - - _this._img = img; - _this._imgBitmap = null; - - if (img.src && img.complete) { - if (img.naturalWidth) { - _this._promise = _this._finishImage(); - } else { - _this._promise = Promise.reject('Image provided had failed to load.'); - } - } else { - _this._promise = new Promise(function (resolve, reject) { - img.addEventListener('load', function () { - return resolve(_this._finishImage()); - }); - img.addEventListener('error', reject); - }); - } - return _this; - } - - _createClass(ImageTexture, [{ - key: '_finishImage', - value: function _finishImage() { - var _this2 = this; - - if (window.createImageBitmap) { - return window.createImageBitmap(this._img).then(function (imgBitmap) { - _this2._imgBitmap = imgBitmap; - return Promise.resolve(_this2); - }); - } - return Promise.resolve(this); - } - }, { - key: 'waitForComplete', - value: function waitForComplete() { - return this._promise; - } - }, { - key: 'format', - get: function get() { - // TODO: Can be RGB in some cases. - return GL.RGBA; - } - }, { - key: 'width', - get: function get() { - return this._img.width; - } - }, { - key: 'height', - get: function get() { - return this._img.height; - } - }, { - key: 'textureKey', - get: function get() { - return this._img.src; - } - }, { - key: 'source', - get: function get() { - return this._imgBitmap || this._img; - } - }]); - - return ImageTexture; -}(Texture); - -var UrlTexture = exports.UrlTexture = function (_ImageTexture) { - _inherits(UrlTexture, _ImageTexture); - - function UrlTexture(url) { - _classCallCheck(this, UrlTexture); - - var img = new Image(); - - var _this3 = _possibleConstructorReturn(this, (UrlTexture.__proto__ || Object.getPrototypeOf(UrlTexture)).call(this, img)); - - img.src = url; - return _this3; - } - - return UrlTexture; -}(ImageTexture); - -var BlobTexture = exports.BlobTexture = function (_ImageTexture2) { - _inherits(BlobTexture, _ImageTexture2); - - function BlobTexture(blob) { - _classCallCheck(this, BlobTexture); - - var img = new Image(); - - var _this4 = _possibleConstructorReturn(this, (BlobTexture.__proto__ || Object.getPrototypeOf(BlobTexture)).call(this, img)); - - img.src = window.URL.createObjectURL(blob); - return _this4; - } - - return BlobTexture; -}(ImageTexture); - -var VideoTexture = exports.VideoTexture = function (_Texture2) { - _inherits(VideoTexture, _Texture2); - - function VideoTexture(video) { - _classCallCheck(this, VideoTexture); - - var _this5 = _possibleConstructorReturn(this, (VideoTexture.__proto__ || Object.getPrototypeOf(VideoTexture)).call(this)); - - _this5._video = video; - - if (video.readyState >= 2) { - _this5._promise = Promise.resolve(_this5); - } else if (video.error) { - _this5._promise = Promise.reject(video.error); - } else { - _this5._promise = new Promise(function (resolve, reject) { - video.addEventListener('loadeddata', function () { - return resolve(_this5); - }); - video.addEventListener('error', reject); - }); - } - return _this5; - } - - _createClass(VideoTexture, [{ - key: 'waitForComplete', - value: function waitForComplete() { - return this._promise; - } - }, { - key: 'format', - get: function get() { - // TODO: Can be RGB in some cases. - return GL.RGBA; - } - }, { - key: 'width', - get: function get() { - return this._video.videoWidth; - } - }, { - key: 'height', - get: function get() { - return this._video.videoHeight; - } - }, { - key: 'textureKey', - get: function get() { - return this._video.src; - } - }, { - key: 'source', - get: function get() { - return this._video; - } - }]); - - return VideoTexture; -}(Texture); - -var nextDataTextureIndex = 0; - -var DataTexture = exports.DataTexture = function (_Texture3) { - _inherits(DataTexture, _Texture3); - - function DataTexture(data, width, height) { - var format = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : GL.RGBA; - var type = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : GL.UNSIGNED_BYTE; - - _classCallCheck(this, DataTexture); - - var _this6 = _possibleConstructorReturn(this, (DataTexture.__proto__ || Object.getPrototypeOf(DataTexture)).call(this)); - - _this6._data = data; - _this6._width = width; - _this6._height = height; - _this6._format = format; - _this6._type = type; - _this6._key = 'DATA_' + nextDataTextureIndex; - nextDataTextureIndex++; - return _this6; - } - - _createClass(DataTexture, [{ - key: 'format', - get: function get() { - return this._format; - } - }, { - key: 'width', - get: function get() { - return this._width; - } - }, { - key: 'height', - get: function get() { - return this._height; - } - }, { - key: 'textureKey', - get: function get() { - return this._key; - } - }]); - - return DataTexture; -}(Texture); - -var ColorTexture = exports.ColorTexture = function (_DataTexture) { - _inherits(ColorTexture, _DataTexture); - - function ColorTexture(r, g, b, a) { - _classCallCheck(this, ColorTexture); - - var colorData = new Uint8Array([r * 255.0, g * 255.0, b * 255.0, a * 255.0]); - - var _this7 = _possibleConstructorReturn(this, (ColorTexture.__proto__ || Object.getPrototypeOf(ColorTexture)).call(this, colorData, 1, 1)); - - _this7.mipmap = false; - _this7._key = 'COLOR_' + colorData[0] + '_' + colorData[1] + '_' + colorData[2] + '_' + colorData[3]; - return _this7; - } - - return ColorTexture; -}(DataTexture); - -/***/ }), - -/***/ "./src/cottontail.js": -/*!***************************!*\ - !*** ./src/cottontail.js ***! - \***************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _node = __webpack_require__(/*! ./core/node.js */ "./src/core/node.js"); - -Object.defineProperty(exports, 'Node', { - enumerable: true, - get: function get() { - return _node.Node; - } -}); - -var _renderer = __webpack_require__(/*! ./core/renderer.js */ "./src/core/renderer.js"); - -Object.defineProperty(exports, 'Renderer', { - enumerable: true, - get: function get() { - return _renderer.Renderer; - } -}); -Object.defineProperty(exports, 'createWebGLContext', { - enumerable: true, - get: function get() { - return _renderer.createWebGLContext; - } -}); - -var _texture = __webpack_require__(/*! ./core/texture.js */ "./src/core/texture.js"); - -Object.defineProperty(exports, 'UrlTexture', { - enumerable: true, - get: function get() { - return _texture.UrlTexture; - } -}); - -var _primitiveStream = __webpack_require__(/*! ./geometry/primitive-stream.js */ "./src/geometry/primitive-stream.js"); - -Object.defineProperty(exports, 'PrimitiveStream', { - enumerable: true, - get: function get() { - return _primitiveStream.PrimitiveStream; - } -}); - -var _boxBuilder = __webpack_require__(/*! ./geometry/box-builder.js */ "./src/geometry/box-builder.js"); - -Object.defineProperty(exports, 'BoxBuilder', { - enumerable: true, - get: function get() { - return _boxBuilder.BoxBuilder; - } -}); - -var _pbr = __webpack_require__(/*! ./materials/pbr.js */ "./src/materials/pbr.js"); - -Object.defineProperty(exports, 'PbrMaterial', { - enumerable: true, - get: function get() { - return _pbr.PbrMaterial; - } -}); - -var _glMatrix = __webpack_require__(/*! ./math/gl-matrix.js */ "./src/math/gl-matrix.js"); - -Object.defineProperty(exports, 'mat4', { - enumerable: true, - get: function get() { - return _glMatrix.mat4; - } -}); -Object.defineProperty(exports, 'mat3', { - enumerable: true, - get: function get() { - return _glMatrix.mat3; - } -}); -Object.defineProperty(exports, 'vec3', { - enumerable: true, - get: function get() { - return _glMatrix.vec3; - } -}); -Object.defineProperty(exports, 'vec4', { - enumerable: true, - get: function get() { - return _glMatrix.vec4; - } -}); -Object.defineProperty(exports, 'quat', { - enumerable: true, - get: function get() { - return _glMatrix.quat; - } -}); - -var _boundsRenderer = __webpack_require__(/*! ./nodes/bounds-renderer.js */ "./src/nodes/bounds-renderer.js"); - -Object.defineProperty(exports, 'BoundsRenderer', { - enumerable: true, - get: function get() { - return _boundsRenderer.BoundsRenderer; - } -}); - -var _button = __webpack_require__(/*! ./nodes/button.js */ "./src/nodes/button.js"); - -Object.defineProperty(exports, 'ButtonNode', { - enumerable: true, - get: function get() { - return _button.ButtonNode; - } -}); - -var _dropShadow = __webpack_require__(/*! ./nodes/drop-shadow.js */ "./src/nodes/drop-shadow.js"); - -Object.defineProperty(exports, 'DropShadowNode', { - enumerable: true, - get: function get() { - return _dropShadow.DropShadowNode; - } -}); - -var _cubeSea = __webpack_require__(/*! ./nodes/cube-sea.js */ "./src/nodes/cube-sea.js"); - -Object.defineProperty(exports, 'CubeSeaNode', { - enumerable: true, - get: function get() { - return _cubeSea.CubeSeaNode; - } -}); - -var _gltf = __webpack_require__(/*! ./nodes/gltf2.js */ "./src/nodes/gltf2.js"); - -Object.defineProperty(exports, 'Gltf2Node', { - enumerable: true, - get: function get() { - return _gltf.Gltf2Node; - } -}); - -var _skybox = __webpack_require__(/*! ./nodes/skybox.js */ "./src/nodes/skybox.js"); - -Object.defineProperty(exports, 'SkyboxNode', { - enumerable: true, - get: function get() { - return _skybox.SkyboxNode; - } -}); - -var _video = __webpack_require__(/*! ./nodes/video.js */ "./src/nodes/video.js"); - -Object.defineProperty(exports, 'VideoNode', { - enumerable: true, - get: function get() { - return _video.VideoNode; - } -}); - -var _scene = __webpack_require__(/*! ./scenes/scene.js */ "./src/scenes/scene.js"); - -Object.defineProperty(exports, 'WebXRView', { - enumerable: true, - get: function get() { - return _scene.WebXRView; - } -}); -Object.defineProperty(exports, 'Scene', { - enumerable: true, - get: function get() { - return _scene.Scene; - } -}); - -var _fallbackHelper = __webpack_require__(/*! ./util/fallback-helper.js */ "./src/util/fallback-helper.js"); - -Object.defineProperty(exports, 'FallbackHelper', { - enumerable: true, - get: function get() { - return _fallbackHelper.FallbackHelper; - } -}); - -var _queryArgs = __webpack_require__(/*! ./util/query-args.js */ "./src/util/query-args.js"); - -Object.defineProperty(exports, 'QueryArgs', { - enumerable: true, - get: function get() { - return _queryArgs.QueryArgs; - } -}); - -/***/ }), - -/***/ "./src/geometry/box-builder.js": -/*!*************************************!*\ - !*** ./src/geometry/box-builder.js ***! - \*************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.BoxBuilder = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _primitiveStream = __webpack_require__(/*! ./primitive-stream.js */ "./src/geometry/primitive-stream.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var BoxBuilder = exports.BoxBuilder = function (_GeometryBuilderBase) { - _inherits(BoxBuilder, _GeometryBuilderBase); - - function BoxBuilder() { - _classCallCheck(this, BoxBuilder); - - return _possibleConstructorReturn(this, (BoxBuilder.__proto__ || Object.getPrototypeOf(BoxBuilder)).apply(this, arguments)); - } - - _createClass(BoxBuilder, [{ - key: 'pushBox', - value: function pushBox(min, max) { - var stream = this.primitiveStream; - - var w = max[0] - min[0]; - var h = max[1] - min[1]; - var d = max[2] - min[2]; - - var wh = w * 0.5; - var hh = h * 0.5; - var dh = d * 0.5; - - var cx = min[0] + wh; - var cy = min[1] + hh; - var cz = min[2] + dh; - - stream.startGeometry(); - - // Bottom - var idx = stream.nextVertexIndex; - stream.pushTriangle(idx, idx + 1, idx + 2); - stream.pushTriangle(idx, idx + 2, idx + 3); - - // X Y Z U V NX NY NZ - stream.pushVertex(-wh + cx, -hh + cy, -dh + cz, 0.0, 1.0, 0.0, -1.0, 0.0); - stream.pushVertex(+wh + cx, -hh + cy, -dh + cz, 1.0, 1.0, 0.0, -1.0, 0.0); - stream.pushVertex(+wh + cx, -hh + cy, +dh + cz, 1.0, 0.0, 0.0, -1.0, 0.0); - stream.pushVertex(-wh + cx, -hh + cy, +dh + cz, 0.0, 0.0, 0.0, -1.0, 0.0); - - // Top - idx = stream.nextVertexIndex; - stream.pushTriangle(idx, idx + 2, idx + 1); - stream.pushTriangle(idx, idx + 3, idx + 2); - - stream.pushVertex(-wh + cx, +hh + cy, -dh + cz, 0.0, 0.0, 0.0, 1.0, 0.0); - stream.pushVertex(+wh + cx, +hh + cy, -dh + cz, 1.0, 0.0, 0.0, 1.0, 0.0); - stream.pushVertex(+wh + cx, +hh + cy, +dh + cz, 1.0, 1.0, 0.0, 1.0, 0.0); - stream.pushVertex(-wh + cx, +hh + cy, +dh + cz, 0.0, 1.0, 0.0, 1.0, 0.0); - - // Left - idx = stream.nextVertexIndex; - stream.pushTriangle(idx, idx + 2, idx + 1); - stream.pushTriangle(idx, idx + 3, idx + 2); - - stream.pushVertex(-wh + cx, -hh + cy, -dh + cz, 0.0, 1.0, -1.0, 0.0, 0.0); - stream.pushVertex(-wh + cx, +hh + cy, -dh + cz, 0.0, 0.0, -1.0, 0.0, 0.0); - stream.pushVertex(-wh + cx, +hh + cy, +dh + cz, 1.0, 0.0, -1.0, 0.0, 0.0); - stream.pushVertex(-wh + cx, -hh + cy, +dh + cz, 1.0, 1.0, -1.0, 0.0, 0.0); - - // Right - idx = stream.nextVertexIndex; - stream.pushTriangle(idx, idx + 1, idx + 2); - stream.pushTriangle(idx, idx + 2, idx + 3); - - stream.pushVertex(+wh + cx, -hh + cy, -dh + cz, 1.0, 1.0, 1.0, 0.0, 0.0); - stream.pushVertex(+wh + cx, +hh + cy, -dh + cz, 1.0, 0.0, 1.0, 0.0, 0.0); - stream.pushVertex(+wh + cx, +hh + cy, +dh + cz, 0.0, 0.0, 1.0, 0.0, 0.0); - stream.pushVertex(+wh + cx, -hh + cy, +dh + cz, 0.0, 1.0, 1.0, 0.0, 0.0); - - // Back - idx = stream.nextVertexIndex; - stream.pushTriangle(idx, idx + 2, idx + 1); - stream.pushTriangle(idx, idx + 3, idx + 2); - - stream.pushVertex(-wh + cx, -hh + cy, -dh + cz, 1.0, 1.0, 0.0, 0.0, -1.0); - stream.pushVertex(+wh + cx, -hh + cy, -dh + cz, 0.0, 1.0, 0.0, 0.0, -1.0); - stream.pushVertex(+wh + cx, +hh + cy, -dh + cz, 0.0, 0.0, 0.0, 0.0, -1.0); - stream.pushVertex(-wh + cx, +hh + cy, -dh + cz, 1.0, 0.0, 0.0, 0.0, -1.0); - - // Front - idx = stream.nextVertexIndex; - stream.pushTriangle(idx, idx + 1, idx + 2); - stream.pushTriangle(idx, idx + 2, idx + 3); - - stream.pushVertex(-wh + cx, -hh + cy, +dh + cz, 0.0, 1.0, 0.0, 0.0, 1.0); - stream.pushVertex(+wh + cx, -hh + cy, +dh + cz, 1.0, 1.0, 0.0, 0.0, 1.0); - stream.pushVertex(+wh + cx, +hh + cy, +dh + cz, 1.0, 0.0, 0.0, 0.0, 1.0); - stream.pushVertex(-wh + cx, +hh + cy, +dh + cz, 0.0, 0.0, 0.0, 0.0, 1.0); - - stream.endGeometry(); - } - }, { - key: 'pushCube', - value: function pushCube() { - var center = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [0, 0, 0]; - var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1.0; - - var hs = size * 0.5; - this.pushBox([center[0] - hs, center[1] - hs, center[2] - hs], [center[0] + hs, center[1] + hs, center[2] + hs]); - } - }]); - - return BoxBuilder; -}(_primitiveStream.GeometryBuilderBase); - -/***/ }), - -/***/ "./src/geometry/primitive-stream.js": -/*!******************************************!*\ - !*** ./src/geometry/primitive-stream.js ***! - \******************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.GeometryBuilderBase = exports.PrimitiveStream = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var _primitive = __webpack_require__(/*! ../core/primitive.js */ "./src/core/primitive.js"); - -var _glMatrix = __webpack_require__(/*! ../math/gl-matrix.js */ "./src/math/gl-matrix.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var GL = WebGLRenderingContext; // For enums - -var tempVec3 = _glMatrix.vec3.create(); - -var PrimitiveStream = exports.PrimitiveStream = function () { - function PrimitiveStream(options) { - _classCallCheck(this, PrimitiveStream); - - this._vertices = []; - this._indices = []; - - this._geometryStarted = false; - - this._vertexOffset = 0; - this._vertexIndex = 0; - this._highIndex = 0; - - this._flipWinding = false; - this._invertNormals = false; - this._transform = null; - this._normalTransform = null; - this._min = null; - this._max = null; - } - - _createClass(PrimitiveStream, [{ - key: 'startGeometry', - value: function startGeometry() { - if (this._geometryStarted) { - throw new Error('Attempted to start a new geometry before the previous one was ended.'); - } - - this._geometryStarted = true; - this._vertexIndex = 0; - this._highIndex = 0; - } - }, { - key: 'endGeometry', - value: function endGeometry() { - if (!this._geometryStarted) { - throw new Error('Attempted to end a geometry before one was started.'); - } - - if (this._highIndex >= this._vertexIndex) { - throw new Error('Geometry contains indices that are out of bounds.\n (Contains an index of ' + this._highIndex + ' when the vertex count is ' + this._vertexIndex + ')'); - } - - this._geometryStarted = false; - this._vertexOffset += this._vertexIndex; - - // TODO: Anything else need to be done to finish processing here? - } - }, { - key: 'pushVertex', - value: function pushVertex(x, y, z) { - var u = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; - var v = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; - var nx = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0; - var ny = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0; - var nz = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 1; - - if (!this._geometryStarted) { - throw new Error('Cannot push vertices before calling startGeometry().'); - } - - // Transform the incoming vertex if we have a transformation matrix - if (this._transform) { - tempVec3[0] = x; - tempVec3[1] = y; - tempVec3[2] = z; - _glMatrix.vec3.transformMat4(tempVec3, tempVec3, this._transform); - x = tempVec3[0]; - y = tempVec3[1]; - z = tempVec3[2]; - - tempVec3[0] = nx; - tempVec3[1] = ny; - tempVec3[2] = nz; - _glMatrix.vec3.transformMat3(tempVec3, tempVec3, this._normalTransform); - nx = tempVec3[0]; - ny = tempVec3[1]; - nz = tempVec3[2]; - } - - if (this._invertNormals) { - nx *= -1.0; - ny *= -1.0; - nz *= -1.0; - } - - this._vertices.push(x, y, z, u, v, nx, ny, nz); - - if (this._min) { - this._min[0] = Math.min(this._min[0], x); - this._min[1] = Math.min(this._min[1], y); - this._min[2] = Math.min(this._min[2], z); - this._max[0] = Math.max(this._max[0], x); - this._max[1] = Math.max(this._max[1], y); - this._max[2] = Math.max(this._max[2], z); - } else { - this._min = _glMatrix.vec3.fromValues(x, y, z); - this._max = _glMatrix.vec3.fromValues(x, y, z); - } - - return this._vertexIndex++; - } - }, { - key: 'pushTriangle', - value: function pushTriangle(idxA, idxB, idxC) { - if (!this._geometryStarted) { - throw new Error('Cannot push triangles before calling startGeometry().'); - } - - this._highIndex = Math.max(this._highIndex, idxA, idxB, idxC); - - idxA += this._vertexOffset; - idxB += this._vertexOffset; - idxC += this._vertexOffset; - - if (this._flipWinding) { - this._indices.push(idxC, idxB, idxA); - } else { - this._indices.push(idxA, idxB, idxC); - } - } - }, { - key: 'clear', - value: function clear() { - if (this._geometryStarted) { - throw new Error('Cannot clear before ending the current geometry.'); - } - - this._vertices = []; - this._indices = []; - this._vertexOffset = 0; - this._min = null; - this._max = null; - } - }, { - key: 'finishPrimitive', - value: function finishPrimitive(renderer) { - if (!this._vertexOffset) { - throw new Error('Attempted to call finishPrimitive() before creating any geometry.'); - } - - var vertexBuffer = renderer.createRenderBuffer(GL.ARRAY_BUFFER, new Float32Array(this._vertices)); - var indexBuffer = renderer.createRenderBuffer(GL.ELEMENT_ARRAY_BUFFER, new Uint16Array(this._indices)); - - var attribs = [new _primitive.PrimitiveAttribute('POSITION', vertexBuffer, 3, GL.FLOAT, 32, 0), new _primitive.PrimitiveAttribute('TEXCOORD_0', vertexBuffer, 2, GL.FLOAT, 32, 12), new _primitive.PrimitiveAttribute('NORMAL', vertexBuffer, 3, GL.FLOAT, 32, 20)]; - - var primitive = new _primitive.Primitive(attribs, this._indices.length); - primitive.setIndexBuffer(indexBuffer); - primitive.setBounds(this._min, this._max); - - return primitive; - } - }, { - key: 'flipWinding', - set: function set(value) { - if (this._geometryStarted) { - throw new Error('Cannot change flipWinding before ending the current geometry.'); - } - this._flipWinding = value; - }, - get: function get() { - this._flipWinding; - } - }, { - key: 'invertNormals', - set: function set(value) { - if (this._geometryStarted) { - throw new Error('Cannot change invertNormals before ending the current geometry.'); - } - this._invertNormals = value; - }, - get: function get() { - this._invertNormals; - } - }, { - key: 'transform', - set: function set(value) { - if (this._geometryStarted) { - throw new Error('Cannot change transform before ending the current geometry.'); - } - this._transform = value; - if (this._transform) { - if (!this._normalTransform) { - this._normalTransform = _glMatrix.mat3.create(); - } - _glMatrix.mat3.fromMat4(this._normalTransform, this._transform); - } - }, - get: function get() { - this._transform; - } - }, { - key: 'nextVertexIndex', - get: function get() { - return this._vertexIndex; - } - }]); - - return PrimitiveStream; -}(); - -var GeometryBuilderBase = exports.GeometryBuilderBase = function () { - function GeometryBuilderBase(primitiveStream) { - _classCallCheck(this, GeometryBuilderBase); - - if (primitiveStream) { - this._stream = primitiveStream; - } else { - this._stream = new PrimitiveStream(); - } - } - - _createClass(GeometryBuilderBase, [{ - key: 'finishPrimitive', - value: function finishPrimitive(renderer) { - return this._stream.finishPrimitive(renderer); - } - }, { - key: 'clear', - value: function clear() { - this._stream.clear(); - } - }, { - key: 'primitiveStream', - set: function set(value) { - this._stream = value; - }, - get: function get() { - return this._stream; - } - }]); - - return GeometryBuilderBase; -}(); - -/***/ }), - -/***/ "./src/loaders/gltf2.js": -/*!******************************!*\ - !*** ./src/loaders/gltf2.js ***! - \******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Gltf2Loader = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var _pbr = __webpack_require__(/*! ../materials/pbr.js */ "./src/materials/pbr.js"); - -var _node2 = __webpack_require__(/*! ../core/node.js */ "./src/core/node.js"); - -var _primitive = __webpack_require__(/*! ../core/primitive.js */ "./src/core/primitive.js"); - -var _texture = __webpack_require__(/*! ../core/texture.js */ "./src/core/texture.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var GL = WebGLRenderingContext; // For enums - -var GLB_MAGIC = 0x46546C67; -var CHUNK_TYPE = { - JSON: 0x4E4F534A, - BIN: 0x004E4942 -}; - -function isAbsoluteUri(uri) { - var absRegEx = new RegExp('^' + window.location.protocol, 'i'); - return !!uri.match(absRegEx); -} - -function isDataUri(uri) { - var dataRegEx = /^data:/; - return !!uri.match(dataRegEx); -} - -function resolveUri(uri, baseUrl) { - if (isAbsoluteUri(uri) || isDataUri(uri)) { - return uri; - } - return baseUrl + uri; -} - -function getComponentCount(type) { - switch (type) { - case 'SCALAR': - return 1; - case 'VEC2': - return 2; - case 'VEC3': - return 3; - case 'VEC4': - return 4; - default: - return 0; - } -} - -/** - * Gltf2SceneLoader - * Loads glTF 2.0 scenes into a renderable node tree. - */ - -var Gltf2Loader = exports.Gltf2Loader = function () { - function Gltf2Loader(renderer) { - _classCallCheck(this, Gltf2Loader); - - this.renderer = renderer; - this._gl = renderer._gl; - } - - _createClass(Gltf2Loader, [{ - key: 'loadFromUrl', - value: function loadFromUrl(url) { - var _this = this; - - return fetch(url).then(function (response) { - var i = url.lastIndexOf('/'); - var baseUrl = i !== 0 ? url.substring(0, i + 1) : ''; - - if (url.endsWith('.gltf')) { - return response.json().then(function (json) { - return _this.loadFromJson(json, baseUrl); - }); - } else if (url.endsWith('.glb')) { - return response.arrayBuffer().then(function (arrayBuffer) { - return _this.loadFromBinary(arrayBuffer, baseUrl); - }); - } else { - throw new Error('Unrecognized file extension'); - } - }); - } - }, { - key: 'loadFromBinary', - value: function loadFromBinary(arrayBuffer, baseUrl) { - var headerView = new DataView(arrayBuffer, 0, 12); - var magic = headerView.getUint32(0, true); - var version = headerView.getUint32(4, true); - var length = headerView.getUint32(8, true); - - if (magic != GLB_MAGIC) { - throw new Error('Invalid magic string in binary header.'); - } - - if (version != 2) { - throw new Error('Incompatible version in binary header.'); - } - - var chunks = {}; - var chunkOffset = 12; - while (chunkOffset < length) { - var chunkHeaderView = new DataView(arrayBuffer, chunkOffset, 8); - var chunkLength = chunkHeaderView.getUint32(0, true); - var chunkType = chunkHeaderView.getUint32(4, true); - chunks[chunkType] = arrayBuffer.slice(chunkOffset + 8, chunkOffset + 8 + chunkLength); - chunkOffset += chunkLength + 8; - } - - if (!chunks[CHUNK_TYPE.JSON]) { - throw new Error('File contained no json chunk.'); - } - - var decoder = new TextDecoder('utf-8'); - var jsonString = decoder.decode(chunks[CHUNK_TYPE.JSON]); - var json = JSON.parse(jsonString); - return this.loadFromJson(json, baseUrl, chunks[CHUNK_TYPE.BIN]); - } - }, { - key: 'loadFromJson', - value: function loadFromJson(json, baseUrl, binaryChunk) { - if (!json.asset) { - throw new Error('Missing asset description.'); - } - - if (json.asset.minVersion != '2.0' && json.asset.version != '2.0') { - throw new Error('Incompatible asset version.'); - } - - var buffers = []; - if (binaryChunk) { - buffers[0] = new Gltf2Resource({}, baseUrl, binaryChunk); - } else { - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = json.buffers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var buffer = _step.value; - - buffers.push(new Gltf2Resource(buffer, baseUrl)); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - } - - var bufferViews = []; - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; - - try { - for (var _iterator2 = json.bufferViews[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var bufferView = _step2.value; - - bufferViews.push(new Gltf2BufferView(bufferView, buffers)); - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } - - var images = []; - if (json.images) { - var _iteratorNormalCompletion3 = true; - var _didIteratorError3 = false; - var _iteratorError3 = undefined; - - try { - for (var _iterator3 = json.images[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { - var image = _step3.value; - - images.push(new Gltf2Resource(image, baseUrl)); - } - } catch (err) { - _didIteratorError3 = true; - _iteratorError3 = err; - } finally { - try { - if (!_iteratorNormalCompletion3 && _iterator3.return) { - _iterator3.return(); - } - } finally { - if (_didIteratorError3) { - throw _iteratorError3; - } - } - } - } - - var textures = []; - if (json.textures) { - var _iteratorNormalCompletion4 = true; - var _didIteratorError4 = false; - var _iteratorError4 = undefined; - - try { - for (var _iterator4 = json.textures[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { - var texture = _step4.value; - - var _image = images[texture.source]; - var glTexture = _image.texture(bufferViews); - if (texture.sampler) { - var sampler = sampler[texture.sampler]; - glTexture.sampler.minFilter = sampler.minFilter; - glTexture.sampler.magFilter = sampler.magFilter; - glTexture.sampler.wrapS = sampler.wrapS; - glTexture.sampler.wrapT = sampler.wrapT; - } - textures.push(glTexture); - } - } catch (err) { - _didIteratorError4 = true; - _iteratorError4 = err; - } finally { - try { - if (!_iteratorNormalCompletion4 && _iterator4.return) { - _iterator4.return(); - } - } finally { - if (_didIteratorError4) { - throw _iteratorError4; - } - } - } - } - - function getTexture(textureInfo) { - if (!textureInfo) { - return null; - } - return textures[textureInfo.index]; - } - - var materials = []; - if (json.materials) { - var _iteratorNormalCompletion5 = true; - var _didIteratorError5 = false; - var _iteratorError5 = undefined; - - try { - for (var _iterator5 = json.materials[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { - var material = _step5.value; - - var glMaterial = new _pbr.PbrMaterial(); - var pbr = material.pbrMetallicRoughness || {}; - - glMaterial.baseColorFactor.value = pbr.baseColorFactor || [1, 1, 1, 1]; - glMaterial.baseColor.texture = getTexture(pbr.baseColorTexture); - glMaterial.metallicRoughnessFactor.value = [pbr.metallicFactor || 1.0, pbr.roughnessFactor || 1.0]; - glMaterial.metallicRoughness.texture = getTexture(pbr.metallicRoughnessTexture); - glMaterial.normal.texture = getTexture(json.normalTexture); - glMaterial.occlusion.texture = getTexture(json.occlusionTexture); - glMaterial.occlusionStrength.value = json.occlusionTexture && json.occlusionTexture.strength ? json.occlusionTexture.strength : 1.0; - glMaterial.emissiveFactor.value = material.emissiveFactor || [0, 0, 0]; - glMaterial.emissive.texture = getTexture(json.emissiveTexture); - if (!glMaterial.emissive.texture && json.emissiveFactor) { - glMaterial.emissive.texture = new _texture.ColorTexture(1.0, 1.0, 1.0, 1.0); - } - - switch (material.alphaMode) { - case 'BLEND': - glMaterial.state.blend = true; - break; - case 'MASK': - // Not really supported. - glMaterial.state.blend = true; - break; - default: - // Includes 'OPAQUE' - glMaterial.state.blend = false; - } - - // glMaterial.alpha_mode = material.alphaMode; - // glMaterial.alpha_cutoff = material.alphaCutoff; - glMaterial.state.cullFace = !material.doubleSided; - - materials.push(glMaterial); - } - } catch (err) { - _didIteratorError5 = true; - _iteratorError5 = err; - } finally { - try { - if (!_iteratorNormalCompletion5 && _iterator5.return) { - _iterator5.return(); - } - } finally { - if (_didIteratorError5) { - throw _iteratorError5; - } - } - } - } - - var accessors = json.accessors; - - var meshes = []; - var _iteratorNormalCompletion6 = true; - var _didIteratorError6 = false; - var _iteratorError6 = undefined; - - try { - for (var _iterator6 = json.meshes[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) { - var mesh = _step6.value; - - var glMesh = new Gltf2Mesh(); - meshes.push(glMesh); - - var _iteratorNormalCompletion8 = true; - var _didIteratorError8 = false; - var _iteratorError8 = undefined; - - try { - for (var _iterator8 = mesh.primitives[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) { - var primitive = _step8.value; - - var _material = null; - if ('material' in primitive) { - _material = materials[primitive.material]; - } else { - // Create a "default" material if the primitive has none. - _material = new _pbr.PbrMaterial(); - } - - var attributes = []; - var elementCount = 0; - /* let glPrimitive = new Gltf2Primitive(primitive, material); - glMesh.primitives.push(glPrimitive); */ - - var min = null; - var max = null; - - for (var name in primitive.attributes) { - var accessor = accessors[primitive.attributes[name]]; - var _bufferView = bufferViews[accessor.bufferView]; - elementCount = accessor.count; - - var glAttribute = new _primitive.PrimitiveAttribute(name, _bufferView.renderBuffer(this.renderer, GL.ARRAY_BUFFER), getComponentCount(accessor.type), accessor.componentType, _bufferView.byteStride || 0, accessor.byteOffset || 0); - glAttribute.normalized = accessor.normalized || false; - - if (name == 'POSITION') { - min = accessor.min; - max = accessor.max; - } - - attributes.push(glAttribute); - } - - var glPrimitive = new _primitive.Primitive(attributes, elementCount, primitive.mode); - - if ('indices' in primitive) { - var _accessor = accessors[primitive.indices]; - var _bufferView2 = bufferViews[_accessor.bufferView]; - - glPrimitive.setIndexBuffer(_bufferView2.renderBuffer(this.renderer, GL.ELEMENT_ARRAY_BUFFER), _accessor.byteOffset || 0, _accessor.componentType); - glPrimitive.indexType = _accessor.componentType; - glPrimitive.indexByteOffset = _accessor.byteOffset || 0; - glPrimitive.elementCount = _accessor.count; - } - - if (min && max) { - glPrimitive.setBounds(min, max); - } - - // After all the attributes have been processed, get a program that is - // appropriate for both the material and the primitive attributes. - glMesh.primitives.push(this.renderer.createRenderPrimitive(glPrimitive, _material)); - } - } catch (err) { - _didIteratorError8 = true; - _iteratorError8 = err; - } finally { - try { - if (!_iteratorNormalCompletion8 && _iterator8.return) { - _iterator8.return(); - } - } finally { - if (_didIteratorError8) { - throw _iteratorError8; - } - } - } - } - } catch (err) { - _didIteratorError6 = true; - _iteratorError6 = err; - } finally { - try { - if (!_iteratorNormalCompletion6 && _iterator6.return) { - _iterator6.return(); - } - } finally { - if (_didIteratorError6) { - throw _iteratorError6; - } - } - } - - var sceneNode = new _node2.Node(); - var scene = json.scenes[json.scene]; - var _iteratorNormalCompletion7 = true; - var _didIteratorError7 = false; - var _iteratorError7 = undefined; - - try { - for (var _iterator7 = scene.nodes[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) { - var nodeId = _step7.value; - - var node = json.nodes[nodeId]; - sceneNode.addNode(this.processNodes(node, json.nodes, meshes)); - } - } catch (err) { - _didIteratorError7 = true; - _iteratorError7 = err; - } finally { - try { - if (!_iteratorNormalCompletion7 && _iterator7.return) { - _iterator7.return(); - } - } finally { - if (_didIteratorError7) { - throw _iteratorError7; - } - } - } - - return sceneNode; - } - }, { - key: 'processNodes', - value: function processNodes(node, nodes, meshes) { - var glNode = new _node2.Node(); - glNode.name = node.name; - - if ('mesh' in node) { - var mesh = meshes[node.mesh]; - var _iteratorNormalCompletion9 = true; - var _didIteratorError9 = false; - var _iteratorError9 = undefined; - - try { - for (var _iterator9 = mesh.primitives[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) { - var primitive = _step9.value; - - glNode.addRenderPrimitive(primitive); - } - } catch (err) { - _didIteratorError9 = true; - _iteratorError9 = err; - } finally { - try { - if (!_iteratorNormalCompletion9 && _iterator9.return) { - _iterator9.return(); - } - } finally { - if (_didIteratorError9) { - throw _iteratorError9; - } - } - } - } - - if (node.matrix) { - glNode.matrix = new Float32Array(node.matrix); - } else if (node.translation || node.rotation || node.scale) { - if (node.translation) { - glNode.translation = new Float32Array(node.translation); - } - - if (node.rotation) { - glNode.rotation = new Float32Array(node.rotation); - } - - if (node.scale) { - glNode.scale = new Float32Array(node.scale); - } - } - - if (node.children) { - var _iteratorNormalCompletion10 = true; - var _didIteratorError10 = false; - var _iteratorError10 = undefined; - - try { - for (var _iterator10 = node.children[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) { - var nodeId = _step10.value; - - var _node = nodes[nodeId]; - glNode.addNode(this.processNodes(_node, nodes, meshes)); - } - } catch (err) { - _didIteratorError10 = true; - _iteratorError10 = err; - } finally { - try { - if (!_iteratorNormalCompletion10 && _iterator10.return) { - _iterator10.return(); - } - } finally { - if (_didIteratorError10) { - throw _iteratorError10; - } - } - } - } - - return glNode; - } - }]); - - return Gltf2Loader; -}(); - -var Gltf2Mesh = function Gltf2Mesh() { - _classCallCheck(this, Gltf2Mesh); - - this.primitives = []; -}; - -var Gltf2BufferView = function () { - function Gltf2BufferView(json, buffers) { - _classCallCheck(this, Gltf2BufferView); - - this.buffer = buffers[json.buffer]; - this.byteOffset = json.byteOffset || 0; - this.byteLength = json.byteLength || null; - this.byteStride = json.byteStride; - - this._viewPromise = null; - this._renderBuffer = null; - } - - _createClass(Gltf2BufferView, [{ - key: 'dataView', - value: function dataView() { - var _this2 = this; - - if (!this._viewPromise) { - this._viewPromise = this.buffer.arrayBuffer().then(function (arrayBuffer) { - return new DataView(arrayBuffer, _this2.byteOffset, _this2.byteLength); - }); - } - return this._viewPromise; - } - }, { - key: 'renderBuffer', - value: function renderBuffer(renderer, target) { - if (!this._renderBuffer) { - this._renderBuffer = renderer.createRenderBuffer(target, this.dataView()); - } - return this._renderBuffer; - } - }]); - - return Gltf2BufferView; -}(); - -var Gltf2Resource = function () { - function Gltf2Resource(json, baseUrl, arrayBuffer) { - _classCallCheck(this, Gltf2Resource); - - this.json = json; - this.baseUrl = baseUrl; - - this._dataPromise = null; - this._texture = null; - if (arrayBuffer) { - this._dataPromise = Promise.resolve(arrayBuffer); - } - } - - _createClass(Gltf2Resource, [{ - key: 'arrayBuffer', - value: function arrayBuffer() { - if (!this._dataPromise) { - if (isDataUri(this.json.uri)) { - var base64String = this.json.uri.replace('data:application/octet-stream;base64,', ''); - var binaryArray = Uint8Array.from(atob(base64String), function (c) { - return c.charCodeAt(0); - }); - this._dataPromise = Promise.resolve(binaryArray.buffer); - return this._dataPromise; - } - - this._dataPromise = fetch(resolveUri(this.json.uri, this.baseUrl)).then(function (response) { - return response.arrayBuffer(); - }); - } - return this._dataPromise; - } - }, { - key: 'texture', - value: function texture(bufferViews) { - var _this3 = this; - - if (!this._texture) { - var img = new Image(); - this._texture = new _texture.ImageTexture(img); - - if (this.json.uri) { - if (isDataUri(this.json.uri)) { - img.src = this.json.uri; - } else { - img.src = '' + this.baseUrl + this.json.uri; - } - } else { - var view = bufferViews[this.json.bufferView]; - view.dataView().then(function (dataView) { - var blob = new Blob([dataView], { type: _this3.json.mimeType }); - img.src = window.URL.createObjectURL(blob); - }); - } - } - return this._texture; - } - }]); - - return Gltf2Resource; -}(); - -/***/ }), - -/***/ "./src/materials/pbr.js": -/*!******************************!*\ - !*** ./src/materials/pbr.js ***! - \******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.PbrMaterial = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _material = __webpack_require__(/*! ../core/material.js */ "./src/core/material.js"); - -var _renderer = __webpack_require__(/*! ../core/renderer.js */ "./src/core/renderer.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var VERTEX_SOURCE = '\nattribute vec3 POSITION, NORMAL;\nattribute vec2 TEXCOORD_0, TEXCOORD_1;\n\nuniform vec3 CAMERA_POSITION;\nuniform vec3 LIGHT_DIRECTION;\n\nvarying vec3 vLight; // Vector from vertex to light.\nvarying vec3 vView; // Vector from vertex to camera.\nvarying vec2 vTex;\n\n#ifdef USE_NORMAL_MAP\nattribute vec4 TANGENT;\nvarying mat3 vTBN;\n#else\nvarying vec3 vNorm;\n#endif\n\n#ifdef USE_VERTEX_COLOR\nattribute vec4 COLOR_0;\nvarying vec4 vCol;\n#endif\n\nvec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vec3 n = normalize(vec3(model * vec4(NORMAL, 0.0)));\n#ifdef USE_NORMAL_MAP\n vec3 t = normalize(vec3(model * vec4(TANGENT.xyz, 0.0)));\n vec3 b = cross(n, t) * TANGENT.w;\n vTBN = mat3(t, b, n);\n#else\n vNorm = n;\n#endif\n\n#ifdef USE_VERTEX_COLOR\n vCol = COLOR_0;\n#endif\n\n vTex = TEXCOORD_0;\n vec4 mPos = model * vec4(POSITION, 1.0);\n vLight = -LIGHT_DIRECTION;\n vView = CAMERA_POSITION - mPos.xyz;\n return proj * view * mPos;\n}'; - -// These equations are borrowed with love from this docs from Epic because I -// just don't have anything novel to bring to the PBR scene. -// http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf -var EPIC_PBR_FUNCTIONS = '\nvec3 lambertDiffuse(vec3 cDiff) {\n return cDiff / M_PI;\n}\n\nfloat specD(float a, float nDotH) {\n float aSqr = a * a;\n float f = ((nDotH * nDotH) * (aSqr - 1.0) + 1.0);\n return aSqr / (M_PI * f * f);\n}\n\nfloat specG(float roughness, float nDotL, float nDotV) {\n float k = (roughness + 1.0) * (roughness + 1.0) / 8.0;\n float gl = nDotL / (nDotL * (1.0 - k) + k);\n float gv = nDotV / (nDotV * (1.0 - k) + k);\n return gl * gv;\n}\n\nvec3 specF(float vDotH, vec3 F0) {\n float exponent = (-5.55473 * vDotH - 6.98316) * vDotH;\n float base = 2.0;\n return F0 + (1.0 - F0) * pow(base, exponent);\n}'; - -var FRAGMENT_SOURCE = '\n#define M_PI 3.14159265\n\nuniform vec4 baseColorFactor;\n#ifdef USE_BASE_COLOR_MAP\nuniform sampler2D baseColorTex;\n#endif\n\nvarying vec3 vLight;\nvarying vec3 vView;\nvarying vec2 vTex;\n\n#ifdef USE_VERTEX_COLOR\nvarying vec4 vCol;\n#endif\n\n#ifdef USE_NORMAL_MAP\nuniform sampler2D normalTex;\nvarying mat3 vTBN;\n#else\nvarying vec3 vNorm;\n#endif\n\n#ifdef USE_METAL_ROUGH_MAP\nuniform sampler2D metallicRoughnessTex;\n#endif\nuniform vec2 metallicRoughnessFactor;\n\n#ifdef USE_OCCLUSION\nuniform sampler2D occlusionTex;\nuniform float occlusionStrength;\n#endif\n\n#ifdef USE_EMISSIVE_TEXTURE\nuniform sampler2D emissiveTex;\n#endif\nuniform vec3 emissiveFactor;\n\nuniform vec3 LIGHT_COLOR;\n\nconst vec3 dielectricSpec = vec3(0.04);\nconst vec3 black = vec3(0.0);\n\n' + EPIC_PBR_FUNCTIONS + '\n\nvec4 fragment_main() {\n#ifdef USE_BASE_COLOR_MAP\n vec4 baseColor = texture2D(baseColorTex, vTex) * baseColorFactor;\n#else\n vec4 baseColor = baseColorFactor;\n#endif\n\n#ifdef USE_VERTEX_COLOR\n baseColor *= vCol;\n#endif\n\n#ifdef USE_NORMAL_MAP\n vec3 n = texture2D(normalTex, vTex).rgb;\n n = normalize(vTBN * (2.0 * n - 1.0));\n#else\n vec3 n = normalize(vNorm);\n#endif\n\n#ifdef FULLY_ROUGH\n float metallic = 0.0;\n#else\n float metallic = metallicRoughnessFactor.x;\n#endif\n\n float roughness = metallicRoughnessFactor.y;\n\n#ifdef USE_METAL_ROUGH_MAP\n vec4 metallicRoughness = texture2D(metallicRoughnessTex, vTex);\n metallic *= metallicRoughness.b;\n roughness *= metallicRoughness.g;\n#endif\n \n vec3 l = normalize(vLight);\n vec3 v = normalize(vView);\n vec3 h = normalize(l+v);\n\n float nDotL = clamp(dot(n, l), 0.001, 1.0);\n float nDotV = abs(dot(n, v)) + 0.001;\n float nDotH = max(dot(n, h), 0.0);\n float vDotH = max(dot(v, h), 0.0);\n\n // From GLTF Spec\n vec3 cDiff = mix(baseColor.rgb * (1.0 - dielectricSpec.r), black, metallic); // Diffuse color\n vec3 F0 = mix(dielectricSpec, baseColor.rgb, metallic); // Specular color\n float a = roughness * roughness;\n\n#ifdef FULLY_ROUGH\n vec3 specular = F0 * 0.45;\n#else\n vec3 F = specF(vDotH, F0);\n float D = specD(a, nDotH);\n float G = specG(roughness, nDotL, nDotV);\n vec3 specular = (D * F * G) / (4.0 * nDotL * nDotV);\n#endif\n float halfLambert = dot(n, l) * 0.5 + 0.5;\n halfLambert *= halfLambert;\n\n vec3 color = (halfLambert * LIGHT_COLOR * lambertDiffuse(cDiff)) + specular;\n\n#ifdef USE_OCCLUSION\n float occlusion = texture2D(occlusionTex, vTex).r;\n color = mix(color, color * occlusion, occlusionStrength);\n#endif\n \n vec3 emissive = emissiveFactor;\n#ifdef USE_EMISSIVE_TEXTURE\n emissive *= texture2D(emissiveTex, vTex).rgb;\n#endif\n color += emissive;\n\n // gamma correction\n //color = pow(color, vec3(1.0/2.2));\n\n return vec4(color, baseColor.a);\n}'; - -var PbrMaterial = exports.PbrMaterial = function (_Material) { - _inherits(PbrMaterial, _Material); - - function PbrMaterial() { - _classCallCheck(this, PbrMaterial); - - var _this = _possibleConstructorReturn(this, (PbrMaterial.__proto__ || Object.getPrototypeOf(PbrMaterial)).call(this)); - - _this.baseColor = _this.defineSampler('baseColorTex'); - _this.metallicRoughness = _this.defineSampler('metallicRoughnessTex'); - _this.normal = _this.defineSampler('normalTex'); - _this.occlusion = _this.defineSampler('occlusionTex'); - _this.emissive = _this.defineSampler('emissiveTex'); - - _this.baseColorFactor = _this.defineUniform('baseColorFactor', [1.0, 1.0, 1.0, 1.0]); - _this.metallicRoughnessFactor = _this.defineUniform('metallicRoughnessFactor', [1.0, 1.0]); - _this.occlusionStrength = _this.defineUniform('occlusionStrength', 1.0); - _this.emissiveFactor = _this.defineUniform('emissiveFactor', [0, 0, 0]); - return _this; - } - - _createClass(PbrMaterial, [{ - key: 'getProgramDefines', - value: function getProgramDefines(renderPrimitive) { - var programDefines = {}; - - if (renderPrimitive._attributeMask & _renderer.ATTRIB_MASK.COLOR_0) { - programDefines['USE_VERTEX_COLOR'] = 1; - } - - if (renderPrimitive._attributeMask & _renderer.ATTRIB_MASK.TEXCOORD_0) { - if (this.baseColor.texture) { - programDefines['USE_BASE_COLOR_MAP'] = 1; - } - - if (this.normal.texture && renderPrimitive._attributeMask & _renderer.ATTRIB_MASK.TANGENT) { - programDefines['USE_NORMAL_MAP'] = 1; - } - - if (this.metallicRoughness.texture) { - programDefines['USE_METAL_ROUGH_MAP'] = 1; - } - - if (this.occlusion.texture) { - programDefines['USE_OCCLUSION'] = 1; - } - - if (this.emissive.texture) { - programDefines['USE_EMISSIVE_TEXTURE'] = 1; - } - } - - if ((!this.metallicRoughness.texture || !(renderPrimitive._attributeMask & _renderer.ATTRIB_MASK.TEXCOORD_0)) && this.metallicRoughnessFactor.value[1] == 1.0) { - programDefines['FULLY_ROUGH'] = 1; - } - - return programDefines; - } - }, { - key: 'materialName', - get: function get() { - return 'PBR'; - } - }, { - key: 'vertexSource', - get: function get() { - return VERTEX_SOURCE; - } - }, { - key: 'fragmentSource', - get: function get() { - return FRAGMENT_SOURCE; - } - }]); - - return PbrMaterial; -}(_material.Material); - -/***/ }), - -/***/ "./src/math/gl-matrix.js": -/*!*******************************!*\ - !*** ./src/math/gl-matrix.js ***! - \*******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.vec4 = exports.vec3 = exports.vec2 = exports.quat2 = exports.quat = exports.mat4 = exports.mat3 = exports.mat2d = exports.mat2 = exports.glMatrix = undefined; - -var _common = __webpack_require__(/*! ../../node_modules/gl-matrix/src/gl-matrix/common.js */ "./node_modules/gl-matrix/src/gl-matrix/common.js"); - -var glMatrix = _interopRequireWildcard(_common); - -var _mat = __webpack_require__(/*! ../../node_modules/gl-matrix/src/gl-matrix/mat2.js */ "./node_modules/gl-matrix/src/gl-matrix/mat2.js"); - -var mat2 = _interopRequireWildcard(_mat); - -var _mat2d = __webpack_require__(/*! ../../node_modules/gl-matrix/src/gl-matrix/mat2d.js */ "./node_modules/gl-matrix/src/gl-matrix/mat2d.js"); - -var mat2d = _interopRequireWildcard(_mat2d); - -var _mat2 = __webpack_require__(/*! ../../node_modules/gl-matrix/src/gl-matrix/mat3.js */ "./node_modules/gl-matrix/src/gl-matrix/mat3.js"); - -var mat3 = _interopRequireWildcard(_mat2); - -var _mat3 = __webpack_require__(/*! ../../node_modules/gl-matrix/src/gl-matrix/mat4.js */ "./node_modules/gl-matrix/src/gl-matrix/mat4.js"); - -var mat4 = _interopRequireWildcard(_mat3); - -var _quat = __webpack_require__(/*! ../../node_modules/gl-matrix/src/gl-matrix/quat.js */ "./node_modules/gl-matrix/src/gl-matrix/quat.js"); - -var quat = _interopRequireWildcard(_quat); - -var _quat2 = __webpack_require__(/*! ../../node_modules/gl-matrix/src/gl-matrix/quat2.js */ "./node_modules/gl-matrix/src/gl-matrix/quat2.js"); - -var quat2 = _interopRequireWildcard(_quat2); - -var _vec = __webpack_require__(/*! ../../node_modules/gl-matrix/src/gl-matrix/vec2.js */ "./node_modules/gl-matrix/src/gl-matrix/vec2.js"); - -var vec2 = _interopRequireWildcard(_vec); - -var _vec2 = __webpack_require__(/*! ../../node_modules/gl-matrix/src/gl-matrix/vec3.js */ "./node_modules/gl-matrix/src/gl-matrix/vec3.js"); - -var vec3 = _interopRequireWildcard(_vec2); - -var _vec3 = __webpack_require__(/*! ../../node_modules/gl-matrix/src/gl-matrix/vec4.js */ "./node_modules/gl-matrix/src/gl-matrix/vec4.js"); - -var vec4 = _interopRequireWildcard(_vec3); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -// Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -exports.glMatrix = glMatrix; -exports.mat2 = mat2; -exports.mat2d = mat2d; -exports.mat3 = mat3; -exports.mat4 = mat4; -exports.quat = quat; -exports.quat2 = quat2; -exports.vec2 = vec2; -exports.vec3 = vec3; -exports.vec4 = vec4; - -/***/ }), - -/***/ "./src/math/ray.js": -/*!*************************!*\ - !*** ./src/math/ray.js ***! - \*************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Ray = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var _glMatrix = __webpack_require__(/*! ./gl-matrix.js */ "./src/math/gl-matrix.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var normalMat = _glMatrix.mat3.create(); - -var RAY_INTERSECTION_OFFSET = 0.02; - -var Ray = exports.Ray = function () { - function Ray() { - var matrix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - - _classCallCheck(this, Ray); - - this.origin = _glMatrix.vec3.create(); - - this._dir = _glMatrix.vec3.create(); - this._dir[2] = -1.0; - - if (matrix) { - _glMatrix.vec3.transformMat4(this.origin, this.origin, matrix); - _glMatrix.mat3.fromMat4(normalMat, matrix); - _glMatrix.vec3.transformMat3(this._dir, this._dir, normalMat); - } - - // To force the inverse and sign calculations. - this.dir = this._dir; - } - - _createClass(Ray, [{ - key: 'intersectsAABB', - - - // Borrowed from: - // eslint-disable-next-line max-len - // https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-box-intersection - value: function intersectsAABB(min, max) { - var r = this; - - var bounds = [min, max]; - - var tmin = (bounds[r.sign[0]][0] - r.origin[0]) * r.inv_dir[0]; - var tmax = (bounds[1 - r.sign[0]][0] - r.origin[0]) * r.inv_dir[0]; - var tymin = (bounds[r.sign[1]][1] - r.origin[1]) * r.inv_dir[1]; - var tymax = (bounds[1 - r.sign[1]][1] - r.origin[1]) * r.inv_dir[1]; - - if (tmin > tymax || tymin > tmax) { - return null; - } - if (tymin > tmin) { - tmin = tymin; - } - if (tymax < tmax) { - tmax = tymax; - } - - var tzmin = (bounds[r.sign[2]][2] - r.origin[2]) * r.inv_dir[2]; - var tzmax = (bounds[1 - r.sign[2]][2] - r.origin[2]) * r.inv_dir[2]; - - if (tmin > tzmax || tzmin > tmax) { - return null; - } - if (tzmin > tmin) { - tmin = tzmin; - } - if (tzmax < tmax) { - tmax = tzmax; - } - - var t = -1; - if (tmin > 0 && tmax > 0) { - t = Math.min(tmin, tmax); - } else if (tmin > 0) { - t = tmin; - } else if (tmax > 0) { - t = tmax; - } else { - // Intersection is behind the ray origin. - return null; - } - - // Push ray intersection point back along the ray a bit so that cursors - // don't accidentally intersect with the hit surface. - t -= RAY_INTERSECTION_OFFSET; - - // Return the point where the ray first intersected with the AABB. - var intersectionPoint = _glMatrix.vec3.clone(this._dir); - _glMatrix.vec3.scale(intersectionPoint, intersectionPoint, t); - _glMatrix.vec3.add(intersectionPoint, intersectionPoint, this.origin); - return intersectionPoint; - } - }, { - key: 'dir', - get: function get() { - return this._dir; - }, - set: function set(value) { - this._dir = _glMatrix.vec3.copy(this._dir, value); - _glMatrix.vec3.normalize(this._dir, this._dir); - - this.inv_dir = _glMatrix.vec3.fromValues(1.0 / this._dir[0], 1.0 / this._dir[1], 1.0 / this._dir[2]); - - this.sign = [this.inv_dir[0] < 0 ? 1 : 0, this.inv_dir[1] < 0 ? 1 : 0, this.inv_dir[2] < 0 ? 1 : 0]; - } - }]); - - return Ray; -}(); - -/***/ }), - -/***/ "./src/nodes/bounds-renderer.js": -/*!**************************************!*\ - !*** ./src/nodes/bounds-renderer.js ***! - \**************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.BoundsRenderer = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _material = __webpack_require__(/*! ../core/material.js */ "./src/core/material.js"); - -var _node = __webpack_require__(/*! ../core/node.js */ "./src/core/node.js"); - -var _primitive = __webpack_require__(/*! ../core/primitive.js */ "./src/core/primitive.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/* -This file renders a passed in XRStageBounds object and attempts -to render geometry on the floor to indicate where the bounds is. -XRStageBounds' `geometry` is a series of XRStageBoundsPoints (in -clockwise-order) with `x` and `z` properties for each. -*/ - -var GL = WebGLRenderingContext; // For enums - -var BoundsMaterial = function (_Material) { - _inherits(BoundsMaterial, _Material); - - function BoundsMaterial() { - _classCallCheck(this, BoundsMaterial); - - var _this = _possibleConstructorReturn(this, (BoundsMaterial.__proto__ || Object.getPrototypeOf(BoundsMaterial)).call(this)); - - _this.state.blend = true; - _this.state.blendFuncSrc = GL.SRC_ALPHA; - _this.state.blendFuncDst = GL.ONE; - _this.state.depthTest = false; - return _this; - } - - _createClass(BoundsMaterial, [{ - key: 'materialName', - get: function get() { - return 'BOUNDS_RENDERER'; - } - }, { - key: 'vertexSource', - get: function get() { - return '\n attribute vec2 POSITION;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n return proj * view * model * vec4(POSITION, 1.0);\n }'; - } - }, { - key: 'fragmentSource', - get: function get() { - return '\n precision mediump float;\n\n vec4 fragment_main() {\n return vec4(0.0, 1.0, 0.0, 0.3);\n }'; - } - }]); - - return BoundsMaterial; -}(_material.Material); - -var BoundsRenderer = exports.BoundsRenderer = function (_Node) { - _inherits(BoundsRenderer, _Node); - - function BoundsRenderer() { - _classCallCheck(this, BoundsRenderer); - - var _this2 = _possibleConstructorReturn(this, (BoundsRenderer.__proto__ || Object.getPrototypeOf(BoundsRenderer)).call(this)); - - _this2._stageBounds = null; - return _this2; - } - - _createClass(BoundsRenderer, [{ - key: 'onRendererChanged', - value: function onRendererChanged(renderer) { - this.stageBounds = this._stageBounds; - } - }, { - key: 'stageBounds', - get: function get() { - return this._stageBounds; - }, - set: function set(stageBounds) { - if (this._stageBounds) { - this.clearRenderPrimitives(); - } - this._stageBounds = stageBounds; - if (!stageBounds || stageBounds.length === 0 || !this._renderer) { - return; - } - - var verts = []; - var indices = []; - - // Tessellate the bounding points from XRStageBounds and connect - // each point to a neighbor and 0,0,0. - var pointCount = stageBounds.geometry.length; - for (var i = 0; i < pointCount; i++) { - var point = stageBounds.geometry[i]; - verts.push(point.x, 0, point.z); - indices.push(i, i === 0 ? pointCount - 1 : i - 1, pointCount); - } - // Center point - verts.push(0, 0, 0); - - var vertexBuffer = this._renderer.createRenderBuffer(GL.ARRAY_BUFFER, new Float32Array(verts)); - var indexBuffer = this._renderer.createRenderBuffer(GL.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices)); - - var attribs = [new _primitive.PrimitiveAttribute('POSITION', vertexBuffer, 3, GL.FLOAT, 12, 0)]; - - var primitive = new _primitive.Primitive(attribs, indices.length); - primitive.setIndexBuffer(indexBuffer); - - var renderPrimitive = this._renderer.createRenderPrimitive(primitive, new BoundsMaterial()); - this.addRenderPrimitive(renderPrimitive); - } - }]); - - return BoundsRenderer; -}(_node.Node); - -/***/ }), - -/***/ "./src/nodes/button.js": -/*!*****************************!*\ - !*** ./src/nodes/button.js ***! - \*****************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ButtonNode = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _material = __webpack_require__(/*! ../core/material.js */ "./src/core/material.js"); - -var _node = __webpack_require__(/*! ../core/node.js */ "./src/core/node.js"); - -var _primitiveStream = __webpack_require__(/*! ../geometry/primitive-stream.js */ "./src/geometry/primitive-stream.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var BUTTON_SIZE = 0.1; -var BUTTON_CORNER_RADIUS = 0.025; -var BUTTON_CORNER_SEGMENTS = 8; -var BUTTON_ICON_SIZE = 0.07; -var BUTTON_LAYER_DISTANCE = 0.005; -var BUTTON_COLOR = 0.75; -var BUTTON_ALPHA = 0.85; -var BUTTON_HOVER_COLOR = 0.9; -var BUTTON_HOVER_ALPHA = 1.0; -var BUTTON_HOVER_SCALE = 1.1; -var BUTTON_HOVER_TRANSITION_TIME_MS = 200; - -var ButtonMaterial = function (_Material) { - _inherits(ButtonMaterial, _Material); - - function ButtonMaterial() { - _classCallCheck(this, ButtonMaterial); - - var _this = _possibleConstructorReturn(this, (ButtonMaterial.__proto__ || Object.getPrototypeOf(ButtonMaterial)).call(this)); - - _this.state.blend = true; - - _this.defineUniform('hoverAmount', 0); - return _this; - } - - _createClass(ButtonMaterial, [{ - key: 'materialName', - get: function get() { - return 'BUTTON_MATERIAL'; - } - }, { - key: 'vertexSource', - get: function get() { - return '\n attribute vec3 POSITION;\n\n uniform float hoverAmount;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n float scale = mix(1.0, ' + BUTTON_HOVER_SCALE + ', hoverAmount);\n vec4 pos = vec4(POSITION.x * scale, POSITION.y * scale, POSITION.z * (scale + (hoverAmount * 0.2)), 1.0);\n return proj * view * model * pos;\n }'; - } - }, { - key: 'fragmentSource', - get: function get() { - return '\n uniform float hoverAmount;\n\n const vec4 default_color = vec4(' + BUTTON_COLOR + ', ' + BUTTON_COLOR + ', ' + BUTTON_COLOR + ', ' + BUTTON_ALPHA + ');\n const vec4 hover_color = vec4(' + BUTTON_HOVER_COLOR + ', ' + BUTTON_HOVER_COLOR + ',\n ' + BUTTON_HOVER_COLOR + ', ' + BUTTON_HOVER_ALPHA + ');\n\n vec4 fragment_main() {\n return mix(default_color, hover_color, hoverAmount);\n }'; - } - }]); - - return ButtonMaterial; -}(_material.Material); - -var ButtonIconMaterial = function (_Material2) { - _inherits(ButtonIconMaterial, _Material2); - - function ButtonIconMaterial() { - _classCallCheck(this, ButtonIconMaterial); - - var _this2 = _possibleConstructorReturn(this, (ButtonIconMaterial.__proto__ || Object.getPrototypeOf(ButtonIconMaterial)).call(this)); - - _this2.state.blend = true; - - _this2.defineUniform('hoverAmount', 0); - _this2.icon = _this2.defineSampler('icon'); - return _this2; - } - - _createClass(ButtonIconMaterial, [{ - key: 'materialName', - get: function get() { - return 'BUTTON_ICON_MATERIAL'; - } - }, { - key: 'vertexSource', - get: function get() { - return '\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n\n uniform float hoverAmount;\n\n varying vec2 vTexCoord;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vTexCoord = TEXCOORD_0;\n float scale = mix(1.0, ' + BUTTON_HOVER_SCALE + ', hoverAmount);\n vec4 pos = vec4(POSITION.x * scale, POSITION.y * scale, POSITION.z * (scale + (hoverAmount * 0.2)), 1.0);\n return proj * view * model * pos;\n }'; - } - }, { - key: 'fragmentSource', - get: function get() { - return '\n uniform sampler2D icon;\n varying vec2 vTexCoord;\n\n vec4 fragment_main() {\n return texture2D(icon, vTexCoord);\n }'; - } - }]); - - return ButtonIconMaterial; -}(_material.Material); - -var ButtonNode = exports.ButtonNode = function (_Node) { - _inherits(ButtonNode, _Node); - - function ButtonNode(iconTexture, callback) { - _classCallCheck(this, ButtonNode); - - // All buttons are selectable by default. - var _this3 = _possibleConstructorReturn(this, (ButtonNode.__proto__ || Object.getPrototypeOf(ButtonNode)).call(this)); - - _this3.selectable = true; - - _this3._selectHandler = callback; - _this3._iconTexture = iconTexture; - _this3._hovered = false; - _this3._hoverT = 0; - return _this3; - } - - _createClass(ButtonNode, [{ - key: 'onRendererChanged', - value: function onRendererChanged(renderer) { - var stream = new _primitiveStream.PrimitiveStream(); - - var hd = BUTTON_LAYER_DISTANCE * 0.5; - - // Build a rounded rect for the background. - var hs = BUTTON_SIZE * 0.5; - var ihs = hs - BUTTON_CORNER_RADIUS; - stream.startGeometry(); - - // Rounded corners and sides - var segments = BUTTON_CORNER_SEGMENTS * 4; - for (var i = 0; i < segments; ++i) { - var rad = i * (Math.PI * 2.0 / segments); - var x = Math.cos(rad) * BUTTON_CORNER_RADIUS; - var y = Math.sin(rad) * BUTTON_CORNER_RADIUS; - var section = Math.floor(i / BUTTON_CORNER_SEGMENTS); - switch (section) { - case 0: - x += ihs; - y += ihs; - break; - case 1: - x -= ihs; - y += ihs; - break; - case 2: - x -= ihs; - y -= ihs; - break; - case 3: - x += ihs; - y -= ihs; - break; - } - - stream.pushVertex(x, y, -hd, 0, 0, 0, 0, 1); - - if (i > 1) { - stream.pushTriangle(0, i - 1, i); - } - } - - stream.endGeometry(); - - var buttonPrimitive = stream.finishPrimitive(renderer); - this._buttonRenderPrimitive = renderer.createRenderPrimitive(buttonPrimitive, new ButtonMaterial()); - this.addRenderPrimitive(this._buttonRenderPrimitive); - - // Build a simple textured quad for the foreground. - hs = BUTTON_ICON_SIZE * 0.5; - stream.clear(); - stream.startGeometry(); - - stream.pushVertex(-hs, hs, hd, 0, 0, 0, 0, 1); - stream.pushVertex(-hs, -hs, hd, 0, 1, 0, 0, 1); - stream.pushVertex(hs, -hs, hd, 1, 1, 0, 0, 1); - stream.pushVertex(hs, hs, hd, 1, 0, 0, 0, 1); - - stream.pushTriangle(0, 1, 2); - stream.pushTriangle(0, 2, 3); - - stream.endGeometry(); - - var iconPrimitive = stream.finishPrimitive(renderer); - var iconMaterial = new ButtonIconMaterial(); - iconMaterial.icon.texture = this._iconTexture; - this._iconRenderPrimitive = renderer.createRenderPrimitive(iconPrimitive, iconMaterial); - this.addRenderPrimitive(this._iconRenderPrimitive); - } - }, { - key: 'onHoverStart', - value: function onHoverStart() { - this._hovered = true; - } - }, { - key: 'onHoverEnd', - value: function onHoverEnd() { - this._hovered = false; - } - }, { - key: '_updateHoverState', - value: function _updateHoverState() { - var t = this._hoverT / BUTTON_HOVER_TRANSITION_TIME_MS; - // Cubic Ease In/Out - // TODO: Get a better animation system - var hoverAmount = t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1; - this._buttonRenderPrimitive.uniforms.hoverAmount.value = hoverAmount; - this._iconRenderPrimitive.uniforms.hoverAmount.value = hoverAmount; - } - }, { - key: 'onUpdate', - value: function onUpdate(timestamp, frameDelta) { - if (this._hovered && this._hoverT < BUTTON_HOVER_TRANSITION_TIME_MS) { - this._hoverT = Math.min(BUTTON_HOVER_TRANSITION_TIME_MS, this._hoverT + frameDelta); - this._updateHoverState(); - } else if (!this._hovered && this._hoverT > 0) { - this._hoverT = Math.max(0.0, this._hoverT - frameDelta); - this._updateHoverState(); - } - } - }, { - key: 'iconTexture', - get: function get() { - return this._iconTexture; - }, - set: function set(value) { - if (this._iconTexture == value) { - return; - } - - this._iconTexture = value; - this._iconRenderPrimitive.samplers.icon.texture = value; - } - }]); - - return ButtonNode; -}(_node.Node); - -/***/ }), - -/***/ "./src/nodes/cube-sea.js": -/*!*******************************!*\ - !*** ./src/nodes/cube-sea.js ***! - \*******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.CubeSeaNode = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _material = __webpack_require__(/*! ../core/material.js */ "./src/core/material.js"); - -var _node = __webpack_require__(/*! ../core/node.js */ "./src/core/node.js"); - -var _texture = __webpack_require__(/*! ../core/texture.js */ "./src/core/texture.js"); - -var _boxBuilder = __webpack_require__(/*! ../geometry/box-builder.js */ "./src/geometry/box-builder.js"); - -var _glMatrix = __webpack_require__(/*! ../math/gl-matrix.js */ "./src/math/gl-matrix.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var CubeSeaMaterial = function (_Material) { - _inherits(CubeSeaMaterial, _Material); - - function CubeSeaMaterial() { - var heavy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - - _classCallCheck(this, CubeSeaMaterial); - - var _this = _possibleConstructorReturn(this, (CubeSeaMaterial.__proto__ || Object.getPrototypeOf(CubeSeaMaterial)).call(this)); - - _this.heavy = heavy; - - _this.baseColor = _this.defineSampler('baseColor'); - return _this; - } - - _createClass(CubeSeaMaterial, [{ - key: 'materialName', - get: function get() { - return 'CUBE_SEA'; - } - }, { - key: 'vertexSource', - get: function get() { - return '\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n attribute vec3 NORMAL;\n\n varying vec2 vTexCoord;\n varying vec3 vLight;\n\n const vec3 lightDir = vec3(0.75, 0.5, 1.0);\n const vec3 ambientColor = vec3(0.5, 0.5, 0.5);\n const vec3 lightColor = vec3(0.75, 0.75, 0.75);\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vec3 normalRotated = vec3(model * vec4(NORMAL, 0.0));\n float lightFactor = max(dot(normalize(lightDir), normalRotated), 0.0);\n vLight = ambientColor + (lightColor * lightFactor);\n vTexCoord = TEXCOORD_0;\n return proj * view * model * vec4(POSITION, 1.0);\n }'; - } - }, { - key: 'fragmentSource', - get: function get() { - if (!this.heavy) { - return '\n precision mediump float;\n uniform sampler2D baseColor;\n varying vec2 vTexCoord;\n varying vec3 vLight;\n\n vec4 fragment_main() {\n return vec4(vLight, 1.0) * texture2D(baseColor, vTexCoord);\n }'; - } else { - // Used when we want to stress the GPU a bit more. - // Stolen with love from https://www.clicktorelease.com/code/codevember-2016/4/ - return '\n precision mediump float;\n\n uniform sampler2D diffuse;\n varying vec2 vTexCoord;\n varying vec3 vLight;\n\n vec2 dimensions = vec2(64, 64);\n float seed = 0.42;\n\n vec2 hash( vec2 p ) {\n p=vec2(dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3)));\n return fract(sin(p)*18.5453);\n }\n\n vec3 hash3( vec2 p ) {\n vec3 q = vec3( dot(p,vec2(127.1,311.7)),\n dot(p,vec2(269.5,183.3)),\n dot(p,vec2(419.2,371.9)) );\n return fract(sin(q)*43758.5453);\n }\n\n float iqnoise( in vec2 x, float u, float v ) {\n vec2 p = floor(x);\n vec2 f = fract(x);\n float k = 1.0+63.0*pow(1.0-v,4.0);\n float va = 0.0;\n float wt = 0.0;\n for( int j=-2; j<=2; j++ )\n for( int i=-2; i<=2; i++ ) {\n vec2 g = vec2( float(i),float(j) );\n vec3 o = hash3( p + g )*vec3(u,u,1.0);\n vec2 r = g - f + o.xy;\n float d = dot(r,r);\n float ww = pow( 1.0-smoothstep(0.0,1.414,sqrt(d)), k );\n va += o.z*ww;\n wt += ww;\n }\n return va/wt;\n }\n\n // return distance, and cell id\n vec2 voronoi( in vec2 x ) {\n vec2 n = floor( x );\n vec2 f = fract( x );\n vec3 m = vec3( 8.0 );\n for( int j=-1; j<=1; j++ )\n for( int i=-1; i<=1; i++ ) {\n vec2 g = vec2( float(i), float(j) );\n vec2 o = hash( n + g );\n vec2 r = g - f + (0.5+0.5*sin(seed+6.2831*o));\n float d = dot( r, r );\n if( d 0 && arguments[0] !== undefined ? arguments[0] : {}; - - _classCallCheck(this, CubeSeaNode); - - // Test variables - // If true, use a very heavyweight shader to stress the GPU. - var _this2 = _possibleConstructorReturn(this, (CubeSeaNode.__proto__ || Object.getPrototypeOf(CubeSeaNode)).call(this)); - - _this2.heavyGpu = !!options.heavyGpu; - - // Number and size of the static cubes. Warning, large values - // don't render right due to overflow of the int16 indices. - _this2.cubeCount = options.cubeCount || (_this2.heavyGpu ? 12 : 10); - _this2.cubeScale = options.cubeScale || 1.0; - - // Draw only half the world cubes. Helps test variable render cost - // when combined with heavyGpu. - _this2.halfOnly = !!options.halfOnly; - - // Automatically spin the world cubes. Intended for automated testing, - // not recommended for viewing in a headset. - _this2.autoRotate = !!options.autoRotate; - - _this2._texture = new _texture.UrlTexture(options.imageUrl || 'media/textures/cube-sea.png'); - - _this2._material = new CubeSeaMaterial(_this2.heavyGpu); - _this2._material.baseColor.texture = _this2._texture; - - _this2._renderPrimitive = null; - return _this2; - } - - _createClass(CubeSeaNode, [{ - key: 'onRendererChanged', - value: function onRendererChanged(renderer) { - this._renderPrimitive = null; - - var boxBuilder = new _boxBuilder.BoxBuilder(); - - // Build the spinning "hero" cubes - boxBuilder.pushCube([0, 0.25, -0.8], 0.1); - boxBuilder.pushCube([0.8, 0.25, 0], 0.1); - boxBuilder.pushCube([0, 0.25, 0.8], 0.1); - boxBuilder.pushCube([-0.8, 0.25, 0], 0.1); - - var heroPrimitive = boxBuilder.finishPrimitive(renderer); - - this.heroNode = renderer.createMesh(heroPrimitive, this._material); - - this.rebuildCubes(boxBuilder); - - this.cubeSeaNode = new _node.Node(); - this.cubeSeaNode.addRenderPrimitive(this._renderPrimitive); - - this.addNode(this.cubeSeaNode); - this.addNode(this.heroNode); - - return this.waitForComplete(); - } - }, { - key: 'rebuildCubes', - value: function rebuildCubes(boxBuilder) { - if (!this._renderer) { - return; - } - - if (!boxBuilder) { - boxBuilder = new _boxBuilder.BoxBuilder(); - } else { - boxBuilder.clear(); - } - - var size = 0.4 * this.cubeScale; - - // Build the cube sea - var halfGrid = this.cubeCount * 0.5; - for (var x = 0; x < this.cubeCount; ++x) { - for (var y = 0; y < this.cubeCount; ++y) { - for (var z = 0; z < this.cubeCount; ++z) { - var pos = [x - halfGrid, y - halfGrid, z - halfGrid]; - // Only draw cubes on one side. Useful for testing variable render - // cost that depends on view direction. - if (this.halfOnly && pos[0] < 0) { - continue; - } - - // Don't place a cube in the center of the grid. - if (pos[0] == 0 && pos[1] == 0 && pos[2] == 0) { - continue; - } - - boxBuilder.pushCube(pos, size); - } - } - } - - if (this.cubeCount > 12) { - // Each cube has 6 sides with 2 triangles and 3 indices per triangle, so - // the total number of indices needed is cubeCount^3 * 36. This exceeds - // the short index range past 12 cubes. - boxBuilder.indexType = 5125; // gl.UNSIGNED_INT - } - var cubeSeaPrimitive = boxBuilder.finishPrimitive(this._renderer); - - if (!this._renderPrimitive) { - this._renderPrimitive = this._renderer.createRenderPrimitive(cubeSeaPrimitive, this._material); - } else { - this._renderPrimitive.setPrimitive(cubeSeaPrimitive); - } - } - }, { - key: 'onUpdate', - value: function onUpdate(timestamp, frameDelta) { - if (this.autoRotate) { - _glMatrix.mat4.fromRotation(this.cubeSeaNode.matrix, timestamp / 500, [0, -1, 0]); - } - _glMatrix.mat4.fromRotation(this.heroNode.matrix, timestamp / 2000, [0, 1, 0]); - } - }]); - - return CubeSeaNode; -}(_node.Node); - -/***/ }), - -/***/ "./src/nodes/drop-shadow.js": -/*!**********************************!*\ - !*** ./src/nodes/drop-shadow.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.DropShadowNode = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _material = __webpack_require__(/*! ../core/material.js */ "./src/core/material.js"); - -var _node = __webpack_require__(/*! ../core/node.js */ "./src/core/node.js"); - -var _primitiveStream = __webpack_require__(/*! ../geometry/primitive-stream.js */ "./src/geometry/primitive-stream.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var GL = WebGLRenderingContext; // For enums - -var SHADOW_SEGMENTS = 32; -var SHADOW_GROUND_OFFSET = 0.01; -var SHADOW_CENTER_ALPHA = 0.7; -var SHADOW_INNER_ALPHA = 0.3; -var SHADOW_OUTER_ALPHA = 0.0; -var SHADOW_INNER_RADIUS = 0.6; -var SHADOW_OUTER_RADIUS = 1.0; - -var DropShadowMaterial = function (_Material) { - _inherits(DropShadowMaterial, _Material); - - function DropShadowMaterial() { - _classCallCheck(this, DropShadowMaterial); - - var _this = _possibleConstructorReturn(this, (DropShadowMaterial.__proto__ || Object.getPrototypeOf(DropShadowMaterial)).call(this)); - - _this.state.blend = true; - _this.state.blendFuncSrc = GL.ONE; - _this.state.blendFuncDst = GL.ONE_MINUS_SRC_ALPHA; - _this.state.depthFunc = GL.LEQUAL; - _this.state.depthMask = false; - return _this; - } - - _createClass(DropShadowMaterial, [{ - key: 'materialName', - get: function get() { - return 'DROP_SHADOW_MATERIAL'; - } - }, { - key: 'vertexSource', - get: function get() { - return '\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n\n varying float vShadow;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vShadow = TEXCOORD_0.x;\n return proj * view * model * vec4(POSITION, 1.0);\n }'; - } - }, { - key: 'fragmentSource', - get: function get() { - return '\n varying float vShadow;\n\n vec4 fragment_main() {\n return vec4(0.0, 0.0, 0.0, vShadow);\n }'; - } - }]); - - return DropShadowMaterial; -}(_material.Material); - -var DropShadowNode = exports.DropShadowNode = function (_Node) { - _inherits(DropShadowNode, _Node); - - function DropShadowNode(iconTexture, callback) { - _classCallCheck(this, DropShadowNode); - - return _possibleConstructorReturn(this, (DropShadowNode.__proto__ || Object.getPrototypeOf(DropShadowNode)).call(this)); - } - - _createClass(DropShadowNode, [{ - key: 'onRendererChanged', - value: function onRendererChanged(renderer) { - var stream = new _primitiveStream.PrimitiveStream(); - - stream.startGeometry(); - - // Shadow center - stream.pushVertex(0, SHADOW_GROUND_OFFSET, 0, SHADOW_CENTER_ALPHA); - - var segRad = Math.PI * 2.0 / SHADOW_SEGMENTS; - - var idx = void 0; - for (var i = 0; i < SHADOW_SEGMENTS; ++i) { - idx = stream.nextVertexIndex; - - var rad = i * segRad; - var x = Math.cos(rad); - var y = Math.sin(rad); - stream.pushVertex(x * SHADOW_INNER_RADIUS, SHADOW_GROUND_OFFSET, y * SHADOW_INNER_RADIUS, SHADOW_INNER_ALPHA); - stream.pushVertex(x * SHADOW_OUTER_RADIUS, SHADOW_GROUND_OFFSET, y * SHADOW_OUTER_RADIUS, SHADOW_OUTER_ALPHA); - - if (i > 0) { - // Inner circle - stream.pushTriangle(0, idx, idx - 2); - - // Outer circle - stream.pushTriangle(idx, idx + 1, idx - 1); - stream.pushTriangle(idx, idx - 1, idx - 2); - } - } - - stream.pushTriangle(0, 1, idx); - - stream.pushTriangle(1, 2, idx + 1); - stream.pushTriangle(1, idx + 1, idx); - - stream.endGeometry(); - - var shadowPrimitive = stream.finishPrimitive(renderer); - this._shadowRenderPrimitive = renderer.createRenderPrimitive(shadowPrimitive, new DropShadowMaterial()); - this.addRenderPrimitive(this._shadowRenderPrimitive); - } - }]); - - return DropShadowNode; -}(_node.Node); - -/***/ }), - -/***/ "./src/nodes/gltf2.js": -/*!****************************!*\ - !*** ./src/nodes/gltf2.js ***! - \****************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Gltf2Node = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _node = __webpack_require__(/*! ../core/node.js */ "./src/core/node.js"); - -var _gltf = __webpack_require__(/*! ../loaders/gltf2.js */ "./src/loaders/gltf2.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -// Using a weak map here allows us to cache a loader per-renderer without -// modifying the renderer object or leaking memory when it's garbage collected. -var gltfLoaderMap = new WeakMap(); - -var Gltf2Node = exports.Gltf2Node = function (_Node) { - _inherits(Gltf2Node, _Node); - - function Gltf2Node(options) { - _classCallCheck(this, Gltf2Node); - - var _this = _possibleConstructorReturn(this, (Gltf2Node.__proto__ || Object.getPrototypeOf(Gltf2Node)).call(this)); - - _this._url = options.url; - - _this._promise = null; - _this._resolver = null; - _this._rejecter = null; - return _this; - } - - _createClass(Gltf2Node, [{ - key: 'onRendererChanged', - value: function onRendererChanged(renderer) { - var _this2 = this; - - var loader = gltfLoaderMap.get(renderer); - if (!loader) { - loader = new _gltf.Gltf2Loader(renderer); - gltfLoaderMap.set(renderer, loader); - } - - // Do we have a previously resolved promise? If so clear it. - if (!this._resolver && this._promise) { - this._promise = null; - } - - this._ensurePromise(); - - loader.loadFromUrl(this._url).then(function (sceneNode) { - _this2.addNode(sceneNode); - _this2._resolver(sceneNode.waitForComplete()); - _this2._resolver = null; - _this2._rejecter = null; - }).catch(function (err) { - _this2._rejecter(err); - _this2._resolver = null; - _this2._rejecter = null; - }); - } - }, { - key: '_ensurePromise', - value: function _ensurePromise() { - var _this3 = this; - - if (!this._promise) { - this._promise = new Promise(function (resolve, reject) { - _this3._resolver = resolve; - _this3._rejecter = reject; - }); - } - return this._promise; - } - }, { - key: 'waitForComplete', - value: function waitForComplete() { - return this._ensurePromise(); - } - }]); - - return Gltf2Node; -}(_node.Node); - -/***/ }), - -/***/ "./src/nodes/input-renderer.js": -/*!*************************************!*\ - !*** ./src/nodes/input-renderer.js ***! - \*************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.InputRenderer = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _material = __webpack_require__(/*! ../core/material.js */ "./src/core/material.js"); - -var _node = __webpack_require__(/*! ../core/node.js */ "./src/core/node.js"); - -var _primitive = __webpack_require__(/*! ../core/primitive.js */ "./src/core/primitive.js"); - -var _texture = __webpack_require__(/*! ../core/texture.js */ "./src/core/texture.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var GL = WebGLRenderingContext; // For enums - -// Laser texture data, 48x1 RGBA (not premultiplied alpha). This represents a -// "cross section" of the laser beam with a bright core and a feathered edge. -// Borrowed from Chromium source code. -var LASER_TEXTURE_DATA = new Uint8Array([0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x02, 0xbf, 0xbf, 0xbf, 0x04, 0xcc, 0xcc, 0xcc, 0x05, 0xdb, 0xdb, 0xdb, 0x07, 0xcc, 0xcc, 0xcc, 0x0a, 0xd8, 0xd8, 0xd8, 0x0d, 0xd2, 0xd2, 0xd2, 0x11, 0xce, 0xce, 0xce, 0x15, 0xce, 0xce, 0xce, 0x1a, 0xce, 0xce, 0xce, 0x1f, 0xcd, 0xcd, 0xcd, 0x24, 0xc8, 0xc8, 0xc8, 0x2a, 0xc9, 0xc9, 0xc9, 0x2f, 0xc9, 0xc9, 0xc9, 0x34, 0xc9, 0xc9, 0xc9, 0x39, 0xc9, 0xc9, 0xc9, 0x3d, 0xc8, 0xc8, 0xc8, 0x41, 0xcb, 0xcb, 0xcb, 0x44, 0xee, 0xee, 0xee, 0x87, 0xfa, 0xfa, 0xfa, 0xc8, 0xf9, 0xf9, 0xf9, 0xc9, 0xf9, 0xf9, 0xf9, 0xc9, 0xfa, 0xfa, 0xfa, 0xc9, 0xfa, 0xfa, 0xfa, 0xc9, 0xf9, 0xf9, 0xf9, 0xc9, 0xf9, 0xf9, 0xf9, 0xc9, 0xfa, 0xfa, 0xfa, 0xc8, 0xee, 0xee, 0xee, 0x87, 0xcb, 0xcb, 0xcb, 0x44, 0xc8, 0xc8, 0xc8, 0x41, 0xc9, 0xc9, 0xc9, 0x3d, 0xc9, 0xc9, 0xc9, 0x39, 0xc9, 0xc9, 0xc9, 0x34, 0xc9, 0xc9, 0xc9, 0x2f, 0xc8, 0xc8, 0xc8, 0x2a, 0xcd, 0xcd, 0xcd, 0x24, 0xce, 0xce, 0xce, 0x1f, 0xce, 0xce, 0xce, 0x1a, 0xce, 0xce, 0xce, 0x15, 0xd2, 0xd2, 0xd2, 0x11, 0xd8, 0xd8, 0xd8, 0x0d, 0xcc, 0xcc, 0xcc, 0x0a, 0xdb, 0xdb, 0xdb, 0x07, 0xcc, 0xcc, 0xcc, 0x05, 0xbf, 0xbf, 0xbf, 0x04, 0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x01]); - -var LASER_LENGTH = 1.0; -var LASER_DIAMETER = 0.01; -var LASER_FADE_END = 0.535; -var LASER_FADE_POINT = 0.5335; -var LASER_DEFAULT_COLOR = [1.0, 1.0, 1.0, 0.25]; - -var CURSOR_RADIUS = 0.004; -var CURSOR_SHADOW_RADIUS = 0.007; -var CURSOR_SHADOW_INNER_LUMINANCE = 0.5; -var CURSOR_SHADOW_OUTER_LUMINANCE = 0.0; -var CURSOR_SHADOW_INNER_OPACITY = 0.75; -var CURSOR_SHADOW_OUTER_OPACITY = 0.0; -var CURSOR_OPACITY = 0.9; -var CURSOR_SEGMENTS = 16; -var CURSOR_DEFAULT_COLOR = [1.0, 1.0, 1.0, 1.0]; -var CURSOR_DEFAULT_HIDDEN_COLOR = [0.5, 0.5, 0.5, 0.25]; - -var DEFAULT_RESET_OPTIONS = { - controllers: true, - lasers: true, - cursors: true -}; - -var LaserMaterial = function (_Material) { - _inherits(LaserMaterial, _Material); - - function LaserMaterial() { - _classCallCheck(this, LaserMaterial); - - var _this = _possibleConstructorReturn(this, (LaserMaterial.__proto__ || Object.getPrototypeOf(LaserMaterial)).call(this)); - - _this.renderOrder = _material.RENDER_ORDER.ADDITIVE; - _this.state.cullFace = false; - _this.state.blend = true; - _this.state.blendFuncSrc = GL.ONE; - _this.state.blendFuncDst = GL.ONE; - _this.state.depthMask = false; - - _this.laser = _this.defineSampler('diffuse'); - _this.laser.texture = new _texture.DataTexture(LASER_TEXTURE_DATA, 48, 1); - _this.laserColor = _this.defineUniform('laserColor', LASER_DEFAULT_COLOR); - return _this; - } - - _createClass(LaserMaterial, [{ - key: 'materialName', - get: function get() { - return 'INPUT_LASER'; - } - }, { - key: 'vertexSource', - get: function get() { - return '\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n\n varying vec2 vTexCoord;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vTexCoord = TEXCOORD_0;\n return proj * view * model * vec4(POSITION, 1.0);\n }'; - } - }, { - key: 'fragmentSource', - get: function get() { - return '\n precision mediump float;\n\n uniform vec4 laserColor;\n uniform sampler2D diffuse;\n varying vec2 vTexCoord;\n\n const float fadePoint = ' + LASER_FADE_POINT + ';\n const float fadeEnd = ' + LASER_FADE_END + ';\n\n vec4 fragment_main() {\n vec2 uv = vTexCoord;\n float front_fade_factor = 1.0 - clamp(1.0 - (uv.y - fadePoint) / (1.0 - fadePoint), 0.0, 1.0);\n float back_fade_factor = clamp((uv.y - fadePoint) / (fadeEnd - fadePoint), 0.0, 1.0);\n vec4 color = laserColor * texture2D(diffuse, vTexCoord);\n float opacity = color.a * front_fade_factor * back_fade_factor;\n return vec4(color.rgb * opacity, opacity);\n }'; - } - }]); - - return LaserMaterial; -}(_material.Material); - -var CURSOR_VERTEX_SHADER = '\nattribute vec4 POSITION;\n\nvarying float vLuminance;\nvarying float vOpacity;\n\nvec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vLuminance = POSITION.z;\n vOpacity = POSITION.w;\n\n // Billboarded, constant size vertex transform.\n vec4 screenPos = proj * view * model * vec4(0.0, 0.0, 0.0, 1.0);\n screenPos /= screenPos.w;\n screenPos.xy += POSITION.xy;\n return screenPos;\n}'; - -var CURSOR_FRAGMENT_SHADER = '\nprecision mediump float;\n\nuniform vec4 cursorColor;\nvarying float vLuminance;\nvarying float vOpacity;\n\nvec4 fragment_main() {\n vec3 color = cursorColor.rgb * vLuminance;\n float opacity = cursorColor.a * vOpacity;\n return vec4(color * opacity, opacity);\n}'; - -// Cursors are drawn as billboards that always face the camera and are rendered -// as a fixed size no matter how far away they are. - -var CursorMaterial = function (_Material2) { - _inherits(CursorMaterial, _Material2); - - function CursorMaterial() { - _classCallCheck(this, CursorMaterial); - - var _this2 = _possibleConstructorReturn(this, (CursorMaterial.__proto__ || Object.getPrototypeOf(CursorMaterial)).call(this)); - - _this2.renderOrder = _material.RENDER_ORDER.ADDITIVE; - _this2.state.cullFace = false; - _this2.state.blend = true; - _this2.state.blendFuncSrc = GL.ONE; - _this2.state.depthMask = false; - - _this2.cursorColor = _this2.defineUniform('cursorColor', CURSOR_DEFAULT_COLOR); - return _this2; - } - - _createClass(CursorMaterial, [{ - key: 'materialName', - get: function get() { - return 'INPUT_CURSOR'; - } - }, { - key: 'vertexSource', - get: function get() { - return CURSOR_VERTEX_SHADER; - } - }, { - key: 'fragmentSource', - get: function get() { - return CURSOR_FRAGMENT_SHADER; - } - }]); - - return CursorMaterial; -}(_material.Material); - -var CursorHiddenMaterial = function (_Material3) { - _inherits(CursorHiddenMaterial, _Material3); - - function CursorHiddenMaterial() { - _classCallCheck(this, CursorHiddenMaterial); - - var _this3 = _possibleConstructorReturn(this, (CursorHiddenMaterial.__proto__ || Object.getPrototypeOf(CursorHiddenMaterial)).call(this)); - - _this3.renderOrder = _material.RENDER_ORDER.ADDITIVE; - _this3.state.cullFace = false; - _this3.state.blend = true; - _this3.state.blendFuncSrc = GL.ONE; - _this3.state.depthFunc = GL.GEQUAL; - _this3.state.depthMask = false; - - _this3.cursorColor = _this3.defineUniform('cursorColor', CURSOR_DEFAULT_HIDDEN_COLOR); - return _this3; - } - - // TODO: Rename to "program_name" - - - _createClass(CursorHiddenMaterial, [{ - key: 'materialName', - get: function get() { - return 'INPUT_CURSOR_2'; - } - }, { - key: 'vertexSource', - get: function get() { - return CURSOR_VERTEX_SHADER; - } - }, { - key: 'fragmentSource', - get: function get() { - return CURSOR_FRAGMENT_SHADER; - } - }]); - - return CursorHiddenMaterial; -}(_material.Material); - -var InputRenderer = exports.InputRenderer = function (_Node) { - _inherits(InputRenderer, _Node); - - function InputRenderer() { - _classCallCheck(this, InputRenderer); - - var _this4 = _possibleConstructorReturn(this, (InputRenderer.__proto__ || Object.getPrototypeOf(InputRenderer)).call(this)); - - _this4._maxInputElements = 32; - - _this4._controllers = []; - _this4._controllerNode = null; - _this4._controllerNodeHandedness = null; - _this4._lasers = null; - _this4._cursors = null; - - _this4._activeControllers = 0; - _this4._activeLasers = 0; - _this4._activeCursors = 0; - return _this4; - } - - _createClass(InputRenderer, [{ - key: 'onRendererChanged', - value: function onRendererChanged(renderer) { - this._controllers = []; - this._controllerNode = null; - this._controllerNodeHandedness = null; - this._lasers = null; - this._cursors = null; - - this._activeControllers = 0; - this._activeLasers = 0; - this._activeCursors = 0; - } - }, { - key: 'setControllerMesh', - value: function setControllerMesh(controllerNode) { - var handedness = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'right'; - - this._controllerNode = controllerNode; - this._controllerNode.visible = false; - // FIXME: Temporary fix to initialize for cloning. - this.addNode(this._controllerNode); - this._controllerNodeHandedness = handedness; - } - }, { - key: 'addController', - value: function addController(gripMatrix) { - if (!this._controllerNode) { - return; - } - - var controller = null; - if (this._activeControllers < this._controllers.length) { - controller = this._controllers[this._activeControllers]; - } else { - controller = this._controllerNode.clone(); - this.addNode(controller); - this._controllers.push(controller); - } - this._activeControllers = (this._activeControllers + 1) % this._maxInputElements; - - controller.matrix = gripMatrix; - controller.visible = true; - } - }, { - key: 'addLaserPointer', - value: function addLaserPointer(targetRay) { - // Create the laser pointer mesh if needed. - if (!this._lasers && this._renderer) { - this._lasers = [this._createLaserMesh()]; - this.addNode(this._lasers[0]); - } - - var laser = null; - if (this._activeLasers < this._lasers.length) { - laser = this._lasers[this._activeLasers]; - } else { - laser = this._lasers[0].clone(); - this.addNode(laser); - this._lasers.push(laser); - } - this._activeLasers = (this._activeLasers + 1) % this._maxInputElements; - - laser.matrix = targetRay.transformMatrix; - laser.visible = true; - } - }, { - key: 'addCursor', - value: function addCursor(cursorPos) { - // Create the cursor mesh if needed. - if (!this._cursors && this._renderer) { - this._cursors = [this._createCursorMesh()]; - this.addNode(this._cursors[0]); - } - - var cursor = null; - if (this._activeCursors < this._cursors.length) { - cursor = this._cursors[this._activeCursors]; - } else { - cursor = this._cursors[0].clone(); - this.addNode(cursor); - this._cursors.push(cursor); - } - this._activeCursors = (this._activeCursors + 1) % this._maxInputElements; - - cursor.translation = cursorPos; - cursor.visible = true; - } - }, { - key: 'reset', - value: function reset(options) { - if (!options) { - options = DEFAULT_RESET_OPTIONS; - } - if (this._controllers && options.controllers) { - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = this._controllers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var controller = _step.value; - - controller.visible = false; - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - - this._activeControllers = 0; - } - if (this._lasers && options.lasers) { - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; - - try { - for (var _iterator2 = this._lasers[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var laser = _step2.value; - - laser.visible = false; - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } - - this._activeLasers = 0; - } - if (this._cursors && options.cursors) { - var _iteratorNormalCompletion3 = true; - var _didIteratorError3 = false; - var _iteratorError3 = undefined; - - try { - for (var _iterator3 = this._cursors[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { - var cursor = _step3.value; - - cursor.visible = false; - } - } catch (err) { - _didIteratorError3 = true; - _iteratorError3 = err; - } finally { - try { - if (!_iteratorNormalCompletion3 && _iterator3.return) { - _iterator3.return(); - } - } finally { - if (_didIteratorError3) { - throw _iteratorError3; - } - } - } - - this._activeCursors = 0; - } - } - }, { - key: '_createLaserMesh', - value: function _createLaserMesh() { - var gl = this._renderer._gl; - - var lr = LASER_DIAMETER * 0.5; - var ll = LASER_LENGTH; - - // Laser is rendered as cross-shaped beam - var laserVerts = [ - // X Y Z U V - 0.0, lr, 0.0, 0.0, 1.0, 0.0, lr, -ll, 0.0, 0.0, 0.0, -lr, 0.0, 1.0, 1.0, 0.0, -lr, -ll, 1.0, 0.0, lr, 0.0, 0.0, 0.0, 1.0, lr, 0.0, -ll, 0.0, 0.0, -lr, 0.0, 0.0, 1.0, 1.0, -lr, 0.0, -ll, 1.0, 0.0, 0.0, -lr, 0.0, 0.0, 1.0, 0.0, -lr, -ll, 0.0, 0.0, 0.0, lr, 0.0, 1.0, 1.0, 0.0, lr, -ll, 1.0, 0.0, -lr, 0.0, 0.0, 0.0, 1.0, -lr, 0.0, -ll, 0.0, 0.0, lr, 0.0, 0.0, 1.0, 1.0, lr, 0.0, -ll, 1.0, 0.0]; - var laserIndices = [0, 1, 2, 1, 3, 2, 4, 5, 6, 5, 7, 6, 8, 9, 10, 9, 11, 10, 12, 13, 14, 13, 15, 14]; - - var laserVertexBuffer = this._renderer.createRenderBuffer(gl.ARRAY_BUFFER, new Float32Array(laserVerts)); - var laserIndexBuffer = this._renderer.createRenderBuffer(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(laserIndices)); - - var laserIndexCount = laserIndices.length; - - var laserAttribs = [new _primitive.PrimitiveAttribute('POSITION', laserVertexBuffer, 3, gl.FLOAT, 20, 0), new _primitive.PrimitiveAttribute('TEXCOORD_0', laserVertexBuffer, 2, gl.FLOAT, 20, 12)]; - - var laserPrimitive = new _primitive.Primitive(laserAttribs, laserIndexCount); - laserPrimitive.setIndexBuffer(laserIndexBuffer); - - var laserMaterial = new LaserMaterial(); - - var laserRenderPrimitive = this._renderer.createRenderPrimitive(laserPrimitive, laserMaterial); - var meshNode = new _node.Node(); - meshNode.addRenderPrimitive(laserRenderPrimitive); - return meshNode; - } - }, { - key: '_createCursorMesh', - value: function _createCursorMesh() { - var gl = this._renderer._gl; - - // Cursor is a circular white dot with a dark "shadow" skirt around the edge - // that fades from black to transparent as it moves out from the center. - // Cursor verts are packed as [X, Y, Luminance, Opacity] - var cursorVerts = []; - var cursorIndices = []; - - var segRad = 2.0 * Math.PI / CURSOR_SEGMENTS; - - // Cursor center - for (var i = 0; i < CURSOR_SEGMENTS; ++i) { - var rad = i * segRad; - var x = Math.cos(rad); - var y = Math.sin(rad); - cursorVerts.push(x * CURSOR_RADIUS, y * CURSOR_RADIUS, 1.0, CURSOR_OPACITY); - - if (i > 1) { - cursorIndices.push(0, i - 1, i); - } - } - - var indexOffset = CURSOR_SEGMENTS; - - // Cursor Skirt - for (var _i = 0; _i < CURSOR_SEGMENTS; ++_i) { - var _rad = _i * segRad; - var _x2 = Math.cos(_rad); - var _y = Math.sin(_rad); - cursorVerts.push(_x2 * CURSOR_RADIUS, _y * CURSOR_RADIUS, CURSOR_SHADOW_INNER_LUMINANCE, CURSOR_SHADOW_INNER_OPACITY); - cursorVerts.push(_x2 * CURSOR_SHADOW_RADIUS, _y * CURSOR_SHADOW_RADIUS, CURSOR_SHADOW_OUTER_LUMINANCE, CURSOR_SHADOW_OUTER_OPACITY); - - if (_i > 0) { - var _idx = indexOffset + _i * 2; - cursorIndices.push(_idx - 2, _idx - 1, _idx); - cursorIndices.push(_idx - 1, _idx + 1, _idx); - } - } - - var idx = indexOffset + CURSOR_SEGMENTS * 2; - cursorIndices.push(idx - 2, idx - 1, indexOffset); - cursorIndices.push(idx - 1, indexOffset + 1, indexOffset); - - var cursorVertexBuffer = this._renderer.createRenderBuffer(gl.ARRAY_BUFFER, new Float32Array(cursorVerts)); - var cursorIndexBuffer = this._renderer.createRenderBuffer(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(cursorIndices)); - - var cursorIndexCount = cursorIndices.length; - - var cursorAttribs = [new _primitive.PrimitiveAttribute('POSITION', cursorVertexBuffer, 4, gl.FLOAT, 16, 0)]; - - var cursorPrimitive = new _primitive.Primitive(cursorAttribs, cursorIndexCount); - cursorPrimitive.setIndexBuffer(cursorIndexBuffer); - - var cursorMaterial = new CursorMaterial(); - var cursorHiddenMaterial = new CursorHiddenMaterial(); - - // Cursor renders two parts: The bright opaque cursor for areas where it's - // not obscured and a more transparent, darker version for areas where it's - // behind another object. - var cursorRenderPrimitive = this._renderer.createRenderPrimitive(cursorPrimitive, cursorMaterial); - var cursorHiddenRenderPrimitive = this._renderer.createRenderPrimitive(cursorPrimitive, cursorHiddenMaterial); - var meshNode = new _node.Node(); - meshNode.addRenderPrimitive(cursorRenderPrimitive); - meshNode.addRenderPrimitive(cursorHiddenRenderPrimitive); - return meshNode; - } - }]); - - return InputRenderer; -}(_node.Node); - -/***/ }), - -/***/ "./src/nodes/seven-segment-text.js": -/*!*****************************************!*\ - !*** ./src/nodes/seven-segment-text.js ***! - \*****************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.SevenSegmentText = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _material = __webpack_require__(/*! ../core/material.js */ "./src/core/material.js"); - -var _node = __webpack_require__(/*! ../core/node.js */ "./src/core/node.js"); - -var _primitive = __webpack_require__(/*! ../core/primitive.js */ "./src/core/primitive.js"); - -function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/* -Renders simple text using a seven-segment LED style pattern. Only really good -for numbers and a limited number of other characters. -*/ - -var TEXT_KERNING = 2.0; - -var SevenSegmentMaterial = function (_Material) { - _inherits(SevenSegmentMaterial, _Material); - - function SevenSegmentMaterial() { - _classCallCheck(this, SevenSegmentMaterial); - - return _possibleConstructorReturn(this, (SevenSegmentMaterial.__proto__ || Object.getPrototypeOf(SevenSegmentMaterial)).apply(this, arguments)); - } - - _createClass(SevenSegmentMaterial, [{ - key: 'materialName', - get: function get() { - return 'SEVEN_SEGMENT_TEXT'; - } - }, { - key: 'vertexSource', - get: function get() { - return '\n attribute vec2 POSITION;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n return proj * view * model * vec4(POSITION, 0.0, 1.0);\n }'; - } - }, { - key: 'fragmentSource', - get: function get() { - return '\n precision mediump float;\n const vec4 color = vec4(0.0, 1.0, 0.0, 1.0);\n\n vec4 fragment_main() {\n return color;\n }'; - } - }]); - - return SevenSegmentMaterial; -}(_material.Material); - -var SevenSegmentText = exports.SevenSegmentText = function (_Node) { - _inherits(SevenSegmentText, _Node); - - function SevenSegmentText() { - _classCallCheck(this, SevenSegmentText); - - var _this2 = _possibleConstructorReturn(this, (SevenSegmentText.__proto__ || Object.getPrototypeOf(SevenSegmentText)).call(this)); - - _this2._text = ''; - _this2._charNodes = []; - return _this2; - } - - _createClass(SevenSegmentText, [{ - key: 'onRendererChanged', - value: function onRendererChanged(renderer) { - this.clearNodes(); - this._charNodes = []; - - var vertices = []; - var segmentIndices = {}; - var indices = []; - - var width = 0.5; - var thickness = 0.25; - - function defineSegment(id, left, top, right, bottom) { - var idx = vertices.length / 2; - vertices.push(left, top, right, top, right, bottom, left, bottom); - - segmentIndices[id] = [idx, idx + 2, idx + 1, idx, idx + 3, idx + 2]; - } - - var characters = {}; - function defineCharacter(c, segments) { - var character = { - character: c, - offset: indices.length * 2, - count: 0 - }; - - for (var i = 0; i < segments.length; ++i) { - var idx = segments[i]; - var segment = segmentIndices[idx]; - character.count += segment.length; - indices.push.apply(indices, _toConsumableArray(segment)); - } - - characters[c] = character; - } - - /* Segment layout is as follows: - |-0-| - 3 4 - |-1-| - 5 6 - |-2-| - */ - - defineSegment(0, -1, 1, width, 1 - thickness); - defineSegment(1, -1, thickness * 0.5, width, -thickness * 0.5); - defineSegment(2, -1, -1 + thickness, width, -1); - defineSegment(3, -1, 1, -1 + thickness, -thickness * 0.5); - defineSegment(4, width - thickness, 1, width, -thickness * 0.5); - defineSegment(5, -1, thickness * 0.5, -1 + thickness, -1); - defineSegment(6, width - thickness, thickness * 0.5, width, -1); - - defineCharacter('0', [0, 2, 3, 4, 5, 6]); - defineCharacter('1', [4, 6]); - defineCharacter('2', [0, 1, 2, 4, 5]); - defineCharacter('3', [0, 1, 2, 4, 6]); - defineCharacter('4', [1, 3, 4, 6]); - defineCharacter('5', [0, 1, 2, 3, 6]); - defineCharacter('6', [0, 1, 2, 3, 5, 6]); - defineCharacter('7', [0, 4, 6]); - defineCharacter('8', [0, 1, 2, 3, 4, 5, 6]); - defineCharacter('9', [0, 1, 2, 3, 4, 6]); - defineCharacter('A', [0, 1, 3, 4, 5, 6]); - defineCharacter('B', [1, 2, 3, 5, 6]); - defineCharacter('C', [0, 2, 3, 5]); - defineCharacter('D', [1, 2, 4, 5, 6]); - defineCharacter('E', [0, 1, 2, 4, 6]); - defineCharacter('F', [0, 1, 3, 5]); - defineCharacter('P', [0, 1, 3, 4, 5]); - defineCharacter('-', [1]); - defineCharacter(' ', []); - defineCharacter('_', [2]); // Used for undefined characters - - var gl = renderer.gl; - var vertexBuffer = renderer.createRenderBuffer(gl.ARRAY_BUFFER, new Float32Array(vertices)); - var indexBuffer = renderer.createRenderBuffer(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices)); - - var vertexAttribs = [new _primitive.PrimitiveAttribute('POSITION', vertexBuffer, 2, gl.FLOAT, 8, 0)]; - - var primitive = new _primitive.Primitive(vertexAttribs, indices.length); - primitive.setIndexBuffer(indexBuffer); - - var material = new SevenSegmentMaterial(); - - this._charPrimitives = {}; - for (var char in characters) { - var charDef = characters[char]; - primitive.elementCount = charDef.count; - primitive.indexByteOffset = charDef.offset; - this._charPrimitives[char] = renderer.createRenderPrimitive(primitive, material); - } - - this.text = this._text; - } - }, { - key: 'text', - get: function get() { - return this._text; - }, - set: function set(value) { - this._text = value; - - var i = 0; - var charPrimitive = null; - for (; i < value.length; ++i) { - if (value[i] in this._charPrimitives) { - charPrimitive = this._charPrimitives[value[i]]; - } else { - charPrimitive = this._charPrimitives['_']; - } - - if (this._charNodes.length <= i) { - var node = new _node.Node(); - node.addRenderPrimitive(charPrimitive); - var offset = i * TEXT_KERNING; - node.translation = [offset, 0, 0]; - this._charNodes.push(node); - this.addNode(node); - } else { - // This is sort of an abuse of how these things are expected to work, - // but it's the cheapest thing I could think of that didn't break the - // world. - this._charNodes[i].clearRenderPrimitives(); - this._charNodes[i].addRenderPrimitive(charPrimitive); - this._charNodes[i].visible = true; - } - } - - // If there's any nodes left over make them invisible - for (; i < this._charNodes.length; ++i) { - this._charNodes[i].visible = false; - } - } - }]); - - return SevenSegmentText; -}(_node.Node); - -/***/ }), - -/***/ "./src/nodes/skybox.js": -/*!*****************************!*\ - !*** ./src/nodes/skybox.js ***! - \*****************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.SkyboxNode = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _material = __webpack_require__(/*! ../core/material.js */ "./src/core/material.js"); - -var _primitive = __webpack_require__(/*! ../core/primitive.js */ "./src/core/primitive.js"); - -var _node = __webpack_require__(/*! ../core/node.js */ "./src/core/node.js"); - -var _texture = __webpack_require__(/*! ../core/texture.js */ "./src/core/texture.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/* -Node for displaying 360 equirect images as a skybox. -*/ - -var GL = WebGLRenderingContext; // For enums - -var SkyboxMaterial = function (_Material) { - _inherits(SkyboxMaterial, _Material); - - function SkyboxMaterial() { - _classCallCheck(this, SkyboxMaterial); - - var _this = _possibleConstructorReturn(this, (SkyboxMaterial.__proto__ || Object.getPrototypeOf(SkyboxMaterial)).call(this)); - - _this.renderOrder = _material.RENDER_ORDER.SKY; - _this.state.depthFunc = GL.LEQUAL; - _this.state.depthMask = false; - - _this.image = _this.defineSampler('diffuse'); - - _this.texCoordScaleOffset = _this.defineUniform('texCoordScaleOffset', [1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0], 4); - return _this; - } - - _createClass(SkyboxMaterial, [{ - key: 'materialName', - get: function get() { - return 'SKYBOX'; - } - }, { - key: 'vertexSource', - get: function get() { - return '\n uniform int EYE_INDEX;\n uniform vec4 texCoordScaleOffset[2];\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n varying vec2 vTexCoord;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vec4 scaleOffset = texCoordScaleOffset[EYE_INDEX];\n vTexCoord = (TEXCOORD_0 * scaleOffset.xy) + scaleOffset.zw;\n // Drop the translation portion of the view matrix\n view[3].xyz = vec3(0.0, 0.0, 0.0);\n vec4 out_vec = proj * view * model * vec4(POSITION, 1.0);\n\n // Returning the W component for both Z and W forces the geometry depth to\n // the far plane. When combined with a depth func of LEQUAL this makes the\n // sky write to any depth fragment that has not been written to yet.\n return out_vec.xyww;\n }'; - } - }, { - key: 'fragmentSource', - get: function get() { - return '\n uniform sampler2D diffuse;\n varying vec2 vTexCoord;\n\n vec4 fragment_main() {\n return texture2D(diffuse, vTexCoord);\n }'; - } - }]); - - return SkyboxMaterial; -}(_material.Material); - -var SkyboxNode = exports.SkyboxNode = function (_Node) { - _inherits(SkyboxNode, _Node); - - function SkyboxNode(options) { - _classCallCheck(this, SkyboxNode); - - var _this2 = _possibleConstructorReturn(this, (SkyboxNode.__proto__ || Object.getPrototypeOf(SkyboxNode)).call(this)); - - _this2._url = options.url; - _this2._displayMode = options.displayMode || 'mono'; - _this2._rotationY = options.rotationY || 0; - return _this2; - } - - _createClass(SkyboxNode, [{ - key: 'onRendererChanged', - value: function onRendererChanged(renderer) { - var vertices = []; - var indices = []; - - var latSegments = 40; - var lonSegments = 40; - - // Create the vertices/indices - for (var i = 0; i <= latSegments; ++i) { - var theta = i * Math.PI / latSegments; - var sinTheta = Math.sin(theta); - var cosTheta = Math.cos(theta); - - var idxOffsetA = i * (lonSegments + 1); - var idxOffsetB = (i + 1) * (lonSegments + 1); - - for (var j = 0; j <= lonSegments; ++j) { - var phi = j * 2 * Math.PI / lonSegments + this._rotationY; - var x = Math.sin(phi) * sinTheta; - var y = cosTheta; - var z = -Math.cos(phi) * sinTheta; - var u = j / lonSegments; - var v = i / latSegments; - - // Vertex shader will force the geometry to the far plane, so the - // radius of the sphere is immaterial. - vertices.push(x, y, z, u, v); - - if (i < latSegments && j < lonSegments) { - var idxA = idxOffsetA + j; - var idxB = idxOffsetB + j; - - indices.push(idxA, idxB, idxA + 1, idxB, idxB + 1, idxA + 1); - } - } - } - - var vertexBuffer = renderer.createRenderBuffer(GL.ARRAY_BUFFER, new Float32Array(vertices)); - var indexBuffer = renderer.createRenderBuffer(GL.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices)); - - var attribs = [new _primitive.PrimitiveAttribute('POSITION', vertexBuffer, 3, GL.FLOAT, 20, 0), new _primitive.PrimitiveAttribute('TEXCOORD_0', vertexBuffer, 2, GL.FLOAT, 20, 12)]; - - var primitive = new _primitive.Primitive(attribs, indices.length); - primitive.setIndexBuffer(indexBuffer); - - var material = new SkyboxMaterial(); - material.image.texture = new _texture.UrlTexture(this._url); - - switch (this._displayMode) { - case 'mono': - material.texCoordScaleOffset.value = [1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0]; - break; - case 'stereoTopBottom': - material.texCoordScaleOffset.value = [1.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5]; - break; - case 'stereoLeftRight': - material.texCoordScaleOffset.value = [0.5, 1.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0]; - break; - } - - var renderPrimitive = renderer.createRenderPrimitive(primitive, material); - this.addRenderPrimitive(renderPrimitive); - } - }]); - - return SkyboxNode; -}(_node.Node); - -/***/ }), - -/***/ "./src/nodes/stats-viewer.js": -/*!***********************************!*\ - !*** ./src/nodes/stats-viewer.js ***! - \***********************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.StatsViewer = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _material = __webpack_require__(/*! ../core/material.js */ "./src/core/material.js"); - -var _node = __webpack_require__(/*! ../core/node.js */ "./src/core/node.js"); - -var _primitive = __webpack_require__(/*! ../core/primitive.js */ "./src/core/primitive.js"); - -var _sevenSegmentText = __webpack_require__(/*! ./seven-segment-text.js */ "./src/nodes/seven-segment-text.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/* -Heavily inspired by Mr. Doobs stats.js, this FPS counter is rendered completely -with WebGL, allowing it to be shown in cases where overlaid HTML elements aren't -usable (like WebXR), or if you want the FPS counter to be rendered as part of -your scene. -*/ - -var SEGMENTS = 30; -var MAX_FPS = 90; - -var StatsMaterial = function (_Material) { - _inherits(StatsMaterial, _Material); - - function StatsMaterial() { - _classCallCheck(this, StatsMaterial); - - return _possibleConstructorReturn(this, (StatsMaterial.__proto__ || Object.getPrototypeOf(StatsMaterial)).apply(this, arguments)); - } - - _createClass(StatsMaterial, [{ - key: 'materialName', - get: function get() { - return 'STATS_VIEWER'; - } - }, { - key: 'vertexSource', - get: function get() { - return '\n attribute vec3 POSITION;\n attribute vec3 COLOR_0;\n varying vec4 vColor;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vColor = vec4(COLOR_0, 1.0);\n return proj * view * model * vec4(POSITION, 1.0);\n }'; - } - }, { - key: 'fragmentSource', - get: function get() { - return '\n precision mediump float;\n varying vec4 vColor;\n\n vec4 fragment_main() {\n return vColor;\n }'; - } - }]); - - return StatsMaterial; -}(_material.Material); - -function segmentToX(i) { - return 0.9 / SEGMENTS * i - 0.45; -} - -function fpsToY(value) { - return Math.min(value, MAX_FPS) * (0.7 / MAX_FPS) - 0.45; -} - -function fpsToRGB(value) { - return { - r: Math.max(0.0, Math.min(1.0, 1.0 - value / 60)), - g: Math.max(0.0, Math.min(1.0, (value - 15) / (MAX_FPS - 15))), - b: Math.max(0.0, Math.min(1.0, (value - 15) / (MAX_FPS - 15))) - }; -} - -var now = window.performance && performance.now ? performance.now.bind(performance) : Date.now; - -var StatsViewer = exports.StatsViewer = function (_Node) { - _inherits(StatsViewer, _Node); - - function StatsViewer() { - _classCallCheck(this, StatsViewer); - - var _this2 = _possibleConstructorReturn(this, (StatsViewer.__proto__ || Object.getPrototypeOf(StatsViewer)).call(this)); - - _this2._performanceMonitoring = false; - - _this2._startTime = now(); - _this2._prevFrameTime = _this2._startTime; - _this2._prevGraphUpdateTime = _this2._startTime; - _this2._frames = 0; - _this2._fpsAverage = 0; - _this2._fpsMin = 0; - _this2._fpsStep = _this2._performanceMonitoring ? 1000 : 250; - _this2._lastSegment = 0; - - _this2._fpsVertexBuffer = null; - _this2._fpsRenderPrimitive = null; - _this2._fpsNode = null; - - _this2._sevenSegmentNode = new _sevenSegmentText.SevenSegmentText(); - // Hard coded because it doesn't change: - // Scale by 0.075 in X and Y - // Translate into upper left corner w/ z = 0.02 - _this2._sevenSegmentNode.matrix = new Float32Array([0.075, 0, 0, 0, 0, 0.075, 0, 0, 0, 0, 1, 0, -0.3625, 0.3625, 0.02, 1]); - return _this2; - } - - _createClass(StatsViewer, [{ - key: 'onRendererChanged', - value: function onRendererChanged(renderer) { - this.clearNodes(); - - var gl = renderer.gl; - - var fpsVerts = []; - var fpsIndices = []; - - // Graph geometry - for (var i = 0; i < SEGMENTS; ++i) { - // Bar top - fpsVerts.push(segmentToX(i), fpsToY(0), 0.02, 0.0, 1.0, 1.0); - fpsVerts.push(segmentToX(i + 1), fpsToY(0), 0.02, 0.0, 1.0, 1.0); - - // Bar bottom - fpsVerts.push(segmentToX(i), fpsToY(0), 0.02, 0.0, 1.0, 1.0); - fpsVerts.push(segmentToX(i + 1), fpsToY(0), 0.02, 0.0, 1.0, 1.0); - - var idx = i * 4; - fpsIndices.push(idx, idx + 3, idx + 1, idx + 3, idx, idx + 2); - } - - function addBGSquare(left, bottom, right, top, z, r, g, b) { - var idx = fpsVerts.length / 6; - - fpsVerts.push(left, bottom, z, r, g, b); - fpsVerts.push(right, top, z, r, g, b); - fpsVerts.push(left, top, z, r, g, b); - fpsVerts.push(right, bottom, z, r, g, b); - - fpsIndices.push(idx, idx + 1, idx + 2, idx, idx + 3, idx + 1); - } - - // Panel Background - addBGSquare(-0.5, -0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.125); - - // FPS Background - addBGSquare(-0.45, -0.45, 0.45, 0.25, 0.01, 0.0, 0.0, 0.4); - - // 30 FPS line - addBGSquare(-0.45, fpsToY(30), 0.45, fpsToY(32), 0.015, 0.5, 0.0, 0.5); - - // 60 FPS line - addBGSquare(-0.45, fpsToY(60), 0.45, fpsToY(62), 0.015, 0.2, 0.0, 0.75); - - this._fpsVertexBuffer = renderer.createRenderBuffer(gl.ARRAY_BUFFER, new Float32Array(fpsVerts), gl.DYNAMIC_DRAW); - var fpsIndexBuffer = renderer.createRenderBuffer(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(fpsIndices)); - - var fpsAttribs = [new _primitive.PrimitiveAttribute('POSITION', this._fpsVertexBuffer, 3, gl.FLOAT, 24, 0), new _primitive.PrimitiveAttribute('COLOR_0', this._fpsVertexBuffer, 3, gl.FLOAT, 24, 12)]; - - var fpsPrimitive = new _primitive.Primitive(fpsAttribs, fpsIndices.length); - fpsPrimitive.setIndexBuffer(fpsIndexBuffer); - fpsPrimitive.setBounds([-0.5, -0.5, 0.0], [0.5, 0.5, 0.015]); - - this._fpsRenderPrimitive = renderer.createRenderPrimitive(fpsPrimitive, new StatsMaterial()); - this._fpsNode = new _node.Node(); - this._fpsNode.addRenderPrimitive(this._fpsRenderPrimitive); - - this.addNode(this._fpsNode); - this.addNode(this._sevenSegmentNode); - } - }, { - key: 'begin', - value: function begin() { - this._startTime = now(); - } - }, { - key: 'end', - value: function end() { - var time = now(); - - var frameFps = 1000 / (time - this._prevFrameTime); - this._prevFrameTime = time; - this._fpsMin = this._frames ? Math.min(this._fpsMin, frameFps) : frameFps; - this._frames++; - - if (time > this._prevGraphUpdateTime + this._fpsStep) { - var intervalTime = time - this._prevGraphUpdateTime; - this._fpsAverage = Math.round(1000 / (intervalTime / this._frames)); - - // Draw both average and minimum FPS for this period - // so that dropped frames are more clearly visible. - this._updateGraph(this._fpsMin, this._fpsAverage); - if (this._performanceMonitoring) { - console.log('Average FPS: ' + this._fpsAverage + ' Min FPS: ' + this._fpsMin); - } - - this._prevGraphUpdateTime = time; - this._frames = 0; - this._fpsMin = 0; - } - } - }, { - key: '_updateGraph', - value: function _updateGraph(valueLow, valueHigh) { - var color = fpsToRGB(valueLow); - // Draw a range from the low to high value. Artificially widen the - // range a bit to ensure that near-equal values still remain - // visible - the logic here should match that used by the - // "60 FPS line" setup below. Hitting 60fps consistently will - // keep the top half of the 60fps background line visible. - var y0 = fpsToY(valueLow - 1); - var y1 = fpsToY(valueHigh + 1); - - // Update the current segment with the new FPS value - var updateVerts = [segmentToX(this._lastSegment), y1, 0.02, color.r, color.g, color.b, segmentToX(this._lastSegment + 1), y1, 0.02, color.r, color.g, color.b, segmentToX(this._lastSegment), y0, 0.02, color.r, color.g, color.b, segmentToX(this._lastSegment + 1), y0, 0.02, color.r, color.g, color.b]; - - // Re-shape the next segment into the green "progress" line - color.r = 0.2; - color.g = 1.0; - color.b = 0.2; - - if (this._lastSegment == SEGMENTS - 1) { - // If we're updating the last segment we need to do two bufferSubDatas - // to update the segment and turn the first segment into the progress line. - this._renderer.updateRenderBuffer(this._fpsVertexBuffer, new Float32Array(updateVerts), this._lastSegment * 24 * 4); - updateVerts = [segmentToX(0), fpsToY(MAX_FPS), 0.02, color.r, color.g, color.b, segmentToX(.25), fpsToY(MAX_FPS), 0.02, color.r, color.g, color.b, segmentToX(0), fpsToY(0), 0.02, color.r, color.g, color.b, segmentToX(.25), fpsToY(0), 0.02, color.r, color.g, color.b]; - this._renderer.updateRenderBuffer(this._fpsVertexBuffer, new Float32Array(updateVerts), 0); - } else { - updateVerts.push(segmentToX(this._lastSegment + 1), fpsToY(MAX_FPS), 0.02, color.r, color.g, color.b, segmentToX(this._lastSegment + 1.25), fpsToY(MAX_FPS), 0.02, color.r, color.g, color.b, segmentToX(this._lastSegment + 1), fpsToY(0), 0.02, color.r, color.g, color.b, segmentToX(this._lastSegment + 1.25), fpsToY(0), 0.02, color.r, color.g, color.b); - this._renderer.updateRenderBuffer(this._fpsVertexBuffer, new Float32Array(updateVerts), this._lastSegment * 24 * 4); - } - - this._lastSegment = (this._lastSegment + 1) % SEGMENTS; - - this._sevenSegmentNode.text = this._fpsAverage + ' FP5'; - } - }, { - key: 'performanceMonitoring', - get: function get() { - return this._performanceMonitoring; - }, - set: function set(value) { - this._performanceMonitoring = value; - this._fpsStep = value ? 1000 : 250; - } - }]); - - return StatsViewer; -}(_node.Node); - -/***/ }), - -/***/ "./src/nodes/video.js": -/*!****************************!*\ - !*** ./src/nodes/video.js ***! - \****************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.VideoNode = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _material = __webpack_require__(/*! ../core/material.js */ "./src/core/material.js"); - -var _primitive = __webpack_require__(/*! ../core/primitive.js */ "./src/core/primitive.js"); - -var _node = __webpack_require__(/*! ../core/node.js */ "./src/core/node.js"); - -var _texture = __webpack_require__(/*! ../core/texture.js */ "./src/core/texture.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/* -Node for displaying 2D or stereo videos on a quad. -*/ - -var GL = WebGLRenderingContext; // For enums - -var VideoMaterial = function (_Material) { - _inherits(VideoMaterial, _Material); - - function VideoMaterial() { - _classCallCheck(this, VideoMaterial); - - var _this = _possibleConstructorReturn(this, (VideoMaterial.__proto__ || Object.getPrototypeOf(VideoMaterial)).call(this)); - - _this.image = _this.defineSampler('diffuse'); - - _this.texCoordScaleOffset = _this.defineUniform('texCoordScaleOffset', [1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0], 4); - return _this; - } - - _createClass(VideoMaterial, [{ - key: 'materialName', - get: function get() { - return 'VIDEO_PLAYER'; - } - }, { - key: 'vertexSource', - get: function get() { - return '\n uniform int EYE_INDEX;\n uniform vec4 texCoordScaleOffset[2];\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n varying vec2 vTexCoord;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vec4 scaleOffset = texCoordScaleOffset[EYE_INDEX];\n vTexCoord = (TEXCOORD_0 * scaleOffset.xy) + scaleOffset.zw;\n vec4 out_vec = proj * view * model * vec4(POSITION, 1.0);\n return out_vec;\n }'; - } - }, { - key: 'fragmentSource', - get: function get() { - return '\n uniform sampler2D diffuse;\n varying vec2 vTexCoord;\n\n vec4 fragment_main() {\n return texture2D(diffuse, vTexCoord);\n }'; - } - }]); - - return VideoMaterial; -}(_material.Material); - -var VideoNode = exports.VideoNode = function (_Node) { - _inherits(VideoNode, _Node); - - function VideoNode(options) { - _classCallCheck(this, VideoNode); - - var _this2 = _possibleConstructorReturn(this, (VideoNode.__proto__ || Object.getPrototypeOf(VideoNode)).call(this)); - - _this2._video = options.video; - _this2._displayMode = options.displayMode || 'mono'; - - _this2._video_texture = new _texture.VideoTexture(_this2._video); - return _this2; - } - - _createClass(VideoNode, [{ - key: 'onRendererChanged', - value: function onRendererChanged(renderer) { - var vertices = [-1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, -1.0, 0.0, 1.0, 1.0, -1.0, -1.0, 0.0, 0.0, 1.0]; - var indices = [0, 2, 1, 0, 3, 2]; - - var vertexBuffer = renderer.createRenderBuffer(GL.ARRAY_BUFFER, new Float32Array(vertices)); - var indexBuffer = renderer.createRenderBuffer(GL.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices)); - - var attribs = [new _primitive.PrimitiveAttribute('POSITION', vertexBuffer, 3, GL.FLOAT, 20, 0), new _primitive.PrimitiveAttribute('TEXCOORD_0', vertexBuffer, 2, GL.FLOAT, 20, 12)]; - - var primitive = new _primitive.Primitive(attribs, indices.length); - primitive.setIndexBuffer(indexBuffer); - primitive.setBounds([-1.0, -1.0, 0.0], [1.0, 1.0, 0.015]); - - var material = new VideoMaterial(); - material.image.texture = this._video_texture; - - switch (this._displayMode) { - case 'mono': - material.texCoordScaleOffset.value = [1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0]; - break; - case 'stereoTopBottom': - material.texCoordScaleOffset.value = [1.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5]; - break; - case 'stereoLeftRight': - material.texCoordScaleOffset.value = [0.5, 1.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0]; - break; - } - - var renderPrimitive = renderer.createRenderPrimitive(primitive, material); - this.addRenderPrimitive(renderPrimitive); - } - }, { - key: 'aspectRatio', - get: function get() { - var width = this._video.videoWidth; - var height = this._video.videoHeight; - - switch (this._displayMode) { - case 'stereoTopBottom': - height *= 0.5;break; - case 'stereoLeftRight': - width *= 0.5;break; - } - - if (!height || !width) { - return 1; - } - - return width / height; - } - }]); - - return VideoNode; -}(_node.Node); - -/***/ }), - -/***/ "./src/scenes/scene.js": -/*!*****************************!*\ - !*** ./src/scenes/scene.js ***! - \*****************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Scene = exports.WebXRView = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _renderer = __webpack_require__(/*! ../core/renderer.js */ "./src/core/renderer.js"); - -var _inputRenderer = __webpack_require__(/*! ../nodes/input-renderer.js */ "./src/nodes/input-renderer.js"); - -var _statsViewer = __webpack_require__(/*! ../nodes/stats-viewer.js */ "./src/nodes/stats-viewer.js"); - -var _node = __webpack_require__(/*! ../core/node.js */ "./src/core/node.js"); - -var _glMatrix = __webpack_require__(/*! ../math/gl-matrix.js */ "./src/math/gl-matrix.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var WebXRView = exports.WebXRView = function (_RenderView) { - _inherits(WebXRView, _RenderView); - - function WebXRView(view, pose, layer) { - _classCallCheck(this, WebXRView); - - return _possibleConstructorReturn(this, (WebXRView.__proto__ || Object.getPrototypeOf(WebXRView)).call(this, view ? view.projectionMatrix : null, pose && view ? view.viewMatrix : null, layer && view ? layer.getViewport(view) : null, view ? view.eye : 'left')); - } - - return WebXRView; -}(_renderer.RenderView); - -var Scene = exports.Scene = function (_Node) { - _inherits(Scene, _Node); - - function Scene() { - _classCallCheck(this, Scene); - - var _this2 = _possibleConstructorReturn(this, (Scene.__proto__ || Object.getPrototypeOf(Scene)).call(this)); - - _this2._timestamp = -1; - _this2._frameDelta = 0; - _this2._statsStanding = false; - _this2._stats = null; - _this2._statsEnabled = false; - _this2.enableStats(true); // Ensure the stats are added correctly by default. - - _this2._inputRenderer = null; - _this2._resetInputEndFrame = true; - - _this2._lastTimestamp = 0; - - _this2._hoverFrame = 0; - _this2._hoveredNodes = []; - - _this2.clear = true; - return _this2; - } - - _createClass(Scene, [{ - key: 'setRenderer', - value: function setRenderer(renderer) { - this._setRenderer(renderer); - } - }, { - key: 'loseRenderer', - value: function loseRenderer() { - if (this._renderer) { - this._stats = null; - this._renderer = null; - this._inputRenderer = null; - } - } - }, { - key: 'updateInputSources', - - - // Helper function that automatically adds the appropriate visual elements for - // all input sources. - value: function updateInputSources(frame, refSpace) { - // FIXME: Check for the existence of the API first. This check should be - // removed once the input API is part of the official spec. - if (!frame.session.getInputSources) { - return; - } - - var inputSources = frame.session.getInputSources(); - - var newHoveredNodes = []; - var lastHoverFrame = this._hoverFrame; - this._hoverFrame++; - - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = inputSources[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var inputSource = _step.value; - - var inputPose = frame.getInputPose(inputSource, refSpace); - - if (!inputPose) { - continue; - } - - // Any time that we have a grip matrix, we'll render a controller. - if (inputPose.gripTransform.matrix) { - this.inputRenderer.addController(inputPose.gripTransform.matrix); - } - - if (inputPose.targetRay) { - if (inputSource.targetRayMode == 'tracked-pointer') { - // If we have a pointer matrix and the pointer origin is the users - // hand (as opposed to their head or the screen) use it to render - // a ray coming out of the input device to indicate the pointer - // direction. - this.inputRenderer.addLaserPointer(inputPose.targetRay); - } - - // If we have a pointer matrix we can also use it to render a cursor - // for both handheld and gaze-based input sources. - - // Check and see if the pointer is pointing at any selectable objects. - var hitResult = this.hitTest(inputPose.targetRay); - - if (hitResult) { - // Render a cursor at the intersection point. - this.inputRenderer.addCursor(hitResult.intersection); - - if (hitResult.node._hoverFrameId != lastHoverFrame) { - hitResult.node.onHoverStart(); - } - hitResult.node._hoverFrameId = this._hoverFrame; - newHoveredNodes.push(hitResult.node); - } else { - // Statically render the cursor 1 meters down the ray since we didn't - // hit anything selectable. - var cursorDistance = 1.0; - var cursorPos = _glMatrix.vec3.fromValues(inputPose.targetRay.origin.x, inputPose.targetRay.origin.y, inputPose.targetRay.origin.z); - _glMatrix.vec3.add(cursorPos, cursorPos, [inputPose.targetRay.direction.x * cursorDistance, inputPose.targetRay.direction.y * cursorDistance, inputPose.targetRay.direction.z * cursorDistance]); - // let cursorPos = vec3.fromValues(0, 0, -1.0); - // vec3.transformMat4(cursorPos, cursorPos, inputPose.targetRay); - this.inputRenderer.addCursor(cursorPos); - } - } - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; - - try { - for (var _iterator2 = this._hoveredNodes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var hoverNode = _step2.value; - - if (hoverNode._hoverFrameId != this._hoverFrame) { - hoverNode.onHoverEnd(); - } - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } - - this._hoveredNodes = newHoveredNodes; - } - }, { - key: 'handleSelect', - value: function handleSelect(inputSource, frame, refSpace) { - var inputPose = frame.getInputPose(inputSource, refSpace); - - if (!inputPose) { - return; - } - - this.handleSelectPointer(inputPose.targetRay); - } - }, { - key: 'handleSelectPointer', - value: function handleSelectPointer(targetRay) { - if (targetRay) { - // Check and see if the pointer is pointing at any selectable objects. - var hitResult = this.hitTest(targetRay); - - if (hitResult) { - // Render a cursor at the intersection point. - hitResult.node.handleSelect(); - } - } - } - }, { - key: 'enableStats', - value: function enableStats(enable) { - if (enable == this._statsEnabled) { - return; - } - - this._statsEnabled = enable; - - if (enable) { - this._stats = new _statsViewer.StatsViewer(); - this._stats.selectable = true; - this.addNode(this._stats); - - if (this._statsStanding) { - this._stats.translation = [0, 1.4, -0.75]; - } else { - this._stats.translation = [0, -0.3, -0.5]; - } - this._stats.scale = [0.3, 0.3, 0.3]; - _glMatrix.quat.fromEuler(this._stats.rotation, -45.0, 0.0, 0.0); - } else if (!enable) { - if (this._stats) { - this.removeNode(this._stats); - this._stats = null; - } - } - } - }, { - key: 'standingStats', - value: function standingStats(enable) { - this._statsStanding = enable; - if (this._stats) { - if (this._statsStanding) { - this._stats.translation = [0, 1.4, -0.75]; - } else { - this._stats.translation = [0, -0.3, -0.5]; - } - this._stats.scale = [0.3, 0.3, 0.3]; - _glMatrix.quat.fromEuler(this._stats.rotation, -45.0, 0.0, 0.0); - } - } - }, { - key: 'draw', - value: function draw(projectionMatrix, viewMatrix, eye) { - var view = new _renderer.RenderView(); - view.projectionMatrix = projectionMatrix; - view.viewMatrix = viewMatrix; - if (eye) { - view.eye = eye; - } - - this.drawViewArray([view]); - } - - /** Draws the scene into the base layer of the XRFrame's session */ - - }, { - key: 'drawXRFrame', - value: function drawXRFrame(xrFrame, pose) { - if (!this._renderer || !pose) { - return; - } - - var gl = this._renderer.gl; - var session = xrFrame.session; - // Assumed to be a XRWebGLLayer for now. - var layer = session.renderState.baseLayer; - - if (!gl) { - return; - } - - gl.bindFramebuffer(gl.FRAMEBUFFER, layer.framebuffer); - - if (this.clear) { - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); - } - - var views = []; - var _iteratorNormalCompletion3 = true; - var _didIteratorError3 = false; - var _iteratorError3 = undefined; - - try { - for (var _iterator3 = pose.views[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { - var view = _step3.value; - - views.push(new WebXRView(view, pose, layer)); - } - } catch (err) { - _didIteratorError3 = true; - _iteratorError3 = err; - } finally { - try { - if (!_iteratorNormalCompletion3 && _iterator3.return) { - _iterator3.return(); - } - } finally { - if (_didIteratorError3) { - throw _iteratorError3; - } - } - } - - this.drawViewArray(views); - } - }, { - key: 'drawViewArray', - value: function drawViewArray(views) { - // Don't draw when we don't have a valid context - if (!this._renderer) { - return; - } - - this._renderer.drawViews(views, this); - } - }, { - key: 'startFrame', - value: function startFrame() { - var prevTimestamp = this._timestamp; - this._timestamp = performance.now(); - if (this._stats) { - this._stats.begin(); - } - - if (prevTimestamp >= 0) { - this._frameDelta = this._timestamp - prevTimestamp; - } else { - this._frameDelta = 0; - } - - this._update(this._timestamp, this._frameDelta); - - return this._frameDelta; - } - }, { - key: 'endFrame', - value: function endFrame() { - if (this._inputRenderer && this._resetInputEndFrame) { - this._inputRenderer.reset(); - } - - if (this._stats) { - this._stats.end(); - } - } - - // Override to load scene resources on construction or context restore. - - }, { - key: 'onLoadScene', - value: function onLoadScene(renderer) { - return Promise.resolve(); - } - }, { - key: 'inputRenderer', - get: function get() { - if (!this._inputRenderer) { - this._inputRenderer = new _inputRenderer.InputRenderer(); - this.addNode(this._inputRenderer); - } - return this._inputRenderer; - } - }]); - - return Scene; -}(_node.Node); - -/***/ }), - -/***/ "./src/util/fallback-helper.js": -/*!*************************************!*\ - !*** ./src/util/fallback-helper.js ***! - \*************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.FallbackHelper = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); // Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -var _glMatrix = __webpack_require__(/*! ../math/gl-matrix.js */ "./src/math/gl-matrix.js"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var LOOK_SPEED = 0.0025; - -var FallbackHelper = exports.FallbackHelper = function () { - function FallbackHelper(scene, gl) { - var _this = this; - - _classCallCheck(this, FallbackHelper); - - this.scene = scene; - this.gl = gl; - this._emulateStage = false; - - this.lookYaw = 0; - this.lookPitch = 0; - - this.viewMatrix = _glMatrix.mat4.create(); - - var projectionMatrix = _glMatrix.mat4.create(); - this.projectionMatrix = projectionMatrix; - - // Using a simple identity matrix for the view. - _glMatrix.mat4.identity(this.viewMatrix); - - // We need to track the canvas size in order to resize the WebGL - // backbuffer width and height, as well as update the projection matrix - // and adjust the viewport. - function onResize() { - gl.canvas.width = gl.canvas.offsetWidth * window.devicePixelRatio; - gl.canvas.height = gl.canvas.offsetHeight * window.devicePixelRatio; - _glMatrix.mat4.perspective(projectionMatrix, Math.PI * 0.4, gl.canvas.width / gl.canvas.height, 0.1, 1000.0); - gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); - } - window.addEventListener('resize', onResize); - onResize(); - - // Upding the view matrix with touch or mouse events. - var canvas = gl.canvas; - var lastTouchX = 0; - var lastTouchY = 0; - canvas.addEventListener('touchstart', function (ev) { - if (ev.touches.length == 2) { - lastTouchX = ev.touches[1].pageX; - lastTouchY = ev.touches[1].pageY; - } - }); - canvas.addEventListener('touchmove', function (ev) { - // Rotate the view when two fingers are being used. - if (ev.touches.length == 2) { - _this.onLook(ev.touches[1].pageX - lastTouchX, ev.touches[1].pageY - lastTouchY); - lastTouchX = ev.touches[1].pageX; - lastTouchY = ev.touches[1].pageY; - } - }); - canvas.addEventListener('mousemove', function (ev) { - // Only rotate when the right button is pressed. - if (ev.buttons & 2) { - _this.onLook(ev.movementX, ev.movementY); - } - }); - canvas.addEventListener('contextmenu', function (ev) { - // Prevent context menus on the canvas so that we can use right click to rotate. - ev.preventDefault(); - }); - - this.boundOnFrame = this.onFrame.bind(this); - window.requestAnimationFrame(this.boundOnFrame); - } - - _createClass(FallbackHelper, [{ - key: 'onLook', - value: function onLook(yaw, pitch) { - this.lookYaw += yaw * LOOK_SPEED; - this.lookPitch += pitch * LOOK_SPEED; - - // Clamp pitch rotation beyond looking straight up or down. - if (this.lookPitch < -Math.PI * 0.5) { - this.lookPitch = -Math.PI * 0.5; - } - if (this.lookPitch > Math.PI * 0.5) { - this.lookPitch = Math.PI * 0.5; - } - - this.updateView(); - } - }, { - key: 'onFrame', - value: function onFrame(t) { - var gl = this.gl; - window.requestAnimationFrame(this.boundOnFrame); - - this.scene.startFrame(); - - // We can skip setting the framebuffer and viewport every frame, because - // it won't change from frame to frame and we're updating the viewport - // only when we resize for efficency. - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); - - // We're drawing with our own projection and view matrix now, and we - // don't have a list of view to loop through, but otherwise all of the - // WebGL drawing logic is exactly the same. - this.scene.draw(this.projectionMatrix, this.viewMatrix); - - this.scene.endFrame(); - } - }, { - key: 'updateView', - value: function updateView() { - _glMatrix.mat4.identity(this.viewMatrix); - - _glMatrix.mat4.rotateX(this.viewMatrix, this.viewMatrix, -this.lookPitch); - _glMatrix.mat4.rotateY(this.viewMatrix, this.viewMatrix, -this.lookYaw); - - // If we're emulating a stage frame of reference we'll need to move the view - // matrix roughly a meter and a half up in the air. - if (this._emulateStage) { - _glMatrix.mat4.translate(this.viewMatrix, this.viewMatrix, [0, -1.6, 0]); - } - } - }, { - key: 'emulateStage', - get: function get() { - return this._emulateStage; - }, - set: function set(value) { - this._emulateStage = value; - this.updateView(); - } - }]); - - return FallbackHelper; -}(); - -/***/ }), - -/***/ "./src/util/query-args.js": -/*!********************************!*\ - !*** ./src/util/query-args.js ***! - \********************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -// Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/* -Provides a simple way to get values from the query string if they're present -and use a default value if not. Not strictly a "WebGL" utility, but I use it -frequently enough for debugging that I wanted to include it here. - -Example: -For the URL http://example.com/index.html?particleCount=1000 - -QueryArgs.getInt("particleCount", 100); // URL overrides, returns 1000 -QueryArgs.getInt("particleSize", 10); // Not in URL, returns default of 10 -*/ - -var urlArgs = null; -window.onhashchange = function () { - // Force re-parsing on next access - urlArgs = null; -}; - -function ensureArgsCached() { - if (!urlArgs) { - urlArgs = {}; - var query = window.location.search.substring(1) || window.location.hash.substring(1); - var vars = query.split('&'); - for (var i = 0; i < vars.length; i++) { - var pair = vars[i].split('='); - urlArgs[pair[0].toLowerCase()] = decodeURIComponent(pair[1]); - } - } -} - -var QueryArgs = exports.QueryArgs = function () { - function QueryArgs() { - _classCallCheck(this, QueryArgs); - } - - _createClass(QueryArgs, null, [{ - key: 'getString', - value: function getString(name, defaultValue) { - ensureArgsCached(); - var lcaseName = name.toLowerCase(); - if (lcaseName in urlArgs) { - return urlArgs[lcaseName]; - } - return defaultValue; - } - }, { - key: 'getInt', - value: function getInt(name, defaultValue) { - ensureArgsCached(); - var lcaseName = name.toLowerCase(); - if (lcaseName in urlArgs) { - return parseInt(urlArgs[lcaseName], 10); - } - return defaultValue; - } - }, { - key: 'getFloat', - value: function getFloat(name, defaultValue) { - ensureArgsCached(); - var lcaseName = name.toLowerCase(); - if (lcaseName in urlArgs) { - return parseFloat(urlArgs[lcaseName]); - } - return defaultValue; - } - }, { - key: 'getBool', - value: function getBool(name, defaultValue) { - ensureArgsCached(); - var lcaseName = name.toLowerCase(); - if (lcaseName in urlArgs) { - return parseInt(urlArgs[lcaseName], 10) != 0; - } - return defaultValue; - } - }]); - - return QueryArgs; -}(); - -/***/ }) - -/******/ }); -}); -//# sourceMappingURL=cottontail.debug.js.map \ No newline at end of file diff --git a/js/cottontail/build/cottontail.debug.js.map b/js/cottontail/build/cottontail.debug.js.map deleted file mode 100644 index f9fa6940b..000000000 --- a/js/cottontail/build/cottontail.debug.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./node_modules/gl-matrix/src/gl-matrix/common.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/mat2.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/mat2d.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/mat3.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/mat4.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/quat.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/quat2.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/vec2.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/vec3.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/vec4.js","webpack:///./src/core/material.js","webpack:///./src/core/node.js","webpack:///./src/core/primitive.js","webpack:///./src/core/program.js","webpack:///./src/core/renderer.js","webpack:///./src/core/texture.js","webpack:///./src/cottontail.js","webpack:///./src/geometry/box-builder.js","webpack:///./src/geometry/primitive-stream.js","webpack:///./src/loaders/gltf2.js","webpack:///./src/materials/pbr.js","webpack:///./src/math/gl-matrix.js","webpack:///./src/math/ray.js","webpack:///./src/nodes/bounds-renderer.js","webpack:///./src/nodes/button.js","webpack:///./src/nodes/cube-sea.js","webpack:///./src/nodes/drop-shadow.js","webpack:///./src/nodes/gltf2.js","webpack:///./src/nodes/input-renderer.js","webpack:///./src/nodes/seven-segment-text.js","webpack:///./src/nodes/skybox.js","webpack:///./src/nodes/stats-viewer.js","webpack:///./src/nodes/video.js","webpack:///./src/scenes/scene.js","webpack:///./src/util/fallback-helper.js","webpack:///./src/util/query-args.js"],"names":["stateToBlendFunc","GL","WebGLRenderingContext","CAP","CULL_FACE","BLEND","DEPTH_TEST","STENCIL_TEST","COLOR_MASK","DEPTH_MASK","STENCIL_MASK","MAT_STATE","CAPS_RANGE","BLEND_SRC_SHIFT","BLEND_SRC_RANGE","BLEND_DST_SHIFT","BLEND_DST_RANGE","BLEND_FUNC_RANGE","DEPTH_FUNC_SHIFT","DEPTH_FUNC_RANGE","RENDER_ORDER","OPAQUE","SKY","TRANSPARENT","ADDITIVE","DEFAULT","state","mask","shift","value","SRC_COLOR","MaterialState","_state","blendFuncSrc","SRC_ALPHA","blendFuncDst","ONE_MINUS_SRC_ALPHA","depthFunc","LESS","NEVER","MaterialSampler","uniformName","_uniformName","_texture","MaterialUniform","defaultValue","length","_value","_length","Array","Material","renderOrder","_samplers","_uniforms","sampler","push","uniform","renderPrimitive","DEFAULT_TRANSLATION","Float32Array","DEFAULT_ROTATION","DEFAULT_SCALE","tmpRayMatrix","mat4","create","Node","name","children","parent","visible","selectable","_matrix","_dirtyTRS","_translation","_rotation","_scale","_dirtyWorldMatrix","_worldMatrix","_activeFrameId","_hoverFrameId","_renderPrimitives","_renderer","_selectHandler","renderer","clearRenderPrimitives","onRendererChanged","child","_setRenderer","cloneNode","vec3","copy","quat","waitForComplete","then","primitive","addRenderPrimitive","addNode","clone","frameId","markActive","removeNode","i","indexOf","splice","setMatrixDirty","fromRotationTranslationScale","childPromises","Promise","all","_instances","index","ray","localRay","_min","invert","worldMatrix","multiply","transformMatrix","Ray","intersection","intersectsAABB","_max","transformMat4","_hitTestSelectableNode","origin","fromValues","x","y","z","node","distance","result","childResult","hitTest","timestamp","frameDelta","onUpdate","_update","_updateLocalMatrix","mul","PrimitiveAttribute","buffer","componentCount","componentType","stride","byteOffset","normalized","Primitive","attributes","elementCount","mode","indexBuffer","indexByteOffset","indexType","min","max","Program","gl","vertSrc","fragSrc","attribMap","defines","_gl","program","createProgram","attrib","_firstUse","_nextUseCallbacks","definesString","define","_vertShader","createShader","VERTEX_SHADER","attachShader","shaderSource","compileShader","_fragShader","FRAGMENT_SHADER","attribName","bindAttribLocation","linkProgram","callback","getProgramParameter","LINK_STATUS","getShaderParameter","COMPILE_STATUS","console","error","getShaderInfoLog","getProgramInfoLog","deleteProgram","attribCount","ACTIVE_ATTRIBUTES","attribInfo","getActiveAttrib","getAttribLocation","uniformCount","ACTIVE_UNIFORMS","uniformInfo","getActiveUniform","replace","getUniformLocation","deleteShader","useProgram","createWebGLContext","ATTRIB","POSITION","NORMAL","TANGENT","TEXCOORD_0","TEXCOORD_1","COLOR_0","ATTRIB_MASK","DEF_LIGHT_DIR","DEF_LIGHT_COLOR","PRECISION_REGEX","RegExp","VERTEX_SHADER_SINGLE_ENTRY","VERTEX_SHADER_MULTI_ENTRY","FRAGMENT_SHADER_ENTRY","isPowerOfTwo","n","glAttribs","alpha","webglCanvas","document","createElement","contextTypes","webgl2","context","contextType","getContext","webglType","RenderView","projectionMatrix","viewMatrix","viewport","eye","_eye","_eyeIndex","RenderBuffer","target","usage","_target","_usage","_buffer","_promise","resolve","RenderPrimitiveAttribute","primitiveAttribute","_attrib_index","_componentCount","_componentType","_stride","_byteOffset","_normalized","RenderPrimitiveAttributeBuffer","_attributes","RenderPrimitive","_material","setPrimitive","_mode","_elementCount","_vao","_complete","_attributeBuffers","_attributeMask","attribute","renderAttribute","foundBuffer","attributeBuffer","_indexBuffer","_indexByteOffset","_indexType","material","reject","completionPromises","_samplerDictionary","_uniform_dictionary","RenderTexture","texture","_activeCallback","inverseMatrix","setCap","glEnum","cap","prevState","change","enable","disable","RenderMaterialSampler","materialSampler","_renderTexture","_getRenderTexture","_index","RenderMaterialUniform","materialUniform","_uniform","RenderMaterial","_program","_completeForActiveFrame","renderSampler","renderUniform","_firstBind","_renderOrder","activeTexture","TEXTURE0","bindTexture","TEXTURE_2D","uniform1fv","uniform2fv","uniform3fv","uniform4fv","otherState","Renderer","_frameId","_programCache","_textureCache","_cameraPositions","_vaoExt","getExtension","fragHighPrecision","getShaderPrecisionFormat","HIGH_FLOAT","_defaultFragPrecision","precision","_depthMaskNeedsReset","_colorMaskNeedsReset","_globalLightColor","_globalLightDir","data","STATIC_DRAW","glBuffer","createBuffer","renderBuffer","bindBuffer","bufferData","byteLength","offset","bufferSubData","updateRenderBuffer","_getMaterialProgram","renderMaterial","setRenderMaterial","meshNode","createRenderPrimitive","views","rootNode","vp","width","height","cameraPosition","set","renderPrimitives","_drawRenderPrimitiveSet","bindVertexArrayOES","depthMask","colorMask","attribMask","use","LIGHT_DIRECTION","LIGHT_COLOR","uniformMatrix4fv","PROJECTION_MATRIX","VIEW_MATRIX","CAMERA_POSITION","uniform1i","EYE_INDEX","eyeIndex","_bindMaterialState","bind","createVertexArrayOES","_bindPrimitive","view","instance","MODEL_MATRIX","drawElements","drawArrays","key","textureKey","Error","textureHandle","createTexture","renderTexture","DataTexture","texImage2D","format","_type","_data","_setSamplerParameters","UNSIGNED_BYTE","source","VideoTexture","_video","addEventListener","paused","waiting","powerOfTwo","mipmap","generateMipmap","minFilter","LINEAR_MIPMAP_LINEAR","LINEAR","wrapS","REPEAT","CLAMP_TO_EDGE","wrapT","texParameteri","TEXTURE_MAG_FILTER","magFilter","TEXTURE_MIN_FILTER","TEXTURE_WRAP_S","TEXTURE_WRAP_T","materialName","vertexSource","fragmentSource","getProgramDefines","_getProgramKey","multiview","fullVertexSource","precisionMatch","match","fragPrecisionHeader","fullFragmentSource","onNextUse","enableVertexAttribArray","disableVertexAttribArray","ARRAY_BUFFER","vertexAttribPointer","ELEMENT_ARRAY_BUFFER","prevMaterial","_capsDiff","colorMaskChange","depthMaskChange","stencilMaskChange","stencilMask","_blendDiff","blendFunc","_depthFuncDiff","TextureSampler","Texture","RGBA","ImageTexture","img","_img","_imgBitmap","src","complete","naturalWidth","_finishImage","window","createImageBitmap","imgBitmap","UrlTexture","url","Image","BlobTexture","blob","URL","createObjectURL","video","readyState","videoWidth","videoHeight","nextDataTextureIndex","type","_width","_height","_format","_key","ColorTexture","r","g","b","a","colorData","Uint8Array","PrimitiveStream","BoxBuilder","PbrMaterial","mat3","vec4","BoundsRenderer","ButtonNode","DropShadowNode","CubeSeaNode","Gltf2Node","SkyboxNode","VideoNode","WebXRView","Scene","FallbackHelper","QueryArgs","stream","primitiveStream","w","h","d","wh","hh","dh","cx","cy","cz","startGeometry","idx","nextVertexIndex","pushTriangle","pushVertex","endGeometry","center","size","hs","pushBox","GeometryBuilderBase","tempVec3","options","_vertices","_indices","_geometryStarted","_vertexOffset","_vertexIndex","_highIndex","_flipWinding","_invertNormals","_transform","_normalTransform","u","v","nx","ny","nz","transformMat3","Math","idxA","idxB","idxC","vertexBuffer","createRenderBuffer","Uint16Array","attribs","FLOAT","setIndexBuffer","setBounds","fromMat4","_stream","finishPrimitive","clear","GLB_MAGIC","CHUNK_TYPE","JSON","BIN","isAbsoluteUri","uri","absRegEx","location","protocol","isDataUri","dataRegEx","resolveUri","baseUrl","getComponentCount","Gltf2Loader","fetch","response","lastIndexOf","substring","endsWith","json","loadFromJson","arrayBuffer","loadFromBinary","headerView","DataView","magic","getUint32","version","chunks","chunkOffset","chunkHeaderView","chunkLength","chunkType","slice","decoder","TextDecoder","jsonString","decode","parse","binaryChunk","asset","minVersion","buffers","Gltf2Resource","bufferViews","bufferView","Gltf2BufferView","images","image","textures","glTexture","getTexture","textureInfo","materials","glMaterial","pbr","pbrMetallicRoughness","baseColorFactor","baseColor","baseColorTexture","metallicRoughnessFactor","metallicFactor","roughnessFactor","metallicRoughness","metallicRoughnessTexture","normal","normalTexture","occlusion","occlusionTexture","occlusionStrength","strength","emissiveFactor","emissive","emissiveTexture","alphaMode","blend","cullFace","doubleSided","accessors","meshes","mesh","glMesh","Gltf2Mesh","primitives","accessor","count","glAttribute","byteStride","glPrimitive","indices","sceneNode","scene","scenes","nodes","nodeId","processNodes","glNode","matrix","translation","rotation","scale","_viewPromise","_renderBuffer","dataView","_dataPromise","base64String","binaryArray","from","atob","c","charCodeAt","Blob","mimeType","VERTEX_SOURCE","EPIC_PBR_FUNCTIONS","FRAGMENT_SOURCE","defineSampler","defineUniform","programDefines","glMatrix","mat2","mat2d","quat2","vec2","normalMat","RAY_INTERSECTION_OFFSET","_dir","dir","bounds","tmin","sign","inv_dir","tmax","tymin","tymax","tzmin","tzmax","t","intersectionPoint","add","normalize","BoundsMaterial","ONE","depthTest","_stageBounds","stageBounds","verts","pointCount","geometry","point","BUTTON_SIZE","BUTTON_CORNER_RADIUS","BUTTON_CORNER_SEGMENTS","BUTTON_ICON_SIZE","BUTTON_LAYER_DISTANCE","BUTTON_COLOR","BUTTON_ALPHA","BUTTON_HOVER_COLOR","BUTTON_HOVER_ALPHA","BUTTON_HOVER_SCALE","BUTTON_HOVER_TRANSITION_TIME_MS","ButtonMaterial","ButtonIconMaterial","icon","iconTexture","_iconTexture","_hovered","_hoverT","hd","ihs","segments","rad","PI","cos","sin","section","floor","buttonPrimitive","_buttonRenderPrimitive","iconPrimitive","iconMaterial","_iconRenderPrimitive","hoverAmount","uniforms","_updateHoverState","samplers","CubeSeaMaterial","heavy","heavyGpu","cubeCount","cubeScale","halfOnly","autoRotate","imageUrl","_renderPrimitive","boxBuilder","pushCube","heroPrimitive","heroNode","createMesh","rebuildCubes","cubeSeaNode","halfGrid","pos","cubeSeaPrimitive","fromRotation","SHADOW_SEGMENTS","SHADOW_GROUND_OFFSET","SHADOW_CENTER_ALPHA","SHADOW_INNER_ALPHA","SHADOW_OUTER_ALPHA","SHADOW_INNER_RADIUS","SHADOW_OUTER_RADIUS","DropShadowMaterial","LEQUAL","segRad","shadowPrimitive","_shadowRenderPrimitive","gltfLoaderMap","WeakMap","_url","_resolver","_rejecter","loader","get","_ensurePromise","loadFromUrl","catch","err","LASER_TEXTURE_DATA","LASER_LENGTH","LASER_DIAMETER","LASER_FADE_END","LASER_FADE_POINT","LASER_DEFAULT_COLOR","CURSOR_RADIUS","CURSOR_SHADOW_RADIUS","CURSOR_SHADOW_INNER_LUMINANCE","CURSOR_SHADOW_OUTER_LUMINANCE","CURSOR_SHADOW_INNER_OPACITY","CURSOR_SHADOW_OUTER_OPACITY","CURSOR_OPACITY","CURSOR_SEGMENTS","CURSOR_DEFAULT_COLOR","CURSOR_DEFAULT_HIDDEN_COLOR","DEFAULT_RESET_OPTIONS","controllers","lasers","cursors","LaserMaterial","laser","laserColor","CURSOR_VERTEX_SHADER","CURSOR_FRAGMENT_SHADER","CursorMaterial","cursorColor","CursorHiddenMaterial","GEQUAL","InputRenderer","_maxInputElements","_controllers","_controllerNode","_controllerNodeHandedness","_lasers","_cursors","_activeControllers","_activeLasers","_activeCursors","controllerNode","handedness","gripMatrix","controller","targetRay","_createLaserMesh","cursorPos","_createCursorMesh","cursor","lr","ll","laserVerts","laserIndices","laserVertexBuffer","laserIndexBuffer","laserIndexCount","laserAttribs","laserPrimitive","laserMaterial","laserRenderPrimitive","cursorVerts","cursorIndices","indexOffset","cursorVertexBuffer","cursorIndexBuffer","cursorIndexCount","cursorAttribs","cursorPrimitive","cursorMaterial","cursorHiddenMaterial","cursorRenderPrimitive","cursorHiddenRenderPrimitive","TEXT_KERNING","SevenSegmentMaterial","SevenSegmentText","_text","_charNodes","clearNodes","vertices","segmentIndices","thickness","defineSegment","id","left","top","right","bottom","characters","defineCharacter","character","segment","vertexAttribs","_charPrimitives","char","charDef","text","charPrimitive","SkyboxMaterial","texCoordScaleOffset","_displayMode","displayMode","_rotationY","rotationY","latSegments","lonSegments","theta","sinTheta","cosTheta","idxOffsetA","idxOffsetB","j","phi","SEGMENTS","MAX_FPS","StatsMaterial","segmentToX","fpsToY","fpsToRGB","now","performance","Date","StatsViewer","_performanceMonitoring","_startTime","_prevFrameTime","_prevGraphUpdateTime","_frames","_fpsAverage","_fpsMin","_fpsStep","_lastSegment","_fpsVertexBuffer","_fpsRenderPrimitive","_fpsNode","_sevenSegmentNode","fpsVerts","fpsIndices","addBGSquare","DYNAMIC_DRAW","fpsIndexBuffer","fpsAttribs","fpsPrimitive","time","frameFps","intervalTime","round","_updateGraph","log","valueLow","valueHigh","color","y0","y1","updateVerts","VideoMaterial","_video_texture","pose","layer","getViewport","_timestamp","_frameDelta","_statsStanding","_stats","_statsEnabled","enableStats","_inputRenderer","_resetInputEndFrame","_lastTimestamp","_hoverFrame","_hoveredNodes","frame","refSpace","session","getInputSources","inputSources","newHoveredNodes","lastHoverFrame","inputSource","inputPose","getInputPose","gripTransform","inputRenderer","addController","targetRayMode","addLaserPointer","hitResult","addCursor","onHoverStart","cursorDistance","direction","hoverNode","onHoverEnd","handleSelectPointer","handleSelect","fromEuler","drawViewArray","xrFrame","renderState","baseLayer","bindFramebuffer","FRAMEBUFFER","framebuffer","COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","drawViews","prevTimestamp","begin","reset","end","LOOK_SPEED","_emulateStage","lookYaw","lookPitch","identity","onResize","canvas","offsetWidth","devicePixelRatio","offsetHeight","perspective","drawingBufferWidth","drawingBufferHeight","lastTouchX","lastTouchY","ev","touches","pageX","pageY","onLook","buttons","movementX","movementY","preventDefault","boundOnFrame","onFrame","requestAnimationFrame","yaw","pitch","updateView","startFrame","draw","endFrame","rotateX","rotateY","translate","urlArgs","onhashchange","ensureArgsCached","query","search","hash","vars","split","pair","toLowerCase","decodeURIComponent","lcaseName","parseInt","parseFloat"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAkB;AAC1E;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAyC,iCAAiC;AAC1E,wHAAgH,mBAAmB,EAAE;AACrI;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;;;;;;;AClFA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;;AAEA;AACO;AACA;AACA;;AAEP;AACA;AACA;AACA,WAAW,KAAK;AAChB;AACO;AACP;AACA;;AAEA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACO;AACP;AACA;;;;;;;;;;;;;ACzCA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAuC;;AAEvC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,KAAK;AAClB;AACO;AACP,gBAAgB,qDAAmB;AACnC,KAAK,qDAAmB;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP,gBAAgB,qDAAmB;AACnC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP,gBAAgB,qDAAmB;AACnC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB;;AAEO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACO;AACP;AACA;AACA,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;;;;;;;;;;;;AC9ZP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAwC;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACO;AACP,gBAAgB,qDAAmB;AACnC,KAAK,qDAAmB;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACO;AACP,gBAAgB,qDAAmB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACO;AACP,gBAAgB,qDAAmB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,OAAO;AACpB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,OAAO;AACpB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACO;AACP;AACA;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AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP,gBAAgB,qDAAmB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP,gBAAgB,qDAAmB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,MAAM;AACjB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,KAAK;AACf,UAAU,KAAK;AACf;AACA,YAAY,KAAK;AACjB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,UAAU,KAAK;AACf,UAAU,KAAK;AACf;AACA,YAAY,KAAK;AACjB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AAIA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACO;AACP;AACA;AACA,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C;;AAEA;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;;;;;;;;;;;;AC1uBP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAwC;;AAExC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,KAAK;AAClB;AACO;AACP,gBAAgB,qDAAmB;AACnC,KAAK,qDAAmB;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP,gBAAgB,qDAAmB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP,gBAAgB,qDAAmB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,YAAY,WAAW,WAAW;AAClC;AACA;AACA;AACA;;AAEA,YAAY,WAAW,YAAY;AACnC;AACA;AACA;AACA;;AAEA,aAAa,YAAY,YAAY;AACrC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH,eAAe,YAAY,YAAY;AACvC,eAAe,YAAY,YAAY;AACvC,eAAe,YAAY,aAAa;;AAExC,iBAAiB,cAAc,cAAc;AAC7C,iBAAiB,cAAc,cAAc;AAC7C,iBAAiB,cAAc,eAAe;;AAE9C;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,YAAY,kDAAgB,GAAG,aAAa;;AAE5C;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,aAAa,YAAY,YAAY;AACrC,aAAa,YAAY,YAAY;AACrC,aAAa,YAAY,aAAa;;AAEtC;AACA,sBAAsB,yBAAyB;AAC/C,0BAA0B,qBAAqB;AAC/C,0BAA0B,yBAAyB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;;AAEA,YAAY,kDAAgB,GAAG,aAAa;;AAE5C;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,MAAM;AACjB,aAAa,KAAK;AAClB;AACO;AACP,wBAAwB,qDAAmB;AAC3C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,YAAY,KAAK;AACjB,YAAY,KAAK;AACjB,YAAY,KAAK;AACjB;AACO;AACP;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,KAAK;AACjB,YAAY,KAAK;AACjB,YAAY,KAAK;AACjB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,YAAY,KAAK;AACjB;AACO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB;AACA,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iCAAiC,kDAAgB;AACjD,iCAAiC,kDAAgB;AACjD,iCAAiC,kDAAgB;AACjD;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAA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A;AACA;AACA;AACA;AACA,YAAY,KAAK;AACjB,YAAY,KAAK;AACjB,YAAY,OAAO;AACnB;AACO;AACP;AACA;AACA,UAAU,kDAAgB;AAC1B;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,kDAAgB;AACvC;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA,WAAW,iDAAe;AAC1B,WAAW,iDAAe;AAC1B,WAAW,iDAAe;;AAE1B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA,oCAAoC;AACpC;AACA,sBAAsB;AACtB;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,EAAE;AACb,WAAW,EAAE;AACb,WAAW,EAAE;AACb,aAAa,KAAK;AAClB;AACA;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACO,cAAc,8CAAU;;AAE/B;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACO,mBAAmB,mDAAe;;AAEzC;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACO;AACP,eAAe,qDAAmB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACO;AACP,eAAe,qDAAmB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACO;AACP,eAAe,qDAAmB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACO;AACP;AACA,cAAc,+CAAW;AACzB,EAAE,oDAAgB;AAClB,cAAc,qDAAmB;AACjC,EAAE,uDAAmB;AACrB;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY,KAAK;AACjB,YAAY,MAAM;AAClB,YAAY,KAAK;AACjB;AACO,gBAAgB,6CAAS;;AAEhC;AACA;AACA,YAAY,KAAK;AACjB,YAAY,MAAM;AAClB,YAAY,KAAK;AACjB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACO,gBAAgB,6CAAS;;AAEhC;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY,KAAK;AACjB,YAAY,MAAM;AAClB,YAAY,KAAK;AACjB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,gDAAY;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,gDAAY;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,gDAAY;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACO;AACP;AACA,sBAAsB,kDAAgB;AACtC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,OAAO;AACpB;AACA;AACO,YAAY,4CAAQ;;AAE3B;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,OAAO;AACpB;AACA;AACO,eAAe,+CAAW;;AAEjC;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,OAAO;AACpB;AACA;AACO,sBAAsB,sDAAkB;;AAE/C;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,QAAQ;AACrB;AACO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,QAAQ;AACrB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,kDAAgB;AAC/C,yBAAyB,kDAAgB;AACzC,yBAAyB,kDAAgB;AACzC,yBAAyB,kDAAgB;AACzC,yBAAyB,kDAAgB;AACzC,yBAAyB,kDAAgB;AACzC,yBAAyB,kDAAgB;AACzC,yBAAyB,kDAAgB;AACzC;;;;;;;;;;;;;ACr1BA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAwC;;AAExC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,KAAK;AAClB;AACO;AACP,gBAAgB,qDAAmB;AACnC,KAAK,qDAAmB;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP,gBAAgB,qDAAmB;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP,gBAAgB,qDAAmB;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA,UAAU,iDAAe;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,MAAM;AACjB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;AAGA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACO;AACP;AACA;AACA,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C;;AAEA;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,SAAS;AACpB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACO;AACP;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA,mBAAmB,OAAO;AAC1B,oBAAoB;AACpB;AACA,oBAAoB;AACpB;;AA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AAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;;AAEA,UAAU,iDAAe;AACzB,WAAW,iDAAe;AAC1B;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACO;AACP;AACA;AACA,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C;;AAEA;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,SAAS;AACpB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACO;AACP;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA,mBAAmB,OAAO;AAC1B,oBAAoB,iBAAiB;AACrC;AACA,oBAAoB,iBAAiB;AACrC;;AAEA;AACA;AACA,CAAC;;;;;;;;;;;;;AChwBD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAwC;;AAExC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,KAAK;AAClB;AACO;AACP,gBAAgB,qDAAmB;AACnC,KAAK,qDAAmB;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP,gBAAgB,qDAAmB;AACnC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP,gBAAgB,qDAAmB;AACnC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,iDAAe;AACxB,SAAS,iDAAe;AACxB;AACA,GAAG;AACH;AACA,SAAS,iDAAe;AACxB,SAAS,iDAAe;AACxB;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACO;AACP;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACO;AACP;AACA;AACA,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C,+BAA+B,kDAAgB;AAC/C;;AAEA;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA,cAAc;AACd;AACA;AACO;;AAEP;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,SAAS;AACpB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACO;AACP;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA,mBAAmB,OAAO;AAC1B,oBAAoB,iBAAiB,iBAAiB;AACtD;AACA,oBAAoB,iBAAiB,iBAAiB;AACtD;;AAEA;AACA;AACA,CAAC;;;;;;;;;;;;;;;;;;;;;QC3hBeA,gB,GAAAA,gB;;;;AA9DhB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;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jCm9B;AACA,UAAIS,YAAYv8B,KAAKq8B,WAAL,EAAhB;AACA,UAAIE,aAAaX,OAAjB,EAA0B;AACxB,eAAOY,SAASZ,QAAQW,SAAR,CAAT,EAA6B,EAA7B,KAAoC,CAA3C;AACD;AACD,aAAO59B,YAAP;AACD","file":"cottontail.debug.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/cottontail.js\");\n","/**\n * Common utilities\n * @module glMatrix\n */\n\n// Configuration Constants\nexport const EPSILON = 0.000001;\nexport let ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array;\nexport const RANDOM = Math.random;\n\n/**\n * Sets the type of array used when creating new vectors and matrices\n *\n * @param {Type} type Array type, such as Float32Array or Array\n */\nexport function setMatrixArrayType(type) {\n ARRAY_TYPE = type;\n}\n\nconst degree = Math.PI / 180;\n\n/**\n * Convert Degree To Radian\n *\n * @param {Number} a Angle in Degrees\n */\nexport function toRadian(a) {\n return a * degree;\n}\n\n/**\n * Tests whether or not the arguments have approximately the same value, within an absolute\n * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less\n * than or equal to 1.0, and a relative tolerance is used for larger values)\n *\n * @param {Number} a The first number to test.\n * @param {Number} b The second number to test.\n * @returns {Boolean} True if the numbers are approximately equal, false otherwise.\n */\nexport function equals(a, b) {\n return Math.abs(a - b) <= EPSILON*Math.max(1.0, Math.abs(a), Math.abs(b));\n}\n","import * as glMatrix from \"./common.js\"\n\n/**\n * 2x2 Matrix\n * @module mat2\n */\n\n/**\n * Creates a new identity mat2\n *\n * @returns {mat2} a new 2x2 matrix\n */\nexport function create() {\n let out = new glMatrix.ARRAY_TYPE(4);\n if(glMatrix.ARRAY_TYPE != Float32Array) {\n out[1] = 0;\n out[2] = 0;\n }\n out[0] = 1;\n out[3] = 1;\n return out;\n}\n\n/**\n * Creates a new mat2 initialized with values from an existing matrix\n *\n * @param {mat2} a matrix to clone\n * @returns {mat2} a new 2x2 matrix\n */\nexport function clone(a) {\n let out = new glMatrix.ARRAY_TYPE(4);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n\n/**\n * Copy the values from one mat2 to another\n *\n * @param {mat2} out the receiving matrix\n * @param {mat2} a the source matrix\n * @returns {mat2} out\n */\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n\n/**\n * Set a mat2 to the identity matrix\n *\n * @param {mat2} out the receiving matrix\n * @returns {mat2} out\n */\nexport function identity(out) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n return out;\n}\n\n/**\n * Create a new mat2 with the given values\n *\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m10 Component in column 1, row 0 position (index 2)\n * @param {Number} m11 Component in column 1, row 1 position (index 3)\n * @returns {mat2} out A new 2x2 matrix\n */\nexport function fromValues(m00, m01, m10, m11) {\n let out = new glMatrix.ARRAY_TYPE(4);\n out[0] = m00;\n out[1] = m01;\n out[2] = m10;\n out[3] = m11;\n return out;\n}\n\n/**\n * Set the components of a mat2 to the given values\n *\n * @param {mat2} out the receiving matrix\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m10 Component in column 1, row 0 position (index 2)\n * @param {Number} m11 Component in column 1, row 1 position (index 3)\n * @returns {mat2} out\n */\nexport function set(out, m00, m01, m10, m11) {\n out[0] = m00;\n out[1] = m01;\n out[2] = m10;\n out[3] = m11;\n return out;\n}\n\n/**\n * Transpose the values of a mat2\n *\n * @param {mat2} out the receiving matrix\n * @param {mat2} a the source matrix\n * @returns {mat2} out\n */\nexport function transpose(out, a) {\n // If we are transposing ourselves we can skip a few steps but have to cache\n // some values\n if (out === a) {\n let a1 = a[1];\n out[1] = a[2];\n out[2] = a1;\n } else {\n out[0] = a[0];\n out[1] = a[2];\n out[2] = a[1];\n out[3] = a[3];\n }\n\n return out;\n}\n\n/**\n * Inverts a mat2\n *\n * @param {mat2} out the receiving matrix\n * @param {mat2} a the source matrix\n * @returns {mat2} out\n */\nexport function invert(out, a) {\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\n\n // Calculate the determinant\n let det = a0 * a3 - a2 * a1;\n\n if (!det) {\n return null;\n }\n det = 1.0 / det;\n\n out[0] = a3 * det;\n out[1] = -a1 * det;\n out[2] = -a2 * det;\n out[3] = a0 * det;\n\n return out;\n}\n\n/**\n * Calculates the adjugate of a mat2\n *\n * @param {mat2} out the receiving matrix\n * @param {mat2} a the source matrix\n * @returns {mat2} out\n */\nexport function adjoint(out, a) {\n // Caching this value is nessecary if out == a\n let a0 = a[0];\n out[0] = a[3];\n out[1] = -a[1];\n out[2] = -a[2];\n out[3] = a0;\n\n return out;\n}\n\n/**\n * Calculates the determinant of a mat2\n *\n * @param {mat2} a the source matrix\n * @returns {Number} determinant of a\n */\nexport function determinant(a) {\n return a[0] * a[3] - a[2] * a[1];\n}\n\n/**\n * Multiplies two mat2's\n *\n * @param {mat2} out the receiving matrix\n * @param {mat2} a the first operand\n * @param {mat2} b the second operand\n * @returns {mat2} out\n */\nexport function multiply(out, a, b) {\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];\n out[0] = a0 * b0 + a2 * b1;\n out[1] = a1 * b0 + a3 * b1;\n out[2] = a0 * b2 + a2 * b3;\n out[3] = a1 * b2 + a3 * b3;\n return out;\n}\n\n/**\n * Rotates a mat2 by the given angle\n *\n * @param {mat2} out the receiving matrix\n * @param {mat2} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat2} out\n */\nexport function rotate(out, a, rad) {\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\n let s = Math.sin(rad);\n let c = Math.cos(rad);\n out[0] = a0 * c + a2 * s;\n out[1] = a1 * c + a3 * s;\n out[2] = a0 * -s + a2 * c;\n out[3] = a1 * -s + a3 * c;\n return out;\n}\n\n/**\n * Scales the mat2 by the dimensions in the given vec2\n *\n * @param {mat2} out the receiving matrix\n * @param {mat2} a the matrix to rotate\n * @param {vec2} v the vec2 to scale the matrix by\n * @returns {mat2} out\n **/\nexport function scale(out, a, v) {\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\n let v0 = v[0], v1 = v[1];\n out[0] = a0 * v0;\n out[1] = a1 * v0;\n out[2] = a2 * v1;\n out[3] = a3 * v1;\n return out;\n}\n\n/**\n * Creates a matrix from a given angle\n * This is equivalent to (but much faster than):\n *\n * mat2.identity(dest);\n * mat2.rotate(dest, dest, rad);\n *\n * @param {mat2} out mat2 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat2} out\n */\nexport function fromRotation(out, rad) {\n let s = Math.sin(rad);\n let c = Math.cos(rad);\n out[0] = c;\n out[1] = s;\n out[2] = -s;\n out[3] = c;\n return out;\n}\n\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n * mat2.identity(dest);\n * mat2.scale(dest, dest, vec);\n *\n * @param {mat2} out mat2 receiving operation result\n * @param {vec2} v Scaling vector\n * @returns {mat2} out\n */\nexport function fromScaling(out, v) {\n out[0] = v[0];\n out[1] = 0;\n out[2] = 0;\n out[3] = v[1];\n return out;\n}\n\n/**\n * Returns a string representation of a mat2\n *\n * @param {mat2} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\nexport function str(a) {\n return 'mat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';\n}\n\n/**\n * Returns Frobenius norm of a mat2\n *\n * @param {mat2} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\nexport function frob(a) {\n return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2)))\n}\n\n/**\n * Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix\n * @param {mat2} L the lower triangular matrix\n * @param {mat2} D the diagonal matrix\n * @param {mat2} U the upper triangular matrix\n * @param {mat2} a the input matrix to factorize\n */\n\nexport function LDU(L, D, U, a) {\n L[2] = a[2]/a[0];\n U[0] = a[0];\n U[1] = a[1];\n U[3] = a[3] - L[2] * U[1];\n return [L, D, U];\n}\n\n/**\n * Adds two mat2's\n *\n * @param {mat2} out the receiving matrix\n * @param {mat2} a the first operand\n * @param {mat2} b the second operand\n * @returns {mat2} out\n */\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n return out;\n}\n\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat2} out the receiving matrix\n * @param {mat2} a the first operand\n * @param {mat2} b the second operand\n * @returns {mat2} out\n */\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n return out;\n}\n\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {mat2} a The first matrix.\n * @param {mat2} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {mat2} a The first matrix.\n * @param {mat2} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\nexport function equals(a, b) {\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\n Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&\n Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&\n Math.abs(a3 - b3) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a3), Math.abs(b3)));\n}\n\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat2} out the receiving matrix\n * @param {mat2} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat2} out\n */\nexport function multiplyScalar(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n return out;\n}\n\n/**\n * Adds two mat2's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat2} out the receiving vector\n * @param {mat2} a the first operand\n * @param {mat2} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat2} out\n */\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n out[0] = a[0] + (b[0] * scale);\n out[1] = a[1] + (b[1] * scale);\n out[2] = a[2] + (b[2] * scale);\n out[3] = a[3] + (b[3] * scale);\n return out;\n}\n\n/**\n * Alias for {@link mat2.multiply}\n * @function\n */\nexport const mul = multiply;\n\n/**\n * Alias for {@link mat2.subtract}\n * @function\n */\nexport const sub = subtract;\n","import * as glMatrix from \"./common.js\";\n\n/**\n * 2x3 Matrix\n * @module mat2d\n *\n * @description\n * A mat2d contains six elements defined as:\n *
\n * [a, c, tx,\n *  b, d, ty]\n * 
\n * This is a short form for the 3x3 matrix:\n *
\n * [a, c, tx,\n *  b, d, ty,\n *  0, 0, 1]\n * 
\n * The last row is ignored so the array is shorter and operations are faster.\n */\n\n/**\n * Creates a new identity mat2d\n *\n * @returns {mat2d} a new 2x3 matrix\n */\nexport function create() {\n let out = new glMatrix.ARRAY_TYPE(6);\n if(glMatrix.ARRAY_TYPE != Float32Array) {\n out[1] = 0;\n out[2] = 0;\n out[4] = 0;\n out[5] = 0;\n }\n out[0] = 1;\n out[3] = 1;\n return out;\n}\n\n/**\n * Creates a new mat2d initialized with values from an existing matrix\n *\n * @param {mat2d} a matrix to clone\n * @returns {mat2d} a new 2x3 matrix\n */\nexport function clone(a) {\n let out = new glMatrix.ARRAY_TYPE(6);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n return out;\n}\n\n/**\n * Copy the values from one mat2d to another\n *\n * @param {mat2d} out the receiving matrix\n * @param {mat2d} a the source matrix\n * @returns {mat2d} out\n */\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n return out;\n}\n\n/**\n * Set a mat2d to the identity matrix\n *\n * @param {mat2d} out the receiving matrix\n * @returns {mat2d} out\n */\nexport function identity(out) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n out[4] = 0;\n out[5] = 0;\n return out;\n}\n\n/**\n * Create a new mat2d with the given values\n *\n * @param {Number} a Component A (index 0)\n * @param {Number} b Component B (index 1)\n * @param {Number} c Component C (index 2)\n * @param {Number} d Component D (index 3)\n * @param {Number} tx Component TX (index 4)\n * @param {Number} ty Component TY (index 5)\n * @returns {mat2d} A new mat2d\n */\nexport function fromValues(a, b, c, d, tx, ty) {\n let out = new glMatrix.ARRAY_TYPE(6);\n out[0] = a;\n out[1] = b;\n out[2] = c;\n out[3] = d;\n out[4] = tx;\n out[5] = ty;\n return out;\n}\n\n/**\n * Set the components of a mat2d to the given values\n *\n * @param {mat2d} out the receiving matrix\n * @param {Number} a Component A (index 0)\n * @param {Number} b Component B (index 1)\n * @param {Number} c Component C (index 2)\n * @param {Number} d Component D (index 3)\n * @param {Number} tx Component TX (index 4)\n * @param {Number} ty Component TY (index 5)\n * @returns {mat2d} out\n */\nexport function set(out, a, b, c, d, tx, ty) {\n out[0] = a;\n out[1] = b;\n out[2] = c;\n out[3] = d;\n out[4] = tx;\n out[5] = ty;\n return out;\n}\n\n/**\n * Inverts a mat2d\n *\n * @param {mat2d} out the receiving matrix\n * @param {mat2d} a the source matrix\n * @returns {mat2d} out\n */\nexport function invert(out, a) {\n let aa = a[0], ab = a[1], ac = a[2], ad = a[3];\n let atx = a[4], aty = a[5];\n\n let det = aa * ad - ab * ac;\n if(!det){\n return null;\n }\n det = 1.0 / det;\n\n out[0] = ad * det;\n out[1] = -ab * det;\n out[2] = -ac * det;\n out[3] = aa * det;\n out[4] = (ac * aty - ad * atx) * det;\n out[5] = (ab * atx - aa * aty) * det;\n return out;\n}\n\n/**\n * Calculates the determinant of a mat2d\n *\n * @param {mat2d} a the source matrix\n * @returns {Number} determinant of a\n */\nexport function determinant(a) {\n return a[0] * a[3] - a[1] * a[2];\n}\n\n/**\n * Multiplies two mat2d's\n *\n * @param {mat2d} out the receiving matrix\n * @param {mat2d} a the first operand\n * @param {mat2d} b the second operand\n * @returns {mat2d} out\n */\nexport function multiply(out, a, b) {\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5];\n out[0] = a0 * b0 + a2 * b1;\n out[1] = a1 * b0 + a3 * b1;\n out[2] = a0 * b2 + a2 * b3;\n out[3] = a1 * b2 + a3 * b3;\n out[4] = a0 * b4 + a2 * b5 + a4;\n out[5] = a1 * b4 + a3 * b5 + a5;\n return out;\n}\n\n/**\n * Rotates a mat2d by the given angle\n *\n * @param {mat2d} out the receiving matrix\n * @param {mat2d} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat2d} out\n */\nexport function rotate(out, a, rad) {\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];\n let s = Math.sin(rad);\n let c = Math.cos(rad);\n out[0] = a0 * c + a2 * s;\n out[1] = a1 * c + a3 * s;\n out[2] = a0 * -s + a2 * c;\n out[3] = a1 * -s + a3 * c;\n out[4] = a4;\n out[5] = a5;\n return out;\n}\n\n/**\n * Scales the mat2d by the dimensions in the given vec2\n *\n * @param {mat2d} out the receiving matrix\n * @param {mat2d} a the matrix to translate\n * @param {vec2} v the vec2 to scale the matrix by\n * @returns {mat2d} out\n **/\nexport function scale(out, a, v) {\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];\n let v0 = v[0], v1 = v[1];\n out[0] = a0 * v0;\n out[1] = a1 * v0;\n out[2] = a2 * v1;\n out[3] = a3 * v1;\n out[4] = a4;\n out[5] = a5;\n return out;\n}\n\n/**\n * Translates the mat2d by the dimensions in the given vec2\n *\n * @param {mat2d} out the receiving matrix\n * @param {mat2d} a the matrix to translate\n * @param {vec2} v the vec2 to translate the matrix by\n * @returns {mat2d} out\n **/\nexport function translate(out, a, v) {\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];\n let v0 = v[0], v1 = v[1];\n out[0] = a0;\n out[1] = a1;\n out[2] = a2;\n out[3] = a3;\n out[4] = a0 * v0 + a2 * v1 + a4;\n out[5] = a1 * v0 + a3 * v1 + a5;\n return out;\n}\n\n/**\n * Creates a matrix from a given angle\n * This is equivalent to (but much faster than):\n *\n * mat2d.identity(dest);\n * mat2d.rotate(dest, dest, rad);\n *\n * @param {mat2d} out mat2d receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat2d} out\n */\nexport function fromRotation(out, rad) {\n let s = Math.sin(rad), c = Math.cos(rad);\n out[0] = c;\n out[1] = s;\n out[2] = -s;\n out[3] = c;\n out[4] = 0;\n out[5] = 0;\n return out;\n}\n\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n * mat2d.identity(dest);\n * mat2d.scale(dest, dest, vec);\n *\n * @param {mat2d} out mat2d receiving operation result\n * @param {vec2} v Scaling vector\n * @returns {mat2d} out\n */\nexport function fromScaling(out, v) {\n out[0] = v[0];\n out[1] = 0;\n out[2] = 0;\n out[3] = v[1];\n out[4] = 0;\n out[5] = 0;\n return out;\n}\n\n/**\n * Creates a matrix from a vector translation\n * This is equivalent to (but much faster than):\n *\n * mat2d.identity(dest);\n * mat2d.translate(dest, dest, vec);\n *\n * @param {mat2d} out mat2d receiving operation result\n * @param {vec2} v Translation vector\n * @returns {mat2d} out\n */\nexport function fromTranslation(out, v) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n out[4] = v[0];\n out[5] = v[1];\n return out;\n}\n\n/**\n * Returns a string representation of a mat2d\n *\n * @param {mat2d} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\nexport function str(a) {\n return 'mat2d(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' +\n a[3] + ', ' + a[4] + ', ' + a[5] + ')';\n}\n\n/**\n * Returns Frobenius norm of a mat2d\n *\n * @param {mat2d} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\nexport function frob(a) {\n return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + 1))\n}\n\n/**\n * Adds two mat2d's\n *\n * @param {mat2d} out the receiving matrix\n * @param {mat2d} a the first operand\n * @param {mat2d} b the second operand\n * @returns {mat2d} out\n */\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n out[4] = a[4] + b[4];\n out[5] = a[5] + b[5];\n return out;\n}\n\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat2d} out the receiving matrix\n * @param {mat2d} a the first operand\n * @param {mat2d} b the second operand\n * @returns {mat2d} out\n */\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n out[4] = a[4] - b[4];\n out[5] = a[5] - b[5];\n return out;\n}\n\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat2d} out the receiving matrix\n * @param {mat2d} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat2d} out\n */\nexport function multiplyScalar(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n out[4] = a[4] * b;\n out[5] = a[5] * b;\n return out;\n}\n\n/**\n * Adds two mat2d's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat2d} out the receiving vector\n * @param {mat2d} a the first operand\n * @param {mat2d} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat2d} out\n */\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n out[0] = a[0] + (b[0] * scale);\n out[1] = a[1] + (b[1] * scale);\n out[2] = a[2] + (b[2] * scale);\n out[3] = a[3] + (b[3] * scale);\n out[4] = a[4] + (b[4] * scale);\n out[5] = a[5] + (b[5] * scale);\n return out;\n}\n\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {mat2d} a The first matrix.\n * @param {mat2d} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5];\n}\n\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {mat2d} a The first matrix.\n * @param {mat2d} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\nexport function equals(a, b) {\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5];\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\n Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&\n Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&\n Math.abs(a3 - b3) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a3), Math.abs(b3)) &&\n Math.abs(a4 - b4) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a4), Math.abs(b4)) &&\n Math.abs(a5 - b5) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a5), Math.abs(b5)));\n}\n\n/**\n * Alias for {@link mat2d.multiply}\n * @function\n */\nexport const mul = multiply;\n\n/**\n * Alias for {@link mat2d.subtract}\n * @function\n */\nexport const sub = subtract;\n","import * as glMatrix from \"./common.js\";\n\n/**\n * 3x3 Matrix\n * @module mat3\n */\n\n/**\n * Creates a new identity mat3\n *\n * @returns {mat3} a new 3x3 matrix\n */\nexport function create() {\n let out = new glMatrix.ARRAY_TYPE(9);\n if(glMatrix.ARRAY_TYPE != Float32Array) {\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n }\n out[0] = 1;\n out[4] = 1;\n out[8] = 1;\n return out;\n}\n\n/**\n * Copies the upper-left 3x3 values into the given mat3.\n *\n * @param {mat3} out the receiving 3x3 matrix\n * @param {mat4} a the source 4x4 matrix\n * @returns {mat3} out\n */\nexport function fromMat4(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[4];\n out[4] = a[5];\n out[5] = a[6];\n out[6] = a[8];\n out[7] = a[9];\n out[8] = a[10];\n return out;\n}\n\n/**\n * Creates a new mat3 initialized with values from an existing matrix\n *\n * @param {mat3} a matrix to clone\n * @returns {mat3} a new 3x3 matrix\n */\nexport function clone(a) {\n let out = new glMatrix.ARRAY_TYPE(9);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n return out;\n}\n\n/**\n * Copy the values from one mat3 to another\n *\n * @param {mat3} out the receiving matrix\n * @param {mat3} a the source matrix\n * @returns {mat3} out\n */\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n return out;\n}\n\n/**\n * Create a new mat3 with the given values\n *\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m10 Component in column 1, row 0 position (index 3)\n * @param {Number} m11 Component in column 1, row 1 position (index 4)\n * @param {Number} m12 Component in column 1, row 2 position (index 5)\n * @param {Number} m20 Component in column 2, row 0 position (index 6)\n * @param {Number} m21 Component in column 2, row 1 position (index 7)\n * @param {Number} m22 Component in column 2, row 2 position (index 8)\n * @returns {mat3} A new mat3\n */\nexport function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {\n let out = new glMatrix.ARRAY_TYPE(9);\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m10;\n out[4] = m11;\n out[5] = m12;\n out[6] = m20;\n out[7] = m21;\n out[8] = m22;\n return out;\n}\n\n/**\n * Set the components of a mat3 to the given values\n *\n * @param {mat3} out the receiving matrix\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m10 Component in column 1, row 0 position (index 3)\n * @param {Number} m11 Component in column 1, row 1 position (index 4)\n * @param {Number} m12 Component in column 1, row 2 position (index 5)\n * @param {Number} m20 Component in column 2, row 0 position (index 6)\n * @param {Number} m21 Component in column 2, row 1 position (index 7)\n * @param {Number} m22 Component in column 2, row 2 position (index 8)\n * @returns {mat3} out\n */\nexport function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m10;\n out[4] = m11;\n out[5] = m12;\n out[6] = m20;\n out[7] = m21;\n out[8] = m22;\n return out;\n}\n\n/**\n * Set a mat3 to the identity matrix\n *\n * @param {mat3} out the receiving matrix\n * @returns {mat3} out\n */\nexport function identity(out) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 1;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 1;\n return out;\n}\n\n/**\n * Transpose the values of a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {mat3} a the source matrix\n * @returns {mat3} out\n */\nexport function transpose(out, a) {\n // If we are transposing ourselves we can skip a few steps but have to cache some values\n if (out === a) {\n let a01 = a[1], a02 = a[2], a12 = a[5];\n out[1] = a[3];\n out[2] = a[6];\n out[3] = a01;\n out[5] = a[7];\n out[6] = a02;\n out[7] = a12;\n } else {\n out[0] = a[0];\n out[1] = a[3];\n out[2] = a[6];\n out[3] = a[1];\n out[4] = a[4];\n out[5] = a[7];\n out[6] = a[2];\n out[7] = a[5];\n out[8] = a[8];\n }\n\n return out;\n}\n\n/**\n * Inverts a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {mat3} a the source matrix\n * @returns {mat3} out\n */\nexport function invert(out, a) {\n let a00 = a[0], a01 = a[1], a02 = a[2];\n let a10 = a[3], a11 = a[4], a12 = a[5];\n let a20 = a[6], a21 = a[7], a22 = a[8];\n\n let b01 = a22 * a11 - a12 * a21;\n let b11 = -a22 * a10 + a12 * a20;\n let b21 = a21 * a10 - a11 * a20;\n\n // Calculate the determinant\n let det = a00 * b01 + a01 * b11 + a02 * b21;\n\n if (!det) {\n return null;\n }\n det = 1.0 / det;\n\n out[0] = b01 * det;\n out[1] = (-a22 * a01 + a02 * a21) * det;\n out[2] = (a12 * a01 - a02 * a11) * det;\n out[3] = b11 * det;\n out[4] = (a22 * a00 - a02 * a20) * det;\n out[5] = (-a12 * a00 + a02 * a10) * det;\n out[6] = b21 * det;\n out[7] = (-a21 * a00 + a01 * a20) * det;\n out[8] = (a11 * a00 - a01 * a10) * det;\n return out;\n}\n\n/**\n * Calculates the adjugate of a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {mat3} a the source matrix\n * @returns {mat3} out\n */\nexport function adjoint(out, a) {\n let a00 = a[0], a01 = a[1], a02 = a[2];\n let a10 = a[3], a11 = a[4], a12 = a[5];\n let a20 = a[6], a21 = a[7], a22 = a[8];\n\n out[0] = (a11 * a22 - a12 * a21);\n out[1] = (a02 * a21 - a01 * a22);\n out[2] = (a01 * a12 - a02 * a11);\n out[3] = (a12 * a20 - a10 * a22);\n out[4] = (a00 * a22 - a02 * a20);\n out[5] = (a02 * a10 - a00 * a12);\n out[6] = (a10 * a21 - a11 * a20);\n out[7] = (a01 * a20 - a00 * a21);\n out[8] = (a00 * a11 - a01 * a10);\n return out;\n}\n\n/**\n * Calculates the determinant of a mat3\n *\n * @param {mat3} a the source matrix\n * @returns {Number} determinant of a\n */\nexport function determinant(a) {\n let a00 = a[0], a01 = a[1], a02 = a[2];\n let a10 = a[3], a11 = a[4], a12 = a[5];\n let a20 = a[6], a21 = a[7], a22 = a[8];\n\n return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);\n}\n\n/**\n * Multiplies two mat3's\n *\n * @param {mat3} out the receiving matrix\n * @param {mat3} a the first operand\n * @param {mat3} b the second operand\n * @returns {mat3} out\n */\nexport function multiply(out, a, b) {\n let a00 = a[0], a01 = a[1], a02 = a[2];\n let a10 = a[3], a11 = a[4], a12 = a[5];\n let a20 = a[6], a21 = a[7], a22 = a[8];\n\n let b00 = b[0], b01 = b[1], b02 = b[2];\n let b10 = b[3], b11 = b[4], b12 = b[5];\n let b20 = b[6], b21 = b[7], b22 = b[8];\n\n out[0] = b00 * a00 + b01 * a10 + b02 * a20;\n out[1] = b00 * a01 + b01 * a11 + b02 * a21;\n out[2] = b00 * a02 + b01 * a12 + b02 * a22;\n\n out[3] = b10 * a00 + b11 * a10 + b12 * a20;\n out[4] = b10 * a01 + b11 * a11 + b12 * a21;\n out[5] = b10 * a02 + b11 * a12 + b12 * a22;\n\n out[6] = b20 * a00 + b21 * a10 + b22 * a20;\n out[7] = b20 * a01 + b21 * a11 + b22 * a21;\n out[8] = b20 * a02 + b21 * a12 + b22 * a22;\n return out;\n}\n\n/**\n * Translate a mat3 by the given vector\n *\n * @param {mat3} out the receiving matrix\n * @param {mat3} a the matrix to translate\n * @param {vec2} v vector to translate by\n * @returns {mat3} out\n */\nexport function translate(out, a, v) {\n let a00 = a[0], a01 = a[1], a02 = a[2],\n a10 = a[3], a11 = a[4], a12 = a[5],\n a20 = a[6], a21 = a[7], a22 = a[8],\n x = v[0], y = v[1];\n\n out[0] = a00;\n out[1] = a01;\n out[2] = a02;\n\n out[3] = a10;\n out[4] = a11;\n out[5] = a12;\n\n out[6] = x * a00 + y * a10 + a20;\n out[7] = x * a01 + y * a11 + a21;\n out[8] = x * a02 + y * a12 + a22;\n return out;\n}\n\n/**\n * Rotates a mat3 by the given angle\n *\n * @param {mat3} out the receiving matrix\n * @param {mat3} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat3} out\n */\nexport function rotate(out, a, rad) {\n let a00 = a[0], a01 = a[1], a02 = a[2],\n a10 = a[3], a11 = a[4], a12 = a[5],\n a20 = a[6], a21 = a[7], a22 = a[8],\n\n s = Math.sin(rad),\n c = Math.cos(rad);\n\n out[0] = c * a00 + s * a10;\n out[1] = c * a01 + s * a11;\n out[2] = c * a02 + s * a12;\n\n out[3] = c * a10 - s * a00;\n out[4] = c * a11 - s * a01;\n out[5] = c * a12 - s * a02;\n\n out[6] = a20;\n out[7] = a21;\n out[8] = a22;\n return out;\n};\n\n/**\n * Scales the mat3 by the dimensions in the given vec2\n *\n * @param {mat3} out the receiving matrix\n * @param {mat3} a the matrix to rotate\n * @param {vec2} v the vec2 to scale the matrix by\n * @returns {mat3} out\n **/\nexport function scale(out, a, v) {\n let x = v[0], y = v[1];\n\n out[0] = x * a[0];\n out[1] = x * a[1];\n out[2] = x * a[2];\n\n out[3] = y * a[3];\n out[4] = y * a[4];\n out[5] = y * a[5];\n\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n return out;\n}\n\n/**\n * Creates a matrix from a vector translation\n * This is equivalent to (but much faster than):\n *\n * mat3.identity(dest);\n * mat3.translate(dest, dest, vec);\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {vec2} v Translation vector\n * @returns {mat3} out\n */\nexport function fromTranslation(out, v) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 1;\n out[5] = 0;\n out[6] = v[0];\n out[7] = v[1];\n out[8] = 1;\n return out;\n}\n\n/**\n * Creates a matrix from a given angle\n * This is equivalent to (but much faster than):\n *\n * mat3.identity(dest);\n * mat3.rotate(dest, dest, rad);\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat3} out\n */\nexport function fromRotation(out, rad) {\n let s = Math.sin(rad), c = Math.cos(rad);\n\n out[0] = c;\n out[1] = s;\n out[2] = 0;\n\n out[3] = -s;\n out[4] = c;\n out[5] = 0;\n\n out[6] = 0;\n out[7] = 0;\n out[8] = 1;\n return out;\n}\n\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n * mat3.identity(dest);\n * mat3.scale(dest, dest, vec);\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {vec2} v Scaling vector\n * @returns {mat3} out\n */\nexport function fromScaling(out, v) {\n out[0] = v[0];\n out[1] = 0;\n out[2] = 0;\n\n out[3] = 0;\n out[4] = v[1];\n out[5] = 0;\n\n out[6] = 0;\n out[7] = 0;\n out[8] = 1;\n return out;\n}\n\n/**\n * Copies the values from a mat2d into a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {mat2d} a the matrix to copy\n * @returns {mat3} out\n **/\nexport function fromMat2d(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = 0;\n\n out[3] = a[2];\n out[4] = a[3];\n out[5] = 0;\n\n out[6] = a[4];\n out[7] = a[5];\n out[8] = 1;\n return out;\n}\n\n/**\n* Calculates a 3x3 matrix from the given quaternion\n*\n* @param {mat3} out mat3 receiving operation result\n* @param {quat} q Quaternion to create matrix from\n*\n* @returns {mat3} out\n*/\nexport function fromQuat(out, q) {\n let x = q[0], y = q[1], z = q[2], w = q[3];\n let x2 = x + x;\n let y2 = y + y;\n let z2 = z + z;\n\n let xx = x * x2;\n let yx = y * x2;\n let yy = y * y2;\n let zx = z * x2;\n let zy = z * y2;\n let zz = z * z2;\n let wx = w * x2;\n let wy = w * y2;\n let wz = w * z2;\n\n out[0] = 1 - yy - zz;\n out[3] = yx - wz;\n out[6] = zx + wy;\n\n out[1] = yx + wz;\n out[4] = 1 - xx - zz;\n out[7] = zy - wx;\n\n out[2] = zx - wy;\n out[5] = zy + wx;\n out[8] = 1 - xx - yy;\n\n return out;\n}\n\n/**\n* Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix\n*\n* @param {mat3} out mat3 receiving operation result\n* @param {mat4} a Mat4 to derive the normal matrix from\n*\n* @returns {mat3} out\n*/\nexport function normalFromMat4(out, a) {\n let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];\n let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];\n let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];\n let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];\n\n let b00 = a00 * a11 - a01 * a10;\n let b01 = a00 * a12 - a02 * a10;\n let b02 = a00 * a13 - a03 * a10;\n let b03 = a01 * a12 - a02 * a11;\n let b04 = a01 * a13 - a03 * a11;\n let b05 = a02 * a13 - a03 * a12;\n let b06 = a20 * a31 - a21 * a30;\n let b07 = a20 * a32 - a22 * a30;\n let b08 = a20 * a33 - a23 * a30;\n let b09 = a21 * a32 - a22 * a31;\n let b10 = a21 * a33 - a23 * a31;\n let b11 = a22 * a33 - a23 * a32;\n\n // Calculate the determinant\n let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n if (!det) {\n return null;\n }\n det = 1.0 / det;\n\n out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;\n out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;\n out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;\n\n out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;\n out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;\n out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;\n\n out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;\n out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;\n out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;\n\n return out;\n}\n\n/**\n * Generates a 2D projection matrix with the given bounds\n *\n * @param {mat3} out mat3 frustum matrix will be written into\n * @param {number} width Width of your gl context\n * @param {number} height Height of gl context\n * @returns {mat3} out\n */\nexport function projection(out, width, height) {\n out[0] = 2 / width;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = -2 / height;\n out[5] = 0;\n out[6] = -1;\n out[7] = 1;\n out[8] = 1;\n return out;\n}\n\n/**\n * Returns a string representation of a mat3\n *\n * @param {mat3} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\nexport function str(a) {\n return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' +\n a[3] + ', ' + a[4] + ', ' + a[5] + ', ' +\n a[6] + ', ' + a[7] + ', ' + a[8] + ')';\n}\n\n/**\n * Returns Frobenius norm of a mat3\n *\n * @param {mat3} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\nexport function frob(a) {\n return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2)))\n}\n\n/**\n * Adds two mat3's\n *\n * @param {mat3} out the receiving matrix\n * @param {mat3} a the first operand\n * @param {mat3} b the second operand\n * @returns {mat3} out\n */\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n out[4] = a[4] + b[4];\n out[5] = a[5] + b[5];\n out[6] = a[6] + b[6];\n out[7] = a[7] + b[7];\n out[8] = a[8] + b[8];\n return out;\n}\n\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat3} out the receiving matrix\n * @param {mat3} a the first operand\n * @param {mat3} b the second operand\n * @returns {mat3} out\n */\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n out[4] = a[4] - b[4];\n out[5] = a[5] - b[5];\n out[6] = a[6] - b[6];\n out[7] = a[7] - b[7];\n out[8] = a[8] - b[8];\n return out;\n}\n\n\n\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat3} out the receiving matrix\n * @param {mat3} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat3} out\n */\nexport function multiplyScalar(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n out[4] = a[4] * b;\n out[5] = a[5] * b;\n out[6] = a[6] * b;\n out[7] = a[7] * b;\n out[8] = a[8] * b;\n return out;\n}\n\n/**\n * Adds two mat3's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat3} out the receiving vector\n * @param {mat3} a the first operand\n * @param {mat3} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat3} out\n */\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n out[0] = a[0] + (b[0] * scale);\n out[1] = a[1] + (b[1] * scale);\n out[2] = a[2] + (b[2] * scale);\n out[3] = a[3] + (b[3] * scale);\n out[4] = a[4] + (b[4] * scale);\n out[5] = a[5] + (b[5] * scale);\n out[6] = a[6] + (b[6] * scale);\n out[7] = a[7] + (b[7] * scale);\n out[8] = a[8] + (b[8] * scale);\n return out;\n}\n\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {mat3} a The first matrix.\n * @param {mat3} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] &&\n a[3] === b[3] && a[4] === b[4] && a[5] === b[5] &&\n a[6] === b[6] && a[7] === b[7] && a[8] === b[8];\n}\n\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {mat3} a The first matrix.\n * @param {mat3} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\nexport function equals(a, b) {\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7], a8 = a[8];\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8];\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\n Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&\n Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&\n Math.abs(a3 - b3) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a3), Math.abs(b3)) &&\n Math.abs(a4 - b4) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a4), Math.abs(b4)) &&\n Math.abs(a5 - b5) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a5), Math.abs(b5)) &&\n Math.abs(a6 - b6) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a6), Math.abs(b6)) &&\n Math.abs(a7 - b7) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a7), Math.abs(b7)) &&\n Math.abs(a8 - b8) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a8), Math.abs(b8)));\n}\n\n/**\n * Alias for {@link mat3.multiply}\n * @function\n */\nexport const mul = multiply;\n\n/**\n * Alias for {@link mat3.subtract}\n * @function\n */\nexport const sub = subtract;\n","import * as glMatrix from \"./common.js\";\n\n/**\n * 4x4 Matrix
Format: column-major, when typed out it looks like row-major
The matrices are being post multiplied.\n * @module mat4\n */\n\n/**\n * Creates a new identity mat4\n *\n * @returns {mat4} a new 4x4 matrix\n */\nexport function create() {\n let out = new glMatrix.ARRAY_TYPE(16);\n if(glMatrix.ARRAY_TYPE != Float32Array) {\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n }\n out[0] = 1;\n out[5] = 1;\n out[10] = 1;\n out[15] = 1;\n return out;\n}\n\n/**\n * Creates a new mat4 initialized with values from an existing matrix\n *\n * @param {mat4} a matrix to clone\n * @returns {mat4} a new 4x4 matrix\n */\nexport function clone(a) {\n let out = new glMatrix.ARRAY_TYPE(16);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n return out;\n}\n\n/**\n * Copy the values from one mat4 to another\n *\n * @param {mat4} out the receiving matrix\n * @param {mat4} a the source matrix\n * @returns {mat4} out\n */\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n return out;\n}\n\n/**\n * Create a new mat4 with the given values\n *\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m03 Component in column 0, row 3 position (index 3)\n * @param {Number} m10 Component in column 1, row 0 position (index 4)\n * @param {Number} m11 Component in column 1, row 1 position (index 5)\n * @param {Number} m12 Component in column 1, row 2 position (index 6)\n * @param {Number} m13 Component in column 1, row 3 position (index 7)\n * @param {Number} m20 Component in column 2, row 0 position (index 8)\n * @param {Number} m21 Component in column 2, row 1 position (index 9)\n * @param {Number} m22 Component in column 2, row 2 position (index 10)\n * @param {Number} m23 Component in column 2, row 3 position (index 11)\n * @param {Number} m30 Component in column 3, row 0 position (index 12)\n * @param {Number} m31 Component in column 3, row 1 position (index 13)\n * @param {Number} m32 Component in column 3, row 2 position (index 14)\n * @param {Number} m33 Component in column 3, row 3 position (index 15)\n * @returns {mat4} A new mat4\n */\nexport function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {\n let out = new glMatrix.ARRAY_TYPE(16);\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m03;\n out[4] = m10;\n out[5] = m11;\n out[6] = m12;\n out[7] = m13;\n out[8] = m20;\n out[9] = m21;\n out[10] = m22;\n out[11] = m23;\n out[12] = m30;\n out[13] = m31;\n out[14] = m32;\n out[15] = m33;\n return out;\n}\n\n/**\n * Set the components of a mat4 to the given values\n *\n * @param {mat4} out the receiving matrix\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m03 Component in column 0, row 3 position (index 3)\n * @param {Number} m10 Component in column 1, row 0 position (index 4)\n * @param {Number} m11 Component in column 1, row 1 position (index 5)\n * @param {Number} m12 Component in column 1, row 2 position (index 6)\n * @param {Number} m13 Component in column 1, row 3 position (index 7)\n * @param {Number} m20 Component in column 2, row 0 position (index 8)\n * @param {Number} m21 Component in column 2, row 1 position (index 9)\n * @param {Number} m22 Component in column 2, row 2 position (index 10)\n * @param {Number} m23 Component in column 2, row 3 position (index 11)\n * @param {Number} m30 Component in column 3, row 0 position (index 12)\n * @param {Number} m31 Component in column 3, row 1 position (index 13)\n * @param {Number} m32 Component in column 3, row 2 position (index 14)\n * @param {Number} m33 Component in column 3, row 3 position (index 15)\n * @returns {mat4} out\n */\nexport function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m03;\n out[4] = m10;\n out[5] = m11;\n out[6] = m12;\n out[7] = m13;\n out[8] = m20;\n out[9] = m21;\n out[10] = m22;\n out[11] = m23;\n out[12] = m30;\n out[13] = m31;\n out[14] = m32;\n out[15] = m33;\n return out;\n}\n\n\n/**\n * Set a mat4 to the identity matrix\n *\n * @param {mat4} out the receiving matrix\n * @returns {mat4} out\n */\nexport function identity(out) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n\n/**\n * Transpose the values of a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {mat4} a the source matrix\n * @returns {mat4} out\n */\nexport function transpose(out, a) {\n // If we are transposing ourselves we can skip a few steps but have to cache some values\n if (out === a) {\n let a01 = a[1], a02 = a[2], a03 = a[3];\n let a12 = a[6], a13 = a[7];\n let a23 = a[11];\n\n out[1] = a[4];\n out[2] = a[8];\n out[3] = a[12];\n out[4] = a01;\n out[6] = a[9];\n out[7] = a[13];\n out[8] = a02;\n out[9] = a12;\n out[11] = a[14];\n out[12] = a03;\n out[13] = a13;\n out[14] = a23;\n } else {\n out[0] = a[0];\n out[1] = a[4];\n out[2] = a[8];\n out[3] = a[12];\n out[4] = a[1];\n out[5] = a[5];\n out[6] = a[9];\n out[7] = a[13];\n out[8] = a[2];\n out[9] = a[6];\n out[10] = a[10];\n out[11] = a[14];\n out[12] = a[3];\n out[13] = a[7];\n out[14] = a[11];\n out[15] = a[15];\n }\n\n return out;\n}\n\n/**\n * Inverts a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {mat4} a the source matrix\n * @returns {mat4} out\n */\nexport function invert(out, a) {\n let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];\n let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];\n let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];\n let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];\n\n let b00 = a00 * a11 - a01 * a10;\n let b01 = a00 * a12 - a02 * a10;\n let b02 = a00 * a13 - a03 * a10;\n let b03 = a01 * a12 - a02 * a11;\n let b04 = a01 * a13 - a03 * a11;\n let b05 = a02 * a13 - a03 * a12;\n let b06 = a20 * a31 - a21 * a30;\n let b07 = a20 * a32 - a22 * a30;\n let b08 = a20 * a33 - a23 * a30;\n let b09 = a21 * a32 - a22 * a31;\n let b10 = a21 * a33 - a23 * a31;\n let b11 = a22 * a33 - a23 * a32;\n\n // Calculate the determinant\n let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n if (!det) {\n return null;\n }\n det = 1.0 / det;\n\n out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;\n out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;\n out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;\n out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;\n out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;\n out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;\n out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;\n out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;\n out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;\n out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;\n out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;\n out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;\n out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;\n out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;\n out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;\n out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;\n\n return out;\n}\n\n/**\n * Calculates the adjugate of a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {mat4} a the source matrix\n * @returns {mat4} out\n */\nexport function adjoint(out, a) {\n let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];\n let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];\n let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];\n let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];\n\n out[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22));\n out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22));\n out[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12));\n out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12));\n out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22));\n out[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22));\n out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12));\n out[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12));\n out[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21));\n out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21));\n out[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11));\n out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11));\n out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21));\n out[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21));\n out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11));\n out[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11));\n return out;\n}\n\n/**\n * Calculates the determinant of a mat4\n *\n * @param {mat4} a the source matrix\n * @returns {Number} determinant of a\n */\nexport function determinant(a) {\n let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];\n let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];\n let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];\n let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];\n\n let b00 = a00 * a11 - a01 * a10;\n let b01 = a00 * a12 - a02 * a10;\n let b02 = a00 * a13 - a03 * a10;\n let b03 = a01 * a12 - a02 * a11;\n let b04 = a01 * a13 - a03 * a11;\n let b05 = a02 * a13 - a03 * a12;\n let b06 = a20 * a31 - a21 * a30;\n let b07 = a20 * a32 - a22 * a30;\n let b08 = a20 * a33 - a23 * a30;\n let b09 = a21 * a32 - a22 * a31;\n let b10 = a21 * a33 - a23 * a31;\n let b11 = a22 * a33 - a23 * a32;\n\n // Calculate the determinant\n return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n}\n\n/**\n * Multiplies two mat4s\n *\n * @param {mat4} out the receiving matrix\n * @param {mat4} a the first operand\n * @param {mat4} b the second operand\n * @returns {mat4} out\n */\nexport function multiply(out, a, b) {\n let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];\n let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];\n let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];\n let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];\n\n // Cache only the current line of the second matrix\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];\n out[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30;\n out[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31;\n out[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32;\n out[3] = b0*a03 + b1*a13 + b2*a23 + b3*a33;\n\n b0 = b[4]; b1 = b[5]; b2 = b[6]; b3 = b[7];\n out[4] = b0*a00 + b1*a10 + b2*a20 + b3*a30;\n out[5] = b0*a01 + b1*a11 + b2*a21 + b3*a31;\n out[6] = b0*a02 + b1*a12 + b2*a22 + b3*a32;\n out[7] = b0*a03 + b1*a13 + b2*a23 + b3*a33;\n\n b0 = b[8]; b1 = b[9]; b2 = b[10]; b3 = b[11];\n out[8] = b0*a00 + b1*a10 + b2*a20 + b3*a30;\n out[9] = b0*a01 + b1*a11 + b2*a21 + b3*a31;\n out[10] = b0*a02 + b1*a12 + b2*a22 + b3*a32;\n out[11] = b0*a03 + b1*a13 + b2*a23 + b3*a33;\n\n b0 = b[12]; b1 = b[13]; b2 = b[14]; b3 = b[15];\n out[12] = b0*a00 + b1*a10 + b2*a20 + b3*a30;\n out[13] = b0*a01 + b1*a11 + b2*a21 + b3*a31;\n out[14] = b0*a02 + b1*a12 + b2*a22 + b3*a32;\n out[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33;\n return out;\n}\n\n/**\n * Translate a mat4 by the given vector\n *\n * @param {mat4} out the receiving matrix\n * @param {mat4} a the matrix to translate\n * @param {vec3} v vector to translate by\n * @returns {mat4} out\n */\nexport function translate(out, a, v) {\n let x = v[0], y = v[1], z = v[2];\n let a00, a01, a02, a03;\n let a10, a11, a12, a13;\n let a20, a21, a22, a23;\n\n if (a === out) {\n out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];\n out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];\n out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];\n out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];\n } else {\n a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3];\n a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7];\n a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11];\n\n out[0] = a00; out[1] = a01; out[2] = a02; out[3] = a03;\n out[4] = a10; out[5] = a11; out[6] = a12; out[7] = a13;\n out[8] = a20; out[9] = a21; out[10] = a22; out[11] = a23;\n\n out[12] = a00 * x + a10 * y + a20 * z + a[12];\n out[13] = a01 * x + a11 * y + a21 * z + a[13];\n out[14] = a02 * x + a12 * y + a22 * z + a[14];\n out[15] = a03 * x + a13 * y + a23 * z + a[15];\n }\n\n return out;\n}\n\n/**\n * Scales the mat4 by the dimensions in the given vec3 not using vectorization\n *\n * @param {mat4} out the receiving matrix\n * @param {mat4} a the matrix to scale\n * @param {vec3} v the vec3 to scale the matrix by\n * @returns {mat4} out\n **/\nexport function scale(out, a, v) {\n let x = v[0], y = v[1], z = v[2];\n\n out[0] = a[0] * x;\n out[1] = a[1] * x;\n out[2] = a[2] * x;\n out[3] = a[3] * x;\n out[4] = a[4] * y;\n out[5] = a[5] * y;\n out[6] = a[6] * y;\n out[7] = a[7] * y;\n out[8] = a[8] * z;\n out[9] = a[9] * z;\n out[10] = a[10] * z;\n out[11] = a[11] * z;\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n return out;\n}\n\n/**\n * Rotates a mat4 by the given angle around the given axis\n *\n * @param {mat4} out the receiving matrix\n * @param {mat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @param {vec3} axis the axis to rotate around\n * @returns {mat4} out\n */\nexport function rotate(out, a, rad, axis) {\n let x = axis[0], y = axis[1], z = axis[2];\n let len = Math.sqrt(x * x + y * y + z * z);\n let s, c, t;\n let a00, a01, a02, a03;\n let a10, a11, a12, a13;\n let a20, a21, a22, a23;\n let b00, b01, b02;\n let b10, b11, b12;\n let b20, b21, b22;\n\n if (len < glMatrix.EPSILON) { return null; }\n\n len = 1 / len;\n x *= len;\n y *= len;\n z *= len;\n\n s = Math.sin(rad);\n c = Math.cos(rad);\n t = 1 - c;\n\n a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3];\n a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7];\n a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11];\n\n // Construct the elements of the rotation matrix\n b00 = x * x * t + c; b01 = y * x * t + z * s; b02 = z * x * t - y * s;\n b10 = x * y * t - z * s; b11 = y * y * t + c; b12 = z * y * t + x * s;\n b20 = x * z * t + y * s; b21 = y * z * t - x * s; b22 = z * z * t + c;\n\n // Perform rotation-specific matrix multiplication\n out[0] = a00 * b00 + a10 * b01 + a20 * b02;\n out[1] = a01 * b00 + a11 * b01 + a21 * b02;\n out[2] = a02 * b00 + a12 * b01 + a22 * b02;\n out[3] = a03 * b00 + a13 * b01 + a23 * b02;\n out[4] = a00 * b10 + a10 * b11 + a20 * b12;\n out[5] = a01 * b10 + a11 * b11 + a21 * b12;\n out[6] = a02 * b10 + a12 * b11 + a22 * b12;\n out[7] = a03 * b10 + a13 * b11 + a23 * b12;\n out[8] = a00 * b20 + a10 * b21 + a20 * b22;\n out[9] = a01 * b20 + a11 * b21 + a21 * b22;\n out[10] = a02 * b20 + a12 * b21 + a22 * b22;\n out[11] = a03 * b20 + a13 * b21 + a23 * b22;\n\n if (a !== out) { // If the source and destination differ, copy the unchanged last row\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n }\n return out;\n}\n\n/**\n * Rotates a matrix by the given angle around the X axis\n *\n * @param {mat4} out the receiving matrix\n * @param {mat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\nexport function rotateX(out, a, rad) {\n let s = Math.sin(rad);\n let c = Math.cos(rad);\n let a10 = a[4];\n let a11 = a[5];\n let a12 = a[6];\n let a13 = a[7];\n let a20 = a[8];\n let a21 = a[9];\n let a22 = a[10];\n let a23 = a[11];\n\n if (a !== out) { // If the source and destination differ, copy the unchanged rows\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n }\n\n // Perform axis-specific matrix multiplication\n out[4] = a10 * c + a20 * s;\n out[5] = a11 * c + a21 * s;\n out[6] = a12 * c + a22 * s;\n out[7] = a13 * c + a23 * s;\n out[8] = a20 * c - a10 * s;\n out[9] = a21 * c - a11 * s;\n out[10] = a22 * c - a12 * s;\n out[11] = a23 * c - a13 * s;\n return out;\n}\n\n/**\n * Rotates a matrix by the given angle around the Y axis\n *\n * @param {mat4} out the receiving matrix\n * @param {mat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\nexport function rotateY(out, a, rad) {\n let s = Math.sin(rad);\n let c = Math.cos(rad);\n let a00 = a[0];\n let a01 = a[1];\n let a02 = a[2];\n let a03 = a[3];\n let a20 = a[8];\n let a21 = a[9];\n let a22 = a[10];\n let a23 = a[11];\n\n if (a !== out) { // If the source and destination differ, copy the unchanged rows\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n }\n\n // Perform axis-specific matrix multiplication\n out[0] = a00 * c - a20 * s;\n out[1] = a01 * c - a21 * s;\n out[2] = a02 * c - a22 * s;\n out[3] = a03 * c - a23 * s;\n out[8] = a00 * s + a20 * c;\n out[9] = a01 * s + a21 * c;\n out[10] = a02 * s + a22 * c;\n out[11] = a03 * s + a23 * c;\n return out;\n}\n\n/**\n * Rotates a matrix by the given angle around the Z axis\n *\n * @param {mat4} out the receiving matrix\n * @param {mat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\nexport function rotateZ(out, a, rad) {\n let s = Math.sin(rad);\n let c = Math.cos(rad);\n let a00 = a[0];\n let a01 = a[1];\n let a02 = a[2];\n let a03 = a[3];\n let a10 = a[4];\n let a11 = a[5];\n let a12 = a[6];\n let a13 = a[7];\n\n if (a !== out) { // If the source and destination differ, copy the unchanged last row\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n }\n\n // Perform axis-specific matrix multiplication\n out[0] = a00 * c + a10 * s;\n out[1] = a01 * c + a11 * s;\n out[2] = a02 * c + a12 * s;\n out[3] = a03 * c + a13 * s;\n out[4] = a10 * c - a00 * s;\n out[5] = a11 * c - a01 * s;\n out[6] = a12 * c - a02 * s;\n out[7] = a13 * c - a03 * s;\n return out;\n}\n\n/**\n * Creates a matrix from a vector translation\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, dest, vec);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {vec3} v Translation vector\n * @returns {mat4} out\n */\nexport function fromTranslation(out, v) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = v[0];\n out[13] = v[1];\n out[14] = v[2];\n out[15] = 1;\n return out;\n}\n\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.scale(dest, dest, vec);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {vec3} v Scaling vector\n * @returns {mat4} out\n */\nexport function fromScaling(out, v) {\n out[0] = v[0];\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = v[1];\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = v[2];\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n\n/**\n * Creates a matrix from a given angle around a given axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotate(dest, dest, rad, axis);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @param {vec3} axis the axis to rotate around\n * @returns {mat4} out\n */\nexport function fromRotation(out, rad, axis) {\n let x = axis[0], y = axis[1], z = axis[2];\n let len = Math.sqrt(x * x + y * y + z * z);\n let s, c, t;\n\n if (len < glMatrix.EPSILON) { return null; }\n\n len = 1 / len;\n x *= len;\n y *= len;\n z *= len;\n\n s = Math.sin(rad);\n c = Math.cos(rad);\n t = 1 - c;\n\n // Perform rotation-specific matrix multiplication\n out[0] = x * x * t + c;\n out[1] = y * x * t + z * s;\n out[2] = z * x * t - y * s;\n out[3] = 0;\n out[4] = x * y * t - z * s;\n out[5] = y * y * t + c;\n out[6] = z * y * t + x * s;\n out[7] = 0;\n out[8] = x * z * t + y * s;\n out[9] = y * z * t - x * s;\n out[10] = z * z * t + c;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n\n/**\n * Creates a matrix from the given angle around the X axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotateX(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\nexport function fromXRotation(out, rad) {\n let s = Math.sin(rad);\n let c = Math.cos(rad);\n\n // Perform axis-specific matrix multiplication\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = c;\n out[6] = s;\n out[7] = 0;\n out[8] = 0;\n out[9] = -s;\n out[10] = c;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n\n/**\n * Creates a matrix from the given angle around the Y axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotateY(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\nexport function fromYRotation(out, rad) {\n let s = Math.sin(rad);\n let c = Math.cos(rad);\n\n // Perform axis-specific matrix multiplication\n out[0] = c;\n out[1] = 0;\n out[2] = -s;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = s;\n out[9] = 0;\n out[10] = c;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n\n/**\n * Creates a matrix from the given angle around the Z axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotateZ(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\nexport function fromZRotation(out, rad) {\n let s = Math.sin(rad);\n let c = Math.cos(rad);\n\n // Perform axis-specific matrix multiplication\n out[0] = c;\n out[1] = s;\n out[2] = 0;\n out[3] = 0;\n out[4] = -s;\n out[5] = c;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n\n/**\n * Creates a matrix from a quaternion rotation and vector translation\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, vec);\n * let quatMat = mat4.create();\n * quat4.toMat4(quat, quatMat);\n * mat4.multiply(dest, quatMat);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat4} q Rotation quaternion\n * @param {vec3} v Translation vector\n * @returns {mat4} out\n */\nexport function fromRotationTranslation(out, q, v) {\n // Quaternion math\n let x = q[0], y = q[1], z = q[2], w = q[3];\n let x2 = x + x;\n let y2 = y + y;\n let z2 = z + z;\n\n let xx = x * x2;\n let xy = x * y2;\n let xz = x * z2;\n let yy = y * y2;\n let yz = y * z2;\n let zz = z * z2;\n let wx = w * x2;\n let wy = w * y2;\n let wz = w * z2;\n\n out[0] = 1 - (yy + zz);\n out[1] = xy + wz;\n out[2] = xz - wy;\n out[3] = 0;\n out[4] = xy - wz;\n out[5] = 1 - (xx + zz);\n out[6] = yz + wx;\n out[7] = 0;\n out[8] = xz + wy;\n out[9] = yz - wx;\n out[10] = 1 - (xx + yy);\n out[11] = 0;\n out[12] = v[0];\n out[13] = v[1];\n out[14] = v[2];\n out[15] = 1;\n\n return out;\n}\n\n/**\n * Creates a new mat4 from a dual quat.\n *\n * @param {mat4} out Matrix\n * @param {quat2} a Dual Quaternion\n * @returns {mat4} mat4 receiving operation result\n */\nexport function fromQuat2(out, a) {\n let translation = new glMatrix.ARRAY_TYPE(3);\n let bx = -a[0], by = -a[1], bz = -a[2], bw = a[3],\n ax = a[4], ay = a[5], az = a[6], aw = a[7];\n\n let magnitude = bx * bx + by * by + bz * bz + bw * bw;\n //Only scale if it makes sense\n if (magnitude > 0) {\n translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude;\n translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude;\n translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude;\n } else {\n translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;\n translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;\n translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;\n }\n fromRotationTranslation(out, a, translation);\n return out;\n}\n\n/**\n * Returns the translation vector component of a transformation\n * matrix. If a matrix is built with fromRotationTranslation,\n * the returned vector will be the same as the translation vector\n * originally supplied.\n * @param {vec3} out Vector to receive translation component\n * @param {mat4} mat Matrix to be decomposed (input)\n * @return {vec3} out\n */\nexport function getTranslation(out, mat) {\n out[0] = mat[12];\n out[1] = mat[13];\n out[2] = mat[14];\n\n return out;\n}\n\n/**\n * Returns the scaling factor component of a transformation\n * matrix. If a matrix is built with fromRotationTranslationScale\n * with a normalized Quaternion paramter, the returned vector will be\n * the same as the scaling vector\n * originally supplied.\n * @param {vec3} out Vector to receive scaling factor component\n * @param {mat4} mat Matrix to be decomposed (input)\n * @return {vec3} out\n */\nexport function getScaling(out, mat) {\n let m11 = mat[0];\n let m12 = mat[1];\n let m13 = mat[2];\n let m21 = mat[4];\n let m22 = mat[5];\n let m23 = mat[6];\n let m31 = mat[8];\n let m32 = mat[9];\n let m33 = mat[10];\n\n out[0] = Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13);\n out[1] = Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23);\n out[2] = Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33);\n\n return out;\n}\n\n/**\n * Returns a quaternion representing the rotational component\n * of a transformation matrix. If a matrix is built with\n * fromRotationTranslation, the returned quaternion will be the\n * same as the quaternion originally supplied.\n * @param {quat} out Quaternion to receive the rotation component\n * @param {mat4} mat Matrix to be decomposed (input)\n * @return {quat} out\n */\nexport function getRotation(out, mat) {\n // Algorithm taken from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm\n let trace = mat[0] + mat[5] + mat[10];\n let S = 0;\n\n if (trace > 0) {\n S = Math.sqrt(trace + 1.0) * 2;\n out[3] = 0.25 * S;\n out[0] = (mat[6] - mat[9]) / S;\n out[1] = (mat[8] - mat[2]) / S;\n out[2] = (mat[1] - mat[4]) / S;\n } else if ((mat[0] > mat[5]) && (mat[0] > mat[10])) {\n S = Math.sqrt(1.0 + mat[0] - mat[5] - mat[10]) * 2;\n out[3] = (mat[6] - mat[9]) / S;\n out[0] = 0.25 * S;\n out[1] = (mat[1] + mat[4]) / S;\n out[2] = (mat[8] + mat[2]) / S;\n } else if (mat[5] > mat[10]) {\n S = Math.sqrt(1.0 + mat[5] - mat[0] - mat[10]) * 2;\n out[3] = (mat[8] - mat[2]) / S;\n out[0] = (mat[1] + mat[4]) / S;\n out[1] = 0.25 * S;\n out[2] = (mat[6] + mat[9]) / S;\n } else {\n S = Math.sqrt(1.0 + mat[10] - mat[0] - mat[5]) * 2;\n out[3] = (mat[1] - mat[4]) / S;\n out[0] = (mat[8] + mat[2]) / S;\n out[1] = (mat[6] + mat[9]) / S;\n out[2] = 0.25 * S;\n }\n\n return out;\n}\n\n/**\n * Creates a matrix from a quaternion rotation, vector translation and vector scale\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, vec);\n * let quatMat = mat4.create();\n * quat4.toMat4(quat, quatMat);\n * mat4.multiply(dest, quatMat);\n * mat4.scale(dest, scale)\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat4} q Rotation quaternion\n * @param {vec3} v Translation vector\n * @param {vec3} s Scaling vector\n * @returns {mat4} out\n */\nexport function fromRotationTranslationScale(out, q, v, s) {\n // Quaternion math\n let x = q[0], y = q[1], z = q[2], w = q[3];\n let x2 = x + x;\n let y2 = y + y;\n let z2 = z + z;\n\n let xx = x * x2;\n let xy = x * y2;\n let xz = x * z2;\n let yy = y * y2;\n let yz = y * z2;\n let zz = z * z2;\n let wx = w * x2;\n let wy = w * y2;\n let wz = w * z2;\n let sx = s[0];\n let sy = s[1];\n let sz = s[2];\n\n out[0] = (1 - (yy + zz)) * sx;\n out[1] = (xy + wz) * sx;\n out[2] = (xz - wy) * sx;\n out[3] = 0;\n out[4] = (xy - wz) * sy;\n out[5] = (1 - (xx + zz)) * sy;\n out[6] = (yz + wx) * sy;\n out[7] = 0;\n out[8] = (xz + wy) * sz;\n out[9] = (yz - wx) * sz;\n out[10] = (1 - (xx + yy)) * sz;\n out[11] = 0;\n out[12] = v[0];\n out[13] = v[1];\n out[14] = v[2];\n out[15] = 1;\n\n return out;\n}\n\n/**\n * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, vec);\n * mat4.translate(dest, origin);\n * let quatMat = mat4.create();\n * quat4.toMat4(quat, quatMat);\n * mat4.multiply(dest, quatMat);\n * mat4.scale(dest, scale)\n * mat4.translate(dest, negativeOrigin);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat4} q Rotation quaternion\n * @param {vec3} v Translation vector\n * @param {vec3} s Scaling vector\n * @param {vec3} o The origin vector around which to scale and rotate\n * @returns {mat4} out\n */\nexport function fromRotationTranslationScaleOrigin(out, q, v, s, o) {\n // Quaternion math\n let x = q[0], y = q[1], z = q[2], w = q[3];\n let x2 = x + x;\n let y2 = y + y;\n let z2 = z + z;\n\n let xx = x * x2;\n let xy = x * y2;\n let xz = x * z2;\n let yy = y * y2;\n let yz = y * z2;\n let zz = z * z2;\n let wx = w * x2;\n let wy = w * y2;\n let wz = w * z2;\n\n let sx = s[0];\n let sy = s[1];\n let sz = s[2];\n\n let ox = o[0];\n let oy = o[1];\n let oz = o[2];\n\n let out0 = (1 - (yy + zz)) * sx;\n let out1 = (xy + wz) * sx;\n let out2 = (xz - wy) * sx;\n let out4 = (xy - wz) * sy;\n let out5 = (1 - (xx + zz)) * sy;\n let out6 = (yz + wx) * sy;\n let out8 = (xz + wy) * sz;\n let out9 = (yz - wx) * sz;\n let out10 = (1 - (xx + yy)) * sz;\n\n out[0] = out0;\n out[1] = out1;\n out[2] = out2;\n out[3] = 0;\n out[4] = out4;\n out[5] = out5;\n out[6] = out6;\n out[7] = 0;\n out[8] = out8;\n out[9] = out9;\n out[10] = out10;\n out[11] = 0;\n out[12] = v[0] + ox - (out0 * ox + out4 * oy + out8 * oz);\n out[13] = v[1] + oy - (out1 * ox + out5 * oy + out9 * oz);\n out[14] = v[2] + oz - (out2 * ox + out6 * oy + out10 * oz);\n out[15] = 1;\n\n return out;\n}\n\n/**\n * Calculates a 4x4 matrix from the given quaternion\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat} q Quaternion to create matrix from\n *\n * @returns {mat4} out\n */\nexport function fromQuat(out, q) {\n let x = q[0], y = q[1], z = q[2], w = q[3];\n let x2 = x + x;\n let y2 = y + y;\n let z2 = z + z;\n\n let xx = x * x2;\n let yx = y * x2;\n let yy = y * y2;\n let zx = z * x2;\n let zy = z * y2;\n let zz = z * z2;\n let wx = w * x2;\n let wy = w * y2;\n let wz = w * z2;\n\n out[0] = 1 - yy - zz;\n out[1] = yx + wz;\n out[2] = zx - wy;\n out[3] = 0;\n\n out[4] = yx - wz;\n out[5] = 1 - xx - zz;\n out[6] = zy + wx;\n out[7] = 0;\n\n out[8] = zx + wy;\n out[9] = zy - wx;\n out[10] = 1 - xx - yy;\n out[11] = 0;\n\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n\n return out;\n}\n\n/**\n * Generates a frustum matrix with the given bounds\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {Number} left Left bound of the frustum\n * @param {Number} right Right bound of the frustum\n * @param {Number} bottom Bottom bound of the frustum\n * @param {Number} top Top bound of the frustum\n * @param {Number} near Near bound of the frustum\n * @param {Number} far Far bound of the frustum\n * @returns {mat4} out\n */\nexport function frustum(out, left, right, bottom, top, near, far) {\n let rl = 1 / (right - left);\n let tb = 1 / (top - bottom);\n let nf = 1 / (near - far);\n out[0] = (near * 2) * rl;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = (near * 2) * tb;\n out[6] = 0;\n out[7] = 0;\n out[8] = (right + left) * rl;\n out[9] = (top + bottom) * tb;\n out[10] = (far + near) * nf;\n out[11] = -1;\n out[12] = 0;\n out[13] = 0;\n out[14] = (far * near * 2) * nf;\n out[15] = 0;\n return out;\n}\n\n/**\n * Generates a perspective projection matrix with the given bounds.\n * Passing null/undefined/no value for far will generate infinite projection matrix.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} fovy Vertical field of view in radians\n * @param {number} aspect Aspect ratio. typically viewport width/height\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum, can be null or Infinity\n * @returns {mat4} out\n */\nexport function perspective(out, fovy, aspect, near, far) {\n let f = 1.0 / Math.tan(fovy / 2), nf;\n out[0] = f / aspect;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = f;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[11] = -1;\n out[12] = 0;\n out[13] = 0;\n out[15] = 0;\n if (far != null && far !== Infinity) {\n nf = 1 / (near - far);\n out[10] = (far + near) * nf;\n out[14] = (2 * far * near) * nf;\n } else {\n out[10] = -1;\n out[14] = -2 * near;\n }\n return out;\n}\n\n/**\n * Generates a perspective projection matrix with the given field of view.\n * This is primarily useful for generating projection matrices to be used\n * with the still experiemental WebVR API.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\nexport function perspectiveFromFieldOfView(out, fov, near, far) {\n let upTan = Math.tan(fov.upDegrees * Math.PI/180.0);\n let downTan = Math.tan(fov.downDegrees * Math.PI/180.0);\n let leftTan = Math.tan(fov.leftDegrees * Math.PI/180.0);\n let rightTan = Math.tan(fov.rightDegrees * Math.PI/180.0);\n let xScale = 2.0 / (leftTan + rightTan);\n let yScale = 2.0 / (upTan + downTan);\n\n out[0] = xScale;\n out[1] = 0.0;\n out[2] = 0.0;\n out[3] = 0.0;\n out[4] = 0.0;\n out[5] = yScale;\n out[6] = 0.0;\n out[7] = 0.0;\n out[8] = -((leftTan - rightTan) * xScale * 0.5);\n out[9] = ((upTan - downTan) * yScale * 0.5);\n out[10] = far / (near - far);\n out[11] = -1.0;\n out[12] = 0.0;\n out[13] = 0.0;\n out[14] = (far * near) / (near - far);\n out[15] = 0.0;\n return out;\n}\n\n/**\n * Generates a orthogonal projection matrix with the given bounds\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} left Left bound of the frustum\n * @param {number} right Right bound of the frustum\n * @param {number} bottom Bottom bound of the frustum\n * @param {number} top Top bound of the frustum\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\nexport function ortho(out, left, right, bottom, top, near, far) {\n let lr = 1 / (left - right);\n let bt = 1 / (bottom - top);\n let nf = 1 / (near - far);\n out[0] = -2 * lr;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = -2 * bt;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 2 * nf;\n out[11] = 0;\n out[12] = (left + right) * lr;\n out[13] = (top + bottom) * bt;\n out[14] = (far + near) * nf;\n out[15] = 1;\n return out;\n}\n\n/**\n * Generates a look-at matrix with the given eye position, focal point, and up axis.\n * If you want a matrix that actually makes an object look at another object, you should use targetTo instead.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {vec3} eye Position of the viewer\n * @param {vec3} center Point the viewer is looking at\n * @param {vec3} up vec3 pointing up\n * @returns {mat4} out\n */\nexport function lookAt(out, eye, center, up) {\n let x0, x1, x2, y0, y1, y2, z0, z1, z2, len;\n let eyex = eye[0];\n let eyey = eye[1];\n let eyez = eye[2];\n let upx = up[0];\n let upy = up[1];\n let upz = up[2];\n let centerx = center[0];\n let centery = center[1];\n let centerz = center[2];\n\n if (Math.abs(eyex - centerx) < glMatrix.EPSILON &&\n Math.abs(eyey - centery) < glMatrix.EPSILON &&\n Math.abs(eyez - centerz) < glMatrix.EPSILON) {\n return identity(out);\n }\n\n z0 = eyex - centerx;\n z1 = eyey - centery;\n z2 = eyez - centerz;\n\n len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);\n z0 *= len;\n z1 *= len;\n z2 *= len;\n\n x0 = upy * z2 - upz * z1;\n x1 = upz * z0 - upx * z2;\n x2 = upx * z1 - upy * z0;\n len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);\n if (!len) {\n x0 = 0;\n x1 = 0;\n x2 = 0;\n } else {\n len = 1 / len;\n x0 *= len;\n x1 *= len;\n x2 *= len;\n }\n\n y0 = z1 * x2 - z2 * x1;\n y1 = z2 * x0 - z0 * x2;\n y2 = z0 * x1 - z1 * x0;\n\n len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);\n if (!len) {\n y0 = 0;\n y1 = 0;\n y2 = 0;\n } else {\n len = 1 / len;\n y0 *= len;\n y1 *= len;\n y2 *= len;\n }\n\n out[0] = x0;\n out[1] = y0;\n out[2] = z0;\n out[3] = 0;\n out[4] = x1;\n out[5] = y1;\n out[6] = z1;\n out[7] = 0;\n out[8] = x2;\n out[9] = y2;\n out[10] = z2;\n out[11] = 0;\n out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);\n out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);\n out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);\n out[15] = 1;\n\n return out;\n}\n\n/**\n * Generates a matrix that makes something look at something else.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {vec3} eye Position of the viewer\n * @param {vec3} center Point the viewer is looking at\n * @param {vec3} up vec3 pointing up\n * @returns {mat4} out\n */\nexport function targetTo(out, eye, target, up) {\n let eyex = eye[0],\n eyey = eye[1],\n eyez = eye[2],\n upx = up[0],\n upy = up[1],\n upz = up[2];\n\n let z0 = eyex - target[0],\n z1 = eyey - target[1],\n z2 = eyez - target[2];\n\n let len = z0*z0 + z1*z1 + z2*z2;\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n z0 *= len;\n z1 *= len;\n z2 *= len;\n }\n\n let x0 = upy * z2 - upz * z1,\n x1 = upz * z0 - upx * z2,\n x2 = upx * z1 - upy * z0;\n\n len = x0*x0 + x1*x1 + x2*x2;\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n x0 *= len;\n x1 *= len;\n x2 *= len;\n }\n\n out[0] = x0;\n out[1] = x1;\n out[2] = x2;\n out[3] = 0;\n out[4] = z1 * x2 - z2 * x1;\n out[5] = z2 * x0 - z0 * x2;\n out[6] = z0 * x1 - z1 * x0;\n out[7] = 0;\n out[8] = z0;\n out[9] = z1;\n out[10] = z2;\n out[11] = 0;\n out[12] = eyex;\n out[13] = eyey;\n out[14] = eyez;\n out[15] = 1;\n return out;\n};\n\n/**\n * Returns a string representation of a mat4\n *\n * @param {mat4} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\nexport function str(a) {\n return 'mat4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' +\n a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' +\n a[8] + ', ' + a[9] + ', ' + a[10] + ', ' + a[11] + ', ' +\n a[12] + ', ' + a[13] + ', ' + a[14] + ', ' + a[15] + ')';\n}\n\n/**\n * Returns Frobenius norm of a mat4\n *\n * @param {mat4} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\nexport function frob(a) {\n return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2) + Math.pow(a[9], 2) + Math.pow(a[10], 2) + Math.pow(a[11], 2) + Math.pow(a[12], 2) + Math.pow(a[13], 2) + Math.pow(a[14], 2) + Math.pow(a[15], 2) ))\n}\n\n/**\n * Adds two mat4's\n *\n * @param {mat4} out the receiving matrix\n * @param {mat4} a the first operand\n * @param {mat4} b the second operand\n * @returns {mat4} out\n */\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n out[4] = a[4] + b[4];\n out[5] = a[5] + b[5];\n out[6] = a[6] + b[6];\n out[7] = a[7] + b[7];\n out[8] = a[8] + b[8];\n out[9] = a[9] + b[9];\n out[10] = a[10] + b[10];\n out[11] = a[11] + b[11];\n out[12] = a[12] + b[12];\n out[13] = a[13] + b[13];\n out[14] = a[14] + b[14];\n out[15] = a[15] + b[15];\n return out;\n}\n\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat4} out the receiving matrix\n * @param {mat4} a the first operand\n * @param {mat4} b the second operand\n * @returns {mat4} out\n */\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n out[4] = a[4] - b[4];\n out[5] = a[5] - b[5];\n out[6] = a[6] - b[6];\n out[7] = a[7] - b[7];\n out[8] = a[8] - b[8];\n out[9] = a[9] - b[9];\n out[10] = a[10] - b[10];\n out[11] = a[11] - b[11];\n out[12] = a[12] - b[12];\n out[13] = a[13] - b[13];\n out[14] = a[14] - b[14];\n out[15] = a[15] - b[15];\n return out;\n}\n\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat4} out the receiving matrix\n * @param {mat4} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat4} out\n */\nexport function multiplyScalar(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n out[4] = a[4] * b;\n out[5] = a[5] * b;\n out[6] = a[6] * b;\n out[7] = a[7] * b;\n out[8] = a[8] * b;\n out[9] = a[9] * b;\n out[10] = a[10] * b;\n out[11] = a[11] * b;\n out[12] = a[12] * b;\n out[13] = a[13] * b;\n out[14] = a[14] * b;\n out[15] = a[15] * b;\n return out;\n}\n\n/**\n * Adds two mat4's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat4} out the receiving vector\n * @param {mat4} a the first operand\n * @param {mat4} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat4} out\n */\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n out[0] = a[0] + (b[0] * scale);\n out[1] = a[1] + (b[1] * scale);\n out[2] = a[2] + (b[2] * scale);\n out[3] = a[3] + (b[3] * scale);\n out[4] = a[4] + (b[4] * scale);\n out[5] = a[5] + (b[5] * scale);\n out[6] = a[6] + (b[6] * scale);\n out[7] = a[7] + (b[7] * scale);\n out[8] = a[8] + (b[8] * scale);\n out[9] = a[9] + (b[9] * scale);\n out[10] = a[10] + (b[10] * scale);\n out[11] = a[11] + (b[11] * scale);\n out[12] = a[12] + (b[12] * scale);\n out[13] = a[13] + (b[13] * scale);\n out[14] = a[14] + (b[14] * scale);\n out[15] = a[15] + (b[15] * scale);\n return out;\n}\n\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {mat4} a The first matrix.\n * @param {mat4} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] &&\n a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] &&\n a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] &&\n a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15];\n}\n\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {mat4} a The first matrix.\n * @param {mat4} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\nexport function equals(a, b) {\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\n let a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7];\n let a8 = a[8], a9 = a[9], a10 = a[10], a11 = a[11];\n let a12 = a[12], a13 = a[13], a14 = a[14], a15 = a[15];\n\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];\n let b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7];\n let b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11];\n let b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15];\n\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\n Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&\n Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&\n Math.abs(a3 - b3) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a3), Math.abs(b3)) &&\n Math.abs(a4 - b4) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a4), Math.abs(b4)) &&\n Math.abs(a5 - b5) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a5), Math.abs(b5)) &&\n Math.abs(a6 - b6) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a6), Math.abs(b6)) &&\n Math.abs(a7 - b7) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a7), Math.abs(b7)) &&\n Math.abs(a8 - b8) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a8), Math.abs(b8)) &&\n Math.abs(a9 - b9) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a9), Math.abs(b9)) &&\n Math.abs(a10 - b10) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a10), Math.abs(b10)) &&\n Math.abs(a11 - b11) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a11), Math.abs(b11)) &&\n Math.abs(a12 - b12) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a12), Math.abs(b12)) &&\n Math.abs(a13 - b13) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a13), Math.abs(b13)) &&\n Math.abs(a14 - b14) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a14), Math.abs(b14)) &&\n Math.abs(a15 - b15) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a15), Math.abs(b15)));\n}\n\n/**\n * Alias for {@link mat4.multiply}\n * @function\n */\nexport const mul = multiply;\n\n/**\n * Alias for {@link mat4.subtract}\n * @function\n */\nexport const sub = subtract;\n","import * as glMatrix from \"./common.js\"\nimport * as mat3 from \"./mat3.js\"\nimport * as vec3 from \"./vec3.js\"\nimport * as vec4 from \"./vec4.js\"\n\n/**\n * Quaternion\n * @module quat\n */\n\n/**\n * Creates a new identity quat\n *\n * @returns {quat} a new quaternion\n */\nexport function create() {\n let out = new glMatrix.ARRAY_TYPE(4);\n if(glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n }\n out[3] = 1;\n return out;\n}\n\n/**\n * Set a quat to the identity quaternion\n *\n * @param {quat} out the receiving quaternion\n * @returns {quat} out\n */\nexport function identity(out) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n return out;\n}\n\n/**\n * Sets a quat from the given angle and rotation axis,\n * then returns it.\n *\n * @param {quat} out the receiving quaternion\n * @param {vec3} axis the axis around which to rotate\n * @param {Number} rad the angle in radians\n * @returns {quat} out\n **/\nexport function setAxisAngle(out, axis, rad) {\n rad = rad * 0.5;\n let s = Math.sin(rad);\n out[0] = s * axis[0];\n out[1] = s * axis[1];\n out[2] = s * axis[2];\n out[3] = Math.cos(rad);\n return out;\n}\n\n/**\n * Gets the rotation axis and angle for a given\n * quaternion. If a quaternion is created with\n * setAxisAngle, this method will return the same\n * values as providied in the original parameter list\n * OR functionally equivalent values.\n * Example: The quaternion formed by axis [0, 0, 1] and\n * angle -90 is the same as the quaternion formed by\n * [0, 0, 1] and 270. This method favors the latter.\n * @param {vec3} out_axis Vector receiving the axis of rotation\n * @param {quat} q Quaternion to be decomposed\n * @return {Number} Angle, in radians, of the rotation\n */\nexport function getAxisAngle(out_axis, q) {\n let rad = Math.acos(q[3]) * 2.0;\n let s = Math.sin(rad / 2.0);\n if (s > glMatrix.EPSILON) {\n out_axis[0] = q[0] / s;\n out_axis[1] = q[1] / s;\n out_axis[2] = q[2] / s;\n } else {\n // If s is zero, return any axis (no rotation - axis does not matter)\n out_axis[0] = 1;\n out_axis[1] = 0;\n out_axis[2] = 0;\n }\n return rad;\n}\n\n/**\n * Multiplies two quat's\n *\n * @param {quat} out the receiving quaternion\n * @param {quat} a the first operand\n * @param {quat} b the second operand\n * @returns {quat} out\n */\nexport function multiply(out, a, b) {\n let ax = a[0], ay = a[1], az = a[2], aw = a[3];\n let bx = b[0], by = b[1], bz = b[2], bw = b[3];\n\n out[0] = ax * bw + aw * bx + ay * bz - az * by;\n out[1] = ay * bw + aw * by + az * bx - ax * bz;\n out[2] = az * bw + aw * bz + ax * by - ay * bx;\n out[3] = aw * bw - ax * bx - ay * by - az * bz;\n return out;\n}\n\n/**\n * Rotates a quaternion by the given angle about the X axis\n *\n * @param {quat} out quat receiving operation result\n * @param {quat} a quat to rotate\n * @param {number} rad angle (in radians) to rotate\n * @returns {quat} out\n */\nexport function rotateX(out, a, rad) {\n rad *= 0.5;\n\n let ax = a[0], ay = a[1], az = a[2], aw = a[3];\n let bx = Math.sin(rad), bw = Math.cos(rad);\n\n out[0] = ax * bw + aw * bx;\n out[1] = ay * bw + az * bx;\n out[2] = az * bw - ay * bx;\n out[3] = aw * bw - ax * bx;\n return out;\n}\n\n/**\n * Rotates a quaternion by the given angle about the Y axis\n *\n * @param {quat} out quat receiving operation result\n * @param {quat} a quat to rotate\n * @param {number} rad angle (in radians) to rotate\n * @returns {quat} out\n */\nexport function rotateY(out, a, rad) {\n rad *= 0.5;\n\n let ax = a[0], ay = a[1], az = a[2], aw = a[3];\n let by = Math.sin(rad), bw = Math.cos(rad);\n\n out[0] = ax * bw - az * by;\n out[1] = ay * bw + aw * by;\n out[2] = az * bw + ax * by;\n out[3] = aw * bw - ay * by;\n return out;\n}\n\n/**\n * Rotates a quaternion by the given angle about the Z axis\n *\n * @param {quat} out quat receiving operation result\n * @param {quat} a quat to rotate\n * @param {number} rad angle (in radians) to rotate\n * @returns {quat} out\n */\nexport function rotateZ(out, a, rad) {\n rad *= 0.5;\n\n let ax = a[0], ay = a[1], az = a[2], aw = a[3];\n let bz = Math.sin(rad), bw = Math.cos(rad);\n\n out[0] = ax * bw + ay * bz;\n out[1] = ay * bw - ax * bz;\n out[2] = az * bw + aw * bz;\n out[3] = aw * bw - az * bz;\n return out;\n}\n\n/**\n * Calculates the W component of a quat from the X, Y, and Z components.\n * Assumes that quaternion is 1 unit in length.\n * Any existing W component will be ignored.\n *\n * @param {quat} out the receiving quaternion\n * @param {quat} a quat to calculate W component of\n * @returns {quat} out\n */\nexport function calculateW(out, a) {\n let x = a[0], y = a[1], z = a[2];\n\n out[0] = x;\n out[1] = y;\n out[2] = z;\n out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z));\n return out;\n}\n\n/**\n * Performs a spherical linear interpolation between two quat\n *\n * @param {quat} out the receiving quaternion\n * @param {quat} a the first operand\n * @param {quat} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {quat} out\n */\nexport function slerp(out, a, b, t) {\n // benchmarks:\n // http://jsperf.com/quaternion-slerp-implementations\n let ax = a[0], ay = a[1], az = a[2], aw = a[3];\n let bx = b[0], by = b[1], bz = b[2], bw = b[3];\n\n let omega, cosom, sinom, scale0, scale1;\n\n // calc cosine\n cosom = ax * bx + ay * by + az * bz + aw * bw;\n // adjust signs (if necessary)\n if ( cosom < 0.0 ) {\n cosom = -cosom;\n bx = - bx;\n by = - by;\n bz = - bz;\n bw = - bw;\n }\n // calculate coefficients\n if ( (1.0 - cosom) > glMatrix.EPSILON ) {\n // standard case (slerp)\n omega = Math.acos(cosom);\n sinom = Math.sin(omega);\n scale0 = Math.sin((1.0 - t) * omega) / sinom;\n scale1 = Math.sin(t * omega) / sinom;\n } else {\n // \"from\" and \"to\" quaternions are very close\n // ... so we can do a linear interpolation\n scale0 = 1.0 - t;\n scale1 = t;\n }\n // calculate final values\n out[0] = scale0 * ax + scale1 * bx;\n out[1] = scale0 * ay + scale1 * by;\n out[2] = scale0 * az + scale1 * bz;\n out[3] = scale0 * aw + scale1 * bw;\n\n return out;\n}\n\n/**\n * Generates a random quaternion\n *\n * @param {quat} out the receiving quaternion\n * @returns {quat} out\n */\nexport function random(out) {\n // Implementation of http://planning.cs.uiuc.edu/node198.html\n // TODO: Calling random 3 times is probably not the fastest solution\n let u1 = glMatrix.RANDOM();\n let u2 = glMatrix.RANDOM();\n let u3 = glMatrix.RANDOM();\n\n let sqrt1MinusU1 = Math.sqrt(1 - u1);\n let sqrtU1 = Math.sqrt(u1);\n\n out[0] = sqrt1MinusU1 * Math.sin(2.0 * Math.PI * u2);\n out[1] = sqrt1MinusU1 * Math.cos(2.0 * Math.PI * u2);\n out[2] = sqrtU1 * Math.sin(2.0 * Math.PI * u3);\n out[3] = sqrtU1 * Math.cos(2.0 * Math.PI * u3);\n return out;\n}\n\n/**\n * Calculates the inverse of a quat\n *\n * @param {quat} out the receiving quaternion\n * @param {quat} a quat to calculate inverse of\n * @returns {quat} out\n */\nexport function invert(out, a) {\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\n let dot = a0*a0 + a1*a1 + a2*a2 + a3*a3;\n let invDot = dot ? 1.0/dot : 0;\n\n // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0\n\n out[0] = -a0*invDot;\n out[1] = -a1*invDot;\n out[2] = -a2*invDot;\n out[3] = a3*invDot;\n return out;\n}\n\n/**\n * Calculates the conjugate of a quat\n * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.\n *\n * @param {quat} out the receiving quaternion\n * @param {quat} a quat to calculate conjugate of\n * @returns {quat} out\n */\nexport function conjugate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n out[2] = -a[2];\n out[3] = a[3];\n return out;\n}\n\n/**\n * Creates a quaternion from the given 3x3 rotation matrix.\n *\n * NOTE: The resultant quaternion is not normalized, so you should be sure\n * to renormalize the quaternion yourself where necessary.\n *\n * @param {quat} out the receiving quaternion\n * @param {mat3} m rotation matrix\n * @returns {quat} out\n * @function\n */\nexport function fromMat3(out, m) {\n // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes\n // article \"Quaternion Calculus and Fast Animation\".\n let fTrace = m[0] + m[4] + m[8];\n let fRoot;\n\n if ( fTrace > 0.0 ) {\n // |w| > 1/2, may as well choose w > 1/2\n fRoot = Math.sqrt(fTrace + 1.0); // 2w\n out[3] = 0.5 * fRoot;\n fRoot = 0.5/fRoot; // 1/(4w)\n out[0] = (m[5]-m[7])*fRoot;\n out[1] = (m[6]-m[2])*fRoot;\n out[2] = (m[1]-m[3])*fRoot;\n } else {\n // |w| <= 1/2\n let i = 0;\n if ( m[4] > m[0] )\n i = 1;\n if ( m[8] > m[i*3+i] )\n i = 2;\n let j = (i+1)%3;\n let k = (i+2)%3;\n\n fRoot = Math.sqrt(m[i*3+i]-m[j*3+j]-m[k*3+k] + 1.0);\n out[i] = 0.5 * fRoot;\n fRoot = 0.5 / fRoot;\n out[3] = (m[j*3+k] - m[k*3+j]) * fRoot;\n out[j] = (m[j*3+i] + m[i*3+j]) * fRoot;\n out[k] = (m[k*3+i] + m[i*3+k]) * fRoot;\n }\n\n return out;\n}\n\n/**\n * Creates a quaternion from the given euler angle x, y, z.\n *\n * @param {quat} out the receiving quaternion\n * @param {x} Angle to rotate around X axis in degrees.\n * @param {y} Angle to rotate around Y axis in degrees.\n * @param {z} Angle to rotate around Z axis in degrees.\n * @returns {quat} out\n * @function\n */\nexport function fromEuler(out, x, y, z) {\n let halfToRad = 0.5 * Math.PI / 180.0;\n x *= halfToRad;\n y *= halfToRad;\n z *= halfToRad;\n\n let sx = Math.sin(x);\n let cx = Math.cos(x);\n let sy = Math.sin(y);\n let cy = Math.cos(y);\n let sz = Math.sin(z);\n let cz = Math.cos(z);\n\n out[0] = sx * cy * cz - cx * sy * sz;\n out[1] = cx * sy * cz + sx * cy * sz;\n out[2] = cx * cy * sz - sx * sy * cz;\n out[3] = cx * cy * cz + sx * sy * sz;\n\n return out;\n}\n\n/**\n * Returns a string representation of a quatenion\n *\n * @param {quat} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\nexport function str(a) {\n return 'quat(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';\n}\n\n/**\n * Creates a new quat initialized with values from an existing quaternion\n *\n * @param {quat} a quaternion to clone\n * @returns {quat} a new quaternion\n * @function\n */\nexport const clone = vec4.clone;\n\n/**\n * Creates a new quat initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {quat} a new quaternion\n * @function\n */\nexport const fromValues = vec4.fromValues;\n\n/**\n * Copy the values from one quat to another\n *\n * @param {quat} out the receiving quaternion\n * @param {quat} a the source quaternion\n * @returns {quat} out\n * @function\n */\nexport const copy = vec4.copy;\n\n/**\n * Set the components of a quat to the given values\n *\n * @param {quat} out the receiving quaternion\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {quat} out\n * @function\n */\nexport const set = vec4.set;\n\n/**\n * Adds two quat's\n *\n * @param {quat} out the receiving quaternion\n * @param {quat} a the first operand\n * @param {quat} b the second operand\n * @returns {quat} out\n * @function\n */\nexport const add = vec4.add;\n\n/**\n * Alias for {@link quat.multiply}\n * @function\n */\nexport const mul = multiply;\n\n/**\n * Scales a quat by a scalar number\n *\n * @param {quat} out the receiving vector\n * @param {quat} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {quat} out\n * @function\n */\nexport const scale = vec4.scale;\n\n/**\n * Calculates the dot product of two quat's\n *\n * @param {quat} a the first operand\n * @param {quat} b the second operand\n * @returns {Number} dot product of a and b\n * @function\n */\nexport const dot = vec4.dot;\n\n/**\n * Performs a linear interpolation between two quat's\n *\n * @param {quat} out the receiving quaternion\n * @param {quat} a the first operand\n * @param {quat} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {quat} out\n * @function\n */\nexport const lerp = vec4.lerp;\n\n/**\n * Calculates the length of a quat\n *\n * @param {quat} a vector to calculate length of\n * @returns {Number} length of a\n */\nexport const length = vec4.length;\n\n/**\n * Alias for {@link quat.length}\n * @function\n */\nexport const len = length;\n\n/**\n * Calculates the squared length of a quat\n *\n * @param {quat} a vector to calculate squared length of\n * @returns {Number} squared length of a\n * @function\n */\nexport const squaredLength = vec4.squaredLength;\n\n/**\n * Alias for {@link quat.squaredLength}\n * @function\n */\nexport const sqrLen = squaredLength;\n\n/**\n * Normalize a quat\n *\n * @param {quat} out the receiving quaternion\n * @param {quat} a quaternion to normalize\n * @returns {quat} out\n * @function\n */\nexport const normalize = vec4.normalize;\n\n/**\n * Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===)\n *\n * @param {quat} a The first quaternion.\n * @param {quat} b The second quaternion.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\nexport const exactEquals = vec4.exactEquals;\n\n/**\n * Returns whether or not the quaternions have approximately the same elements in the same position.\n *\n * @param {quat} a The first vector.\n * @param {quat} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\nexport const equals = vec4.equals;\n\n/**\n * Sets a quaternion to represent the shortest rotation from one\n * vector to another.\n *\n * Both vectors are assumed to be unit length.\n *\n * @param {quat} out the receiving quaternion.\n * @param {vec3} a the initial vector\n * @param {vec3} b the destination vector\n * @returns {quat} out\n */\nexport const rotationTo = (function() {\n let tmpvec3 = vec3.create();\n let xUnitVec3 = vec3.fromValues(1,0,0);\n let yUnitVec3 = vec3.fromValues(0,1,0);\n\n return function(out, a, b) {\n let dot = vec3.dot(a, b);\n if (dot < -0.999999) {\n vec3.cross(tmpvec3, xUnitVec3, a);\n if (vec3.len(tmpvec3) < 0.000001)\n vec3.cross(tmpvec3, yUnitVec3, a);\n vec3.normalize(tmpvec3, tmpvec3);\n setAxisAngle(out, tmpvec3, Math.PI);\n return out;\n } else if (dot > 0.999999) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n return out;\n } else {\n vec3.cross(tmpvec3, a, b);\n out[0] = tmpvec3[0];\n out[1] = tmpvec3[1];\n out[2] = tmpvec3[2];\n out[3] = 1 + dot;\n return normalize(out, out);\n }\n };\n})();\n\n/**\n * Performs a spherical linear interpolation with two control points\n *\n * @param {quat} out the receiving quaternion\n * @param {quat} a the first operand\n * @param {quat} b the second operand\n * @param {quat} c the third operand\n * @param {quat} d the fourth operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {quat} out\n */\nexport const sqlerp = (function () {\n let temp1 = create();\n let temp2 = create();\n\n return function (out, a, b, c, d, t) {\n slerp(temp1, a, d, t);\n slerp(temp2, b, c, t);\n slerp(out, temp1, temp2, 2 * t * (1 - t));\n\n return out;\n };\n}());\n\n/**\n * Sets the specified quaternion with values corresponding to the given\n * axes. Each axis is a vec3 and is expected to be unit length and\n * perpendicular to all other specified axes.\n *\n * @param {vec3} view the vector representing the viewing direction\n * @param {vec3} right the vector representing the local \"right\" direction\n * @param {vec3} up the vector representing the local \"up\" direction\n * @returns {quat} out\n */\nexport const setAxes = (function() {\n let matr = mat3.create();\n\n return function(out, view, right, up) {\n matr[0] = right[0];\n matr[3] = right[1];\n matr[6] = right[2];\n\n matr[1] = up[0];\n matr[4] = up[1];\n matr[7] = up[2];\n\n matr[2] = -view[0];\n matr[5] = -view[1];\n matr[8] = -view[2];\n\n return normalize(out, fromMat3(out, matr));\n };\n})();\n","import * as glMatrix from \"./common.js\";\nimport * as quat from \"./quat.js\";\nimport * as mat4 from \"./mat4.js\";\n\n/**\n * Dual Quaternion
\n * Format: [real, dual]
\n * Quaternion format: XYZW
\n * Make sure to have normalized dual quaternions, otherwise the functions may not work as intended.
\n * @module quat2\n */\n\n\n/**\n * Creates a new identity dual quat\n *\n * @returns {quat2} a new dual quaternion [real -> rotation, dual -> translation]\n */\nexport function create() {\n let dq = new glMatrix.ARRAY_TYPE(8);\n if(glMatrix.ARRAY_TYPE != Float32Array) {\n dq[0] = 0;\n dq[1] = 0;\n dq[2] = 0;\n dq[4] = 0;\n dq[5] = 0;\n dq[6] = 0;\n dq[7] = 0;\n }\n dq[3] = 1;\n return dq;\n}\n\n/**\n * Creates a new quat initialized with values from an existing quaternion\n *\n * @param {quat2} a dual quaternion to clone\n * @returns {quat2} new dual quaternion\n * @function\n */\nexport function clone(a) {\n let dq = new glMatrix.ARRAY_TYPE(8);\n dq[0] = a[0];\n dq[1] = a[1];\n dq[2] = a[2];\n dq[3] = a[3];\n dq[4] = a[4];\n dq[5] = a[5];\n dq[6] = a[6];\n dq[7] = a[7];\n return dq;\n}\n\n/**\n * Creates a new dual quat initialized with the given values\n *\n * @param {Number} x1 X component\n * @param {Number} y1 Y component\n * @param {Number} z1 Z component\n * @param {Number} w1 W component\n * @param {Number} x2 X component\n * @param {Number} y2 Y component\n * @param {Number} z2 Z component\n * @param {Number} w2 W component\n * @returns {quat2} new dual quaternion\n * @function\n */\nexport function fromValues(x1, y1, z1, w1, x2, y2, z2, w2) {\n let dq = new glMatrix.ARRAY_TYPE(8);\n dq[0] = x1;\n dq[1] = y1;\n dq[2] = z1;\n dq[3] = w1;\n dq[4] = x2;\n dq[5] = y2;\n dq[6] = z2;\n dq[7] = w2;\n return dq;\n}\n\n/**\n * Creates a new dual quat from the given values (quat and translation)\n *\n * @param {Number} x1 X component\n * @param {Number} y1 Y component\n * @param {Number} z1 Z component\n * @param {Number} w1 W component\n * @param {Number} x2 X component (translation)\n * @param {Number} y2 Y component (translation)\n * @param {Number} z2 Z component (translation)\n * @returns {quat2} new dual quaternion\n * @function\n */\nexport function fromRotationTranslationValues(x1, y1, z1, w1, x2, y2, z2) {\n let dq = new glMatrix.ARRAY_TYPE(8);\n dq[0] = x1;\n dq[1] = y1;\n dq[2] = z1;\n dq[3] = w1;\n let ax = x2 * 0.5,\n ay = y2 * 0.5,\n az = z2 * 0.5;\n dq[4] = ax * w1 + ay * z1 - az * y1;\n dq[5] = ay * w1 + az * x1 - ax * z1;\n dq[6] = az * w1 + ax * y1 - ay * x1;\n dq[7] = -ax * x1 - ay * y1 - az * z1;\n return dq;\n}\n\n/**\n * Creates a dual quat from a quaternion and a translation\n *\n * @param {quat2} dual quaternion receiving operation result\n * @param {quat} q quaternion\n * @param {vec3} t tranlation vector\n * @returns {quat2} dual quaternion receiving operation result\n * @function\n */\nexport function fromRotationTranslation(out, q, t) {\n let ax = t[0] * 0.5,\n ay = t[1] * 0.5,\n az = t[2] * 0.5,\n bx = q[0],\n by = q[1],\n bz = q[2],\n bw = q[3];\n out[0] = bx;\n out[1] = by;\n out[2] = bz;\n out[3] = bw;\n out[4] = ax * bw + ay * bz - az * by;\n out[5] = ay * bw + az * bx - ax * bz;\n out[6] = az * bw + ax * by - ay * bx;\n out[7] = -ax * bx - ay * by - az * bz;\n return out;\n}\n\n/**\n * Creates a dual quat from a translation\n *\n * @param {quat2} dual quaternion receiving operation result\n * @param {vec3} t translation vector\n * @returns {quat2} dual quaternion receiving operation result\n * @function\n */\nexport function fromTranslation(out, t) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n out[4] = t[0] * 0.5;\n out[5] = t[1] * 0.5;\n out[6] = t[2] * 0.5;\n out[7] = 0;\n return out;\n}\n\n/**\n * Creates a dual quat from a quaternion\n *\n * @param {quat2} dual quaternion receiving operation result\n * @param {quat} q the quaternion\n * @returns {quat2} dual quaternion receiving operation result\n * @function\n */\nexport function fromRotation(out, q) {\n out[0] = q[0];\n out[1] = q[1];\n out[2] = q[2];\n out[3] = q[3];\n out[4] = 0;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n return out;\n}\n\n/**\n * Creates a new dual quat from a matrix (4x4)\n *\n * @param {quat2} out the dual quaternion\n * @param {mat4} a the matrix\n * @returns {quat2} dual quat receiving operation result\n * @function\n */\nexport function fromMat4(out, a) {\n //TODO Optimize this\n let outer = quat.create();\n mat4.getRotation(outer, a);\n let t = new glMatrix.ARRAY_TYPE(3);\n mat4.getTranslation(t, a);\n fromRotationTranslation(out, outer, t);\n return out;\n}\n\n/**\n * Copy the values from one dual quat to another\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {quat2} a the source dual quaternion\n * @returns {quat2} out\n * @function\n */\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n return out;\n}\n\n/**\n * Set a dual quat to the identity dual quaternion\n *\n * @param {quat2} out the receiving quaternion\n * @returns {quat2} out\n */\nexport function identity(out) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n out[4] = 0;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n return out;\n}\n\n/**\n * Set the components of a dual quat to the given values\n *\n * @param {quat2} out the receiving quaternion\n * @param {Number} x1 X component\n * @param {Number} y1 Y component\n * @param {Number} z1 Z component\n * @param {Number} w1 W component\n * @param {Number} x2 X component\n * @param {Number} y2 Y component\n * @param {Number} z2 Z component\n * @param {Number} w2 W component\n * @returns {quat2} out\n * @function\n */\nexport function set(out, x1, y1, z1, w1, x2, y2, z2, w2) {\n out[0] = x1;\n out[1] = y1;\n out[2] = z1;\n out[3] = w1;\n\n out[4] = x2;\n out[5] = y2;\n out[6] = z2;\n out[7] = w2;\n return out;\n}\n\n/**\n * Gets the real part of a dual quat\n * @param {quat} out real part\n * @param {quat2} a Dual Quaternion\n * @return {quat} real part\n */\nexport const getReal = quat.copy;\n\n/**\n * Gets the dual part of a dual quat\n * @param {quat} out dual part\n * @param {quat2} a Dual Quaternion\n * @return {quat} dual part\n */\nexport function getDual(out, a) {\n out[0] = a[4];\n out[1] = a[5];\n out[2] = a[6];\n out[3] = a[7];\n return out;\n}\n\n/**\n * Set the real component of a dual quat to the given quaternion\n *\n * @param {quat2} out the receiving quaternion\n * @param {quat} q a quaternion representing the real part\n * @returns {quat2} out\n * @function\n */\nexport const setReal = quat.copy;\n\n/**\n * Set the dual component of a dual quat to the given quaternion\n *\n * @param {quat2} out the receiving quaternion\n * @param {quat} q a quaternion representing the dual part\n * @returns {quat2} out\n * @function\n */\nexport function setDual(out, q) {\n out[4] = q[0];\n out[5] = q[1];\n out[6] = q[2];\n out[7] = q[3];\n return out;\n}\n\n/**\n * Gets the translation of a normalized dual quat\n * @param {vec3} out translation\n * @param {quat2} a Dual Quaternion to be decomposed\n * @return {vec3} translation\n */\nexport function getTranslation(out, a) {\n let ax = a[4],\n ay = a[5],\n az = a[6],\n aw = a[7],\n bx = -a[0],\n by = -a[1],\n bz = -a[2],\n bw = a[3];\n out[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;\n out[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;\n out[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;\n return out;\n}\n\n/**\n * Translates a dual quat by the given vector\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {quat2} a the dual quaternion to translate\n * @param {vec3} v vector to translate by\n * @returns {quat2} out\n */\nexport function translate(out, a, v) {\n let ax1 = a[0],\n ay1 = a[1],\n az1 = a[2],\n aw1 = a[3],\n bx1 = v[0] * 0.5,\n by1 = v[1] * 0.5,\n bz1 = v[2] * 0.5,\n ax2 = a[4],\n ay2 = a[5],\n az2 = a[6],\n aw2 = a[7];\n out[0] = ax1;\n out[1] = ay1;\n out[2] = az1;\n out[3] = aw1;\n out[4] = aw1 * bx1 + ay1 * bz1 - az1 * by1 + ax2;\n out[5] = aw1 * by1 + az1 * bx1 - ax1 * bz1 + ay2;\n out[6] = aw1 * bz1 + ax1 * by1 - ay1 * bx1 + az2;\n out[7] = -ax1 * bx1 - ay1 * by1 - az1 * bz1 + aw2;\n return out;\n}\n\n/**\n * Rotates a dual quat around the X axis\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {quat2} a the dual quaternion to rotate\n * @param {number} rad how far should the rotation be\n * @returns {quat2} out\n */\nexport function rotateX(out, a, rad) {\n let bx = -a[0],\n by = -a[1],\n bz = -a[2],\n bw = a[3],\n ax = a[4],\n ay = a[5],\n az = a[6],\n aw = a[7],\n ax1 = ax * bw + aw * bx + ay * bz - az * by,\n ay1 = ay * bw + aw * by + az * bx - ax * bz,\n az1 = az * bw + aw * bz + ax * by - ay * bx,\n aw1 = aw * bw - ax * bx - ay * by - az * bz;\n quat.rotateX(out, a, rad);\n bx = out[0];\n by = out[1];\n bz = out[2];\n bw = out[3];\n out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;\n out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;\n out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;\n out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;\n return out;\n}\n\n/**\n * Rotates a dual quat around the Y axis\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {quat2} a the dual quaternion to rotate\n * @param {number} rad how far should the rotation be\n * @returns {quat2} out\n */\nexport function rotateY(out, a, rad) {\n let bx = -a[0],\n by = -a[1],\n bz = -a[2],\n bw = a[3],\n ax = a[4],\n ay = a[5],\n az = a[6],\n aw = a[7],\n ax1 = ax * bw + aw * bx + ay * bz - az * by,\n ay1 = ay * bw + aw * by + az * bx - ax * bz,\n az1 = az * bw + aw * bz + ax * by - ay * bx,\n aw1 = aw * bw - ax * bx - ay * by - az * bz;\n quat.rotateY(out, a, rad);\n bx = out[0];\n by = out[1];\n bz = out[2];\n bw = out[3];\n out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;\n out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;\n out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;\n out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;\n return out;\n}\n\n/**\n * Rotates a dual quat around the Z axis\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {quat2} a the dual quaternion to rotate\n * @param {number} rad how far should the rotation be\n * @returns {quat2} out\n */\nexport function rotateZ(out, a, rad) {\n let bx = -a[0],\n by = -a[1],\n bz = -a[2],\n bw = a[3],\n ax = a[4],\n ay = a[5],\n az = a[6],\n aw = a[7],\n ax1 = ax * bw + aw * bx + ay * bz - az * by,\n ay1 = ay * bw + aw * by + az * bx - ax * bz,\n az1 = az * bw + aw * bz + ax * by - ay * bx,\n aw1 = aw * bw - ax * bx - ay * by - az * bz;\n quat.rotateZ(out, a, rad);\n bx = out[0];\n by = out[1];\n bz = out[2];\n bw = out[3];\n out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;\n out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;\n out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;\n out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;\n return out;\n}\n\n/**\n * Rotates a dual quat by a given quaternion (a * q)\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {quat2} a the dual quaternion to rotate\n * @param {quat} q quaternion to rotate by\n * @returns {quat2} out\n */\nexport function rotateByQuatAppend(out, a, q) {\n let qx = q[0],\n qy = q[1],\n qz = q[2],\n qw = q[3],\n ax = a[0],\n ay = a[1],\n az = a[2],\n aw = a[3];\n\n out[0] = ax * qw + aw * qx + ay * qz - az * qy;\n out[1] = ay * qw + aw * qy + az * qx - ax * qz;\n out[2] = az * qw + aw * qz + ax * qy - ay * qx;\n out[3] = aw * qw - ax * qx - ay * qy - az * qz;\n ax = a[4];\n ay = a[5];\n az = a[6];\n aw = a[7];\n out[4] = ax * qw + aw * qx + ay * qz - az * qy;\n out[5] = ay * qw + aw * qy + az * qx - ax * qz;\n out[6] = az * qw + aw * qz + ax * qy - ay * qx;\n out[7] = aw * qw - ax * qx - ay * qy - az * qz;\n return out;\n}\n\n/**\n * Rotates a dual quat by a given quaternion (q * a)\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {quat} q quaternion to rotate by\n * @param {quat2} a the dual quaternion to rotate\n * @returns {quat2} out\n */\nexport function rotateByQuatPrepend(out, q, a) {\n let qx = q[0],\n qy = q[1],\n qz = q[2],\n qw = q[3],\n bx = a[0],\n by = a[1],\n bz = a[2],\n bw = a[3];\n\n out[0] = qx * bw + qw * bx + qy * bz - qz * by;\n out[1] = qy * bw + qw * by + qz * bx - qx * bz;\n out[2] = qz * bw + qw * bz + qx * by - qy * bx;\n out[3] = qw * bw - qx * bx - qy * by - qz * bz;\n bx = a[4];\n by = a[5];\n bz = a[6];\n bw = a[7];\n out[4] = qx * bw + qw * bx + qy * bz - qz * by;\n out[5] = qy * bw + qw * by + qz * bx - qx * bz;\n out[6] = qz * bw + qw * bz + qx * by - qy * bx;\n out[7] = qw * bw - qx * bx - qy * by - qz * bz;\n return out;\n}\n\n/**\n * Rotates a dual quat around a given axis. Does the normalisation automatically\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {quat2} a the dual quaternion to rotate\n * @param {vec3} axis the axis to rotate around\n * @param {Number} rad how far the rotation should be\n * @returns {quat2} out\n */\nexport function rotateAroundAxis(out, a, axis, rad) {\n //Special case for rad = 0\n if (Math.abs(rad) < glMatrix.EPSILON) {\n return copy(out, a);\n }\n let axisLength = Math.sqrt(axis[0] * axis[0] + axis[1] * axis[1] + axis[2] * axis[2]);\n\n rad = rad * 0.5;\n let s = Math.sin(rad);\n let bx = s * axis[0] / axisLength;\n let by = s * axis[1] / axisLength;\n let bz = s * axis[2] / axisLength;\n let bw = Math.cos(rad);\n\n let ax1 = a[0],\n ay1 = a[1],\n az1 = a[2],\n aw1 = a[3];\n out[0] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;\n out[1] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;\n out[2] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;\n out[3] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;\n\n let ax = a[4],\n ay = a[5],\n az = a[6],\n aw = a[7];\n out[4] = ax * bw + aw * bx + ay * bz - az * by;\n out[5] = ay * bw + aw * by + az * bx - ax * bz;\n out[6] = az * bw + aw * bz + ax * by - ay * bx;\n out[7] = aw * bw - ax * bx - ay * by - az * bz;\n\n return out;\n}\n\n/**\n * Adds two dual quat's\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {quat2} a the first operand\n * @param {quat2} b the second operand\n * @returns {quat2} out\n * @function\n */\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n out[4] = a[4] + b[4];\n out[5] = a[5] + b[5];\n out[6] = a[6] + b[6];\n out[7] = a[7] + b[7];\n return out;\n}\n\n/**\n * Multiplies two dual quat's\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {quat2} a the first operand\n * @param {quat2} b the second operand\n * @returns {quat2} out\n */\nexport function multiply(out, a, b) {\n let ax0 = a[0],\n ay0 = a[1],\n az0 = a[2],\n aw0 = a[3],\n bx1 = b[4],\n by1 = b[5],\n bz1 = b[6],\n bw1 = b[7],\n ax1 = a[4],\n ay1 = a[5],\n az1 = a[6],\n aw1 = a[7],\n bx0 = b[0],\n by0 = b[1],\n bz0 = b[2],\n bw0 = b[3];\n out[0] = ax0 * bw0 + aw0 * bx0 + ay0 * bz0 - az0 * by0;\n out[1] = ay0 * bw0 + aw0 * by0 + az0 * bx0 - ax0 * bz0;\n out[2] = az0 * bw0 + aw0 * bz0 + ax0 * by0 - ay0 * bx0;\n out[3] = aw0 * bw0 - ax0 * bx0 - ay0 * by0 - az0 * bz0;\n out[4] = ax0 * bw1 + aw0 * bx1 + ay0 * bz1 - az0 * by1 + ax1 * bw0 + aw1 * bx0 + ay1 * bz0 - az1 * by0;\n out[5] = ay0 * bw1 + aw0 * by1 + az0 * bx1 - ax0 * bz1 + ay1 * bw0 + aw1 * by0 + az1 * bx0 - ax1 * bz0;\n out[6] = az0 * bw1 + aw0 * bz1 + ax0 * by1 - ay0 * bx1 + az1 * bw0 + aw1 * bz0 + ax1 * by0 - ay1 * bx0;\n out[7] = aw0 * bw1 - ax0 * bx1 - ay0 * by1 - az0 * bz1 + aw1 * bw0 - ax1 * bx0 - ay1 * by0 - az1 * bz0;\n return out;\n}\n\n/**\n * Alias for {@link quat2.multiply}\n * @function\n */\nexport const mul = multiply;\n\n/**\n * Scales a dual quat by a scalar number\n *\n * @param {quat2} out the receiving dual quat\n * @param {quat2} a the dual quat to scale\n * @param {Number} b amount to scale the dual quat by\n * @returns {quat2} out\n * @function\n */\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n out[4] = a[4] * b;\n out[5] = a[5] * b;\n out[6] = a[6] * b;\n out[7] = a[7] * b;\n return out;\n}\n\n/**\n * Calculates the dot product of two dual quat's (The dot product of the real parts)\n *\n * @param {quat2} a the first operand\n * @param {quat2} b the second operand\n * @returns {Number} dot product of a and b\n * @function\n */\nexport const dot = quat.dot;\n\n/**\n * Performs a linear interpolation between two dual quats's\n * NOTE: The resulting dual quaternions won't always be normalized (The error is most noticeable when t = 0.5)\n *\n * @param {quat2} out the receiving dual quat\n * @param {quat2} a the first operand\n * @param {quat2} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {quat2} out\n */\nexport function lerp(out, a, b, t) {\n let mt = 1 - t;\n if (dot(a, b) < 0) t = -t;\n\n out[0] = a[0] * mt + b[0] * t;\n out[1] = a[1] * mt + b[1] * t;\n out[2] = a[2] * mt + b[2] * t;\n out[3] = a[3] * mt + b[3] * t;\n out[4] = a[4] * mt + b[4] * t;\n out[5] = a[5] * mt + b[5] * t;\n out[6] = a[6] * mt + b[6] * t;\n out[7] = a[7] * mt + b[7] * t;\n\n return out;\n}\n\n/**\n * Calculates the inverse of a dual quat. If they are normalized, conjugate is cheaper\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {quat2} a dual quat to calculate inverse of\n * @returns {quat2} out\n */\nexport function invert(out, a) {\n let sqlen = squaredLength(a);\n out[0] = -a[0] / sqlen;\n out[1] = -a[1] / sqlen;\n out[2] = -a[2] / sqlen;\n out[3] = a[3] / sqlen;\n out[4] = -a[4] / sqlen;\n out[5] = -a[5] / sqlen;\n out[6] = -a[6] / sqlen;\n out[7] = a[7] / sqlen;\n return out;\n}\n\n/**\n * Calculates the conjugate of a dual quat\n * If the dual quaternion is normalized, this function is faster than quat2.inverse and produces the same result.\n *\n * @param {quat2} out the receiving quaternion\n * @param {quat2} a quat to calculate conjugate of\n * @returns {quat2} out\n */\nexport function conjugate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n out[2] = -a[2];\n out[3] = a[3];\n out[4] = -a[4];\n out[5] = -a[5];\n out[6] = -a[6];\n out[7] = a[7];\n return out;\n}\n\n/**\n * Calculates the length of a dual quat\n *\n * @param {quat2} a dual quat to calculate length of\n * @returns {Number} length of a\n * @function\n */\nexport const length = quat.length;\n\n/**\n * Alias for {@link quat2.length}\n * @function\n */\nexport const len = length;\n\n/**\n * Calculates the squared length of a dual quat\n *\n * @param {quat2} a dual quat to calculate squared length of\n * @returns {Number} squared length of a\n * @function\n */\nexport const squaredLength = quat.squaredLength;\n\n/**\n * Alias for {@link quat2.squaredLength}\n * @function\n */\nexport const sqrLen = squaredLength;\n\n/**\n * Normalize a dual quat\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {quat2} a dual quaternion to normalize\n * @returns {quat2} out\n * @function\n */\nexport function normalize(out, a) {\n let magnitude = squaredLength(a);\n if (magnitude > 0) {\n magnitude = Math.sqrt(magnitude);\n\n let a0 = a[0] / magnitude;\n let a1 = a[1] / magnitude;\n let a2 = a[2] / magnitude;\n let a3 = a[3] / magnitude;\n\n let b0 = a[4];\n let b1 = a[5];\n let b2 = a[6];\n let b3 = a[7];\n\n let a_dot_b = (a0 * b0) + (a1 * b1) + (a2 * b2) + (a3 * b3);\n\n out[0] = a0;\n out[1] = a1;\n out[2] = a2;\n out[3] = a3;\n\n out[4] = (b0 - (a0 * a_dot_b)) / magnitude;\n out[5] = (b1 - (a1 * a_dot_b)) / magnitude;\n out[6] = (b2 - (a2 * a_dot_b)) / magnitude;\n out[7] = (b3 - (a3 * a_dot_b)) / magnitude;\n }\n return out;\n}\n\n/**\n * Returns a string representation of a dual quatenion\n *\n * @param {quat2} a dual quaternion to represent as a string\n * @returns {String} string representation of the dual quat\n */\nexport function str(a) {\n return 'quat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' +\n a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ')';\n}\n\n/**\n * Returns whether or not the dual quaternions have exactly the same elements in the same position (when compared with ===)\n *\n * @param {quat2} a the first dual quaternion.\n * @param {quat2} b the second dual quaternion.\n * @returns {Boolean} true if the dual quaternions are equal, false otherwise.\n */\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] &&\n a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7];\n}\n\n/**\n * Returns whether or not the dual quaternions have approximately the same elements in the same position.\n *\n * @param {quat2} a the first dual quat.\n * @param {quat2} b the second dual quat.\n * @returns {Boolean} true if the dual quats are equal, false otherwise.\n */\nexport function equals(a, b) {\n let a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3],\n a4 = a[4],\n a5 = a[5],\n a6 = a[6],\n a7 = a[7];\n let b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7];\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\n Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&\n Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&\n Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) &&\n Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) &&\n Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) &&\n Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) &&\n Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)));\n}\n","import * as glMatrix from \"./common.js\";\n\n/**\n * 2 Dimensional Vector\n * @module vec2\n */\n\n/**\n * Creates a new, empty vec2\n *\n * @returns {vec2} a new 2D vector\n */\nexport function create() {\n let out = new glMatrix.ARRAY_TYPE(2);\n if(glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n }\n return out;\n}\n\n/**\n * Creates a new vec2 initialized with values from an existing vector\n *\n * @param {vec2} a vector to clone\n * @returns {vec2} a new 2D vector\n */\nexport function clone(a) {\n let out = new glMatrix.ARRAY_TYPE(2);\n out[0] = a[0];\n out[1] = a[1];\n return out;\n}\n\n/**\n * Creates a new vec2 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @returns {vec2} a new 2D vector\n */\nexport function fromValues(x, y) {\n let out = new glMatrix.ARRAY_TYPE(2);\n out[0] = x;\n out[1] = y;\n return out;\n}\n\n/**\n * Copy the values from one vec2 to another\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a the source vector\n * @returns {vec2} out\n */\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n return out;\n}\n\n/**\n * Set the components of a vec2 to the given values\n *\n * @param {vec2} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @returns {vec2} out\n */\nexport function set(out, x, y) {\n out[0] = x;\n out[1] = y;\n return out;\n}\n\n/**\n * Adds two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a the first operand\n * @param {vec2} b the second operand\n * @returns {vec2} out\n */\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n return out;\n}\n\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a the first operand\n * @param {vec2} b the second operand\n * @returns {vec2} out\n */\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n return out;\n}\n\n/**\n * Multiplies two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a the first operand\n * @param {vec2} b the second operand\n * @returns {vec2} out\n */\nexport function multiply(out, a, b) {\n out[0] = a[0] * b[0];\n out[1] = a[1] * b[1];\n return out;\n}\n\n/**\n * Divides two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a the first operand\n * @param {vec2} b the second operand\n * @returns {vec2} out\n */\nexport function divide(out, a, b) {\n out[0] = a[0] / b[0];\n out[1] = a[1] / b[1];\n return out;\n}\n\n/**\n * Math.ceil the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a vector to ceil\n * @returns {vec2} out\n */\nexport function ceil(out, a) {\n out[0] = Math.ceil(a[0]);\n out[1] = Math.ceil(a[1]);\n return out;\n}\n\n/**\n * Math.floor the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a vector to floor\n * @returns {vec2} out\n */\nexport function floor(out, a) {\n out[0] = Math.floor(a[0]);\n out[1] = Math.floor(a[1]);\n return out;\n}\n\n/**\n * Returns the minimum of two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a the first operand\n * @param {vec2} b the second operand\n * @returns {vec2} out\n */\nexport function min(out, a, b) {\n out[0] = Math.min(a[0], b[0]);\n out[1] = Math.min(a[1], b[1]);\n return out;\n}\n\n/**\n * Returns the maximum of two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a the first operand\n * @param {vec2} b the second operand\n * @returns {vec2} out\n */\nexport function max(out, a, b) {\n out[0] = Math.max(a[0], b[0]);\n out[1] = Math.max(a[1], b[1]);\n return out;\n}\n\n/**\n * Math.round the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a vector to round\n * @returns {vec2} out\n */\nexport function round (out, a) {\n out[0] = Math.round(a[0]);\n out[1] = Math.round(a[1]);\n return out;\n}\n\n/**\n * Scales a vec2 by a scalar number\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec2} out\n */\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n return out;\n}\n\n/**\n * Adds two vec2's after scaling the second operand by a scalar value\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a the first operand\n * @param {vec2} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec2} out\n */\nexport function scaleAndAdd(out, a, b, scale) {\n out[0] = a[0] + (b[0] * scale);\n out[1] = a[1] + (b[1] * scale);\n return out;\n}\n\n/**\n * Calculates the euclidian distance between two vec2's\n *\n * @param {vec2} a the first operand\n * @param {vec2} b the second operand\n * @returns {Number} distance between a and b\n */\nexport function distance(a, b) {\n var x = b[0] - a[0],\n y = b[1] - a[1];\n return Math.sqrt(x*x + y*y);\n}\n\n/**\n * Calculates the squared euclidian distance between two vec2's\n *\n * @param {vec2} a the first operand\n * @param {vec2} b the second operand\n * @returns {Number} squared distance between a and b\n */\nexport function squaredDistance(a, b) {\n var x = b[0] - a[0],\n y = b[1] - a[1];\n return x*x + y*y;\n}\n\n/**\n * Calculates the length of a vec2\n *\n * @param {vec2} a vector to calculate length of\n * @returns {Number} length of a\n */\nexport function length(a) {\n var x = a[0],\n y = a[1];\n return Math.sqrt(x*x + y*y);\n}\n\n/**\n * Calculates the squared length of a vec2\n *\n * @param {vec2} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\nexport function squaredLength (a) {\n var x = a[0],\n y = a[1];\n return x*x + y*y;\n}\n\n/**\n * Negates the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a vector to negate\n * @returns {vec2} out\n */\nexport function negate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n return out;\n}\n\n/**\n * Returns the inverse of the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a vector to invert\n * @returns {vec2} out\n */\nexport function inverse(out, a) {\n out[0] = 1.0 / a[0];\n out[1] = 1.0 / a[1];\n return out;\n}\n\n/**\n * Normalize a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a vector to normalize\n * @returns {vec2} out\n */\nexport function normalize(out, a) {\n var x = a[0],\n y = a[1];\n var len = x*x + y*y;\n if (len > 0) {\n //TODO: evaluate use of glm_invsqrt here?\n len = 1 / Math.sqrt(len);\n out[0] = a[0] * len;\n out[1] = a[1] * len;\n }\n return out;\n}\n\n/**\n * Calculates the dot product of two vec2's\n *\n * @param {vec2} a the first operand\n * @param {vec2} b the second operand\n * @returns {Number} dot product of a and b\n */\nexport function dot(a, b) {\n return a[0] * b[0] + a[1] * b[1];\n}\n\n/**\n * Computes the cross product of two vec2's\n * Note that the cross product must by definition produce a 3D vector\n *\n * @param {vec3} out the receiving vector\n * @param {vec2} a the first operand\n * @param {vec2} b the second operand\n * @returns {vec3} out\n */\nexport function cross(out, a, b) {\n var z = a[0] * b[1] - a[1] * b[0];\n out[0] = out[1] = 0;\n out[2] = z;\n return out;\n}\n\n/**\n * Performs a linear interpolation between two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a the first operand\n * @param {vec2} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec2} out\n */\nexport function lerp(out, a, b, t) {\n var ax = a[0],\n ay = a[1];\n out[0] = ax + t * (b[0] - ax);\n out[1] = ay + t * (b[1] - ay);\n return out;\n}\n\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec2} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\n * @returns {vec2} out\n */\nexport function random(out, scale) {\n scale = scale || 1.0;\n var r = glMatrix.RANDOM() * 2.0 * Math.PI;\n out[0] = Math.cos(r) * scale;\n out[1] = Math.sin(r) * scale;\n return out;\n}\n\n/**\n * Transforms the vec2 with a mat2\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a the vector to transform\n * @param {mat2} m matrix to transform with\n * @returns {vec2} out\n */\nexport function transformMat2(out, a, m) {\n var x = a[0],\n y = a[1];\n out[0] = m[0] * x + m[2] * y;\n out[1] = m[1] * x + m[3] * y;\n return out;\n}\n\n/**\n * Transforms the vec2 with a mat2d\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a the vector to transform\n * @param {mat2d} m matrix to transform with\n * @returns {vec2} out\n */\nexport function transformMat2d(out, a, m) {\n var x = a[0],\n y = a[1];\n out[0] = m[0] * x + m[2] * y + m[4];\n out[1] = m[1] * x + m[3] * y + m[5];\n return out;\n}\n\n/**\n * Transforms the vec2 with a mat3\n * 3rd vector component is implicitly '1'\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a the vector to transform\n * @param {mat3} m matrix to transform with\n * @returns {vec2} out\n */\nexport function transformMat3(out, a, m) {\n var x = a[0],\n y = a[1];\n out[0] = m[0] * x + m[3] * y + m[6];\n out[1] = m[1] * x + m[4] * y + m[7];\n return out;\n}\n\n/**\n * Transforms the vec2 with a mat4\n * 3rd vector component is implicitly '0'\n * 4th vector component is implicitly '1'\n *\n * @param {vec2} out the receiving vector\n * @param {vec2} a the vector to transform\n * @param {mat4} m matrix to transform with\n * @returns {vec2} out\n */\nexport function transformMat4(out, a, m) {\n let x = a[0];\n let y = a[1];\n out[0] = m[0] * x + m[4] * y + m[12];\n out[1] = m[1] * x + m[5] * y + m[13];\n return out;\n}\n\n/**\n * Rotate a 2D vector\n * @param {vec2} out The receiving vec2\n * @param {vec2} a The vec2 point to rotate\n * @param {vec2} b The origin of the rotation\n * @param {Number} c The angle of rotation\n * @returns {vec2} out\n */\nexport function rotate(out, a, b, c) {\n //Translate point to the origin\n let p0 = a[0] - b[0],\n p1 = a[1] - b[1],\n sinC = Math.sin(c),\n cosC = Math.cos(c);\n \n //perform rotation and translate to correct position\n out[0] = p0*cosC - p1*sinC + b[0];\n out[1] = p0*sinC + p1*cosC + b[1];\n\n return out;\n}\n\n/**\n * Get the angle between two 2D vectors\n * @param {vec2} a The first operand\n * @param {vec2} b The second operand\n * @returns {Number} The angle in radians\n */\nexport function angle(a, b) {\n let x1 = a[0],\n y1 = a[1],\n x2 = b[0],\n y2 = b[1];\n \n let len1 = x1*x1 + y1*y1;\n if (len1 > 0) {\n //TODO: evaluate use of glm_invsqrt here?\n len1 = 1 / Math.sqrt(len1);\n }\n \n let len2 = x2*x2 + y2*y2;\n if (len2 > 0) {\n //TODO: evaluate use of glm_invsqrt here?\n len2 = 1 / Math.sqrt(len2);\n }\n \n let cosine = (x1 * x2 + y1 * y2) * len1 * len2;\n \n \n if(cosine > 1.0) {\n return 0;\n }\n else if(cosine < -1.0) {\n return Math.PI;\n } else {\n return Math.acos(cosine);\n }\n}\n\n/**\n * Returns a string representation of a vector\n *\n * @param {vec2} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\nexport function str(a) {\n return 'vec2(' + a[0] + ', ' + a[1] + ')';\n}\n\n/**\n * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)\n *\n * @param {vec2} a The first vector.\n * @param {vec2} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1];\n}\n\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {vec2} a The first vector.\n * @param {vec2} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\nexport function equals(a, b) {\n let a0 = a[0], a1 = a[1];\n let b0 = b[0], b1 = b[1];\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\n Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)));\n}\n\n/**\n * Alias for {@link vec2.length}\n * @function\n */\nexport const len = length;\n\n/**\n * Alias for {@link vec2.subtract}\n * @function\n */\nexport const sub = subtract;\n\n/**\n * Alias for {@link vec2.multiply}\n * @function\n */\nexport const mul = multiply;\n\n/**\n * Alias for {@link vec2.divide}\n * @function\n */\nexport const div = divide;\n\n/**\n * Alias for {@link vec2.distance}\n * @function\n */\nexport const dist = distance;\n\n/**\n * Alias for {@link vec2.squaredDistance}\n * @function\n */\nexport const sqrDist = squaredDistance;\n\n/**\n * Alias for {@link vec2.squaredLength}\n * @function\n */\nexport const sqrLen = squaredLength;\n\n/**\n * Perform some operation over an array of vec2s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\nexport const forEach = (function() {\n let vec = create();\n\n return function(a, stride, offset, count, fn, arg) {\n let i, l;\n if(!stride) {\n stride = 2;\n }\n\n if(!offset) {\n offset = 0;\n }\n\n if(count) {\n l = Math.min((count * stride) + offset, a.length);\n } else {\n l = a.length;\n }\n\n for(i = offset; i < l; i += stride) {\n vec[0] = a[i]; vec[1] = a[i+1];\n fn(vec, vec, arg);\n a[i] = vec[0]; a[i+1] = vec[1];\n }\n\n return a;\n };\n})();\n","import * as glMatrix from \"./common.js\";\n\n/**\n * 3 Dimensional Vector\n * @module vec3\n */\n\n/**\n * Creates a new, empty vec3\n *\n * @returns {vec3} a new 3D vector\n */\nexport function create() {\n let out = new glMatrix.ARRAY_TYPE(3);\n if(glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n }\n return out;\n}\n\n/**\n * Creates a new vec3 initialized with values from an existing vector\n *\n * @param {vec3} a vector to clone\n * @returns {vec3} a new 3D vector\n */\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(3);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n return out;\n}\n\n/**\n * Calculates the length of a vec3\n *\n * @param {vec3} a vector to calculate length of\n * @returns {Number} length of a\n */\nexport function length(a) {\n let x = a[0];\n let y = a[1];\n let z = a[2];\n return Math.sqrt(x*x + y*y + z*z);\n}\n\n/**\n * Creates a new vec3 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @returns {vec3} a new 3D vector\n */\nexport function fromValues(x, y, z) {\n let out = new glMatrix.ARRAY_TYPE(3);\n out[0] = x;\n out[1] = y;\n out[2] = z;\n return out;\n}\n\n/**\n * Copy the values from one vec3 to another\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the source vector\n * @returns {vec3} out\n */\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n return out;\n}\n\n/**\n * Set the components of a vec3 to the given values\n *\n * @param {vec3} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @returns {vec3} out\n */\nexport function set(out, x, y, z) {\n out[0] = x;\n out[1] = y;\n out[2] = z;\n return out;\n}\n\n/**\n * Adds two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the first operand\n * @param {vec3} b the second operand\n * @returns {vec3} out\n */\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n return out;\n}\n\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the first operand\n * @param {vec3} b the second operand\n * @returns {vec3} out\n */\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n return out;\n}\n\n/**\n * Multiplies two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the first operand\n * @param {vec3} b the second operand\n * @returns {vec3} out\n */\nexport function multiply(out, a, b) {\n out[0] = a[0] * b[0];\n out[1] = a[1] * b[1];\n out[2] = a[2] * b[2];\n return out;\n}\n\n/**\n * Divides two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the first operand\n * @param {vec3} b the second operand\n * @returns {vec3} out\n */\nexport function divide(out, a, b) {\n out[0] = a[0] / b[0];\n out[1] = a[1] / b[1];\n out[2] = a[2] / b[2];\n return out;\n}\n\n/**\n * Math.ceil the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a vector to ceil\n * @returns {vec3} out\n */\nexport function ceil(out, a) {\n out[0] = Math.ceil(a[0]);\n out[1] = Math.ceil(a[1]);\n out[2] = Math.ceil(a[2]);\n return out;\n}\n\n/**\n * Math.floor the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a vector to floor\n * @returns {vec3} out\n */\nexport function floor(out, a) {\n out[0] = Math.floor(a[0]);\n out[1] = Math.floor(a[1]);\n out[2] = Math.floor(a[2]);\n return out;\n}\n\n/**\n * Returns the minimum of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the first operand\n * @param {vec3} b the second operand\n * @returns {vec3} out\n */\nexport function min(out, a, b) {\n out[0] = Math.min(a[0], b[0]);\n out[1] = Math.min(a[1], b[1]);\n out[2] = Math.min(a[2], b[2]);\n return out;\n}\n\n/**\n * Returns the maximum of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the first operand\n * @param {vec3} b the second operand\n * @returns {vec3} out\n */\nexport function max(out, a, b) {\n out[0] = Math.max(a[0], b[0]);\n out[1] = Math.max(a[1], b[1]);\n out[2] = Math.max(a[2], b[2]);\n return out;\n}\n\n/**\n * Math.round the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a vector to round\n * @returns {vec3} out\n */\nexport function round(out, a) {\n out[0] = Math.round(a[0]);\n out[1] = Math.round(a[1]);\n out[2] = Math.round(a[2]);\n return out;\n}\n\n/**\n * Scales a vec3 by a scalar number\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec3} out\n */\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n return out;\n}\n\n/**\n * Adds two vec3's after scaling the second operand by a scalar value\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the first operand\n * @param {vec3} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec3} out\n */\nexport function scaleAndAdd(out, a, b, scale) {\n out[0] = a[0] + (b[0] * scale);\n out[1] = a[1] + (b[1] * scale);\n out[2] = a[2] + (b[2] * scale);\n return out;\n}\n\n/**\n * Calculates the euclidian distance between two vec3's\n *\n * @param {vec3} a the first operand\n * @param {vec3} b the second operand\n * @returns {Number} distance between a and b\n */\nexport function distance(a, b) {\n let x = b[0] - a[0];\n let y = b[1] - a[1];\n let z = b[2] - a[2];\n return Math.sqrt(x*x + y*y + z*z);\n}\n\n/**\n * Calculates the squared euclidian distance between two vec3's\n *\n * @param {vec3} a the first operand\n * @param {vec3} b the second operand\n * @returns {Number} squared distance between a and b\n */\nexport function squaredDistance(a, b) {\n let x = b[0] - a[0];\n let y = b[1] - a[1];\n let z = b[2] - a[2];\n return x*x + y*y + z*z;\n}\n\n/**\n * Calculates the squared length of a vec3\n *\n * @param {vec3} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\nexport function squaredLength(a) {\n let x = a[0];\n let y = a[1];\n let z = a[2];\n return x*x + y*y + z*z;\n}\n\n/**\n * Negates the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a vector to negate\n * @returns {vec3} out\n */\nexport function negate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n out[2] = -a[2];\n return out;\n}\n\n/**\n * Returns the inverse of the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a vector to invert\n * @returns {vec3} out\n */\nexport function inverse(out, a) {\n out[0] = 1.0 / a[0];\n out[1] = 1.0 / a[1];\n out[2] = 1.0 / a[2];\n return out;\n}\n\n/**\n * Normalize a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a vector to normalize\n * @returns {vec3} out\n */\nexport function normalize(out, a) {\n let x = a[0];\n let y = a[1];\n let z = a[2];\n let len = x*x + y*y + z*z;\n if (len > 0) {\n //TODO: evaluate use of glm_invsqrt here?\n len = 1 / Math.sqrt(len);\n out[0] = a[0] * len;\n out[1] = a[1] * len;\n out[2] = a[2] * len;\n }\n return out;\n}\n\n/**\n * Calculates the dot product of two vec3's\n *\n * @param {vec3} a the first operand\n * @param {vec3} b the second operand\n * @returns {Number} dot product of a and b\n */\nexport function dot(a, b) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n}\n\n/**\n * Computes the cross product of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the first operand\n * @param {vec3} b the second operand\n * @returns {vec3} out\n */\nexport function cross(out, a, b) {\n let ax = a[0], ay = a[1], az = a[2];\n let bx = b[0], by = b[1], bz = b[2];\n\n out[0] = ay * bz - az * by;\n out[1] = az * bx - ax * bz;\n out[2] = ax * by - ay * bx;\n return out;\n}\n\n/**\n * Performs a linear interpolation between two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the first operand\n * @param {vec3} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\nexport function lerp(out, a, b, t) {\n let ax = a[0];\n let ay = a[1];\n let az = a[2];\n out[0] = ax + t * (b[0] - ax);\n out[1] = ay + t * (b[1] - ay);\n out[2] = az + t * (b[2] - az);\n return out;\n}\n\n/**\n * Performs a hermite interpolation with two control points\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the first operand\n * @param {vec3} b the second operand\n * @param {vec3} c the third operand\n * @param {vec3} d the fourth operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\nexport function hermite(out, a, b, c, d, t) {\n let factorTimes2 = t * t;\n let factor1 = factorTimes2 * (2 * t - 3) + 1;\n let factor2 = factorTimes2 * (t - 2) + t;\n let factor3 = factorTimes2 * (t - 1);\n let factor4 = factorTimes2 * (3 - 2 * t);\n\n out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;\n out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;\n out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;\n\n return out;\n}\n\n/**\n * Performs a bezier interpolation with two control points\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the first operand\n * @param {vec3} b the second operand\n * @param {vec3} c the third operand\n * @param {vec3} d the fourth operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\nexport function bezier(out, a, b, c, d, t) {\n let inverseFactor = 1 - t;\n let inverseFactorTimesTwo = inverseFactor * inverseFactor;\n let factorTimes2 = t * t;\n let factor1 = inverseFactorTimesTwo * inverseFactor;\n let factor2 = 3 * t * inverseFactorTimesTwo;\n let factor3 = 3 * factorTimes2 * inverseFactor;\n let factor4 = factorTimes2 * t;\n\n out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;\n out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;\n out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;\n\n return out;\n}\n\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec3} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\n * @returns {vec3} out\n */\nexport function random(out, scale) {\n scale = scale || 1.0;\n\n let r = glMatrix.RANDOM() * 2.0 * Math.PI;\n let z = (glMatrix.RANDOM() * 2.0) - 1.0;\n let zScale = Math.sqrt(1.0-z*z) * scale;\n\n out[0] = Math.cos(r) * zScale;\n out[1] = Math.sin(r) * zScale;\n out[2] = z * scale;\n return out;\n}\n\n/**\n * Transforms the vec3 with a mat4.\n * 4th vector component is implicitly '1'\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the vector to transform\n * @param {mat4} m matrix to transform with\n * @returns {vec3} out\n */\nexport function transformMat4(out, a, m) {\n let x = a[0], y = a[1], z = a[2];\n let w = m[3] * x + m[7] * y + m[11] * z + m[15];\n w = w || 1.0;\n out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;\n out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;\n out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;\n return out;\n}\n\n/**\n * Transforms the vec3 with a mat3.\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the vector to transform\n * @param {mat3} m the 3x3 matrix to transform with\n * @returns {vec3} out\n */\nexport function transformMat3(out, a, m) {\n let x = a[0], y = a[1], z = a[2];\n out[0] = x * m[0] + y * m[3] + z * m[6];\n out[1] = x * m[1] + y * m[4] + z * m[7];\n out[2] = x * m[2] + y * m[5] + z * m[8];\n return out;\n}\n\n/**\n * Transforms the vec3 with a quat\n * Can also be used for dual quaternions. (Multiply it with the real part)\n *\n * @param {vec3} out the receiving vector\n * @param {vec3} a the vector to transform\n * @param {quat} q quaternion to transform with\n * @returns {vec3} out\n */\nexport function transformQuat(out, a, q) {\n // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed\n let qx = q[0], qy = q[1], qz = q[2], qw = q[3];\n let x = a[0], y = a[1], z = a[2];\n // var qvec = [qx, qy, qz];\n // var uv = vec3.cross([], qvec, a);\n let uvx = qy * z - qz * y,\n uvy = qz * x - qx * z,\n uvz = qx * y - qy * x;\n // var uuv = vec3.cross([], qvec, uv);\n let uuvx = qy * uvz - qz * uvy,\n uuvy = qz * uvx - qx * uvz,\n uuvz = qx * uvy - qy * uvx;\n // vec3.scale(uv, uv, 2 * w);\n let w2 = qw * 2;\n uvx *= w2;\n uvy *= w2;\n uvz *= w2;\n // vec3.scale(uuv, uuv, 2);\n uuvx *= 2;\n uuvy *= 2;\n uuvz *= 2;\n // return vec3.add(out, a, vec3.add(out, uv, uuv));\n out[0] = x + uvx + uuvx;\n out[1] = y + uvy + uuvy;\n out[2] = z + uvz + uuvz;\n return out;\n}\n\n/**\n * Rotate a 3D vector around the x-axis\n * @param {vec3} out The receiving vec3\n * @param {vec3} a The vec3 point to rotate\n * @param {vec3} b The origin of the rotation\n * @param {Number} c The angle of rotation\n * @returns {vec3} out\n */\nexport function rotateX(out, a, b, c){\n let p = [], r=[];\n //Translate point to the origin\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2];\n\n //perform rotation\n r[0] = p[0];\n r[1] = p[1]*Math.cos(c) - p[2]*Math.sin(c);\n r[2] = p[1]*Math.sin(c) + p[2]*Math.cos(c);\n\n //translate to correct position\n out[0] = r[0] + b[0];\n out[1] = r[1] + b[1];\n out[2] = r[2] + b[2];\n\n return out;\n}\n\n/**\n * Rotate a 3D vector around the y-axis\n * @param {vec3} out The receiving vec3\n * @param {vec3} a The vec3 point to rotate\n * @param {vec3} b The origin of the rotation\n * @param {Number} c The angle of rotation\n * @returns {vec3} out\n */\nexport function rotateY(out, a, b, c){\n let p = [], r=[];\n //Translate point to the origin\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2];\n\n //perform rotation\n r[0] = p[2]*Math.sin(c) + p[0]*Math.cos(c);\n r[1] = p[1];\n r[2] = p[2]*Math.cos(c) - p[0]*Math.sin(c);\n\n //translate to correct position\n out[0] = r[0] + b[0];\n out[1] = r[1] + b[1];\n out[2] = r[2] + b[2];\n\n return out;\n}\n\n/**\n * Rotate a 3D vector around the z-axis\n * @param {vec3} out The receiving vec3\n * @param {vec3} a The vec3 point to rotate\n * @param {vec3} b The origin of the rotation\n * @param {Number} c The angle of rotation\n * @returns {vec3} out\n */\nexport function rotateZ(out, a, b, c){\n let p = [], r=[];\n //Translate point to the origin\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2];\n\n //perform rotation\n r[0] = p[0]*Math.cos(c) - p[1]*Math.sin(c);\n r[1] = p[0]*Math.sin(c) + p[1]*Math.cos(c);\n r[2] = p[2];\n\n //translate to correct position\n out[0] = r[0] + b[0];\n out[1] = r[1] + b[1];\n out[2] = r[2] + b[2];\n\n return out;\n}\n\n/**\n * Get the angle between two 3D vectors\n * @param {vec3} a The first operand\n * @param {vec3} b The second operand\n * @returns {Number} The angle in radians\n */\nexport function angle(a, b) {\n let tempA = fromValues(a[0], a[1], a[2]);\n let tempB = fromValues(b[0], b[1], b[2]);\n\n normalize(tempA, tempA);\n normalize(tempB, tempB);\n\n let cosine = dot(tempA, tempB);\n\n if(cosine > 1.0) {\n return 0;\n }\n else if(cosine < -1.0) {\n return Math.PI;\n } else {\n return Math.acos(cosine);\n }\n}\n\n/**\n * Returns a string representation of a vector\n *\n * @param {vec3} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\nexport function str(a) {\n return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')';\n}\n\n/**\n * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)\n *\n * @param {vec3} a The first vector.\n * @param {vec3} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\n}\n\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {vec3} a The first vector.\n * @param {vec3} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\nexport function equals(a, b) {\n let a0 = a[0], a1 = a[1], a2 = a[2];\n let b0 = b[0], b1 = b[1], b2 = b[2];\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\n Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&\n Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)));\n}\n\n/**\n * Alias for {@link vec3.subtract}\n * @function\n */\nexport const sub = subtract;\n\n/**\n * Alias for {@link vec3.multiply}\n * @function\n */\nexport const mul = multiply;\n\n/**\n * Alias for {@link vec3.divide}\n * @function\n */\nexport const div = divide;\n\n/**\n * Alias for {@link vec3.distance}\n * @function\n */\nexport const dist = distance;\n\n/**\n * Alias for {@link vec3.squaredDistance}\n * @function\n */\nexport const sqrDist = squaredDistance;\n\n/**\n * Alias for {@link vec3.length}\n * @function\n */\nexport const len = length;\n\n/**\n * Alias for {@link vec3.squaredLength}\n * @function\n */\nexport const sqrLen = squaredLength;\n\n/**\n * Perform some operation over an array of vec3s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\nexport const forEach = (function() {\n let vec = create();\n\n return function(a, stride, offset, count, fn, arg) {\n let i, l;\n if(!stride) {\n stride = 3;\n }\n\n if(!offset) {\n offset = 0;\n }\n\n if(count) {\n l = Math.min((count * stride) + offset, a.length);\n } else {\n l = a.length;\n }\n\n for(i = offset; i < l; i += stride) {\n vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2];\n fn(vec, vec, arg);\n a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2];\n }\n\n return a;\n };\n})();\n","import * as glMatrix from \"./common.js\";\n\n/**\n * 4 Dimensional Vector\n * @module vec4\n */\n\n/**\n * Creates a new, empty vec4\n *\n * @returns {vec4} a new 4D vector\n */\nexport function create() {\n let out = new glMatrix.ARRAY_TYPE(4);\n if(glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n }\n return out;\n}\n\n/**\n * Creates a new vec4 initialized with values from an existing vector\n *\n * @param {vec4} a vector to clone\n * @returns {vec4} a new 4D vector\n */\nexport function clone(a) {\n let out = new glMatrix.ARRAY_TYPE(4);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n\n/**\n * Creates a new vec4 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {vec4} a new 4D vector\n */\nexport function fromValues(x, y, z, w) {\n let out = new glMatrix.ARRAY_TYPE(4);\n out[0] = x;\n out[1] = y;\n out[2] = z;\n out[3] = w;\n return out;\n}\n\n/**\n * Copy the values from one vec4 to another\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a the source vector\n * @returns {vec4} out\n */\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n\n/**\n * Set the components of a vec4 to the given values\n *\n * @param {vec4} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {vec4} out\n */\nexport function set(out, x, y, z, w) {\n out[0] = x;\n out[1] = y;\n out[2] = z;\n out[3] = w;\n return out;\n}\n\n/**\n * Adds two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a the first operand\n * @param {vec4} b the second operand\n * @returns {vec4} out\n */\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n return out;\n}\n\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a the first operand\n * @param {vec4} b the second operand\n * @returns {vec4} out\n */\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n return out;\n}\n\n/**\n * Multiplies two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a the first operand\n * @param {vec4} b the second operand\n * @returns {vec4} out\n */\nexport function multiply(out, a, b) {\n out[0] = a[0] * b[0];\n out[1] = a[1] * b[1];\n out[2] = a[2] * b[2];\n out[3] = a[3] * b[3];\n return out;\n}\n\n/**\n * Divides two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a the first operand\n * @param {vec4} b the second operand\n * @returns {vec4} out\n */\nexport function divide(out, a, b) {\n out[0] = a[0] / b[0];\n out[1] = a[1] / b[1];\n out[2] = a[2] / b[2];\n out[3] = a[3] / b[3];\n return out;\n}\n\n/**\n * Math.ceil the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a vector to ceil\n * @returns {vec4} out\n */\nexport function ceil(out, a) {\n out[0] = Math.ceil(a[0]);\n out[1] = Math.ceil(a[1]);\n out[2] = Math.ceil(a[2]);\n out[3] = Math.ceil(a[3]);\n return out;\n}\n\n/**\n * Math.floor the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a vector to floor\n * @returns {vec4} out\n */\nexport function floor(out, a) {\n out[0] = Math.floor(a[0]);\n out[1] = Math.floor(a[1]);\n out[2] = Math.floor(a[2]);\n out[3] = Math.floor(a[3]);\n return out;\n}\n\n/**\n * Returns the minimum of two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a the first operand\n * @param {vec4} b the second operand\n * @returns {vec4} out\n */\nexport function min(out, a, b) {\n out[0] = Math.min(a[0], b[0]);\n out[1] = Math.min(a[1], b[1]);\n out[2] = Math.min(a[2], b[2]);\n out[3] = Math.min(a[3], b[3]);\n return out;\n}\n\n/**\n * Returns the maximum of two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a the first operand\n * @param {vec4} b the second operand\n * @returns {vec4} out\n */\nexport function max(out, a, b) {\n out[0] = Math.max(a[0], b[0]);\n out[1] = Math.max(a[1], b[1]);\n out[2] = Math.max(a[2], b[2]);\n out[3] = Math.max(a[3], b[3]);\n return out;\n}\n\n/**\n * Math.round the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a vector to round\n * @returns {vec4} out\n */\nexport function round(out, a) {\n out[0] = Math.round(a[0]);\n out[1] = Math.round(a[1]);\n out[2] = Math.round(a[2]);\n out[3] = Math.round(a[3]);\n return out;\n}\n\n/**\n * Scales a vec4 by a scalar number\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec4} out\n */\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n return out;\n}\n\n/**\n * Adds two vec4's after scaling the second operand by a scalar value\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a the first operand\n * @param {vec4} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec4} out\n */\nexport function scaleAndAdd(out, a, b, scale) {\n out[0] = a[0] + (b[0] * scale);\n out[1] = a[1] + (b[1] * scale);\n out[2] = a[2] + (b[2] * scale);\n out[3] = a[3] + (b[3] * scale);\n return out;\n}\n\n/**\n * Calculates the euclidian distance between two vec4's\n *\n * @param {vec4} a the first operand\n * @param {vec4} b the second operand\n * @returns {Number} distance between a and b\n */\nexport function distance(a, b) {\n let x = b[0] - a[0];\n let y = b[1] - a[1];\n let z = b[2] - a[2];\n let w = b[3] - a[3];\n return Math.sqrt(x*x + y*y + z*z + w*w);\n}\n\n/**\n * Calculates the squared euclidian distance between two vec4's\n *\n * @param {vec4} a the first operand\n * @param {vec4} b the second operand\n * @returns {Number} squared distance between a and b\n */\nexport function squaredDistance(a, b) {\n let x = b[0] - a[0];\n let y = b[1] - a[1];\n let z = b[2] - a[2];\n let w = b[3] - a[3];\n return x*x + y*y + z*z + w*w;\n}\n\n/**\n * Calculates the length of a vec4\n *\n * @param {vec4} a vector to calculate length of\n * @returns {Number} length of a\n */\nexport function length(a) {\n let x = a[0];\n let y = a[1];\n let z = a[2];\n let w = a[3];\n return Math.sqrt(x*x + y*y + z*z + w*w);\n}\n\n/**\n * Calculates the squared length of a vec4\n *\n * @param {vec4} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\nexport function squaredLength(a) {\n let x = a[0];\n let y = a[1];\n let z = a[2];\n let w = a[3];\n return x*x + y*y + z*z + w*w;\n}\n\n/**\n * Negates the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a vector to negate\n * @returns {vec4} out\n */\nexport function negate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n out[2] = -a[2];\n out[3] = -a[3];\n return out;\n}\n\n/**\n * Returns the inverse of the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a vector to invert\n * @returns {vec4} out\n */\nexport function inverse(out, a) {\n out[0] = 1.0 / a[0];\n out[1] = 1.0 / a[1];\n out[2] = 1.0 / a[2];\n out[3] = 1.0 / a[3];\n return out;\n}\n\n/**\n * Normalize a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a vector to normalize\n * @returns {vec4} out\n */\nexport function normalize(out, a) {\n let x = a[0];\n let y = a[1];\n let z = a[2];\n let w = a[3];\n let len = x*x + y*y + z*z + w*w;\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n out[0] = x * len;\n out[1] = y * len;\n out[2] = z * len;\n out[3] = w * len;\n }\n return out;\n}\n\n/**\n * Calculates the dot product of two vec4's\n *\n * @param {vec4} a the first operand\n * @param {vec4} b the second operand\n * @returns {Number} dot product of a and b\n */\nexport function dot(a, b) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];\n}\n\n/**\n * Performs a linear interpolation between two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a the first operand\n * @param {vec4} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec4} out\n */\nexport function lerp(out, a, b, t) {\n let ax = a[0];\n let ay = a[1];\n let az = a[2];\n let aw = a[3];\n out[0] = ax + t * (b[0] - ax);\n out[1] = ay + t * (b[1] - ay);\n out[2] = az + t * (b[2] - az);\n out[3] = aw + t * (b[3] - aw);\n return out;\n}\n\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec4} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\n * @returns {vec4} out\n */\nexport function random(out, scale) {\n scale = scale || 1.0;\n\n // Marsaglia, George. Choosing a Point from the Surface of a\n // Sphere. Ann. Math. Statist. 43 (1972), no. 2, 645--646.\n // http://projecteuclid.org/euclid.aoms/1177692644;\n var v1, v2, v3, v4;\n var s1, s2;\n do {\n v1 = glMatrix.RANDOM() * 2 - 1;\n v2 = glMatrix.RANDOM() * 2 - 1;\n s1 = v1 * v1 + v2 * v2;\n } while (s1 >= 1);\n do {\n v3 = glMatrix.RANDOM() * 2 - 1;\n v4 = glMatrix.RANDOM() * 2 - 1;\n s2 = v3 * v3 + v4 * v4;\n } while (s2 >= 1);\n\n var d = Math.sqrt((1 - s1) / s2);\n out[0] = scale * v1;\n out[1] = scale * v2;\n out[2] = scale * v3 * d;\n out[3] = scale * v4 * d;\n return out;\n}\n\n/**\n * Transforms the vec4 with a mat4.\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a the vector to transform\n * @param {mat4} m matrix to transform with\n * @returns {vec4} out\n */\nexport function transformMat4(out, a, m) {\n let x = a[0], y = a[1], z = a[2], w = a[3];\n out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;\n out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;\n out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;\n out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;\n return out;\n}\n\n/**\n * Transforms the vec4 with a quat\n *\n * @param {vec4} out the receiving vector\n * @param {vec4} a the vector to transform\n * @param {quat} q quaternion to transform with\n * @returns {vec4} out\n */\nexport function transformQuat(out, a, q) {\n let x = a[0], y = a[1], z = a[2];\n let qx = q[0], qy = q[1], qz = q[2], qw = q[3];\n\n // calculate quat * vec\n let ix = qw * x + qy * z - qz * y;\n let iy = qw * y + qz * x - qx * z;\n let iz = qw * z + qx * y - qy * x;\n let iw = -qx * x - qy * y - qz * z;\n\n // calculate result * inverse quat\n out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;\n out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;\n out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;\n out[3] = a[3];\n return out;\n}\n\n/**\n * Returns a string representation of a vector\n *\n * @param {vec4} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\nexport function str(a) {\n return 'vec4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';\n}\n\n/**\n * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)\n *\n * @param {vec4} a The first vector.\n * @param {vec4} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {vec4} a The first vector.\n * @param {vec4} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\nexport function equals(a, b) {\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\n Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&\n Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&\n Math.abs(a3 - b3) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a3), Math.abs(b3)));\n}\n\n/**\n * Alias for {@link vec4.subtract}\n * @function\n */\nexport const sub = subtract;\n\n/**\n * Alias for {@link vec4.multiply}\n * @function\n */\nexport const mul = multiply;\n\n/**\n * Alias for {@link vec4.divide}\n * @function\n */\nexport const div = divide;\n\n/**\n * Alias for {@link vec4.distance}\n * @function\n */\nexport const dist = distance;\n\n/**\n * Alias for {@link vec4.squaredDistance}\n * @function\n */\nexport const sqrDist = squaredDistance;\n\n/**\n * Alias for {@link vec4.length}\n * @function\n */\nexport const len = length;\n\n/**\n * Alias for {@link vec4.squaredLength}\n * @function\n */\nexport const sqrLen = squaredLength;\n\n/**\n * Perform some operation over an array of vec4s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\nexport const forEach = (function() {\n let vec = create();\n\n return function(a, stride, offset, count, fn, arg) {\n let i, l;\n if(!stride) {\n stride = 4;\n }\n\n if(!offset) {\n offset = 0;\n }\n\n if(count) {\n l = Math.min((count * stride) + offset, a.length);\n } else {\n l = a.length;\n }\n\n for(i = offset; i < l; i += stride) {\n vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2]; vec[3] = a[i+3];\n fn(vec, vec, arg);\n a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2]; a[i+3] = vec[3];\n }\n\n return a;\n };\n})();\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nconst GL = WebGLRenderingContext; // For enums\n\nexport const CAP = {\n // Enable caps\n CULL_FACE: 0x001,\n BLEND: 0x002,\n DEPTH_TEST: 0x004,\n STENCIL_TEST: 0x008,\n COLOR_MASK: 0x010,\n DEPTH_MASK: 0x020,\n STENCIL_MASK: 0x040,\n};\n\nexport const MAT_STATE = {\n CAPS_RANGE: 0x000000FF,\n BLEND_SRC_SHIFT: 8,\n BLEND_SRC_RANGE: 0x00000F00,\n BLEND_DST_SHIFT: 12,\n BLEND_DST_RANGE: 0x0000F000,\n BLEND_FUNC_RANGE: 0x0000FF00,\n DEPTH_FUNC_SHIFT: 16,\n DEPTH_FUNC_RANGE: 0x000F0000,\n};\n\nexport const RENDER_ORDER = {\n // Render opaque objects first.\n OPAQUE: 0,\n\n // Render the sky after all opaque object to save fill rate.\n SKY: 1,\n\n // Render transparent objects next so that the opaqe objects show through.\n TRANSPARENT: 2,\n\n // Finally render purely additive effects like pointer rays so that they\n // can render without depth mask.\n ADDITIVE: 3,\n\n // Render order will be picked based on the material properties.\n DEFAULT: 4,\n};\n\nexport function stateToBlendFunc(state, mask, shift) {\n let value = (state & mask) >> shift;\n switch (value) {\n case 0:\n case 1:\n return value;\n default:\n return (value - 2) + GL.SRC_COLOR;\n }\n}\n\nexport class MaterialState {\n constructor() {\n this._state = CAP.CULL_FACE |\n CAP.DEPTH_TEST |\n CAP.COLOR_MASK |\n CAP.DEPTH_MASK;\n\n // Use a fairly commonly desired blend func as the default.\n this.blendFuncSrc = GL.SRC_ALPHA;\n this.blendFuncDst = GL.ONE_MINUS_SRC_ALPHA;\n\n this.depthFunc = GL.LESS;\n }\n\n get cullFace() {\n return !!(this._state & CAP.CULL_FACE);\n }\n set cullFace(value) {\n if (value) {\n this._state |= CAP.CULL_FACE;\n } else {\n this._state &= ~CAP.CULL_FACE;\n }\n }\n\n get blend() {\n return !!(this._state & CAP.BLEND);\n }\n set blend(value) {\n if (value) {\n this._state |= CAP.BLEND;\n } else {\n this._state &= ~CAP.BLEND;\n }\n }\n\n get depthTest() {\n return !!(this._state & CAP.DEPTH_TEST);\n }\n set depthTest(value) {\n if (value) {\n this._state |= CAP.DEPTH_TEST;\n } else {\n this._state &= ~CAP.DEPTH_TEST;\n }\n }\n\n get stencilTest() {\n return !!(this._state & CAP.STENCIL_TEST);\n }\n set stencilTest(value) {\n if (value) {\n this._state |= CAP.STENCIL_TEST;\n } else {\n this._state &= ~CAP.STENCIL_TEST;\n }\n }\n\n get colorMask() {\n return !!(this._state & CAP.COLOR_MASK);\n }\n set colorMask(value) {\n if (value) {\n this._state |= CAP.COLOR_MASK;\n } else {\n this._state &= ~CAP.COLOR_MASK;\n }\n }\n\n get depthMask() {\n return !!(this._state & CAP.DEPTH_MASK);\n }\n set depthMask(value) {\n if (value) {\n this._state |= CAP.DEPTH_MASK;\n } else {\n this._state &= ~CAP.DEPTH_MASK;\n }\n }\n\n get depthFunc() {\n return ((this._state & MAT_STATE.DEPTH_FUNC_RANGE) >> MAT_STATE.DEPTH_FUNC_SHIFT) + GL.NEVER;\n }\n set depthFunc(value) {\n value = value - GL.NEVER;\n this._state &= ~MAT_STATE.DEPTH_FUNC_RANGE;\n this._state |= (value << MAT_STATE.DEPTH_FUNC_SHIFT);\n }\n\n get stencilMask() {\n return !!(this._state & CAP.STENCIL_MASK);\n }\n set stencilMask(value) {\n if (value) {\n this._state |= CAP.STENCIL_MASK;\n } else {\n this._state &= ~CAP.STENCIL_MASK;\n }\n }\n\n get blendFuncSrc() {\n return stateToBlendFunc(this._state, MAT_STATE.BLEND_SRC_RANGE, MAT_STATE.BLEND_SRC_SHIFT);\n }\n set blendFuncSrc(value) {\n switch (value) {\n case 0:\n case 1:\n break;\n default:\n value = (value - GL.SRC_COLOR) + 2;\n }\n this._state &= ~MAT_STATE.BLEND_SRC_RANGE;\n this._state |= (value << MAT_STATE.BLEND_SRC_SHIFT);\n }\n\n get blendFuncDst() {\n return stateToBlendFunc(this._state, MAT_STATE.BLEND_DST_RANGE, MAT_STATE.BLEND_DST_SHIFT);\n }\n set blendFuncDst(value) {\n switch (value) {\n case 0:\n case 1:\n break;\n default:\n value = (value - GL.SRC_COLOR) + 2;\n }\n this._state &= ~MAT_STATE.BLEND_DST_RANGE;\n this._state |= (value << MAT_STATE.BLEND_DST_SHIFT);\n }\n}\n\nclass MaterialSampler {\n constructor(uniformName) {\n this._uniformName = uniformName;\n this._texture = null;\n }\n\n get texture() {\n return this._texture;\n }\n\n set texture(value) {\n this._texture = value;\n }\n}\n\nclass MaterialUniform {\n constructor(uniformName, defaultValue, length) {\n this._uniformName = uniformName;\n this._value = defaultValue;\n this._length = length;\n if (!this._length) {\n if (defaultValue instanceof Array) {\n this._length = defaultValue.length;\n } else {\n this._length = 1;\n }\n }\n }\n\n get value() {\n return this._value;\n }\n\n set value(value) {\n this._value = value;\n }\n}\n\nexport class Material {\n constructor() {\n this.state = new MaterialState;\n this.renderOrder = RENDER_ORDER.DEFAULT;\n this._samplers = [];\n this._uniforms = [];\n }\n\n defineSampler(uniformName) {\n let sampler = new MaterialSampler(uniformName);\n this._samplers.push(sampler);\n return sampler;\n }\n\n defineUniform(uniformName, defaultValue=null, length=0) {\n let uniform = new MaterialUniform(uniformName, defaultValue, length);\n this._uniforms.push(uniform);\n return uniform;\n }\n\n get materialName() {\n return null;\n }\n\n get vertexSource() {\n return null;\n }\n\n get fragmentSource() {\n return null;\n }\n\n getProgramDefines(renderPrimitive) {\n return {};\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Ray} from '../math/ray.js';\nimport {mat4, vec3, quat} from '../math/gl-matrix.js';\n\nconst DEFAULT_TRANSLATION = new Float32Array([0, 0, 0]);\nconst DEFAULT_ROTATION = new Float32Array([0, 0, 0, 1]);\nconst DEFAULT_SCALE = new Float32Array([1, 1, 1]);\n\nlet tmpRayMatrix = mat4.create();\n\nexport class Node {\n constructor() {\n this.name = null; // Only for debugging\n this.children = [];\n this.parent = null;\n this.visible = true;\n this.selectable = false;\n\n this._matrix = null;\n\n this._dirtyTRS = false;\n this._translation = null;\n this._rotation = null;\n this._scale = null;\n\n this._dirtyWorldMatrix = false;\n this._worldMatrix = null;\n\n this._activeFrameId = -1;\n this._hoverFrameId = -1;\n this._renderPrimitives = null;\n this._renderer = null;\n\n this._selectHandler = null;\n }\n\n _setRenderer(renderer) {\n if (this._renderer == renderer) {\n return;\n }\n\n if (this._renderer) {\n // Changing the renderer removes any previously attached renderPrimitives\n // from a different renderer.\n this.clearRenderPrimitives();\n }\n\n this._renderer = renderer;\n if (renderer) {\n this.onRendererChanged(renderer);\n\n for (let child of this.children) {\n child._setRenderer(renderer);\n }\n }\n }\n\n onRendererChanged(renderer) {\n // Override in other node types to respond to changes in the renderer.\n }\n\n // Create a clone of this node and all of it's children. Does not duplicate\n // RenderPrimitives, the cloned nodes will be treated as new instances of the\n // geometry.\n clone() {\n let cloneNode = new Node();\n cloneNode.name = this.name;\n cloneNode.visible = this.visible;\n cloneNode._renderer = this._renderer;\n\n cloneNode._dirtyTRS = this._dirtyTRS;\n\n if (this._translation) {\n cloneNode._translation = vec3.create();\n vec3.copy(cloneNode._translation, this._translation);\n }\n\n if (this._rotation) {\n cloneNode._rotation = quat.create();\n quat.copy(cloneNode._rotation, this._rotation);\n }\n\n if (this._scale) {\n cloneNode._scale = vec3.create();\n vec3.copy(cloneNode._scale, this._scale);\n }\n\n // Only copy the matrices if they're not already dirty.\n if (!cloneNode._dirtyTRS && this._matrix) {\n cloneNode._matrix = mat4.create();\n mat4.copy(cloneNode._matrix, this._matrix);\n }\n\n cloneNode._dirtyWorldMatrix = this._dirtyWorldMatrix;\n if (!cloneNode._dirtyWorldMatrix && this._worldMatrix) {\n cloneNode._worldMatrix = mat4.create();\n mat4.copy(cloneNode._worldMatrix, this._worldMatrix);\n }\n\n this.waitForComplete().then(() => {\n if (this._renderPrimitives) {\n for (let primitive of this._renderPrimitives) {\n cloneNode.addRenderPrimitive(primitive);\n }\n }\n\n for (let child of this.children) {\n cloneNode.addNode(child.clone());\n }\n });\n\n return cloneNode;\n }\n\n markActive(frameId) {\n if (this.visible && this._renderPrimitives) {\n this._activeFrameId = frameId;\n for (let primitive of this._renderPrimitives) {\n primitive.markActive(frameId);\n }\n }\n\n for (let child of this.children) {\n if (child.visible) {\n child.markActive(frameId);\n }\n }\n }\n\n addNode(value) {\n if (!value || value.parent == this) {\n return;\n }\n\n if (value.parent) {\n value.parent.removeNode(value);\n }\n value.parent = this;\n\n this.children.push(value);\n\n if (this._renderer) {\n value._setRenderer(this._renderer);\n }\n }\n\n removeNode(value) {\n let i = this.children.indexOf(value);\n if (i > -1) {\n this.children.splice(i, 1);\n value.parent = null;\n }\n }\n\n clearNodes() {\n for (let child of this.children) {\n child.parent = null;\n }\n this.children = [];\n }\n\n setMatrixDirty() {\n if (!this._dirtyWorldMatrix) {\n this._dirtyWorldMatrix = true;\n for (let child of this.children) {\n child.setMatrixDirty();\n }\n }\n }\n\n _updateLocalMatrix() {\n if (!this._matrix) {\n this._matrix = mat4.create();\n }\n\n if (this._dirtyTRS) {\n this._dirtyTRS = false;\n mat4.fromRotationTranslationScale(\n this._matrix,\n this._rotation || DEFAULT_ROTATION,\n this._translation || DEFAULT_TRANSLATION,\n this._scale || DEFAULT_SCALE);\n }\n\n return this._matrix;\n }\n\n set matrix(value) {\n if (value) {\n if (!this._matrix) {\n this._matrix = mat4.create();\n }\n mat4.copy(this._matrix, value);\n } else {\n this._matrix = null;\n }\n this.setMatrixDirty();\n this._dirtyTRS = false;\n this._translation = null;\n this._rotation = null;\n this._scale = null;\n }\n\n get matrix() {\n this.setMatrixDirty();\n\n return this._updateLocalMatrix();\n }\n\n get worldMatrix() {\n if (!this._worldMatrix) {\n this._dirtyWorldMatrix = true;\n this._worldMatrix = mat4.create();\n }\n\n if (this._dirtyWorldMatrix || this._dirtyTRS) {\n if (this.parent) {\n // TODO: Some optimizations that could be done here if the node matrix\n // is an identity matrix.\n mat4.mul(this._worldMatrix, this.parent.worldMatrix, this._updateLocalMatrix());\n } else {\n mat4.copy(this._worldMatrix, this._updateLocalMatrix());\n }\n this._dirtyWorldMatrix = false;\n }\n\n return this._worldMatrix;\n }\n\n // TODO: Decompose matrix when fetching these?\n set translation(value) {\n if (value != null) {\n this._dirtyTRS = true;\n this.setMatrixDirty();\n }\n this._translation = value;\n }\n\n get translation() {\n this._dirtyTRS = true;\n this.setMatrixDirty();\n if (!this._translation) {\n this._translation = vec3.clone(DEFAULT_TRANSLATION);\n }\n return this._translation;\n }\n\n set rotation(value) {\n if (value != null) {\n this._dirtyTRS = true;\n this.setMatrixDirty();\n }\n this._rotation = value;\n }\n\n get rotation() {\n this._dirtyTRS = true;\n this.setMatrixDirty();\n if (!this._rotation) {\n this._rotation = quat.clone(DEFAULT_ROTATION);\n }\n return this._rotation;\n }\n\n set scale(value) {\n if (value != null) {\n this._dirtyTRS = true;\n this.setMatrixDirty();\n }\n this._scale = value;\n }\n\n get scale() {\n this._dirtyTRS = true;\n this.setMatrixDirty();\n if (!this._scale) {\n this._scale = vec3.clone(DEFAULT_SCALE);\n }\n return this._scale;\n }\n\n waitForComplete() {\n let childPromises = [];\n for (let child of this.children) {\n childPromises.push(child.waitForComplete());\n }\n if (this._renderPrimitives) {\n for (let primitive of this._renderPrimitives) {\n childPromises.push(primitive.waitForComplete());\n }\n }\n return Promise.all(childPromises).then(() => this);\n }\n\n get renderPrimitives() {\n return this._renderPrimitives;\n }\n\n addRenderPrimitive(primitive) {\n if (!this._renderPrimitives) {\n this._renderPrimitives = [primitive];\n } else {\n this._renderPrimitives.push(primitive);\n }\n primitive._instances.push(this);\n }\n\n removeRenderPrimitive(primitive) {\n if (!this._renderPrimitives) {\n return;\n }\n\n let index = this._renderPrimitives._instances.indexOf(primitive);\n if (index > -1) {\n this._renderPrimitives._instances.splice(index, 1);\n\n index = primitive._instances.indexOf(this);\n if (index > -1) {\n primitive._instances.splice(index, 1);\n }\n\n if (!this._renderPrimitives.length) {\n this._renderPrimitives = null;\n }\n }\n }\n\n clearRenderPrimitives() {\n if (this._renderPrimitives) {\n for (let primitive of this._renderPrimitives) {\n let index = primitive._instances.indexOf(this);\n if (index > -1) {\n primitive._instances.splice(index, 1);\n }\n }\n this._renderPrimitives = null;\n }\n }\n\n _hitTestSelectableNode(ray) {\n if (this._renderPrimitives) {\n let localRay = null;\n for (let primitive of this._renderPrimitives) {\n if (primitive._min) {\n if (!localRay) {\n mat4.invert(tmpRayMatrix, this.worldMatrix);\n mat4.multiply(tmpRayMatrix, tmpRayMatrix, ray.transformMatrix);\n localRay = new Ray(tmpRayMatrix);\n }\n let intersection = localRay.intersectsAABB(primitive._min, primitive._max);\n if (intersection) {\n vec3.transformMat4(intersection, intersection, this.worldMatrix);\n return intersection;\n }\n }\n }\n }\n for (let child of this.children) {\n let intersection = child._hitTestSelectableNode(ray);\n if (intersection) {\n return intersection;\n }\n }\n return null;\n }\n\n hitTest(ray) {\n if (this.selectable && this.visible) {\n let intersection = this._hitTestSelectableNode(ray);\n\n if (intersection) {\n let origin = vec3.fromValues(ray.origin.x, ray.origin.y, ray.origin.z);\n return {\n node: this,\n intersection: intersection,\n distance: vec3.distance(origin, intersection),\n };\n }\n return null;\n }\n\n let result = null;\n for (let child of this.children) {\n let childResult = child.hitTest(ray);\n if (childResult) {\n if (!result || result.distance > childResult.distance) {\n result = childResult;\n }\n }\n }\n return result;\n }\n\n onSelect(value) {\n this._selectHandler = value;\n }\n\n get selectHandler() {\n return this._selectHandler;\n }\n\n // Called when a selectable node is selected.\n handleSelect() {\n if (this._selectHandler) {\n this._selectHandler();\n }\n }\n\n // Called when a selectable element is pointed at.\n onHoverStart() {\n\n }\n\n // Called when a selectable element is no longer pointed at.\n onHoverEnd() {\n\n }\n\n _update(timestamp, frameDelta) {\n this.onUpdate(timestamp, frameDelta);\n\n for (let child of this.children) {\n child._update(timestamp, frameDelta);\n }\n }\n\n // Called every frame so that the nodes can animate themselves\n onUpdate(timestamp, frameDelta) {\n\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {vec3} from '../math/gl-matrix.js';\n\nexport class PrimitiveAttribute {\n constructor(name, buffer, componentCount, componentType, stride, byteOffset) {\n this.name = name;\n this.buffer = buffer;\n this.componentCount = componentCount || 3;\n this.componentType = componentType || 5126; // gl.FLOAT;\n this.stride = stride || 0;\n this.byteOffset = byteOffset || 0;\n this.normalized = false;\n }\n}\n\nexport class Primitive {\n constructor(attributes, elementCount, mode) {\n this.attributes = attributes || [];\n this.elementCount = elementCount || 0;\n this.mode = mode || 4; // gl.TRIANGLES;\n this.indexBuffer = null;\n this.indexByteOffset = 0;\n this.indexType = 0;\n this._min = null;\n this._max = null;\n }\n\n setIndexBuffer(indexBuffer, byteOffset, indexType) {\n this.indexBuffer = indexBuffer;\n this.indexByteOffset = byteOffset || 0;\n this.indexType = indexType || 5123; // gl.UNSIGNED_SHORT;\n }\n\n setBounds(min, max) {\n this._min = vec3.clone(min);\n this._max = vec3.clone(max);\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nexport class Program {\n constructor(gl, vertSrc, fragSrc, attribMap, defines) {\n this._gl = gl;\n this.program = gl.createProgram();\n this.attrib = null;\n this.uniform = null;\n this.defines = {};\n\n this._firstUse = true;\n this._nextUseCallbacks = [];\n\n let definesString = '';\n if (defines) {\n for (let define in defines) {\n this.defines[define] = defines[define];\n definesString += `#define ${define} ${defines[define]}\\n`;\n }\n }\n\n this._vertShader = gl.createShader(gl.VERTEX_SHADER);\n gl.attachShader(this.program, this._vertShader);\n gl.shaderSource(this._vertShader, definesString + vertSrc);\n gl.compileShader(this._vertShader);\n\n this._fragShader = gl.createShader(gl.FRAGMENT_SHADER);\n gl.attachShader(this.program, this._fragShader);\n gl.shaderSource(this._fragShader, definesString + fragSrc);\n gl.compileShader(this._fragShader);\n\n if (attribMap) {\n this.attrib = {};\n for (let attribName in attribMap) {\n gl.bindAttribLocation(this.program, attribMap[attribName], attribName);\n this.attrib[attribName] = attribMap[attribName];\n }\n }\n\n gl.linkProgram(this.program);\n }\n\n onNextUse(callback) {\n this._nextUseCallbacks.push(callback);\n }\n\n use() {\n let gl = this._gl;\n\n // If this is the first time the program has been used do all the error checking and\n // attrib/uniform querying needed.\n if (this._firstUse) {\n this._firstUse = false;\n if (!gl.getProgramParameter(this.program, gl.LINK_STATUS)) {\n if (!gl.getShaderParameter(this._vertShader, gl.COMPILE_STATUS)) {\n console.error('Vertex shader compile error: ' + gl.getShaderInfoLog(this._vertShader));\n } else if (!gl.getShaderParameter(this._fragShader, gl.COMPILE_STATUS)) {\n console.error('Fragment shader compile error: ' + gl.getShaderInfoLog(this._fragShader));\n } else {\n console.error('Program link error: ' + gl.getProgramInfoLog(this.program));\n }\n gl.deleteProgram(this.program);\n this.program = null;\n } else {\n if (!this.attrib) {\n this.attrib = {};\n let attribCount = gl.getProgramParameter(this.program, gl.ACTIVE_ATTRIBUTES);\n for (let i = 0; i < attribCount; i++) {\n let attribInfo = gl.getActiveAttrib(this.program, i);\n this.attrib[attribInfo.name] = gl.getAttribLocation(this.program, attribInfo.name);\n }\n }\n\n this.uniform = {};\n let uniformCount = gl.getProgramParameter(this.program, gl.ACTIVE_UNIFORMS);\n let uniformName = '';\n for (let i = 0; i < uniformCount; i++) {\n let uniformInfo = gl.getActiveUniform(this.program, i);\n uniformName = uniformInfo.name.replace('[0]', '');\n this.uniform[uniformName] = gl.getUniformLocation(this.program, uniformName);\n }\n }\n gl.deleteShader(this._vertShader);\n gl.deleteShader(this._fragShader);\n }\n\n gl.useProgram(this.program);\n\n if (this._nextUseCallbacks.length) {\n for (let callback of this._nextUseCallbacks) {\n callback(this);\n }\n this._nextUseCallbacks = [];\n }\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {CAP, MAT_STATE, RENDER_ORDER, stateToBlendFunc} from './material.js';\nimport {Node} from './node.js';\nimport {Program} from './program.js';\nimport {DataTexture, VideoTexture} from './texture.js';\nimport {mat4, vec3} from '../math/gl-matrix.js';\n\nexport const ATTRIB = {\n POSITION: 1,\n NORMAL: 2,\n TANGENT: 3,\n TEXCOORD_0: 4,\n TEXCOORD_1: 5,\n COLOR_0: 6,\n};\n\nexport const ATTRIB_MASK = {\n POSITION: 0x0001,\n NORMAL: 0x0002,\n TANGENT: 0x0004,\n TEXCOORD_0: 0x0008,\n TEXCOORD_1: 0x0010,\n COLOR_0: 0x0020,\n};\n\nconst GL = WebGLRenderingContext; // For enums\n\nconst DEF_LIGHT_DIR = new Float32Array([-0.1, -1.0, -0.2]);\nconst DEF_LIGHT_COLOR = new Float32Array([3.0, 3.0, 3.0]);\n\nconst PRECISION_REGEX = new RegExp('precision (lowp|mediump|highp) float;');\n\nconst VERTEX_SHADER_SINGLE_ENTRY = `\nuniform mat4 PROJECTION_MATRIX, VIEW_MATRIX, MODEL_MATRIX;\n\nvoid main() {\n gl_Position = vertex_main(PROJECTION_MATRIX, VIEW_MATRIX, MODEL_MATRIX);\n}\n`;\n\nconst VERTEX_SHADER_MULTI_ENTRY = `\n#ERROR Multiview rendering is not implemented\nvoid main() {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n}\n`;\n\nconst FRAGMENT_SHADER_ENTRY = `\nvoid main() {\n gl_FragColor = fragment_main();\n}\n`;\n\nfunction isPowerOfTwo(n) {\n return (n & (n - 1)) === 0;\n}\n\n// Creates a WebGL context and initializes it with some common default state.\nexport function createWebGLContext(glAttribs) {\n glAttribs = glAttribs || {alpha: false};\n\n let webglCanvas = document.createElement('canvas');\n let contextTypes = glAttribs.webgl2 ? ['webgl2'] : ['webgl', 'experimental-webgl'];\n let context = null;\n\n for (let contextType of contextTypes) {\n context = webglCanvas.getContext(contextType, glAttribs);\n if (context) {\n break;\n }\n }\n\n if (!context) {\n let webglType = (glAttribs.webgl2 ? 'WebGL 2' : 'WebGL');\n console.error('This browser does not support ' + webglType + '.');\n return null;\n }\n\n return context;\n}\n\nexport class RenderView {\n constructor(projectionMatrix, viewMatrix, viewport = null, eye = 'left') {\n this.projectionMatrix = projectionMatrix;\n this.viewMatrix = viewMatrix;\n this.viewport = viewport;\n // If an eye isn't given the left eye is assumed.\n this._eye = eye;\n this._eyeIndex = (eye == 'left' ? 0 : 1);\n }\n\n get eye() {\n return this._eye;\n }\n\n set eye(value) {\n this._eye = value;\n this._eyeIndex = (value == 'left' ? 0 : 1);\n }\n\n get eyeIndex() {\n return this._eyeIndex;\n }\n}\n\nclass RenderBuffer {\n constructor(target, usage, buffer, length = 0) {\n this._target = target;\n this._usage = usage;\n this._length = length;\n if (buffer instanceof Promise) {\n this._buffer = null;\n this._promise = buffer.then((buffer) => {\n this._buffer = buffer;\n return this;\n });\n } else {\n this._buffer = buffer;\n this._promise = Promise.resolve(this);\n }\n }\n\n waitForComplete() {\n return this._promise;\n }\n}\n\nclass RenderPrimitiveAttribute {\n constructor(primitiveAttribute) {\n this._attrib_index = ATTRIB[primitiveAttribute.name];\n this._componentCount = primitiveAttribute.componentCount;\n this._componentType = primitiveAttribute.componentType;\n this._stride = primitiveAttribute.stride;\n this._byteOffset = primitiveAttribute.byteOffset;\n this._normalized = primitiveAttribute.normalized;\n }\n}\n\nclass RenderPrimitiveAttributeBuffer {\n constructor(buffer) {\n this._buffer = buffer;\n this._attributes = [];\n }\n}\n\nclass RenderPrimitive {\n constructor(primitive) {\n this._activeFrameId = 0;\n this._instances = [];\n this._material = null;\n\n this.setPrimitive(primitive);\n }\n\n setPrimitive(primitive) {\n this._mode = primitive.mode;\n this._elementCount = primitive.elementCount;\n this._promise = null;\n this._vao = null;\n this._complete = false;\n this._attributeBuffers = [];\n this._attributeMask = 0;\n\n for (let attribute of primitive.attributes) {\n this._attributeMask |= ATTRIB_MASK[attribute.name];\n let renderAttribute = new RenderPrimitiveAttribute(attribute);\n let foundBuffer = false;\n for (let attributeBuffer of this._attributeBuffers) {\n if (attributeBuffer._buffer == attribute.buffer) {\n attributeBuffer._attributes.push(renderAttribute);\n foundBuffer = true;\n break;\n }\n }\n if (!foundBuffer) {\n let attributeBuffer = new RenderPrimitiveAttributeBuffer(attribute.buffer);\n attributeBuffer._attributes.push(renderAttribute);\n this._attributeBuffers.push(attributeBuffer);\n }\n }\n\n this._indexBuffer = null;\n this._indexByteOffset = 0;\n this._indexType = 0;\n\n if (primitive.indexBuffer) {\n this._indexByteOffset = primitive.indexByteOffset;\n this._indexType = primitive.indexType;\n this._indexBuffer = primitive.indexBuffer;\n }\n\n if (primitive._min) {\n this._min = vec3.clone(primitive._min);\n this._max = vec3.clone(primitive._max);\n } else {\n this._min = null;\n this._max = null;\n }\n\n if (this._material != null) {\n this.waitForComplete(); // To flip the _complete flag.\n }\n }\n\n setRenderMaterial(material) {\n this._material = material;\n this._promise = null;\n this._complete = false;\n\n if (this._material != null) {\n this.waitForComplete(); // To flip the _complete flag.\n }\n }\n\n markActive(frameId) {\n if (this._complete && this._activeFrameId != frameId) {\n if (this._material) {\n if (!this._material.markActive(frameId)) {\n return;\n }\n }\n this._activeFrameId = frameId;\n }\n }\n\n get samplers() {\n return this._material._samplerDictionary;\n }\n\n get uniforms() {\n return this._material._uniform_dictionary;\n }\n\n waitForComplete() {\n if (!this._promise) {\n if (!this._material) {\n return Promise.reject('RenderPrimitive does not have a material');\n }\n\n let completionPromises = [];\n\n for (let attributeBuffer of this._attributeBuffers) {\n if (!attributeBuffer._buffer._buffer) {\n completionPromises.push(attributeBuffer._buffer._promise);\n }\n }\n\n if (this._indexBuffer && !this._indexBuffer._buffer) {\n completionPromises.push(this._indexBuffer._promise);\n }\n\n this._promise = Promise.all(completionPromises).then(() => {\n this._complete = true;\n return this;\n });\n }\n return this._promise;\n }\n}\n\nexport class RenderTexture {\n constructor(texture) {\n this._texture = texture;\n this._complete = false;\n this._activeFrameId = 0;\n this._activeCallback = null;\n }\n\n markActive(frameId) {\n if (this._activeCallback && this._activeFrameId != frameId) {\n this._activeFrameId = frameId;\n this._activeCallback(this);\n }\n }\n}\n\nconst inverseMatrix = mat4.create();\n\nfunction setCap(gl, glEnum, cap, prevState, state) {\n let change = (state & cap) - (prevState & cap);\n if (!change) {\n return;\n }\n\n if (change > 0) {\n gl.enable(glEnum);\n } else {\n gl.disable(glEnum);\n }\n}\n\nclass RenderMaterialSampler {\n constructor(renderer, materialSampler, index) {\n this._renderer = renderer;\n this._uniformName = materialSampler._uniformName;\n this._renderTexture = renderer._getRenderTexture(materialSampler._texture);\n this._index = index;\n }\n\n set texture(value) {\n this._renderTexture = this._renderer._getRenderTexture(value);\n }\n}\n\nclass RenderMaterialUniform {\n constructor(materialUniform) {\n this._uniformName = materialUniform._uniformName;\n this._uniform = null;\n this._length = materialUniform._length;\n if (materialUniform._value instanceof Array) {\n this._value = new Float32Array(materialUniform._value);\n } else {\n this._value = new Float32Array([materialUniform._value]);\n }\n }\n\n set value(value) {\n if (this._value.length == 1) {\n this._value[0] = value;\n } else {\n for (let i = 0; i < this._value.length; ++i) {\n this._value[i] = value[i];\n }\n }\n }\n}\n\nclass RenderMaterial {\n constructor(renderer, material, program) {\n this._program = program;\n this._state = material.state._state;\n this._activeFrameId = 0;\n this._completeForActiveFrame = false;\n\n this._samplerDictionary = {};\n this._samplers = [];\n for (let i = 0; i < material._samplers.length; ++i) {\n let renderSampler = new RenderMaterialSampler(renderer, material._samplers[i], i);\n this._samplers.push(renderSampler);\n this._samplerDictionary[renderSampler._uniformName] = renderSampler;\n }\n\n this._uniform_dictionary = {};\n this._uniforms = [];\n for (let uniform of material._uniforms) {\n let renderUniform = new RenderMaterialUniform(uniform);\n this._uniforms.push(renderUniform);\n this._uniform_dictionary[renderUniform._uniformName] = renderUniform;\n }\n\n this._firstBind = true;\n\n this._renderOrder = material.renderOrder;\n if (this._renderOrder == RENDER_ORDER.DEFAULT) {\n if (this._state & CAP.BLEND) {\n this._renderOrder = RENDER_ORDER.TRANSPARENT;\n } else {\n this._renderOrder = RENDER_ORDER.OPAQUE;\n }\n }\n }\n\n bind(gl) {\n // First time we do a binding, cache the uniform locations and remove\n // unused uniforms from the list.\n if (this._firstBind) {\n for (let i = 0; i < this._samplers.length;) {\n let sampler = this._samplers[i];\n if (!this._program.uniform[sampler._uniformName]) {\n this._samplers.splice(i, 1);\n continue;\n }\n ++i;\n }\n\n for (let i = 0; i < this._uniforms.length;) {\n let uniform = this._uniforms[i];\n uniform._uniform = this._program.uniform[uniform._uniformName];\n if (!uniform._uniform) {\n this._uniforms.splice(i, 1);\n continue;\n }\n ++i;\n }\n this._firstBind = false;\n }\n\n for (let sampler of this._samplers) {\n gl.activeTexture(gl.TEXTURE0 + sampler._index);\n if (sampler._renderTexture && sampler._renderTexture._complete) {\n gl.bindTexture(gl.TEXTURE_2D, sampler._renderTexture._texture);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n }\n\n for (let uniform of this._uniforms) {\n switch (uniform._length) {\n case 1: gl.uniform1fv(uniform._uniform, uniform._value); break;\n case 2: gl.uniform2fv(uniform._uniform, uniform._value); break;\n case 3: gl.uniform3fv(uniform._uniform, uniform._value); break;\n case 4: gl.uniform4fv(uniform._uniform, uniform._value); break;\n }\n }\n }\n\n markActive(frameId) {\n if (this._activeFrameId != frameId) {\n this._activeFrameId = frameId;\n this._completeForActiveFrame = true;\n for (let i = 0; i < this._samplers.length; ++i) {\n let sampler = this._samplers[i];\n if (sampler._renderTexture) {\n if (!sampler._renderTexture._complete) {\n this._completeForActiveFrame = false;\n break;\n }\n sampler._renderTexture.markActive(frameId);\n }\n }\n }\n return this._completeForActiveFrame;\n }\n\n // Material State fetchers\n get cullFace() {\n return !!(this._state & CAP.CULL_FACE);\n }\n get blend() {\n return !!(this._state & CAP.BLEND);\n }\n get depthTest() {\n return !!(this._state & CAP.DEPTH_TEST);\n }\n get stencilTest() {\n return !!(this._state & CAP.STENCIL_TEST);\n }\n get colorMask() {\n return !!(this._state & CAP.COLOR_MASK);\n }\n get depthMask() {\n return !!(this._state & CAP.DEPTH_MASK);\n }\n get stencilMask() {\n return !!(this._state & CAP.STENCIL_MASK);\n }\n get depthFunc() {\n return ((this._state & MAT_STATE.DEPTH_FUNC_RANGE) >> MAT_STATE.DEPTH_FUNC_SHIFT) + GL.NEVER;\n }\n get blendFuncSrc() {\n return stateToBlendFunc(this._state, MAT_STATE.BLEND_SRC_RANGE, MAT_STATE.BLEND_SRC_SHIFT);\n }\n get blendFuncDst() {\n return stateToBlendFunc(this._state, MAT_STATE.BLEND_DST_RANGE, MAT_STATE.BLEND_DST_SHIFT);\n }\n\n // Only really for use from the renderer\n _capsDiff(otherState) {\n return (otherState & MAT_STATE.CAPS_RANGE) ^ (this._state & MAT_STATE.CAPS_RANGE);\n }\n\n _blendDiff(otherState) {\n if (!(this._state & CAP.BLEND)) {\n return 0;\n }\n return (otherState & MAT_STATE.BLEND_FUNC_RANGE) ^ (this._state & MAT_STATE.BLEND_FUNC_RANGE);\n }\n\n _depthFuncDiff(otherState) {\n if (!(this._state & CAP.DEPTH_TEST)) {\n return 0;\n }\n return (otherState & MAT_STATE.DEPTH_FUNC_RANGE) ^ (this._state & MAT_STATE.DEPTH_FUNC_RANGE);\n }\n}\n\nexport class Renderer {\n constructor(gl) {\n this._gl = gl || createWebGLContext();\n this._frameId = 0;\n this._programCache = {};\n this._textureCache = {};\n this._renderPrimitives = Array(RENDER_ORDER.DEFAULT);\n this._cameraPositions = [];\n\n this._vaoExt = gl.getExtension('OES_vertex_array_object');\n\n let fragHighPrecision = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);\n this._defaultFragPrecision = fragHighPrecision.precision > 0 ? 'highp' : 'mediump';\n\n this._depthMaskNeedsReset = false;\n this._colorMaskNeedsReset = false;\n\n this._globalLightColor = vec3.clone(DEF_LIGHT_COLOR);\n this._globalLightDir = vec3.clone(DEF_LIGHT_DIR);\n }\n\n get gl() {\n return this._gl;\n }\n\n set globalLightColor(value) {\n vec3.copy(this._globalLightColor, value);\n }\n\n get globalLightColor() {\n return vec3.clone(this._globalLightColor);\n }\n\n set globalLightDir(value) {\n vec3.copy(this._globalLightDir, value);\n }\n\n get globalLightDir() {\n return vec3.clone(this._globalLightDir);\n }\n\n createRenderBuffer(target, data, usage = GL.STATIC_DRAW) {\n let gl = this._gl;\n let glBuffer = gl.createBuffer();\n\n if (data instanceof Promise) {\n let renderBuffer = new RenderBuffer(target, usage, data.then((data) => {\n gl.bindBuffer(target, glBuffer);\n gl.bufferData(target, data, usage);\n renderBuffer._length = data.byteLength;\n return glBuffer;\n }));\n return renderBuffer;\n } else {\n gl.bindBuffer(target, glBuffer);\n gl.bufferData(target, data, usage);\n return new RenderBuffer(target, usage, glBuffer, data.byteLength);\n }\n }\n\n updateRenderBuffer(buffer, data, offset = 0) {\n if (buffer._buffer) {\n let gl = this._gl;\n gl.bindBuffer(buffer._target, buffer._buffer);\n if (offset == 0 && buffer._length == data.byteLength) {\n gl.bufferData(buffer._target, data, buffer._usage);\n } else {\n gl.bufferSubData(buffer._target, offset, data);\n }\n } else {\n buffer.waitForComplete().then((buffer) => {\n this.updateRenderBuffer(buffer, data, offset);\n });\n }\n }\n\n createRenderPrimitive(primitive, material) {\n let renderPrimitive = new RenderPrimitive(primitive);\n\n let program = this._getMaterialProgram(material, renderPrimitive);\n let renderMaterial = new RenderMaterial(this, material, program);\n renderPrimitive.setRenderMaterial(renderMaterial);\n\n if (!this._renderPrimitives[renderMaterial._renderOrder]) {\n this._renderPrimitives[renderMaterial._renderOrder] = [];\n }\n\n this._renderPrimitives[renderMaterial._renderOrder].push(renderPrimitive);\n\n return renderPrimitive;\n }\n\n createMesh(primitive, material) {\n let meshNode = new Node();\n meshNode.addRenderPrimitive(this.createRenderPrimitive(primitive, material));\n return meshNode;\n }\n\n drawViews(views, rootNode) {\n if (!rootNode) {\n return;\n }\n\n let gl = this._gl;\n this._frameId++;\n\n rootNode.markActive(this._frameId);\n\n // If there's only one view then flip the algorithm a bit so that we're only\n // setting the viewport once.\n if (views.length == 1 && views[0].viewport) {\n let vp = views[0].viewport;\n this._gl.viewport(vp.x, vp.y, vp.width, vp.height);\n }\n\n // Get the positions of the 'camera' for each view matrix.\n for (let i = 0; i < views.length; ++i) {\n mat4.invert(inverseMatrix, views[i].viewMatrix);\n\n if (this._cameraPositions.length <= i) {\n this._cameraPositions.push(vec3.create());\n }\n let cameraPosition = this._cameraPositions[i];\n vec3.set(cameraPosition, 0, 0, 0);\n vec3.transformMat4(cameraPosition, cameraPosition, inverseMatrix);\n }\n\n // Draw each set of render primitives in order\n for (let renderPrimitives of this._renderPrimitives) {\n if (renderPrimitives && renderPrimitives.length) {\n this._drawRenderPrimitiveSet(views, renderPrimitives);\n }\n }\n\n if (this._vaoExt) {\n this._vaoExt.bindVertexArrayOES(null);\n }\n\n if (this._depthMaskNeedsReset) {\n gl.depthMask(true);\n }\n if (this._colorMaskNeedsReset) {\n gl.colorMask(true, true, true, true);\n }\n }\n\n _drawRenderPrimitiveSet(views, renderPrimitives) {\n let gl = this._gl;\n let program = null;\n let material = null;\n let attribMask = 0;\n\n // Loop through every primitive known to the renderer.\n for (let primitive of renderPrimitives) {\n // Skip over those that haven't been marked as active for this frame.\n if (primitive._activeFrameId != this._frameId) {\n continue;\n }\n\n // Bind the primitive material's program if it's different than the one we\n // were using for the previous primitive.\n // TODO: The ording of this could be more efficient.\n if (program != primitive._material._program) {\n program = primitive._material._program;\n program.use();\n\n if (program.uniform.LIGHT_DIRECTION) {\n gl.uniform3fv(program.uniform.LIGHT_DIRECTION, this._globalLightDir);\n }\n\n if (program.uniform.LIGHT_COLOR) {\n gl.uniform3fv(program.uniform.LIGHT_COLOR, this._globalLightColor);\n }\n\n if (views.length == 1) {\n gl.uniformMatrix4fv(program.uniform.PROJECTION_MATRIX, false, views[0].projectionMatrix);\n gl.uniformMatrix4fv(program.uniform.VIEW_MATRIX, false, views[0].viewMatrix);\n gl.uniform3fv(program.uniform.CAMERA_POSITION, this._cameraPositions[0]);\n gl.uniform1i(program.uniform.EYE_INDEX, views[0].eyeIndex);\n }\n }\n\n if (material != primitive._material) {\n this._bindMaterialState(primitive._material, material);\n primitive._material.bind(gl, program, material);\n material = primitive._material;\n }\n\n if (this._vaoExt) {\n if (primitive._vao) {\n this._vaoExt.bindVertexArrayOES(primitive._vao);\n } else {\n primitive._vao = this._vaoExt.createVertexArrayOES();\n this._vaoExt.bindVertexArrayOES(primitive._vao);\n this._bindPrimitive(primitive);\n }\n } else {\n this._bindPrimitive(primitive, attribMask);\n attribMask = primitive._attributeMask;\n }\n\n for (let i = 0; i < views.length; ++i) {\n let view = views[i];\n if (views.length > 1) {\n if (view.viewport) {\n let vp = view.viewport;\n gl.viewport(vp.x, vp.y, vp.width, vp.height);\n }\n gl.uniformMatrix4fv(program.uniform.PROJECTION_MATRIX, false, view.projectionMatrix);\n gl.uniformMatrix4fv(program.uniform.VIEW_MATRIX, false, view.viewMatrix);\n gl.uniform3fv(program.uniform.CAMERA_POSITION, this._cameraPositions[i]);\n gl.uniform1i(program.uniform.EYE_INDEX, view.eyeIndex);\n }\n\n for (let instance of primitive._instances) {\n if (instance._activeFrameId != this._frameId) {\n continue;\n }\n\n gl.uniformMatrix4fv(program.uniform.MODEL_MATRIX, false, instance.worldMatrix);\n\n if (primitive._indexBuffer) {\n gl.drawElements(primitive._mode, primitive._elementCount,\n primitive._indexType, primitive._indexByteOffset);\n } else {\n gl.drawArrays(primitive._mode, 0, primitive._elementCount);\n }\n }\n }\n }\n }\n\n _getRenderTexture(texture) {\n if (!texture) {\n return null;\n }\n\n let key = texture.textureKey;\n if (!key) {\n throw new Error('Texure does not have a valid key');\n }\n\n if (key in this._textureCache) {\n return this._textureCache[key];\n } else {\n let gl = this._gl;\n let textureHandle = gl.createTexture();\n\n let renderTexture = new RenderTexture(textureHandle);\n this._textureCache[key] = renderTexture;\n\n if (texture instanceof DataTexture) {\n gl.bindTexture(gl.TEXTURE_2D, textureHandle);\n gl.texImage2D(gl.TEXTURE_2D, 0, texture.format, texture.width, texture.height,\n 0, texture.format, texture._type, texture._data);\n this._setSamplerParameters(texture);\n renderTexture._complete = true;\n } else {\n texture.waitForComplete().then(() => {\n gl.bindTexture(gl.TEXTURE_2D, textureHandle);\n gl.texImage2D(gl.TEXTURE_2D, 0, texture.format, texture.format, gl.UNSIGNED_BYTE, texture.source);\n this._setSamplerParameters(texture);\n renderTexture._complete = true;\n\n if (texture instanceof VideoTexture) {\n // Once the video starts playing, set a callback to update it's\n // contents each frame.\n texture._video.addEventListener('playing', () => {\n renderTexture._activeCallback = () => {\n if (!texture._video.paused && !texture._video.waiting) {\n gl.bindTexture(gl.TEXTURE_2D, textureHandle);\n gl.texImage2D(gl.TEXTURE_2D, 0, texture.format, texture.format, gl.UNSIGNED_BYTE, texture.source);\n }\n };\n });\n }\n });\n }\n\n return renderTexture;\n }\n }\n\n _setSamplerParameters(texture) {\n let gl = this._gl;\n\n let sampler = texture.sampler;\n let powerOfTwo = isPowerOfTwo(texture.width) && isPowerOfTwo(texture.height);\n let mipmap = powerOfTwo && texture.mipmap;\n if (mipmap) {\n gl.generateMipmap(gl.TEXTURE_2D);\n }\n\n let minFilter = sampler.minFilter || (mipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);\n let wrapS = sampler.wrapS || (powerOfTwo ? gl.REPEAT : gl.CLAMP_TO_EDGE);\n let wrapT = sampler.wrapT || (powerOfTwo ? gl.REPEAT : gl.CLAMP_TO_EDGE);\n\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, sampler.magFilter || gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT);\n }\n\n _getProgramKey(name, defines) {\n let key = `${name}:`;\n\n for (let define in defines) {\n key += `${define}=${defines[define]},`;\n }\n\n return key;\n }\n\n _getMaterialProgram(material, renderPrimitive) {\n let materialName = material.materialName;\n let vertexSource = material.vertexSource;\n let fragmentSource = material.fragmentSource;\n\n // These should always be defined for every material\n if (materialName == null) {\n throw new Error('Material does not have a name');\n }\n if (vertexSource == null) {\n throw new Error(`Material \"${materialName}\" does not have a vertex source`);\n }\n if (fragmentSource == null) {\n throw new Error(`Material \"${materialName}\" does not have a fragment source`);\n }\n\n let defines = material.getProgramDefines(renderPrimitive);\n let key = this._getProgramKey(materialName, defines);\n\n if (key in this._programCache) {\n return this._programCache[key];\n } else {\n let multiview = false; // Handle this dynamically later\n let fullVertexSource = vertexSource;\n fullVertexSource += multiview ? VERTEX_SHADER_MULTI_ENTRY :\n VERTEX_SHADER_SINGLE_ENTRY;\n\n let precisionMatch = fragmentSource.match(PRECISION_REGEX);\n let fragPrecisionHeader = precisionMatch ? '' : `precision ${this._defaultFragPrecision} float;\\n`;\n\n let fullFragmentSource = fragPrecisionHeader + fragmentSource;\n fullFragmentSource += FRAGMENT_SHADER_ENTRY;\n\n let program = new Program(this._gl, fullVertexSource, fullFragmentSource, ATTRIB, defines);\n this._programCache[key] = program;\n\n program.onNextUse((program) => {\n // Bind the samplers to the right texture index. This is constant for\n // the lifetime of the program.\n for (let i = 0; i < material._samplers.length; ++i) {\n let sampler = material._samplers[i];\n let uniform = program.uniform[sampler._uniformName];\n if (uniform) {\n this._gl.uniform1i(uniform, i);\n }\n }\n });\n\n return program;\n }\n }\n\n _bindPrimitive(primitive, attribMask) {\n let gl = this._gl;\n\n // If the active attributes have changed then update the active set.\n if (attribMask != primitive._attributeMask) {\n for (let attrib in ATTRIB) {\n if (primitive._attributeMask & ATTRIB_MASK[attrib]) {\n gl.enableVertexAttribArray(ATTRIB[attrib]);\n } else {\n gl.disableVertexAttribArray(ATTRIB[attrib]);\n }\n }\n }\n\n // Bind the primitive attributes and indices.\n for (let attributeBuffer of primitive._attributeBuffers) {\n gl.bindBuffer(gl.ARRAY_BUFFER, attributeBuffer._buffer._buffer);\n for (let attrib of attributeBuffer._attributes) {\n gl.vertexAttribPointer(\n attrib._attrib_index, attrib._componentCount, attrib._componentType,\n attrib._normalized, attrib._stride, attrib._byteOffset);\n }\n }\n\n if (primitive._indexBuffer) {\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, primitive._indexBuffer._buffer);\n } else {\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);\n }\n }\n\n _bindMaterialState(material, prevMaterial = null) {\n let gl = this._gl;\n\n let state = material._state;\n let prevState = prevMaterial ? prevMaterial._state : ~state;\n\n // Return early if both materials use identical state\n if (state == prevState) {\n return;\n }\n\n // Any caps bits changed?\n if (material._capsDiff(prevState)) {\n setCap(gl, gl.CULL_FACE, CAP.CULL_FACE, prevState, state);\n setCap(gl, gl.BLEND, CAP.BLEND, prevState, state);\n setCap(gl, gl.DEPTH_TEST, CAP.DEPTH_TEST, prevState, state);\n setCap(gl, gl.STENCIL_TEST, CAP.STENCIL_TEST, prevState, state);\n\n let colorMaskChange = (state & CAP.COLOR_MASK) - (prevState & CAP.COLOR_MASK);\n if (colorMaskChange) {\n let mask = colorMaskChange > 1;\n this._colorMaskNeedsReset = !mask;\n gl.colorMask(mask, mask, mask, mask);\n }\n\n let depthMaskChange = (state & CAP.DEPTH_MASK) - (prevState & CAP.DEPTH_MASK);\n if (depthMaskChange) {\n this._depthMaskNeedsReset = !(depthMaskChange > 1);\n gl.depthMask(depthMaskChange > 1);\n }\n\n let stencilMaskChange = (state & CAP.STENCIL_MASK) - (prevState & CAP.STENCIL_MASK);\n if (stencilMaskChange) {\n gl.stencilMask(stencilMaskChange > 1);\n }\n }\n\n // Blending enabled and blend func changed?\n if (material._blendDiff(prevState)) {\n gl.blendFunc(material.blendFuncSrc, material.blendFuncDst);\n }\n\n // Depth testing enabled and depth func changed?\n if (material._depthFuncDiff(prevState)) {\n gl.depthFunc(material.depthFunc);\n }\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nconst GL = WebGLRenderingContext; // For enums\n\nexport class TextureSampler {\n constructor() {\n this.minFilter = null;\n this.magFilter = null;\n this.wrapS = null;\n this.wrapT = null;\n }\n}\n\nexport class Texture {\n constructor() {\n this.sampler = new TextureSampler();\n this.mipmap = true;\n // TODO: Anisotropy\n }\n\n get format() {\n return GL.RGBA;\n }\n\n get width() {\n return 0;\n }\n\n get height() {\n return 0;\n }\n\n get textureKey() {\n return null;\n }\n}\n\nexport class ImageTexture extends Texture {\n constructor(img) {\n super();\n\n this._img = img;\n this._imgBitmap = null;\n\n if (img.src && img.complete) {\n if (img.naturalWidth) {\n this._promise = this._finishImage();\n } else {\n this._promise = Promise.reject('Image provided had failed to load.');\n }\n } else {\n this._promise = new Promise((resolve, reject) => {\n img.addEventListener('load', () => resolve(this._finishImage()));\n img.addEventListener('error', reject);\n });\n }\n }\n\n _finishImage() {\n if (window.createImageBitmap) {\n return window.createImageBitmap(this._img).then((imgBitmap) => {\n this._imgBitmap = imgBitmap;\n return Promise.resolve(this);\n });\n }\n return Promise.resolve(this);\n }\n\n get format() {\n // TODO: Can be RGB in some cases.\n return GL.RGBA;\n }\n\n get width() {\n return this._img.width;\n }\n\n get height() {\n return this._img.height;\n }\n\n waitForComplete() {\n return this._promise;\n }\n\n get textureKey() {\n return this._img.src;\n }\n\n get source() {\n return this._imgBitmap || this._img;\n }\n}\n\nexport class UrlTexture extends ImageTexture {\n constructor(url) {\n let img = new Image();\n super(img);\n img.src = url;\n }\n}\n\nexport class BlobTexture extends ImageTexture {\n constructor(blob) {\n let img = new Image();\n super(img);\n img.src = window.URL.createObjectURL(blob);\n }\n}\n\nexport class VideoTexture extends Texture {\n constructor(video) {\n super();\n\n this._video = video;\n\n if (video.readyState >= 2) {\n this._promise = Promise.resolve(this);\n } else if (video.error) {\n this._promise = Promise.reject(video.error);\n } else {\n this._promise = new Promise((resolve, reject) => {\n video.addEventListener('loadeddata', () => resolve(this));\n video.addEventListener('error', reject);\n });\n }\n }\n\n get format() {\n // TODO: Can be RGB in some cases.\n return GL.RGBA;\n }\n\n get width() {\n return this._video.videoWidth;\n }\n\n get height() {\n return this._video.videoHeight;\n }\n\n waitForComplete() {\n return this._promise;\n }\n\n get textureKey() {\n return this._video.src;\n }\n\n get source() {\n return this._video;\n }\n}\n\nlet nextDataTextureIndex = 0;\n\nexport class DataTexture extends Texture {\n constructor(data, width, height, format = GL.RGBA, type = GL.UNSIGNED_BYTE) {\n super();\n\n this._data = data;\n this._width = width;\n this._height = height;\n this._format = format;\n this._type = type;\n this._key = `DATA_${nextDataTextureIndex}`;\n nextDataTextureIndex++;\n }\n\n get format() {\n return this._format;\n }\n\n get width() {\n return this._width;\n }\n\n get height() {\n return this._height;\n }\n\n get textureKey() {\n return this._key;\n }\n}\n\nexport class ColorTexture extends DataTexture {\n constructor(r, g, b, a) {\n let colorData = new Uint8Array([r*255.0, g*255.0, b*255.0, a*255.0]);\n super(colorData, 1, 1);\n\n this.mipmap = false;\n this._key = `COLOR_${colorData[0]}_${colorData[1]}_${colorData[2]}_${colorData[3]}`;\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nexport {Node} from './core/node.js';\nexport {Renderer, createWebGLContext} from './core/renderer.js';\nexport {UrlTexture} from './core/texture.js';\n\nexport {PrimitiveStream} from './geometry/primitive-stream.js';\nexport {BoxBuilder} from './geometry/box-builder.js';\n\nexport {PbrMaterial} from './materials/pbr.js';\n\nexport {mat4, mat3, vec3, vec4, quat} from './math/gl-matrix.js';\n\nexport {BoundsRenderer} from './nodes/bounds-renderer.js';\nexport {ButtonNode} from './nodes/button.js';\nexport {DropShadowNode} from './nodes/drop-shadow.js';\nexport {CubeSeaNode} from './nodes/cube-sea.js';\nexport {Gltf2Node} from './nodes/gltf2.js';\nexport {SkyboxNode} from './nodes/skybox.js';\nexport {VideoNode} from './nodes/video.js';\n\nexport {WebXRView, Scene} from './scenes/scene.js';\n\nexport {FallbackHelper} from './util/fallback-helper.js';\nexport {QueryArgs} from './util/query-args.js';\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {GeometryBuilderBase} from './primitive-stream.js';\n\nexport class BoxBuilder extends GeometryBuilderBase {\n pushBox(min, max) {\n let stream = this.primitiveStream;\n\n let w = max[0] - min[0];\n let h = max[1] - min[1];\n let d = max[2] - min[2];\n\n let wh = w * 0.5;\n let hh = h * 0.5;\n let dh = d * 0.5;\n\n let cx = min[0] + wh;\n let cy = min[1] + hh;\n let cz = min[2] + dh;\n\n stream.startGeometry();\n\n // Bottom\n let idx = stream.nextVertexIndex;\n stream.pushTriangle(idx, idx+1, idx+2);\n stream.pushTriangle(idx, idx+2, idx+3);\n\n // X Y Z U V NX NY NZ\n stream.pushVertex(-wh+cx, -hh+cy, -dh+cz, 0.0, 1.0, 0.0, -1.0, 0.0);\n stream.pushVertex(+wh+cx, -hh+cy, -dh+cz, 1.0, 1.0, 0.0, -1.0, 0.0);\n stream.pushVertex(+wh+cx, -hh+cy, +dh+cz, 1.0, 0.0, 0.0, -1.0, 0.0);\n stream.pushVertex(-wh+cx, -hh+cy, +dh+cz, 0.0, 0.0, 0.0, -1.0, 0.0);\n\n // Top\n idx = stream.nextVertexIndex;\n stream.pushTriangle(idx, idx+2, idx+1);\n stream.pushTriangle(idx, idx+3, idx+2);\n\n stream.pushVertex(-wh+cx, +hh+cy, -dh+cz, 0.0, 0.0, 0.0, 1.0, 0.0);\n stream.pushVertex(+wh+cx, +hh+cy, -dh+cz, 1.0, 0.0, 0.0, 1.0, 0.0);\n stream.pushVertex(+wh+cx, +hh+cy, +dh+cz, 1.0, 1.0, 0.0, 1.0, 0.0);\n stream.pushVertex(-wh+cx, +hh+cy, +dh+cz, 0.0, 1.0, 0.0, 1.0, 0.0);\n\n // Left\n idx = stream.nextVertexIndex;\n stream.pushTriangle(idx, idx+2, idx+1);\n stream.pushTriangle(idx, idx+3, idx+2);\n\n stream.pushVertex(-wh+cx, -hh+cy, -dh+cz, 0.0, 1.0, -1.0, 0.0, 0.0);\n stream.pushVertex(-wh+cx, +hh+cy, -dh+cz, 0.0, 0.0, -1.0, 0.0, 0.0);\n stream.pushVertex(-wh+cx, +hh+cy, +dh+cz, 1.0, 0.0, -1.0, 0.0, 0.0);\n stream.pushVertex(-wh+cx, -hh+cy, +dh+cz, 1.0, 1.0, -1.0, 0.0, 0.0);\n\n // Right\n idx = stream.nextVertexIndex;\n stream.pushTriangle(idx, idx+1, idx+2);\n stream.pushTriangle(idx, idx+2, idx+3);\n\n stream.pushVertex(+wh+cx, -hh+cy, -dh+cz, 1.0, 1.0, 1.0, 0.0, 0.0);\n stream.pushVertex(+wh+cx, +hh+cy, -dh+cz, 1.0, 0.0, 1.0, 0.0, 0.0);\n stream.pushVertex(+wh+cx, +hh+cy, +dh+cz, 0.0, 0.0, 1.0, 0.0, 0.0);\n stream.pushVertex(+wh+cx, -hh+cy, +dh+cz, 0.0, 1.0, 1.0, 0.0, 0.0);\n\n // Back\n idx = stream.nextVertexIndex;\n stream.pushTriangle(idx, idx+2, idx+1);\n stream.pushTriangle(idx, idx+3, idx+2);\n\n stream.pushVertex(-wh+cx, -hh+cy, -dh+cz, 1.0, 1.0, 0.0, 0.0, -1.0);\n stream.pushVertex(+wh+cx, -hh+cy, -dh+cz, 0.0, 1.0, 0.0, 0.0, -1.0);\n stream.pushVertex(+wh+cx, +hh+cy, -dh+cz, 0.0, 0.0, 0.0, 0.0, -1.0);\n stream.pushVertex(-wh+cx, +hh+cy, -dh+cz, 1.0, 0.0, 0.0, 0.0, -1.0);\n\n // Front\n idx = stream.nextVertexIndex;\n stream.pushTriangle(idx, idx+1, idx+2);\n stream.pushTriangle(idx, idx+2, idx+3);\n\n stream.pushVertex(-wh+cx, -hh+cy, +dh+cz, 0.0, 1.0, 0.0, 0.0, 1.0);\n stream.pushVertex(+wh+cx, -hh+cy, +dh+cz, 1.0, 1.0, 0.0, 0.0, 1.0);\n stream.pushVertex(+wh+cx, +hh+cy, +dh+cz, 1.0, 0.0, 0.0, 0.0, 1.0);\n stream.pushVertex(-wh+cx, +hh+cy, +dh+cz, 0.0, 0.0, 0.0, 0.0, 1.0);\n\n stream.endGeometry();\n }\n\n pushCube(center = [0, 0, 0], size = 1.0) {\n let hs = size * 0.5;\n this.pushBox([center[0] - hs, center[1] - hs, center[2] - hs],\n [center[0] + hs, center[1] + hs, center[2] + hs]);\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\nimport {mat3, vec3} from '../math/gl-matrix.js';\n\nconst GL = WebGLRenderingContext; // For enums\n\nconst tempVec3 = vec3.create();\n\nexport class PrimitiveStream {\n constructor(options) {\n this._vertices = [];\n this._indices = [];\n\n this._geometryStarted = false;\n\n this._vertexOffset = 0;\n this._vertexIndex = 0;\n this._highIndex = 0;\n\n this._flipWinding = false;\n this._invertNormals = false;\n this._transform = null;\n this._normalTransform = null;\n this._min = null;\n this._max = null;\n }\n\n set flipWinding(value) {\n if (this._geometryStarted) {\n throw new Error(`Cannot change flipWinding before ending the current geometry.`);\n }\n this._flipWinding = value;\n }\n\n get flipWinding() {\n this._flipWinding;\n }\n\n set invertNormals(value) {\n if (this._geometryStarted) {\n throw new Error(`Cannot change invertNormals before ending the current geometry.`);\n }\n this._invertNormals = value;\n }\n\n get invertNormals() {\n this._invertNormals;\n }\n\n set transform(value) {\n if (this._geometryStarted) {\n throw new Error(`Cannot change transform before ending the current geometry.`);\n }\n this._transform = value;\n if (this._transform) {\n if (!this._normalTransform) {\n this._normalTransform = mat3.create();\n }\n mat3.fromMat4(this._normalTransform, this._transform);\n }\n }\n\n get transform() {\n this._transform;\n }\n\n startGeometry() {\n if (this._geometryStarted) {\n throw new Error(`Attempted to start a new geometry before the previous one was ended.`);\n }\n\n this._geometryStarted = true;\n this._vertexIndex = 0;\n this._highIndex = 0;\n }\n\n endGeometry() {\n if (!this._geometryStarted) {\n throw new Error(`Attempted to end a geometry before one was started.`);\n }\n\n if (this._highIndex >= this._vertexIndex) {\n throw new Error(`Geometry contains indices that are out of bounds.\n (Contains an index of ${this._highIndex} when the vertex count is ${this._vertexIndex})`);\n }\n\n this._geometryStarted = false;\n this._vertexOffset += this._vertexIndex;\n\n // TODO: Anything else need to be done to finish processing here?\n }\n\n pushVertex(x, y, z, u = 0, v = 0, nx = 0, ny = 0, nz = 1) {\n if (!this._geometryStarted) {\n throw new Error(`Cannot push vertices before calling startGeometry().`);\n }\n\n // Transform the incoming vertex if we have a transformation matrix\n if (this._transform) {\n tempVec3[0] = x;\n tempVec3[1] = y;\n tempVec3[2] = z;\n vec3.transformMat4(tempVec3, tempVec3, this._transform);\n x = tempVec3[0];\n y = tempVec3[1];\n z = tempVec3[2];\n\n tempVec3[0] = nx;\n tempVec3[1] = ny;\n tempVec3[2] = nz;\n vec3.transformMat3(tempVec3, tempVec3, this._normalTransform);\n nx = tempVec3[0];\n ny = tempVec3[1];\n nz = tempVec3[2];\n }\n\n if (this._invertNormals) {\n nx *= -1.0;\n ny *= -1.0;\n nz *= -1.0;\n }\n\n this._vertices.push(x, y, z, u, v, nx, ny, nz);\n\n if (this._min) {\n this._min[0] = Math.min(this._min[0], x);\n this._min[1] = Math.min(this._min[1], y);\n this._min[2] = Math.min(this._min[2], z);\n this._max[0] = Math.max(this._max[0], x);\n this._max[1] = Math.max(this._max[1], y);\n this._max[2] = Math.max(this._max[2], z);\n } else {\n this._min = vec3.fromValues(x, y, z);\n this._max = vec3.fromValues(x, y, z);\n }\n\n return this._vertexIndex++;\n }\n\n get nextVertexIndex() {\n return this._vertexIndex;\n }\n\n pushTriangle(idxA, idxB, idxC) {\n if (!this._geometryStarted) {\n throw new Error(`Cannot push triangles before calling startGeometry().`);\n }\n\n this._highIndex = Math.max(this._highIndex, idxA, idxB, idxC);\n\n idxA += this._vertexOffset;\n idxB += this._vertexOffset;\n idxC += this._vertexOffset;\n\n if (this._flipWinding) {\n this._indices.push(idxC, idxB, idxA);\n } else {\n this._indices.push(idxA, idxB, idxC);\n }\n }\n\n clear() {\n if (this._geometryStarted) {\n throw new Error(`Cannot clear before ending the current geometry.`);\n }\n\n this._vertices = [];\n this._indices = [];\n this._vertexOffset = 0;\n this._min = null;\n this._max = null;\n }\n\n finishPrimitive(renderer) {\n if (!this._vertexOffset) {\n throw new Error(`Attempted to call finishPrimitive() before creating any geometry.`);\n }\n\n let vertexBuffer = renderer.createRenderBuffer(GL.ARRAY_BUFFER, new Float32Array(this._vertices));\n let indexBuffer = renderer.createRenderBuffer(GL.ELEMENT_ARRAY_BUFFER, new Uint16Array(this._indices));\n\n let attribs = [\n new PrimitiveAttribute('POSITION', vertexBuffer, 3, GL.FLOAT, 32, 0),\n new PrimitiveAttribute('TEXCOORD_0', vertexBuffer, 2, GL.FLOAT, 32, 12),\n new PrimitiveAttribute('NORMAL', vertexBuffer, 3, GL.FLOAT, 32, 20),\n ];\n\n let primitive = new Primitive(attribs, this._indices.length);\n primitive.setIndexBuffer(indexBuffer);\n primitive.setBounds(this._min, this._max);\n\n return primitive;\n }\n}\n\nexport class GeometryBuilderBase {\n constructor(primitiveStream) {\n if (primitiveStream) {\n this._stream = primitiveStream;\n } else {\n this._stream = new PrimitiveStream();\n }\n }\n\n set primitiveStream(value) {\n this._stream = value;\n }\n\n get primitiveStream() {\n return this._stream;\n }\n\n finishPrimitive(renderer) {\n return this._stream.finishPrimitive(renderer);\n }\n\n clear() {\n this._stream.clear();\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {PbrMaterial} from '../materials/pbr.js';\nimport {Node} from '../core/node.js';\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\nimport {ImageTexture, ColorTexture} from '../core/texture.js';\n\nconst GL = WebGLRenderingContext; // For enums\n\nconst GLB_MAGIC = 0x46546C67;\nconst CHUNK_TYPE = {\n JSON: 0x4E4F534A,\n BIN: 0x004E4942,\n};\n\nfunction isAbsoluteUri(uri) {\n let absRegEx = new RegExp('^'+window.location.protocol, 'i');\n return !!uri.match(absRegEx);\n}\n\nfunction isDataUri(uri) {\n let dataRegEx = /^data:/;\n return !!uri.match(dataRegEx);\n}\n\nfunction resolveUri(uri, baseUrl) {\n if (isAbsoluteUri(uri) || isDataUri(uri)) {\n return uri;\n }\n return baseUrl + uri;\n}\n\nfunction getComponentCount(type) {\n switch (type) {\n case 'SCALAR': return 1;\n case 'VEC2': return 2;\n case 'VEC3': return 3;\n case 'VEC4': return 4;\n default: return 0;\n }\n}\n\n/**\n * Gltf2SceneLoader\n * Loads glTF 2.0 scenes into a renderable node tree.\n */\n\nexport class Gltf2Loader {\n constructor(renderer) {\n this.renderer = renderer;\n this._gl = renderer._gl;\n }\n\n loadFromUrl(url) {\n return fetch(url)\n .then((response) => {\n let i = url.lastIndexOf('/');\n let baseUrl = (i !== 0) ? url.substring(0, i + 1) : '';\n\n if (url.endsWith('.gltf')) {\n return response.json().then((json) => {\n return this.loadFromJson(json, baseUrl);\n });\n } else if (url.endsWith('.glb')) {\n return response.arrayBuffer().then((arrayBuffer) => {\n return this.loadFromBinary(arrayBuffer, baseUrl);\n });\n } else {\n throw new Error('Unrecognized file extension');\n }\n });\n }\n\n loadFromBinary(arrayBuffer, baseUrl) {\n let headerView = new DataView(arrayBuffer, 0, 12);\n let magic = headerView.getUint32(0, true);\n let version = headerView.getUint32(4, true);\n let length = headerView.getUint32(8, true);\n\n if (magic != GLB_MAGIC) {\n throw new Error('Invalid magic string in binary header.');\n }\n\n if (version != 2) {\n throw new Error('Incompatible version in binary header.');\n }\n\n let chunks = {};\n let chunkOffset = 12;\n while (chunkOffset < length) {\n let chunkHeaderView = new DataView(arrayBuffer, chunkOffset, 8);\n let chunkLength = chunkHeaderView.getUint32(0, true);\n let chunkType = chunkHeaderView.getUint32(4, true);\n chunks[chunkType] = arrayBuffer.slice(chunkOffset + 8, chunkOffset + 8 + chunkLength);\n chunkOffset += chunkLength + 8;\n }\n\n if (!chunks[CHUNK_TYPE.JSON]) {\n throw new Error('File contained no json chunk.');\n }\n\n let decoder = new TextDecoder('utf-8');\n let jsonString = decoder.decode(chunks[CHUNK_TYPE.JSON]);\n let json = JSON.parse(jsonString);\n return this.loadFromJson(json, baseUrl, chunks[CHUNK_TYPE.BIN]);\n }\n\n loadFromJson(json, baseUrl, binaryChunk) {\n if (!json.asset) {\n throw new Error('Missing asset description.');\n }\n\n if (json.asset.minVersion != '2.0' && json.asset.version != '2.0') {\n throw new Error('Incompatible asset version.');\n }\n\n let buffers = [];\n if (binaryChunk) {\n buffers[0] = new Gltf2Resource({}, baseUrl, binaryChunk);\n } else {\n for (let buffer of json.buffers) {\n buffers.push(new Gltf2Resource(buffer, baseUrl));\n }\n }\n\n let bufferViews = [];\n for (let bufferView of json.bufferViews) {\n bufferViews.push(new Gltf2BufferView(bufferView, buffers));\n }\n\n let images = [];\n if (json.images) {\n for (let image of json.images) {\n images.push(new Gltf2Resource(image, baseUrl));\n }\n }\n\n let textures = [];\n if (json.textures) {\n for (let texture of json.textures) {\n let image = images[texture.source];\n let glTexture = image.texture(bufferViews);\n if (texture.sampler) {\n let sampler = sampler[texture.sampler];\n glTexture.sampler.minFilter = sampler.minFilter;\n glTexture.sampler.magFilter = sampler.magFilter;\n glTexture.sampler.wrapS = sampler.wrapS;\n glTexture.sampler.wrapT = sampler.wrapT;\n }\n textures.push(glTexture);\n }\n }\n\n function getTexture(textureInfo) {\n if (!textureInfo) {\n return null;\n }\n return textures[textureInfo.index];\n }\n\n let materials = [];\n if (json.materials) {\n for (let material of json.materials) {\n let glMaterial = new PbrMaterial();\n let pbr = material.pbrMetallicRoughness || {};\n\n glMaterial.baseColorFactor.value = pbr.baseColorFactor || [1, 1, 1, 1];\n glMaterial.baseColor.texture = getTexture(pbr.baseColorTexture);\n glMaterial.metallicRoughnessFactor.value = [\n pbr.metallicFactor || 1.0,\n pbr.roughnessFactor || 1.0,\n ];\n glMaterial.metallicRoughness.texture = getTexture(pbr.metallicRoughnessTexture);\n glMaterial.normal.texture = getTexture(json.normalTexture);\n glMaterial.occlusion.texture = getTexture(json.occlusionTexture);\n glMaterial.occlusionStrength.value = (json.occlusionTexture && json.occlusionTexture.strength) ?\n json.occlusionTexture.strength : 1.0;\n glMaterial.emissiveFactor.value = material.emissiveFactor || [0, 0, 0];\n glMaterial.emissive.texture = getTexture(json.emissiveTexture);\n if (!glMaterial.emissive.texture && json.emissiveFactor) {\n glMaterial.emissive.texture = new ColorTexture(1.0, 1.0, 1.0, 1.0);\n }\n\n switch (material.alphaMode) {\n case 'BLEND':\n glMaterial.state.blend = true;\n break;\n case 'MASK':\n // Not really supported.\n glMaterial.state.blend = true;\n break;\n default: // Includes 'OPAQUE'\n glMaterial.state.blend = false;\n }\n\n // glMaterial.alpha_mode = material.alphaMode;\n // glMaterial.alpha_cutoff = material.alphaCutoff;\n glMaterial.state.cullFace = !(material.doubleSided);\n\n materials.push(glMaterial);\n }\n }\n\n let accessors = json.accessors;\n\n let meshes = [];\n for (let mesh of json.meshes) {\n let glMesh = new Gltf2Mesh();\n meshes.push(glMesh);\n\n for (let primitive of mesh.primitives) {\n let material = null;\n if ('material' in primitive) {\n material = materials[primitive.material];\n } else {\n // Create a \"default\" material if the primitive has none.\n material = new PbrMaterial();\n }\n\n let attributes = [];\n let elementCount = 0;\n /* let glPrimitive = new Gltf2Primitive(primitive, material);\n glMesh.primitives.push(glPrimitive); */\n\n let min = null;\n let max = null;\n\n for (let name in primitive.attributes) {\n let accessor = accessors[primitive.attributes[name]];\n let bufferView = bufferViews[accessor.bufferView];\n elementCount = accessor.count;\n\n let glAttribute = new PrimitiveAttribute(\n name,\n bufferView.renderBuffer(this.renderer, GL.ARRAY_BUFFER),\n getComponentCount(accessor.type),\n accessor.componentType,\n bufferView.byteStride || 0,\n accessor.byteOffset || 0\n );\n glAttribute.normalized = accessor.normalized || false;\n\n if (name == 'POSITION') {\n min = accessor.min;\n max = accessor.max;\n }\n\n attributes.push(glAttribute);\n }\n\n let glPrimitive = new Primitive(attributes, elementCount, primitive.mode);\n\n if ('indices' in primitive) {\n let accessor = accessors[primitive.indices];\n let bufferView = bufferViews[accessor.bufferView];\n\n glPrimitive.setIndexBuffer(\n bufferView.renderBuffer(this.renderer, GL.ELEMENT_ARRAY_BUFFER),\n accessor.byteOffset || 0,\n accessor.componentType\n );\n glPrimitive.indexType = accessor.componentType;\n glPrimitive.indexByteOffset = accessor.byteOffset || 0;\n glPrimitive.elementCount = accessor.count;\n }\n\n if (min && max) {\n glPrimitive.setBounds(min, max);\n }\n\n // After all the attributes have been processed, get a program that is\n // appropriate for both the material and the primitive attributes.\n glMesh.primitives.push(\n this.renderer.createRenderPrimitive(glPrimitive, material));\n }\n }\n\n let sceneNode = new Node();\n let scene = json.scenes[json.scene];\n for (let nodeId of scene.nodes) {\n let node = json.nodes[nodeId];\n sceneNode.addNode(\n this.processNodes(node, json.nodes, meshes));\n }\n\n return sceneNode;\n }\n\n processNodes(node, nodes, meshes) {\n let glNode = new Node();\n glNode.name = node.name;\n\n if ('mesh' in node) {\n let mesh = meshes[node.mesh];\n for (let primitive of mesh.primitives) {\n glNode.addRenderPrimitive(primitive);\n }\n }\n\n if (node.matrix) {\n glNode.matrix = new Float32Array(node.matrix);\n } else if (node.translation || node.rotation || node.scale) {\n if (node.translation) {\n glNode.translation = new Float32Array(node.translation);\n }\n\n if (node.rotation) {\n glNode.rotation = new Float32Array(node.rotation);\n }\n\n if (node.scale) {\n glNode.scale = new Float32Array(node.scale);\n }\n }\n\n if (node.children) {\n for (let nodeId of node.children) {\n let node = nodes[nodeId];\n glNode.addNode(this.processNodes(node, nodes, meshes));\n }\n }\n\n return glNode;\n }\n}\n\nclass Gltf2Mesh {\n constructor() {\n this.primitives = [];\n }\n}\n\nclass Gltf2BufferView {\n constructor(json, buffers) {\n this.buffer = buffers[json.buffer];\n this.byteOffset = json.byteOffset || 0;\n this.byteLength = json.byteLength || null;\n this.byteStride = json.byteStride;\n\n this._viewPromise = null;\n this._renderBuffer = null;\n }\n\n dataView() {\n if (!this._viewPromise) {\n this._viewPromise = this.buffer.arrayBuffer().then((arrayBuffer) => {\n return new DataView(arrayBuffer, this.byteOffset, this.byteLength);\n });\n }\n return this._viewPromise;\n }\n\n renderBuffer(renderer, target) {\n if (!this._renderBuffer) {\n this._renderBuffer = renderer.createRenderBuffer(target, this.dataView());\n }\n return this._renderBuffer;\n }\n}\n\nclass Gltf2Resource {\n constructor(json, baseUrl, arrayBuffer) {\n this.json = json;\n this.baseUrl = baseUrl;\n\n this._dataPromise = null;\n this._texture = null;\n if (arrayBuffer) {\n this._dataPromise = Promise.resolve(arrayBuffer);\n }\n }\n\n arrayBuffer() {\n if (!this._dataPromise) {\n if (isDataUri(this.json.uri)) {\n let base64String = this.json.uri.replace('data:application/octet-stream;base64,', '');\n let binaryArray = Uint8Array.from(atob(base64String), (c) => c.charCodeAt(0));\n this._dataPromise = Promise.resolve(binaryArray.buffer);\n return this._dataPromise;\n }\n\n this._dataPromise = fetch(resolveUri(this.json.uri, this.baseUrl))\n .then((response) => response.arrayBuffer());\n }\n return this._dataPromise;\n }\n\n texture(bufferViews) {\n if (!this._texture) {\n let img = new Image();\n this._texture = new ImageTexture(img);\n\n if (this.json.uri) {\n if (isDataUri(this.json.uri)) {\n img.src = this.json.uri;\n } else {\n img.src = `${this.baseUrl}${this.json.uri}`;\n }\n } else {\n let view = bufferViews[this.json.bufferView];\n view.dataView().then((dataView) => {\n let blob = new Blob([dataView], {type: this.json.mimeType});\n img.src = window.URL.createObjectURL(blob);\n });\n }\n }\n return this._texture;\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Material} from '../core/material.js';\nimport {ATTRIB_MASK} from '../core/renderer.js';\n\nconst VERTEX_SOURCE = `\nattribute vec3 POSITION, NORMAL;\nattribute vec2 TEXCOORD_0, TEXCOORD_1;\n\nuniform vec3 CAMERA_POSITION;\nuniform vec3 LIGHT_DIRECTION;\n\nvarying vec3 vLight; // Vector from vertex to light.\nvarying vec3 vView; // Vector from vertex to camera.\nvarying vec2 vTex;\n\n#ifdef USE_NORMAL_MAP\nattribute vec4 TANGENT;\nvarying mat3 vTBN;\n#else\nvarying vec3 vNorm;\n#endif\n\n#ifdef USE_VERTEX_COLOR\nattribute vec4 COLOR_0;\nvarying vec4 vCol;\n#endif\n\nvec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vec3 n = normalize(vec3(model * vec4(NORMAL, 0.0)));\n#ifdef USE_NORMAL_MAP\n vec3 t = normalize(vec3(model * vec4(TANGENT.xyz, 0.0)));\n vec3 b = cross(n, t) * TANGENT.w;\n vTBN = mat3(t, b, n);\n#else\n vNorm = n;\n#endif\n\n#ifdef USE_VERTEX_COLOR\n vCol = COLOR_0;\n#endif\n\n vTex = TEXCOORD_0;\n vec4 mPos = model * vec4(POSITION, 1.0);\n vLight = -LIGHT_DIRECTION;\n vView = CAMERA_POSITION - mPos.xyz;\n return proj * view * mPos;\n}`;\n\n// These equations are borrowed with love from this docs from Epic because I\n// just don't have anything novel to bring to the PBR scene.\n// http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf\nconst EPIC_PBR_FUNCTIONS = `\nvec3 lambertDiffuse(vec3 cDiff) {\n return cDiff / M_PI;\n}\n\nfloat specD(float a, float nDotH) {\n float aSqr = a * a;\n float f = ((nDotH * nDotH) * (aSqr - 1.0) + 1.0);\n return aSqr / (M_PI * f * f);\n}\n\nfloat specG(float roughness, float nDotL, float nDotV) {\n float k = (roughness + 1.0) * (roughness + 1.0) / 8.0;\n float gl = nDotL / (nDotL * (1.0 - k) + k);\n float gv = nDotV / (nDotV * (1.0 - k) + k);\n return gl * gv;\n}\n\nvec3 specF(float vDotH, vec3 F0) {\n float exponent = (-5.55473 * vDotH - 6.98316) * vDotH;\n float base = 2.0;\n return F0 + (1.0 - F0) * pow(base, exponent);\n}`;\n\nconst FRAGMENT_SOURCE = `\n#define M_PI 3.14159265\n\nuniform vec4 baseColorFactor;\n#ifdef USE_BASE_COLOR_MAP\nuniform sampler2D baseColorTex;\n#endif\n\nvarying vec3 vLight;\nvarying vec3 vView;\nvarying vec2 vTex;\n\n#ifdef USE_VERTEX_COLOR\nvarying vec4 vCol;\n#endif\n\n#ifdef USE_NORMAL_MAP\nuniform sampler2D normalTex;\nvarying mat3 vTBN;\n#else\nvarying vec3 vNorm;\n#endif\n\n#ifdef USE_METAL_ROUGH_MAP\nuniform sampler2D metallicRoughnessTex;\n#endif\nuniform vec2 metallicRoughnessFactor;\n\n#ifdef USE_OCCLUSION\nuniform sampler2D occlusionTex;\nuniform float occlusionStrength;\n#endif\n\n#ifdef USE_EMISSIVE_TEXTURE\nuniform sampler2D emissiveTex;\n#endif\nuniform vec3 emissiveFactor;\n\nuniform vec3 LIGHT_COLOR;\n\nconst vec3 dielectricSpec = vec3(0.04);\nconst vec3 black = vec3(0.0);\n\n${EPIC_PBR_FUNCTIONS}\n\nvec4 fragment_main() {\n#ifdef USE_BASE_COLOR_MAP\n vec4 baseColor = texture2D(baseColorTex, vTex) * baseColorFactor;\n#else\n vec4 baseColor = baseColorFactor;\n#endif\n\n#ifdef USE_VERTEX_COLOR\n baseColor *= vCol;\n#endif\n\n#ifdef USE_NORMAL_MAP\n vec3 n = texture2D(normalTex, vTex).rgb;\n n = normalize(vTBN * (2.0 * n - 1.0));\n#else\n vec3 n = normalize(vNorm);\n#endif\n\n#ifdef FULLY_ROUGH\n float metallic = 0.0;\n#else\n float metallic = metallicRoughnessFactor.x;\n#endif\n\n float roughness = metallicRoughnessFactor.y;\n\n#ifdef USE_METAL_ROUGH_MAP\n vec4 metallicRoughness = texture2D(metallicRoughnessTex, vTex);\n metallic *= metallicRoughness.b;\n roughness *= metallicRoughness.g;\n#endif\n \n vec3 l = normalize(vLight);\n vec3 v = normalize(vView);\n vec3 h = normalize(l+v);\n\n float nDotL = clamp(dot(n, l), 0.001, 1.0);\n float nDotV = abs(dot(n, v)) + 0.001;\n float nDotH = max(dot(n, h), 0.0);\n float vDotH = max(dot(v, h), 0.0);\n\n // From GLTF Spec\n vec3 cDiff = mix(baseColor.rgb * (1.0 - dielectricSpec.r), black, metallic); // Diffuse color\n vec3 F0 = mix(dielectricSpec, baseColor.rgb, metallic); // Specular color\n float a = roughness * roughness;\n\n#ifdef FULLY_ROUGH\n vec3 specular = F0 * 0.45;\n#else\n vec3 F = specF(vDotH, F0);\n float D = specD(a, nDotH);\n float G = specG(roughness, nDotL, nDotV);\n vec3 specular = (D * F * G) / (4.0 * nDotL * nDotV);\n#endif\n float halfLambert = dot(n, l) * 0.5 + 0.5;\n halfLambert *= halfLambert;\n\n vec3 color = (halfLambert * LIGHT_COLOR * lambertDiffuse(cDiff)) + specular;\n\n#ifdef USE_OCCLUSION\n float occlusion = texture2D(occlusionTex, vTex).r;\n color = mix(color, color * occlusion, occlusionStrength);\n#endif\n \n vec3 emissive = emissiveFactor;\n#ifdef USE_EMISSIVE_TEXTURE\n emissive *= texture2D(emissiveTex, vTex).rgb;\n#endif\n color += emissive;\n\n // gamma correction\n //color = pow(color, vec3(1.0/2.2));\n\n return vec4(color, baseColor.a);\n}`;\n\nexport class PbrMaterial extends Material {\n constructor() {\n super();\n\n this.baseColor = this.defineSampler('baseColorTex');\n this.metallicRoughness = this.defineSampler('metallicRoughnessTex');\n this.normal = this.defineSampler('normalTex');\n this.occlusion = this.defineSampler('occlusionTex');\n this.emissive = this.defineSampler('emissiveTex');\n\n this.baseColorFactor = this.defineUniform('baseColorFactor', [1.0, 1.0, 1.0, 1.0]);\n this.metallicRoughnessFactor = this.defineUniform('metallicRoughnessFactor', [1.0, 1.0]);\n this.occlusionStrength = this.defineUniform('occlusionStrength', 1.0);\n this.emissiveFactor = this.defineUniform('emissiveFactor', [0, 0, 0]);\n }\n\n get materialName() {\n return 'PBR';\n }\n\n get vertexSource() {\n return VERTEX_SOURCE;\n }\n\n get fragmentSource() {\n return FRAGMENT_SOURCE;\n }\n\n getProgramDefines(renderPrimitive) {\n let programDefines = {};\n\n if (renderPrimitive._attributeMask & ATTRIB_MASK.COLOR_0) {\n programDefines['USE_VERTEX_COLOR'] = 1;\n }\n\n if (renderPrimitive._attributeMask & ATTRIB_MASK.TEXCOORD_0) {\n if (this.baseColor.texture) {\n programDefines['USE_BASE_COLOR_MAP'] = 1;\n }\n\n if (this.normal.texture && (renderPrimitive._attributeMask & ATTRIB_MASK.TANGENT)) {\n programDefines['USE_NORMAL_MAP'] = 1;\n }\n\n if (this.metallicRoughness.texture) {\n programDefines['USE_METAL_ROUGH_MAP'] = 1;\n }\n\n if (this.occlusion.texture) {\n programDefines['USE_OCCLUSION'] = 1;\n }\n\n if (this.emissive.texture) {\n programDefines['USE_EMISSIVE_TEXTURE'] = 1;\n }\n }\n\n if ((!this.metallicRoughness.texture ||\n !(renderPrimitive._attributeMask & ATTRIB_MASK.TEXCOORD_0)) &&\n this.metallicRoughnessFactor.value[1] == 1.0) {\n programDefines['FULLY_ROUGH'] = 1;\n }\n\n return programDefines;\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport * as glMatrix from '../../node_modules/gl-matrix/src/gl-matrix/common.js';\nimport * as mat2 from '../../node_modules/gl-matrix/src/gl-matrix/mat2.js';\nimport * as mat2d from '../../node_modules/gl-matrix/src/gl-matrix/mat2d.js';\nimport * as mat3 from '../../node_modules/gl-matrix/src/gl-matrix/mat3.js';\nimport * as mat4 from '../../node_modules/gl-matrix/src/gl-matrix/mat4.js';\nimport * as quat from '../../node_modules/gl-matrix/src/gl-matrix/quat.js';\nimport * as quat2 from '../../node_modules/gl-matrix/src/gl-matrix/quat2.js';\nimport * as vec2 from '../../node_modules/gl-matrix/src/gl-matrix/vec2.js';\nimport * as vec3 from '../../node_modules/gl-matrix/src/gl-matrix/vec3.js';\nimport * as vec4 from '../../node_modules/gl-matrix/src/gl-matrix/vec4.js';\n\nexport {\n glMatrix,\n mat2,\n mat2d,\n mat3,\n mat4,\n quat,\n quat2,\n vec2,\n vec3,\n vec4,\n};\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {mat3, vec3} from './gl-matrix.js';\n\nlet normalMat = mat3.create();\n\nconst RAY_INTERSECTION_OFFSET = 0.02;\n\nexport class Ray {\n constructor(matrix = null) {\n this.origin = vec3.create();\n\n this._dir = vec3.create();\n this._dir[2] = -1.0;\n\n if (matrix) {\n vec3.transformMat4(this.origin, this.origin, matrix);\n mat3.fromMat4(normalMat, matrix);\n vec3.transformMat3(this._dir, this._dir, normalMat);\n }\n\n // To force the inverse and sign calculations.\n this.dir = this._dir;\n }\n\n get dir() {\n return this._dir;\n }\n\n set dir(value) {\n this._dir = vec3.copy(this._dir, value);\n vec3.normalize(this._dir, this._dir);\n\n this.inv_dir = vec3.fromValues(\n 1.0 / this._dir[0],\n 1.0 / this._dir[1],\n 1.0 / this._dir[2]);\n\n this.sign = [\n (this.inv_dir[0] < 0) ? 1 : 0,\n (this.inv_dir[1] < 0) ? 1 : 0,\n (this.inv_dir[2] < 0) ? 1 : 0,\n ];\n }\n\n // Borrowed from:\n // eslint-disable-next-line max-len\n // https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-box-intersection\n intersectsAABB(min, max) {\n let r = this;\n\n let bounds = [min, max];\n\n let tmin = (bounds[r.sign[0]][0] - r.origin[0]) * r.inv_dir[0];\n let tmax = (bounds[1-r.sign[0]][0] - r.origin[0]) * r.inv_dir[0];\n let tymin = (bounds[r.sign[1]][1] - r.origin[1]) * r.inv_dir[1];\n let tymax = (bounds[1-r.sign[1]][1] - r.origin[1]) * r.inv_dir[1];\n\n if ((tmin > tymax) || (tymin > tmax)) {\n return null;\n }\n if (tymin > tmin) {\n tmin = tymin;\n }\n if (tymax < tmax) {\n tmax = tymax;\n }\n\n let tzmin = (bounds[r.sign[2]][2] - r.origin[2]) * r.inv_dir[2];\n let tzmax = (bounds[1-r.sign[2]][2] - r.origin[2]) * r.inv_dir[2];\n\n if ((tmin > tzmax) || (tzmin > tmax)) {\n return null;\n }\n if (tzmin > tmin) {\n tmin = tzmin;\n }\n if (tzmax < tmax) {\n tmax = tzmax;\n }\n\n let t = -1;\n if (tmin > 0 && tmax > 0) {\n t = Math.min(tmin, tmax);\n } else if (tmin > 0) {\n t = tmin;\n } else if (tmax > 0) {\n t = tmax;\n } else {\n // Intersection is behind the ray origin.\n return null;\n }\n\n // Push ray intersection point back along the ray a bit so that cursors\n // don't accidentally intersect with the hit surface.\n t -= RAY_INTERSECTION_OFFSET;\n\n // Return the point where the ray first intersected with the AABB.\n let intersectionPoint = vec3.clone(this._dir);\n vec3.scale(intersectionPoint, intersectionPoint, t);\n vec3.add(intersectionPoint, intersectionPoint, this.origin);\n return intersectionPoint;\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n/*\nThis file renders a passed in XRStageBounds object and attempts\nto render geometry on the floor to indicate where the bounds is.\nXRStageBounds' `geometry` is a series of XRStageBoundsPoints (in\nclockwise-order) with `x` and `z` properties for each.\n*/\n\nimport {Material} from '../core/material.js';\nimport {Node} from '../core/node.js';\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\n\nconst GL = WebGLRenderingContext; // For enums\n\nclass BoundsMaterial extends Material {\n constructor() {\n super();\n\n this.state.blend = true;\n this.state.blendFuncSrc = GL.SRC_ALPHA;\n this.state.blendFuncDst = GL.ONE;\n this.state.depthTest = false;\n }\n\n get materialName() {\n return 'BOUNDS_RENDERER';\n }\n\n get vertexSource() {\n return `\n attribute vec2 POSITION;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n return proj * view * model * vec4(POSITION, 1.0);\n }`;\n }\n\n get fragmentSource() {\n return `\n precision mediump float;\n\n vec4 fragment_main() {\n return vec4(0.0, 1.0, 0.0, 0.3);\n }`;\n }\n}\n\nexport class BoundsRenderer extends Node {\n constructor() {\n super();\n\n this._stageBounds = null;\n }\n\n onRendererChanged(renderer) {\n this.stageBounds = this._stageBounds;\n }\n\n get stageBounds() {\n return this._stageBounds;\n }\n\n set stageBounds(stageBounds) {\n if (this._stageBounds) {\n this.clearRenderPrimitives();\n }\n this._stageBounds = stageBounds;\n if (!stageBounds || stageBounds.length === 0 || !this._renderer) {\n return;\n }\n\n let verts = [];\n let indices = [];\n\n // Tessellate the bounding points from XRStageBounds and connect\n // each point to a neighbor and 0,0,0.\n const pointCount = stageBounds.geometry.length;\n for (let i = 0; i < pointCount; i++) {\n const point = stageBounds.geometry[i];\n verts.push(point.x, 0, point.z);\n indices.push(i, i === 0 ? pointCount - 1 : i - 1, pointCount);\n }\n // Center point\n verts.push(0, 0, 0);\n\n let vertexBuffer = this._renderer.createRenderBuffer(GL.ARRAY_BUFFER, new Float32Array(verts));\n let indexBuffer = this._renderer.createRenderBuffer(GL.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices));\n\n let attribs = [\n new PrimitiveAttribute('POSITION', vertexBuffer, 3, GL.FLOAT, 12, 0),\n ];\n\n let primitive = new Primitive(attribs, indices.length);\n primitive.setIndexBuffer(indexBuffer);\n\n let renderPrimitive = this._renderer.createRenderPrimitive(primitive, new BoundsMaterial());\n this.addRenderPrimitive(renderPrimitive);\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Material} from '../core/material.js';\nimport {Node} from '../core/node.js';\nimport {PrimitiveStream} from '../geometry/primitive-stream.js';\n\nconst BUTTON_SIZE = 0.1;\nconst BUTTON_CORNER_RADIUS = 0.025;\nconst BUTTON_CORNER_SEGMENTS = 8;\nconst BUTTON_ICON_SIZE = 0.07;\nconst BUTTON_LAYER_DISTANCE = 0.005;\nconst BUTTON_COLOR = 0.75;\nconst BUTTON_ALPHA = 0.85;\nconst BUTTON_HOVER_COLOR = 0.9;\nconst BUTTON_HOVER_ALPHA = 1.0;\nconst BUTTON_HOVER_SCALE = 1.1;\nconst BUTTON_HOVER_TRANSITION_TIME_MS = 200;\n\nclass ButtonMaterial extends Material {\n constructor() {\n super();\n\n this.state.blend = true;\n\n this.defineUniform('hoverAmount', 0);\n }\n\n get materialName() {\n return 'BUTTON_MATERIAL';\n }\n\n get vertexSource() {\n return `\n attribute vec3 POSITION;\n\n uniform float hoverAmount;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n float scale = mix(1.0, ${BUTTON_HOVER_SCALE}, hoverAmount);\n vec4 pos = vec4(POSITION.x * scale, POSITION.y * scale, POSITION.z * (scale + (hoverAmount * 0.2)), 1.0);\n return proj * view * model * pos;\n }`;\n }\n\n get fragmentSource() {\n return `\n uniform float hoverAmount;\n\n const vec4 default_color = vec4(${BUTTON_COLOR}, ${BUTTON_COLOR}, ${BUTTON_COLOR}, ${BUTTON_ALPHA});\n const vec4 hover_color = vec4(${BUTTON_HOVER_COLOR}, ${BUTTON_HOVER_COLOR},\n ${BUTTON_HOVER_COLOR}, ${BUTTON_HOVER_ALPHA});\n\n vec4 fragment_main() {\n return mix(default_color, hover_color, hoverAmount);\n }`;\n }\n}\n\nclass ButtonIconMaterial extends Material {\n constructor() {\n super();\n\n this.state.blend = true;\n\n this.defineUniform('hoverAmount', 0);\n this.icon = this.defineSampler('icon');\n }\n\n get materialName() {\n return 'BUTTON_ICON_MATERIAL';\n }\n\n get vertexSource() {\n return `\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n\n uniform float hoverAmount;\n\n varying vec2 vTexCoord;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vTexCoord = TEXCOORD_0;\n float scale = mix(1.0, ${BUTTON_HOVER_SCALE}, hoverAmount);\n vec4 pos = vec4(POSITION.x * scale, POSITION.y * scale, POSITION.z * (scale + (hoverAmount * 0.2)), 1.0);\n return proj * view * model * pos;\n }`;\n }\n\n get fragmentSource() {\n return `\n uniform sampler2D icon;\n varying vec2 vTexCoord;\n\n vec4 fragment_main() {\n return texture2D(icon, vTexCoord);\n }`;\n }\n}\n\nexport class ButtonNode extends Node {\n constructor(iconTexture, callback) {\n super();\n\n // All buttons are selectable by default.\n this.selectable = true;\n\n this._selectHandler = callback;\n this._iconTexture = iconTexture;\n this._hovered = false;\n this._hoverT = 0;\n }\n\n get iconTexture() {\n return this._iconTexture;\n }\n\n set iconTexture(value) {\n if (this._iconTexture == value) {\n return;\n }\n\n this._iconTexture = value;\n this._iconRenderPrimitive.samplers.icon.texture = value;\n }\n\n onRendererChanged(renderer) {\n let stream = new PrimitiveStream();\n\n let hd = BUTTON_LAYER_DISTANCE * 0.5;\n\n // Build a rounded rect for the background.\n let hs = BUTTON_SIZE * 0.5;\n let ihs = hs - BUTTON_CORNER_RADIUS;\n stream.startGeometry();\n\n // Rounded corners and sides\n let segments = BUTTON_CORNER_SEGMENTS * 4;\n for (let i = 0; i < segments; ++i) {\n let rad = i * ((Math.PI * 2.0) / segments);\n let x = Math.cos(rad) * BUTTON_CORNER_RADIUS;\n let y = Math.sin(rad) * BUTTON_CORNER_RADIUS;\n let section = Math.floor(i / BUTTON_CORNER_SEGMENTS);\n switch (section) {\n case 0:\n x += ihs;\n y += ihs;\n break;\n case 1:\n x -= ihs;\n y += ihs;\n break;\n case 2:\n x -= ihs;\n y -= ihs;\n break;\n case 3:\n x += ihs;\n y -= ihs;\n break;\n }\n\n stream.pushVertex(x, y, -hd, 0, 0, 0, 0, 1);\n\n if (i > 1) {\n stream.pushTriangle(0, i-1, i);\n }\n }\n\n stream.endGeometry();\n\n let buttonPrimitive = stream.finishPrimitive(renderer);\n this._buttonRenderPrimitive = renderer.createRenderPrimitive(buttonPrimitive, new ButtonMaterial());\n this.addRenderPrimitive(this._buttonRenderPrimitive);\n\n // Build a simple textured quad for the foreground.\n hs = BUTTON_ICON_SIZE * 0.5;\n stream.clear();\n stream.startGeometry();\n\n stream.pushVertex(-hs, hs, hd, 0, 0, 0, 0, 1);\n stream.pushVertex(-hs, -hs, hd, 0, 1, 0, 0, 1);\n stream.pushVertex(hs, -hs, hd, 1, 1, 0, 0, 1);\n stream.pushVertex(hs, hs, hd, 1, 0, 0, 0, 1);\n\n stream.pushTriangle(0, 1, 2);\n stream.pushTriangle(0, 2, 3);\n\n stream.endGeometry();\n\n let iconPrimitive = stream.finishPrimitive(renderer);\n let iconMaterial = new ButtonIconMaterial();\n iconMaterial.icon.texture = this._iconTexture;\n this._iconRenderPrimitive = renderer.createRenderPrimitive(iconPrimitive, iconMaterial);\n this.addRenderPrimitive(this._iconRenderPrimitive);\n }\n\n onHoverStart() {\n this._hovered = true;\n }\n\n onHoverEnd() {\n this._hovered = false;\n }\n\n _updateHoverState() {\n let t = this._hoverT / BUTTON_HOVER_TRANSITION_TIME_MS;\n // Cubic Ease In/Out\n // TODO: Get a better animation system\n let hoverAmount = t<.5 ? 4*t*t*t : (t-1)*(2*t-2)*(2*t-2)+1;\n this._buttonRenderPrimitive.uniforms.hoverAmount.value = hoverAmount;\n this._iconRenderPrimitive.uniforms.hoverAmount.value = hoverAmount;\n }\n\n onUpdate(timestamp, frameDelta) {\n if (this._hovered && this._hoverT < BUTTON_HOVER_TRANSITION_TIME_MS) {\n this._hoverT = Math.min(BUTTON_HOVER_TRANSITION_TIME_MS, this._hoverT + frameDelta);\n this._updateHoverState();\n } else if (!this._hovered && this._hoverT > 0) {\n this._hoverT = Math.max(0.0, this._hoverT - frameDelta);\n this._updateHoverState();\n }\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Material} from '../core/material.js';\nimport {Node} from '../core/node.js';\nimport {UrlTexture} from '../core/texture.js';\nimport {BoxBuilder} from '../geometry/box-builder.js';\nimport {mat4} from '../math/gl-matrix.js';\n\nclass CubeSeaMaterial extends Material {\n constructor(heavy = false) {\n super();\n\n this.heavy = heavy;\n\n this.baseColor = this.defineSampler('baseColor');\n }\n\n get materialName() {\n return 'CUBE_SEA';\n }\n\n get vertexSource() {\n return `\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n attribute vec3 NORMAL;\n\n varying vec2 vTexCoord;\n varying vec3 vLight;\n\n const vec3 lightDir = vec3(0.75, 0.5, 1.0);\n const vec3 ambientColor = vec3(0.5, 0.5, 0.5);\n const vec3 lightColor = vec3(0.75, 0.75, 0.75);\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vec3 normalRotated = vec3(model * vec4(NORMAL, 0.0));\n float lightFactor = max(dot(normalize(lightDir), normalRotated), 0.0);\n vLight = ambientColor + (lightColor * lightFactor);\n vTexCoord = TEXCOORD_0;\n return proj * view * model * vec4(POSITION, 1.0);\n }`;\n }\n\n get fragmentSource() {\n if (!this.heavy) {\n return `\n precision mediump float;\n uniform sampler2D baseColor;\n varying vec2 vTexCoord;\n varying vec3 vLight;\n\n vec4 fragment_main() {\n return vec4(vLight, 1.0) * texture2D(baseColor, vTexCoord);\n }`;\n } else {\n // Used when we want to stress the GPU a bit more.\n // Stolen with love from https://www.clicktorelease.com/code/codevember-2016/4/\n return `\n precision mediump float;\n\n uniform sampler2D diffuse;\n varying vec2 vTexCoord;\n varying vec3 vLight;\n\n vec2 dimensions = vec2(64, 64);\n float seed = 0.42;\n\n vec2 hash( vec2 p ) {\n p=vec2(dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3)));\n return fract(sin(p)*18.5453);\n }\n\n vec3 hash3( vec2 p ) {\n vec3 q = vec3( dot(p,vec2(127.1,311.7)),\n dot(p,vec2(269.5,183.3)),\n dot(p,vec2(419.2,371.9)) );\n return fract(sin(q)*43758.5453);\n }\n\n float iqnoise( in vec2 x, float u, float v ) {\n vec2 p = floor(x);\n vec2 f = fract(x);\n float k = 1.0+63.0*pow(1.0-v,4.0);\n float va = 0.0;\n float wt = 0.0;\n for( int j=-2; j<=2; j++ )\n for( int i=-2; i<=2; i++ ) {\n vec2 g = vec2( float(i),float(j) );\n vec3 o = hash3( p + g )*vec3(u,u,1.0);\n vec2 r = g - f + o.xy;\n float d = dot(r,r);\n float ww = pow( 1.0-smoothstep(0.0,1.414,sqrt(d)), k );\n va += o.z*ww;\n wt += ww;\n }\n return va/wt;\n }\n\n // return distance, and cell id\n vec2 voronoi( in vec2 x ) {\n vec2 n = floor( x );\n vec2 f = fract( x );\n vec3 m = vec3( 8.0 );\n for( int j=-1; j<=1; j++ )\n for( int i=-1; i<=1; i++ ) {\n vec2 g = vec2( float(i), float(j) );\n vec2 o = hash( n + g );\n vec2 r = g - f + (0.5+0.5*sin(seed+6.2831*o));\n float d = dot( r, r );\n if( d 12) {\n // Each cube has 6 sides with 2 triangles and 3 indices per triangle, so\n // the total number of indices needed is cubeCount^3 * 36. This exceeds\n // the short index range past 12 cubes.\n boxBuilder.indexType = 5125; // gl.UNSIGNED_INT\n }\n let cubeSeaPrimitive = boxBuilder.finishPrimitive(this._renderer);\n\n if (!this._renderPrimitive) {\n this._renderPrimitive = this._renderer.createRenderPrimitive(cubeSeaPrimitive, this._material);\n } else {\n this._renderPrimitive.setPrimitive(cubeSeaPrimitive);\n }\n }\n\n onUpdate(timestamp, frameDelta) {\n if (this.autoRotate) {\n mat4.fromRotation(this.cubeSeaNode.matrix, timestamp / 500, [0, -1, 0]);\n }\n mat4.fromRotation(this.heroNode.matrix, timestamp / 2000, [0, 1, 0]);\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Material} from '../core/material.js';\nimport {Node} from '../core/node.js';\nimport {PrimitiveStream} from '../geometry/primitive-stream.js';\n\nconst GL = WebGLRenderingContext; // For enums\n\nconst SHADOW_SEGMENTS = 32;\nconst SHADOW_GROUND_OFFSET = 0.01;\nconst SHADOW_CENTER_ALPHA = 0.7;\nconst SHADOW_INNER_ALPHA = 0.3;\nconst SHADOW_OUTER_ALPHA = 0.0;\nconst SHADOW_INNER_RADIUS = 0.6;\nconst SHADOW_OUTER_RADIUS = 1.0;\n\nclass DropShadowMaterial extends Material {\n constructor() {\n super();\n\n this.state.blend = true;\n this.state.blendFuncSrc = GL.ONE;\n this.state.blendFuncDst = GL.ONE_MINUS_SRC_ALPHA;\n this.state.depthFunc = GL.LEQUAL;\n this.state.depthMask = false;\n }\n\n get materialName() {\n return 'DROP_SHADOW_MATERIAL';\n }\n\n get vertexSource() {\n return `\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n\n varying float vShadow;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vShadow = TEXCOORD_0.x;\n return proj * view * model * vec4(POSITION, 1.0);\n }`;\n }\n\n get fragmentSource() {\n return `\n varying float vShadow;\n\n vec4 fragment_main() {\n return vec4(0.0, 0.0, 0.0, vShadow);\n }`;\n }\n}\n\nexport class DropShadowNode extends Node {\n constructor(iconTexture, callback) {\n super();\n }\n\n onRendererChanged(renderer) {\n let stream = new PrimitiveStream();\n\n stream.startGeometry();\n\n // Shadow center\n stream.pushVertex(0, SHADOW_GROUND_OFFSET, 0, SHADOW_CENTER_ALPHA);\n\n let segRad = ((Math.PI * 2.0) / SHADOW_SEGMENTS);\n\n let idx;\n for (let i = 0; i < SHADOW_SEGMENTS; ++i) {\n idx = stream.nextVertexIndex;\n\n let rad = i * segRad;\n let x = Math.cos(rad);\n let y = Math.sin(rad);\n stream.pushVertex(x * SHADOW_INNER_RADIUS, SHADOW_GROUND_OFFSET, y * SHADOW_INNER_RADIUS, SHADOW_INNER_ALPHA);\n stream.pushVertex(x * SHADOW_OUTER_RADIUS, SHADOW_GROUND_OFFSET, y * SHADOW_OUTER_RADIUS, SHADOW_OUTER_ALPHA);\n\n if (i > 0) {\n // Inner circle\n stream.pushTriangle(0, idx, idx-2);\n\n // Outer circle\n stream.pushTriangle(idx, idx+1, idx-1);\n stream.pushTriangle(idx, idx-1, idx-2);\n }\n }\n\n stream.pushTriangle(0, 1, idx);\n\n stream.pushTriangle(1, 2, idx+1);\n stream.pushTriangle(1, idx+1, idx);\n\n stream.endGeometry();\n\n let shadowPrimitive = stream.finishPrimitive(renderer);\n this._shadowRenderPrimitive = renderer.createRenderPrimitive(shadowPrimitive, new DropShadowMaterial());\n this.addRenderPrimitive(this._shadowRenderPrimitive);\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Node} from '../core/node.js';\nimport {Gltf2Loader} from '../loaders/gltf2.js';\n\n// Using a weak map here allows us to cache a loader per-renderer without\n// modifying the renderer object or leaking memory when it's garbage collected.\nlet gltfLoaderMap = new WeakMap();\n\nexport class Gltf2Node extends Node {\n constructor(options) {\n super();\n this._url = options.url;\n\n this._promise = null;\n this._resolver = null;\n this._rejecter = null;\n }\n\n onRendererChanged(renderer) {\n let loader = gltfLoaderMap.get(renderer);\n if (!loader) {\n loader = new Gltf2Loader(renderer);\n gltfLoaderMap.set(renderer, loader);\n }\n\n // Do we have a previously resolved promise? If so clear it.\n if (!this._resolver && this._promise) {\n this._promise = null;\n }\n\n this._ensurePromise();\n\n loader.loadFromUrl(this._url).then((sceneNode) => {\n this.addNode(sceneNode);\n this._resolver(sceneNode.waitForComplete());\n this._resolver = null;\n this._rejecter = null;\n }).catch((err) => {\n this._rejecter(err);\n this._resolver = null;\n this._rejecter = null;\n });\n }\n\n _ensurePromise() {\n if (!this._promise) {\n this._promise = new Promise((resolve, reject) => {\n this._resolver = resolve;\n this._rejecter = reject;\n });\n }\n return this._promise;\n }\n\n waitForComplete() {\n return this._ensurePromise();\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Material, RENDER_ORDER} from '../core/material.js';\nimport {Node} from '../core/node.js';\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\nimport {DataTexture} from '../core/texture.js';\n\nconst GL = WebGLRenderingContext; // For enums\n\n// Laser texture data, 48x1 RGBA (not premultiplied alpha). This represents a\n// \"cross section\" of the laser beam with a bright core and a feathered edge.\n// Borrowed from Chromium source code.\nconst LASER_TEXTURE_DATA = new Uint8Array([\n0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x02, 0xbf, 0xbf, 0xbf, 0x04, 0xcc, 0xcc, 0xcc, 0x05,\n0xdb, 0xdb, 0xdb, 0x07, 0xcc, 0xcc, 0xcc, 0x0a, 0xd8, 0xd8, 0xd8, 0x0d, 0xd2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\nconst LASER_DEFAULT_COLOR = [1.0, 1.0, 1.0, 0.25];\n\nconst CURSOR_RADIUS = 0.004;\nconst CURSOR_SHADOW_RADIUS = 0.007;\nconst CURSOR_SHADOW_INNER_LUMINANCE = 0.5;\nconst CURSOR_SHADOW_OUTER_LUMINANCE = 0.0;\nconst CURSOR_SHADOW_INNER_OPACITY = 0.75;\nconst CURSOR_SHADOW_OUTER_OPACITY = 0.0;\nconst CURSOR_OPACITY = 0.9;\nconst CURSOR_SEGMENTS = 16;\nconst CURSOR_DEFAULT_COLOR = [1.0, 1.0, 1.0, 1.0];\nconst CURSOR_DEFAULT_HIDDEN_COLOR = [0.5, 0.5, 0.5, 0.25];\n\nconst DEFAULT_RESET_OPTIONS = {\n controllers: true,\n lasers: true,\n cursors: true,\n};\n\nclass LaserMaterial extends Material {\n constructor() {\n super();\n this.renderOrder = RENDER_ORDER.ADDITIVE;\n this.state.cullFace = false;\n this.state.blend = true;\n this.state.blendFuncSrc = GL.ONE;\n this.state.blendFuncDst = GL.ONE;\n this.state.depthMask = false;\n\n this.laser = this.defineSampler('diffuse');\n this.laser.texture = new DataTexture(LASER_TEXTURE_DATA, 48, 1);\n this.laserColor = this.defineUniform('laserColor', LASER_DEFAULT_COLOR);\n }\n\n get materialName() {\n return 'INPUT_LASER';\n }\n\n get vertexSource() {\n return `\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n\n varying vec2 vTexCoord;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vTexCoord = TEXCOORD_0;\n return proj * view * model * vec4(POSITION, 1.0);\n }`;\n }\n\n get fragmentSource() {\n return `\n precision mediump float;\n\n uniform vec4 laserColor;\n uniform sampler2D diffuse;\n varying vec2 vTexCoord;\n\n const float fadePoint = ${LASER_FADE_POINT};\n const float fadeEnd = ${LASER_FADE_END};\n\n vec4 fragment_main() {\n vec2 uv = vTexCoord;\n float front_fade_factor = 1.0 - clamp(1.0 - (uv.y - fadePoint) / (1.0 - fadePoint), 0.0, 1.0);\n float back_fade_factor = clamp((uv.y - fadePoint) / (fadeEnd - fadePoint), 0.0, 1.0);\n vec4 color = laserColor * texture2D(diffuse, vTexCoord);\n float opacity = color.a * front_fade_factor * back_fade_factor;\n return vec4(color.rgb * opacity, opacity);\n }`;\n }\n}\n\nconst CURSOR_VERTEX_SHADER = `\nattribute vec4 POSITION;\n\nvarying float vLuminance;\nvarying float vOpacity;\n\nvec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vLuminance = POSITION.z;\n vOpacity = POSITION.w;\n\n // Billboarded, constant size vertex transform.\n vec4 screenPos = proj * view * model * vec4(0.0, 0.0, 0.0, 1.0);\n screenPos /= screenPos.w;\n screenPos.xy += POSITION.xy;\n return screenPos;\n}`;\n\nconst CURSOR_FRAGMENT_SHADER = `\nprecision mediump float;\n\nuniform vec4 cursorColor;\nvarying float vLuminance;\nvarying float vOpacity;\n\nvec4 fragment_main() {\n vec3 color = cursorColor.rgb * vLuminance;\n float opacity = cursorColor.a * vOpacity;\n return vec4(color * opacity, opacity);\n}`;\n\n// Cursors are drawn as billboards that always face the camera and are rendered\n// as a fixed size no matter how far away they are.\nclass CursorMaterial extends Material {\n constructor() {\n super();\n this.renderOrder = RENDER_ORDER.ADDITIVE;\n this.state.cullFace = false;\n this.state.blend = true;\n this.state.blendFuncSrc = GL.ONE;\n this.state.depthMask = false;\n\n this.cursorColor = this.defineUniform('cursorColor', CURSOR_DEFAULT_COLOR);\n }\n\n get materialName() {\n return 'INPUT_CURSOR';\n }\n\n get vertexSource() {\n return CURSOR_VERTEX_SHADER;\n }\n\n get fragmentSource() {\n return CURSOR_FRAGMENT_SHADER;\n }\n}\n\nclass CursorHiddenMaterial extends Material {\n constructor() {\n super();\n this.renderOrder = RENDER_ORDER.ADDITIVE;\n this.state.cullFace = false;\n this.state.blend = true;\n this.state.blendFuncSrc = GL.ONE;\n this.state.depthFunc = GL.GEQUAL;\n this.state.depthMask = false;\n\n this.cursorColor = this.defineUniform('cursorColor', CURSOR_DEFAULT_HIDDEN_COLOR);\n }\n\n // TODO: Rename to \"program_name\"\n get materialName() {\n return 'INPUT_CURSOR_2';\n }\n\n get vertexSource() {\n return CURSOR_VERTEX_SHADER;\n }\n\n get fragmentSource() {\n return CURSOR_FRAGMENT_SHADER;\n }\n}\n\nexport class InputRenderer extends Node {\n constructor() {\n super();\n\n this._maxInputElements = 32;\n\n this._controllers = [];\n this._controllerNode = null;\n this._controllerNodeHandedness = null;\n this._lasers = null;\n this._cursors = null;\n\n this._activeControllers = 0;\n this._activeLasers = 0;\n this._activeCursors = 0;\n }\n\n onRendererChanged(renderer) {\n this._controllers = [];\n this._controllerNode = null;\n this._controllerNodeHandedness = null;\n this._lasers = null;\n this._cursors = null;\n\n this._activeControllers = 0;\n this._activeLasers = 0;\n this._activeCursors = 0;\n }\n\n setControllerMesh(controllerNode, handedness = 'right') {\n this._controllerNode = controllerNode;\n this._controllerNode.visible = false;\n // FIXME: Temporary fix to initialize for cloning.\n this.addNode(this._controllerNode);\n this._controllerNodeHandedness = handedness;\n }\n\n addController(gripMatrix) {\n if (!this._controllerNode) {\n return;\n }\n\n let controller = null;\n if (this._activeControllers < this._controllers.length) {\n controller = this._controllers[this._activeControllers];\n } else {\n controller = this._controllerNode.clone();\n this.addNode(controller);\n this._controllers.push(controller);\n }\n this._activeControllers = (this._activeControllers + 1) % this._maxInputElements;\n\n controller.matrix = gripMatrix;\n controller.visible = true;\n }\n\n addLaserPointer(targetRay) {\n // Create the laser pointer mesh if needed.\n if (!this._lasers && this._renderer) {\n this._lasers = [this._createLaserMesh()];\n this.addNode(this._lasers[0]);\n }\n\n let laser = null;\n if (this._activeLasers < this._lasers.length) {\n laser = this._lasers[this._activeLasers];\n } else {\n laser = this._lasers[0].clone();\n this.addNode(laser);\n this._lasers.push(laser);\n }\n this._activeLasers = (this._activeLasers + 1) % this._maxInputElements;\n\n laser.matrix = targetRay.transformMatrix;\n laser.visible = true;\n }\n\n addCursor(cursorPos) {\n // Create the cursor mesh if needed.\n if (!this._cursors && this._renderer) {\n this._cursors = [this._createCursorMesh()];\n this.addNode(this._cursors[0]);\n }\n\n let cursor = null;\n if (this._activeCursors < this._cursors.length) {\n cursor = this._cursors[this._activeCursors];\n } else {\n cursor = this._cursors[0].clone();\n this.addNode(cursor);\n this._cursors.push(cursor);\n }\n this._activeCursors = (this._activeCursors + 1) % this._maxInputElements;\n\n cursor.translation = cursorPos;\n cursor.visible = true;\n }\n\n reset(options) {\n if (!options) {\n options = DEFAULT_RESET_OPTIONS;\n }\n if (this._controllers && options.controllers) {\n for (let controller of this._controllers) {\n controller.visible = false;\n }\n this._activeControllers = 0;\n }\n if (this._lasers && options.lasers) {\n for (let laser of this._lasers) {\n laser.visible = false;\n }\n this._activeLasers = 0;\n }\n if (this._cursors && options.cursors) {\n for (let cursor of this._cursors) {\n cursor.visible = false;\n }\n this._activeCursors = 0;\n }\n }\n\n _createLaserMesh() {\n let gl = this._renderer._gl;\n\n let lr = LASER_DIAMETER * 0.5;\n let ll = LASER_LENGTH;\n\n // Laser is rendered as cross-shaped beam\n let laserVerts = [\n // X Y Z U V\n 0.0, lr, 0.0, 0.0, 1.0,\n 0.0, lr, -ll, 0.0, 0.0,\n 0.0, -lr, 0.0, 1.0, 1.0,\n 0.0, -lr, -ll, 1.0, 0.0,\n\n lr, 0.0, 0.0, 0.0, 1.0,\n lr, 0.0, -ll, 0.0, 0.0,\n -lr, 0.0, 0.0, 1.0, 1.0,\n -lr, 0.0, -ll, 1.0, 0.0,\n\n 0.0, -lr, 0.0, 0.0, 1.0,\n 0.0, -lr, -ll, 0.0, 0.0,\n 0.0, lr, 0.0, 1.0, 1.0,\n 0.0, lr, -ll, 1.0, 0.0,\n\n -lr, 0.0, 0.0, 0.0, 1.0,\n -lr, 0.0, -ll, 0.0, 0.0,\n lr, 0.0, 0.0, 1.0, 1.0,\n lr, 0.0, -ll, 1.0, 0.0,\n ];\n let laserIndices = [\n 0, 1, 2, 1, 3, 2,\n 4, 5, 6, 5, 7, 6,\n 8, 9, 10, 9, 11, 10,\n 12, 13, 14, 13, 15, 14,\n ];\n\n let laserVertexBuffer = this._renderer.createRenderBuffer(gl.ARRAY_BUFFER, new Float32Array(laserVerts));\n let laserIndexBuffer = this._renderer.createRenderBuffer(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(laserIndices));\n\n let laserIndexCount = laserIndices.length;\n\n let laserAttribs = [\n new PrimitiveAttribute('POSITION', laserVertexBuffer, 3, gl.FLOAT, 20, 0),\n new PrimitiveAttribute('TEXCOORD_0', laserVertexBuffer, 2, gl.FLOAT, 20, 12),\n ];\n\n let laserPrimitive = new Primitive(laserAttribs, laserIndexCount);\n laserPrimitive.setIndexBuffer(laserIndexBuffer);\n\n let laserMaterial = new LaserMaterial();\n\n let laserRenderPrimitive = this._renderer.createRenderPrimitive(laserPrimitive, laserMaterial);\n let meshNode = new Node();\n meshNode.addRenderPrimitive(laserRenderPrimitive);\n return meshNode;\n }\n\n _createCursorMesh() {\n let gl = this._renderer._gl;\n\n // Cursor is a circular white dot with a dark \"shadow\" skirt around the edge\n // that fades from black to transparent as it moves out from the center.\n // Cursor verts are packed as [X, Y, Luminance, Opacity]\n let cursorVerts = [];\n let cursorIndices = [];\n\n let segRad = (2.0 * Math.PI) / CURSOR_SEGMENTS;\n\n // Cursor center\n for (let i = 0; i < CURSOR_SEGMENTS; ++i) {\n let rad = i * segRad;\n let x = Math.cos(rad);\n let y = Math.sin(rad);\n cursorVerts.push(x * CURSOR_RADIUS, y * CURSOR_RADIUS, 1.0, CURSOR_OPACITY);\n\n if (i > 1) {\n cursorIndices.push(0, i-1, i);\n }\n }\n\n let indexOffset = CURSOR_SEGMENTS;\n\n // Cursor Skirt\n for (let i = 0; i < CURSOR_SEGMENTS; ++i) {\n let rad = i * segRad;\n let x = Math.cos(rad);\n let y = Math.sin(rad);\n cursorVerts.push(x * CURSOR_RADIUS, y * CURSOR_RADIUS,\n CURSOR_SHADOW_INNER_LUMINANCE, CURSOR_SHADOW_INNER_OPACITY);\n cursorVerts.push(x * CURSOR_SHADOW_RADIUS, y * CURSOR_SHADOW_RADIUS,\n CURSOR_SHADOW_OUTER_LUMINANCE, CURSOR_SHADOW_OUTER_OPACITY);\n\n if (i > 0) {\n let idx = indexOffset + (i * 2);\n cursorIndices.push(idx-2, idx-1, idx);\n cursorIndices.push(idx-1, idx+1, idx);\n }\n }\n\n let idx = indexOffset + (CURSOR_SEGMENTS * 2);\n cursorIndices.push(idx-2, idx-1, indexOffset);\n cursorIndices.push(idx-1, indexOffset+1, indexOffset);\n\n let cursorVertexBuffer = this._renderer.createRenderBuffer(gl.ARRAY_BUFFER, new Float32Array(cursorVerts));\n let cursorIndexBuffer = this._renderer.createRenderBuffer(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(cursorIndices));\n\n let cursorIndexCount = cursorIndices.length;\n\n let cursorAttribs = [\n new PrimitiveAttribute('POSITION', cursorVertexBuffer, 4, gl.FLOAT, 16, 0),\n ];\n\n let cursorPrimitive = new Primitive(cursorAttribs, cursorIndexCount);\n cursorPrimitive.setIndexBuffer(cursorIndexBuffer);\n\n let cursorMaterial = new CursorMaterial();\n let cursorHiddenMaterial = new CursorHiddenMaterial();\n\n // Cursor renders two parts: The bright opaque cursor for areas where it's\n // not obscured and a more transparent, darker version for areas where it's\n // behind another object.\n let cursorRenderPrimitive = this._renderer.createRenderPrimitive(cursorPrimitive, cursorMaterial);\n let cursorHiddenRenderPrimitive = this._renderer.createRenderPrimitive(cursorPrimitive, cursorHiddenMaterial);\n let meshNode = new Node();\n meshNode.addRenderPrimitive(cursorRenderPrimitive);\n meshNode.addRenderPrimitive(cursorHiddenRenderPrimitive);\n return meshNode;\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n/*\nRenders simple text using a seven-segment LED style pattern. Only really good\nfor numbers and a limited number of other characters.\n*/\n\nimport {Material} from '../core/material.js';\nimport {Node} from '../core/node.js';\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\n\nconst TEXT_KERNING = 2.0;\n\nclass SevenSegmentMaterial extends Material {\n get materialName() {\n return 'SEVEN_SEGMENT_TEXT';\n }\n\n get vertexSource() {\n return `\n attribute vec2 POSITION;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n return proj * view * model * vec4(POSITION, 0.0, 1.0);\n }`;\n }\n\n get fragmentSource() {\n return `\n precision mediump float;\n const vec4 color = vec4(0.0, 1.0, 0.0, 1.0);\n\n vec4 fragment_main() {\n return color;\n }`;\n }\n}\n\nexport class SevenSegmentText extends Node {\n constructor() {\n super();\n\n this._text = '';\n this._charNodes = [];\n }\n\n onRendererChanged(renderer) {\n this.clearNodes();\n this._charNodes = [];\n\n let vertices = [];\n let segmentIndices = {};\n let indices = [];\n\n const width = 0.5;\n const thickness = 0.25;\n\n function defineSegment(id, left, top, right, bottom) {\n let idx = vertices.length / 2;\n vertices.push(\n left, top,\n right, top,\n right, bottom,\n left, bottom);\n\n segmentIndices[id] = [\n idx, idx+2, idx+1,\n idx, idx+3, idx+2,\n ];\n }\n\n let characters = {};\n function defineCharacter(c, segments) {\n let character = {\n character: c,\n offset: indices.length * 2,\n count: 0,\n };\n\n for (let i = 0; i < segments.length; ++i) {\n let idx = segments[i];\n let segment = segmentIndices[idx];\n character.count += segment.length;\n indices.push(...segment);\n }\n\n characters[c] = character;\n }\n\n /* Segment layout is as follows:\n\n |-0-|\n 3 4\n |-1-|\n 5 6\n |-2-|\n\n */\n\n defineSegment(0, -1, 1, width, 1-thickness);\n defineSegment(1, -1, thickness*0.5, width, -thickness*0.5);\n defineSegment(2, -1, -1+thickness, width, -1);\n defineSegment(3, -1, 1, -1+thickness, -thickness*0.5);\n defineSegment(4, width-thickness, 1, width, -thickness*0.5);\n defineSegment(5, -1, thickness*0.5, -1+thickness, -1);\n defineSegment(6, width-thickness, thickness*0.5, width, -1);\n\n\n defineCharacter('0', [0, 2, 3, 4, 5, 6]);\n defineCharacter('1', [4, 6]);\n defineCharacter('2', [0, 1, 2, 4, 5]);\n defineCharacter('3', [0, 1, 2, 4, 6]);\n defineCharacter('4', [1, 3, 4, 6]);\n defineCharacter('5', [0, 1, 2, 3, 6]);\n defineCharacter('6', [0, 1, 2, 3, 5, 6]);\n defineCharacter('7', [0, 4, 6]);\n defineCharacter('8', [0, 1, 2, 3, 4, 5, 6]);\n defineCharacter('9', [0, 1, 2, 3, 4, 6]);\n defineCharacter('A', [0, 1, 3, 4, 5, 6]);\n defineCharacter('B', [1, 2, 3, 5, 6]);\n defineCharacter('C', [0, 2, 3, 5]);\n defineCharacter('D', [1, 2, 4, 5, 6]);\n defineCharacter('E', [0, 1, 2, 4, 6]);\n defineCharacter('F', [0, 1, 3, 5]);\n defineCharacter('P', [0, 1, 3, 4, 5]);\n defineCharacter('-', [1]);\n defineCharacter(' ', []);\n defineCharacter('_', [2]); // Used for undefined characters\n\n let gl = renderer.gl;\n let vertexBuffer = renderer.createRenderBuffer(gl.ARRAY_BUFFER, new Float32Array(vertices));\n let indexBuffer = renderer.createRenderBuffer(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices));\n\n let vertexAttribs = [\n new PrimitiveAttribute('POSITION', vertexBuffer, 2, gl.FLOAT, 8, 0),\n ];\n\n let primitive = new Primitive(vertexAttribs, indices.length);\n primitive.setIndexBuffer(indexBuffer);\n\n let material = new SevenSegmentMaterial();\n\n this._charPrimitives = {};\n for (let char in characters) {\n let charDef = characters[char];\n primitive.elementCount = charDef.count;\n primitive.indexByteOffset = charDef.offset;\n this._charPrimitives[char] = renderer.createRenderPrimitive(primitive, material);\n }\n\n this.text = this._text;\n }\n\n get text() {\n return this._text;\n }\n\n set text(value) {\n this._text = value;\n\n let i = 0;\n let charPrimitive = null;\n for (; i < value.length; ++i) {\n if (value[i] in this._charPrimitives) {\n charPrimitive = this._charPrimitives[value[i]];\n } else {\n charPrimitive = this._charPrimitives['_'];\n }\n\n if (this._charNodes.length <= i) {\n let node = new Node();\n node.addRenderPrimitive(charPrimitive);\n let offset = i * TEXT_KERNING;\n node.translation = [offset, 0, 0];\n this._charNodes.push(node);\n this.addNode(node);\n } else {\n // This is sort of an abuse of how these things are expected to work,\n // but it's the cheapest thing I could think of that didn't break the\n // world.\n this._charNodes[i].clearRenderPrimitives();\n this._charNodes[i].addRenderPrimitive(charPrimitive);\n this._charNodes[i].visible = true;\n }\n }\n\n // If there's any nodes left over make them invisible\n for (; i < this._charNodes.length; ++i) {\n this._charNodes[i].visible = false;\n }\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n/*\nNode for displaying 360 equirect images as a skybox.\n*/\n\nimport {Material, RENDER_ORDER} from '../core/material.js';\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\nimport {Node} from '../core/node.js';\nimport {UrlTexture} from '../core/texture.js';\n\nconst GL = WebGLRenderingContext; // For enums\n\nclass SkyboxMaterial extends Material {\n constructor() {\n super();\n this.renderOrder = RENDER_ORDER.SKY;\n this.state.depthFunc = GL.LEQUAL;\n this.state.depthMask = false;\n\n this.image = this.defineSampler('diffuse');\n\n this.texCoordScaleOffset = this.defineUniform('texCoordScaleOffset',\n [1.0, 1.0, 0.0, 0.0,\n 1.0, 1.0, 0.0, 0.0], 4);\n }\n\n get materialName() {\n return 'SKYBOX';\n }\n\n get vertexSource() {\n return `\n uniform int EYE_INDEX;\n uniform vec4 texCoordScaleOffset[2];\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n varying vec2 vTexCoord;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vec4 scaleOffset = texCoordScaleOffset[EYE_INDEX];\n vTexCoord = (TEXCOORD_0 * scaleOffset.xy) + scaleOffset.zw;\n // Drop the translation portion of the view matrix\n view[3].xyz = vec3(0.0, 0.0, 0.0);\n vec4 out_vec = proj * view * model * vec4(POSITION, 1.0);\n\n // Returning the W component for both Z and W forces the geometry depth to\n // the far plane. When combined with a depth func of LEQUAL this makes the\n // sky write to any depth fragment that has not been written to yet.\n return out_vec.xyww;\n }`;\n }\n\n get fragmentSource() {\n return `\n uniform sampler2D diffuse;\n varying vec2 vTexCoord;\n\n vec4 fragment_main() {\n return texture2D(diffuse, vTexCoord);\n }`;\n }\n}\n\nexport class SkyboxNode extends Node {\n constructor(options) {\n super();\n\n this._url = options.url;\n this._displayMode = options.displayMode || 'mono';\n this._rotationY = options.rotationY || 0;\n }\n\n onRendererChanged(renderer) {\n let vertices = [];\n let indices = [];\n\n let latSegments = 40;\n let lonSegments = 40;\n\n // Create the vertices/indices\n for (let i=0; i <= latSegments; ++i) {\n let theta = i * Math.PI / latSegments;\n let sinTheta = Math.sin(theta);\n let cosTheta = Math.cos(theta);\n\n let idxOffsetA = i * (lonSegments+1);\n let idxOffsetB = (i+1) * (lonSegments+1);\n\n for (let j=0; j <= lonSegments; ++j) {\n let phi = (j * 2 * Math.PI / lonSegments) + this._rotationY;\n let x = Math.sin(phi) * sinTheta;\n let y = cosTheta;\n let z = -Math.cos(phi) * sinTheta;\n let u = (j / lonSegments);\n let v = (i / latSegments);\n\n // Vertex shader will force the geometry to the far plane, so the\n // radius of the sphere is immaterial.\n vertices.push(x, y, z, u, v);\n\n if (i < latSegments && j < lonSegments) {\n let idxA = idxOffsetA+j;\n let idxB = idxOffsetB+j;\n\n indices.push(idxA, idxB, idxA+1,\n idxB, idxB+1, idxA+1);\n }\n }\n }\n\n let vertexBuffer = renderer.createRenderBuffer(GL.ARRAY_BUFFER, new Float32Array(vertices));\n let indexBuffer = renderer.createRenderBuffer(GL.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices));\n\n let attribs = [\n new PrimitiveAttribute('POSITION', vertexBuffer, 3, GL.FLOAT, 20, 0),\n new PrimitiveAttribute('TEXCOORD_0', vertexBuffer, 2, GL.FLOAT, 20, 12),\n ];\n\n let primitive = new Primitive(attribs, indices.length);\n primitive.setIndexBuffer(indexBuffer);\n\n let material = new SkyboxMaterial();\n material.image.texture = new UrlTexture(this._url);\n\n switch (this._displayMode) {\n case 'mono':\n material.texCoordScaleOffset.value = [1.0, 1.0, 0.0, 0.0,\n 1.0, 1.0, 0.0, 0.0];\n break;\n case 'stereoTopBottom':\n material.texCoordScaleOffset.value = [1.0, 0.5, 0.0, 0.0,\n 1.0, 0.5, 0.0, 0.5];\n break;\n case 'stereoLeftRight':\n material.texCoordScaleOffset.value = [0.5, 1.0, 0.0, 0.0,\n 0.5, 1.0, 0.5, 0.0];\n break;\n }\n\n let renderPrimitive = renderer.createRenderPrimitive(primitive, material);\n this.addRenderPrimitive(renderPrimitive);\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n/*\nHeavily inspired by Mr. Doobs stats.js, this FPS counter is rendered completely\nwith WebGL, allowing it to be shown in cases where overlaid HTML elements aren't\nusable (like WebXR), or if you want the FPS counter to be rendered as part of\nyour scene.\n*/\n\nimport {Material} from '../core/material.js';\nimport {Node} from '../core/node.js';\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\nimport {SevenSegmentText} from './seven-segment-text.js';\n\nconst SEGMENTS = 30;\nconst MAX_FPS = 90;\n\nclass StatsMaterial extends Material {\n get materialName() {\n return 'STATS_VIEWER';\n }\n\n get vertexSource() {\n return `\n attribute vec3 POSITION;\n attribute vec3 COLOR_0;\n varying vec4 vColor;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vColor = vec4(COLOR_0, 1.0);\n return proj * view * model * vec4(POSITION, 1.0);\n }`;\n }\n\n get fragmentSource() {\n return `\n precision mediump float;\n varying vec4 vColor;\n\n vec4 fragment_main() {\n return vColor;\n }`;\n }\n}\n\nfunction segmentToX(i) {\n return ((0.9/SEGMENTS) * i) - 0.45;\n}\n\nfunction fpsToY(value) {\n return (Math.min(value, MAX_FPS) * (0.7 / MAX_FPS)) - 0.45;\n}\n\nfunction fpsToRGB(value) {\n return {\n r: Math.max(0.0, Math.min(1.0, 1.0 - (value/60))),\n g: Math.max(0.0, Math.min(1.0, ((value-15)/(MAX_FPS-15)))),\n b: Math.max(0.0, Math.min(1.0, ((value-15)/(MAX_FPS-15)))),\n };\n}\n\nlet now = (window.performance && performance.now) ? performance.now.bind(performance) : Date.now;\n\nexport class StatsViewer extends Node {\n constructor() {\n super();\n\n this._performanceMonitoring = false;\n\n this._startTime = now();\n this._prevFrameTime = this._startTime;\n this._prevGraphUpdateTime = this._startTime;\n this._frames = 0;\n this._fpsAverage = 0;\n this._fpsMin = 0;\n this._fpsStep = this._performanceMonitoring ? 1000 : 250;\n this._lastSegment = 0;\n\n this._fpsVertexBuffer = null;\n this._fpsRenderPrimitive = null;\n this._fpsNode = null;\n\n this._sevenSegmentNode = new SevenSegmentText();\n // Hard coded because it doesn't change:\n // Scale by 0.075 in X and Y\n // Translate into upper left corner w/ z = 0.02\n this._sevenSegmentNode.matrix = new Float32Array([\n 0.075, 0, 0, 0,\n 0, 0.075, 0, 0,\n 0, 0, 1, 0,\n -0.3625, 0.3625, 0.02, 1,\n ]);\n }\n\n onRendererChanged(renderer) {\n this.clearNodes();\n\n let gl = renderer.gl;\n\n let fpsVerts = [];\n let fpsIndices = [];\n\n // Graph geometry\n for (let i = 0; i < SEGMENTS; ++i) {\n // Bar top\n fpsVerts.push(segmentToX(i), fpsToY(0), 0.02, 0.0, 1.0, 1.0);\n fpsVerts.push(segmentToX(i+1), fpsToY(0), 0.02, 0.0, 1.0, 1.0);\n\n // Bar bottom\n fpsVerts.push(segmentToX(i), fpsToY(0), 0.02, 0.0, 1.0, 1.0);\n fpsVerts.push(segmentToX(i+1), fpsToY(0), 0.02, 0.0, 1.0, 1.0);\n\n let idx = i * 4;\n fpsIndices.push(idx, idx+3, idx+1,\n idx+3, idx, idx+2);\n }\n\n function addBGSquare(left, bottom, right, top, z, r, g, b) {\n let idx = fpsVerts.length / 6;\n\n fpsVerts.push(left, bottom, z, r, g, b);\n fpsVerts.push(right, top, z, r, g, b);\n fpsVerts.push(left, top, z, r, g, b);\n fpsVerts.push(right, bottom, z, r, g, b);\n\n fpsIndices.push(idx, idx+1, idx+2,\n idx, idx+3, idx+1);\n }\n\n // Panel Background\n addBGSquare(-0.5, -0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.125);\n\n // FPS Background\n addBGSquare(-0.45, -0.45, 0.45, 0.25, 0.01, 0.0, 0.0, 0.4);\n\n // 30 FPS line\n addBGSquare(-0.45, fpsToY(30), 0.45, fpsToY(32), 0.015, 0.5, 0.0, 0.5);\n\n // 60 FPS line\n addBGSquare(-0.45, fpsToY(60), 0.45, fpsToY(62), 0.015, 0.2, 0.0, 0.75);\n\n this._fpsVertexBuffer = renderer.createRenderBuffer(gl.ARRAY_BUFFER, new Float32Array(fpsVerts), gl.DYNAMIC_DRAW);\n let fpsIndexBuffer = renderer.createRenderBuffer(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(fpsIndices));\n\n let fpsAttribs = [\n new PrimitiveAttribute('POSITION', this._fpsVertexBuffer, 3, gl.FLOAT, 24, 0),\n new PrimitiveAttribute('COLOR_0', this._fpsVertexBuffer, 3, gl.FLOAT, 24, 12),\n ];\n\n let fpsPrimitive = new Primitive(fpsAttribs, fpsIndices.length);\n fpsPrimitive.setIndexBuffer(fpsIndexBuffer);\n fpsPrimitive.setBounds([-0.5, -0.5, 0.0], [0.5, 0.5, 0.015]);\n\n this._fpsRenderPrimitive = renderer.createRenderPrimitive(fpsPrimitive, new StatsMaterial());\n this._fpsNode = new Node();\n this._fpsNode.addRenderPrimitive(this._fpsRenderPrimitive);\n\n this.addNode(this._fpsNode);\n this.addNode(this._sevenSegmentNode);\n }\n\n get performanceMonitoring() {\n return this._performanceMonitoring;\n }\n\n set performanceMonitoring(value) {\n this._performanceMonitoring = value;\n this._fpsStep = value ? 1000 : 250;\n }\n\n begin() {\n this._startTime = now();\n }\n\n end() {\n let time = now();\n\n let frameFps = 1000 / (time - this._prevFrameTime);\n this._prevFrameTime = time;\n this._fpsMin = this._frames ? Math.min(this._fpsMin, frameFps) : frameFps;\n this._frames++;\n\n if (time > this._prevGraphUpdateTime + this._fpsStep) {\n let intervalTime = time - this._prevGraphUpdateTime;\n this._fpsAverage = Math.round(1000 / (intervalTime / this._frames));\n\n // Draw both average and minimum FPS for this period\n // so that dropped frames are more clearly visible.\n this._updateGraph(this._fpsMin, this._fpsAverage);\n if (this._performanceMonitoring) {\n console.log(`Average FPS: ${this._fpsAverage} Min FPS: ${this._fpsMin}`);\n }\n\n this._prevGraphUpdateTime = time;\n this._frames = 0;\n this._fpsMin = 0;\n }\n }\n\n _updateGraph(valueLow, valueHigh) {\n let color = fpsToRGB(valueLow);\n // Draw a range from the low to high value. Artificially widen the\n // range a bit to ensure that near-equal values still remain\n // visible - the logic here should match that used by the\n // \"60 FPS line\" setup below. Hitting 60fps consistently will\n // keep the top half of the 60fps background line visible.\n let y0 = fpsToY(valueLow - 1);\n let y1 = fpsToY(valueHigh + 1);\n\n // Update the current segment with the new FPS value\n let updateVerts = [\n segmentToX(this._lastSegment), y1, 0.02, color.r, color.g, color.b,\n segmentToX(this._lastSegment+1), y1, 0.02, color.r, color.g, color.b,\n segmentToX(this._lastSegment), y0, 0.02, color.r, color.g, color.b,\n segmentToX(this._lastSegment+1), y0, 0.02, color.r, color.g, color.b,\n ];\n\n // Re-shape the next segment into the green \"progress\" line\n color.r = 0.2;\n color.g = 1.0;\n color.b = 0.2;\n\n if (this._lastSegment == SEGMENTS - 1) {\n // If we're updating the last segment we need to do two bufferSubDatas\n // to update the segment and turn the first segment into the progress line.\n this._renderer.updateRenderBuffer(this._fpsVertexBuffer, new Float32Array(updateVerts),\n this._lastSegment * 24 * 4);\n updateVerts = [\n segmentToX(0), fpsToY(MAX_FPS), 0.02, color.r, color.g, color.b,\n segmentToX(.25), fpsToY(MAX_FPS), 0.02, color.r, color.g, color.b,\n segmentToX(0), fpsToY(0), 0.02, color.r, color.g, color.b,\n segmentToX(.25), fpsToY(0), 0.02, color.r, color.g, color.b,\n ];\n this._renderer.updateRenderBuffer(this._fpsVertexBuffer, new Float32Array(updateVerts), 0);\n } else {\n updateVerts.push(\n segmentToX(this._lastSegment+1), fpsToY(MAX_FPS), 0.02, color.r, color.g, color.b,\n segmentToX(this._lastSegment+1.25), fpsToY(MAX_FPS), 0.02, color.r, color.g, color.b,\n segmentToX(this._lastSegment+1), fpsToY(0), 0.02, color.r, color.g, color.b,\n segmentToX(this._lastSegment+1.25), fpsToY(0), 0.02, color.r, color.g, color.b\n );\n this._renderer.updateRenderBuffer(this._fpsVertexBuffer, new Float32Array(updateVerts),\n this._lastSegment * 24 * 4);\n }\n\n this._lastSegment = (this._lastSegment+1) % SEGMENTS;\n\n this._sevenSegmentNode.text = `${this._fpsAverage} FP5`;\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n/*\nNode for displaying 2D or stereo videos on a quad.\n*/\n\nimport {Material} from '../core/material.js';\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\nimport {Node} from '../core/node.js';\nimport {VideoTexture} from '../core/texture.js';\n\nconst GL = WebGLRenderingContext; // For enums\n\nclass VideoMaterial extends Material {\n constructor() {\n super();\n\n this.image = this.defineSampler('diffuse');\n\n this.texCoordScaleOffset = this.defineUniform('texCoordScaleOffset',\n [1.0, 1.0, 0.0, 0.0,\n 1.0, 1.0, 0.0, 0.0], 4);\n }\n\n get materialName() {\n return 'VIDEO_PLAYER';\n }\n\n get vertexSource() {\n return `\n uniform int EYE_INDEX;\n uniform vec4 texCoordScaleOffset[2];\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n varying vec2 vTexCoord;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vec4 scaleOffset = texCoordScaleOffset[EYE_INDEX];\n vTexCoord = (TEXCOORD_0 * scaleOffset.xy) + scaleOffset.zw;\n vec4 out_vec = proj * view * model * vec4(POSITION, 1.0);\n return out_vec;\n }`;\n }\n\n get fragmentSource() {\n return `\n uniform sampler2D diffuse;\n varying vec2 vTexCoord;\n\n vec4 fragment_main() {\n return texture2D(diffuse, vTexCoord);\n }`;\n }\n}\n\nexport class VideoNode extends Node {\n constructor(options) {\n super();\n\n this._video = options.video;\n this._displayMode = options.displayMode || 'mono';\n\n this._video_texture = new VideoTexture(this._video);\n }\n\n get aspectRatio() {\n let width = this._video.videoWidth;\n let height = this._video.videoHeight;\n\n switch (this._displayMode) {\n case 'stereoTopBottom': height *= 0.5; break;\n case 'stereoLeftRight': width *= 0.5; break;\n }\n\n if (!height || !width) {\n return 1;\n }\n\n return width / height;\n }\n\n onRendererChanged(renderer) {\n let vertices = [\n -1.0, 1.0, 0.0, 0.0, 0.0,\n 1.0, 1.0, 0.0, 1.0, 0.0,\n 1.0, -1.0, 0.0, 1.0, 1.0,\n -1.0, -1.0, 0.0, 0.0, 1.0,\n ];\n let indices = [\n 0, 2, 1,\n 0, 3, 2,\n ];\n\n let vertexBuffer = renderer.createRenderBuffer(GL.ARRAY_BUFFER, new Float32Array(vertices));\n let indexBuffer = renderer.createRenderBuffer(GL.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices));\n\n let attribs = [\n new PrimitiveAttribute('POSITION', vertexBuffer, 3, GL.FLOAT, 20, 0),\n new PrimitiveAttribute('TEXCOORD_0', vertexBuffer, 2, GL.FLOAT, 20, 12),\n ];\n\n let primitive = new Primitive(attribs, indices.length);\n primitive.setIndexBuffer(indexBuffer);\n primitive.setBounds([-1.0, -1.0, 0.0], [1.0, 1.0, 0.015]);\n\n let material = new VideoMaterial();\n material.image.texture = this._video_texture;\n\n switch (this._displayMode) {\n case 'mono':\n material.texCoordScaleOffset.value = [1.0, 1.0, 0.0, 0.0,\n 1.0, 1.0, 0.0, 0.0];\n break;\n case 'stereoTopBottom':\n material.texCoordScaleOffset.value = [1.0, 0.5, 0.0, 0.0,\n 1.0, 0.5, 0.0, 0.5];\n break;\n case 'stereoLeftRight':\n material.texCoordScaleOffset.value = [0.5, 1.0, 0.0, 0.0,\n 0.5, 1.0, 0.5, 0.0];\n break;\n }\n\n let renderPrimitive = renderer.createRenderPrimitive(primitive, material);\n this.addRenderPrimitive(renderPrimitive);\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {RenderView} from '../core/renderer.js';\nimport {InputRenderer} from '../nodes/input-renderer.js';\nimport {StatsViewer} from '../nodes/stats-viewer.js';\nimport {Node} from '../core/node.js';\nimport {vec3, quat} from '../math/gl-matrix.js';\n\nexport class WebXRView extends RenderView {\n constructor(view, pose, layer) {\n super(\n view ? view.projectionMatrix : null,\n (pose && view) ? view.viewMatrix : null,\n (layer && view) ? layer.getViewport(view) : null,\n view ? view.eye : 'left'\n );\n }\n}\n\nexport class Scene extends Node {\n constructor() {\n super();\n\n this._timestamp = -1;\n this._frameDelta = 0;\n this._statsStanding = false;\n this._stats = null;\n this._statsEnabled = false;\n this.enableStats(true); // Ensure the stats are added correctly by default.\n\n this._inputRenderer = null;\n this._resetInputEndFrame = true;\n\n this._lastTimestamp = 0;\n\n this._hoverFrame = 0;\n this._hoveredNodes = [];\n\n this.clear = true;\n }\n\n setRenderer(renderer) {\n this._setRenderer(renderer);\n }\n\n loseRenderer() {\n if (this._renderer) {\n this._stats = null;\n this._renderer = null;\n this._inputRenderer = null;\n }\n }\n\n get inputRenderer() {\n if (!this._inputRenderer) {\n this._inputRenderer = new InputRenderer();\n this.addNode(this._inputRenderer);\n }\n return this._inputRenderer;\n }\n\n // Helper function that automatically adds the appropriate visual elements for\n // all input sources.\n updateInputSources(frame, refSpace) {\n // FIXME: Check for the existence of the API first. This check should be\n // removed once the input API is part of the official spec.\n if (!frame.session.getInputSources) {\n return;\n }\n\n let inputSources = frame.session.getInputSources();\n\n let newHoveredNodes = [];\n let lastHoverFrame = this._hoverFrame;\n this._hoverFrame++;\n\n for (let inputSource of inputSources) {\n let inputPose = frame.getInputPose(inputSource, refSpace);\n\n if (!inputPose) {\n continue;\n }\n\n // Any time that we have a grip matrix, we'll render a controller.\n if (inputPose.gripTransform.matrix) {\n this.inputRenderer.addController(inputPose.gripTransform.matrix);\n }\n\n if (inputPose.targetRay) {\n if (inputSource.targetRayMode == 'tracked-pointer') {\n // If we have a pointer matrix and the pointer origin is the users\n // hand (as opposed to their head or the screen) use it to render\n // a ray coming out of the input device to indicate the pointer\n // direction.\n this.inputRenderer.addLaserPointer(inputPose.targetRay);\n }\n\n // If we have a pointer matrix we can also use it to render a cursor\n // for both handheld and gaze-based input sources.\n\n // Check and see if the pointer is pointing at any selectable objects.\n let hitResult = this.hitTest(inputPose.targetRay);\n\n if (hitResult) {\n // Render a cursor at the intersection point.\n this.inputRenderer.addCursor(hitResult.intersection);\n\n if (hitResult.node._hoverFrameId != lastHoverFrame) {\n hitResult.node.onHoverStart();\n }\n hitResult.node._hoverFrameId = this._hoverFrame;\n newHoveredNodes.push(hitResult.node);\n } else {\n // Statically render the cursor 1 meters down the ray since we didn't\n // hit anything selectable.\n let cursorDistance = 1.0;\n let cursorPos = vec3.fromValues(\n inputPose.targetRay.origin.x,\n inputPose.targetRay.origin.y,\n inputPose.targetRay.origin.z\n );\n vec3.add(cursorPos, cursorPos, [\n inputPose.targetRay.direction.x * cursorDistance,\n inputPose.targetRay.direction.y * cursorDistance,\n inputPose.targetRay.direction.z * cursorDistance,\n ]);\n // let cursorPos = vec3.fromValues(0, 0, -1.0);\n // vec3.transformMat4(cursorPos, cursorPos, inputPose.targetRay);\n this.inputRenderer.addCursor(cursorPos);\n }\n }\n }\n\n for (let hoverNode of this._hoveredNodes) {\n if (hoverNode._hoverFrameId != this._hoverFrame) {\n hoverNode.onHoverEnd();\n }\n }\n\n this._hoveredNodes = newHoveredNodes;\n }\n\n handleSelect(inputSource, frame, refSpace) {\n let inputPose = frame.getInputPose(inputSource, refSpace);\n\n if (!inputPose) {\n return;\n }\n\n this.handleSelectPointer(inputPose.targetRay);\n }\n\n handleSelectPointer(targetRay) {\n if (targetRay) {\n // Check and see if the pointer is pointing at any selectable objects.\n let hitResult = this.hitTest(targetRay);\n\n if (hitResult) {\n // Render a cursor at the intersection point.\n hitResult.node.handleSelect();\n }\n }\n }\n\n enableStats(enable) {\n if (enable == this._statsEnabled) {\n return;\n }\n\n this._statsEnabled = enable;\n\n if (enable) {\n this._stats = new StatsViewer();\n this._stats.selectable = true;\n this.addNode(this._stats);\n\n if (this._statsStanding) {\n this._stats.translation = [0, 1.4, -0.75];\n } else {\n this._stats.translation = [0, -0.3, -0.5];\n }\n this._stats.scale = [0.3, 0.3, 0.3];\n quat.fromEuler(this._stats.rotation, -45.0, 0.0, 0.0);\n } else if (!enable) {\n if (this._stats) {\n this.removeNode(this._stats);\n this._stats = null;\n }\n }\n }\n\n standingStats(enable) {\n this._statsStanding = enable;\n if (this._stats) {\n if (this._statsStanding) {\n this._stats.translation = [0, 1.4, -0.75];\n } else {\n this._stats.translation = [0, -0.3, -0.5];\n }\n this._stats.scale = [0.3, 0.3, 0.3];\n quat.fromEuler(this._stats.rotation, -45.0, 0.0, 0.0);\n }\n }\n\n draw(projectionMatrix, viewMatrix, eye) {\n let view = new RenderView();\n view.projectionMatrix = projectionMatrix;\n view.viewMatrix = viewMatrix;\n if (eye) {\n view.eye = eye;\n }\n\n this.drawViewArray([view]);\n }\n\n /** Draws the scene into the base layer of the XRFrame's session */\n drawXRFrame(xrFrame, pose) {\n if (!this._renderer || !pose) {\n return;\n }\n\n let gl = this._renderer.gl;\n let session = xrFrame.session;\n // Assumed to be a XRWebGLLayer for now.\n let layer = session.renderState.baseLayer;\n\n if (!gl) {\n return;\n }\n\n gl.bindFramebuffer(gl.FRAMEBUFFER, layer.framebuffer);\n\n if (this.clear) {\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n }\n\n let views = [];\n for (let view of pose.views) {\n views.push(new WebXRView(view, pose, layer));\n }\n\n this.drawViewArray(views);\n }\n\n drawViewArray(views) {\n // Don't draw when we don't have a valid context\n if (!this._renderer) {\n return;\n }\n\n this._renderer.drawViews(views, this);\n }\n\n startFrame() {\n let prevTimestamp = this._timestamp;\n this._timestamp = performance.now();\n if (this._stats) {\n this._stats.begin();\n }\n\n if (prevTimestamp >= 0) {\n this._frameDelta = this._timestamp - prevTimestamp;\n } else {\n this._frameDelta = 0;\n }\n\n this._update(this._timestamp, this._frameDelta);\n\n return this._frameDelta;\n }\n\n endFrame() {\n if (this._inputRenderer && this._resetInputEndFrame) {\n this._inputRenderer.reset();\n }\n\n if (this._stats) {\n this._stats.end();\n }\n }\n\n // Override to load scene resources on construction or context restore.\n onLoadScene(renderer) {\n return Promise.resolve();\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {mat4} from '../math/gl-matrix.js';\n\nconst LOOK_SPEED = 0.0025;\n\nexport class FallbackHelper {\n constructor(scene, gl) {\n this.scene = scene;\n this.gl = gl;\n this._emulateStage = false;\n\n this.lookYaw = 0;\n this.lookPitch = 0;\n\n this.viewMatrix = mat4.create();\n\n let projectionMatrix = mat4.create();\n this.projectionMatrix = projectionMatrix;\n\n // Using a simple identity matrix for the view.\n mat4.identity(this.viewMatrix);\n\n // We need to track the canvas size in order to resize the WebGL\n // backbuffer width and height, as well as update the projection matrix\n // and adjust the viewport.\n function onResize() {\n gl.canvas.width = gl.canvas.offsetWidth * window.devicePixelRatio;\n gl.canvas.height = gl.canvas.offsetHeight * window.devicePixelRatio;\n mat4.perspective(projectionMatrix, Math.PI*0.4,\n gl.canvas.width/gl.canvas.height,\n 0.1, 1000.0);\n gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);\n }\n window.addEventListener('resize', onResize);\n onResize();\n\n // Upding the view matrix with touch or mouse events.\n let canvas = gl.canvas;\n let lastTouchX = 0;\n let lastTouchY = 0;\n canvas.addEventListener('touchstart', (ev) => {\n if (ev.touches.length == 2) {\n lastTouchX = ev.touches[1].pageX;\n lastTouchY = ev.touches[1].pageY;\n }\n });\n canvas.addEventListener('touchmove', (ev) => {\n // Rotate the view when two fingers are being used.\n if (ev.touches.length == 2) {\n this.onLook(ev.touches[1].pageX - lastTouchX, ev.touches[1].pageY - lastTouchY);\n lastTouchX = ev.touches[1].pageX;\n lastTouchY = ev.touches[1].pageY;\n }\n });\n canvas.addEventListener('mousemove', (ev) => {\n // Only rotate when the right button is pressed.\n if (ev.buttons & 2) {\n this.onLook(ev.movementX, ev.movementY);\n }\n });\n canvas.addEventListener('contextmenu', (ev) => {\n // Prevent context menus on the canvas so that we can use right click to rotate.\n ev.preventDefault();\n });\n\n this.boundOnFrame = this.onFrame.bind(this);\n window.requestAnimationFrame(this.boundOnFrame);\n }\n\n onLook(yaw, pitch) {\n this.lookYaw += yaw * LOOK_SPEED;\n this.lookPitch += pitch * LOOK_SPEED;\n\n // Clamp pitch rotation beyond looking straight up or down.\n if (this.lookPitch < -Math.PI*0.5) {\n this.lookPitch = -Math.PI*0.5;\n }\n if (this.lookPitch > Math.PI*0.5) {\n this.lookPitch = Math.PI*0.5;\n }\n\n this.updateView();\n }\n\n onFrame(t) {\n let gl = this.gl;\n window.requestAnimationFrame(this.boundOnFrame);\n\n this.scene.startFrame();\n\n // We can skip setting the framebuffer and viewport every frame, because\n // it won't change from frame to frame and we're updating the viewport\n // only when we resize for efficency.\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n // We're drawing with our own projection and view matrix now, and we\n // don't have a list of view to loop through, but otherwise all of the\n // WebGL drawing logic is exactly the same.\n this.scene.draw(this.projectionMatrix, this.viewMatrix);\n\n this.scene.endFrame();\n }\n\n get emulateStage() {\n return this._emulateStage;\n }\n\n set emulateStage(value) {\n this._emulateStage = value;\n this.updateView();\n }\n\n updateView() {\n mat4.identity(this.viewMatrix);\n\n mat4.rotateX(this.viewMatrix, this.viewMatrix, -this.lookPitch);\n mat4.rotateY(this.viewMatrix, this.viewMatrix, -this.lookYaw);\n\n // If we're emulating a stage frame of reference we'll need to move the view\n // matrix roughly a meter and a half up in the air.\n if (this._emulateStage) {\n mat4.translate(this.viewMatrix, this.viewMatrix, [0, -1.6, 0]);\n }\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n/*\nProvides a simple way to get values from the query string if they're present\nand use a default value if not. Not strictly a \"WebGL\" utility, but I use it\nfrequently enough for debugging that I wanted to include it here.\n\nExample:\nFor the URL http://example.com/index.html?particleCount=1000\n\nQueryArgs.getInt(\"particleCount\", 100); // URL overrides, returns 1000\nQueryArgs.getInt(\"particleSize\", 10); // Not in URL, returns default of 10\n*/\n\nlet urlArgs = null;\nwindow.onhashchange = function() {\n // Force re-parsing on next access\n urlArgs = null;\n};\n\nfunction ensureArgsCached() {\n if (!urlArgs) {\n urlArgs = {};\n let query = window.location.search.substring(1) || window.location.hash.substring(1);\n let vars = query.split('&');\n for (let i = 0; i < vars.length; i++) {\n let pair = vars[i].split('=');\n urlArgs[pair[0].toLowerCase()] = decodeURIComponent(pair[1]);\n }\n }\n}\n\nexport class QueryArgs {\n static getString(name, defaultValue) {\n ensureArgsCached();\n let lcaseName = name.toLowerCase();\n if (lcaseName in urlArgs) {\n return urlArgs[lcaseName];\n }\n return defaultValue;\n }\n\n static getInt(name, defaultValue) {\n ensureArgsCached();\n let lcaseName = name.toLowerCase();\n if (lcaseName in urlArgs) {\n return parseInt(urlArgs[lcaseName], 10);\n }\n return defaultValue;\n }\n\n static getFloat(name, defaultValue) {\n ensureArgsCached();\n let lcaseName = name.toLowerCase();\n if (lcaseName in urlArgs) {\n return parseFloat(urlArgs[lcaseName]);\n }\n return defaultValue;\n }\n\n static getBool(name, defaultValue) {\n ensureArgsCached();\n let lcaseName = name.toLowerCase();\n if (lcaseName in urlArgs) {\n return parseInt(urlArgs[lcaseName], 10) != 0;\n }\n return defaultValue;\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/js/cottontail/build/cottontail.js b/js/cottontail/build/cottontail.js deleted file mode 100644 index 5b9bab7a0..000000000 --- a/js/cottontail/build/cottontail.js +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * Copyright 2018 The Immersive Web Community Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(window,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=15)}([function(t,e,r){"use strict";r.r(e),r.d(e,"EPSILON",function(){return n}),r.d(e,"ARRAY_TYPE",function(){return i}),r.d(e,"RANDOM",function(){return o}),r.d(e,"setMatrixArrayType",function(){return a}),r.d(e,"toRadian",function(){return s}),r.d(e,"equals",function(){return c});const n=1e-6;let i="undefined"!=typeof Float32Array?Float32Array:Array;const o=Math.random;function a(t){i=t}const u=Math.PI/180;function s(t){return t*u}function c(t,e){return Math.abs(t-e)<=n*Math.max(1,Math.abs(t),Math.abs(e))}},function(t,e,r){"use strict";r.r(e),r.d(e,"create",function(){return i}),r.d(e,"clone",function(){return o}),r.d(e,"fromValues",function(){return a}),r.d(e,"copy",function(){return u}),r.d(e,"set",function(){return s}),r.d(e,"add",function(){return c}),r.d(e,"subtract",function(){return f}),r.d(e,"multiply",function(){return l}),r.d(e,"divide",function(){return h}),r.d(e,"ceil",function(){return d}),r.d(e,"floor",function(){return v}),r.d(e,"min",function(){return _}),r.d(e,"max",function(){return m}),r.d(e,"round",function(){return p}),r.d(e,"scale",function(){return y}),r.d(e,"scaleAndAdd",function(){return b}),r.d(e,"distance",function(){return g}),r.d(e,"squaredDistance",function(){return M}),r.d(e,"length",function(){return x}),r.d(e,"squaredLength",function(){return T}),r.d(e,"negate",function(){return E}),r.d(e,"inverse",function(){return w}),r.d(e,"normalize",function(){return O}),r.d(e,"dot",function(){return R}),r.d(e,"lerp",function(){return P}),r.d(e,"random",function(){return S}),r.d(e,"transformMat4",function(){return A}),r.d(e,"transformQuat",function(){return N}),r.d(e,"str",function(){return C}),r.d(e,"exactEquals",function(){return I}),r.d(e,"equals",function(){return L}),r.d(e,"sub",function(){return k}),r.d(e,"mul",function(){return F}),r.d(e,"div",function(){return D}),r.d(e,"dist",function(){return j}),r.d(e,"sqrDist",function(){return B}),r.d(e,"len",function(){return U}),r.d(e,"sqrLen",function(){return V}),r.d(e,"forEach",function(){return Y});var n=r(0);function i(){let t=new n.ARRAY_TYPE(4);return n.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function o(t){let e=new n.ARRAY_TYPE(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function a(t,e,r,i){let o=new n.ARRAY_TYPE(4);return o[0]=t,o[1]=e,o[2]=r,o[3]=i,o}function u(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function s(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}function c(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function f(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function l(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function h(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function d(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t}function v(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t}function _(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}function m(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}function p(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t[3]=Math.round(e[3]),t}function y(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function b(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t}function g(t,e){let r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],o=e[3]-t[3];return Math.sqrt(r*r+n*n+i*i+o*o)}function M(t,e){let r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],o=e[3]-t[3];return r*r+n*n+i*i+o*o}function x(t){let e=t[0],r=t[1],n=t[2],i=t[3];return Math.sqrt(e*e+r*r+n*n+i*i)}function T(t){let e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}function E(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}function w(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}function O(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],a=r*r+n*n+i*i+o*o;return a>0&&(a=1/Math.sqrt(a),t[0]=r*a,t[1]=n*a,t[2]=i*a,t[3]=o*a),t}function R(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function P(t,e,r,n){let i=e[0],o=e[1],a=e[2],u=e[3];return t[0]=i+n*(r[0]-i),t[1]=o+n*(r[1]-o),t[2]=a+n*(r[2]-a),t[3]=u+n*(r[3]-u),t}function S(t,e){var r,i,o,a,u,s;e=e||1;do{u=(r=2*n.RANDOM()-1)*r+(i=2*n.RANDOM()-1)*i}while(u>=1);do{s=(o=2*n.RANDOM()-1)*o+(a=2*n.RANDOM()-1)*a}while(s>=1);var c=Math.sqrt((1-u)/s);return t[0]=e*r,t[1]=e*i,t[2]=e*o*c,t[3]=e*a*c,t}function A(t,e,r){let n=e[0],i=e[1],o=e[2],a=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*o+r[12]*a,t[1]=r[1]*n+r[5]*i+r[9]*o+r[13]*a,t[2]=r[2]*n+r[6]*i+r[10]*o+r[14]*a,t[3]=r[3]*n+r[7]*i+r[11]*o+r[15]*a,t}function N(t,e,r){let n=e[0],i=e[1],o=e[2],a=r[0],u=r[1],s=r[2],c=r[3],f=c*n+u*o-s*i,l=c*i+s*n-a*o,h=c*o+a*i-u*n,d=-a*n-u*i-s*o;return t[0]=f*c+d*-a+l*-s-h*-u,t[1]=l*c+d*-u+h*-a-f*-s,t[2]=h*c+d*-s+f*-u-l*-a,t[3]=e[3],t}function C(t){return"vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function I(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function L(t,e){let r=t[0],i=t[1],o=t[2],a=t[3],u=e[0],s=e[1],c=e[2],f=e[3];return Math.abs(r-u)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(i-s)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(o-c)<=n.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))&&Math.abs(a-f)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(f))}const k=f,F=l,D=h,j=g,B=M,U=x,V=T,Y=function(){let t=i();return function(e,r,n,i,o,a){let u,s;for(r||(r=4),n||(n=0),s=i?Math.min(i*r+n,e.length):e.length,u=n;u-1&&(this.children.splice(e,1),t.parent=null)}},{key:"clearNodes",value:function(){var t=!0,e=!1,r=void 0;try{for(var n,i=this.children[Symbol.iterator]();!(t=(n=i.next()).done);t=!0){n.value.parent=null}}catch(t){e=!0,r=t}finally{try{!t&&i.return&&i.return()}finally{if(e)throw r}}this.children=[]}},{key:"setMatrixDirty",value:function(){if(!this._dirtyWorldMatrix){this._dirtyWorldMatrix=!0;var t=!0,e=!1,r=void 0;try{for(var n,i=this.children[Symbol.iterator]();!(t=(n=i.next()).done);t=!0){n.value.setMatrixDirty()}}catch(t){e=!0,r=t}finally{try{!t&&i.return&&i.return()}finally{if(e)throw r}}}}},{key:"_updateLocalMatrix",value:function(){return this._matrix||(this._matrix=o.mat4.create()),this._dirtyTRS&&(this._dirtyTRS=!1,o.mat4.fromRotationTranslationScale(this._matrix,this._rotation||u,this._translation||a,this._scale||s)),this._matrix}},{key:"waitForComplete",value:function(){var t=this,e=[],r=!0,n=!1,i=void 0;try{for(var o,a=this.children[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var u=o.value;e.push(u.waitForComplete())}}catch(t){n=!0,i=t}finally{try{!r&&a.return&&a.return()}finally{if(n)throw i}}if(this._renderPrimitives){var s=!0,c=!1,f=void 0;try{for(var l,h=this._renderPrimitives[Symbol.iterator]();!(s=(l=h.next()).done);s=!0){var d=l.value;e.push(d.waitForComplete())}}catch(t){c=!0,f=t}finally{try{!s&&h.return&&h.return()}finally{if(c)throw f}}}return Promise.all(e).then(function(){return t})}},{key:"addRenderPrimitive",value:function(t){this._renderPrimitives?this._renderPrimitives.push(t):this._renderPrimitives=[t],t._instances.push(this)}},{key:"removeRenderPrimitive",value:function(t){if(this._renderPrimitives){var e=this._renderPrimitives._instances.indexOf(t);e>-1&&(this._renderPrimitives._instances.splice(e,1),(e=t._instances.indexOf(this))>-1&&t._instances.splice(e,1),this._renderPrimitives.length||(this._renderPrimitives=null))}}},{key:"clearRenderPrimitives",value:function(){if(this._renderPrimitives){var t=!0,e=!1,r=void 0;try{for(var n,i=this._renderPrimitives[Symbol.iterator]();!(t=(n=i.next()).done);t=!0){var o=n.value,a=o._instances.indexOf(this);a>-1&&o._instances.splice(a,1)}}catch(t){e=!0,r=t}finally{try{!t&&i.return&&i.return()}finally{if(e)throw r}}this._renderPrimitives=null}}},{key:"_hitTestSelectableNode",value:function(t){if(this._renderPrimitives){var e=null,r=!0,n=!1,a=void 0;try{for(var u,s=this._renderPrimitives[Symbol.iterator]();!(r=(u=s.next()).done);r=!0){var f=u.value;if(f._min){e||(o.mat4.invert(c,this.worldMatrix),o.mat4.multiply(c,c,t.transformMatrix),e=new i.Ray(c));var l=e.intersectsAABB(f._min,f._max);if(l)return o.vec3.transformMat4(l,l,this.worldMatrix),l}}}catch(t){n=!0,a=t}finally{try{!r&&s.return&&s.return()}finally{if(n)throw a}}}var h=!0,d=!1,v=void 0;try{for(var _,m=this.children[Symbol.iterator]();!(h=(_=m.next()).done);h=!0){var p=_.value._hitTestSelectableNode(t);if(p)return p}}catch(t){d=!0,v=t}finally{try{!h&&m.return&&m.return()}finally{if(d)throw v}}return null}},{key:"hitTest",value:function(t){if(this.selectable&&this.visible){var e=this._hitTestSelectableNode(t);if(e){var r=o.vec3.fromValues(t.origin.x,t.origin.y,t.origin.z);return{node:this,intersection:e,distance:o.vec3.distance(r,e)}}return null}var n=null,i=!0,a=!1,u=void 0;try{for(var s,c=this.children[Symbol.iterator]();!(i=(s=c.next()).done);i=!0){var f=s.value.hitTest(t);f&&(!n||n.distance>f.distance)&&(n=f)}}catch(t){a=!0,u=t}finally{try{!i&&c.return&&c.return()}finally{if(a)throw u}}return n}},{key:"onSelect",value:function(t){this._selectHandler=t}},{key:"handleSelect",value:function(){this._selectHandler&&this._selectHandler()}},{key:"onHoverStart",value:function(){}},{key:"onHoverEnd",value:function(){}},{key:"_update",value:function(t,e){this.onUpdate(t,e);var r=!0,n=!1,i=void 0;try{for(var o,a=this.children[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){o.value._update(t,e)}}catch(t){n=!0,i=t}finally{try{!r&&a.return&&a.return()}finally{if(n)throw i}}}},{key:"onUpdate",value:function(t,e){}},{key:"matrix",set:function(t){t?(this._matrix||(this._matrix=o.mat4.create()),o.mat4.copy(this._matrix,t)):this._matrix=null,this.setMatrixDirty(),this._dirtyTRS=!1,this._translation=null,this._rotation=null,this._scale=null},get:function(){return this.setMatrixDirty(),this._updateLocalMatrix()}},{key:"worldMatrix",get:function(){return this._worldMatrix||(this._dirtyWorldMatrix=!0,this._worldMatrix=o.mat4.create()),(this._dirtyWorldMatrix||this._dirtyTRS)&&(this.parent?o.mat4.mul(this._worldMatrix,this.parent.worldMatrix,this._updateLocalMatrix()):o.mat4.copy(this._worldMatrix,this._updateLocalMatrix()),this._dirtyWorldMatrix=!1),this._worldMatrix}},{key:"translation",set:function(t){null!=t&&(this._dirtyTRS=!0,this.setMatrixDirty()),this._translation=t},get:function(){return this._dirtyTRS=!0,this.setMatrixDirty(),this._translation||(this._translation=o.vec3.clone(a)),this._translation}},{key:"rotation",set:function(t){null!=t&&(this._dirtyTRS=!0,this.setMatrixDirty()),this._rotation=t},get:function(){return this._dirtyTRS=!0,this.setMatrixDirty(),this._rotation||(this._rotation=o.quat.clone(u)),this._rotation}},{key:"scale",set:function(t){null!=t&&(this._dirtyTRS=!0,this.setMatrixDirty()),this._scale=t},get:function(){return this._dirtyTRS=!0,this.setMatrixDirty(),this._scale||(this._scale=o.vec3.clone(s)),this._scale}},{key:"renderPrimitives",get:function(){return this._renderPrimitives}},{key:"selectHandler",get:function(){return this._selectHandler}}]),t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var r=0;r>r;switch(n){case 0:case 1:return n;default:return n-2+o.SRC_COLOR}}var f=e.MaterialState=function(){function t(){i(this,t),this._state=a.CULL_FACE|a.DEPTH_TEST|a.COLOR_MASK|a.DEPTH_MASK,this.blendFuncSrc=o.SRC_ALPHA,this.blendFuncDst=o.ONE_MINUS_SRC_ALPHA,this.depthFunc=o.LESS}return n(t,[{key:"cullFace",get:function(){return!!(this._state&a.CULL_FACE)},set:function(t){t?this._state|=a.CULL_FACE:this._state&=~a.CULL_FACE}},{key:"blend",get:function(){return!!(this._state&a.BLEND)},set:function(t){t?this._state|=a.BLEND:this._state&=~a.BLEND}},{key:"depthTest",get:function(){return!!(this._state&a.DEPTH_TEST)},set:function(t){t?this._state|=a.DEPTH_TEST:this._state&=~a.DEPTH_TEST}},{key:"stencilTest",get:function(){return!!(this._state&a.STENCIL_TEST)},set:function(t){t?this._state|=a.STENCIL_TEST:this._state&=~a.STENCIL_TEST}},{key:"colorMask",get:function(){return!!(this._state&a.COLOR_MASK)},set:function(t){t?this._state|=a.COLOR_MASK:this._state&=~a.COLOR_MASK}},{key:"depthMask",get:function(){return!!(this._state&a.DEPTH_MASK)},set:function(t){t?this._state|=a.DEPTH_MASK:this._state&=~a.DEPTH_MASK}},{key:"depthFunc",get:function(){return((this._state&u.DEPTH_FUNC_RANGE)>>u.DEPTH_FUNC_SHIFT)+o.NEVER},set:function(t){t-=o.NEVER,this._state&=~u.DEPTH_FUNC_RANGE,this._state|=t<1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=new h(t,e,r);return this._uniforms.push(n),n}},{key:"getProgramDefines",value:function(t){return{}}},{key:"materialName",get:function(){return null}},{key:"vertexSource",get:function(){return null}},{key:"fragmentSource",get:function(){return null}}]),t}()},function(t,e,r){"use strict";r.r(e),r.d(e,"create",function(){return u}),r.d(e,"identity",function(){return s}),r.d(e,"setAxisAngle",function(){return c}),r.d(e,"getAxisAngle",function(){return f}),r.d(e,"multiply",function(){return l}),r.d(e,"rotateX",function(){return h}),r.d(e,"rotateY",function(){return d}),r.d(e,"rotateZ",function(){return v}),r.d(e,"calculateW",function(){return _}),r.d(e,"slerp",function(){return m}),r.d(e,"random",function(){return p}),r.d(e,"invert",function(){return y}),r.d(e,"conjugate",function(){return b}),r.d(e,"fromMat3",function(){return g}),r.d(e,"fromEuler",function(){return M}),r.d(e,"str",function(){return x}),r.d(e,"clone",function(){return T}),r.d(e,"fromValues",function(){return E}),r.d(e,"copy",function(){return w}),r.d(e,"set",function(){return O}),r.d(e,"add",function(){return R}),r.d(e,"mul",function(){return P}),r.d(e,"scale",function(){return S}),r.d(e,"dot",function(){return A}),r.d(e,"lerp",function(){return N}),r.d(e,"length",function(){return C}),r.d(e,"len",function(){return I}),r.d(e,"squaredLength",function(){return L}),r.d(e,"sqrLen",function(){return k}),r.d(e,"normalize",function(){return F}),r.d(e,"exactEquals",function(){return D}),r.d(e,"equals",function(){return j}),r.d(e,"rotationTo",function(){return B}),r.d(e,"sqlerp",function(){return U}),r.d(e,"setAxes",function(){return V});var n=r(0),i=r(12),o=r(5),a=r(1);function u(){let t=new n.ARRAY_TYPE(4);return n.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function s(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function c(t,e,r){r*=.5;let n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function f(t,e){let r=2*Math.acos(e[3]),i=Math.sin(r/2);return i>n.EPSILON?(t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i):(t[0]=1,t[1]=0,t[2]=0),r}function l(t,e,r){let n=e[0],i=e[1],o=e[2],a=e[3],u=r[0],s=r[1],c=r[2],f=r[3];return t[0]=n*f+a*u+i*c-o*s,t[1]=i*f+a*s+o*u-n*c,t[2]=o*f+a*c+n*s-i*u,t[3]=a*f-n*u-i*s-o*c,t}function h(t,e,r){r*=.5;let n=e[0],i=e[1],o=e[2],a=e[3],u=Math.sin(r),s=Math.cos(r);return t[0]=n*s+a*u,t[1]=i*s+o*u,t[2]=o*s-i*u,t[3]=a*s-n*u,t}function d(t,e,r){r*=.5;let n=e[0],i=e[1],o=e[2],a=e[3],u=Math.sin(r),s=Math.cos(r);return t[0]=n*s-o*u,t[1]=i*s+a*u,t[2]=o*s+n*u,t[3]=a*s-i*u,t}function v(t,e,r){r*=.5;let n=e[0],i=e[1],o=e[2],a=e[3],u=Math.sin(r),s=Math.cos(r);return t[0]=n*s+i*u,t[1]=i*s-n*u,t[2]=o*s+a*u,t[3]=a*s-o*u,t}function _(t,e){let r=e[0],n=e[1],i=e[2];return t[0]=r,t[1]=n,t[2]=i,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),t}function m(t,e,r,i){let o,a,u,s,c,f=e[0],l=e[1],h=e[2],d=e[3],v=r[0],_=r[1],m=r[2],p=r[3];return(a=f*v+l*_+h*m+d*p)<0&&(a=-a,v=-v,_=-_,m=-m,p=-p),1-a>n.EPSILON?(o=Math.acos(a),u=Math.sin(o),s=Math.sin((1-i)*o)/u,c=Math.sin(i*o)/u):(s=1-i,c=i),t[0]=s*f+c*v,t[1]=s*l+c*_,t[2]=s*h+c*m,t[3]=s*d+c*p,t}function p(t){let e=n.RANDOM(),r=n.RANDOM(),i=n.RANDOM(),o=Math.sqrt(1-e),a=Math.sqrt(e);return t[0]=o*Math.sin(2*Math.PI*r),t[1]=o*Math.cos(2*Math.PI*r),t[2]=a*Math.sin(2*Math.PI*i),t[3]=a*Math.cos(2*Math.PI*i),t}function y(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],a=r*r+n*n+i*i+o*o,u=a?1/a:0;return t[0]=-r*u,t[1]=-n*u,t[2]=-i*u,t[3]=o*u,t}function b(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function g(t,e){let r,n=e[0]+e[4]+e[8];if(n>0)r=Math.sqrt(n+1),t[3]=.5*r,r=.5/r,t[0]=(e[5]-e[7])*r,t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{let n=0;e[4]>e[0]&&(n=1),e[8]>e[3*n+n]&&(n=2);let i=(n+1)%3,o=(n+2)%3;r=Math.sqrt(e[3*n+n]-e[3*i+i]-e[3*o+o]+1),t[n]=.5*r,r=.5/r,t[3]=(e[3*i+o]-e[3*o+i])*r,t[i]=(e[3*i+n]+e[3*n+i])*r,t[o]=(e[3*o+n]+e[3*n+o])*r}return t}function M(t,e,r,n){let i=.5*Math.PI/180;e*=i,r*=i,n*=i;let o=Math.sin(e),a=Math.cos(e),u=Math.sin(r),s=Math.cos(r),c=Math.sin(n),f=Math.cos(n);return t[0]=o*s*f-a*u*c,t[1]=a*u*f+o*s*c,t[2]=a*s*c-o*u*f,t[3]=a*s*f+o*u*c,t}function x(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}const T=a.clone,E=a.fromValues,w=a.copy,O=a.set,R=a.add,P=l,S=a.scale,A=a.dot,N=a.lerp,C=a.length,I=C,L=a.squaredLength,k=L,F=a.normalize,D=a.exactEquals,j=a.equals,B=function(){let t=o.create(),e=o.fromValues(1,0,0),r=o.fromValues(0,1,0);return function(n,i,a){let u=o.dot(i,a);return u<-.999999?(o.cross(t,e,i),o.len(t)<1e-6&&o.cross(t,r,i),o.normalize(t,t),c(n,t,Math.PI),n):u>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(o.cross(t,i,a),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+u,F(n,n))}}(),U=function(){let t=u(),e=u();return function(r,n,i,o,a,u){return m(t,n,a,u),m(e,i,o,u),m(r,t,e,2*u*(1-u)),r}}(),V=function(){let t=i.create();return function(e,r,n,i){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=i[0],t[4]=i[1],t[7]=i[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],F(e,g(e,t))}}()},function(t,e,r){"use strict";r.r(e),r.d(e,"create",function(){return i}),r.d(e,"clone",function(){return o}),r.d(e,"length",function(){return a}),r.d(e,"fromValues",function(){return u}),r.d(e,"copy",function(){return s}),r.d(e,"set",function(){return c}),r.d(e,"add",function(){return f}),r.d(e,"subtract",function(){return l}),r.d(e,"multiply",function(){return h}),r.d(e,"divide",function(){return d}),r.d(e,"ceil",function(){return v}),r.d(e,"floor",function(){return _}),r.d(e,"min",function(){return m}),r.d(e,"max",function(){return p}),r.d(e,"round",function(){return y}),r.d(e,"scale",function(){return b}),r.d(e,"scaleAndAdd",function(){return g}),r.d(e,"distance",function(){return M}),r.d(e,"squaredDistance",function(){return x}),r.d(e,"squaredLength",function(){return T}),r.d(e,"negate",function(){return E}),r.d(e,"inverse",function(){return w}),r.d(e,"normalize",function(){return O}),r.d(e,"dot",function(){return R}),r.d(e,"cross",function(){return P}),r.d(e,"lerp",function(){return S}),r.d(e,"hermite",function(){return A}),r.d(e,"bezier",function(){return N}),r.d(e,"random",function(){return C}),r.d(e,"transformMat4",function(){return I}),r.d(e,"transformMat3",function(){return L}),r.d(e,"transformQuat",function(){return k}),r.d(e,"rotateX",function(){return F}),r.d(e,"rotateY",function(){return D}),r.d(e,"rotateZ",function(){return j}),r.d(e,"angle",function(){return B}),r.d(e,"str",function(){return U}),r.d(e,"exactEquals",function(){return V}),r.d(e,"equals",function(){return Y}),r.d(e,"sub",function(){return G}),r.d(e,"mul",function(){return q}),r.d(e,"div",function(){return H}),r.d(e,"dist",function(){return X}),r.d(e,"sqrDist",function(){return W}),r.d(e,"len",function(){return K}),r.d(e,"sqrLen",function(){return z}),r.d(e,"forEach",function(){return Q});var n=r(0);function i(){let t=new n.ARRAY_TYPE(3);return n.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function o(t){var e=new n.ARRAY_TYPE(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function a(t){let e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function u(t,e,r){let i=new n.ARRAY_TYPE(3);return i[0]=t,i[1]=e,i[2]=r,i}function s(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function c(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function f(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function l(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function h(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function d(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function v(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function _(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function m(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function p(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function y(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}function b(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function g(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function M(t,e){let r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)}function x(t,e){let r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}function T(t){let e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function E(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function w(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function O(t,e){let r=e[0],n=e[1],i=e[2],o=r*r+n*n+i*i;return o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o),t}function R(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function P(t,e,r){let n=e[0],i=e[1],o=e[2],a=r[0],u=r[1],s=r[2];return t[0]=i*s-o*u,t[1]=o*a-n*s,t[2]=n*u-i*a,t}function S(t,e,r,n){let i=e[0],o=e[1],a=e[2];return t[0]=i+n*(r[0]-i),t[1]=o+n*(r[1]-o),t[2]=a+n*(r[2]-a),t}function A(t,e,r,n,i,o){let a=o*o,u=a*(2*o-3)+1,s=a*(o-2)+o,c=a*(o-1),f=a*(3-2*o);return t[0]=e[0]*u+r[0]*s+n[0]*c+i[0]*f,t[1]=e[1]*u+r[1]*s+n[1]*c+i[1]*f,t[2]=e[2]*u+r[2]*s+n[2]*c+i[2]*f,t}function N(t,e,r,n,i,o){let a=1-o,u=a*a,s=o*o,c=u*a,f=3*o*u,l=3*s*a,h=s*o;return t[0]=e[0]*c+r[0]*f+n[0]*l+i[0]*h,t[1]=e[1]*c+r[1]*f+n[1]*l+i[1]*h,t[2]=e[2]*c+r[2]*f+n[2]*l+i[2]*h,t}function C(t,e){e=e||1;let r=2*n.RANDOM()*Math.PI,i=2*n.RANDOM()-1,o=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*o,t[1]=Math.sin(r)*o,t[2]=i*e,t}function I(t,e,r){let n=e[0],i=e[1],o=e[2],a=r[3]*n+r[7]*i+r[11]*o+r[15];return a=a||1,t[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/a,t[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/a,t[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/a,t}function L(t,e,r){let n=e[0],i=e[1],o=e[2];return t[0]=n*r[0]+i*r[3]+o*r[6],t[1]=n*r[1]+i*r[4]+o*r[7],t[2]=n*r[2]+i*r[5]+o*r[8],t}function k(t,e,r){let n=r[0],i=r[1],o=r[2],a=r[3],u=e[0],s=e[1],c=e[2],f=i*c-o*s,l=o*u-n*c,h=n*s-i*u,d=i*h-o*l,v=o*f-n*h,_=n*l-i*f,m=2*a;return f*=m,l*=m,h*=m,d*=2,v*=2,_*=2,t[0]=u+f+d,t[1]=s+l+v,t[2]=c+h+_,t}function F(t,e,r,n){let i=[],o=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],o[0]=i[0],o[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),o[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function D(t,e,r,n){let i=[],o=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],o[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),o[1]=i[1],o[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function j(t,e,r,n){let i=[],o=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],o[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),o[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),o[2]=i[2],t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function B(t,e){let r=u(t[0],t[1],t[2]),n=u(e[0],e[1],e[2]);O(r,r),O(n,n);let i=R(r,n);return i>1?0:i<-1?Math.PI:Math.acos(i)}function U(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function V(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function Y(t,e){let r=t[0],i=t[1],o=t[2],a=e[0],u=e[1],s=e[2];return Math.abs(r-a)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-u)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(o-s)<=n.EPSILON*Math.max(1,Math.abs(o),Math.abs(s))}const G=l,q=h,H=d,X=M,W=x,K=a,z=T,Q=function(){let t=i();return function(e,r,n,i,o,a){let u,s;for(r||(r=3),n||(n=0),s=i?Math.min(i*r+n,e.length):e.length,u=n;u=2?r._promise=Promise.resolve(r):t.error?r._promise=Promise.reject(t.error):r._promise=new Promise(function(e,n){t.addEventListener("loadeddata",function(){return e(r)}),t.addEventListener("error",n)}),r}return o(e,c),n(e,[{key:"waitForComplete",value:function(){return this._promise}},{key:"format",get:function(){return u.RGBA}},{key:"width",get:function(){return this._video.videoWidth}},{key:"height",get:function(){return this._video.videoHeight}},{key:"textureKey",get:function(){return this._video.src}},{key:"source",get:function(){return this._video}}]),e}(),0),h=e.DataTexture=function(t){function e(t,r,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:u.RGBA,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:u.UNSIGNED_BYTE;a(this,e);var c=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return c._data=t,c._width=r,c._height=n,c._format=o,c._type=s,c._key="DATA_"+l,l++,c}return o(e,c),n(e,[{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"textureKey",get:function(){return this._key}}]),e}();e.ColorTexture=function(t){function e(t,r,n,o){a(this,e);var u=new Uint8Array([255*t,255*r,255*n,255*o]),s=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,u,1,1));return s.mipmap=!1,s._key="COLOR_"+u[0]+"_"+u[1]+"_"+u[2]+"_"+u[3],s}return o(e,h),e}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GeometryBuilderBase=e.PrimitiveStream=void 0;var n=function(){function t(t,e){for(var r=0;r=this._vertexIndex)throw new Error("Geometry contains indices that are out of bounds.\n (Contains an index of "+this._highIndex+" when the vertex count is "+this._vertexIndex+")");this._geometryStarted=!1,this._vertexOffset+=this._vertexIndex}},{key:"pushVertex",value:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,u=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:1;if(!this._geometryStarted)throw new Error("Cannot push vertices before calling startGeometry().");return this._transform&&(s[0]=t,s[1]=e,s[2]=r,o.vec3.transformMat4(s,s,this._transform),t=s[0],e=s[1],r=s[2],s[0]=a,s[1]=u,s[2]=c,o.vec3.transformMat3(s,s,this._normalTransform),a=s[0],u=s[1],c=s[2]),this._invertNormals&&(a*=-1,u*=-1,c*=-1),this._vertices.push(t,e,r,n,i,a,u,c),this._min?(this._min[0]=Math.min(this._min[0],t),this._min[1]=Math.min(this._min[1],e),this._min[2]=Math.min(this._min[2],r),this._max[0]=Math.max(this._max[0],t),this._max[1]=Math.max(this._max[1],e),this._max[2]=Math.max(this._max[2],r)):(this._min=o.vec3.fromValues(t,e,r),this._max=o.vec3.fromValues(t,e,r)),this._vertexIndex++}},{key:"pushTriangle",value:function(t,e,r){if(!this._geometryStarted)throw new Error("Cannot push triangles before calling startGeometry().");this._highIndex=Math.max(this._highIndex,t,e,r),t+=this._vertexOffset,e+=this._vertexOffset,r+=this._vertexOffset,this._flipWinding?this._indices.push(r,e,t):this._indices.push(t,e,r)}},{key:"clear",value:function(){if(this._geometryStarted)throw new Error("Cannot clear before ending the current geometry.");this._vertices=[],this._indices=[],this._vertexOffset=0,this._min=null,this._max=null}},{key:"finishPrimitive",value:function(t){if(!this._vertexOffset)throw new Error("Attempted to call finishPrimitive() before creating any geometry.");var e=t.createRenderBuffer(u.ARRAY_BUFFER,new Float32Array(this._vertices)),r=t.createRenderBuffer(u.ELEMENT_ARRAY_BUFFER,new Uint16Array(this._indices)),n=[new i.PrimitiveAttribute("POSITION",e,3,u.FLOAT,32,0),new i.PrimitiveAttribute("TEXCOORD_0",e,2,u.FLOAT,32,12),new i.PrimitiveAttribute("NORMAL",e,3,u.FLOAT,32,20)],o=new i.Primitive(n,this._indices.length);return o.setIndexBuffer(r),o.setBounds(this._min,this._max),o}},{key:"flipWinding",set:function(t){if(this._geometryStarted)throw new Error("Cannot change flipWinding before ending the current geometry.");this._flipWinding=t},get:function(){this._flipWinding}},{key:"invertNormals",set:function(t){if(this._geometryStarted)throw new Error("Cannot change invertNormals before ending the current geometry.");this._invertNormals=t},get:function(){this._invertNormals}},{key:"transform",set:function(t){if(this._geometryStarted)throw new Error("Cannot change transform before ending the current geometry.");this._transform=t,this._transform&&(this._normalTransform||(this._normalTransform=o.mat3.create()),o.mat3.fromMat4(this._normalTransform,this._transform))},get:function(){this._transform}},{key:"nextVertexIndex",get:function(){return this._vertexIndex}}]),t}();e.GeometryBuilderBase=function(){function t(e){a(this,t),this._stream=e||new c}return n(t,[{key:"finishPrimitive",value:function(t){return this._stream.finishPrimitive(t)}},{key:"clear",value:function(){this._stream.clear()}},{key:"primitiveStream",set:function(t){this._stream=t},get:function(){return this._stream}}]),t}()},function(t,e,r){"use strict";r.r(e),r.d(e,"create",function(){return i}),r.d(e,"clone",function(){return o}),r.d(e,"copy",function(){return a}),r.d(e,"fromValues",function(){return u}),r.d(e,"set",function(){return s}),r.d(e,"identity",function(){return c}),r.d(e,"transpose",function(){return f}),r.d(e,"invert",function(){return l}),r.d(e,"adjoint",function(){return h}),r.d(e,"determinant",function(){return d}),r.d(e,"multiply",function(){return v}),r.d(e,"translate",function(){return _}),r.d(e,"scale",function(){return m}),r.d(e,"rotate",function(){return p}),r.d(e,"rotateX",function(){return y}),r.d(e,"rotateY",function(){return b}),r.d(e,"rotateZ",function(){return g}),r.d(e,"fromTranslation",function(){return M}),r.d(e,"fromScaling",function(){return x}),r.d(e,"fromRotation",function(){return T}),r.d(e,"fromXRotation",function(){return E}),r.d(e,"fromYRotation",function(){return w}),r.d(e,"fromZRotation",function(){return O}),r.d(e,"fromRotationTranslation",function(){return R}),r.d(e,"fromQuat2",function(){return P}),r.d(e,"getTranslation",function(){return S}),r.d(e,"getScaling",function(){return A}),r.d(e,"getRotation",function(){return N}),r.d(e,"fromRotationTranslationScale",function(){return C}),r.d(e,"fromRotationTranslationScaleOrigin",function(){return I}),r.d(e,"fromQuat",function(){return L}),r.d(e,"frustum",function(){return k}),r.d(e,"perspective",function(){return F}),r.d(e,"perspectiveFromFieldOfView",function(){return D}),r.d(e,"ortho",function(){return j}),r.d(e,"lookAt",function(){return B}),r.d(e,"targetTo",function(){return U}),r.d(e,"str",function(){return V}),r.d(e,"frob",function(){return Y}),r.d(e,"add",function(){return G}),r.d(e,"subtract",function(){return q}),r.d(e,"multiplyScalar",function(){return H}),r.d(e,"multiplyScalarAndAdd",function(){return X}),r.d(e,"exactEquals",function(){return W}),r.d(e,"equals",function(){return K}),r.d(e,"mul",function(){return z}),r.d(e,"sub",function(){return Q});var n=r(0);function i(){let t=new n.ARRAY_TYPE(16);return n.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function o(t){let e=new n.ARRAY_TYPE(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function a(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function u(t,e,r,i,o,a,u,s,c,f,l,h,d,v,_,m){let p=new n.ARRAY_TYPE(16);return p[0]=t,p[1]=e,p[2]=r,p[3]=i,p[4]=o,p[5]=a,p[6]=u,p[7]=s,p[8]=c,p[9]=f,p[10]=l,p[11]=h,p[12]=d,p[13]=v,p[14]=_,p[15]=m,p}function s(t,e,r,n,i,o,a,u,s,c,f,l,h,d,v,_,m){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=o,t[5]=a,t[6]=u,t[7]=s,t[8]=c,t[9]=f,t[10]=l,t[11]=h,t[12]=d,t[13]=v,t[14]=_,t[15]=m,t}function c(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function f(t,e){if(t===e){let r=e[1],n=e[2],i=e[3],o=e[6],a=e[7],u=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=o,t[11]=e[14],t[12]=i,t[13]=a,t[14]=u}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function l(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],u=e[5],s=e[6],c=e[7],f=e[8],l=e[9],h=e[10],d=e[11],v=e[12],_=e[13],m=e[14],p=e[15],y=r*u-n*a,b=r*s-i*a,g=r*c-o*a,M=n*s-i*u,x=n*c-o*u,T=i*c-o*s,E=f*_-l*v,w=f*m-h*v,O=f*p-d*v,R=l*m-h*_,P=l*p-d*_,S=h*p-d*m,A=y*S-b*P+g*R+M*O-x*w+T*E;return A?(A=1/A,t[0]=(u*S-s*P+c*R)*A,t[1]=(i*P-n*S-o*R)*A,t[2]=(_*T-m*x+p*M)*A,t[3]=(h*x-l*T-d*M)*A,t[4]=(s*O-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=t[0],r=t[1],n=t[2],i=t[3],o=t[4],a=t[5],u=t[6],s=t[7],c=t[8],f=t[9],l=t[10],h=t[11],d=t[12],v=t[13],_=t[14],m=t[15];return(e*a-r*o)*(l*m-h*_)-(e*u-n*o)*(f*m-h*v)+(e*s-i*o)*(f*_-l*v)+(r*u-n*a)*(c*m-h*d)-(r*s-i*a)*(c*_-l*d)+(n*s-i*u)*(c*v-f*d)}function v(t,e,r){let n=e[0],i=e[1],o=e[2],a=e[3],u=e[4],s=e[5],c=e[6],f=e[7],l=e[8],h=e[9],d=e[10],v=e[11],_=e[12],m=e[13],p=e[14],y=e[15],b=r[0],g=r[1],M=r[2],x=r[3];return t[0]=b*n+g*u+M*l+x*_,t[1]=b*i+g*s+M*h+x*m,t[2]=b*o+g*c+M*d+x*p,t[3]=b*a+g*f+M*v+x*y,b=r[4],g=r[5],M=r[6],x=r[7],t[4]=b*n+g*u+M*l+x*_,t[5]=b*i+g*s+M*h+x*m,t[6]=b*o+g*c+M*d+x*p,t[7]=b*a+g*f+M*v+x*y,b=r[8],g=r[9],M=r[10],x=r[11],t[8]=b*n+g*u+M*l+x*_,t[9]=b*i+g*s+M*h+x*m,t[10]=b*o+g*c+M*d+x*p,t[11]=b*a+g*f+M*v+x*y,b=r[12],g=r[13],M=r[14],x=r[15],t[12]=b*n+g*u+M*l+x*_,t[13]=b*i+g*s+M*h+x*m,t[14]=b*o+g*c+M*d+x*p,t[15]=b*a+g*f+M*v+x*y,t}function _(t,e,r){let n,i,o,a,u,s,c,f,l,h,d,v,_=r[0],m=r[1],p=r[2];return e===t?(t[12]=e[0]*_+e[4]*m+e[8]*p+e[12],t[13]=e[1]*_+e[5]*m+e[9]*p+e[13],t[14]=e[2]*_+e[6]*m+e[10]*p+e[14],t[15]=e[3]*_+e[7]*m+e[11]*p+e[15]):(n=e[0],i=e[1],o=e[2],a=e[3],u=e[4],s=e[5],c=e[6],f=e[7],l=e[8],h=e[9],d=e[10],v=e[11],t[0]=n,t[1]=i,t[2]=o,t[3]=a,t[4]=u,t[5]=s,t[6]=c,t[7]=f,t[8]=l,t[9]=h,t[10]=d,t[11]=v,t[12]=n*_+u*m+l*p+e[12],t[13]=i*_+s*m+h*p+e[13],t[14]=o*_+c*m+d*p+e[14],t[15]=a*_+f*m+v*p+e[15]),t}function m(t,e,r){let n=r[0],i=r[1],o=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function p(t,e,r,i){let o,a,u,s,c,f,l,h,d,v,_,m,p,y,b,g,M,x,T,E,w,O,R,P,S=i[0],A=i[1],N=i[2],C=Math.sqrt(S*S+A*A+N*N);return C0?(r[0]=2*(s*u+l*i+c*a-f*o)/h,r[1]=2*(c*u+l*o+f*i-s*a)/h,r[2]=2*(f*u+l*a+s*o-c*i)/h):(r[0]=2*(s*u+l*i+c*a-f*o),r[1]=2*(c*u+l*o+f*i-s*a),r[2]=2*(f*u+l*a+s*o-c*i)),R(t,e,r),t}function S(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function A(t,e){let r=e[0],n=e[1],i=e[2],o=e[4],a=e[5],u=e[6],s=e[8],c=e[9],f=e[10];return t[0]=Math.sqrt(r*r+n*n+i*i),t[1]=Math.sqrt(o*o+a*a+u*u),t[2]=Math.sqrt(s*s+c*c+f*f),t}function N(t,e){let r=e[0]+e[5]+e[10],n=0;return r>0?(n=2*Math.sqrt(r+1),t[3]=.25*n,t[0]=(e[6]-e[9])/n,t[1]=(e[8]-e[2])/n,t[2]=(e[1]-e[4])/n):e[0]>e[5]&&e[0]>e[10]?(n=2*Math.sqrt(1+e[0]-e[5]-e[10]),t[3]=(e[6]-e[9])/n,t[0]=.25*n,t[1]=(e[1]+e[4])/n,t[2]=(e[8]+e[2])/n):e[5]>e[10]?(n=2*Math.sqrt(1+e[5]-e[0]-e[10]),t[3]=(e[8]-e[2])/n,t[0]=(e[1]+e[4])/n,t[1]=.25*n,t[2]=(e[6]+e[9])/n):(n=2*Math.sqrt(1+e[10]-e[0]-e[5]),t[3]=(e[1]-e[4])/n,t[0]=(e[8]+e[2])/n,t[1]=(e[6]+e[9])/n,t[2]=.25*n),t}function C(t,e,r,n){let i=e[0],o=e[1],a=e[2],u=e[3],s=i+i,c=o+o,f=a+a,l=i*s,h=i*c,d=i*f,v=o*c,_=o*f,m=a*f,p=u*s,y=u*c,b=u*f,g=n[0],M=n[1],x=n[2];return t[0]=(1-(v+m))*g,t[1]=(h+b)*g,t[2]=(d-y)*g,t[3]=0,t[4]=(h-b)*M,t[5]=(1-(l+m))*M,t[6]=(_+p)*M,t[7]=0,t[8]=(d+y)*x,t[9]=(_-p)*x,t[10]=(1-(l+v))*x,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function I(t,e,r,n,i){let o=e[0],a=e[1],u=e[2],s=e[3],c=o+o,f=a+a,l=u+u,h=o*c,d=o*f,v=o*l,_=a*f,m=a*l,p=u*l,y=s*c,b=s*f,g=s*l,M=n[0],x=n[1],T=n[2],E=i[0],w=i[1],O=i[2],R=(1-(_+p))*M,P=(d+g)*M,S=(v-b)*M,A=(d-g)*x,N=(1-(h+p))*x,C=(m+y)*x,I=(v+b)*T,L=(m-y)*T,k=(1-(h+_))*T;return t[0]=R,t[1]=P,t[2]=S,t[3]=0,t[4]=A,t[5]=N,t[6]=C,t[7]=0,t[8]=I,t[9]=L,t[10]=k,t[11]=0,t[12]=r[0]+E-(R*E+A*w+I*O),t[13]=r[1]+w-(P*E+N*w+L*O),t[14]=r[2]+O-(S*E+C*w+k*O),t[15]=1,t}function L(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],a=r+r,u=n+n,s=i+i,c=r*a,f=n*a,l=n*u,h=i*a,d=i*u,v=i*s,_=o*a,m=o*u,p=o*s;return t[0]=1-l-v,t[1]=f+p,t[2]=h-m,t[3]=0,t[4]=f-p,t[5]=1-c-v,t[6]=d+_,t[7]=0,t[8]=h+m,t[9]=d-_,t[10]=1-c-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function k(t,e,r,n,i,o,a){let u=1/(r-e),s=1/(i-n),c=1/(o-a);return t[0]=2*o*u,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*o*s,t[6]=0,t[7]=0,t[8]=(r+e)*u,t[9]=(i+n)*s,t[10]=(a+o)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*o*2*c,t[15]=0,t}function F(t,e,r,n,i){let o,a=1/Math.tan(e/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(o=1/(n-i),t[10]=(i+n)*o,t[14]=2*i*n*o):(t[10]=-1,t[14]=-2*n),t}function D(t,e,r,n){let i=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),u=Math.tan(e.rightDegrees*Math.PI/180),s=2/(a+u),c=2/(i+o);return t[0]=s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=-(a-u)*s*.5,t[9]=(i-o)*c*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t}function j(t,e,r,n,i,o,a){let u=1/(e-r),s=1/(n-i),c=1/(o-a);return t[0]=-2*u,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+r)*u,t[13]=(i+n)*s,t[14]=(a+o)*c,t[15]=1,t}function B(t,e,r,i){let o,a,u,s,f,l,h,d,v,_,m=e[0],p=e[1],y=e[2],b=i[0],g=i[1],M=i[2],x=r[0],T=r[1],E=r[2];return Math.abs(m-x)0&&(f*=d=1/Math.sqrt(d),l*=d,h*=d);let v=s*h-c*l,_=c*f-u*h,m=u*l-s*f;return(d=v*v+_*_+m*m)>0&&(v*=d=1/Math.sqrt(d),_*=d,m*=d),t[0]=v,t[1]=_,t[2]=m,t[3]=0,t[4]=l*m-h*_,t[5]=h*v-f*m,t[6]=f*_-l*v,t[7]=0,t[8]=f,t[9]=l,t[10]=h,t[11]=0,t[12]=i,t[13]=o,t[14]=a,t[15]=1,t}function V(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"}function Y(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+Math.pow(t[6],2)+Math.pow(t[7],2)+Math.pow(t[8],2)+Math.pow(t[9],2)+Math.pow(t[10],2)+Math.pow(t[11],2)+Math.pow(t[12],2)+Math.pow(t[13],2)+Math.pow(t[14],2)+Math.pow(t[15],2))}function G(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function q(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function H(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function X(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t}function W(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function K(t,e){let r=t[0],i=t[1],o=t[2],a=t[3],u=t[4],s=t[5],c=t[6],f=t[7],l=t[8],h=t[9],d=t[10],v=t[11],_=t[12],m=t[13],p=t[14],y=t[15],b=e[0],g=e[1],M=e[2],x=e[3],T=e[4],E=e[5],w=e[6],O=e[7],R=e[8],P=e[9],S=e[10],A=e[11],N=e[12],C=e[13],I=e[14],L=e[15];return Math.abs(r-b)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(i-g)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(g))&&Math.abs(o-M)<=n.EPSILON*Math.max(1,Math.abs(o),Math.abs(M))&&Math.abs(a-x)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(x))&&Math.abs(u-T)<=n.EPSILON*Math.max(1,Math.abs(u),Math.abs(T))&&Math.abs(s-E)<=n.EPSILON*Math.max(1,Math.abs(s),Math.abs(E))&&Math.abs(c-w)<=n.EPSILON*Math.max(1,Math.abs(c),Math.abs(w))&&Math.abs(f-O)<=n.EPSILON*Math.max(1,Math.abs(f),Math.abs(O))&&Math.abs(l-R)<=n.EPSILON*Math.max(1,Math.abs(l),Math.abs(R))&&Math.abs(h-P)<=n.EPSILON*Math.max(1,Math.abs(h),Math.abs(P))&&Math.abs(d-S)<=n.EPSILON*Math.max(1,Math.abs(d),Math.abs(S))&&Math.abs(v-A)<=n.EPSILON*Math.max(1,Math.abs(v),Math.abs(A))&&Math.abs(_-N)<=n.EPSILON*Math.max(1,Math.abs(_),Math.abs(N))&&Math.abs(m-C)<=n.EPSILON*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(p-I)<=n.EPSILON*Math.max(1,Math.abs(p),Math.abs(I))&&Math.abs(y-L)<=n.EPSILON*Math.max(1,Math.abs(y),Math.abs(L))}const z=v,Q=q},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Renderer=e.RenderTexture=e.RenderView=e.ATTRIB_MASK=e.ATTRIB=void 0;var n=function(){function t(t,e){for(var r=0;r2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"left";c(this,t),this.projectionMatrix=e,this.viewMatrix=r,this.viewport=n,this._eye=i,this._eyeIndex="left"==i?0:1}return n(t,[{key:"eye",get:function(){return this._eye},set:function(t){this._eye=t,this._eyeIndex="left"==t?0:1}},{key:"eyeIndex",get:function(){return this._eyeIndex}}]),t}();var y=function(){function t(e,r,n){var i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;c(this,t),this._target=e,this._usage=r,this._length=o,n instanceof Promise?(this._buffer=null,this._promise=n.then(function(t){return i._buffer=t,i})):(this._buffer=n,this._promise=Promise.resolve(this))}return n(t,[{key:"waitForComplete",value:function(){return this._promise}}]),t}(),b=function t(e){c(this,t),this._attrib_index=f[e.name],this._componentCount=e.componentCount,this._componentType=e.componentType,this._stride=e.stride,this._byteOffset=e.byteOffset,this._normalized=e.normalized},g=function t(e){c(this,t),this._buffer=e,this._attributes=[]},M=function(){function t(e){c(this,t),this._activeFrameId=0,this._instances=[],this._material=null,this.setPrimitive(e)}return n(t,[{key:"setPrimitive",value:function(t){this._mode=t.mode,this._elementCount=t.elementCount,this._promise=null,this._vao=null,this._complete=!1,this._attributeBuffers=[],this._attributeMask=0;var e=!0,r=!1,n=void 0;try{for(var i,o=t.attributes[Symbol.iterator]();!(e=(i=o.next()).done);e=!0){var a=i.value;this._attributeMask|=l[a.name];var u=new b(a),c=!1,f=!0,h=!1,d=void 0;try{for(var v,_=this._attributeBuffers[Symbol.iterator]();!(f=(v=_.next()).done);f=!0){var m=v.value;if(m._buffer==a.buffer){m._attributes.push(u),c=!0;break}}}catch(t){h=!0,d=t}finally{try{!f&&_.return&&_.return()}finally{if(h)throw d}}if(!c){var p=new g(a.buffer);p._attributes.push(u),this._attributeBuffers.push(p)}}}catch(t){r=!0,n=t}finally{try{!e&&o.return&&o.return()}finally{if(r)throw n}}this._indexBuffer=null,this._indexByteOffset=0,this._indexType=0,t.indexBuffer&&(this._indexByteOffset=t.indexByteOffset,this._indexType=t.indexType,this._indexBuffer=t.indexBuffer),t._min?(this._min=s.vec3.clone(t._min),this._max=s.vec3.clone(t._max)):(this._min=null,this._max=null),null!=this._material&&this.waitForComplete()}},{key:"setRenderMaterial",value:function(t){this._material=t,this._promise=null,this._complete=!1,null!=this._material&&this.waitForComplete()}},{key:"markActive",value:function(t){if(this._complete&&this._activeFrameId!=t){if(this._material&&!this._material.markActive(t))return;this._activeFrameId=t}}},{key:"waitForComplete",value:function(){var t=this;if(!this._promise){if(!this._material)return Promise.reject("RenderPrimitive does not have a material");var e=[],r=!0,n=!1,i=void 0;try{for(var o,a=this._attributeBuffers[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var u=o.value;u._buffer._buffer||e.push(u._buffer._promise)}}catch(t){n=!0,i=t}finally{try{!r&&a.return&&a.return()}finally{if(n)throw i}}this._indexBuffer&&!this._indexBuffer._buffer&&e.push(this._indexBuffer._promise),this._promise=Promise.all(e).then(function(){return t._complete=!0,t})}return this._promise}},{key:"samplers",get:function(){return this._material._samplerDictionary}},{key:"uniforms",get:function(){return this._material._uniform_dictionary}}]),t}(),x=e.RenderTexture=function(){function t(e){c(this,t),this._texture=e,this._complete=!1,this._activeFrameId=0,this._activeCallback=null}return n(t,[{key:"markActive",value:function(t){this._activeCallback&&this._activeFrameId!=t&&(this._activeFrameId=t,this._activeCallback(this))}}]),t}(),T=s.mat4.create();function E(t,e,r,n,i){var o=(i&r)-(n&r);o&&(o>0?t.enable(e):t.disable(e))}var w=function(){function t(e,r,n){c(this,t),this._renderer=e,this._uniformName=r._uniformName,this._renderTexture=e._getRenderTexture(r._texture),this._index=n}return n(t,[{key:"texture",set:function(t){this._renderTexture=this._renderer._getRenderTexture(t)}}]),t}(),O=function(){function t(e){c(this,t),this._uniformName=e._uniformName,this._uniform=null,this._length=e._length,e._value instanceof Array?this._value=new Float32Array(e._value):this._value=new Float32Array([e._value])}return n(t,[{key:"value",set:function(t){if(1==this._value.length)this._value[0]=t;else for(var e=0;e>i.MAT_STATE.DEPTH_FUNC_SHIFT)+h.NEVER}},{key:"blendFuncSrc",get:function(){return(0,i.stateToBlendFunc)(this._state,i.MAT_STATE.BLEND_SRC_RANGE,i.MAT_STATE.BLEND_SRC_SHIFT)}},{key:"blendFuncDst",get:function(){return(0,i.stateToBlendFunc)(this._state,i.MAT_STATE.BLEND_DST_RANGE,i.MAT_STATE.BLEND_DST_SHIFT)}}]),t}();e.Renderer=function(){function t(e){c(this,t),this._gl=e||p(),this._frameId=0,this._programCache={},this._textureCache={},this._renderPrimitives=Array(i.RENDER_ORDER.DEFAULT),this._cameraPositions=[],this._vaoExt=e.getExtension("OES_vertex_array_object");var r=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT);this._defaultFragPrecision=r.precision>0?"highp":"mediump",this._depthMaskNeedsReset=!1,this._colorMaskNeedsReset=!1,this._globalLightColor=s.vec3.clone(v),this._globalLightDir=s.vec3.clone(d)}return n(t,[{key:"createRenderBuffer",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:h.STATIC_DRAW,n=this._gl,i=n.createBuffer();if(e instanceof Promise){var o=new y(t,r,e.then(function(e){return n.bindBuffer(t,i),n.bufferData(t,e,r),o._length=e.byteLength,i}));return o}return n.bindBuffer(t,i),n.bufferData(t,e,r),new y(t,r,i,e.byteLength)}},{key:"updateRenderBuffer",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(t._buffer){var i=this._gl;i.bindBuffer(t._target,t._buffer),0==n&&t._length==e.byteLength?i.bufferData(t._target,e,t._usage):i.bufferSubData(t._target,n,e)}else t.waitForComplete().then(function(t){r.updateRenderBuffer(t,e,n)})}},{key:"createRenderPrimitive",value:function(t,e){var r=new M(t),n=this._getMaterialProgram(e,r),i=new R(this,e,n);return r.setRenderMaterial(i),this._renderPrimitives[i._renderOrder]||(this._renderPrimitives[i._renderOrder]=[]),this._renderPrimitives[i._renderOrder].push(r),r}},{key:"createMesh",value:function(t,e){var r=new o.Node;return r.addRenderPrimitive(this.createRenderPrimitive(t,e)),r}},{key:"drawViews",value:function(t,e){if(e){var r=this._gl;if(this._frameId++,e.markActive(this._frameId),1==t.length&&t[0].viewport){var n=t[0].viewport;this._gl.viewport(n.x,n.y,n.width,n.height)}for(var i=0;i1){if(d.viewport){var v=d.viewport;r.viewport(v.x,v.y,v.width,v.height)}r.uniformMatrix4fv(n.uniform.PROJECTION_MATRIX,!1,d.projectionMatrix),r.uniformMatrix4fv(n.uniform.VIEW_MATRIX,!1,d.viewMatrix),r.uniform3fv(n.uniform.CAMERA_POSITION,this._cameraPositions[h]),r.uniform1i(n.uniform.EYE_INDEX,d.eyeIndex)}var _=!0,m=!1,p=void 0;try{for(var y,b=l._instances[Symbol.iterator]();!(_=(y=b.next()).done);_=!0){var g=y.value;g._activeFrameId==this._frameId&&(r.uniformMatrix4fv(n.uniform.MODEL_MATRIX,!1,g.worldMatrix),l._indexBuffer?r.drawElements(l._mode,l._elementCount,l._indexType,l._indexByteOffset):r.drawArrays(l._mode,0,l._elementCount))}}catch(t){m=!0,p=t}finally{try{!_&&b.return&&b.return()}finally{if(m)throw p}}}}}}catch(t){u=!0,s=t}finally{try{!a&&f.return&&f.return()}finally{if(u)throw s}}}},{key:"_getRenderTexture",value:function(t){var e=this;if(!t)return null;var r=t.textureKey;if(!r)throw new Error("Texure does not have a valid key");if(r in this._textureCache)return this._textureCache[r];var n=this._gl,i=n.createTexture(),o=new x(i);return this._textureCache[r]=o,t instanceof u.DataTexture?(n.bindTexture(n.TEXTURE_2D,i),n.texImage2D(n.TEXTURE_2D,0,t.format,t.width,t.height,0,t.format,t._type,t._data),this._setSamplerParameters(t),o._complete=!0):t.waitForComplete().then(function(){n.bindTexture(n.TEXTURE_2D,i),n.texImage2D(n.TEXTURE_2D,0,t.format,t.format,n.UNSIGNED_BYTE,t.source),e._setSamplerParameters(t),o._complete=!0,t instanceof u.VideoTexture&&t._video.addEventListener("playing",function(){o._activeCallback=function(){t._video.paused||t._video.waiting||(n.bindTexture(n.TEXTURE_2D,i),n.texImage2D(n.TEXTURE_2D,0,t.format,t.format,n.UNSIGNED_BYTE,t.source))}})}),o}},{key:"_setSamplerParameters",value:function(t){var e=this._gl,r=t.sampler,n=m(t.width)&&m(t.height),i=n&&t.mipmap;i&&e.generateMipmap(e.TEXTURE_2D);var o=r.minFilter||(i?e.LINEAR_MIPMAP_LINEAR:e.LINEAR),a=r.wrapS||(n?e.REPEAT:e.CLAMP_TO_EDGE),u=r.wrapT||(n?e.REPEAT:e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,r.magFilter||e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,o),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,a),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,u)}},{key:"_getProgramKey",value:function(t,e){var r=t+":";for(var n in e)r+=n+"="+e[n]+",";return r}},{key:"_getMaterialProgram",value:function(t,e){var r=this,n=t.materialName,i=t.vertexSource,o=t.fragmentSource;if(null==n)throw new Error("Material does not have a name");if(null==i)throw new Error('Material "'+n+'" does not have a vertex source');if(null==o)throw new Error('Material "'+n+'" does not have a fragment source');var u=t.getProgramDefines(e),s=this._getProgramKey(n,u);if(s in this._programCache)return this._programCache[s];var c=i;c+="\nuniform mat4 PROJECTION_MATRIX, VIEW_MATRIX, MODEL_MATRIX;\n\nvoid main() {\n gl_Position = vertex_main(PROJECTION_MATRIX, VIEW_MATRIX, MODEL_MATRIX);\n}\n";var l=(o.match(_)?"":"precision "+this._defaultFragPrecision+" float;\n")+o;l+="\nvoid main() {\n gl_FragColor = fragment_main();\n}\n";var h=new a.Program(this._gl,c,l,f,u);return this._programCache[s]=h,h.onNextUse(function(e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:null,r=this._gl,n=t._state,o=e?e._state:~n;if(n!=o){if(t._capsDiff(o)){E(r,r.CULL_FACE,i.CAP.CULL_FACE,o,n),E(r,r.BLEND,i.CAP.BLEND,o,n),E(r,r.DEPTH_TEST,i.CAP.DEPTH_TEST,o,n),E(r,r.STENCIL_TEST,i.CAP.STENCIL_TEST,o,n);var a=(n&i.CAP.COLOR_MASK)-(o&i.CAP.COLOR_MASK);if(a){var u=a>1;this._colorMaskNeedsReset=!u,r.colorMask(u,u,u,u)}var s=(n&i.CAP.DEPTH_MASK)-(o&i.CAP.DEPTH_MASK);s&&(this._depthMaskNeedsReset=!(s>1),r.depthMask(s>1));var c=(n&i.CAP.STENCIL_MASK)-(o&i.CAP.STENCIL_MASK);c&&r.stencilMask(c>1)}t._blendDiff(o)&&r.blendFunc(t.blendFuncSrc,t.blendFuncDst),t._depthFuncDiff(o)&&r.depthFunc(t.depthFunc)}}},{key:"gl",get:function(){return this._gl}},{key:"globalLightColor",set:function(t){s.vec3.copy(this._globalLightColor,t)},get:function(){return s.vec3.clone(this._globalLightColor)}},{key:"globalLightDir",set:function(t){s.vec3.copy(this._globalLightDir,t)},get:function(){return s.vec3.clone(this._globalLightDir)}}]),t}()},function(t,e,r){"use strict";r.r(e),r.d(e,"create",function(){return i}),r.d(e,"fromMat4",function(){return o}),r.d(e,"clone",function(){return a}),r.d(e,"copy",function(){return u}),r.d(e,"fromValues",function(){return s}),r.d(e,"set",function(){return c}),r.d(e,"identity",function(){return f}),r.d(e,"transpose",function(){return l}),r.d(e,"invert",function(){return h}),r.d(e,"adjoint",function(){return d}),r.d(e,"determinant",function(){return v}),r.d(e,"multiply",function(){return _}),r.d(e,"translate",function(){return m}),r.d(e,"rotate",function(){return p}),r.d(e,"scale",function(){return y}),r.d(e,"fromTranslation",function(){return b}),r.d(e,"fromRotation",function(){return g}),r.d(e,"fromScaling",function(){return M}),r.d(e,"fromMat2d",function(){return x}),r.d(e,"fromQuat",function(){return T}),r.d(e,"normalFromMat4",function(){return E}),r.d(e,"projection",function(){return w}),r.d(e,"str",function(){return O}),r.d(e,"frob",function(){return R}),r.d(e,"add",function(){return P}),r.d(e,"subtract",function(){return S}),r.d(e,"multiplyScalar",function(){return A}),r.d(e,"multiplyScalarAndAdd",function(){return N}),r.d(e,"exactEquals",function(){return C}),r.d(e,"equals",function(){return I}),r.d(e,"mul",function(){return L}),r.d(e,"sub",function(){return k});var n=r(0);function i(){let t=new n.ARRAY_TYPE(9);return n.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function o(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}function a(t){let e=new n.ARRAY_TYPE(9);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function u(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function s(t,e,r,i,o,a,u,s,c){let f=new n.ARRAY_TYPE(9);return f[0]=t,f[1]=e,f[2]=r,f[3]=i,f[4]=o,f[5]=a,f[6]=u,f[7]=s,f[8]=c,f}function c(t,e,r,n,i,o,a,u,s,c){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=o,t[5]=a,t[6]=u,t[7]=s,t[8]=c,t}function f(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function l(t,e){if(t===e){let r=e[1],n=e[2],i=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=i}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function h(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],u=e[5],s=e[6],c=e[7],f=e[8],l=f*a-u*c,h=-f*o+u*s,d=c*o-a*s,v=r*l+n*h+i*d;return v?(v=1/v,t[0]=l*v,t[1]=(-f*n+i*c)*v,t[2]=(u*n-i*a)*v,t[3]=h*v,t[4]=(f*r-i*s)*v,t[5]=(-u*r+i*o)*v,t[6]=d*v,t[7]=(-c*r+n*s)*v,t[8]=(a*r-n*o)*v,t):null}function d(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],u=e[5],s=e[6],c=e[7],f=e[8];return t[0]=a*f-u*c,t[1]=i*c-n*f,t[2]=n*u-i*a,t[3]=u*s-o*f,t[4]=r*f-i*s,t[5]=i*o-r*u,t[6]=o*c-a*s,t[7]=n*s-r*c,t[8]=r*a-n*o,t}function v(t){let e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],a=t[5],u=t[6],s=t[7],c=t[8];return e*(c*o-a*s)+r*(-c*i+a*u)+n*(s*i-o*u)}function _(t,e,r){let n=e[0],i=e[1],o=e[2],a=e[3],u=e[4],s=e[5],c=e[6],f=e[7],l=e[8],h=r[0],d=r[1],v=r[2],_=r[3],m=r[4],p=r[5],y=r[6],b=r[7],g=r[8];return t[0]=h*n+d*a+v*c,t[1]=h*i+d*u+v*f,t[2]=h*o+d*s+v*l,t[3]=_*n+m*a+p*c,t[4]=_*i+m*u+p*f,t[5]=_*o+m*s+p*l,t[6]=y*n+b*a+g*c,t[7]=y*i+b*u+g*f,t[8]=y*o+b*s+g*l,t}function m(t,e,r){let n=e[0],i=e[1],o=e[2],a=e[3],u=e[4],s=e[5],c=e[6],f=e[7],l=e[8],h=r[0],d=r[1];return t[0]=n,t[1]=i,t[2]=o,t[3]=a,t[4]=u,t[5]=s,t[6]=h*n+d*a+c,t[7]=h*i+d*u+f,t[8]=h*o+d*s+l,t}function p(t,e,r){let n=e[0],i=e[1],o=e[2],a=e[3],u=e[4],s=e[5],c=e[6],f=e[7],l=e[8],h=Math.sin(r),d=Math.cos(r);return t[0]=d*n+h*a,t[1]=d*i+h*u,t[2]=d*o+h*s,t[3]=d*a-h*n,t[4]=d*u-h*i,t[5]=d*s-h*o,t[6]=c,t[7]=f,t[8]=l,t}function y(t,e,r){let n=r[0],i=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=i*e[3],t[4]=i*e[4],t[5]=i*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function b(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e[0],t[7]=e[1],t[8]=1,t}function g(t,e){let r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=-r,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function M(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=e[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function x(t,e){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=e[4],t[7]=e[5],t[8]=1,t}function T(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],a=r+r,u=n+n,s=i+i,c=r*a,f=n*a,l=n*u,h=i*a,d=i*u,v=i*s,_=o*a,m=o*u,p=o*s;return t[0]=1-l-v,t[3]=f-p,t[6]=h+m,t[1]=f+p,t[4]=1-c-v,t[7]=d-_,t[2]=h-m,t[5]=d+_,t[8]=1-c-l,t}function E(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],u=e[5],s=e[6],c=e[7],f=e[8],l=e[9],h=e[10],d=e[11],v=e[12],_=e[13],m=e[14],p=e[15],y=r*u-n*a,b=r*s-i*a,g=r*c-o*a,M=n*s-i*u,x=n*c-o*u,T=i*c-o*s,E=f*_-l*v,w=f*m-h*v,O=f*p-d*v,R=l*m-h*_,P=l*p-d*_,S=h*p-d*m,A=y*S-b*P+g*R+M*O-x*w+T*E;return A?(A=1/A,t[0]=(u*S-s*P+c*R)*A,t[1]=(s*O-a*S-c*w)*A,t[2]=(a*P-u*O+c*E)*A,t[3]=(i*P-n*S-o*R)*A,t[4]=(r*S-i*O+o*w)*A,t[5]=(n*O-r*P-o*E)*A,t[6]=(_*T-m*x+p*M)*A,t[7]=(m*g-v*T-p*b)*A,t[8]=(v*x-_*g+p*y)*A,t):null}function w(t,e,r){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/r,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t}function O(t){return"mat3("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"}function R(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+Math.pow(t[6],2)+Math.pow(t[7],2)+Math.pow(t[8],2))}function P(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t}function S(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t}function A(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t}function N(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t}function C(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]}function I(t,e){let r=t[0],i=t[1],o=t[2],a=t[3],u=t[4],s=t[5],c=t[6],f=t[7],l=t[8],h=e[0],d=e[1],v=e[2],_=e[3],m=e[4],p=e[5],y=e[6],b=e[7],g=e[8];return Math.abs(r-h)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(i-d)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(d))&&Math.abs(o-v)<=n.EPSILON*Math.max(1,Math.abs(o),Math.abs(v))&&Math.abs(a-_)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(_))&&Math.abs(u-m)<=n.EPSILON*Math.max(1,Math.abs(u),Math.abs(m))&&Math.abs(s-p)<=n.EPSILON*Math.max(1,Math.abs(s),Math.abs(p))&&Math.abs(c-y)<=n.EPSILON*Math.max(1,Math.abs(c),Math.abs(y))&&Math.abs(f-b)<=n.EPSILON*Math.max(1,Math.abs(f),Math.abs(b))&&Math.abs(l-g)<=n.EPSILON*Math.max(1,Math.abs(l),Math.abs(g))}const L=_,k=S},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BoxBuilder=void 0;var n=function(){function t(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[0,0,0],e=.5*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1);this.pushBox([t[0]-e,t[1]-e,t[2]-e],[t[0]+e,t[1]+e,t[2]+e])}}]),e}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PbrMaterial=void 0;var n=function(){function t(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:null;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.origin=i.vec3.create(),this._dir=i.vec3.create(),this._dir[2]=-1,e&&(i.vec3.transformMat4(this.origin,this.origin,e),i.mat3.fromMat4(o,e),i.vec3.transformMat3(this._dir,this._dir,o)),this.dir=this._dir}return n(t,[{key:"intersectsAABB",value:function(t,e){var r=this,n=[t,e],o=(n[r.sign[0]][0]-r.origin[0])*r.inv_dir[0],a=(n[1-r.sign[0]][0]-r.origin[0])*r.inv_dir[0],u=(n[r.sign[1]][1]-r.origin[1])*r.inv_dir[1],s=(n[1-r.sign[1]][1]-r.origin[1])*r.inv_dir[1];if(o>s||u>a)return null;u>o&&(o=u),sf||c>a)return null;c>o&&(o=c),f0&&a>0)l=Math.min(o,a);else if(o>0)l=o;else{if(!(a>0))return null;l=a}l-=.02;var h=i.vec3.clone(this._dir);return i.vec3.scale(h,h,l),i.vec3.add(h,h,this.origin),h}},{key:"dir",get:function(){return this._dir},set:function(t){this._dir=i.vec3.copy(this._dir,t),i.vec3.normalize(this._dir,this._dir),this.inv_dir=i.vec3.fromValues(1/this._dir[0],1/this._dir[1],1/this._dir[2]),this.sign=[this.inv_dir[0]<0?1:0,this.inv_dir[1]<0?1:0,this.inv_dir[2]<0?1:0]}}]),t}()},function(t,e,r){"use strict";r.r(e),r.d(e,"create",function(){return i}),r.d(e,"clone",function(){return o}),r.d(e,"copy",function(){return a}),r.d(e,"identity",function(){return u}),r.d(e,"fromValues",function(){return s}),r.d(e,"set",function(){return c}),r.d(e,"transpose",function(){return f}),r.d(e,"invert",function(){return l}),r.d(e,"adjoint",function(){return h}),r.d(e,"determinant",function(){return d}),r.d(e,"multiply",function(){return v}),r.d(e,"rotate",function(){return _}),r.d(e,"scale",function(){return m}),r.d(e,"fromRotation",function(){return p}),r.d(e,"fromScaling",function(){return y}),r.d(e,"str",function(){return b}),r.d(e,"frob",function(){return g}),r.d(e,"LDU",function(){return M}),r.d(e,"add",function(){return x}),r.d(e,"subtract",function(){return T}),r.d(e,"exactEquals",function(){return E}),r.d(e,"equals",function(){return w}),r.d(e,"multiplyScalar",function(){return O}),r.d(e,"multiplyScalarAndAdd",function(){return R}),r.d(e,"mul",function(){return P}),r.d(e,"sub",function(){return S});var n=r(0);function i(){let t=new n.ARRAY_TYPE(4);return n.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}function o(t){let e=new n.ARRAY_TYPE(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function a(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function u(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t}function s(t,e,r,i){let o=new n.ARRAY_TYPE(4);return o[0]=t,o[1]=e,o[2]=r,o[3]=i,o}function c(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}function f(t,e){if(t===e){let r=e[1];t[1]=e[2],t[2]=r}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t}function l(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],a=r*o-i*n;return a?(a=1/a,t[0]=o*a,t[1]=-n*a,t[2]=-i*a,t[3]=r*a,t):null}function h(t,e){let r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t}function d(t){return t[0]*t[3]-t[2]*t[1]}function v(t,e,r){let n=e[0],i=e[1],o=e[2],a=e[3],u=r[0],s=r[1],c=r[2],f=r[3];return t[0]=n*u+o*s,t[1]=i*u+a*s,t[2]=n*c+o*f,t[3]=i*c+a*f,t}function _(t,e,r){let n=e[0],i=e[1],o=e[2],a=e[3],u=Math.sin(r),s=Math.cos(r);return t[0]=n*s+o*u,t[1]=i*s+a*u,t[2]=n*-u+o*s,t[3]=i*-u+a*s,t}function m(t,e,r){let n=e[0],i=e[1],o=e[2],a=e[3],u=r[0],s=r[1];return t[0]=n*u,t[1]=i*u,t[2]=o*s,t[3]=a*s,t}function p(t,e){let r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t}function y(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t}function b(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function g(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2))}function M(t,e,r,n){return t[2]=n[2]/n[0],r[0]=n[0],r[1]=n[1],r[3]=n[3]-t[2]*r[1],[t,e,r]}function x(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function T(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function E(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function w(t,e){let r=t[0],i=t[1],o=t[2],a=t[3],u=e[0],s=e[1],c=e[2],f=e[3];return Math.abs(r-u)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(i-s)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(o-c)<=n.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))&&Math.abs(a-f)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(f))}function O(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function R(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t}const P=v,S=T},function(t,e,r){"use strict";r.r(e),r.d(e,"create",function(){return i}),r.d(e,"clone",function(){return o}),r.d(e,"copy",function(){return a}),r.d(e,"identity",function(){return u}),r.d(e,"fromValues",function(){return s}),r.d(e,"set",function(){return c}),r.d(e,"invert",function(){return f}),r.d(e,"determinant",function(){return l}),r.d(e,"multiply",function(){return h}),r.d(e,"rotate",function(){return d}),r.d(e,"scale",function(){return v}),r.d(e,"translate",function(){return _}),r.d(e,"fromRotation",function(){return m}),r.d(e,"fromScaling",function(){return p}),r.d(e,"fromTranslation",function(){return y}),r.d(e,"str",function(){return b}),r.d(e,"frob",function(){return g}),r.d(e,"add",function(){return M}),r.d(e,"subtract",function(){return x}),r.d(e,"multiplyScalar",function(){return T}),r.d(e,"multiplyScalarAndAdd",function(){return E}),r.d(e,"exactEquals",function(){return w}),r.d(e,"equals",function(){return O}),r.d(e,"mul",function(){return R}),r.d(e,"sub",function(){return P});var n=r(0);function i(){let t=new n.ARRAY_TYPE(6);return n.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t}function o(t){let e=new n.ARRAY_TYPE(6);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function a(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t}function u(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t}function s(t,e,r,i,o,a){let u=new n.ARRAY_TYPE(6);return u[0]=t,u[1]=e,u[2]=r,u[3]=i,u[4]=o,u[5]=a,u}function c(t,e,r,n,i,o,a){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=o,t[5]=a,t}function f(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],u=e[5],s=r*o-n*i;return s?(s=1/s,t[0]=o*s,t[1]=-n*s,t[2]=-i*s,t[3]=r*s,t[4]=(i*u-o*a)*s,t[5]=(n*a-r*u)*s,t):null}function l(t){return t[0]*t[3]-t[1]*t[2]}function h(t,e,r){let n=e[0],i=e[1],o=e[2],a=e[3],u=e[4],s=e[5],c=r[0],f=r[1],l=r[2],h=r[3],d=r[4],v=r[5];return t[0]=n*c+o*f,t[1]=i*c+a*f,t[2]=n*l+o*h,t[3]=i*l+a*h,t[4]=n*d+o*v+u,t[5]=i*d+a*v+s,t}function d(t,e,r){let n=e[0],i=e[1],o=e[2],a=e[3],u=e[4],s=e[5],c=Math.sin(r),f=Math.cos(r);return t[0]=n*f+o*c,t[1]=i*f+a*c,t[2]=n*-c+o*f,t[3]=i*-c+a*f,t[4]=u,t[5]=s,t}function v(t,e,r){let n=e[0],i=e[1],o=e[2],a=e[3],u=e[4],s=e[5],c=r[0],f=r[1];return t[0]=n*c,t[1]=i*c,t[2]=o*f,t[3]=a*f,t[4]=u,t[5]=s,t}function _(t,e,r){let n=e[0],i=e[1],o=e[2],a=e[3],u=e[4],s=e[5],c=r[0],f=r[1];return t[0]=n,t[1]=i,t[2]=o,t[3]=a,t[4]=n*c+o*f+u,t[5]=i*c+a*f+s,t}function m(t,e){let r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t[4]=0,t[5]=0,t}function p(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t[4]=0,t[5]=0,t}function y(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t}function b(t){return"mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"}function g(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+1)}function M(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t}function x(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t}function T(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t}function E(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t}function w(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]}function O(t,e){let r=t[0],i=t[1],o=t[2],a=t[3],u=t[4],s=t[5],c=e[0],f=e[1],l=e[2],h=e[3],d=e[4],v=e[5];return Math.abs(r-c)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(i-f)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(f))&&Math.abs(o-l)<=n.EPSILON*Math.max(1,Math.abs(o),Math.abs(l))&&Math.abs(a-h)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(u-d)<=n.EPSILON*Math.max(1,Math.abs(u),Math.abs(d))&&Math.abs(s-v)<=n.EPSILON*Math.max(1,Math.abs(s),Math.abs(v))}const R=h,P=x},function(t,e,r){"use strict";r.r(e),r.d(e,"create",function(){return a}),r.d(e,"clone",function(){return u}),r.d(e,"fromValues",function(){return s}),r.d(e,"fromRotationTranslationValues",function(){return c}),r.d(e,"fromRotationTranslation",function(){return f}),r.d(e,"fromTranslation",function(){return l}),r.d(e,"fromRotation",function(){return h}),r.d(e,"fromMat4",function(){return d}),r.d(e,"copy",function(){return v}),r.d(e,"identity",function(){return _}),r.d(e,"set",function(){return m}),r.d(e,"getReal",function(){return p}),r.d(e,"getDual",function(){return y}),r.d(e,"setReal",function(){return b}),r.d(e,"setDual",function(){return g}),r.d(e,"getTranslation",function(){return M}),r.d(e,"translate",function(){return x}),r.d(e,"rotateX",function(){return T}),r.d(e,"rotateY",function(){return E}),r.d(e,"rotateZ",function(){return w}),r.d(e,"rotateByQuatAppend",function(){return O}),r.d(e,"rotateByQuatPrepend",function(){return R}),r.d(e,"rotateAroundAxis",function(){return P}),r.d(e,"add",function(){return S}),r.d(e,"multiply",function(){return A}),r.d(e,"mul",function(){return N}),r.d(e,"scale",function(){return C}),r.d(e,"dot",function(){return I}),r.d(e,"lerp",function(){return L}),r.d(e,"invert",function(){return k}),r.d(e,"conjugate",function(){return F}),r.d(e,"length",function(){return D}),r.d(e,"len",function(){return j}),r.d(e,"squaredLength",function(){return B}),r.d(e,"sqrLen",function(){return U}),r.d(e,"normalize",function(){return V}),r.d(e,"str",function(){return Y}),r.d(e,"exactEquals",function(){return G}),r.d(e,"equals",function(){return q});var n=r(0),i=r(4),o=r(10);function a(){let t=new n.ARRAY_TYPE(8);return n.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0),t[3]=1,t}function u(t){let e=new n.ARRAY_TYPE(8);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e}function s(t,e,r,i,o,a,u,s){let c=new n.ARRAY_TYPE(8);return c[0]=t,c[1]=e,c[2]=r,c[3]=i,c[4]=o,c[5]=a,c[6]=u,c[7]=s,c}function c(t,e,r,i,o,a,u){let s=new n.ARRAY_TYPE(8);s[0]=t,s[1]=e,s[2]=r,s[3]=i;let c=.5*o,f=.5*a,l=.5*u;return s[4]=c*i+f*r-l*e,s[5]=f*i+l*t-c*r,s[6]=l*i+c*e-f*t,s[7]=-c*t-f*e-l*r,s}function f(t,e,r){let n=.5*r[0],i=.5*r[1],o=.5*r[2],a=e[0],u=e[1],s=e[2],c=e[3];return t[0]=a,t[1]=u,t[2]=s,t[3]=c,t[4]=n*c+i*s-o*u,t[5]=i*c+o*a-n*s,t[6]=o*c+n*u-i*a,t[7]=-n*a-i*u-o*s,t}function l(t,e){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=.5*e[0],t[5]=.5*e[1],t[6]=.5*e[2],t[7]=0,t}function h(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=0,t[5]=0,t[6]=0,t[7]=0,t}function d(t,e){let r=i.create();o.getRotation(r,e);let a=new n.ARRAY_TYPE(3);return o.getTranslation(a,e),f(t,r,a),t}function v(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t}function _(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t}function m(t,e,r,n,i,o,a,u,s){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=o,t[5]=a,t[6]=u,t[7]=s,t}const p=i.copy;function y(t,e){return t[0]=e[4],t[1]=e[5],t[2]=e[6],t[3]=e[7],t}const b=i.copy;function g(t,e){return t[4]=e[0],t[5]=e[1],t[6]=e[2],t[7]=e[3],t}function M(t,e){let r=e[4],n=e[5],i=e[6],o=e[7],a=-e[0],u=-e[1],s=-e[2],c=e[3];return t[0]=2*(r*c+o*a+n*s-i*u),t[1]=2*(n*c+o*u+i*a-r*s),t[2]=2*(i*c+o*s+r*u-n*a),t}function x(t,e,r){let n=e[0],i=e[1],o=e[2],a=e[3],u=.5*r[0],s=.5*r[1],c=.5*r[2],f=e[4],l=e[5],h=e[6],d=e[7];return t[0]=n,t[1]=i,t[2]=o,t[3]=a,t[4]=a*u+i*c-o*s+f,t[5]=a*s+o*u-n*c+l,t[6]=a*c+n*s-i*u+h,t[7]=-n*u-i*s-o*c+d,t}function T(t,e,r){let n=-e[0],o=-e[1],a=-e[2],u=e[3],s=e[4],c=e[5],f=e[6],l=e[7],h=s*u+l*n+c*a-f*o,d=c*u+l*o+f*n-s*a,v=f*u+l*a+s*o-c*n,_=l*u-s*n-c*o-f*a;return i.rotateX(t,e,r),n=t[0],o=t[1],a=t[2],u=t[3],t[4]=h*u+_*n+d*a-v*o,t[5]=d*u+_*o+v*n-h*a,t[6]=v*u+_*a+h*o-d*n,t[7]=_*u-h*n-d*o-v*a,t}function E(t,e,r){let n=-e[0],o=-e[1],a=-e[2],u=e[3],s=e[4],c=e[5],f=e[6],l=e[7],h=s*u+l*n+c*a-f*o,d=c*u+l*o+f*n-s*a,v=f*u+l*a+s*o-c*n,_=l*u-s*n-c*o-f*a;return i.rotateY(t,e,r),n=t[0],o=t[1],a=t[2],u=t[3],t[4]=h*u+_*n+d*a-v*o,t[5]=d*u+_*o+v*n-h*a,t[6]=v*u+_*a+h*o-d*n,t[7]=_*u-h*n-d*o-v*a,t}function w(t,e,r){let n=-e[0],o=-e[1],a=-e[2],u=e[3],s=e[4],c=e[5],f=e[6],l=e[7],h=s*u+l*n+c*a-f*o,d=c*u+l*o+f*n-s*a,v=f*u+l*a+s*o-c*n,_=l*u-s*n-c*o-f*a;return i.rotateZ(t,e,r),n=t[0],o=t[1],a=t[2],u=t[3],t[4]=h*u+_*n+d*a-v*o,t[5]=d*u+_*o+v*n-h*a,t[6]=v*u+_*a+h*o-d*n,t[7]=_*u-h*n-d*o-v*a,t}function O(t,e,r){let n=r[0],i=r[1],o=r[2],a=r[3],u=e[0],s=e[1],c=e[2],f=e[3];return t[0]=u*a+f*n+s*o-c*i,t[1]=s*a+f*i+c*n-u*o,t[2]=c*a+f*o+u*i-s*n,t[3]=f*a-u*n-s*i-c*o,u=e[4],s=e[5],c=e[6],f=e[7],t[4]=u*a+f*n+s*o-c*i,t[5]=s*a+f*i+c*n-u*o,t[6]=c*a+f*o+u*i-s*n,t[7]=f*a-u*n-s*i-c*o,t}function R(t,e,r){let n=e[0],i=e[1],o=e[2],a=e[3],u=r[0],s=r[1],c=r[2],f=r[3];return t[0]=n*f+a*u+i*c-o*s,t[1]=i*f+a*s+o*u-n*c,t[2]=o*f+a*c+n*s-i*u,t[3]=a*f-n*u-i*s-o*c,u=r[4],s=r[5],c=r[6],f=r[7],t[4]=n*f+a*u+i*c-o*s,t[5]=i*f+a*s+o*u-n*c,t[6]=o*f+a*c+n*s-i*u,t[7]=a*f-n*u-i*s-o*c,t}function P(t,e,r,i){if(Math.abs(i)0){r=Math.sqrt(r);let n=e[0]/r,i=e[1]/r,o=e[2]/r,a=e[3]/r,u=e[4],s=e[5],c=e[6],f=e[7],l=n*u+i*s+o*c+a*f;t[0]=n,t[1]=i,t[2]=o,t[3]=a,t[4]=(u-n*l)/r,t[5]=(s-i*l)/r,t[6]=(c-o*l)/r,t[7]=(f-a*l)/r}return t}function Y(t){return"quat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+")"}function G(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]}function q(t,e){let r=t[0],i=t[1],o=t[2],a=t[3],u=t[4],s=t[5],c=t[6],f=t[7],l=e[0],h=e[1],d=e[2],v=e[3],_=e[4],m=e[5],p=e[6],y=e[7];return Math.abs(r-l)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(i-h)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(o-d)<=n.EPSILON*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(a-v)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(v))&&Math.abs(u-_)<=n.EPSILON*Math.max(1,Math.abs(u),Math.abs(_))&&Math.abs(s-m)<=n.EPSILON*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(c-p)<=n.EPSILON*Math.max(1,Math.abs(c),Math.abs(p))&&Math.abs(f-y)<=n.EPSILON*Math.max(1,Math.abs(f),Math.abs(y))}},function(t,e,r){"use strict";r.r(e),r.d(e,"create",function(){return i}),r.d(e,"clone",function(){return o}),r.d(e,"fromValues",function(){return a}),r.d(e,"copy",function(){return u}),r.d(e,"set",function(){return s}),r.d(e,"add",function(){return c}),r.d(e,"subtract",function(){return f}),r.d(e,"multiply",function(){return l}),r.d(e,"divide",function(){return h}),r.d(e,"ceil",function(){return d}),r.d(e,"floor",function(){return v}),r.d(e,"min",function(){return _}),r.d(e,"max",function(){return m}),r.d(e,"round",function(){return p}),r.d(e,"scale",function(){return y}),r.d(e,"scaleAndAdd",function(){return b}),r.d(e,"distance",function(){return g}),r.d(e,"squaredDistance",function(){return M}),r.d(e,"length",function(){return x}),r.d(e,"squaredLength",function(){return T}),r.d(e,"negate",function(){return E}),r.d(e,"inverse",function(){return w}),r.d(e,"normalize",function(){return O}),r.d(e,"dot",function(){return R}),r.d(e,"cross",function(){return P}),r.d(e,"lerp",function(){return S}),r.d(e,"random",function(){return A}),r.d(e,"transformMat2",function(){return N}),r.d(e,"transformMat2d",function(){return C}),r.d(e,"transformMat3",function(){return I}),r.d(e,"transformMat4",function(){return L}),r.d(e,"rotate",function(){return k}),r.d(e,"angle",function(){return F}),r.d(e,"str",function(){return D}),r.d(e,"exactEquals",function(){return j}),r.d(e,"equals",function(){return B}),r.d(e,"len",function(){return U}),r.d(e,"sub",function(){return V}),r.d(e,"mul",function(){return Y}),r.d(e,"div",function(){return G}),r.d(e,"dist",function(){return q}),r.d(e,"sqrDist",function(){return H}),r.d(e,"sqrLen",function(){return X}),r.d(e,"forEach",function(){return W});var n=r(0);function i(){let t=new n.ARRAY_TYPE(2);return n.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0),t}function o(t){let e=new n.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e}function a(t,e){let r=new n.ARRAY_TYPE(2);return r[0]=t,r[1]=e,r}function u(t,e){return t[0]=e[0],t[1]=e[1],t}function s(t,e,r){return t[0]=e,t[1]=r,t}function c(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function f(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function l(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function h(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function d(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function v(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function _(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function m(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function p(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t}function y(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function b(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t}function g(t,e){var r=e[0]-t[0],n=e[1]-t[1];return Math.sqrt(r*r+n*n)}function M(t,e){var r=e[0]-t[0],n=e[1]-t[1];return r*r+n*n}function x(t){var e=t[0],r=t[1];return Math.sqrt(e*e+r*r)}function T(t){var e=t[0],r=t[1];return e*e+r*r}function E(t,e){return t[0]=-e[0],t[1]=-e[1],t}function w(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function O(t,e){var r=e[0],n=e[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i),t}function R(t,e){return t[0]*e[0]+t[1]*e[1]}function P(t,e,r){var n=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=n,t}function S(t,e,r,n){var i=e[0],o=e[1];return t[0]=i+n*(r[0]-i),t[1]=o+n*(r[1]-o),t}function A(t,e){e=e||1;var r=2*n.RANDOM()*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function N(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i,t[1]=r[1]*n+r[3]*i,t}function C(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i+r[4],t[1]=r[1]*n+r[3]*i+r[5],t}function I(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[3]*i+r[6],t[1]=r[1]*n+r[4]*i+r[7],t}function L(t,e,r){let n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t}function k(t,e,r,n){let i=e[0]-r[0],o=e[1]-r[1],a=Math.sin(n),u=Math.cos(n);return t[0]=i*u-o*a+r[0],t[1]=i*a+o*u+r[1],t}function F(t,e){let r=t[0],n=t[1],i=e[0],o=e[1],a=r*r+n*n;a>0&&(a=1/Math.sqrt(a));let u=i*i+o*o;u>0&&(u=1/Math.sqrt(u));let s=(r*i+n*o)*a*u;return s>1?0:s<-1?Math.PI:Math.acos(s)}function D(t){return"vec2("+t[0]+", "+t[1]+")"}function j(t,e){return t[0]===e[0]&&t[1]===e[1]}function B(t,e){let r=t[0],i=t[1],o=e[0],a=e[1];return Math.abs(r-o)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-a)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(a))}const U=x,V=f,Y=l,G=h,q=g,H=M,X=T,W=function(){let t=i();return function(e,r,n,i,o,a){let u,s;for(r||(r=2),n||(n=0),s=i?Math.min(i*r+n,e.length):e.length,u=n;u1&&e.pushTriangle(0,o-1,o)}e.endGeometry();var h=e.finishPrimitive(t);this._buttonRenderPrimitive=t.createRenderPrimitive(h,new f),this.addRenderPrimitive(this._buttonRenderPrimitive),n=.035,e.clear(),e.startGeometry(),e.pushVertex(-n,n,r,0,0,0,0,1),e.pushVertex(-n,-n,r,0,1,0,0,1),e.pushVertex(n,-n,r,1,1,0,0,1),e.pushVertex(n,n,r,1,0,0,0,1),e.pushTriangle(0,1,2),e.pushTriangle(0,2,3),e.endGeometry();var d=e.finishPrimitive(t),v=new l;v.icon.texture=this._iconTexture,this._iconRenderPrimitive=t.createRenderPrimitive(d,v),this.addRenderPrimitive(this._iconRenderPrimitive)}},{key:"onHoverStart",value:function(){this._hovered=!0}},{key:"onHoverEnd",value:function(){this._hovered=!1}},{key:"_updateHoverState",value:function(){var t=this._hoverT/200,e=t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1;this._buttonRenderPrimitive.uniforms.hoverAmount.value=e,this._iconRenderPrimitive.uniforms.hoverAmount.value=e}},{key:"onUpdate",value:function(t,e){this._hovered&&this._hoverT<200?(this._hoverT=Math.min(200,this._hoverT+e),this._updateHoverState()):!this._hovered&&this._hoverT>0&&(this._hoverT=Math.max(0,this._hoverT-e),this._updateHoverState())}},{key:"iconTexture",get:function(){return this._iconTexture},set:function(t){this._iconTexture!=t&&(this._iconTexture=t,this._iconRenderPrimitive.samplers.icon.texture=t)}}]),e}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DropShadowNode=void 0;var n=function(){function t(t,e){for(var r=0;r0&&(e.pushTriangle(0,n,n-2),e.pushTriangle(n,n+1,n-1),e.pushTriangle(n,n-1,n-2))}e.pushTriangle(0,1,n),e.pushTriangle(1,2,n+1),e.pushTriangle(1,n+1,n),e.endGeometry();var c=e.finishPrimitive(t);this._shadowRenderPrimitive=t.createRenderPrimitive(c,new l),this.addRenderPrimitive(this._shadowRenderPrimitive)}}]),e}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CubeSeaNode=void 0;var n=function(){function t(t,e){for(var r=0;r0&&void 0!==arguments[0]&&arguments[0];c(this,e);var r=f(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return r.heavy=t,r.baseColor=r.defineSampler("baseColor"),r}return l(e,i.Material),n(e,[{key:"materialName",get:function(){return"CUBE_SEA"}},{key:"vertexSource",get:function(){return"\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n attribute vec3 NORMAL;\n\n varying vec2 vTexCoord;\n varying vec3 vLight;\n\n const vec3 lightDir = vec3(0.75, 0.5, 1.0);\n const vec3 ambientColor = vec3(0.5, 0.5, 0.5);\n const vec3 lightColor = vec3(0.75, 0.75, 0.75);\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vec3 normalRotated = vec3(model * vec4(NORMAL, 0.0));\n float lightFactor = max(dot(normalize(lightDir), normalRotated), 0.0);\n vLight = ambientColor + (lightColor * lightFactor);\n vTexCoord = TEXCOORD_0;\n return proj * view * model * vec4(POSITION, 1.0);\n }"}},{key:"fragmentSource",get:function(){return this.heavy?"\n precision mediump float;\n\n uniform sampler2D diffuse;\n varying vec2 vTexCoord;\n varying vec3 vLight;\n\n vec2 dimensions = vec2(64, 64);\n float seed = 0.42;\n\n vec2 hash( vec2 p ) {\n p=vec2(dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3)));\n return fract(sin(p)*18.5453);\n }\n\n vec3 hash3( vec2 p ) {\n vec3 q = vec3( dot(p,vec2(127.1,311.7)),\n dot(p,vec2(269.5,183.3)),\n dot(p,vec2(419.2,371.9)) );\n return fract(sin(q)*43758.5453);\n }\n\n float iqnoise( in vec2 x, float u, float v ) {\n vec2 p = floor(x);\n vec2 f = fract(x);\n float k = 1.0+63.0*pow(1.0-v,4.0);\n float va = 0.0;\n float wt = 0.0;\n for( int j=-2; j<=2; j++ )\n for( int i=-2; i<=2; i++ ) {\n vec2 g = vec2( float(i),float(j) );\n vec3 o = hash3( p + g )*vec3(u,u,1.0);\n vec2 r = g - f + o.xy;\n float d = dot(r,r);\n float ww = pow( 1.0-smoothstep(0.0,1.414,sqrt(d)), k );\n va += o.z*ww;\n wt += ww;\n }\n return va/wt;\n }\n\n // return distance, and cell id\n vec2 voronoi( in vec2 x ) {\n vec2 n = floor( x );\n vec2 f = fract( x );\n vec3 m = vec3( 8.0 );\n for( int j=-1; j<=1; j++ )\n for( int i=-1; i<=1; i++ ) {\n vec2 g = vec2( float(i), float(j) );\n vec2 o = hash( n + g );\n vec2 r = g - f + (0.5+0.5*sin(seed+6.2831*o));\n float d = dot( r, r );\n if( d0&&void 0!==arguments[0]?arguments[0]:{};c(this,e);var r=f(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return r.heavyGpu=!!t.heavyGpu,r.cubeCount=t.cubeCount||(r.heavyGpu?12:10),r.cubeScale=t.cubeScale||1,r.halfOnly=!!t.halfOnly,r.autoRotate=!!t.autoRotate,r._texture=new a.UrlTexture(t.imageUrl||"media/textures/cube-sea.png"),r._material=new h(r.heavyGpu),r._material.baseColor.texture=r._texture,r._renderPrimitive=null,r}return l(e,o.Node),n(e,[{key:"onRendererChanged",value:function(t){this._renderPrimitive=null;var e=new u.BoxBuilder;e.pushCube([0,.25,-.8],.1),e.pushCube([.8,.25,0],.1),e.pushCube([0,.25,.8],.1),e.pushCube([-.8,.25,0],.1);var r=e.finishPrimitive(t);return this.heroNode=t.createMesh(r,this._material),this.rebuildCubes(e),this.cubeSeaNode=new o.Node,this.cubeSeaNode.addRenderPrimitive(this._renderPrimitive),this.addNode(this.cubeSeaNode),this.addNode(this.heroNode),this.waitForComplete()}},{key:"rebuildCubes",value:function(t){if(this._renderer){t?t.clear():t=new u.BoxBuilder;for(var e=.4*this.cubeScale,r=.5*this.cubeCount,n=0;n12&&(t.indexType=5125);var s=t.finishPrimitive(this._renderer);this._renderPrimitive?this._renderPrimitive.setPrimitive(s):this._renderPrimitive=this._renderer.createRenderPrimitive(s,this._material)}}},{key:"onUpdate",value:function(t,e){this.autoRotate&&s.mat4.fromRotation(this.cubeSeaNode.matrix,t/500,[0,-1,0]),s.mat4.fromRotation(this.heroNode.matrix,t/2e3,[0,1,0])}}]),e}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Gltf2Node=void 0;var n=function(){function t(t,e){for(var r=0;r=0?this._timestamp-t:0,this._update(this._timestamp,this._frameDelta),this._frameDelta}},{key:"endFrame",value:function(){this._inputRenderer&&this._resetInputEndFrame&&this._inputRenderer.reset(),this._stats&&this._stats.end()}},{key:"onLoadScene",value:function(t){return Promise.resolve()}},{key:"inputRenderer",get:function(){return this._inputRenderer||(this._inputRenderer=new o.InputRenderer,this.addNode(this._inputRenderer)),this._inputRenderer}}]),e}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InputRenderer=void 0;var n=function(){function t(t,e){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:"right";this._controllerNode=t,this._controllerNode.visible=!1,this.addNode(this._controllerNode),this._controllerNodeHandedness=e}},{key:"addController",value:function(t){if(this._controllerNode){var e=null;this._activeControllers1&&r.push(0,i-1,i)}for(var f=0;f<16;++f){var l=f*n,h=Math.cos(l),d=Math.sin(l);if(e.push(.004*h,.004*d,.5,.75),e.push(.007*h,.007*d,0,0),f>0){var v=16+2*f;r.push(v-2,v-1,v),r.push(v-1,v+1,v)}}r.push(46,47,16),r.push(47,17,16);var _=this._renderer.createRenderBuffer(t.ARRAY_BUFFER,new Float32Array(e)),m=this._renderer.createRenderBuffer(t.ELEMENT_ARRAY_BUFFER,new Uint16Array(r)),p=r.length,y=[new a.PrimitiveAttribute("POSITION",_,4,t.FLOAT,16,0)],b=new a.Primitive(y,p);b.setIndexBuffer(m);var x=new g,T=new M,E=this._renderer.createRenderPrimitive(b,x),w=this._renderer.createRenderPrimitive(b,T),O=new o.Node;return O.addRenderPrimitive(E),O.addRenderPrimitive(w),O}}]),e}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StatsViewer=void 0;var n=function(){function t(t,e){for(var r=0;rthis._prevGraphUpdateTime+this._fpsStep){var r=t-this._prevGraphUpdateTime;this._fpsAverage=Math.round(1e3/(r/this._frames)),this._updateGraph(this._fpsMin,this._fpsAverage),this._performanceMonitoring&&console.log("Average FPS: "+this._fpsAverage+" Min FPS: "+this._fpsMin),this._prevGraphUpdateTime=t,this._frames=0,this._fpsMin=0}}},{key:"_updateGraph",value:function(t,e){var r,n=(r=t,{r:Math.max(0,Math.min(1,1-r/60)),g:Math.max(0,Math.min(1,(r-15)/(h-15))),b:Math.max(0,Math.min(1,(r-15)/(h-15)))}),i=_(t-1),o=_(e+1),a=[v(this._lastSegment),o,.02,n.r,n.g,n.b,v(this._lastSegment+1),o,.02,n.r,n.g,n.b,v(this._lastSegment),i,.02,n.r,n.g,n.b,v(this._lastSegment+1),i,.02,n.r,n.g,n.b];n.r=.2,n.g=1,n.b=.2,this._lastSegment==l-1?(this._renderer.updateRenderBuffer(this._fpsVertexBuffer,new Float32Array(a),24*this._lastSegment*4),a=[v(0),_(h),.02,n.r,n.g,n.b,v(.25),_(h),.02,n.r,n.g,n.b,v(0),_(0),.02,n.r,n.g,n.b,v(.25),_(0),.02,n.r,n.g,n.b],this._renderer.updateRenderBuffer(this._fpsVertexBuffer,new Float32Array(a),0)):(a.push(v(this._lastSegment+1),_(h),.02,n.r,n.g,n.b,v(this._lastSegment+1.25),_(h),.02,n.r,n.g,n.b,v(this._lastSegment+1),_(0),.02,n.r,n.g,n.b,v(this._lastSegment+1.25),_(0),.02,n.r,n.g,n.b),this._renderer.updateRenderBuffer(this._fpsVertexBuffer,new Float32Array(a),24*this._lastSegment*4)),this._lastSegment=(this._lastSegment+1)%l,this._sevenSegmentNode.text=this._fpsAverage+" FP5"}},{key:"performanceMonitoring",get:function(){return this._performanceMonitoring},set:function(t){this._performanceMonitoring=t,this._fpsStep=t?1e3:250}}]),e}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SevenSegmentText=void 0;var n=function(){function t(t,e){for(var r=0;r.5*Math.PI&&(this.lookPitch=.5*Math.PI),this.updateView()}},{key:"onFrame",value:function(t){var e=this.gl;window.requestAnimationFrame(this.boundOnFrame),this.scene.startFrame(),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),this.scene.draw(this.projectionMatrix,this.viewMatrix),this.scene.endFrame()}},{key:"updateView",value:function(){i.mat4.identity(this.viewMatrix),i.mat4.rotateX(this.viewMatrix,this.viewMatrix,-this.lookPitch),i.mat4.rotateY(this.viewMatrix,this.viewMatrix,-this.lookYaw),this._emulateStage&&i.mat4.translate(this.viewMatrix,this.viewMatrix,[0,-1.6,0])}},{key:"emulateStage",get:function(){return this._emulateStage},set:function(t){this._emulateStage=t,this.updateView()}}]),t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var r=0;r { - if (ev.touches.length == 2) { - lastTouchX = ev.touches[1].pageX; - lastTouchY = ev.touches[1].pageY; - } - }); - canvas.addEventListener('touchmove', (ev) => { - // Rotate the view when two fingers are being used. - if (ev.touches.length == 2) { - this.onLook(ev.touches[1].pageX - lastTouchX, ev.touches[1].pageY - lastTouchY); - lastTouchX = ev.touches[1].pageX; - lastTouchY = ev.touches[1].pageY; - } - }); - canvas.addEventListener('mousemove', (ev) => { - // Only rotate when the right button is pressed. - if (ev.buttons & 2) { - this.onLook(ev.movementX, ev.movementY); - } - }); - canvas.addEventListener('contextmenu', (ev) => { - // Prevent context menus on the canvas so that we can use right click to rotate. - ev.preventDefault(); - }); - - this.boundOnFrame = this.onFrame.bind(this); - window.requestAnimationFrame(this.boundOnFrame); - } - - onLook(yaw, pitch) { - this.lookYaw += yaw * LOOK_SPEED; - this.lookPitch += pitch * LOOK_SPEED; - - // Clamp pitch rotation beyond looking straight up or down. - if (this.lookPitch < -Math.PI*0.5) { - this.lookPitch = -Math.PI*0.5; - } - if (this.lookPitch > Math.PI*0.5) { - this.lookPitch = Math.PI*0.5; - } - - this.updateView(); - } - - onFrame(t) { - let gl = this.gl; - window.requestAnimationFrame(this.boundOnFrame); - - this.scene.startFrame(); - - // We can skip setting the framebuffer and viewport every frame, because - // it won't change from frame to frame and we're updating the viewport - // only when we resize for efficency. - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); - - // We're drawing with our own projection and view matrix now, and we - // don't have a list of view to loop through, but otherwise all of the - // WebGL drawing logic is exactly the same. - this.scene.draw(this.projectionMatrix, this.viewMatrix); - - this.scene.endFrame(); - } - - get emulateStage() { - return this._emulateStage; - } - - set emulateStage(value) { - this._emulateStage = value; - this.updateView(); - } - - updateView() { - mat4.identity(this.viewMatrix); - - mat4.rotateX(this.viewMatrix, this.viewMatrix, -this.lookPitch); - mat4.rotateY(this.viewMatrix, this.viewMatrix, -this.lookYaw); - - // If we're emulating a stage frame of reference we'll need to move the view - // matrix roughly a meter and a half up in the air. - if (this._emulateStage) { - mat4.translate(this.viewMatrix, this.viewMatrix, [0, -1.6, 0]); - } - } -} diff --git a/js/cottontail/webpack.config.debug.js b/js/cottontail/webpack.config.debug.js deleted file mode 100644 index 6adb05554..000000000 --- a/js/cottontail/webpack.config.debug.js +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -'use strict'; - -let fs = require('fs'); -let path = require('path'); -let webpack = require('webpack'); - -// Read the LICENSE file to append to the generated file. -let header = fs.readFileSync('LICENSE.md', { encoding: 'utf8' }); - -module.exports = { - entry: './src/cottontail.js', - output: { - path: path.join(__dirname, 'build'), - filename: 'cottontail.debug.js', - libraryTarget: 'umd' - }, - devtool: 'source-map', - module: { - rules: [ - { - test: /\.js$/, - exclude: /node_modules/, - use: { - loader: 'babel-loader' - } - } - ] - }, - plugins: [ - new webpack.BannerPlugin({ banner: header, entryOnly: true }), - ], - mode: "development" -}; - diff --git a/js/cottontail/webpack.config.js b/js/cottontail/webpack.config.js deleted file mode 100644 index 8268697e6..000000000 --- a/js/cottontail/webpack.config.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -'use strict'; - -let fs = require('fs'); -let path = require('path'); -let webpack = require('webpack'); - -// Read the LICENSE file to append to the generated file. -let header = fs.readFileSync('LICENSE.md', { encoding: 'utf8' }); - -module.exports = { - entry: './src/cottontail.js', - output: { - path: path.join(__dirname, 'build'), - filename: 'cottontail.js', - libraryTarget: 'umd' - }, - module: { - rules: [ - { - test: /\.js$/, - exclude: /node_modules/, - use: { - loader: 'babel-loader' - } - } - ] - }, - plugins: [ - new webpack.BannerPlugin({ banner: header, entryOnly: true }), - ], - mode: "production" -}; - diff --git a/js/render/README.md b/js/render/README.md new file mode 100644 index 000000000..673a0ec98 --- /dev/null +++ b/js/render/README.md @@ -0,0 +1,23 @@ +WebXR Samples Renderer +========================================== +A simple WebGL renderering framework optimised for demonstrating WebXR concepts. + +This library does two things well and not much else: + +1) Loading and Rendering GLTF 2.0 files. +2) Optimising for WebXR-style rendering. + +However it explicitly goes out of it's way to NOT wrap much, if any, WebXR +functionality. This is because arguably it's sole purpose in life is to enable +the WebXR samples, who's sole purpose in life is to provide easy-to-follow code +snippets demonstrating the API use and thus anything this code did to hide the +WebXR API's direct use is counter productive. + +The only "third party" dependency is gl-matrix. + +Using this renderer for your own projects is very much not recommended, as you will +almost certainly be better served by one of the other more popular frameworks +out there. + +Library previously had a build step but all WebXR-enabled browsers support JS +modules, so it turned out to be more of a nusiance than it was worth. diff --git a/js/cottontail/src/core/material.js b/js/render/core/material.js similarity index 100% rename from js/cottontail/src/core/material.js rename to js/render/core/material.js diff --git a/js/cottontail/src/core/node.js b/js/render/core/node.js similarity index 96% rename from js/cottontail/src/core/node.js rename to js/render/core/node.js index 37a072e31..a85bb28ce 100644 --- a/js/cottontail/src/core/node.js +++ b/js/render/core/node.js @@ -356,14 +356,14 @@ export class Node { } } - _hitTestSelectableNode(ray) { + _hitTestSelectableNode(rigidTransform) { if (this._renderPrimitives) { let localRay = null; for (let primitive of this._renderPrimitives) { if (primitive._min) { if (!localRay) { mat4.invert(tmpRayMatrix, this.worldMatrix); - mat4.multiply(tmpRayMatrix, tmpRayMatrix, ray.transformMatrix); + mat4.multiply(tmpRayMatrix, tmpRayMatrix, rigidTransform.matrix); localRay = new Ray(tmpRayMatrix); } let intersection = localRay.intersectsAABB(primitive._min, primitive._max); @@ -375,7 +375,7 @@ export class Node { } } for (let child of this.children) { - let intersection = child._hitTestSelectableNode(ray); + let intersection = child._hitTestSelectableNode(rigidTransform); if (intersection) { return intersection; } @@ -383,11 +383,12 @@ export class Node { return null; } - hitTest(ray) { + hitTest(rigidTransform) { if (this.selectable && this.visible) { - let intersection = this._hitTestSelectableNode(ray); + let intersection = this._hitTestSelectableNode(rigidTransform); if (intersection) { + let ray = new Ray(rigidTransform.matrix); let origin = vec3.fromValues(ray.origin.x, ray.origin.y, ray.origin.z); return { node: this, @@ -400,7 +401,7 @@ export class Node { let result = null; for (let child of this.children) { - let childResult = child.hitTest(ray); + let childResult = child.hitTest(rigidTransform); if (childResult) { if (!result || result.distance > childResult.distance) { result = childResult; diff --git a/js/cottontail/src/core/primitive.js b/js/render/core/primitive.js similarity index 100% rename from js/cottontail/src/core/primitive.js rename to js/render/core/primitive.js diff --git a/js/cottontail/src/core/program.js b/js/render/core/program.js similarity index 100% rename from js/cottontail/src/core/program.js rename to js/render/core/program.js diff --git a/js/cottontail/src/core/renderer.js b/js/render/core/renderer.js similarity index 97% rename from js/cottontail/src/core/renderer.js rename to js/render/core/renderer.js index 661eb2bfc..9a14c8859 100644 --- a/js/cottontail/src/core/renderer.js +++ b/js/render/core/renderer.js @@ -99,13 +99,31 @@ export function createWebGLContext(glAttribs) { } export class RenderView { - constructor(projectionMatrix, viewMatrix, viewport = null, eye = 'left') { + constructor(projectionMatrix, viewTransform, viewport = null, eye = 'left') { this.projectionMatrix = projectionMatrix; - this.viewMatrix = viewMatrix; + this.viewTransform = viewTransform; this.viewport = viewport; // If an eye isn't given the left eye is assumed. this._eye = eye; this._eyeIndex = (eye == 'left' ? 0 : 1); + + // Compute the view matrix + this._viewMatrix = mat4.create(); + let q = viewTransform.orientation; + let t = viewTransform.position; + mat4.fromRotationTranslation( + this._viewMatrix, + [q.x, q.y, q.z, q.w], + [t.x, t.y, t.z] + ); + mat4.invert(this._viewMatrix, this._viewMatrix); + + // Alternative view matrix code path + //this._viewMatrix = viewTransform.inverse().matrix; + } + + get viewMatrix() { + return this._viewMatrix; } get eye() { @@ -610,14 +628,18 @@ export class Renderer { // Get the positions of the 'camera' for each view matrix. for (let i = 0; i < views.length; ++i) { - mat4.invert(inverseMatrix, views[i].viewMatrix); - if (this._cameraPositions.length <= i) { this._cameraPositions.push(vec3.create()); } + let p = views[i].viewTransform.position; + this._cameraPositions[i][0] = p.x; + this._cameraPositions[i][1] = p.y; + this._cameraPositions[i][2] = p.z; + + /*mat4.invert(inverseMatrix, views[i].viewMatrix); let cameraPosition = this._cameraPositions[i]; vec3.set(cameraPosition, 0, 0, 0); - vec3.transformMat4(cameraPosition, cameraPosition, inverseMatrix); + vec3.transformMat4(cameraPosition, cameraPosition, inverseMatrix);*/ } // Draw each set of render primitives in order diff --git a/js/cottontail/src/core/texture.js b/js/render/core/texture.js similarity index 100% rename from js/cottontail/src/core/texture.js rename to js/render/core/texture.js diff --git a/js/cottontail/src/geometry/box-builder.js b/js/render/geometry/box-builder.js similarity index 100% rename from js/cottontail/src/geometry/box-builder.js rename to js/render/geometry/box-builder.js diff --git a/js/cottontail/src/geometry/cone-builder.js b/js/render/geometry/cone-builder.js similarity index 100% rename from js/cottontail/src/geometry/cone-builder.js rename to js/render/geometry/cone-builder.js diff --git a/js/cottontail/src/geometry/primitive-stream.js b/js/render/geometry/primitive-stream.js similarity index 100% rename from js/cottontail/src/geometry/primitive-stream.js rename to js/render/geometry/primitive-stream.js diff --git a/js/cottontail/src/loaders/gltf2.js b/js/render/loaders/gltf2.js similarity index 100% rename from js/cottontail/src/loaders/gltf2.js rename to js/render/loaders/gltf2.js diff --git a/js/cottontail/src/materials/pbr.js b/js/render/materials/pbr.js similarity index 100% rename from js/cottontail/src/materials/pbr.js rename to js/render/materials/pbr.js diff --git a/js/cottontail/src/math/gl-matrix.js b/js/render/math/gl-matrix.js similarity index 61% rename from js/cottontail/src/math/gl-matrix.js rename to js/render/math/gl-matrix.js index fbd22d39c..045648855 100644 --- a/js/cottontail/src/math/gl-matrix.js +++ b/js/render/math/gl-matrix.js @@ -18,16 +18,16 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -import * as glMatrix from '../../node_modules/gl-matrix/src/gl-matrix/common.js'; -import * as mat2 from '../../node_modules/gl-matrix/src/gl-matrix/mat2.js'; -import * as mat2d from '../../node_modules/gl-matrix/src/gl-matrix/mat2d.js'; -import * as mat3 from '../../node_modules/gl-matrix/src/gl-matrix/mat3.js'; -import * as mat4 from '../../node_modules/gl-matrix/src/gl-matrix/mat4.js'; -import * as quat from '../../node_modules/gl-matrix/src/gl-matrix/quat.js'; -import * as quat2 from '../../node_modules/gl-matrix/src/gl-matrix/quat2.js'; -import * as vec2 from '../../node_modules/gl-matrix/src/gl-matrix/vec2.js'; -import * as vec3 from '../../node_modules/gl-matrix/src/gl-matrix/vec3.js'; -import * as vec4 from '../../node_modules/gl-matrix/src/gl-matrix/vec4.js'; +import * as glMatrix from '../../third-party/gl-matrix/src/gl-matrix/common.js'; +import * as mat2 from '../../third-party/gl-matrix/src/gl-matrix/mat2.js'; +import * as mat2d from '../../third-party/gl-matrix/src/gl-matrix/mat2d.js'; +import * as mat3 from '../../third-party/gl-matrix/src/gl-matrix/mat3.js'; +import * as mat4 from '../../third-party/gl-matrix/src/gl-matrix/mat4.js'; +import * as quat from '../../third-party/gl-matrix/src/gl-matrix/quat.js'; +import * as quat2 from '../../third-party/gl-matrix/src/gl-matrix/quat2.js'; +import * as vec2 from '../../third-party/gl-matrix/src/gl-matrix/vec2.js'; +import * as vec3 from '../../third-party/gl-matrix/src/gl-matrix/vec3.js'; +import * as vec4 from '../../third-party/gl-matrix/src/gl-matrix/vec4.js'; export { glMatrix, diff --git a/js/cottontail/src/math/ray.js b/js/render/math/ray.js similarity index 97% rename from js/cottontail/src/math/ray.js rename to js/render/math/ray.js index 3ece441d9..ceb5daf05 100644 --- a/js/cottontail/src/math/ray.js +++ b/js/render/math/ray.js @@ -38,14 +38,14 @@ export class Ray { } // To force the inverse and sign calculations. - this.dir = this._dir; + this.direction = this._dir; } - get dir() { + get direction() { return this._dir; } - set dir(value) { + set direction(value) { this._dir = vec3.copy(this._dir, value); vec3.normalize(this._dir, this._dir); diff --git a/js/cottontail/src/nodes/bounds-renderer.js b/js/render/nodes/bounds-renderer.js similarity index 69% rename from js/cottontail/src/nodes/bounds-renderer.js rename to js/render/nodes/bounds-renderer.js index 081efa14d..5fc68908f 100644 --- a/js/cottontail/src/nodes/bounds-renderer.js +++ b/js/render/nodes/bounds-renderer.js @@ -19,13 +19,13 @@ // SOFTWARE. /* -This file renders a passed in XRStageBounds object and attempts +This file renders a passed in XRBoundedReferenceSpace object and attempts to render geometry on the floor to indicate where the bounds is. -XRStageBounds' `geometry` is a series of XRStageBoundsPoints (in -clockwise-order) with `x` and `z` properties for each. +The bounds `geometry` is a series of DOMPointReadOnlys in +clockwise-order. */ -import {Material} from '../core/material.js'; +import {Material, RENDER_ORDER} from '../core/material.js'; import {Node} from '../core/node.js'; import {Primitive, PrimitiveAttribute} from '../core/primitive.js'; @@ -35,10 +35,12 @@ class BoundsMaterial extends Material { constructor() { super(); + this.renderOrder = RENDER_ORDER.ADDITIVE; this.state.blend = true; this.state.blendFuncSrc = GL.SRC_ALPHA; this.state.blendFuncDst = GL.ONE; this.state.depthTest = false; + this.state.cullFace = false; } get materialName() { @@ -47,9 +49,10 @@ class BoundsMaterial extends Material { get vertexSource() { return ` - attribute vec2 POSITION; - + attribute vec3 POSITION; + varying vec3 v_pos; vec4 vertex_main(mat4 proj, mat4 view, mat4 model) { + v_pos = POSITION; return proj * view * model * vec4(POSITION, 1.0); }`; } @@ -57,50 +60,62 @@ class BoundsMaterial extends Material { get fragmentSource() { return ` precision mediump float; - + varying vec3 v_pos; vec4 fragment_main() { - return vec4(0.0, 1.0, 0.0, 0.3); + return vec4(0.0, 1.0, 0.0, (2.0 - v_pos.y) * 0.5); }`; } } export class BoundsRenderer extends Node { - constructor() { + constructor(boundedRefSpace) { super(); - this._stageBounds = null; + this._boundedRefSpace = boundedRefSpace; } onRendererChanged(renderer) { - this.stageBounds = this._stageBounds; + this.boundedRefSpace = this._boundedRefSpace; } - get stageBounds() { - return this._stageBounds; + get boundedRefSpace() { + return this._boundedRefSpace; } - set stageBounds(stageBounds) { - if (this._stageBounds) { + set boundedRefSpace(refSpace) { + if (this._boundedRefSpace) { this.clearRenderPrimitives(); } - this._stageBounds = stageBounds; - if (!stageBounds || stageBounds.length === 0 || !this._renderer) { + this._boundedRefSpace = refSpace; + if (!refSpace || refSpace.boundsGeometry.length === 0 || !this._renderer) { return; } + let geometry = refSpace.boundsGeometry; + let verts = []; let indices = []; // Tessellate the bounding points from XRStageBounds and connect // each point to a neighbor and 0,0,0. - const pointCount = stageBounds.geometry.length; + const pointCount = geometry.length; + let lastIndex = -1; for (let i = 0; i < pointCount; i++) { - const point = stageBounds.geometry[i]; + const point = geometry[i]; verts.push(point.x, 0, point.z); - indices.push(i, i === 0 ? pointCount - 1 : i - 1, pointCount); + verts.push(point.x, 2.0, point.z); + + lastIndex += 2; + if (i > 0) { + indices.push(lastIndex, lastIndex-1, lastIndex-2); + indices.push(lastIndex-2, lastIndex-1, lastIndex-3); + } + } + + if (pointCount > 1) { + indices.push(1, 0, lastIndex); + indices.push(lastIndex, 0, lastIndex-1); } - // Center point - verts.push(0, 0, 0); let vertexBuffer = this._renderer.createRenderBuffer(GL.ARRAY_BUFFER, new Float32Array(verts)); let indexBuffer = this._renderer.createRenderBuffer(GL.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices)); diff --git a/js/cottontail/src/nodes/button.js b/js/render/nodes/button.js similarity index 100% rename from js/cottontail/src/nodes/button.js rename to js/render/nodes/button.js diff --git a/js/cottontail/src/nodes/cube-sea.js b/js/render/nodes/cube-sea.js similarity index 100% rename from js/cottontail/src/nodes/cube-sea.js rename to js/render/nodes/cube-sea.js diff --git a/js/cottontail/src/nodes/drop-shadow.js b/js/render/nodes/drop-shadow.js similarity index 100% rename from js/cottontail/src/nodes/drop-shadow.js rename to js/render/nodes/drop-shadow.js diff --git a/js/cottontail/src/nodes/gltf2.js b/js/render/nodes/gltf2.js similarity index 100% rename from js/cottontail/src/nodes/gltf2.js rename to js/render/nodes/gltf2.js diff --git a/js/cottontail/src/nodes/input-renderer.js b/js/render/nodes/input-renderer.js similarity index 99% rename from js/cottontail/src/nodes/input-renderer.js rename to js/render/nodes/input-renderer.js index fd89982d0..46235b1b1 100644 --- a/js/cottontail/src/nodes/input-renderer.js +++ b/js/render/nodes/input-renderer.js @@ -260,7 +260,7 @@ export class InputRenderer extends Node { controller.visible = true; } - addLaserPointer(targetRay) { + addLaserPointer(rigidTransform) { // Create the laser pointer mesh if needed. if (!this._lasers && this._renderer) { this._lasers = [this._createLaserMesh()]; @@ -277,7 +277,7 @@ export class InputRenderer extends Node { } this._activeLasers = (this._activeLasers + 1) % this._maxInputElements; - laser.matrix = targetRay.transformMatrix; + laser.matrix = rigidTransform.matrix; laser.visible = true; } diff --git a/js/cottontail/src/nodes/seven-segment-text.js b/js/render/nodes/seven-segment-text.js similarity index 100% rename from js/cottontail/src/nodes/seven-segment-text.js rename to js/render/nodes/seven-segment-text.js diff --git a/js/cottontail/src/nodes/skybox.js b/js/render/nodes/skybox.js similarity index 100% rename from js/cottontail/src/nodes/skybox.js rename to js/render/nodes/skybox.js diff --git a/js/cottontail/src/nodes/stats-viewer.js b/js/render/nodes/stats-viewer.js similarity index 100% rename from js/cottontail/src/nodes/stats-viewer.js rename to js/render/nodes/stats-viewer.js diff --git a/js/cottontail/src/nodes/video.js b/js/render/nodes/video.js similarity index 100% rename from js/cottontail/src/nodes/video.js rename to js/render/nodes/video.js diff --git a/js/cottontail/src/scenes/scene.js b/js/render/scenes/scene.js similarity index 66% rename from js/cottontail/src/scenes/scene.js rename to js/render/scenes/scene.js index 4d6e05a8d..60823ddc3 100644 --- a/js/cottontail/src/scenes/scene.js +++ b/js/render/scenes/scene.js @@ -23,12 +23,13 @@ import {InputRenderer} from '../nodes/input-renderer.js'; import {StatsViewer} from '../nodes/stats-viewer.js'; import {Node} from '../core/node.js'; import {vec3, quat} from '../math/gl-matrix.js'; +import {Ray} from '../math/ray.js'; export class WebXRView extends RenderView { - constructor(view, pose, layer) { + constructor(view, layer) { super( view ? view.projectionMatrix : null, - (pose && view) ? view.viewMatrix : null, + view ? view.transform : null, (layer && view) ? layer.getViewport(view) : null, view ? view.eye : 'left' ); @@ -80,73 +81,70 @@ export class Scene extends Node { // Helper function that automatically adds the appropriate visual elements for // all input sources. updateInputSources(frame, refSpace) { - // FIXME: Check for the existence of the API first. This check should be - // removed once the input API is part of the official spec. - if (!frame.session.getInputSources) { - return; - } - - let inputSources = frame.session.getInputSources(); - let newHoveredNodes = []; let lastHoverFrame = this._hoverFrame; this._hoverFrame++; - for (let inputSource of inputSources) { - let inputPose = frame.getInputPose(inputSource, refSpace); + for (let inputSource of frame.session.inputSources) { + let targetRayPose = frame.getPose(inputSource.targetRaySpace, refSpace); - if (!inputPose) { + if (!targetRayPose) { continue; } - // Any time that we have a grip matrix, we'll render a controller. - if (inputPose.gripTransform.matrix) { - this.inputRenderer.addController(inputPose.gripTransform.matrix); + if (inputSource.targetRayMode == 'tracked-pointer') { + // If we have a pointer matrix and the pointer origin is the users + // hand (as opposed to their head or the screen) use it to render + // a ray coming out of the input device to indicate the pointer + // direction. + this.inputRenderer.addLaserPointer(targetRayPose.transform); } - if (inputPose.targetRay) { - if (inputSource.targetRayMode == 'tracked-pointer') { - // If we have a pointer matrix and the pointer origin is the users - // hand (as opposed to their head or the screen) use it to render - // a ray coming out of the input device to indicate the pointer - // direction. - this.inputRenderer.addLaserPointer(inputPose.targetRay); + // If we have a pointer matrix we can also use it to render a cursor + // for both handheld and gaze-based input sources. + + // Check and see if the pointer is pointing at any selectable objects. + let hitResult = this.hitTest(targetRayPose.transform); + + if (hitResult) { + // Render a cursor at the intersection point. + this.inputRenderer.addCursor(hitResult.intersection); + + if (hitResult.node._hoverFrameId != lastHoverFrame) { + hitResult.node.onHoverStart(); } + hitResult.node._hoverFrameId = this._hoverFrame; + newHoveredNodes.push(hitResult.node); + } else { + // Statically render the cursor 1 meters down the ray since we didn't + // hit anything selectable. + let targetRay = new Ray(targetRayPose.transform); + let cursorDistance = 1.0; + let cursorPos = vec3.fromValues( + targetRay.origin.x, + targetRay.origin.y, + targetRay.origin.z + ); + vec3.add(cursorPos, cursorPos, [ + targetRay.direction.x * cursorDistance, + targetRay.direction.y * cursorDistance, + targetRay.direction.z * cursorDistance, + ]); + // let cursorPos = vec3.fromValues(0, 0, -1.0); + // vec3.transformMat4(cursorPos, cursorPos, inputPose.targetRay); + this.inputRenderer.addCursor(cursorPos); + } + + if (inputSource.gripSpace) { + let gripPose = frame.getPose(inputSource.gripSpace, refSpace); - // If we have a pointer matrix we can also use it to render a cursor - // for both handheld and gaze-based input sources. - - // Check and see if the pointer is pointing at any selectable objects. - let hitResult = this.hitTest(inputPose.targetRay); - - if (hitResult) { - // Render a cursor at the intersection point. - this.inputRenderer.addCursor(hitResult.intersection); - - if (hitResult.node._hoverFrameId != lastHoverFrame) { - hitResult.node.onHoverStart(); - } - hitResult.node._hoverFrameId = this._hoverFrame; - newHoveredNodes.push(hitResult.node); - } else { - // Statically render the cursor 1 meters down the ray since we didn't - // hit anything selectable. - let cursorDistance = 1.0; - let cursorPos = vec3.fromValues( - inputPose.targetRay.origin.x, - inputPose.targetRay.origin.y, - inputPose.targetRay.origin.z - ); - vec3.add(cursorPos, cursorPos, [ - inputPose.targetRay.direction.x * cursorDistance, - inputPose.targetRay.direction.y * cursorDistance, - inputPose.targetRay.direction.z * cursorDistance, - ]); - // let cursorPos = vec3.fromValues(0, 0, -1.0); - // vec3.transformMat4(cursorPos, cursorPos, inputPose.targetRay); - this.inputRenderer.addCursor(cursorPos); + // Any time that we have a grip matrix, we'll render a controller. + if (gripPose) { + this.inputRenderer.addController(gripPose.transform.matrix); } } + + } for (let hoverNode of this._hoveredNodes) { @@ -159,19 +157,19 @@ export class Scene extends Node { } handleSelect(inputSource, frame, refSpace) { - let inputPose = frame.getInputPose(inputSource, refSpace); + let targetRayPose = frame.getPose(inputSource.targetRaySpace, refSpace); - if (!inputPose) { + if (!targetRayPose) { return; } - this.handleSelectPointer(inputPose.targetRay); + this.handleSelectPointer(targetRayPose.transform); } - handleSelectPointer(targetRay) { - if (targetRay) { + handleSelectPointer(rigidTransform) { + if (rigidTransform) { // Check and see if the pointer is pointing at any selectable objects. - let hitResult = this.hitTest(targetRay); + let hitResult = this.hitTest(rigidTransform); if (hitResult) { // Render a cursor at the intersection point. @@ -220,10 +218,8 @@ export class Scene extends Node { } } - draw(projectionMatrix, viewMatrix, eye) { - let view = new RenderView(); - view.projectionMatrix = projectionMatrix; - view.viewMatrix = viewMatrix; + draw(projectionMatrix, viewTransform, eye) { + let view = new RenderView(projectionMatrix, viewTransform); if (eye) { view.eye = eye; } @@ -254,7 +250,7 @@ export class Scene extends Node { let views = []; for (let view of pose.views) { - views.push(new WebXRView(view, pose, layer)); + views.push(new WebXRView(view, layer)); } this.drawViewArray(views); diff --git a/js/third-party/gl-matrix/LICENSE.md b/js/third-party/gl-matrix/LICENSE.md new file mode 100644 index 000000000..c74d17fa7 --- /dev/null +++ b/js/third-party/gl-matrix/LICENSE.md @@ -0,0 +1,19 @@ +Copyright (c) 2015-2018, Brandon Jones, Colin MacKenzie IV. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/js/third-party/gl-matrix/src/gl-matrix.js b/js/third-party/gl-matrix/src/gl-matrix.js new file mode 100644 index 000000000..71e0e7170 --- /dev/null +++ b/js/third-party/gl-matrix/src/gl-matrix.js @@ -0,0 +1,17 @@ +import * as glMatrix from "./gl-matrix/common.js"; +import * as mat2 from "./gl-matrix/mat2.js"; +import * as mat2d from "./gl-matrix/mat2d.js"; +import * as mat3 from "./gl-matrix/mat3.js"; +import * as mat4 from "./gl-matrix/mat4.js"; +import * as quat from "./gl-matrix/quat.js"; +import * as quat2 from "./gl-matrix/quat2.js"; +import * as vec2 from "./gl-matrix/vec2.js"; +import * as vec3 from "./gl-matrix/vec3.js"; +import * as vec4 from "./gl-matrix/vec4.js"; + +export { + glMatrix, + mat2, mat2d, mat3, mat4, + quat, quat2, + vec2, vec3, vec4, +}; diff --git a/js/third-party/gl-matrix/src/gl-matrix/common.js b/js/third-party/gl-matrix/src/gl-matrix/common.js new file mode 100644 index 000000000..98b19236c --- /dev/null +++ b/js/third-party/gl-matrix/src/gl-matrix/common.js @@ -0,0 +1,42 @@ +/** + * Common utilities + * @module glMatrix + */ + +// Configuration Constants +export const EPSILON = 0.000001; +export let ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array; +export const RANDOM = Math.random; + +/** + * Sets the type of array used when creating new vectors and matrices + * + * @param {Type} type Array type, such as Float32Array or Array + */ +export function setMatrixArrayType(type) { + ARRAY_TYPE = type; +} + +const degree = Math.PI / 180; + +/** + * Convert Degree To Radian + * + * @param {Number} a Angle in Degrees + */ +export function toRadian(a) { + return a * degree; +} + +/** + * Tests whether or not the arguments have approximately the same value, within an absolute + * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less + * than or equal to 1.0, and a relative tolerance is used for larger values) + * + * @param {Number} a The first number to test. + * @param {Number} b The second number to test. + * @returns {Boolean} True if the numbers are approximately equal, false otherwise. + */ +export function equals(a, b) { + return Math.abs(a - b) <= EPSILON*Math.max(1.0, Math.abs(a), Math.abs(b)); +} diff --git a/js/third-party/gl-matrix/src/gl-matrix/mat2.js b/js/third-party/gl-matrix/src/gl-matrix/mat2.js new file mode 100644 index 000000000..50d8e7c95 --- /dev/null +++ b/js/third-party/gl-matrix/src/gl-matrix/mat2.js @@ -0,0 +1,415 @@ +import * as glMatrix from "./common.js" + +/** + * 2x2 Matrix + * @module mat2 + */ + +/** + * Creates a new identity mat2 + * + * @returns {mat2} a new 2x2 matrix + */ +export function create() { + let out = new glMatrix.ARRAY_TYPE(4); + if(glMatrix.ARRAY_TYPE != Float32Array) { + out[1] = 0; + out[2] = 0; + } + out[0] = 1; + out[3] = 1; + return out; +} + +/** + * Creates a new mat2 initialized with values from an existing matrix + * + * @param {mat2} a matrix to clone + * @returns {mat2} a new 2x2 matrix + */ +export function clone(a) { + let out = new glMatrix.ARRAY_TYPE(4); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; +} + +/** + * Copy the values from one mat2 to another + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the source matrix + * @returns {mat2} out + */ +export function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; +} + +/** + * Set a mat2 to the identity matrix + * + * @param {mat2} out the receiving matrix + * @returns {mat2} out + */ +export function identity(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + return out; +} + +/** + * Create a new mat2 with the given values + * + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m10 Component in column 1, row 0 position (index 2) + * @param {Number} m11 Component in column 1, row 1 position (index 3) + * @returns {mat2} out A new 2x2 matrix + */ +export function fromValues(m00, m01, m10, m11) { + let out = new glMatrix.ARRAY_TYPE(4); + out[0] = m00; + out[1] = m01; + out[2] = m10; + out[3] = m11; + return out; +} + +/** + * Set the components of a mat2 to the given values + * + * @param {mat2} out the receiving matrix + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m10 Component in column 1, row 0 position (index 2) + * @param {Number} m11 Component in column 1, row 1 position (index 3) + * @returns {mat2} out + */ +export function set(out, m00, m01, m10, m11) { + out[0] = m00; + out[1] = m01; + out[2] = m10; + out[3] = m11; + return out; +} + +/** + * Transpose the values of a mat2 + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the source matrix + * @returns {mat2} out + */ +export function transpose(out, a) { + // If we are transposing ourselves we can skip a few steps but have to cache + // some values + if (out === a) { + let a1 = a[1]; + out[1] = a[2]; + out[2] = a1; + } else { + out[0] = a[0]; + out[1] = a[2]; + out[2] = a[1]; + out[3] = a[3]; + } + + return out; +} + +/** + * Inverts a mat2 + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the source matrix + * @returns {mat2} out + */ +export function invert(out, a) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + + // Calculate the determinant + let det = a0 * a3 - a2 * a1; + + if (!det) { + return null; + } + det = 1.0 / det; + + out[0] = a3 * det; + out[1] = -a1 * det; + out[2] = -a2 * det; + out[3] = a0 * det; + + return out; +} + +/** + * Calculates the adjugate of a mat2 + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the source matrix + * @returns {mat2} out + */ +export function adjoint(out, a) { + // Caching this value is nessecary if out == a + let a0 = a[0]; + out[0] = a[3]; + out[1] = -a[1]; + out[2] = -a[2]; + out[3] = a0; + + return out; +} + +/** + * Calculates the determinant of a mat2 + * + * @param {mat2} a the source matrix + * @returns {Number} determinant of a + */ +export function determinant(a) { + return a[0] * a[3] - a[2] * a[1]; +} + +/** + * Multiplies two mat2's + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the first operand + * @param {mat2} b the second operand + * @returns {mat2} out + */ +export function multiply(out, a, b) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + out[0] = a0 * b0 + a2 * b1; + out[1] = a1 * b0 + a3 * b1; + out[2] = a0 * b2 + a2 * b3; + out[3] = a1 * b2 + a3 * b3; + return out; +} + +/** + * Rotates a mat2 by the given angle + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat2} out + */ +export function rotate(out, a, rad) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + let s = Math.sin(rad); + let c = Math.cos(rad); + out[0] = a0 * c + a2 * s; + out[1] = a1 * c + a3 * s; + out[2] = a0 * -s + a2 * c; + out[3] = a1 * -s + a3 * c; + return out; +} + +/** + * Scales the mat2 by the dimensions in the given vec2 + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the matrix to rotate + * @param {vec2} v the vec2 to scale the matrix by + * @returns {mat2} out + **/ +export function scale(out, a, v) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + let v0 = v[0], v1 = v[1]; + out[0] = a0 * v0; + out[1] = a1 * v0; + out[2] = a2 * v1; + out[3] = a3 * v1; + return out; +} + +/** + * Creates a matrix from a given angle + * This is equivalent to (but much faster than): + * + * mat2.identity(dest); + * mat2.rotate(dest, dest, rad); + * + * @param {mat2} out mat2 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat2} out + */ +export function fromRotation(out, rad) { + let s = Math.sin(rad); + let c = Math.cos(rad); + out[0] = c; + out[1] = s; + out[2] = -s; + out[3] = c; + return out; +} + +/** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat2.identity(dest); + * mat2.scale(dest, dest, vec); + * + * @param {mat2} out mat2 receiving operation result + * @param {vec2} v Scaling vector + * @returns {mat2} out + */ +export function fromScaling(out, v) { + out[0] = v[0]; + out[1] = 0; + out[2] = 0; + out[3] = v[1]; + return out; +} + +/** + * Returns a string representation of a mat2 + * + * @param {mat2} a matrix to represent as a string + * @returns {String} string representation of the matrix + */ +export function str(a) { + return 'mat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')'; +} + +/** + * Returns Frobenius norm of a mat2 + * + * @param {mat2} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ +export function frob(a) { + return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2))) +} + +/** + * Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix + * @param {mat2} L the lower triangular matrix + * @param {mat2} D the diagonal matrix + * @param {mat2} U the upper triangular matrix + * @param {mat2} a the input matrix to factorize + */ + +export function LDU(L, D, U, a) { + L[2] = a[2]/a[0]; + U[0] = a[0]; + U[1] = a[1]; + U[3] = a[3] - L[2] * U[1]; + return [L, D, U]; +} + +/** + * Adds two mat2's + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the first operand + * @param {mat2} b the second operand + * @returns {mat2} out + */ +export function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + return out; +} + +/** + * Subtracts matrix b from matrix a + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the first operand + * @param {mat2} b the second operand + * @returns {mat2} out + */ +export function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; + return out; +} + +/** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {mat2} a The first matrix. + * @param {mat2} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ +export function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; +} + +/** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {mat2} a The first matrix. + * @param {mat2} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ +export function equals(a, b) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && + Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && + Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && + Math.abs(a3 - b3) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a3), Math.abs(b3))); +} + +/** + * Multiply each element of the matrix by a scalar. + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {mat2} out + */ +export function multiplyScalar(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + return out; +} + +/** + * Adds two mat2's after multiplying each element of the second operand by a scalar value. + * + * @param {mat2} out the receiving vector + * @param {mat2} a the first operand + * @param {mat2} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {mat2} out + */ +export function multiplyScalarAndAdd(out, a, b, scale) { + out[0] = a[0] + (b[0] * scale); + out[1] = a[1] + (b[1] * scale); + out[2] = a[2] + (b[2] * scale); + out[3] = a[3] + (b[3] * scale); + return out; +} + +/** + * Alias for {@link mat2.multiply} + * @function + */ +export const mul = multiply; + +/** + * Alias for {@link mat2.subtract} + * @function + */ +export const sub = subtract; diff --git a/js/third-party/gl-matrix/src/gl-matrix/mat2d.js b/js/third-party/gl-matrix/src/gl-matrix/mat2d.js new file mode 100644 index 000000000..fd391e8d4 --- /dev/null +++ b/js/third-party/gl-matrix/src/gl-matrix/mat2d.js @@ -0,0 +1,448 @@ +import * as glMatrix from "./common.js"; + +/** + * 2x3 Matrix + * @module mat2d + * + * @description + * A mat2d contains six elements defined as: + *
+ * [a, c, tx,
+ *  b, d, ty]
+ * 
+ * This is a short form for the 3x3 matrix: + *
+ * [a, c, tx,
+ *  b, d, ty,
+ *  0, 0, 1]
+ * 
+ * The last row is ignored so the array is shorter and operations are faster. + */ + +/** + * Creates a new identity mat2d + * + * @returns {mat2d} a new 2x3 matrix + */ +export function create() { + let out = new glMatrix.ARRAY_TYPE(6); + if(glMatrix.ARRAY_TYPE != Float32Array) { + out[1] = 0; + out[2] = 0; + out[4] = 0; + out[5] = 0; + } + out[0] = 1; + out[3] = 1; + return out; +} + +/** + * Creates a new mat2d initialized with values from an existing matrix + * + * @param {mat2d} a matrix to clone + * @returns {mat2d} a new 2x3 matrix + */ +export function clone(a) { + let out = new glMatrix.ARRAY_TYPE(6); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + return out; +} + +/** + * Copy the values from one mat2d to another + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the source matrix + * @returns {mat2d} out + */ +export function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + return out; +} + +/** + * Set a mat2d to the identity matrix + * + * @param {mat2d} out the receiving matrix + * @returns {mat2d} out + */ +export function identity(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = 0; + out[5] = 0; + return out; +} + +/** + * Create a new mat2d with the given values + * + * @param {Number} a Component A (index 0) + * @param {Number} b Component B (index 1) + * @param {Number} c Component C (index 2) + * @param {Number} d Component D (index 3) + * @param {Number} tx Component TX (index 4) + * @param {Number} ty Component TY (index 5) + * @returns {mat2d} A new mat2d + */ +export function fromValues(a, b, c, d, tx, ty) { + let out = new glMatrix.ARRAY_TYPE(6); + out[0] = a; + out[1] = b; + out[2] = c; + out[3] = d; + out[4] = tx; + out[5] = ty; + return out; +} + +/** + * Set the components of a mat2d to the given values + * + * @param {mat2d} out the receiving matrix + * @param {Number} a Component A (index 0) + * @param {Number} b Component B (index 1) + * @param {Number} c Component C (index 2) + * @param {Number} d Component D (index 3) + * @param {Number} tx Component TX (index 4) + * @param {Number} ty Component TY (index 5) + * @returns {mat2d} out + */ +export function set(out, a, b, c, d, tx, ty) { + out[0] = a; + out[1] = b; + out[2] = c; + out[3] = d; + out[4] = tx; + out[5] = ty; + return out; +} + +/** + * Inverts a mat2d + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the source matrix + * @returns {mat2d} out + */ +export function invert(out, a) { + let aa = a[0], ab = a[1], ac = a[2], ad = a[3]; + let atx = a[4], aty = a[5]; + + let det = aa * ad - ab * ac; + if(!det){ + return null; + } + det = 1.0 / det; + + out[0] = ad * det; + out[1] = -ab * det; + out[2] = -ac * det; + out[3] = aa * det; + out[4] = (ac * aty - ad * atx) * det; + out[5] = (ab * atx - aa * aty) * det; + return out; +} + +/** + * Calculates the determinant of a mat2d + * + * @param {mat2d} a the source matrix + * @returns {Number} determinant of a + */ +export function determinant(a) { + return a[0] * a[3] - a[1] * a[2]; +} + +/** + * Multiplies two mat2d's + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the first operand + * @param {mat2d} b the second operand + * @returns {mat2d} out + */ +export function multiply(out, a, b) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5]; + out[0] = a0 * b0 + a2 * b1; + out[1] = a1 * b0 + a3 * b1; + out[2] = a0 * b2 + a2 * b3; + out[3] = a1 * b2 + a3 * b3; + out[4] = a0 * b4 + a2 * b5 + a4; + out[5] = a1 * b4 + a3 * b5 + a5; + return out; +} + +/** + * Rotates a mat2d by the given angle + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat2d} out + */ +export function rotate(out, a, rad) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; + let s = Math.sin(rad); + let c = Math.cos(rad); + out[0] = a0 * c + a2 * s; + out[1] = a1 * c + a3 * s; + out[2] = a0 * -s + a2 * c; + out[3] = a1 * -s + a3 * c; + out[4] = a4; + out[5] = a5; + return out; +} + +/** + * Scales the mat2d by the dimensions in the given vec2 + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the matrix to translate + * @param {vec2} v the vec2 to scale the matrix by + * @returns {mat2d} out + **/ +export function scale(out, a, v) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; + let v0 = v[0], v1 = v[1]; + out[0] = a0 * v0; + out[1] = a1 * v0; + out[2] = a2 * v1; + out[3] = a3 * v1; + out[4] = a4; + out[5] = a5; + return out; +} + +/** + * Translates the mat2d by the dimensions in the given vec2 + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the matrix to translate + * @param {vec2} v the vec2 to translate the matrix by + * @returns {mat2d} out + **/ +export function translate(out, a, v) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; + let v0 = v[0], v1 = v[1]; + out[0] = a0; + out[1] = a1; + out[2] = a2; + out[3] = a3; + out[4] = a0 * v0 + a2 * v1 + a4; + out[5] = a1 * v0 + a3 * v1 + a5; + return out; +} + +/** + * Creates a matrix from a given angle + * This is equivalent to (but much faster than): + * + * mat2d.identity(dest); + * mat2d.rotate(dest, dest, rad); + * + * @param {mat2d} out mat2d receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat2d} out + */ +export function fromRotation(out, rad) { + let s = Math.sin(rad), c = Math.cos(rad); + out[0] = c; + out[1] = s; + out[2] = -s; + out[3] = c; + out[4] = 0; + out[5] = 0; + return out; +} + +/** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat2d.identity(dest); + * mat2d.scale(dest, dest, vec); + * + * @param {mat2d} out mat2d receiving operation result + * @param {vec2} v Scaling vector + * @returns {mat2d} out + */ +export function fromScaling(out, v) { + out[0] = v[0]; + out[1] = 0; + out[2] = 0; + out[3] = v[1]; + out[4] = 0; + out[5] = 0; + return out; +} + +/** + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): + * + * mat2d.identity(dest); + * mat2d.translate(dest, dest, vec); + * + * @param {mat2d} out mat2d receiving operation result + * @param {vec2} v Translation vector + * @returns {mat2d} out + */ +export function fromTranslation(out, v) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = v[0]; + out[5] = v[1]; + return out; +} + +/** + * Returns a string representation of a mat2d + * + * @param {mat2d} a matrix to represent as a string + * @returns {String} string representation of the matrix + */ +export function str(a) { + return 'mat2d(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + + a[3] + ', ' + a[4] + ', ' + a[5] + ')'; +} + +/** + * Returns Frobenius norm of a mat2d + * + * @param {mat2d} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ +export function frob(a) { + return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + 1)) +} + +/** + * Adds two mat2d's + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the first operand + * @param {mat2d} b the second operand + * @returns {mat2d} out + */ +export function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + out[4] = a[4] + b[4]; + out[5] = a[5] + b[5]; + return out; +} + +/** + * Subtracts matrix b from matrix a + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the first operand + * @param {mat2d} b the second operand + * @returns {mat2d} out + */ +export function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; + out[4] = a[4] - b[4]; + out[5] = a[5] - b[5]; + return out; +} + +/** + * Multiply each element of the matrix by a scalar. + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {mat2d} out + */ +export function multiplyScalar(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + out[4] = a[4] * b; + out[5] = a[5] * b; + return out; +} + +/** + * Adds two mat2d's after multiplying each element of the second operand by a scalar value. + * + * @param {mat2d} out the receiving vector + * @param {mat2d} a the first operand + * @param {mat2d} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {mat2d} out + */ +export function multiplyScalarAndAdd(out, a, b, scale) { + out[0] = a[0] + (b[0] * scale); + out[1] = a[1] + (b[1] * scale); + out[2] = a[2] + (b[2] * scale); + out[3] = a[3] + (b[3] * scale); + out[4] = a[4] + (b[4] * scale); + out[5] = a[5] + (b[5] * scale); + return out; +} + +/** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {mat2d} a The first matrix. + * @param {mat2d} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ +export function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5]; +} + +/** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {mat2d} a The first matrix. + * @param {mat2d} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ +export function equals(a, b) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5]; + return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && + Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && + Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && + Math.abs(a3 - b3) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a3), Math.abs(b3)) && + Math.abs(a4 - b4) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a4), Math.abs(b4)) && + Math.abs(a5 - b5) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a5), Math.abs(b5))); +} + +/** + * Alias for {@link mat2d.multiply} + * @function + */ +export const mul = multiply; + +/** + * Alias for {@link mat2d.subtract} + * @function + */ +export const sub = subtract; diff --git a/js/third-party/gl-matrix/src/gl-matrix/mat3.js b/js/third-party/gl-matrix/src/gl-matrix/mat3.js new file mode 100644 index 000000000..47330c932 --- /dev/null +++ b/js/third-party/gl-matrix/src/gl-matrix/mat3.js @@ -0,0 +1,747 @@ +import * as glMatrix from "./common.js"; + +/** + * 3x3 Matrix + * @module mat3 + */ + +/** + * Creates a new identity mat3 + * + * @returns {mat3} a new 3x3 matrix + */ +export function create() { + let out = new glMatrix.ARRAY_TYPE(9); + if(glMatrix.ARRAY_TYPE != Float32Array) { + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; + } + out[0] = 1; + out[4] = 1; + out[8] = 1; + return out; +} + +/** + * Copies the upper-left 3x3 values into the given mat3. + * + * @param {mat3} out the receiving 3x3 matrix + * @param {mat4} a the source 4x4 matrix + * @returns {mat3} out + */ +export function fromMat4(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[4]; + out[4] = a[5]; + out[5] = a[6]; + out[6] = a[8]; + out[7] = a[9]; + out[8] = a[10]; + return out; +} + +/** + * Creates a new mat3 initialized with values from an existing matrix + * + * @param {mat3} a matrix to clone + * @returns {mat3} a new 3x3 matrix + */ +export function clone(a) { + let out = new glMatrix.ARRAY_TYPE(9); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + return out; +} + +/** + * Copy the values from one mat3 to another + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the source matrix + * @returns {mat3} out + */ +export function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + return out; +} + +/** + * Create a new mat3 with the given values + * + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m10 Component in column 1, row 0 position (index 3) + * @param {Number} m11 Component in column 1, row 1 position (index 4) + * @param {Number} m12 Component in column 1, row 2 position (index 5) + * @param {Number} m20 Component in column 2, row 0 position (index 6) + * @param {Number} m21 Component in column 2, row 1 position (index 7) + * @param {Number} m22 Component in column 2, row 2 position (index 8) + * @returns {mat3} A new mat3 + */ +export function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) { + let out = new glMatrix.ARRAY_TYPE(9); + out[0] = m00; + out[1] = m01; + out[2] = m02; + out[3] = m10; + out[4] = m11; + out[5] = m12; + out[6] = m20; + out[7] = m21; + out[8] = m22; + return out; +} + +/** + * Set the components of a mat3 to the given values + * + * @param {mat3} out the receiving matrix + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m10 Component in column 1, row 0 position (index 3) + * @param {Number} m11 Component in column 1, row 1 position (index 4) + * @param {Number} m12 Component in column 1, row 2 position (index 5) + * @param {Number} m20 Component in column 2, row 0 position (index 6) + * @param {Number} m21 Component in column 2, row 1 position (index 7) + * @param {Number} m22 Component in column 2, row 2 position (index 8) + * @returns {mat3} out + */ +export function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { + out[0] = m00; + out[1] = m01; + out[2] = m02; + out[3] = m10; + out[4] = m11; + out[5] = m12; + out[6] = m20; + out[7] = m21; + out[8] = m22; + return out; +} + +/** + * Set a mat3 to the identity matrix + * + * @param {mat3} out the receiving matrix + * @returns {mat3} out + */ +export function identity(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 1; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 1; + return out; +} + +/** + * Transpose the values of a mat3 + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the source matrix + * @returns {mat3} out + */ +export function transpose(out, a) { + // If we are transposing ourselves we can skip a few steps but have to cache some values + if (out === a) { + let a01 = a[1], a02 = a[2], a12 = a[5]; + out[1] = a[3]; + out[2] = a[6]; + out[3] = a01; + out[5] = a[7]; + out[6] = a02; + out[7] = a12; + } else { + out[0] = a[0]; + out[1] = a[3]; + out[2] = a[6]; + out[3] = a[1]; + out[4] = a[4]; + out[5] = a[7]; + out[6] = a[2]; + out[7] = a[5]; + out[8] = a[8]; + } + + return out; +} + +/** + * Inverts a mat3 + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the source matrix + * @returns {mat3} out + */ +export function invert(out, a) { + let a00 = a[0], a01 = a[1], a02 = a[2]; + let a10 = a[3], a11 = a[4], a12 = a[5]; + let a20 = a[6], a21 = a[7], a22 = a[8]; + + let b01 = a22 * a11 - a12 * a21; + let b11 = -a22 * a10 + a12 * a20; + let b21 = a21 * a10 - a11 * a20; + + // Calculate the determinant + let det = a00 * b01 + a01 * b11 + a02 * b21; + + if (!det) { + return null; + } + det = 1.0 / det; + + out[0] = b01 * det; + out[1] = (-a22 * a01 + a02 * a21) * det; + out[2] = (a12 * a01 - a02 * a11) * det; + out[3] = b11 * det; + out[4] = (a22 * a00 - a02 * a20) * det; + out[5] = (-a12 * a00 + a02 * a10) * det; + out[6] = b21 * det; + out[7] = (-a21 * a00 + a01 * a20) * det; + out[8] = (a11 * a00 - a01 * a10) * det; + return out; +} + +/** + * Calculates the adjugate of a mat3 + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the source matrix + * @returns {mat3} out + */ +export function adjoint(out, a) { + let a00 = a[0], a01 = a[1], a02 = a[2]; + let a10 = a[3], a11 = a[4], a12 = a[5]; + let a20 = a[6], a21 = a[7], a22 = a[8]; + + out[0] = (a11 * a22 - a12 * a21); + out[1] = (a02 * a21 - a01 * a22); + out[2] = (a01 * a12 - a02 * a11); + out[3] = (a12 * a20 - a10 * a22); + out[4] = (a00 * a22 - a02 * a20); + out[5] = (a02 * a10 - a00 * a12); + out[6] = (a10 * a21 - a11 * a20); + out[7] = (a01 * a20 - a00 * a21); + out[8] = (a00 * a11 - a01 * a10); + return out; +} + +/** + * Calculates the determinant of a mat3 + * + * @param {mat3} a the source matrix + * @returns {Number} determinant of a + */ +export function determinant(a) { + let a00 = a[0], a01 = a[1], a02 = a[2]; + let a10 = a[3], a11 = a[4], a12 = a[5]; + let a20 = a[6], a21 = a[7], a22 = a[8]; + + return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); +} + +/** + * Multiplies two mat3's + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the first operand + * @param {mat3} b the second operand + * @returns {mat3} out + */ +export function multiply(out, a, b) { + let a00 = a[0], a01 = a[1], a02 = a[2]; + let a10 = a[3], a11 = a[4], a12 = a[5]; + let a20 = a[6], a21 = a[7], a22 = a[8]; + + let b00 = b[0], b01 = b[1], b02 = b[2]; + let b10 = b[3], b11 = b[4], b12 = b[5]; + let b20 = b[6], b21 = b[7], b22 = b[8]; + + out[0] = b00 * a00 + b01 * a10 + b02 * a20; + out[1] = b00 * a01 + b01 * a11 + b02 * a21; + out[2] = b00 * a02 + b01 * a12 + b02 * a22; + + out[3] = b10 * a00 + b11 * a10 + b12 * a20; + out[4] = b10 * a01 + b11 * a11 + b12 * a21; + out[5] = b10 * a02 + b11 * a12 + b12 * a22; + + out[6] = b20 * a00 + b21 * a10 + b22 * a20; + out[7] = b20 * a01 + b21 * a11 + b22 * a21; + out[8] = b20 * a02 + b21 * a12 + b22 * a22; + return out; +} + +/** + * Translate a mat3 by the given vector + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the matrix to translate + * @param {vec2} v vector to translate by + * @returns {mat3} out + */ +export function translate(out, a, v) { + let a00 = a[0], a01 = a[1], a02 = a[2], + a10 = a[3], a11 = a[4], a12 = a[5], + a20 = a[6], a21 = a[7], a22 = a[8], + x = v[0], y = v[1]; + + out[0] = a00; + out[1] = a01; + out[2] = a02; + + out[3] = a10; + out[4] = a11; + out[5] = a12; + + out[6] = x * a00 + y * a10 + a20; + out[7] = x * a01 + y * a11 + a21; + out[8] = x * a02 + y * a12 + a22; + return out; +} + +/** + * Rotates a mat3 by the given angle + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat3} out + */ +export function rotate(out, a, rad) { + let a00 = a[0], a01 = a[1], a02 = a[2], + a10 = a[3], a11 = a[4], a12 = a[5], + a20 = a[6], a21 = a[7], a22 = a[8], + + s = Math.sin(rad), + c = Math.cos(rad); + + out[0] = c * a00 + s * a10; + out[1] = c * a01 + s * a11; + out[2] = c * a02 + s * a12; + + out[3] = c * a10 - s * a00; + out[4] = c * a11 - s * a01; + out[5] = c * a12 - s * a02; + + out[6] = a20; + out[7] = a21; + out[8] = a22; + return out; +}; + +/** + * Scales the mat3 by the dimensions in the given vec2 + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the matrix to rotate + * @param {vec2} v the vec2 to scale the matrix by + * @returns {mat3} out + **/ +export function scale(out, a, v) { + let x = v[0], y = v[1]; + + out[0] = x * a[0]; + out[1] = x * a[1]; + out[2] = x * a[2]; + + out[3] = y * a[3]; + out[4] = y * a[4]; + out[5] = y * a[5]; + + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + return out; +} + +/** + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.translate(dest, dest, vec); + * + * @param {mat3} out mat3 receiving operation result + * @param {vec2} v Translation vector + * @returns {mat3} out + */ +export function fromTranslation(out, v) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 1; + out[5] = 0; + out[6] = v[0]; + out[7] = v[1]; + out[8] = 1; + return out; +} + +/** + * Creates a matrix from a given angle + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.rotate(dest, dest, rad); + * + * @param {mat3} out mat3 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat3} out + */ +export function fromRotation(out, rad) { + let s = Math.sin(rad), c = Math.cos(rad); + + out[0] = c; + out[1] = s; + out[2] = 0; + + out[3] = -s; + out[4] = c; + out[5] = 0; + + out[6] = 0; + out[7] = 0; + out[8] = 1; + return out; +} + +/** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.scale(dest, dest, vec); + * + * @param {mat3} out mat3 receiving operation result + * @param {vec2} v Scaling vector + * @returns {mat3} out + */ +export function fromScaling(out, v) { + out[0] = v[0]; + out[1] = 0; + out[2] = 0; + + out[3] = 0; + out[4] = v[1]; + out[5] = 0; + + out[6] = 0; + out[7] = 0; + out[8] = 1; + return out; +} + +/** + * Copies the values from a mat2d into a mat3 + * + * @param {mat3} out the receiving matrix + * @param {mat2d} a the matrix to copy + * @returns {mat3} out + **/ +export function fromMat2d(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = 0; + + out[3] = a[2]; + out[4] = a[3]; + out[5] = 0; + + out[6] = a[4]; + out[7] = a[5]; + out[8] = 1; + return out; +} + +/** +* Calculates a 3x3 matrix from the given quaternion +* +* @param {mat3} out mat3 receiving operation result +* @param {quat} q Quaternion to create matrix from +* +* @returns {mat3} out +*/ +export function fromQuat(out, q) { + let x = q[0], y = q[1], z = q[2], w = q[3]; + let x2 = x + x; + let y2 = y + y; + let z2 = z + z; + + let xx = x * x2; + let yx = y * x2; + let yy = y * y2; + let zx = z * x2; + let zy = z * y2; + let zz = z * z2; + let wx = w * x2; + let wy = w * y2; + let wz = w * z2; + + out[0] = 1 - yy - zz; + out[3] = yx - wz; + out[6] = zx + wy; + + out[1] = yx + wz; + out[4] = 1 - xx - zz; + out[7] = zy - wx; + + out[2] = zx - wy; + out[5] = zy + wx; + out[8] = 1 - xx - yy; + + return out; +} + +/** +* Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix +* +* @param {mat3} out mat3 receiving operation result +* @param {mat4} a Mat4 to derive the normal matrix from +* +* @returns {mat3} out +*/ +export function normalFromMat4(out, a) { + let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + + let b00 = a00 * a11 - a01 * a10; + let b01 = a00 * a12 - a02 * a10; + let b02 = a00 * a13 - a03 * a10; + let b03 = a01 * a12 - a02 * a11; + let b04 = a01 * a13 - a03 * a11; + let b05 = a02 * a13 - a03 * a12; + let b06 = a20 * a31 - a21 * a30; + let b07 = a20 * a32 - a22 * a30; + let b08 = a20 * a33 - a23 * a30; + let b09 = a21 * a32 - a22 * a31; + let b10 = a21 * a33 - a23 * a31; + let b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) { + return null; + } + det = 1.0 / det; + + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + + out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + + out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + + return out; +} + +/** + * Generates a 2D projection matrix with the given bounds + * + * @param {mat3} out mat3 frustum matrix will be written into + * @param {number} width Width of your gl context + * @param {number} height Height of gl context + * @returns {mat3} out + */ +export function projection(out, width, height) { + out[0] = 2 / width; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = -2 / height; + out[5] = 0; + out[6] = -1; + out[7] = 1; + out[8] = 1; + return out; +} + +/** + * Returns a string representation of a mat3 + * + * @param {mat3} a matrix to represent as a string + * @returns {String} string representation of the matrix + */ +export function str(a) { + return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + + a[6] + ', ' + a[7] + ', ' + a[8] + ')'; +} + +/** + * Returns Frobenius norm of a mat3 + * + * @param {mat3} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ +export function frob(a) { + return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2))) +} + +/** + * Adds two mat3's + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the first operand + * @param {mat3} b the second operand + * @returns {mat3} out + */ +export function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + out[4] = a[4] + b[4]; + out[5] = a[5] + b[5]; + out[6] = a[6] + b[6]; + out[7] = a[7] + b[7]; + out[8] = a[8] + b[8]; + return out; +} + +/** + * Subtracts matrix b from matrix a + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the first operand + * @param {mat3} b the second operand + * @returns {mat3} out + */ +export function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; + out[4] = a[4] - b[4]; + out[5] = a[5] - b[5]; + out[6] = a[6] - b[6]; + out[7] = a[7] - b[7]; + out[8] = a[8] - b[8]; + return out; +} + + + +/** + * Multiply each element of the matrix by a scalar. + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {mat3} out + */ +export function multiplyScalar(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + out[4] = a[4] * b; + out[5] = a[5] * b; + out[6] = a[6] * b; + out[7] = a[7] * b; + out[8] = a[8] * b; + return out; +} + +/** + * Adds two mat3's after multiplying each element of the second operand by a scalar value. + * + * @param {mat3} out the receiving vector + * @param {mat3} a the first operand + * @param {mat3} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {mat3} out + */ +export function multiplyScalarAndAdd(out, a, b, scale) { + out[0] = a[0] + (b[0] * scale); + out[1] = a[1] + (b[1] * scale); + out[2] = a[2] + (b[2] * scale); + out[3] = a[3] + (b[3] * scale); + out[4] = a[4] + (b[4] * scale); + out[5] = a[5] + (b[5] * scale); + out[6] = a[6] + (b[6] * scale); + out[7] = a[7] + (b[7] * scale); + out[8] = a[8] + (b[8] * scale); + return out; +} + +/** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {mat3} a The first matrix. + * @param {mat3} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ +export function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && + a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && + a[6] === b[6] && a[7] === b[7] && a[8] === b[8]; +} + +/** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {mat3} a The first matrix. + * @param {mat3} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ +export function equals(a, b) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7], a8 = a[8]; + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8]; + return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && + Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && + Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && + Math.abs(a3 - b3) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a3), Math.abs(b3)) && + Math.abs(a4 - b4) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a4), Math.abs(b4)) && + Math.abs(a5 - b5) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a5), Math.abs(b5)) && + Math.abs(a6 - b6) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a6), Math.abs(b6)) && + Math.abs(a7 - b7) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a7), Math.abs(b7)) && + Math.abs(a8 - b8) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a8), Math.abs(b8))); +} + +/** + * Alias for {@link mat3.multiply} + * @function + */ +export const mul = multiply; + +/** + * Alias for {@link mat3.subtract} + * @function + */ +export const sub = subtract; diff --git a/js/third-party/gl-matrix/src/gl-matrix/mat4.js b/js/third-party/gl-matrix/src/gl-matrix/mat4.js new file mode 100644 index 000000000..6d60372d6 --- /dev/null +++ b/js/third-party/gl-matrix/src/gl-matrix/mat4.js @@ -0,0 +1,1715 @@ +import * as glMatrix from "./common.js"; + +/** + * 4x4 Matrix
Format: column-major, when typed out it looks like row-major
The matrices are being post multiplied. + * @module mat4 + */ + +/** + * Creates a new identity mat4 + * + * @returns {mat4} a new 4x4 matrix + */ +export function create() { + let out = new glMatrix.ARRAY_TYPE(16); + if(glMatrix.ARRAY_TYPE != Float32Array) { + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + } + out[0] = 1; + out[5] = 1; + out[10] = 1; + out[15] = 1; + return out; +} + +/** + * Creates a new mat4 initialized with values from an existing matrix + * + * @param {mat4} a matrix to clone + * @returns {mat4} a new 4x4 matrix + */ +export function clone(a) { + let out = new glMatrix.ARRAY_TYPE(16); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + return out; +} + +/** + * Copy the values from one mat4 to another + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the source matrix + * @returns {mat4} out + */ +export function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + return out; +} + +/** + * Create a new mat4 with the given values + * + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m03 Component in column 0, row 3 position (index 3) + * @param {Number} m10 Component in column 1, row 0 position (index 4) + * @param {Number} m11 Component in column 1, row 1 position (index 5) + * @param {Number} m12 Component in column 1, row 2 position (index 6) + * @param {Number} m13 Component in column 1, row 3 position (index 7) + * @param {Number} m20 Component in column 2, row 0 position (index 8) + * @param {Number} m21 Component in column 2, row 1 position (index 9) + * @param {Number} m22 Component in column 2, row 2 position (index 10) + * @param {Number} m23 Component in column 2, row 3 position (index 11) + * @param {Number} m30 Component in column 3, row 0 position (index 12) + * @param {Number} m31 Component in column 3, row 1 position (index 13) + * @param {Number} m32 Component in column 3, row 2 position (index 14) + * @param {Number} m33 Component in column 3, row 3 position (index 15) + * @returns {mat4} A new mat4 + */ +export function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { + let out = new glMatrix.ARRAY_TYPE(16); + out[0] = m00; + out[1] = m01; + out[2] = m02; + out[3] = m03; + out[4] = m10; + out[5] = m11; + out[6] = m12; + out[7] = m13; + out[8] = m20; + out[9] = m21; + out[10] = m22; + out[11] = m23; + out[12] = m30; + out[13] = m31; + out[14] = m32; + out[15] = m33; + return out; +} + +/** + * Set the components of a mat4 to the given values + * + * @param {mat4} out the receiving matrix + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m03 Component in column 0, row 3 position (index 3) + * @param {Number} m10 Component in column 1, row 0 position (index 4) + * @param {Number} m11 Component in column 1, row 1 position (index 5) + * @param {Number} m12 Component in column 1, row 2 position (index 6) + * @param {Number} m13 Component in column 1, row 3 position (index 7) + * @param {Number} m20 Component in column 2, row 0 position (index 8) + * @param {Number} m21 Component in column 2, row 1 position (index 9) + * @param {Number} m22 Component in column 2, row 2 position (index 10) + * @param {Number} m23 Component in column 2, row 3 position (index 11) + * @param {Number} m30 Component in column 3, row 0 position (index 12) + * @param {Number} m31 Component in column 3, row 1 position (index 13) + * @param {Number} m32 Component in column 3, row 2 position (index 14) + * @param {Number} m33 Component in column 3, row 3 position (index 15) + * @returns {mat4} out + */ +export function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { + out[0] = m00; + out[1] = m01; + out[2] = m02; + out[3] = m03; + out[4] = m10; + out[5] = m11; + out[6] = m12; + out[7] = m13; + out[8] = m20; + out[9] = m21; + out[10] = m22; + out[11] = m23; + out[12] = m30; + out[13] = m31; + out[14] = m32; + out[15] = m33; + return out; +} + + +/** + * Set a mat4 to the identity matrix + * + * @param {mat4} out the receiving matrix + * @returns {mat4} out + */ +export function identity(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} + +/** + * Transpose the values of a mat4 + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the source matrix + * @returns {mat4} out + */ +export function transpose(out, a) { + // If we are transposing ourselves we can skip a few steps but have to cache some values + if (out === a) { + let a01 = a[1], a02 = a[2], a03 = a[3]; + let a12 = a[6], a13 = a[7]; + let a23 = a[11]; + + out[1] = a[4]; + out[2] = a[8]; + out[3] = a[12]; + out[4] = a01; + out[6] = a[9]; + out[7] = a[13]; + out[8] = a02; + out[9] = a12; + out[11] = a[14]; + out[12] = a03; + out[13] = a13; + out[14] = a23; + } else { + out[0] = a[0]; + out[1] = a[4]; + out[2] = a[8]; + out[3] = a[12]; + out[4] = a[1]; + out[5] = a[5]; + out[6] = a[9]; + out[7] = a[13]; + out[8] = a[2]; + out[9] = a[6]; + out[10] = a[10]; + out[11] = a[14]; + out[12] = a[3]; + out[13] = a[7]; + out[14] = a[11]; + out[15] = a[15]; + } + + return out; +} + +/** + * Inverts a mat4 + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the source matrix + * @returns {mat4} out + */ +export function invert(out, a) { + let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + + let b00 = a00 * a11 - a01 * a10; + let b01 = a00 * a12 - a02 * a10; + let b02 = a00 * a13 - a03 * a10; + let b03 = a01 * a12 - a02 * a11; + let b04 = a01 * a13 - a03 * a11; + let b05 = a02 * a13 - a03 * a12; + let b06 = a20 * a31 - a21 * a30; + let b07 = a20 * a32 - a22 * a30; + let b08 = a20 * a33 - a23 * a30; + let b09 = a21 * a32 - a22 * a31; + let b10 = a21 * a33 - a23 * a31; + let b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) { + return null; + } + det = 1.0 / det; + + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; + out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; + out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; + out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; + out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; + out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; + out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; + + return out; +} + +/** + * Calculates the adjugate of a mat4 + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the source matrix + * @returns {mat4} out + */ +export function adjoint(out, a) { + let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + + out[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22)); + out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); + out[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12)); + out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); + out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); + out[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22)); + out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); + out[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12)); + out[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21)); + out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); + out[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11)); + out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); + out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); + out[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21)); + out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); + out[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); + return out; +} + +/** + * Calculates the determinant of a mat4 + * + * @param {mat4} a the source matrix + * @returns {Number} determinant of a + */ +export function determinant(a) { + let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + + let b00 = a00 * a11 - a01 * a10; + let b01 = a00 * a12 - a02 * a10; + let b02 = a00 * a13 - a03 * a10; + let b03 = a01 * a12 - a02 * a11; + let b04 = a01 * a13 - a03 * a11; + let b05 = a02 * a13 - a03 * a12; + let b06 = a20 * a31 - a21 * a30; + let b07 = a20 * a32 - a22 * a30; + let b08 = a20 * a33 - a23 * a30; + let b09 = a21 * a32 - a22 * a31; + let b10 = a21 * a33 - a23 * a31; + let b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; +} + +/** + * Multiplies two mat4s + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the first operand + * @param {mat4} b the second operand + * @returns {mat4} out + */ +export function multiply(out, a, b) { + let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + + // Cache only the current line of the second matrix + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + out[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[3] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + + b0 = b[4]; b1 = b[5]; b2 = b[6]; b3 = b[7]; + out[4] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[5] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[6] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[7] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + + b0 = b[8]; b1 = b[9]; b2 = b[10]; b3 = b[11]; + out[8] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[9] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[10] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[11] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + + b0 = b[12]; b1 = b[13]; b2 = b[14]; b3 = b[15]; + out[12] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[13] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[14] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + return out; +} + +/** + * Translate a mat4 by the given vector + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to translate + * @param {vec3} v vector to translate by + * @returns {mat4} out + */ +export function translate(out, a, v) { + let x = v[0], y = v[1], z = v[2]; + let a00, a01, a02, a03; + let a10, a11, a12, a13; + let a20, a21, a22, a23; + + if (a === out) { + out[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; + out[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; + out[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; + out[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; + } else { + a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3]; + a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7]; + a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11]; + + out[0] = a00; out[1] = a01; out[2] = a02; out[3] = a03; + out[4] = a10; out[5] = a11; out[6] = a12; out[7] = a13; + out[8] = a20; out[9] = a21; out[10] = a22; out[11] = a23; + + out[12] = a00 * x + a10 * y + a20 * z + a[12]; + out[13] = a01 * x + a11 * y + a21 * z + a[13]; + out[14] = a02 * x + a12 * y + a22 * z + a[14]; + out[15] = a03 * x + a13 * y + a23 * z + a[15]; + } + + return out; +} + +/** + * Scales the mat4 by the dimensions in the given vec3 not using vectorization + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to scale + * @param {vec3} v the vec3 to scale the matrix by + * @returns {mat4} out + **/ +export function scale(out, a, v) { + let x = v[0], y = v[1], z = v[2]; + + out[0] = a[0] * x; + out[1] = a[1] * x; + out[2] = a[2] * x; + out[3] = a[3] * x; + out[4] = a[4] * y; + out[5] = a[5] * y; + out[6] = a[6] * y; + out[7] = a[7] * y; + out[8] = a[8] * z; + out[9] = a[9] * z; + out[10] = a[10] * z; + out[11] = a[11] * z; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + return out; +} + +/** + * Rotates a mat4 by the given angle around the given axis + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @param {vec3} axis the axis to rotate around + * @returns {mat4} out + */ +export function rotate(out, a, rad, axis) { + let x = axis[0], y = axis[1], z = axis[2]; + let len = Math.sqrt(x * x + y * y + z * z); + let s, c, t; + let a00, a01, a02, a03; + let a10, a11, a12, a13; + let a20, a21, a22, a23; + let b00, b01, b02; + let b10, b11, b12; + let b20, b21, b22; + + if (len < glMatrix.EPSILON) { return null; } + + len = 1 / len; + x *= len; + y *= len; + z *= len; + + s = Math.sin(rad); + c = Math.cos(rad); + t = 1 - c; + + a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3]; + a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7]; + a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11]; + + // Construct the elements of the rotation matrix + b00 = x * x * t + c; b01 = y * x * t + z * s; b02 = z * x * t - y * s; + b10 = x * y * t - z * s; b11 = y * y * t + c; b12 = z * y * t + x * s; + b20 = x * z * t + y * s; b21 = y * z * t - x * s; b22 = z * z * t + c; + + // Perform rotation-specific matrix multiplication + out[0] = a00 * b00 + a10 * b01 + a20 * b02; + out[1] = a01 * b00 + a11 * b01 + a21 * b02; + out[2] = a02 * b00 + a12 * b01 + a22 * b02; + out[3] = a03 * b00 + a13 * b01 + a23 * b02; + out[4] = a00 * b10 + a10 * b11 + a20 * b12; + out[5] = a01 * b10 + a11 * b11 + a21 * b12; + out[6] = a02 * b10 + a12 * b11 + a22 * b12; + out[7] = a03 * b10 + a13 * b11 + a23 * b12; + out[8] = a00 * b20 + a10 * b21 + a20 * b22; + out[9] = a01 * b20 + a11 * b21 + a21 * b22; + out[10] = a02 * b20 + a12 * b21 + a22 * b22; + out[11] = a03 * b20 + a13 * b21 + a23 * b22; + + if (a !== out) { // If the source and destination differ, copy the unchanged last row + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } + return out; +} + +/** + * Rotates a matrix by the given angle around the X axis + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ +export function rotateX(out, a, rad) { + let s = Math.sin(rad); + let c = Math.cos(rad); + let a10 = a[4]; + let a11 = a[5]; + let a12 = a[6]; + let a13 = a[7]; + let a20 = a[8]; + let a21 = a[9]; + let a22 = a[10]; + let a23 = a[11]; + + if (a !== out) { // If the source and destination differ, copy the unchanged rows + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } + + // Perform axis-specific matrix multiplication + out[4] = a10 * c + a20 * s; + out[5] = a11 * c + a21 * s; + out[6] = a12 * c + a22 * s; + out[7] = a13 * c + a23 * s; + out[8] = a20 * c - a10 * s; + out[9] = a21 * c - a11 * s; + out[10] = a22 * c - a12 * s; + out[11] = a23 * c - a13 * s; + return out; +} + +/** + * Rotates a matrix by the given angle around the Y axis + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ +export function rotateY(out, a, rad) { + let s = Math.sin(rad); + let c = Math.cos(rad); + let a00 = a[0]; + let a01 = a[1]; + let a02 = a[2]; + let a03 = a[3]; + let a20 = a[8]; + let a21 = a[9]; + let a22 = a[10]; + let a23 = a[11]; + + if (a !== out) { // If the source and destination differ, copy the unchanged rows + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } + + // Perform axis-specific matrix multiplication + out[0] = a00 * c - a20 * s; + out[1] = a01 * c - a21 * s; + out[2] = a02 * c - a22 * s; + out[3] = a03 * c - a23 * s; + out[8] = a00 * s + a20 * c; + out[9] = a01 * s + a21 * c; + out[10] = a02 * s + a22 * c; + out[11] = a03 * s + a23 * c; + return out; +} + +/** + * Rotates a matrix by the given angle around the Z axis + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ +export function rotateZ(out, a, rad) { + let s = Math.sin(rad); + let c = Math.cos(rad); + let a00 = a[0]; + let a01 = a[1]; + let a02 = a[2]; + let a03 = a[3]; + let a10 = a[4]; + let a11 = a[5]; + let a12 = a[6]; + let a13 = a[7]; + + if (a !== out) { // If the source and destination differ, copy the unchanged last row + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } + + // Perform axis-specific matrix multiplication + out[0] = a00 * c + a10 * s; + out[1] = a01 * c + a11 * s; + out[2] = a02 * c + a12 * s; + out[3] = a03 * c + a13 * s; + out[4] = a10 * c - a00 * s; + out[5] = a11 * c - a01 * s; + out[6] = a12 * c - a02 * s; + out[7] = a13 * c - a03 * s; + return out; +} + +/** + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, dest, vec); + * + * @param {mat4} out mat4 receiving operation result + * @param {vec3} v Translation vector + * @returns {mat4} out + */ +export function fromTranslation(out, v) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = v[0]; + out[13] = v[1]; + out[14] = v[2]; + out[15] = 1; + return out; +} + +/** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.scale(dest, dest, vec); + * + * @param {mat4} out mat4 receiving operation result + * @param {vec3} v Scaling vector + * @returns {mat4} out + */ +export function fromScaling(out, v) { + out[0] = v[0]; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = v[1]; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = v[2]; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} + +/** + * Creates a matrix from a given angle around a given axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotate(dest, dest, rad, axis); + * + * @param {mat4} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @param {vec3} axis the axis to rotate around + * @returns {mat4} out + */ +export function fromRotation(out, rad, axis) { + let x = axis[0], y = axis[1], z = axis[2]; + let len = Math.sqrt(x * x + y * y + z * z); + let s, c, t; + + if (len < glMatrix.EPSILON) { return null; } + + len = 1 / len; + x *= len; + y *= len; + z *= len; + + s = Math.sin(rad); + c = Math.cos(rad); + t = 1 - c; + + // Perform rotation-specific matrix multiplication + out[0] = x * x * t + c; + out[1] = y * x * t + z * s; + out[2] = z * x * t - y * s; + out[3] = 0; + out[4] = x * y * t - z * s; + out[5] = y * y * t + c; + out[6] = z * y * t + x * s; + out[7] = 0; + out[8] = x * z * t + y * s; + out[9] = y * z * t - x * s; + out[10] = z * z * t + c; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} + +/** + * Creates a matrix from the given angle around the X axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotateX(dest, dest, rad); + * + * @param {mat4} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ +export function fromXRotation(out, rad) { + let s = Math.sin(rad); + let c = Math.cos(rad); + + // Perform axis-specific matrix multiplication + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = c; + out[6] = s; + out[7] = 0; + out[8] = 0; + out[9] = -s; + out[10] = c; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} + +/** + * Creates a matrix from the given angle around the Y axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotateY(dest, dest, rad); + * + * @param {mat4} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ +export function fromYRotation(out, rad) { + let s = Math.sin(rad); + let c = Math.cos(rad); + + // Perform axis-specific matrix multiplication + out[0] = c; + out[1] = 0; + out[2] = -s; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = s; + out[9] = 0; + out[10] = c; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} + +/** + * Creates a matrix from the given angle around the Z axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotateZ(dest, dest, rad); + * + * @param {mat4} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ +export function fromZRotation(out, rad) { + let s = Math.sin(rad); + let c = Math.cos(rad); + + // Perform axis-specific matrix multiplication + out[0] = c; + out[1] = s; + out[2] = 0; + out[3] = 0; + out[4] = -s; + out[5] = c; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} + +/** + * Creates a matrix from a quaternion rotation and vector translation + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, vec); + * let quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); + * + * @param {mat4} out mat4 receiving operation result + * @param {quat4} q Rotation quaternion + * @param {vec3} v Translation vector + * @returns {mat4} out + */ +export function fromRotationTranslation(out, q, v) { + // Quaternion math + let x = q[0], y = q[1], z = q[2], w = q[3]; + let x2 = x + x; + let y2 = y + y; + let z2 = z + z; + + let xx = x * x2; + let xy = x * y2; + let xz = x * z2; + let yy = y * y2; + let yz = y * z2; + let zz = z * z2; + let wx = w * x2; + let wy = w * y2; + let wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + out[12] = v[0]; + out[13] = v[1]; + out[14] = v[2]; + out[15] = 1; + + return out; +} + +/** + * Creates a new mat4 from a dual quat. + * + * @param {mat4} out Matrix + * @param {quat2} a Dual Quaternion + * @returns {mat4} mat4 receiving operation result + */ +export function fromQuat2(out, a) { + let translation = new glMatrix.ARRAY_TYPE(3); + let bx = -a[0], by = -a[1], bz = -a[2], bw = a[3], + ax = a[4], ay = a[5], az = a[6], aw = a[7]; + + let magnitude = bx * bx + by * by + bz * bz + bw * bw; + //Only scale if it makes sense + if (magnitude > 0) { + translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude; + translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude; + translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude; + } else { + translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2; + translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2; + translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2; + } + fromRotationTranslation(out, a, translation); + return out; +} + +/** + * Returns the translation vector component of a transformation + * matrix. If a matrix is built with fromRotationTranslation, + * the returned vector will be the same as the translation vector + * originally supplied. + * @param {vec3} out Vector to receive translation component + * @param {mat4} mat Matrix to be decomposed (input) + * @return {vec3} out + */ +export function getTranslation(out, mat) { + out[0] = mat[12]; + out[1] = mat[13]; + out[2] = mat[14]; + + return out; +} + +/** + * Returns the scaling factor component of a transformation + * matrix. If a matrix is built with fromRotationTranslationScale + * with a normalized Quaternion paramter, the returned vector will be + * the same as the scaling vector + * originally supplied. + * @param {vec3} out Vector to receive scaling factor component + * @param {mat4} mat Matrix to be decomposed (input) + * @return {vec3} out + */ +export function getScaling(out, mat) { + let m11 = mat[0]; + let m12 = mat[1]; + let m13 = mat[2]; + let m21 = mat[4]; + let m22 = mat[5]; + let m23 = mat[6]; + let m31 = mat[8]; + let m32 = mat[9]; + let m33 = mat[10]; + + out[0] = Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13); + out[1] = Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23); + out[2] = Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33); + + return out; +} + +/** + * Returns a quaternion representing the rotational component + * of a transformation matrix. If a matrix is built with + * fromRotationTranslation, the returned quaternion will be the + * same as the quaternion originally supplied. + * @param {quat} out Quaternion to receive the rotation component + * @param {mat4} mat Matrix to be decomposed (input) + * @return {quat} out + */ +export function getRotation(out, mat) { + // Algorithm taken from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm + let trace = mat[0] + mat[5] + mat[10]; + let S = 0; + + if (trace > 0) { + S = Math.sqrt(trace + 1.0) * 2; + out[3] = 0.25 * S; + out[0] = (mat[6] - mat[9]) / S; + out[1] = (mat[8] - mat[2]) / S; + out[2] = (mat[1] - mat[4]) / S; + } else if ((mat[0] > mat[5]) && (mat[0] > mat[10])) { + S = Math.sqrt(1.0 + mat[0] - mat[5] - mat[10]) * 2; + out[3] = (mat[6] - mat[9]) / S; + out[0] = 0.25 * S; + out[1] = (mat[1] + mat[4]) / S; + out[2] = (mat[8] + mat[2]) / S; + } else if (mat[5] > mat[10]) { + S = Math.sqrt(1.0 + mat[5] - mat[0] - mat[10]) * 2; + out[3] = (mat[8] - mat[2]) / S; + out[0] = (mat[1] + mat[4]) / S; + out[1] = 0.25 * S; + out[2] = (mat[6] + mat[9]) / S; + } else { + S = Math.sqrt(1.0 + mat[10] - mat[0] - mat[5]) * 2; + out[3] = (mat[1] - mat[4]) / S; + out[0] = (mat[8] + mat[2]) / S; + out[1] = (mat[6] + mat[9]) / S; + out[2] = 0.25 * S; + } + + return out; +} + +/** + * Creates a matrix from a quaternion rotation, vector translation and vector scale + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, vec); + * let quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); + * mat4.scale(dest, scale) + * + * @param {mat4} out mat4 receiving operation result + * @param {quat4} q Rotation quaternion + * @param {vec3} v Translation vector + * @param {vec3} s Scaling vector + * @returns {mat4} out + */ +export function fromRotationTranslationScale(out, q, v, s) { + // Quaternion math + let x = q[0], y = q[1], z = q[2], w = q[3]; + let x2 = x + x; + let y2 = y + y; + let z2 = z + z; + + let xx = x * x2; + let xy = x * y2; + let xz = x * z2; + let yy = y * y2; + let yz = y * z2; + let zz = z * z2; + let wx = w * x2; + let wy = w * y2; + let wz = w * z2; + let sx = s[0]; + let sy = s[1]; + let sz = s[2]; + + out[0] = (1 - (yy + zz)) * sx; + out[1] = (xy + wz) * sx; + out[2] = (xz - wy) * sx; + out[3] = 0; + out[4] = (xy - wz) * sy; + out[5] = (1 - (xx + zz)) * sy; + out[6] = (yz + wx) * sy; + out[7] = 0; + out[8] = (xz + wy) * sz; + out[9] = (yz - wx) * sz; + out[10] = (1 - (xx + yy)) * sz; + out[11] = 0; + out[12] = v[0]; + out[13] = v[1]; + out[14] = v[2]; + out[15] = 1; + + return out; +} + +/** + * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, vec); + * mat4.translate(dest, origin); + * let quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); + * mat4.scale(dest, scale) + * mat4.translate(dest, negativeOrigin); + * + * @param {mat4} out mat4 receiving operation result + * @param {quat4} q Rotation quaternion + * @param {vec3} v Translation vector + * @param {vec3} s Scaling vector + * @param {vec3} o The origin vector around which to scale and rotate + * @returns {mat4} out + */ +export function fromRotationTranslationScaleOrigin(out, q, v, s, o) { + // Quaternion math + let x = q[0], y = q[1], z = q[2], w = q[3]; + let x2 = x + x; + let y2 = y + y; + let z2 = z + z; + + let xx = x * x2; + let xy = x * y2; + let xz = x * z2; + let yy = y * y2; + let yz = y * z2; + let zz = z * z2; + let wx = w * x2; + let wy = w * y2; + let wz = w * z2; + + let sx = s[0]; + let sy = s[1]; + let sz = s[2]; + + let ox = o[0]; + let oy = o[1]; + let oz = o[2]; + + let out0 = (1 - (yy + zz)) * sx; + let out1 = (xy + wz) * sx; + let out2 = (xz - wy) * sx; + let out4 = (xy - wz) * sy; + let out5 = (1 - (xx + zz)) * sy; + let out6 = (yz + wx) * sy; + let out8 = (xz + wy) * sz; + let out9 = (yz - wx) * sz; + let out10 = (1 - (xx + yy)) * sz; + + out[0] = out0; + out[1] = out1; + out[2] = out2; + out[3] = 0; + out[4] = out4; + out[5] = out5; + out[6] = out6; + out[7] = 0; + out[8] = out8; + out[9] = out9; + out[10] = out10; + out[11] = 0; + out[12] = v[0] + ox - (out0 * ox + out4 * oy + out8 * oz); + out[13] = v[1] + oy - (out1 * ox + out5 * oy + out9 * oz); + out[14] = v[2] + oz - (out2 * ox + out6 * oy + out10 * oz); + out[15] = 1; + + return out; +} + +/** + * Calculates a 4x4 matrix from the given quaternion + * + * @param {mat4} out mat4 receiving operation result + * @param {quat} q Quaternion to create matrix from + * + * @returns {mat4} out + */ +export function fromQuat(out, q) { + let x = q[0], y = q[1], z = q[2], w = q[3]; + let x2 = x + x; + let y2 = y + y; + let z2 = z + z; + + let xx = x * x2; + let yx = y * x2; + let yy = y * y2; + let zx = z * x2; + let zy = z * y2; + let zz = z * z2; + let wx = w * x2; + let wy = w * y2; + let wz = w * z2; + + out[0] = 1 - yy - zz; + out[1] = yx + wz; + out[2] = zx - wy; + out[3] = 0; + + out[4] = yx - wz; + out[5] = 1 - xx - zz; + out[6] = zy + wx; + out[7] = 0; + + out[8] = zx + wy; + out[9] = zy - wx; + out[10] = 1 - xx - yy; + out[11] = 0; + + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return out; +} + +/** + * Generates a frustum matrix with the given bounds + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {Number} left Left bound of the frustum + * @param {Number} right Right bound of the frustum + * @param {Number} bottom Bottom bound of the frustum + * @param {Number} top Top bound of the frustum + * @param {Number} near Near bound of the frustum + * @param {Number} far Far bound of the frustum + * @returns {mat4} out + */ +export function frustum(out, left, right, bottom, top, near, far) { + let rl = 1 / (right - left); + let tb = 1 / (top - bottom); + let nf = 1 / (near - far); + out[0] = (near * 2) * rl; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = (near * 2) * tb; + out[6] = 0; + out[7] = 0; + out[8] = (right + left) * rl; + out[9] = (top + bottom) * tb; + out[10] = (far + near) * nf; + out[11] = -1; + out[12] = 0; + out[13] = 0; + out[14] = (far * near * 2) * nf; + out[15] = 0; + return out; +} + +/** + * Generates a perspective projection matrix with the given bounds. + * Passing null/undefined/no value for far will generate infinite projection matrix. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} fovy Vertical field of view in radians + * @param {number} aspect Aspect ratio. typically viewport width/height + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum, can be null or Infinity + * @returns {mat4} out + */ +export function perspective(out, fovy, aspect, near, far) { + let f = 1.0 / Math.tan(fovy / 2), nf; + out[0] = f / aspect; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = f; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[11] = -1; + out[12] = 0; + out[13] = 0; + out[15] = 0; + if (far != null && far !== Infinity) { + nf = 1 / (near - far); + out[10] = (far + near) * nf; + out[14] = (2 * far * near) * nf; + } else { + out[10] = -1; + out[14] = -2 * near; + } + return out; +} + +/** + * Generates a perspective projection matrix with the given field of view. + * This is primarily useful for generating projection matrices to be used + * with the still experiemental WebVR API. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {mat4} out + */ +export function perspectiveFromFieldOfView(out, fov, near, far) { + let upTan = Math.tan(fov.upDegrees * Math.PI/180.0); + let downTan = Math.tan(fov.downDegrees * Math.PI/180.0); + let leftTan = Math.tan(fov.leftDegrees * Math.PI/180.0); + let rightTan = Math.tan(fov.rightDegrees * Math.PI/180.0); + let xScale = 2.0 / (leftTan + rightTan); + let yScale = 2.0 / (upTan + downTan); + + out[0] = xScale; + out[1] = 0.0; + out[2] = 0.0; + out[3] = 0.0; + out[4] = 0.0; + out[5] = yScale; + out[6] = 0.0; + out[7] = 0.0; + out[8] = -((leftTan - rightTan) * xScale * 0.5); + out[9] = ((upTan - downTan) * yScale * 0.5); + out[10] = far / (near - far); + out[11] = -1.0; + out[12] = 0.0; + out[13] = 0.0; + out[14] = (far * near) / (near - far); + out[15] = 0.0; + return out; +} + +/** + * Generates a orthogonal projection matrix with the given bounds + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} left Left bound of the frustum + * @param {number} right Right bound of the frustum + * @param {number} bottom Bottom bound of the frustum + * @param {number} top Top bound of the frustum + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {mat4} out + */ +export function ortho(out, left, right, bottom, top, near, far) { + let lr = 1 / (left - right); + let bt = 1 / (bottom - top); + let nf = 1 / (near - far); + out[0] = -2 * lr; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = -2 * bt; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 2 * nf; + out[11] = 0; + out[12] = (left + right) * lr; + out[13] = (top + bottom) * bt; + out[14] = (far + near) * nf; + out[15] = 1; + return out; +} + +/** + * Generates a look-at matrix with the given eye position, focal point, and up axis. + * If you want a matrix that actually makes an object look at another object, you should use targetTo instead. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {vec3} eye Position of the viewer + * @param {vec3} center Point the viewer is looking at + * @param {vec3} up vec3 pointing up + * @returns {mat4} out + */ +export function lookAt(out, eye, center, up) { + let x0, x1, x2, y0, y1, y2, z0, z1, z2, len; + let eyex = eye[0]; + let eyey = eye[1]; + let eyez = eye[2]; + let upx = up[0]; + let upy = up[1]; + let upz = up[2]; + let centerx = center[0]; + let centery = center[1]; + let centerz = center[2]; + + if (Math.abs(eyex - centerx) < glMatrix.EPSILON && + Math.abs(eyey - centery) < glMatrix.EPSILON && + Math.abs(eyez - centerz) < glMatrix.EPSILON) { + return identity(out); + } + + z0 = eyex - centerx; + z1 = eyey - centery; + z2 = eyez - centerz; + + len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); + z0 *= len; + z1 *= len; + z2 *= len; + + x0 = upy * z2 - upz * z1; + x1 = upz * z0 - upx * z2; + x2 = upx * z1 - upy * z0; + len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); + if (!len) { + x0 = 0; + x1 = 0; + x2 = 0; + } else { + len = 1 / len; + x0 *= len; + x1 *= len; + x2 *= len; + } + + y0 = z1 * x2 - z2 * x1; + y1 = z2 * x0 - z0 * x2; + y2 = z0 * x1 - z1 * x0; + + len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); + if (!len) { + y0 = 0; + y1 = 0; + y2 = 0; + } else { + len = 1 / len; + y0 *= len; + y1 *= len; + y2 *= len; + } + + out[0] = x0; + out[1] = y0; + out[2] = z0; + out[3] = 0; + out[4] = x1; + out[5] = y1; + out[6] = z1; + out[7] = 0; + out[8] = x2; + out[9] = y2; + out[10] = z2; + out[11] = 0; + out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); + out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); + out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); + out[15] = 1; + + return out; +} + +/** + * Generates a matrix that makes something look at something else. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {vec3} eye Position of the viewer + * @param {vec3} center Point the viewer is looking at + * @param {vec3} up vec3 pointing up + * @returns {mat4} out + */ +export function targetTo(out, eye, target, up) { + let eyex = eye[0], + eyey = eye[1], + eyez = eye[2], + upx = up[0], + upy = up[1], + upz = up[2]; + + let z0 = eyex - target[0], + z1 = eyey - target[1], + z2 = eyez - target[2]; + + let len = z0*z0 + z1*z1 + z2*z2; + if (len > 0) { + len = 1 / Math.sqrt(len); + z0 *= len; + z1 *= len; + z2 *= len; + } + + let x0 = upy * z2 - upz * z1, + x1 = upz * z0 - upx * z2, + x2 = upx * z1 - upy * z0; + + len = x0*x0 + x1*x1 + x2*x2; + if (len > 0) { + len = 1 / Math.sqrt(len); + x0 *= len; + x1 *= len; + x2 *= len; + } + + out[0] = x0; + out[1] = x1; + out[2] = x2; + out[3] = 0; + out[4] = z1 * x2 - z2 * x1; + out[5] = z2 * x0 - z0 * x2; + out[6] = z0 * x1 - z1 * x0; + out[7] = 0; + out[8] = z0; + out[9] = z1; + out[10] = z2; + out[11] = 0; + out[12] = eyex; + out[13] = eyey; + out[14] = eyez; + out[15] = 1; + return out; +}; + +/** + * Returns a string representation of a mat4 + * + * @param {mat4} a matrix to represent as a string + * @returns {String} string representation of the matrix + */ +export function str(a) { + return 'mat4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + + a[8] + ', ' + a[9] + ', ' + a[10] + ', ' + a[11] + ', ' + + a[12] + ', ' + a[13] + ', ' + a[14] + ', ' + a[15] + ')'; +} + +/** + * Returns Frobenius norm of a mat4 + * + * @param {mat4} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ +export function frob(a) { + return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2) + Math.pow(a[9], 2) + Math.pow(a[10], 2) + Math.pow(a[11], 2) + Math.pow(a[12], 2) + Math.pow(a[13], 2) + Math.pow(a[14], 2) + Math.pow(a[15], 2) )) +} + +/** + * Adds two mat4's + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the first operand + * @param {mat4} b the second operand + * @returns {mat4} out + */ +export function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + out[4] = a[4] + b[4]; + out[5] = a[5] + b[5]; + out[6] = a[6] + b[6]; + out[7] = a[7] + b[7]; + out[8] = a[8] + b[8]; + out[9] = a[9] + b[9]; + out[10] = a[10] + b[10]; + out[11] = a[11] + b[11]; + out[12] = a[12] + b[12]; + out[13] = a[13] + b[13]; + out[14] = a[14] + b[14]; + out[15] = a[15] + b[15]; + return out; +} + +/** + * Subtracts matrix b from matrix a + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the first operand + * @param {mat4} b the second operand + * @returns {mat4} out + */ +export function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; + out[4] = a[4] - b[4]; + out[5] = a[5] - b[5]; + out[6] = a[6] - b[6]; + out[7] = a[7] - b[7]; + out[8] = a[8] - b[8]; + out[9] = a[9] - b[9]; + out[10] = a[10] - b[10]; + out[11] = a[11] - b[11]; + out[12] = a[12] - b[12]; + out[13] = a[13] - b[13]; + out[14] = a[14] - b[14]; + out[15] = a[15] - b[15]; + return out; +} + +/** + * Multiply each element of the matrix by a scalar. + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {mat4} out + */ +export function multiplyScalar(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + out[4] = a[4] * b; + out[5] = a[5] * b; + out[6] = a[6] * b; + out[7] = a[7] * b; + out[8] = a[8] * b; + out[9] = a[9] * b; + out[10] = a[10] * b; + out[11] = a[11] * b; + out[12] = a[12] * b; + out[13] = a[13] * b; + out[14] = a[14] * b; + out[15] = a[15] * b; + return out; +} + +/** + * Adds two mat4's after multiplying each element of the second operand by a scalar value. + * + * @param {mat4} out the receiving vector + * @param {mat4} a the first operand + * @param {mat4} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {mat4} out + */ +export function multiplyScalarAndAdd(out, a, b, scale) { + out[0] = a[0] + (b[0] * scale); + out[1] = a[1] + (b[1] * scale); + out[2] = a[2] + (b[2] * scale); + out[3] = a[3] + (b[3] * scale); + out[4] = a[4] + (b[4] * scale); + out[5] = a[5] + (b[5] * scale); + out[6] = a[6] + (b[6] * scale); + out[7] = a[7] + (b[7] * scale); + out[8] = a[8] + (b[8] * scale); + out[9] = a[9] + (b[9] * scale); + out[10] = a[10] + (b[10] * scale); + out[11] = a[11] + (b[11] * scale); + out[12] = a[12] + (b[12] * scale); + out[13] = a[13] + (b[13] * scale); + out[14] = a[14] + (b[14] * scale); + out[15] = a[15] + (b[15] * scale); + return out; +} + +/** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {mat4} a The first matrix. + * @param {mat4} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ +export function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && + a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && + a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] && + a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15]; +} + +/** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {mat4} a The first matrix. + * @param {mat4} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ +export function equals(a, b) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + let a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7]; + let a8 = a[8], a9 = a[9], a10 = a[10], a11 = a[11]; + let a12 = a[12], a13 = a[13], a14 = a[14], a15 = a[15]; + + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + let b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7]; + let b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11]; + let b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15]; + + return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && + Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && + Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && + Math.abs(a3 - b3) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a3), Math.abs(b3)) && + Math.abs(a4 - b4) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a4), Math.abs(b4)) && + Math.abs(a5 - b5) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a5), Math.abs(b5)) && + Math.abs(a6 - b6) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a6), Math.abs(b6)) && + Math.abs(a7 - b7) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a7), Math.abs(b7)) && + Math.abs(a8 - b8) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a8), Math.abs(b8)) && + Math.abs(a9 - b9) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a9), Math.abs(b9)) && + Math.abs(a10 - b10) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a10), Math.abs(b10)) && + Math.abs(a11 - b11) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a11), Math.abs(b11)) && + Math.abs(a12 - b12) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a12), Math.abs(b12)) && + Math.abs(a13 - b13) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a13), Math.abs(b13)) && + Math.abs(a14 - b14) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a14), Math.abs(b14)) && + Math.abs(a15 - b15) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a15), Math.abs(b15))); +} + +/** + * Alias for {@link mat4.multiply} + * @function + */ +export const mul = multiply; + +/** + * Alias for {@link mat4.subtract} + * @function + */ +export const sub = subtract; diff --git a/js/third-party/gl-matrix/src/gl-matrix/quat.js b/js/third-party/gl-matrix/src/gl-matrix/quat.js new file mode 100644 index 000000000..3cdf62ee3 --- /dev/null +++ b/js/third-party/gl-matrix/src/gl-matrix/quat.js @@ -0,0 +1,631 @@ +import * as glMatrix from "./common.js" +import * as mat3 from "./mat3.js" +import * as vec3 from "./vec3.js" +import * as vec4 from "./vec4.js" + +/** + * Quaternion + * @module quat + */ + +/** + * Creates a new identity quat + * + * @returns {quat} a new quaternion + */ +export function create() { + let out = new glMatrix.ARRAY_TYPE(4); + if(glMatrix.ARRAY_TYPE != Float32Array) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + } + out[3] = 1; + return out; +} + +/** + * Set a quat to the identity quaternion + * + * @param {quat} out the receiving quaternion + * @returns {quat} out + */ +export function identity(out) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 1; + return out; +} + +/** + * Sets a quat from the given angle and rotation axis, + * then returns it. + * + * @param {quat} out the receiving quaternion + * @param {vec3} axis the axis around which to rotate + * @param {Number} rad the angle in radians + * @returns {quat} out + **/ +export function setAxisAngle(out, axis, rad) { + rad = rad * 0.5; + let s = Math.sin(rad); + out[0] = s * axis[0]; + out[1] = s * axis[1]; + out[2] = s * axis[2]; + out[3] = Math.cos(rad); + return out; +} + +/** + * Gets the rotation axis and angle for a given + * quaternion. If a quaternion is created with + * setAxisAngle, this method will return the same + * values as providied in the original parameter list + * OR functionally equivalent values. + * Example: The quaternion formed by axis [0, 0, 1] and + * angle -90 is the same as the quaternion formed by + * [0, 0, 1] and 270. This method favors the latter. + * @param {vec3} out_axis Vector receiving the axis of rotation + * @param {quat} q Quaternion to be decomposed + * @return {Number} Angle, in radians, of the rotation + */ +export function getAxisAngle(out_axis, q) { + let rad = Math.acos(q[3]) * 2.0; + let s = Math.sin(rad / 2.0); + if (s > glMatrix.EPSILON) { + out_axis[0] = q[0] / s; + out_axis[1] = q[1] / s; + out_axis[2] = q[2] / s; + } else { + // If s is zero, return any axis (no rotation - axis does not matter) + out_axis[0] = 1; + out_axis[1] = 0; + out_axis[2] = 0; + } + return rad; +} + +/** + * Multiplies two quat's + * + * @param {quat} out the receiving quaternion + * @param {quat} a the first operand + * @param {quat} b the second operand + * @returns {quat} out + */ +export function multiply(out, a, b) { + let ax = a[0], ay = a[1], az = a[2], aw = a[3]; + let bx = b[0], by = b[1], bz = b[2], bw = b[3]; + + out[0] = ax * bw + aw * bx + ay * bz - az * by; + out[1] = ay * bw + aw * by + az * bx - ax * bz; + out[2] = az * bw + aw * bz + ax * by - ay * bx; + out[3] = aw * bw - ax * bx - ay * by - az * bz; + return out; +} + +/** + * Rotates a quaternion by the given angle about the X axis + * + * @param {quat} out quat receiving operation result + * @param {quat} a quat to rotate + * @param {number} rad angle (in radians) to rotate + * @returns {quat} out + */ +export function rotateX(out, a, rad) { + rad *= 0.5; + + let ax = a[0], ay = a[1], az = a[2], aw = a[3]; + let bx = Math.sin(rad), bw = Math.cos(rad); + + out[0] = ax * bw + aw * bx; + out[1] = ay * bw + az * bx; + out[2] = az * bw - ay * bx; + out[3] = aw * bw - ax * bx; + return out; +} + +/** + * Rotates a quaternion by the given angle about the Y axis + * + * @param {quat} out quat receiving operation result + * @param {quat} a quat to rotate + * @param {number} rad angle (in radians) to rotate + * @returns {quat} out + */ +export function rotateY(out, a, rad) { + rad *= 0.5; + + let ax = a[0], ay = a[1], az = a[2], aw = a[3]; + let by = Math.sin(rad), bw = Math.cos(rad); + + out[0] = ax * bw - az * by; + out[1] = ay * bw + aw * by; + out[2] = az * bw + ax * by; + out[3] = aw * bw - ay * by; + return out; +} + +/** + * Rotates a quaternion by the given angle about the Z axis + * + * @param {quat} out quat receiving operation result + * @param {quat} a quat to rotate + * @param {number} rad angle (in radians) to rotate + * @returns {quat} out + */ +export function rotateZ(out, a, rad) { + rad *= 0.5; + + let ax = a[0], ay = a[1], az = a[2], aw = a[3]; + let bz = Math.sin(rad), bw = Math.cos(rad); + + out[0] = ax * bw + ay * bz; + out[1] = ay * bw - ax * bz; + out[2] = az * bw + aw * bz; + out[3] = aw * bw - az * bz; + return out; +} + +/** + * Calculates the W component of a quat from the X, Y, and Z components. + * Assumes that quaternion is 1 unit in length. + * Any existing W component will be ignored. + * + * @param {quat} out the receiving quaternion + * @param {quat} a quat to calculate W component of + * @returns {quat} out + */ +export function calculateW(out, a) { + let x = a[0], y = a[1], z = a[2]; + + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z)); + return out; +} + +/** + * Performs a spherical linear interpolation between two quat + * + * @param {quat} out the receiving quaternion + * @param {quat} a the first operand + * @param {quat} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {quat} out + */ +export function slerp(out, a, b, t) { + // benchmarks: + // http://jsperf.com/quaternion-slerp-implementations + let ax = a[0], ay = a[1], az = a[2], aw = a[3]; + let bx = b[0], by = b[1], bz = b[2], bw = b[3]; + + let omega, cosom, sinom, scale0, scale1; + + // calc cosine + cosom = ax * bx + ay * by + az * bz + aw * bw; + // adjust signs (if necessary) + if ( cosom < 0.0 ) { + cosom = -cosom; + bx = - bx; + by = - by; + bz = - bz; + bw = - bw; + } + // calculate coefficients + if ( (1.0 - cosom) > glMatrix.EPSILON ) { + // standard case (slerp) + omega = Math.acos(cosom); + sinom = Math.sin(omega); + scale0 = Math.sin((1.0 - t) * omega) / sinom; + scale1 = Math.sin(t * omega) / sinom; + } else { + // "from" and "to" quaternions are very close + // ... so we can do a linear interpolation + scale0 = 1.0 - t; + scale1 = t; + } + // calculate final values + out[0] = scale0 * ax + scale1 * bx; + out[1] = scale0 * ay + scale1 * by; + out[2] = scale0 * az + scale1 * bz; + out[3] = scale0 * aw + scale1 * bw; + + return out; +} + +/** + * Generates a random quaternion + * + * @param {quat} out the receiving quaternion + * @returns {quat} out + */ +export function random(out) { + // Implementation of http://planning.cs.uiuc.edu/node198.html + // TODO: Calling random 3 times is probably not the fastest solution + let u1 = glMatrix.RANDOM(); + let u2 = glMatrix.RANDOM(); + let u3 = glMatrix.RANDOM(); + + let sqrt1MinusU1 = Math.sqrt(1 - u1); + let sqrtU1 = Math.sqrt(u1); + + out[0] = sqrt1MinusU1 * Math.sin(2.0 * Math.PI * u2); + out[1] = sqrt1MinusU1 * Math.cos(2.0 * Math.PI * u2); + out[2] = sqrtU1 * Math.sin(2.0 * Math.PI * u3); + out[3] = sqrtU1 * Math.cos(2.0 * Math.PI * u3); + return out; +} + +/** + * Calculates the inverse of a quat + * + * @param {quat} out the receiving quaternion + * @param {quat} a quat to calculate inverse of + * @returns {quat} out + */ +export function invert(out, a) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + let dot = a0*a0 + a1*a1 + a2*a2 + a3*a3; + let invDot = dot ? 1.0/dot : 0; + + // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 + + out[0] = -a0*invDot; + out[1] = -a1*invDot; + out[2] = -a2*invDot; + out[3] = a3*invDot; + return out; +} + +/** + * Calculates the conjugate of a quat + * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result. + * + * @param {quat} out the receiving quaternion + * @param {quat} a quat to calculate conjugate of + * @returns {quat} out + */ +export function conjugate(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; + out[3] = a[3]; + return out; +} + +/** + * Creates a quaternion from the given 3x3 rotation matrix. + * + * NOTE: The resultant quaternion is not normalized, so you should be sure + * to renormalize the quaternion yourself where necessary. + * + * @param {quat} out the receiving quaternion + * @param {mat3} m rotation matrix + * @returns {quat} out + * @function + */ +export function fromMat3(out, m) { + // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes + // article "Quaternion Calculus and Fast Animation". + let fTrace = m[0] + m[4] + m[8]; + let fRoot; + + if ( fTrace > 0.0 ) { + // |w| > 1/2, may as well choose w > 1/2 + fRoot = Math.sqrt(fTrace + 1.0); // 2w + out[3] = 0.5 * fRoot; + fRoot = 0.5/fRoot; // 1/(4w) + out[0] = (m[5]-m[7])*fRoot; + out[1] = (m[6]-m[2])*fRoot; + out[2] = (m[1]-m[3])*fRoot; + } else { + // |w| <= 1/2 + let i = 0; + if ( m[4] > m[0] ) + i = 1; + if ( m[8] > m[i*3+i] ) + i = 2; + let j = (i+1)%3; + let k = (i+2)%3; + + fRoot = Math.sqrt(m[i*3+i]-m[j*3+j]-m[k*3+k] + 1.0); + out[i] = 0.5 * fRoot; + fRoot = 0.5 / fRoot; + out[3] = (m[j*3+k] - m[k*3+j]) * fRoot; + out[j] = (m[j*3+i] + m[i*3+j]) * fRoot; + out[k] = (m[k*3+i] + m[i*3+k]) * fRoot; + } + + return out; +} + +/** + * Creates a quaternion from the given euler angle x, y, z. + * + * @param {quat} out the receiving quaternion + * @param {x} Angle to rotate around X axis in degrees. + * @param {y} Angle to rotate around Y axis in degrees. + * @param {z} Angle to rotate around Z axis in degrees. + * @returns {quat} out + * @function + */ +export function fromEuler(out, x, y, z) { + let halfToRad = 0.5 * Math.PI / 180.0; + x *= halfToRad; + y *= halfToRad; + z *= halfToRad; + + let sx = Math.sin(x); + let cx = Math.cos(x); + let sy = Math.sin(y); + let cy = Math.cos(y); + let sz = Math.sin(z); + let cz = Math.cos(z); + + out[0] = sx * cy * cz - cx * sy * sz; + out[1] = cx * sy * cz + sx * cy * sz; + out[2] = cx * cy * sz - sx * sy * cz; + out[3] = cx * cy * cz + sx * sy * sz; + + return out; +} + +/** + * Returns a string representation of a quatenion + * + * @param {quat} a vector to represent as a string + * @returns {String} string representation of the vector + */ +export function str(a) { + return 'quat(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')'; +} + +/** + * Creates a new quat initialized with values from an existing quaternion + * + * @param {quat} a quaternion to clone + * @returns {quat} a new quaternion + * @function + */ +export const clone = vec4.clone; + +/** + * Creates a new quat initialized with the given values + * + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {quat} a new quaternion + * @function + */ +export const fromValues = vec4.fromValues; + +/** + * Copy the values from one quat to another + * + * @param {quat} out the receiving quaternion + * @param {quat} a the source quaternion + * @returns {quat} out + * @function + */ +export const copy = vec4.copy; + +/** + * Set the components of a quat to the given values + * + * @param {quat} out the receiving quaternion + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {quat} out + * @function + */ +export const set = vec4.set; + +/** + * Adds two quat's + * + * @param {quat} out the receiving quaternion + * @param {quat} a the first operand + * @param {quat} b the second operand + * @returns {quat} out + * @function + */ +export const add = vec4.add; + +/** + * Alias for {@link quat.multiply} + * @function + */ +export const mul = multiply; + +/** + * Scales a quat by a scalar number + * + * @param {quat} out the receiving vector + * @param {quat} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {quat} out + * @function + */ +export const scale = vec4.scale; + +/** + * Calculates the dot product of two quat's + * + * @param {quat} a the first operand + * @param {quat} b the second operand + * @returns {Number} dot product of a and b + * @function + */ +export const dot = vec4.dot; + +/** + * Performs a linear interpolation between two quat's + * + * @param {quat} out the receiving quaternion + * @param {quat} a the first operand + * @param {quat} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {quat} out + * @function + */ +export const lerp = vec4.lerp; + +/** + * Calculates the length of a quat + * + * @param {quat} a vector to calculate length of + * @returns {Number} length of a + */ +export const length = vec4.length; + +/** + * Alias for {@link quat.length} + * @function + */ +export const len = length; + +/** + * Calculates the squared length of a quat + * + * @param {quat} a vector to calculate squared length of + * @returns {Number} squared length of a + * @function + */ +export const squaredLength = vec4.squaredLength; + +/** + * Alias for {@link quat.squaredLength} + * @function + */ +export const sqrLen = squaredLength; + +/** + * Normalize a quat + * + * @param {quat} out the receiving quaternion + * @param {quat} a quaternion to normalize + * @returns {quat} out + * @function + */ +export const normalize = vec4.normalize; + +/** + * Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===) + * + * @param {quat} a The first quaternion. + * @param {quat} b The second quaternion. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ +export const exactEquals = vec4.exactEquals; + +/** + * Returns whether or not the quaternions have approximately the same elements in the same position. + * + * @param {quat} a The first vector. + * @param {quat} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ +export const equals = vec4.equals; + +/** + * Sets a quaternion to represent the shortest rotation from one + * vector to another. + * + * Both vectors are assumed to be unit length. + * + * @param {quat} out the receiving quaternion. + * @param {vec3} a the initial vector + * @param {vec3} b the destination vector + * @returns {quat} out + */ +export const rotationTo = (function() { + let tmpvec3 = vec3.create(); + let xUnitVec3 = vec3.fromValues(1,0,0); + let yUnitVec3 = vec3.fromValues(0,1,0); + + return function(out, a, b) { + let dot = vec3.dot(a, b); + if (dot < -0.999999) { + vec3.cross(tmpvec3, xUnitVec3, a); + if (vec3.len(tmpvec3) < 0.000001) + vec3.cross(tmpvec3, yUnitVec3, a); + vec3.normalize(tmpvec3, tmpvec3); + setAxisAngle(out, tmpvec3, Math.PI); + return out; + } else if (dot > 0.999999) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 1; + return out; + } else { + vec3.cross(tmpvec3, a, b); + out[0] = tmpvec3[0]; + out[1] = tmpvec3[1]; + out[2] = tmpvec3[2]; + out[3] = 1 + dot; + return normalize(out, out); + } + }; +})(); + +/** + * Performs a spherical linear interpolation with two control points + * + * @param {quat} out the receiving quaternion + * @param {quat} a the first operand + * @param {quat} b the second operand + * @param {quat} c the third operand + * @param {quat} d the fourth operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {quat} out + */ +export const sqlerp = (function () { + let temp1 = create(); + let temp2 = create(); + + return function (out, a, b, c, d, t) { + slerp(temp1, a, d, t); + slerp(temp2, b, c, t); + slerp(out, temp1, temp2, 2 * t * (1 - t)); + + return out; + }; +}()); + +/** + * Sets the specified quaternion with values corresponding to the given + * axes. Each axis is a vec3 and is expected to be unit length and + * perpendicular to all other specified axes. + * + * @param {vec3} view the vector representing the viewing direction + * @param {vec3} right the vector representing the local "right" direction + * @param {vec3} up the vector representing the local "up" direction + * @returns {quat} out + */ +export const setAxes = (function() { + let matr = mat3.create(); + + return function(out, view, right, up) { + matr[0] = right[0]; + matr[3] = right[1]; + matr[6] = right[2]; + + matr[1] = up[0]; + matr[4] = up[1]; + matr[7] = up[2]; + + matr[2] = -view[0]; + matr[5] = -view[1]; + matr[8] = -view[2]; + + return normalize(out, fromMat3(out, matr)); + }; +})(); diff --git a/js/third-party/gl-matrix/src/gl-matrix/quat2.js b/js/third-party/gl-matrix/src/gl-matrix/quat2.js new file mode 100644 index 000000000..1840b6945 --- /dev/null +++ b/js/third-party/gl-matrix/src/gl-matrix/quat2.js @@ -0,0 +1,854 @@ +import * as glMatrix from "./common.js"; +import * as quat from "./quat.js"; +import * as mat4 from "./mat4.js"; + +/** + * Dual Quaternion
+ * Format: [real, dual]
+ * Quaternion format: XYZW
+ * Make sure to have normalized dual quaternions, otherwise the functions may not work as intended.
+ * @module quat2 + */ + + +/** + * Creates a new identity dual quat + * + * @returns {quat2} a new dual quaternion [real -> rotation, dual -> translation] + */ +export function create() { + let dq = new glMatrix.ARRAY_TYPE(8); + if(glMatrix.ARRAY_TYPE != Float32Array) { + dq[0] = 0; + dq[1] = 0; + dq[2] = 0; + dq[4] = 0; + dq[5] = 0; + dq[6] = 0; + dq[7] = 0; + } + dq[3] = 1; + return dq; +} + +/** + * Creates a new quat initialized with values from an existing quaternion + * + * @param {quat2} a dual quaternion to clone + * @returns {quat2} new dual quaternion + * @function + */ +export function clone(a) { + let dq = new glMatrix.ARRAY_TYPE(8); + dq[0] = a[0]; + dq[1] = a[1]; + dq[2] = a[2]; + dq[3] = a[3]; + dq[4] = a[4]; + dq[5] = a[5]; + dq[6] = a[6]; + dq[7] = a[7]; + return dq; +} + +/** + * Creates a new dual quat initialized with the given values + * + * @param {Number} x1 X component + * @param {Number} y1 Y component + * @param {Number} z1 Z component + * @param {Number} w1 W component + * @param {Number} x2 X component + * @param {Number} y2 Y component + * @param {Number} z2 Z component + * @param {Number} w2 W component + * @returns {quat2} new dual quaternion + * @function + */ +export function fromValues(x1, y1, z1, w1, x2, y2, z2, w2) { + let dq = new glMatrix.ARRAY_TYPE(8); + dq[0] = x1; + dq[1] = y1; + dq[2] = z1; + dq[3] = w1; + dq[4] = x2; + dq[5] = y2; + dq[6] = z2; + dq[7] = w2; + return dq; +} + +/** + * Creates a new dual quat from the given values (quat and translation) + * + * @param {Number} x1 X component + * @param {Number} y1 Y component + * @param {Number} z1 Z component + * @param {Number} w1 W component + * @param {Number} x2 X component (translation) + * @param {Number} y2 Y component (translation) + * @param {Number} z2 Z component (translation) + * @returns {quat2} new dual quaternion + * @function + */ +export function fromRotationTranslationValues(x1, y1, z1, w1, x2, y2, z2) { + let dq = new glMatrix.ARRAY_TYPE(8); + dq[0] = x1; + dq[1] = y1; + dq[2] = z1; + dq[3] = w1; + let ax = x2 * 0.5, + ay = y2 * 0.5, + az = z2 * 0.5; + dq[4] = ax * w1 + ay * z1 - az * y1; + dq[5] = ay * w1 + az * x1 - ax * z1; + dq[6] = az * w1 + ax * y1 - ay * x1; + dq[7] = -ax * x1 - ay * y1 - az * z1; + return dq; +} + +/** + * Creates a dual quat from a quaternion and a translation + * + * @param {quat2} dual quaternion receiving operation result + * @param {quat} q quaternion + * @param {vec3} t tranlation vector + * @returns {quat2} dual quaternion receiving operation result + * @function + */ +export function fromRotationTranslation(out, q, t) { + let ax = t[0] * 0.5, + ay = t[1] * 0.5, + az = t[2] * 0.5, + bx = q[0], + by = q[1], + bz = q[2], + bw = q[3]; + out[0] = bx; + out[1] = by; + out[2] = bz; + out[3] = bw; + out[4] = ax * bw + ay * bz - az * by; + out[5] = ay * bw + az * bx - ax * bz; + out[6] = az * bw + ax * by - ay * bx; + out[7] = -ax * bx - ay * by - az * bz; + return out; +} + +/** + * Creates a dual quat from a translation + * + * @param {quat2} dual quaternion receiving operation result + * @param {vec3} t translation vector + * @returns {quat2} dual quaternion receiving operation result + * @function + */ +export function fromTranslation(out, t) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = t[0] * 0.5; + out[5] = t[1] * 0.5; + out[6] = t[2] * 0.5; + out[7] = 0; + return out; +} + +/** + * Creates a dual quat from a quaternion + * + * @param {quat2} dual quaternion receiving operation result + * @param {quat} q the quaternion + * @returns {quat2} dual quaternion receiving operation result + * @function + */ +export function fromRotation(out, q) { + out[0] = q[0]; + out[1] = q[1]; + out[2] = q[2]; + out[3] = q[3]; + out[4] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; + return out; +} + +/** + * Creates a new dual quat from a matrix (4x4) + * + * @param {quat2} out the dual quaternion + * @param {mat4} a the matrix + * @returns {quat2} dual quat receiving operation result + * @function + */ +export function fromMat4(out, a) { + //TODO Optimize this + let outer = quat.create(); + mat4.getRotation(outer, a); + let t = new glMatrix.ARRAY_TYPE(3); + mat4.getTranslation(t, a); + fromRotationTranslation(out, outer, t); + return out; +} + +/** + * Copy the values from one dual quat to another + * + * @param {quat2} out the receiving dual quaternion + * @param {quat2} a the source dual quaternion + * @returns {quat2} out + * @function + */ +export function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + return out; +} + +/** + * Set a dual quat to the identity dual quaternion + * + * @param {quat2} out the receiving quaternion + * @returns {quat2} out + */ +export function identity(out) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; + return out; +} + +/** + * Set the components of a dual quat to the given values + * + * @param {quat2} out the receiving quaternion + * @param {Number} x1 X component + * @param {Number} y1 Y component + * @param {Number} z1 Z component + * @param {Number} w1 W component + * @param {Number} x2 X component + * @param {Number} y2 Y component + * @param {Number} z2 Z component + * @param {Number} w2 W component + * @returns {quat2} out + * @function + */ +export function set(out, x1, y1, z1, w1, x2, y2, z2, w2) { + out[0] = x1; + out[1] = y1; + out[2] = z1; + out[3] = w1; + + out[4] = x2; + out[5] = y2; + out[6] = z2; + out[7] = w2; + return out; +} + +/** + * Gets the real part of a dual quat + * @param {quat} out real part + * @param {quat2} a Dual Quaternion + * @return {quat} real part + */ +export const getReal = quat.copy; + +/** + * Gets the dual part of a dual quat + * @param {quat} out dual part + * @param {quat2} a Dual Quaternion + * @return {quat} dual part + */ +export function getDual(out, a) { + out[0] = a[4]; + out[1] = a[5]; + out[2] = a[6]; + out[3] = a[7]; + return out; +} + +/** + * Set the real component of a dual quat to the given quaternion + * + * @param {quat2} out the receiving quaternion + * @param {quat} q a quaternion representing the real part + * @returns {quat2} out + * @function + */ +export const setReal = quat.copy; + +/** + * Set the dual component of a dual quat to the given quaternion + * + * @param {quat2} out the receiving quaternion + * @param {quat} q a quaternion representing the dual part + * @returns {quat2} out + * @function + */ +export function setDual(out, q) { + out[4] = q[0]; + out[5] = q[1]; + out[6] = q[2]; + out[7] = q[3]; + return out; +} + +/** + * Gets the translation of a normalized dual quat + * @param {vec3} out translation + * @param {quat2} a Dual Quaternion to be decomposed + * @return {vec3} translation + */ +export function getTranslation(out, a) { + let ax = a[4], + ay = a[5], + az = a[6], + aw = a[7], + bx = -a[0], + by = -a[1], + bz = -a[2], + bw = a[3]; + out[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2; + out[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2; + out[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2; + return out; +} + +/** + * Translates a dual quat by the given vector + * + * @param {quat2} out the receiving dual quaternion + * @param {quat2} a the dual quaternion to translate + * @param {vec3} v vector to translate by + * @returns {quat2} out + */ +export function translate(out, a, v) { + let ax1 = a[0], + ay1 = a[1], + az1 = a[2], + aw1 = a[3], + bx1 = v[0] * 0.5, + by1 = v[1] * 0.5, + bz1 = v[2] * 0.5, + ax2 = a[4], + ay2 = a[5], + az2 = a[6], + aw2 = a[7]; + out[0] = ax1; + out[1] = ay1; + out[2] = az1; + out[3] = aw1; + out[4] = aw1 * bx1 + ay1 * bz1 - az1 * by1 + ax2; + out[5] = aw1 * by1 + az1 * bx1 - ax1 * bz1 + ay2; + out[6] = aw1 * bz1 + ax1 * by1 - ay1 * bx1 + az2; + out[7] = -ax1 * bx1 - ay1 * by1 - az1 * bz1 + aw2; + return out; +} + +/** + * Rotates a dual quat around the X axis + * + * @param {quat2} out the receiving dual quaternion + * @param {quat2} a the dual quaternion to rotate + * @param {number} rad how far should the rotation be + * @returns {quat2} out + */ +export function rotateX(out, a, rad) { + let bx = -a[0], + by = -a[1], + bz = -a[2], + bw = a[3], + ax = a[4], + ay = a[5], + az = a[6], + aw = a[7], + ax1 = ax * bw + aw * bx + ay * bz - az * by, + ay1 = ay * bw + aw * by + az * bx - ax * bz, + az1 = az * bw + aw * bz + ax * by - ay * bx, + aw1 = aw * bw - ax * bx - ay * by - az * bz; + quat.rotateX(out, a, rad); + bx = out[0]; + by = out[1]; + bz = out[2]; + bw = out[3]; + out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; + out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; + out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; + out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; + return out; +} + +/** + * Rotates a dual quat around the Y axis + * + * @param {quat2} out the receiving dual quaternion + * @param {quat2} a the dual quaternion to rotate + * @param {number} rad how far should the rotation be + * @returns {quat2} out + */ +export function rotateY(out, a, rad) { + let bx = -a[0], + by = -a[1], + bz = -a[2], + bw = a[3], + ax = a[4], + ay = a[5], + az = a[6], + aw = a[7], + ax1 = ax * bw + aw * bx + ay * bz - az * by, + ay1 = ay * bw + aw * by + az * bx - ax * bz, + az1 = az * bw + aw * bz + ax * by - ay * bx, + aw1 = aw * bw - ax * bx - ay * by - az * bz; + quat.rotateY(out, a, rad); + bx = out[0]; + by = out[1]; + bz = out[2]; + bw = out[3]; + out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; + out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; + out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; + out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; + return out; +} + +/** + * Rotates a dual quat around the Z axis + * + * @param {quat2} out the receiving dual quaternion + * @param {quat2} a the dual quaternion to rotate + * @param {number} rad how far should the rotation be + * @returns {quat2} out + */ +export function rotateZ(out, a, rad) { + let bx = -a[0], + by = -a[1], + bz = -a[2], + bw = a[3], + ax = a[4], + ay = a[5], + az = a[6], + aw = a[7], + ax1 = ax * bw + aw * bx + ay * bz - az * by, + ay1 = ay * bw + aw * by + az * bx - ax * bz, + az1 = az * bw + aw * bz + ax * by - ay * bx, + aw1 = aw * bw - ax * bx - ay * by - az * bz; + quat.rotateZ(out, a, rad); + bx = out[0]; + by = out[1]; + bz = out[2]; + bw = out[3]; + out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; + out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; + out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; + out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; + return out; +} + +/** + * Rotates a dual quat by a given quaternion (a * q) + * + * @param {quat2} out the receiving dual quaternion + * @param {quat2} a the dual quaternion to rotate + * @param {quat} q quaternion to rotate by + * @returns {quat2} out + */ +export function rotateByQuatAppend(out, a, q) { + let qx = q[0], + qy = q[1], + qz = q[2], + qw = q[3], + ax = a[0], + ay = a[1], + az = a[2], + aw = a[3]; + + out[0] = ax * qw + aw * qx + ay * qz - az * qy; + out[1] = ay * qw + aw * qy + az * qx - ax * qz; + out[2] = az * qw + aw * qz + ax * qy - ay * qx; + out[3] = aw * qw - ax * qx - ay * qy - az * qz; + ax = a[4]; + ay = a[5]; + az = a[6]; + aw = a[7]; + out[4] = ax * qw + aw * qx + ay * qz - az * qy; + out[5] = ay * qw + aw * qy + az * qx - ax * qz; + out[6] = az * qw + aw * qz + ax * qy - ay * qx; + out[7] = aw * qw - ax * qx - ay * qy - az * qz; + return out; +} + +/** + * Rotates a dual quat by a given quaternion (q * a) + * + * @param {quat2} out the receiving dual quaternion + * @param {quat} q quaternion to rotate by + * @param {quat2} a the dual quaternion to rotate + * @returns {quat2} out + */ +export function rotateByQuatPrepend(out, q, a) { + let qx = q[0], + qy = q[1], + qz = q[2], + qw = q[3], + bx = a[0], + by = a[1], + bz = a[2], + bw = a[3]; + + out[0] = qx * bw + qw * bx + qy * bz - qz * by; + out[1] = qy * bw + qw * by + qz * bx - qx * bz; + out[2] = qz * bw + qw * bz + qx * by - qy * bx; + out[3] = qw * bw - qx * bx - qy * by - qz * bz; + bx = a[4]; + by = a[5]; + bz = a[6]; + bw = a[7]; + out[4] = qx * bw + qw * bx + qy * bz - qz * by; + out[5] = qy * bw + qw * by + qz * bx - qx * bz; + out[6] = qz * bw + qw * bz + qx * by - qy * bx; + out[7] = qw * bw - qx * bx - qy * by - qz * bz; + return out; +} + +/** + * Rotates a dual quat around a given axis. Does the normalisation automatically + * + * @param {quat2} out the receiving dual quaternion + * @param {quat2} a the dual quaternion to rotate + * @param {vec3} axis the axis to rotate around + * @param {Number} rad how far the rotation should be + * @returns {quat2} out + */ +export function rotateAroundAxis(out, a, axis, rad) { + //Special case for rad = 0 + if (Math.abs(rad) < glMatrix.EPSILON) { + return copy(out, a); + } + let axisLength = Math.sqrt(axis[0] * axis[0] + axis[1] * axis[1] + axis[2] * axis[2]); + + rad = rad * 0.5; + let s = Math.sin(rad); + let bx = s * axis[0] / axisLength; + let by = s * axis[1] / axisLength; + let bz = s * axis[2] / axisLength; + let bw = Math.cos(rad); + + let ax1 = a[0], + ay1 = a[1], + az1 = a[2], + aw1 = a[3]; + out[0] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; + out[1] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; + out[2] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; + out[3] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; + + let ax = a[4], + ay = a[5], + az = a[6], + aw = a[7]; + out[4] = ax * bw + aw * bx + ay * bz - az * by; + out[5] = ay * bw + aw * by + az * bx - ax * bz; + out[6] = az * bw + aw * bz + ax * by - ay * bx; + out[7] = aw * bw - ax * bx - ay * by - az * bz; + + return out; +} + +/** + * Adds two dual quat's + * + * @param {quat2} out the receiving dual quaternion + * @param {quat2} a the first operand + * @param {quat2} b the second operand + * @returns {quat2} out + * @function + */ +export function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + out[4] = a[4] + b[4]; + out[5] = a[5] + b[5]; + out[6] = a[6] + b[6]; + out[7] = a[7] + b[7]; + return out; +} + +/** + * Multiplies two dual quat's + * + * @param {quat2} out the receiving dual quaternion + * @param {quat2} a the first operand + * @param {quat2} b the second operand + * @returns {quat2} out + */ +export function multiply(out, a, b) { + let ax0 = a[0], + ay0 = a[1], + az0 = a[2], + aw0 = a[3], + bx1 = b[4], + by1 = b[5], + bz1 = b[6], + bw1 = b[7], + ax1 = a[4], + ay1 = a[5], + az1 = a[6], + aw1 = a[7], + bx0 = b[0], + by0 = b[1], + bz0 = b[2], + bw0 = b[3]; + out[0] = ax0 * bw0 + aw0 * bx0 + ay0 * bz0 - az0 * by0; + out[1] = ay0 * bw0 + aw0 * by0 + az0 * bx0 - ax0 * bz0; + out[2] = az0 * bw0 + aw0 * bz0 + ax0 * by0 - ay0 * bx0; + out[3] = aw0 * bw0 - ax0 * bx0 - ay0 * by0 - az0 * bz0; + out[4] = ax0 * bw1 + aw0 * bx1 + ay0 * bz1 - az0 * by1 + ax1 * bw0 + aw1 * bx0 + ay1 * bz0 - az1 * by0; + out[5] = ay0 * bw1 + aw0 * by1 + az0 * bx1 - ax0 * bz1 + ay1 * bw0 + aw1 * by0 + az1 * bx0 - ax1 * bz0; + out[6] = az0 * bw1 + aw0 * bz1 + ax0 * by1 - ay0 * bx1 + az1 * bw0 + aw1 * bz0 + ax1 * by0 - ay1 * bx0; + out[7] = aw0 * bw1 - ax0 * bx1 - ay0 * by1 - az0 * bz1 + aw1 * bw0 - ax1 * bx0 - ay1 * by0 - az1 * bz0; + return out; +} + +/** + * Alias for {@link quat2.multiply} + * @function + */ +export const mul = multiply; + +/** + * Scales a dual quat by a scalar number + * + * @param {quat2} out the receiving dual quat + * @param {quat2} a the dual quat to scale + * @param {Number} b amount to scale the dual quat by + * @returns {quat2} out + * @function + */ +export function scale(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + out[4] = a[4] * b; + out[5] = a[5] * b; + out[6] = a[6] * b; + out[7] = a[7] * b; + return out; +} + +/** + * Calculates the dot product of two dual quat's (The dot product of the real parts) + * + * @param {quat2} a the first operand + * @param {quat2} b the second operand + * @returns {Number} dot product of a and b + * @function + */ +export const dot = quat.dot; + +/** + * Performs a linear interpolation between two dual quats's + * NOTE: The resulting dual quaternions won't always be normalized (The error is most noticeable when t = 0.5) + * + * @param {quat2} out the receiving dual quat + * @param {quat2} a the first operand + * @param {quat2} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {quat2} out + */ +export function lerp(out, a, b, t) { + let mt = 1 - t; + if (dot(a, b) < 0) t = -t; + + out[0] = a[0] * mt + b[0] * t; + out[1] = a[1] * mt + b[1] * t; + out[2] = a[2] * mt + b[2] * t; + out[3] = a[3] * mt + b[3] * t; + out[4] = a[4] * mt + b[4] * t; + out[5] = a[5] * mt + b[5] * t; + out[6] = a[6] * mt + b[6] * t; + out[7] = a[7] * mt + b[7] * t; + + return out; +} + +/** + * Calculates the inverse of a dual quat. If they are normalized, conjugate is cheaper + * + * @param {quat2} out the receiving dual quaternion + * @param {quat2} a dual quat to calculate inverse of + * @returns {quat2} out + */ +export function invert(out, a) { + let sqlen = squaredLength(a); + out[0] = -a[0] / sqlen; + out[1] = -a[1] / sqlen; + out[2] = -a[2] / sqlen; + out[3] = a[3] / sqlen; + out[4] = -a[4] / sqlen; + out[5] = -a[5] / sqlen; + out[6] = -a[6] / sqlen; + out[7] = a[7] / sqlen; + return out; +} + +/** + * Calculates the conjugate of a dual quat + * If the dual quaternion is normalized, this function is faster than quat2.inverse and produces the same result. + * + * @param {quat2} out the receiving quaternion + * @param {quat2} a quat to calculate conjugate of + * @returns {quat2} out + */ +export function conjugate(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; + out[3] = a[3]; + out[4] = -a[4]; + out[5] = -a[5]; + out[6] = -a[6]; + out[7] = a[7]; + return out; +} + +/** + * Calculates the length of a dual quat + * + * @param {quat2} a dual quat to calculate length of + * @returns {Number} length of a + * @function + */ +export const length = quat.length; + +/** + * Alias for {@link quat2.length} + * @function + */ +export const len = length; + +/** + * Calculates the squared length of a dual quat + * + * @param {quat2} a dual quat to calculate squared length of + * @returns {Number} squared length of a + * @function + */ +export const squaredLength = quat.squaredLength; + +/** + * Alias for {@link quat2.squaredLength} + * @function + */ +export const sqrLen = squaredLength; + +/** + * Normalize a dual quat + * + * @param {quat2} out the receiving dual quaternion + * @param {quat2} a dual quaternion to normalize + * @returns {quat2} out + * @function + */ +export function normalize(out, a) { + let magnitude = squaredLength(a); + if (magnitude > 0) { + magnitude = Math.sqrt(magnitude); + + let a0 = a[0] / magnitude; + let a1 = a[1] / magnitude; + let a2 = a[2] / magnitude; + let a3 = a[3] / magnitude; + + let b0 = a[4]; + let b1 = a[5]; + let b2 = a[6]; + let b3 = a[7]; + + let a_dot_b = (a0 * b0) + (a1 * b1) + (a2 * b2) + (a3 * b3); + + out[0] = a0; + out[1] = a1; + out[2] = a2; + out[3] = a3; + + out[4] = (b0 - (a0 * a_dot_b)) / magnitude; + out[5] = (b1 - (a1 * a_dot_b)) / magnitude; + out[6] = (b2 - (a2 * a_dot_b)) / magnitude; + out[7] = (b3 - (a3 * a_dot_b)) / magnitude; + } + return out; +} + +/** + * Returns a string representation of a dual quatenion + * + * @param {quat2} a dual quaternion to represent as a string + * @returns {String} string representation of the dual quat + */ +export function str(a) { + return 'quat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ')'; +} + +/** + * Returns whether or not the dual quaternions have exactly the same elements in the same position (when compared with ===) + * + * @param {quat2} a the first dual quaternion. + * @param {quat2} b the second dual quaternion. + * @returns {Boolean} true if the dual quaternions are equal, false otherwise. + */ +export function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && + a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7]; +} + +/** + * Returns whether or not the dual quaternions have approximately the same elements in the same position. + * + * @param {quat2} a the first dual quat. + * @param {quat2} b the second dual quat. + * @returns {Boolean} true if the dual quats are equal, false otherwise. + */ +export function equals(a, b) { + let a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3], + a4 = a[4], + a5 = a[5], + a6 = a[6], + a7 = a[7]; + let b0 = b[0], + b1 = b[1], + b2 = b[2], + b3 = b[3], + b4 = b[4], + b5 = b[5], + b6 = b[6], + b7 = b[7]; + return (Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && + Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && + Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && + Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && + Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && + Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && + Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && + Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7))); +} diff --git a/js/third-party/gl-matrix/src/gl-matrix/vec2.js b/js/third-party/gl-matrix/src/gl-matrix/vec2.js new file mode 100644 index 000000000..1eccbda80 --- /dev/null +++ b/js/third-party/gl-matrix/src/gl-matrix/vec2.js @@ -0,0 +1,625 @@ +import * as glMatrix from "./common.js"; + +/** + * 2 Dimensional Vector + * @module vec2 + */ + +/** + * Creates a new, empty vec2 + * + * @returns {vec2} a new 2D vector + */ +export function create() { + let out = new glMatrix.ARRAY_TYPE(2); + if(glMatrix.ARRAY_TYPE != Float32Array) { + out[0] = 0; + out[1] = 0; + } + return out; +} + +/** + * Creates a new vec2 initialized with values from an existing vector + * + * @param {vec2} a vector to clone + * @returns {vec2} a new 2D vector + */ +export function clone(a) { + let out = new glMatrix.ARRAY_TYPE(2); + out[0] = a[0]; + out[1] = a[1]; + return out; +} + +/** + * Creates a new vec2 initialized with the given values + * + * @param {Number} x X component + * @param {Number} y Y component + * @returns {vec2} a new 2D vector + */ +export function fromValues(x, y) { + let out = new glMatrix.ARRAY_TYPE(2); + out[0] = x; + out[1] = y; + return out; +} + +/** + * Copy the values from one vec2 to another + * + * @param {vec2} out the receiving vector + * @param {vec2} a the source vector + * @returns {vec2} out + */ +export function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + return out; +} + +/** + * Set the components of a vec2 to the given values + * + * @param {vec2} out the receiving vector + * @param {Number} x X component + * @param {Number} y Y component + * @returns {vec2} out + */ +export function set(out, x, y) { + out[0] = x; + out[1] = y; + return out; +} + +/** + * Adds two vec2's + * + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {vec2} out + */ +export function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + return out; +} + +/** + * Subtracts vector b from vector a + * + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {vec2} out + */ +export function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + return out; +} + +/** + * Multiplies two vec2's + * + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {vec2} out + */ +export function multiply(out, a, b) { + out[0] = a[0] * b[0]; + out[1] = a[1] * b[1]; + return out; +} + +/** + * Divides two vec2's + * + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {vec2} out + */ +export function divide(out, a, b) { + out[0] = a[0] / b[0]; + out[1] = a[1] / b[1]; + return out; +} + +/** + * Math.ceil the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {vec2} a vector to ceil + * @returns {vec2} out + */ +export function ceil(out, a) { + out[0] = Math.ceil(a[0]); + out[1] = Math.ceil(a[1]); + return out; +} + +/** + * Math.floor the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {vec2} a vector to floor + * @returns {vec2} out + */ +export function floor(out, a) { + out[0] = Math.floor(a[0]); + out[1] = Math.floor(a[1]); + return out; +} + +/** + * Returns the minimum of two vec2's + * + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {vec2} out + */ +export function min(out, a, b) { + out[0] = Math.min(a[0], b[0]); + out[1] = Math.min(a[1], b[1]); + return out; +} + +/** + * Returns the maximum of two vec2's + * + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {vec2} out + */ +export function max(out, a, b) { + out[0] = Math.max(a[0], b[0]); + out[1] = Math.max(a[1], b[1]); + return out; +} + +/** + * Math.round the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {vec2} a vector to round + * @returns {vec2} out + */ +export function round (out, a) { + out[0] = Math.round(a[0]); + out[1] = Math.round(a[1]); + return out; +} + +/** + * Scales a vec2 by a scalar number + * + * @param {vec2} out the receiving vector + * @param {vec2} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {vec2} out + */ +export function scale(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + return out; +} + +/** + * Adds two vec2's after scaling the second operand by a scalar value + * + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @param {Number} scale the amount to scale b by before adding + * @returns {vec2} out + */ +export function scaleAndAdd(out, a, b, scale) { + out[0] = a[0] + (b[0] * scale); + out[1] = a[1] + (b[1] * scale); + return out; +} + +/** + * Calculates the euclidian distance between two vec2's + * + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {Number} distance between a and b + */ +export function distance(a, b) { + var x = b[0] - a[0], + y = b[1] - a[1]; + return Math.sqrt(x*x + y*y); +} + +/** + * Calculates the squared euclidian distance between two vec2's + * + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {Number} squared distance between a and b + */ +export function squaredDistance(a, b) { + var x = b[0] - a[0], + y = b[1] - a[1]; + return x*x + y*y; +} + +/** + * Calculates the length of a vec2 + * + * @param {vec2} a vector to calculate length of + * @returns {Number} length of a + */ +export function length(a) { + var x = a[0], + y = a[1]; + return Math.sqrt(x*x + y*y); +} + +/** + * Calculates the squared length of a vec2 + * + * @param {vec2} a vector to calculate squared length of + * @returns {Number} squared length of a + */ +export function squaredLength (a) { + var x = a[0], + y = a[1]; + return x*x + y*y; +} + +/** + * Negates the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {vec2} a vector to negate + * @returns {vec2} out + */ +export function negate(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + return out; +} + +/** + * Returns the inverse of the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {vec2} a vector to invert + * @returns {vec2} out + */ +export function inverse(out, a) { + out[0] = 1.0 / a[0]; + out[1] = 1.0 / a[1]; + return out; +} + +/** + * Normalize a vec2 + * + * @param {vec2} out the receiving vector + * @param {vec2} a vector to normalize + * @returns {vec2} out + */ +export function normalize(out, a) { + var x = a[0], + y = a[1]; + var len = x*x + y*y; + if (len > 0) { + //TODO: evaluate use of glm_invsqrt here? + len = 1 / Math.sqrt(len); + out[0] = a[0] * len; + out[1] = a[1] * len; + } + return out; +} + +/** + * Calculates the dot product of two vec2's + * + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {Number} dot product of a and b + */ +export function dot(a, b) { + return a[0] * b[0] + a[1] * b[1]; +} + +/** + * Computes the cross product of two vec2's + * Note that the cross product must by definition produce a 3D vector + * + * @param {vec3} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {vec3} out + */ +export function cross(out, a, b) { + var z = a[0] * b[1] - a[1] * b[0]; + out[0] = out[1] = 0; + out[2] = z; + return out; +} + +/** + * Performs a linear interpolation between two vec2's + * + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {vec2} out + */ +export function lerp(out, a, b, t) { + var ax = a[0], + ay = a[1]; + out[0] = ax + t * (b[0] - ax); + out[1] = ay + t * (b[1] - ay); + return out; +} + +/** + * Generates a random vector with the given scale + * + * @param {vec2} out the receiving vector + * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned + * @returns {vec2} out + */ +export function random(out, scale) { + scale = scale || 1.0; + var r = glMatrix.RANDOM() * 2.0 * Math.PI; + out[0] = Math.cos(r) * scale; + out[1] = Math.sin(r) * scale; + return out; +} + +/** + * Transforms the vec2 with a mat2 + * + * @param {vec2} out the receiving vector + * @param {vec2} a the vector to transform + * @param {mat2} m matrix to transform with + * @returns {vec2} out + */ +export function transformMat2(out, a, m) { + var x = a[0], + y = a[1]; + out[0] = m[0] * x + m[2] * y; + out[1] = m[1] * x + m[3] * y; + return out; +} + +/** + * Transforms the vec2 with a mat2d + * + * @param {vec2} out the receiving vector + * @param {vec2} a the vector to transform + * @param {mat2d} m matrix to transform with + * @returns {vec2} out + */ +export function transformMat2d(out, a, m) { + var x = a[0], + y = a[1]; + out[0] = m[0] * x + m[2] * y + m[4]; + out[1] = m[1] * x + m[3] * y + m[5]; + return out; +} + +/** + * Transforms the vec2 with a mat3 + * 3rd vector component is implicitly '1' + * + * @param {vec2} out the receiving vector + * @param {vec2} a the vector to transform + * @param {mat3} m matrix to transform with + * @returns {vec2} out + */ +export function transformMat3(out, a, m) { + var x = a[0], + y = a[1]; + out[0] = m[0] * x + m[3] * y + m[6]; + out[1] = m[1] * x + m[4] * y + m[7]; + return out; +} + +/** + * Transforms the vec2 with a mat4 + * 3rd vector component is implicitly '0' + * 4th vector component is implicitly '1' + * + * @param {vec2} out the receiving vector + * @param {vec2} a the vector to transform + * @param {mat4} m matrix to transform with + * @returns {vec2} out + */ +export function transformMat4(out, a, m) { + let x = a[0]; + let y = a[1]; + out[0] = m[0] * x + m[4] * y + m[12]; + out[1] = m[1] * x + m[5] * y + m[13]; + return out; +} + +/** + * Rotate a 2D vector + * @param {vec2} out The receiving vec2 + * @param {vec2} a The vec2 point to rotate + * @param {vec2} b The origin of the rotation + * @param {Number} c The angle of rotation + * @returns {vec2} out + */ +export function rotate(out, a, b, c) { + //Translate point to the origin + let p0 = a[0] - b[0], + p1 = a[1] - b[1], + sinC = Math.sin(c), + cosC = Math.cos(c); + + //perform rotation and translate to correct position + out[0] = p0*cosC - p1*sinC + b[0]; + out[1] = p0*sinC + p1*cosC + b[1]; + + return out; +} + +/** + * Get the angle between two 2D vectors + * @param {vec2} a The first operand + * @param {vec2} b The second operand + * @returns {Number} The angle in radians + */ +export function angle(a, b) { + let x1 = a[0], + y1 = a[1], + x2 = b[0], + y2 = b[1]; + + let len1 = x1*x1 + y1*y1; + if (len1 > 0) { + //TODO: evaluate use of glm_invsqrt here? + len1 = 1 / Math.sqrt(len1); + } + + let len2 = x2*x2 + y2*y2; + if (len2 > 0) { + //TODO: evaluate use of glm_invsqrt here? + len2 = 1 / Math.sqrt(len2); + } + + let cosine = (x1 * x2 + y1 * y2) * len1 * len2; + + + if(cosine > 1.0) { + return 0; + } + else if(cosine < -1.0) { + return Math.PI; + } else { + return Math.acos(cosine); + } +} + +/** + * Returns a string representation of a vector + * + * @param {vec2} a vector to represent as a string + * @returns {String} string representation of the vector + */ +export function str(a) { + return 'vec2(' + a[0] + ', ' + a[1] + ')'; +} + +/** + * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===) + * + * @param {vec2} a The first vector. + * @param {vec2} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ +export function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1]; +} + +/** + * Returns whether or not the vectors have approximately the same elements in the same position. + * + * @param {vec2} a The first vector. + * @param {vec2} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ +export function equals(a, b) { + let a0 = a[0], a1 = a[1]; + let b0 = b[0], b1 = b[1]; + return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && + Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1))); +} + +/** + * Alias for {@link vec2.length} + * @function + */ +export const len = length; + +/** + * Alias for {@link vec2.subtract} + * @function + */ +export const sub = subtract; + +/** + * Alias for {@link vec2.multiply} + * @function + */ +export const mul = multiply; + +/** + * Alias for {@link vec2.divide} + * @function + */ +export const div = divide; + +/** + * Alias for {@link vec2.distance} + * @function + */ +export const dist = distance; + +/** + * Alias for {@link vec2.squaredDistance} + * @function + */ +export const sqrDist = squaredDistance; + +/** + * Alias for {@link vec2.squaredLength} + * @function + */ +export const sqrLen = squaredLength; + +/** + * Perform some operation over an array of vec2s. + * + * @param {Array} a the array of vectors to iterate over + * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed + * @param {Number} offset Number of elements to skip at the beginning of the array + * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array + * @param {Function} fn Function to call for each vector in the array + * @param {Object} [arg] additional argument to pass to fn + * @returns {Array} a + * @function + */ +export const forEach = (function() { + let vec = create(); + + return function(a, stride, offset, count, fn, arg) { + let i, l; + if(!stride) { + stride = 2; + } + + if(!offset) { + offset = 0; + } + + if(count) { + l = Math.min((count * stride) + offset, a.length); + } else { + l = a.length; + } + + for(i = offset; i < l; i += stride) { + vec[0] = a[i]; vec[1] = a[i+1]; + fn(vec, vec, arg); + a[i] = vec[0]; a[i+1] = vec[1]; + } + + return a; + }; +})(); diff --git a/js/third-party/gl-matrix/src/gl-matrix/vec3.js b/js/third-party/gl-matrix/src/gl-matrix/vec3.js new file mode 100644 index 000000000..e9ab0dc93 --- /dev/null +++ b/js/third-party/gl-matrix/src/gl-matrix/vec3.js @@ -0,0 +1,769 @@ +import * as glMatrix from "./common.js"; + +/** + * 3 Dimensional Vector + * @module vec3 + */ + +/** + * Creates a new, empty vec3 + * + * @returns {vec3} a new 3D vector + */ +export function create() { + let out = new glMatrix.ARRAY_TYPE(3); + if(glMatrix.ARRAY_TYPE != Float32Array) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + } + return out; +} + +/** + * Creates a new vec3 initialized with values from an existing vector + * + * @param {vec3} a vector to clone + * @returns {vec3} a new 3D vector + */ +export function clone(a) { + var out = new glMatrix.ARRAY_TYPE(3); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + return out; +} + +/** + * Calculates the length of a vec3 + * + * @param {vec3} a vector to calculate length of + * @returns {Number} length of a + */ +export function length(a) { + let x = a[0]; + let y = a[1]; + let z = a[2]; + return Math.sqrt(x*x + y*y + z*z); +} + +/** + * Creates a new vec3 initialized with the given values + * + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @returns {vec3} a new 3D vector + */ +export function fromValues(x, y, z) { + let out = new glMatrix.ARRAY_TYPE(3); + out[0] = x; + out[1] = y; + out[2] = z; + return out; +} + +/** + * Copy the values from one vec3 to another + * + * @param {vec3} out the receiving vector + * @param {vec3} a the source vector + * @returns {vec3} out + */ +export function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + return out; +} + +/** + * Set the components of a vec3 to the given values + * + * @param {vec3} out the receiving vector + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @returns {vec3} out + */ +export function set(out, x, y, z) { + out[0] = x; + out[1] = y; + out[2] = z; + return out; +} + +/** + * Adds two vec3's + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {vec3} out + */ +export function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + return out; +} + +/** + * Subtracts vector b from vector a + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {vec3} out + */ +export function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + return out; +} + +/** + * Multiplies two vec3's + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {vec3} out + */ +export function multiply(out, a, b) { + out[0] = a[0] * b[0]; + out[1] = a[1] * b[1]; + out[2] = a[2] * b[2]; + return out; +} + +/** + * Divides two vec3's + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {vec3} out + */ +export function divide(out, a, b) { + out[0] = a[0] / b[0]; + out[1] = a[1] / b[1]; + out[2] = a[2] / b[2]; + return out; +} + +/** + * Math.ceil the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to ceil + * @returns {vec3} out + */ +export function ceil(out, a) { + out[0] = Math.ceil(a[0]); + out[1] = Math.ceil(a[1]); + out[2] = Math.ceil(a[2]); + return out; +} + +/** + * Math.floor the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to floor + * @returns {vec3} out + */ +export function floor(out, a) { + out[0] = Math.floor(a[0]); + out[1] = Math.floor(a[1]); + out[2] = Math.floor(a[2]); + return out; +} + +/** + * Returns the minimum of two vec3's + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {vec3} out + */ +export function min(out, a, b) { + out[0] = Math.min(a[0], b[0]); + out[1] = Math.min(a[1], b[1]); + out[2] = Math.min(a[2], b[2]); + return out; +} + +/** + * Returns the maximum of two vec3's + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {vec3} out + */ +export function max(out, a, b) { + out[0] = Math.max(a[0], b[0]); + out[1] = Math.max(a[1], b[1]); + out[2] = Math.max(a[2], b[2]); + return out; +} + +/** + * Math.round the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to round + * @returns {vec3} out + */ +export function round(out, a) { + out[0] = Math.round(a[0]); + out[1] = Math.round(a[1]); + out[2] = Math.round(a[2]); + return out; +} + +/** + * Scales a vec3 by a scalar number + * + * @param {vec3} out the receiving vector + * @param {vec3} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {vec3} out + */ +export function scale(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + return out; +} + +/** + * Adds two vec3's after scaling the second operand by a scalar value + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @param {Number} scale the amount to scale b by before adding + * @returns {vec3} out + */ +export function scaleAndAdd(out, a, b, scale) { + out[0] = a[0] + (b[0] * scale); + out[1] = a[1] + (b[1] * scale); + out[2] = a[2] + (b[2] * scale); + return out; +} + +/** + * Calculates the euclidian distance between two vec3's + * + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {Number} distance between a and b + */ +export function distance(a, b) { + let x = b[0] - a[0]; + let y = b[1] - a[1]; + let z = b[2] - a[2]; + return Math.sqrt(x*x + y*y + z*z); +} + +/** + * Calculates the squared euclidian distance between two vec3's + * + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {Number} squared distance between a and b + */ +export function squaredDistance(a, b) { + let x = b[0] - a[0]; + let y = b[1] - a[1]; + let z = b[2] - a[2]; + return x*x + y*y + z*z; +} + +/** + * Calculates the squared length of a vec3 + * + * @param {vec3} a vector to calculate squared length of + * @returns {Number} squared length of a + */ +export function squaredLength(a) { + let x = a[0]; + let y = a[1]; + let z = a[2]; + return x*x + y*y + z*z; +} + +/** + * Negates the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to negate + * @returns {vec3} out + */ +export function negate(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; + return out; +} + +/** + * Returns the inverse of the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to invert + * @returns {vec3} out + */ +export function inverse(out, a) { + out[0] = 1.0 / a[0]; + out[1] = 1.0 / a[1]; + out[2] = 1.0 / a[2]; + return out; +} + +/** + * Normalize a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to normalize + * @returns {vec3} out + */ +export function normalize(out, a) { + let x = a[0]; + let y = a[1]; + let z = a[2]; + let len = x*x + y*y + z*z; + if (len > 0) { + //TODO: evaluate use of glm_invsqrt here? + len = 1 / Math.sqrt(len); + out[0] = a[0] * len; + out[1] = a[1] * len; + out[2] = a[2] * len; + } + return out; +} + +/** + * Calculates the dot product of two vec3's + * + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {Number} dot product of a and b + */ +export function dot(a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; +} + +/** + * Computes the cross product of two vec3's + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {vec3} out + */ +export function cross(out, a, b) { + let ax = a[0], ay = a[1], az = a[2]; + let bx = b[0], by = b[1], bz = b[2]; + + out[0] = ay * bz - az * by; + out[1] = az * bx - ax * bz; + out[2] = ax * by - ay * bx; + return out; +} + +/** + * Performs a linear interpolation between two vec3's + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {vec3} out + */ +export function lerp(out, a, b, t) { + let ax = a[0]; + let ay = a[1]; + let az = a[2]; + out[0] = ax + t * (b[0] - ax); + out[1] = ay + t * (b[1] - ay); + out[2] = az + t * (b[2] - az); + return out; +} + +/** + * Performs a hermite interpolation with two control points + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @param {vec3} c the third operand + * @param {vec3} d the fourth operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {vec3} out + */ +export function hermite(out, a, b, c, d, t) { + let factorTimes2 = t * t; + let factor1 = factorTimes2 * (2 * t - 3) + 1; + let factor2 = factorTimes2 * (t - 2) + t; + let factor3 = factorTimes2 * (t - 1); + let factor4 = factorTimes2 * (3 - 2 * t); + + out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; + out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; + out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; + + return out; +} + +/** + * Performs a bezier interpolation with two control points + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @param {vec3} c the third operand + * @param {vec3} d the fourth operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {vec3} out + */ +export function bezier(out, a, b, c, d, t) { + let inverseFactor = 1 - t; + let inverseFactorTimesTwo = inverseFactor * inverseFactor; + let factorTimes2 = t * t; + let factor1 = inverseFactorTimesTwo * inverseFactor; + let factor2 = 3 * t * inverseFactorTimesTwo; + let factor3 = 3 * factorTimes2 * inverseFactor; + let factor4 = factorTimes2 * t; + + out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; + out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; + out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; + + return out; +} + +/** + * Generates a random vector with the given scale + * + * @param {vec3} out the receiving vector + * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned + * @returns {vec3} out + */ +export function random(out, scale) { + scale = scale || 1.0; + + let r = glMatrix.RANDOM() * 2.0 * Math.PI; + let z = (glMatrix.RANDOM() * 2.0) - 1.0; + let zScale = Math.sqrt(1.0-z*z) * scale; + + out[0] = Math.cos(r) * zScale; + out[1] = Math.sin(r) * zScale; + out[2] = z * scale; + return out; +} + +/** + * Transforms the vec3 with a mat4. + * 4th vector component is implicitly '1' + * + * @param {vec3} out the receiving vector + * @param {vec3} a the vector to transform + * @param {mat4} m matrix to transform with + * @returns {vec3} out + */ +export function transformMat4(out, a, m) { + let x = a[0], y = a[1], z = a[2]; + let w = m[3] * x + m[7] * y + m[11] * z + m[15]; + w = w || 1.0; + out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w; + out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w; + out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w; + return out; +} + +/** + * Transforms the vec3 with a mat3. + * + * @param {vec3} out the receiving vector + * @param {vec3} a the vector to transform + * @param {mat3} m the 3x3 matrix to transform with + * @returns {vec3} out + */ +export function transformMat3(out, a, m) { + let x = a[0], y = a[1], z = a[2]; + out[0] = x * m[0] + y * m[3] + z * m[6]; + out[1] = x * m[1] + y * m[4] + z * m[7]; + out[2] = x * m[2] + y * m[5] + z * m[8]; + return out; +} + +/** + * Transforms the vec3 with a quat + * Can also be used for dual quaternions. (Multiply it with the real part) + * + * @param {vec3} out the receiving vector + * @param {vec3} a the vector to transform + * @param {quat} q quaternion to transform with + * @returns {vec3} out + */ +export function transformQuat(out, a, q) { + // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed + let qx = q[0], qy = q[1], qz = q[2], qw = q[3]; + let x = a[0], y = a[1], z = a[2]; + // var qvec = [qx, qy, qz]; + // var uv = vec3.cross([], qvec, a); + let uvx = qy * z - qz * y, + uvy = qz * x - qx * z, + uvz = qx * y - qy * x; + // var uuv = vec3.cross([], qvec, uv); + let uuvx = qy * uvz - qz * uvy, + uuvy = qz * uvx - qx * uvz, + uuvz = qx * uvy - qy * uvx; + // vec3.scale(uv, uv, 2 * w); + let w2 = qw * 2; + uvx *= w2; + uvy *= w2; + uvz *= w2; + // vec3.scale(uuv, uuv, 2); + uuvx *= 2; + uuvy *= 2; + uuvz *= 2; + // return vec3.add(out, a, vec3.add(out, uv, uuv)); + out[0] = x + uvx + uuvx; + out[1] = y + uvy + uuvy; + out[2] = z + uvz + uuvz; + return out; +} + +/** + * Rotate a 3D vector around the x-axis + * @param {vec3} out The receiving vec3 + * @param {vec3} a The vec3 point to rotate + * @param {vec3} b The origin of the rotation + * @param {Number} c The angle of rotation + * @returns {vec3} out + */ +export function rotateX(out, a, b, c){ + let p = [], r=[]; + //Translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; + + //perform rotation + r[0] = p[0]; + r[1] = p[1]*Math.cos(c) - p[2]*Math.sin(c); + r[2] = p[1]*Math.sin(c) + p[2]*Math.cos(c); + + //translate to correct position + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; + + return out; +} + +/** + * Rotate a 3D vector around the y-axis + * @param {vec3} out The receiving vec3 + * @param {vec3} a The vec3 point to rotate + * @param {vec3} b The origin of the rotation + * @param {Number} c The angle of rotation + * @returns {vec3} out + */ +export function rotateY(out, a, b, c){ + let p = [], r=[]; + //Translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; + + //perform rotation + r[0] = p[2]*Math.sin(c) + p[0]*Math.cos(c); + r[1] = p[1]; + r[2] = p[2]*Math.cos(c) - p[0]*Math.sin(c); + + //translate to correct position + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; + + return out; +} + +/** + * Rotate a 3D vector around the z-axis + * @param {vec3} out The receiving vec3 + * @param {vec3} a The vec3 point to rotate + * @param {vec3} b The origin of the rotation + * @param {Number} c The angle of rotation + * @returns {vec3} out + */ +export function rotateZ(out, a, b, c){ + let p = [], r=[]; + //Translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; + + //perform rotation + r[0] = p[0]*Math.cos(c) - p[1]*Math.sin(c); + r[1] = p[0]*Math.sin(c) + p[1]*Math.cos(c); + r[2] = p[2]; + + //translate to correct position + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; + + return out; +} + +/** + * Get the angle between two 3D vectors + * @param {vec3} a The first operand + * @param {vec3} b The second operand + * @returns {Number} The angle in radians + */ +export function angle(a, b) { + let tempA = fromValues(a[0], a[1], a[2]); + let tempB = fromValues(b[0], b[1], b[2]); + + normalize(tempA, tempA); + normalize(tempB, tempB); + + let cosine = dot(tempA, tempB); + + if(cosine > 1.0) { + return 0; + } + else if(cosine < -1.0) { + return Math.PI; + } else { + return Math.acos(cosine); + } +} + +/** + * Returns a string representation of a vector + * + * @param {vec3} a vector to represent as a string + * @returns {String} string representation of the vector + */ +export function str(a) { + return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')'; +} + +/** + * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) + * + * @param {vec3} a The first vector. + * @param {vec3} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ +export function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2]; +} + +/** + * Returns whether or not the vectors have approximately the same elements in the same position. + * + * @param {vec3} a The first vector. + * @param {vec3} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ +export function equals(a, b) { + let a0 = a[0], a1 = a[1], a2 = a[2]; + let b0 = b[0], b1 = b[1], b2 = b[2]; + return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && + Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && + Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2))); +} + +/** + * Alias for {@link vec3.subtract} + * @function + */ +export const sub = subtract; + +/** + * Alias for {@link vec3.multiply} + * @function + */ +export const mul = multiply; + +/** + * Alias for {@link vec3.divide} + * @function + */ +export const div = divide; + +/** + * Alias for {@link vec3.distance} + * @function + */ +export const dist = distance; + +/** + * Alias for {@link vec3.squaredDistance} + * @function + */ +export const sqrDist = squaredDistance; + +/** + * Alias for {@link vec3.length} + * @function + */ +export const len = length; + +/** + * Alias for {@link vec3.squaredLength} + * @function + */ +export const sqrLen = squaredLength; + +/** + * Perform some operation over an array of vec3s. + * + * @param {Array} a the array of vectors to iterate over + * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed + * @param {Number} offset Number of elements to skip at the beginning of the array + * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array + * @param {Function} fn Function to call for each vector in the array + * @param {Object} [arg] additional argument to pass to fn + * @returns {Array} a + * @function + */ +export const forEach = (function() { + let vec = create(); + + return function(a, stride, offset, count, fn, arg) { + let i, l; + if(!stride) { + stride = 3; + } + + if(!offset) { + offset = 0; + } + + if(count) { + l = Math.min((count * stride) + offset, a.length); + } else { + l = a.length; + } + + for(i = offset; i < l; i += stride) { + vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2]; + fn(vec, vec, arg); + a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2]; + } + + return a; + }; +})(); diff --git a/js/third-party/gl-matrix/src/gl-matrix/vec4.js b/js/third-party/gl-matrix/src/gl-matrix/vec4.js new file mode 100644 index 000000000..147b60e72 --- /dev/null +++ b/js/third-party/gl-matrix/src/gl-matrix/vec4.js @@ -0,0 +1,602 @@ +import * as glMatrix from "./common.js"; + +/** + * 4 Dimensional Vector + * @module vec4 + */ + +/** + * Creates a new, empty vec4 + * + * @returns {vec4} a new 4D vector + */ +export function create() { + let out = new glMatrix.ARRAY_TYPE(4); + if(glMatrix.ARRAY_TYPE != Float32Array) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 0; + } + return out; +} + +/** + * Creates a new vec4 initialized with values from an existing vector + * + * @param {vec4} a vector to clone + * @returns {vec4} a new 4D vector + */ +export function clone(a) { + let out = new glMatrix.ARRAY_TYPE(4); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; +} + +/** + * Creates a new vec4 initialized with the given values + * + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {vec4} a new 4D vector + */ +export function fromValues(x, y, z, w) { + let out = new glMatrix.ARRAY_TYPE(4); + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = w; + return out; +} + +/** + * Copy the values from one vec4 to another + * + * @param {vec4} out the receiving vector + * @param {vec4} a the source vector + * @returns {vec4} out + */ +export function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; +} + +/** + * Set the components of a vec4 to the given values + * + * @param {vec4} out the receiving vector + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {vec4} out + */ +export function set(out, x, y, z, w) { + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = w; + return out; +} + +/** + * Adds two vec4's + * + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {vec4} out + */ +export function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + return out; +} + +/** + * Subtracts vector b from vector a + * + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {vec4} out + */ +export function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; + return out; +} + +/** + * Multiplies two vec4's + * + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {vec4} out + */ +export function multiply(out, a, b) { + out[0] = a[0] * b[0]; + out[1] = a[1] * b[1]; + out[2] = a[2] * b[2]; + out[3] = a[3] * b[3]; + return out; +} + +/** + * Divides two vec4's + * + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {vec4} out + */ +export function divide(out, a, b) { + out[0] = a[0] / b[0]; + out[1] = a[1] / b[1]; + out[2] = a[2] / b[2]; + out[3] = a[3] / b[3]; + return out; +} + +/** + * Math.ceil the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {vec4} a vector to ceil + * @returns {vec4} out + */ +export function ceil(out, a) { + out[0] = Math.ceil(a[0]); + out[1] = Math.ceil(a[1]); + out[2] = Math.ceil(a[2]); + out[3] = Math.ceil(a[3]); + return out; +} + +/** + * Math.floor the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {vec4} a vector to floor + * @returns {vec4} out + */ +export function floor(out, a) { + out[0] = Math.floor(a[0]); + out[1] = Math.floor(a[1]); + out[2] = Math.floor(a[2]); + out[3] = Math.floor(a[3]); + return out; +} + +/** + * Returns the minimum of two vec4's + * + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {vec4} out + */ +export function min(out, a, b) { + out[0] = Math.min(a[0], b[0]); + out[1] = Math.min(a[1], b[1]); + out[2] = Math.min(a[2], b[2]); + out[3] = Math.min(a[3], b[3]); + return out; +} + +/** + * Returns the maximum of two vec4's + * + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {vec4} out + */ +export function max(out, a, b) { + out[0] = Math.max(a[0], b[0]); + out[1] = Math.max(a[1], b[1]); + out[2] = Math.max(a[2], b[2]); + out[3] = Math.max(a[3], b[3]); + return out; +} + +/** + * Math.round the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {vec4} a vector to round + * @returns {vec4} out + */ +export function round(out, a) { + out[0] = Math.round(a[0]); + out[1] = Math.round(a[1]); + out[2] = Math.round(a[2]); + out[3] = Math.round(a[3]); + return out; +} + +/** + * Scales a vec4 by a scalar number + * + * @param {vec4} out the receiving vector + * @param {vec4} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {vec4} out + */ +export function scale(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + return out; +} + +/** + * Adds two vec4's after scaling the second operand by a scalar value + * + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @param {Number} scale the amount to scale b by before adding + * @returns {vec4} out + */ +export function scaleAndAdd(out, a, b, scale) { + out[0] = a[0] + (b[0] * scale); + out[1] = a[1] + (b[1] * scale); + out[2] = a[2] + (b[2] * scale); + out[3] = a[3] + (b[3] * scale); + return out; +} + +/** + * Calculates the euclidian distance between two vec4's + * + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {Number} distance between a and b + */ +export function distance(a, b) { + let x = b[0] - a[0]; + let y = b[1] - a[1]; + let z = b[2] - a[2]; + let w = b[3] - a[3]; + return Math.sqrt(x*x + y*y + z*z + w*w); +} + +/** + * Calculates the squared euclidian distance between two vec4's + * + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {Number} squared distance between a and b + */ +export function squaredDistance(a, b) { + let x = b[0] - a[0]; + let y = b[1] - a[1]; + let z = b[2] - a[2]; + let w = b[3] - a[3]; + return x*x + y*y + z*z + w*w; +} + +/** + * Calculates the length of a vec4 + * + * @param {vec4} a vector to calculate length of + * @returns {Number} length of a + */ +export function length(a) { + let x = a[0]; + let y = a[1]; + let z = a[2]; + let w = a[3]; + return Math.sqrt(x*x + y*y + z*z + w*w); +} + +/** + * Calculates the squared length of a vec4 + * + * @param {vec4} a vector to calculate squared length of + * @returns {Number} squared length of a + */ +export function squaredLength(a) { + let x = a[0]; + let y = a[1]; + let z = a[2]; + let w = a[3]; + return x*x + y*y + z*z + w*w; +} + +/** + * Negates the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {vec4} a vector to negate + * @returns {vec4} out + */ +export function negate(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; + out[3] = -a[3]; + return out; +} + +/** + * Returns the inverse of the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {vec4} a vector to invert + * @returns {vec4} out + */ +export function inverse(out, a) { + out[0] = 1.0 / a[0]; + out[1] = 1.0 / a[1]; + out[2] = 1.0 / a[2]; + out[3] = 1.0 / a[3]; + return out; +} + +/** + * Normalize a vec4 + * + * @param {vec4} out the receiving vector + * @param {vec4} a vector to normalize + * @returns {vec4} out + */ +export function normalize(out, a) { + let x = a[0]; + let y = a[1]; + let z = a[2]; + let w = a[3]; + let len = x*x + y*y + z*z + w*w; + if (len > 0) { + len = 1 / Math.sqrt(len); + out[0] = x * len; + out[1] = y * len; + out[2] = z * len; + out[3] = w * len; + } + return out; +} + +/** + * Calculates the dot product of two vec4's + * + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {Number} dot product of a and b + */ +export function dot(a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; +} + +/** + * Performs a linear interpolation between two vec4's + * + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {vec4} out + */ +export function lerp(out, a, b, t) { + let ax = a[0]; + let ay = a[1]; + let az = a[2]; + let aw = a[3]; + out[0] = ax + t * (b[0] - ax); + out[1] = ay + t * (b[1] - ay); + out[2] = az + t * (b[2] - az); + out[3] = aw + t * (b[3] - aw); + return out; +} + +/** + * Generates a random vector with the given scale + * + * @param {vec4} out the receiving vector + * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned + * @returns {vec4} out + */ +export function random(out, scale) { + scale = scale || 1.0; + + // Marsaglia, George. Choosing a Point from the Surface of a + // Sphere. Ann. Math. Statist. 43 (1972), no. 2, 645--646. + // http://projecteuclid.org/euclid.aoms/1177692644; + var v1, v2, v3, v4; + var s1, s2; + do { + v1 = glMatrix.RANDOM() * 2 - 1; + v2 = glMatrix.RANDOM() * 2 - 1; + s1 = v1 * v1 + v2 * v2; + } while (s1 >= 1); + do { + v3 = glMatrix.RANDOM() * 2 - 1; + v4 = glMatrix.RANDOM() * 2 - 1; + s2 = v3 * v3 + v4 * v4; + } while (s2 >= 1); + + var d = Math.sqrt((1 - s1) / s2); + out[0] = scale * v1; + out[1] = scale * v2; + out[2] = scale * v3 * d; + out[3] = scale * v4 * d; + return out; +} + +/** + * Transforms the vec4 with a mat4. + * + * @param {vec4} out the receiving vector + * @param {vec4} a the vector to transform + * @param {mat4} m matrix to transform with + * @returns {vec4} out + */ +export function transformMat4(out, a, m) { + let x = a[0], y = a[1], z = a[2], w = a[3]; + out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w; + out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w; + out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w; + out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w; + return out; +} + +/** + * Transforms the vec4 with a quat + * + * @param {vec4} out the receiving vector + * @param {vec4} a the vector to transform + * @param {quat} q quaternion to transform with + * @returns {vec4} out + */ +export function transformQuat(out, a, q) { + let x = a[0], y = a[1], z = a[2]; + let qx = q[0], qy = q[1], qz = q[2], qw = q[3]; + + // calculate quat * vec + let ix = qw * x + qy * z - qz * y; + let iy = qw * y + qz * x - qx * z; + let iz = qw * z + qx * y - qy * x; + let iw = -qx * x - qy * y - qz * z; + + // calculate result * inverse quat + out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy; + out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz; + out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx; + out[3] = a[3]; + return out; +} + +/** + * Returns a string representation of a vector + * + * @param {vec4} a vector to represent as a string + * @returns {String} string representation of the vector + */ +export function str(a) { + return 'vec4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')'; +} + +/** + * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) + * + * @param {vec4} a The first vector. + * @param {vec4} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ +export function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; +} + +/** + * Returns whether or not the vectors have approximately the same elements in the same position. + * + * @param {vec4} a The first vector. + * @param {vec4} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ +export function equals(a, b) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && + Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && + Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && + Math.abs(a3 - b3) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a3), Math.abs(b3))); +} + +/** + * Alias for {@link vec4.subtract} + * @function + */ +export const sub = subtract; + +/** + * Alias for {@link vec4.multiply} + * @function + */ +export const mul = multiply; + +/** + * Alias for {@link vec4.divide} + * @function + */ +export const div = divide; + +/** + * Alias for {@link vec4.distance} + * @function + */ +export const dist = distance; + +/** + * Alias for {@link vec4.squaredDistance} + * @function + */ +export const sqrDist = squaredDistance; + +/** + * Alias for {@link vec4.length} + * @function + */ +export const len = length; + +/** + * Alias for {@link vec4.squaredLength} + * @function + */ +export const sqrLen = squaredLength; + +/** + * Perform some operation over an array of vec4s. + * + * @param {Array} a the array of vectors to iterate over + * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed + * @param {Number} offset Number of elements to skip at the beginning of the array + * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array + * @param {Function} fn Function to call for each vector in the array + * @param {Object} [arg] additional argument to pass to fn + * @returns {Array} a + * @function + */ +export const forEach = (function() { + let vec = create(); + + return function(a, stride, offset, count, fn, arg) { + let i, l; + if(!stride) { + stride = 4; + } + + if(!offset) { + offset = 0; + } + + if(count) { + l = Math.min((count * stride) + offset, a.length); + } else { + l = a.length; + } + + for(i = offset; i < l; i += stride) { + vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2]; vec[3] = a[i+3]; + fn(vec, vec, arg); + a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2]; a[i+3] = vec[3]; + } + + return a; + }; +})(); diff --git a/js/third-party/webxr-polyfill/LICENSE b/js/third-party/webxr-polyfill/LICENSE new file mode 100644 index 000000000..ef0602569 --- /dev/null +++ b/js/third-party/webxr-polyfill/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2017 Google Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/js/webxr-polyfill.js b/js/third-party/webxr-polyfill/build/webxr-polyfill.module.js similarity index 51% rename from js/webxr-polyfill.js rename to js/third-party/webxr-polyfill/build/webxr-polyfill.module.js index 047e689bd..5159dbda7 100644 --- a/js/webxr-polyfill.js +++ b/js/third-party/webxr-polyfill/build/webxr-polyfill.module.js @@ -97,239 +97,153 @@ * THE SOFTWARE. */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global.WebXRPolyfill = factory()); -}(this, (function () { 'use strict'; - -var _global = typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : {}; +const _global = typeof global !== 'undefined' ? global : + typeof self !== 'undefined' ? self : + typeof window !== 'undefined' ? window : {}; -var classCallCheck = function (instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); +const PRIVATE = Symbol('@@webxr-polyfill/EventTarget'); +class EventTarget { + constructor() { + this[PRIVATE] = { + listeners: new Map(), + }; } -}; - -var createClass = function () { - function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); + addEventListener(type, listener) { + if (typeof type !== 'string') { throw new Error('`type` must be a string'); } + if (typeof listener !== 'function') { throw new Error('`listener` must be a function'); } + const typedListeners = this[PRIVATE].listeners.get(type) || []; + typedListeners.push(listener); + this[PRIVATE].listeners.set(type, typedListeners); + } + removeEventListener(type, listener) { + if (typeof type !== 'string') { throw new Error('`type` must be a string'); } + if (typeof listener !== 'function') { throw new Error('`listener` must be a function'); } + const typedListeners = this[PRIVATE].listeners.get(type) || []; + for (let i = typedListeners.length; i >= 0; i--) { + if (typedListeners[i] === listener) { + typedListeners.pop(); + } } } - - return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps); - if (staticProps) defineProperties(Constructor, staticProps); - return Constructor; - }; -}(); - - - - - - - - - -var inherits = function (subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - enumerable: false, - writable: true, - configurable: true + dispatchEvent(type, event) { + const typedListeners = this[PRIVATE].listeners.get(type) || []; + const queue = []; + for (let i = 0; i < typedListeners.length; i++) { + queue[i] = typedListeners[i]; + } + for (let listener of queue) { + listener(event); + } + if (typeof this[`on${type}`] === 'function') { + this[`on${type}`](event); } - }); - if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; -}; - - - - - - - - - - - -var possibleConstructorReturn = function (self, call) { - if (!self) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } +} - return call && (typeof call === "object" || typeof call === "function") ? call : self; -}; - -var PRIVATE = Symbol('@@webxr-polyfill/EventTarget'); -var EventTarget = function () { - function EventTarget() { - classCallCheck(this, EventTarget); - this[PRIVATE] = { - listeners: new Map() +const PRIVATE$1 = Symbol('@@webxr-polyfill/XR'); +const XRSessionModes = ['inline', 'immersive-vr', 'immersive-ar']; +const POLYFILL_REQUEST_SESSION_ERROR = +`Polyfill Error: Must call navigator.xr.supportsSession() with any XRSessionMode +or navigator.xr.requestSession('inline') prior to requesting an immersive +session. This is a limitation specific to the WebXR Polyfill and does not apply +to native implementations of the API.`; +class XR$1 extends EventTarget { + constructor(devicePromise) { + super(); + this[PRIVATE$1] = { + device: null, + devicePromise, + immersiveSession: null, + inlineSessions: new Set(), }; + devicePromise.then((device) => { this[PRIVATE$1].device = device; }); } - createClass(EventTarget, [{ - key: 'addEventListener', - value: function addEventListener(type, listener) { - if (typeof type !== 'string') { - throw new Error('`type` must be a string'); - } - if (typeof listener !== 'function') { - throw new Error('`listener` must be a function'); - } - var typedListeners = this[PRIVATE].listeners.get(type) || []; - typedListeners.push(listener); - this[PRIVATE].listeners.set(type, typedListeners); + async supportsSession(mode) { + if (!this[PRIVATE$1].device) { + await this[PRIVATE$1].devicePromise; } - }, { - key: 'removeEventListener', - value: function removeEventListener(type, listener) { - if (typeof type !== 'string') { - throw new Error('`type` must be a string'); - } - if (typeof listener !== 'function') { - throw new Error('`listener` must be a function'); - } - var typedListeners = this[PRIVATE].listeners.get(type) || []; - for (var i = typedListeners.length; i >= 0; i--) { - if (typedListeners[i] === listener) { - typedListeners.pop(); - } + if (mode != 'inline') { + if (!this[PRIVATE$1].device.supportsSession(mode)) { + return Promise.reject(null); } } - }, { - key: 'dispatchEvent', - value: function dispatchEvent(type, event) { - var typedListeners = this[PRIVATE].listeners.get(type) || []; - var queue = []; - for (var i = 0; i < typedListeners.length; i++) { - queue[i] = typedListeners[i]; - } - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - try { - for (var _iterator = queue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var listener = _step.value; - listener(event); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - if (typeof this['on' + type] === 'function') { - this['on' + type](event); + return Promise.resolve(null); + } + async requestSession(mode) { + if (!this[PRIVATE$1].device) { + if (mode != 'inline') { + throw new Error(POLYFILL_REQUEST_SESSION_ERROR); + } else { + await this[PRIVATE$1].devicePromise; } } - }]); - return EventTarget; -}(); - -var PRIVATE$1 = Symbol('@@webxr-polyfill/XR'); -var XR = function (_EventTarget) { - inherits(XR, _EventTarget); - function XR(device) { - classCallCheck(this, XR); - var _this = possibleConstructorReturn(this, (XR.__proto__ || Object.getPrototypeOf(XR)).call(this)); - _this[PRIVATE$1] = { - device: device - }; - return _this; - } - createClass(XR, [{ - key: 'requestDevice', - value: function requestDevice() { - return new Promise(function ($return, $error) { - var device; - return Promise.resolve(this[PRIVATE$1].device).then(function ($await_1) { - try { - device = $await_1; - if (device) { - return $return(device); - } - return $error(new Error('NotFoundError')); - } catch ($boundEx) { - return $error($boundEx); - } - }.bind(this), $error); - }.bind(this)); + const sessionId = await this[PRIVATE$1].device.requestSession(mode); + const session = new XRSession(this[PRIVATE$1].device, mode, sessionId); + if (mode == 'inline') { + this[PRIVATE$1].inlineSessions.add(session); + } else { + this[PRIVATE$1].immersiveSession = session; } - }]); - return XR; -}(EventTarget); + const onSessionEnd = () => { + if (mode == 'inline') { + this[PRIVATE$1].inlineSessions.delete(session); + } else { + this[PRIVATE$1].immersiveSession = null; + } + session.removeEventListener('end', onSessionEnd); + }; + session.addEventListener('end', onSessionEnd); + return session; + } +} -var now = void 0; +let now; if ('performance' in _global === false) { - var startTime = Date.now(); - now = function now() { - return Date.now() - startTime; - }; + let startTime = Date.now(); + now = () => Date.now() - startTime; } else { - now = function now() { - return performance.now(); - }; + now = () => performance.now(); } var now$1 = now; -var PRIVATE$2 = Symbol('@@webxr-polyfill/XRPresentationContext'); -var XRPresentationContext = function () { - function XRPresentationContext(canvas, ctx, glAttribs) { - classCallCheck(this, XRPresentationContext); - this[PRIVATE$2] = { canvas: canvas, ctx: ctx, glAttribs: glAttribs }; - Object.assign(this, ctx); +const PRIVATE$2 = Symbol('@@webxr-polyfill/XRPose'); +class XRPose$1 { + constructor(transform, emulatedPosition) { + this[PRIVATE$2] = { + transform, + emulatedPosition, + }; } - createClass(XRPresentationContext, [{ - key: 'canvas', - get: function get$$1() { - return this[PRIVATE$2].canvas; - } - }]); - return XRPresentationContext; -}(); + get transform() { return this[PRIVATE$2].transform; } + get emulatedPosition() { return this[PRIVATE$2].emulatedPosition; } + _setTransform(transform) { this[PRIVATE$2].transform = transform; } +} -var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array; +const EPSILON = 0.000001; +let ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array; -var degree = Math.PI / 180; +const degree = Math.PI / 180; function create() { - var out = new ARRAY_TYPE(16); + let out = new ARRAY_TYPE(16); + if(ARRAY_TYPE != Float32Array) { + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + } out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; out[10] = 1; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; out[15] = 1; return out; } @@ -376,35 +290,23 @@ function identity(out) { } function invert(out, a) { - var a00 = a[0], - a01 = a[1], - a02 = a[2], - a03 = a[3]; - var a10 = a[4], - a11 = a[5], - a12 = a[6], - a13 = a[7]; - var a20 = a[8], - a21 = a[9], - a22 = a[10], - a23 = a[11]; - var a30 = a[12], - a31 = a[13], - a32 = a[14], - a33 = a[15]; - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; - var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + let b00 = a00 * a11 - a01 * a10; + let b01 = a00 * a12 - a02 * a10; + let b02 = a00 * a13 - a03 * a10; + let b03 = a01 * a12 - a02 * a11; + let b04 = a01 * a13 - a03 * a11; + let b05 = a02 * a13 - a03 * a12; + let b06 = a20 * a31 - a21 * a30; + let b07 = a20 * a32 - a22 * a30; + let b08 = a20 * a33 - a23 * a30; + let b09 = a21 * a32 - a22 * a31; + let b10 = a21 * a33 - a23 * a31; + let b11 = a22 * a33 - a23 * a32; + let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; if (!det) { return null; } @@ -430,45 +332,30 @@ function invert(out, a) { function multiply(out, a, b) { - var a00 = a[0], - a01 = a[1], - a02 = a[2], - a03 = a[3]; - var a10 = a[4], - a11 = a[5], - a12 = a[6], - a13 = a[7]; - var a20 = a[8], - a21 = a[9], - a22 = a[10], - a23 = a[11]; - var a30 = a[12], - a31 = a[13], - a32 = a[14], - a33 = a[15]; - var b0 = b[0], - b1 = b[1], - b2 = b[2], - b3 = b[3]; - out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - b0 = b[4];b1 = b[5];b2 = b[6];b3 = b[7]; - out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - b0 = b[8];b1 = b[9];b2 = b[10];b3 = b[11]; - out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - b0 = b[12];b1 = b[13];b2 = b[14];b3 = b[15]; - out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + out[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[3] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + b0 = b[4]; b1 = b[5]; b2 = b[6]; b3 = b[7]; + out[4] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[5] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[6] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[7] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + b0 = b[8]; b1 = b[9]; b2 = b[10]; b3 = b[11]; + out[8] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[9] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[10] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[11] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + b0 = b[12]; b1 = b[13]; b2 = b[14]; b3 = b[15]; + out[12] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[13] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[14] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33; return out; } @@ -484,22 +371,19 @@ function multiply(out, a, b) { function fromRotationTranslation(out, q, v) { - var x = q[0], - y = q[1], - z = q[2], - w = q[3]; - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; + let x = q[0], y = q[1], z = q[2], w = q[3]; + let x2 = x + x; + let y2 = y + y; + let z2 = z + z; + let xx = x * x2; + let xy = x * y2; + let xz = x * z2; + let yy = y * y2; + let yz = y * z2; + let zz = z * z2; + let wx = w * x2; + let wy = w * y2; + let wz = w * z2; out[0] = 1 - (yy + zz); out[1] = xy + wz; out[2] = xz - wy; @@ -527,15 +411,15 @@ function getTranslation(out, mat) { } function getRotation(out, mat) { - var trace = mat[0] + mat[5] + mat[10]; - var S = 0; + let trace = mat[0] + mat[5] + mat[10]; + let S = 0; if (trace > 0) { S = Math.sqrt(trace + 1.0) * 2; out[3] = 0.25 * S; out[0] = (mat[6] - mat[9]) / S; out[1] = (mat[8] - mat[2]) / S; out[2] = (mat[1] - mat[4]) / S; - } else if (mat[0] > mat[5] && mat[0] > mat[10]) { + } else if ((mat[0] > mat[5]) && (mat[0] > mat[10])) { S = Math.sqrt(1.0 + mat[0] - mat[5] - mat[10]) * 2; out[3] = (mat[6] - mat[9]) / S; out[0] = 0.25 * S; @@ -561,8 +445,7 @@ function getRotation(out, mat) { function perspective(out, fovy, aspect, near, far) { - var f = 1.0 / Math.tan(fovy / 2); - var nf = 1 / (near - far); + let f = 1.0 / Math.tan(fovy / 2), nf; out[0] = f / aspect; out[1] = 0; out[2] = 0; @@ -573,998 +456,987 @@ function perspective(out, fovy, aspect, near, far) { out[7] = 0; out[8] = 0; out[9] = 0; - out[10] = (far + near) * nf; out[11] = -1; out[12] = 0; out[13] = 0; - out[14] = 2 * far * near * nf; out[15] = 0; + if (far != null && far !== Infinity) { + nf = 1 / (near - far); + out[10] = (far + near) * nf; + out[14] = (2 * far * near) * nf; + } else { + out[10] = -1; + out[14] = -2 * near; + } return out; } -var PRIVATE$3 = Symbol('@@webxr-polyfill/XRDevicePose'); -var XRDevicePose = function () { - function XRDevicePose(polyfill) { - classCallCheck(this, XRDevicePose); - this[PRIVATE$3] = { - polyfill: polyfill, - leftViewMatrix: identity(new Float32Array(16)), - rightViewMatrix: identity(new Float32Array(16)), - poseModelMatrix: identity(new Float32Array(16)) - }; +function create$1() { + let out = new ARRAY_TYPE(3); + if(ARRAY_TYPE != Float32Array) { + out[0] = 0; + out[1] = 0; + out[2] = 0; } - createClass(XRDevicePose, [{ - key: 'getViewMatrix', - value: function getViewMatrix(view) { - switch (view.eye) { - case 'left': - return this[PRIVATE$3].leftViewMatrix; - case 'right': - return this[PRIVATE$3].rightViewMatrix; - } - throw new Error('view is not a valid XREye'); - } - }, { - key: 'updateFromFrameOfReference', - value: function updateFromFrameOfReference(frameOfRef) { - var pose = this[PRIVATE$3].polyfill.getBasePoseMatrix(); - var leftViewMatrix = this[PRIVATE$3].polyfill.getBaseViewMatrix('left'); - var rightViewMatrix = this[PRIVATE$3].polyfill.getBaseViewMatrix('right'); - if (pose) { - frameOfRef.transformBasePoseMatrix(this[PRIVATE$3].poseModelMatrix, pose); - } - if (leftViewMatrix && rightViewMatrix) { - frameOfRef.transformBaseViewMatrix(this[PRIVATE$3].leftViewMatrix, leftViewMatrix, this[PRIVATE$3].poseModelMatrix); - frameOfRef.transformBaseViewMatrix(this[PRIVATE$3].rightViewMatrix, rightViewMatrix, this[PRIVATE$3].poseModelMatrix); - } - } - }, { - key: 'poseModelMatrix', - get: function get$$1() { - return this[PRIVATE$3].poseModelMatrix; - } - }]); - return XRDevicePose; -}(); + return out; +} +function clone$1(a) { + var out = new ARRAY_TYPE(3); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + return out; +} +function length(a) { + let x = a[0]; + let y = a[1]; + let z = a[2]; + return Math.sqrt(x*x + y*y + z*z); +} +function fromValues$1(x, y, z) { + let out = new ARRAY_TYPE(3); + out[0] = x; + out[1] = y; + out[2] = z; + return out; +} +function copy$1(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + return out; +} -var PRIVATE$4 = Symbol('@@webxr-polyfill/XRViewport'); -var XRViewport = function () { - function XRViewport(target) { - classCallCheck(this, XRViewport); - this[PRIVATE$4] = { target: target }; - } - createClass(XRViewport, [{ - key: 'x', - get: function get$$1() { - return this[PRIVATE$4].target.x; - } - }, { - key: 'y', - get: function get$$1() { - return this[PRIVATE$4].target.y; - } - }, { - key: 'width', - get: function get$$1() { - return this[PRIVATE$4].target.width; - } - }, { - key: 'height', - get: function get$$1() { - return this[PRIVATE$4].target.height; - } - }]); - return XRViewport; -}(); +function add$1(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + return out; +} -var XREyes = ['left', 'right']; -var PRIVATE$5 = Symbol('@@webxr-polyfill/XRView'); -var XRView = function () { - function XRView(polyfill, eye, sessionId) { - classCallCheck(this, XRView); - if (!XREyes.includes(eye)) { - throw new Error('XREye must be one of: ' + XREyes); - } - var temp = Object.create(null); - var viewport = new XRViewport(temp); - this[PRIVATE$5] = { - polyfill: polyfill, - eye: eye, - viewport: viewport, - temp: temp, - sessionId: sessionId - }; + + + + + + + +function scale$1(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + return out; +} + + + + + + +function normalize(out, a) { + let x = a[0]; + let y = a[1]; + let z = a[2]; + let len = x*x + y*y + z*z; + if (len > 0) { + len = 1 / Math.sqrt(len); + out[0] = a[0] * len; + out[1] = a[1] * len; + out[2] = a[2] * len; } - createClass(XRView, [{ - key: '_getViewport', - value: function _getViewport(layer) { - var viewport = this[PRIVATE$5].viewport; - if (this[PRIVATE$5].polyfill.getViewport(this[PRIVATE$5].sessionId, this.eye, layer, this[PRIVATE$5].temp)) { - return this[PRIVATE$5].viewport; - } - return undefined; - } - }, { - key: 'eye', - get: function get$$1() { - return this[PRIVATE$5].eye; - } - }, { - key: 'projectionMatrix', - get: function get$$1() { - return this[PRIVATE$5].polyfill.getProjectionMatrix(this.eye); - } - }]); - return XRView; -}(); + return out; +} +function dot(a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; +} +function cross(out, a, b) { + let ax = a[0], ay = a[1], az = a[2]; + let bx = b[0], by = b[1], bz = b[2]; + out[0] = ay * bz - az * by; + out[1] = az * bx - ax * bz; + out[2] = ax * by - ay * bx; + return out; +} -var PRIVATE$6 = Symbol('@@webxr-polyfill/XRFrame'); -var XRFrame = function () { - function XRFrame(polyfill, session, sessionId) { - classCallCheck(this, XRFrame); - var devicePose = new XRDevicePose(polyfill); - var views = [new XRView(polyfill, 'left', sessionId)]; - if (session.immersive) { - views.push(new XRView(polyfill, 'right', sessionId)); - } - this[PRIVATE$6] = { - polyfill: polyfill, - devicePose: devicePose, - views: views, - session: session - }; + + + + + +function transformQuat(out, a, q) { + let qx = q[0], qy = q[1], qz = q[2], qw = q[3]; + let x = a[0], y = a[1], z = a[2]; + let uvx = qy * z - qz * y, + uvy = qz * x - qx * z, + uvz = qx * y - qy * x; + let uuvx = qy * uvz - qz * uvy, + uuvy = qz * uvx - qx * uvz, + uuvz = qx * uvy - qy * uvx; + let w2 = qw * 2; + uvx *= w2; + uvy *= w2; + uvz *= w2; + uuvx *= 2; + uuvy *= 2; + uuvz *= 2; + out[0] = x + uvx + uuvx; + out[1] = y + uvy + uuvy; + out[2] = z + uvz + uuvz; + return out; +} + + + +function angle(a, b) { + let tempA = fromValues$1(a[0], a[1], a[2]); + let tempB = fromValues$1(b[0], b[1], b[2]); + normalize(tempA, tempA); + normalize(tempB, tempB); + let cosine = dot(tempA, tempB); + if(cosine > 1.0) { + return 0; + } + else if(cosine < -1.0) { + return Math.PI; + } else { + return Math.acos(cosine); } - createClass(XRFrame, [{ - key: 'getDevicePose', - value: function getDevicePose(coordinateSystem) { - this[PRIVATE$6].devicePose.updateFromFrameOfReference(coordinateSystem); - return this[PRIVATE$6].devicePose; +} + + + + + + + + +const len = length; + +const forEach = (function() { + let vec = create$1(); + return function(a, stride, offset, count, fn, arg) { + let i, l; + if(!stride) { + stride = 3; } - }, { - key: 'getInputPose', - value: function getInputPose(inputSource, coordinateSystem) { - return this[PRIVATE$6].polyfill.getInputPose(inputSource, coordinateSystem); + if(!offset) { + offset = 0; } - }, { - key: 'session', - get: function get$$1() { - return this[PRIVATE$6].session; + if(count) { + l = Math.min((count * stride) + offset, a.length); + } else { + l = a.length; } - }, { - key: 'views', - get: function get$$1() { - return this[PRIVATE$6].views; + for(i = offset; i < l; i += stride) { + vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2]; + fn(vec, vec, arg); + a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2]; } - }]); - return XRFrame; -}(); + return a; + }; +})(); -var PRIVATE$7 = Symbol('@@webxr-polyfill/XRStageBoundsPoint'); -var XRStageBoundsPoint = function () { - function XRStageBoundsPoint(x, z) { - classCallCheck(this, XRStageBoundsPoint); - this[PRIVATE$7] = { x: x, z: z }; +function create$2() { + let out = new ARRAY_TYPE(9); + if(ARRAY_TYPE != Float32Array) { + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; } - createClass(XRStageBoundsPoint, [{ - key: 'x', - get: function get$$1() { - return this[PRIVATE$7].x; - } - }, { - key: 'z', - get: function get$$1() { - return this[PRIVATE$7].z; - } - }]); - return XRStageBoundsPoint; -}(); + out[0] = 1; + out[4] = 1; + out[8] = 1; + return out; +} -var PRIVATE$8 = Symbol('@@webxr-polyfill/XRStageBounds'); -var XRStageBounds = function () { - function XRStageBounds(boundsData) { - classCallCheck(this, XRStageBounds); - var geometry = []; - for (var i = 0; i < boundsData.length; i += 2) { - geometry.push(new XRStageBoundsPoint(boundsData[i], boundsData[i + 1])); - } - this[PRIVATE$8] = { geometry: geometry }; +function create$3() { + let out = new ARRAY_TYPE(4); + if(ARRAY_TYPE != Float32Array) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 0; } - createClass(XRStageBounds, [{ - key: 'geometry', - get: function get$$1() { - return this[PRIVATE$8].geometry; - } - }]); - return XRStageBounds; -}(); + return out; +} +function clone$3(a) { + let out = new ARRAY_TYPE(4); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; +} +function fromValues$3(x, y, z, w) { + let out = new ARRAY_TYPE(4); + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = w; + return out; +} +function copy$3(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; +} + + + + + + + + + + + -var XRCoordinateSystem = function () { - function XRCoordinateSystem() { - classCallCheck(this, XRCoordinateSystem); + + + + + + +function normalize$1(out, a) { + let x = a[0]; + let y = a[1]; + let z = a[2]; + let w = a[3]; + let len = x*x + y*y + z*z + w*w; + if (len > 0) { + len = 1 / Math.sqrt(len); + out[0] = x * len; + out[1] = y * len; + out[2] = z * len; + out[3] = w * len; } - createClass(XRCoordinateSystem, [{ - key: 'getTransformTo', - value: function getTransformTo(other) { - throw new Error('Not yet supported'); - } - }]); - return XRCoordinateSystem; -}(); + return out; +} -var DEFAULT_EMULATION_HEIGHT = 1.6; -var PRIVATE$9 = Symbol('@@webxr-polyfill/XRFrameOfReference'); -var XRFrameOfReferenceTypes = ['head-model', 'eye-level', 'stage']; -var XRFrameOfReferenceOptions = Object.freeze({ - disableStageEmulation: false, - stageEmulationHeight: 0 -}); -var XRFrameOfReference = function (_XRCoordinateSystem) { - inherits(XRFrameOfReference, _XRCoordinateSystem); - function XRFrameOfReference(polyfill, type, options, transform, bounds) { - classCallCheck(this, XRFrameOfReference); - options = Object.assign({}, XRFrameOfReferenceOptions, options); - if (!XRFrameOfReferenceTypes.includes(type)) { - throw new Error('XRFrameOfReferenceType must be one of ' + XRFrameOfReferenceTypes); - } - var _this = possibleConstructorReturn(this, (XRFrameOfReference.__proto__ || Object.getPrototypeOf(XRFrameOfReference)).call(this)); - if (type === 'stage' && options.disableStageEmulation && !transform) { - throw new Error('XRFrameOfReference cannot use \'stage\' type, if disabling emulation and platform does not provide'); - } - var _options = options, - disableStageEmulation = _options.disableStageEmulation, - stageEmulationHeight = _options.stageEmulationHeight; - var emulatedHeight = 0; - if (type === 'stage' && !transform) { - emulatedHeight = stageEmulationHeight !== 0 ? stageEmulationHeight : DEFAULT_EMULATION_HEIGHT; - } - if (type === 'stage' && !transform) { - transform = identity(new Float32Array(16)); - transform[13] = emulatedHeight; - } - _this[PRIVATE$9] = { - disableStageEmulation: disableStageEmulation, - stageEmulationHeight: stageEmulationHeight, - emulatedHeight: emulatedHeight, - type: type, - transform: transform, - polyfill: polyfill, - bounds: bounds - }; - _this.onboundschange = undefined; - return _this; - } - createClass(XRFrameOfReference, [{ - key: 'transformBasePoseMatrix', - value: function transformBasePoseMatrix(out, pose) { - if (this[PRIVATE$9].transform) { - multiply(out, this[PRIVATE$9].transform, pose); - return; - } - switch (this.type) { - case 'head-model': - if (out !== pose) { - copy(out, pose); - } - out[12] = out[13] = out[14] = 0; - return; - case 'eye-level': - if (out !== pose) { - copy(out, pose); - } - return; - } - } - }, { - key: 'transformBaseViewMatrix', - value: function transformBaseViewMatrix(out, view) { - var frameOfRef = this[PRIVATE$9].transform; - if (frameOfRef) { - invert(out, frameOfRef); - multiply(out, view, out); - } - else if (this.type === 'head-model') { - invert(out, view); - out[12] = 0; - out[13] = 0; - out[14] = 0; - invert(out, out); - return out; - } - else { - copy(out, view); - } - return out; + + + + + + + + + + + + + + +const forEach$1 = (function() { + let vec = create$3(); + return function(a, stride, offset, count, fn, arg) { + let i, l; + if(!stride) { + stride = 4; } - }, { - key: 'bounds', - get: function get$$1() { - return this[PRIVATE$9].bounds; + if(!offset) { + offset = 0; } - }, { - key: 'emulatedHeight', - get: function get$$1() { - return this[PRIVATE$9].emulatedHeight; + if(count) { + l = Math.min((count * stride) + offset, a.length); + } else { + l = a.length; } - }, { - key: 'type', - get: function get$$1() { - return this[PRIVATE$9].type; + for(i = offset; i < l; i += stride) { + vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2]; vec[3] = a[i+3]; + fn(vec, vec, arg); + a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2]; a[i+3] = vec[3]; } - }]); - return XRFrameOfReference; -}(XRCoordinateSystem); + return a; + }; +})(); -var PRIVATE$10 = Symbol('@@webxr-polyfill/XRSession'); -var XRSessionCreationOptions = Object.freeze({ - immersive: false, - outputContext: undefined -}); -var validateSessionOptions = function validateSessionOptions(options) { - var immersive = options.immersive, - outputContext = options.outputContext; - if (!immersive && !outputContext) { - return false; +function create$4() { + let out = new ARRAY_TYPE(4); + if(ARRAY_TYPE != Float32Array) { + out[0] = 0; + out[1] = 0; + out[2] = 0; } - if (outputContext !== undefined && !(outputContext instanceof XRPresentationContext)) { - return false; + out[3] = 1; + return out; +} + +function setAxisAngle(out, axis, rad) { + rad = rad * 0.5; + let s = Math.sin(rad); + out[0] = s * axis[0]; + out[1] = s * axis[1]; + out[2] = s * axis[2]; + out[3] = Math.cos(rad); + return out; +} + +function multiply$4(out, a, b) { + let ax = a[0], ay = a[1], az = a[2], aw = a[3]; + let bx = b[0], by = b[1], bz = b[2], bw = b[3]; + out[0] = ax * bw + aw * bx + ay * bz - az * by; + out[1] = ay * bw + aw * by + az * bx - ax * bz; + out[2] = az * bw + aw * bz + ax * by - ay * bx; + out[3] = aw * bw - ax * bx - ay * by - az * bz; + return out; +} + + + + +function slerp(out, a, b, t) { + let ax = a[0], ay = a[1], az = a[2], aw = a[3]; + let bx = b[0], by = b[1], bz = b[2], bw = b[3]; + let omega, cosom, sinom, scale0, scale1; + cosom = ax * bx + ay * by + az * bz + aw * bw; + if ( cosom < 0.0 ) { + cosom = -cosom; + bx = - bx; + by = - by; + bz = - bz; + bw = - bw; + } + if ( (1.0 - cosom) > EPSILON ) { + omega = Math.acos(cosom); + sinom = Math.sin(omega); + scale0 = Math.sin((1.0 - t) * omega) / sinom; + scale1 = Math.sin(t * omega) / sinom; + } else { + scale0 = 1.0 - t; + scale1 = t; } - return true; -}; -var XRSession = function (_EventTarget) { - inherits(XRSession, _EventTarget); - function XRSession(polyfill, device, sessionOptions, id) { - classCallCheck(this, XRSession); - sessionOptions = Object.assign({}, XRSessionCreationOptions, sessionOptions); - var _this = possibleConstructorReturn(this, (XRSession.__proto__ || Object.getPrototypeOf(XRSession)).call(this)); - var _sessionOptions = sessionOptions, - immersive = _sessionOptions.immersive, - outputContext = _sessionOptions.outputContext; - _this[PRIVATE$10] = { - polyfill: polyfill, - device: device, - immersive: immersive, - outputContext: outputContext, - ended: false, - suspended: false, - suspendedCallback: null, - id: id - }; - var frame = new XRFrame(polyfill, _this, _this[PRIVATE$10].id); - _this[PRIVATE$10].frame = frame; - _this[PRIVATE$10].onPresentationEnd = function (sessionId) { - if (sessionId !== _this[PRIVATE$10].id) { - _this[PRIVATE$10].suspended = false; - _this.dispatchEvent('focus', { session: _this }); - var suspendedCallback = _this[PRIVATE$10].suspendedCallback; - _this[PRIVATE$10].suspendedCallback = null; - if (suspendedCallback) { - _this.requestAnimationFrame(suspendedCallback); - } - return; - } - _this[PRIVATE$10].ended = true; - polyfill.removeEventListener('@webvr-polyfill/vr-present-end', _this[PRIVATE$10].onPresentationEnd); - polyfill.removeEventListener('@webvr-polyfill/vr-present-start', _this[PRIVATE$10].onPresentationStart); - polyfill.removeEventListener('@@webvr-polyfill/input-select-start', _this[PRIVATE$10].onSelectStart); - polyfill.removeEventListener('@@webvr-polyfill/input-select-end', _this[PRIVATE$10].onSelectEnd); - _this.dispatchEvent('end', { session: _this }); - }; - polyfill.addEventListener('@@webxr-polyfill/vr-present-end', _this[PRIVATE$10].onPresentationEnd); - _this[PRIVATE$10].onPresentationStart = function (sessionId) { - if (sessionId === _this[PRIVATE$10].id) { - return; - } - _this[PRIVATE$10].suspended = true; - _this.dispatchEvent('blur', { session: _this }); - }; - polyfill.addEventListener('@@webxr-polyfill/vr-present-start', _this[PRIVATE$10].onPresentationStart); - _this[PRIVATE$10].onSelectStart = function (evt) { - if (evt.sessionId !== _this[PRIVATE$10].id) { - return; - } - _this.dispatchEvent('selectstart', { - frame: _this[PRIVATE$10].frame, - inputSource: evt.inputSource - }); + out[0] = scale0 * ax + scale1 * bx; + out[1] = scale0 * ay + scale1 * by; + out[2] = scale0 * az + scale1 * bz; + out[3] = scale0 * aw + scale1 * bw; + return out; +} + +function invert$2(out, a) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + let dot$$1 = a0*a0 + a1*a1 + a2*a2 + a3*a3; + let invDot = dot$$1 ? 1.0/dot$$1 : 0; + out[0] = -a0*invDot; + out[1] = -a1*invDot; + out[2] = -a2*invDot; + out[3] = a3*invDot; + return out; +} + +function fromMat3(out, m) { + let fTrace = m[0] + m[4] + m[8]; + let fRoot; + if ( fTrace > 0.0 ) { + fRoot = Math.sqrt(fTrace + 1.0); + out[3] = 0.5 * fRoot; + fRoot = 0.5/fRoot; + out[0] = (m[5]-m[7])*fRoot; + out[1] = (m[6]-m[2])*fRoot; + out[2] = (m[1]-m[3])*fRoot; + } else { + let i = 0; + if ( m[4] > m[0] ) + i = 1; + if ( m[8] > m[i*3+i] ) + i = 2; + let j = (i+1)%3; + let k = (i+2)%3; + fRoot = Math.sqrt(m[i*3+i]-m[j*3+j]-m[k*3+k] + 1.0); + out[i] = 0.5 * fRoot; + fRoot = 0.5 / fRoot; + out[3] = (m[j*3+k] - m[k*3+j]) * fRoot; + out[j] = (m[j*3+i] + m[i*3+j]) * fRoot; + out[k] = (m[k*3+i] + m[i*3+k]) * fRoot; + } + return out; +} +function fromEuler(out, x, y, z) { + let halfToRad = 0.5 * Math.PI / 180.0; + x *= halfToRad; + y *= halfToRad; + z *= halfToRad; + let sx = Math.sin(x); + let cx = Math.cos(x); + let sy = Math.sin(y); + let cy = Math.cos(y); + let sz = Math.sin(z); + let cz = Math.cos(z); + out[0] = sx * cy * cz - cx * sy * sz; + out[1] = cx * sy * cz + sx * cy * sz; + out[2] = cx * cy * sz - sx * sy * cz; + out[3] = cx * cy * cz + sx * sy * sz; + return out; +} + +const clone$4 = clone$3; +const fromValues$4 = fromValues$3; +const copy$4 = copy$3; + + + + + + + + + + +const normalize$2 = normalize$1; + + +const rotationTo = (function() { + let tmpvec3 = create$1(); + let xUnitVec3 = fromValues$1(1,0,0); + let yUnitVec3 = fromValues$1(0,1,0); + return function(out, a, b) { + let dot$$1 = dot(a, b); + if (dot$$1 < -0.999999) { + cross(tmpvec3, xUnitVec3, a); + if (len(tmpvec3) < 0.000001) + cross(tmpvec3, yUnitVec3, a); + normalize(tmpvec3, tmpvec3); + setAxisAngle(out, tmpvec3, Math.PI); + return out; + } else if (dot$$1 > 0.999999) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 1; + return out; + } else { + cross(tmpvec3, a, b); + out[0] = tmpvec3[0]; + out[1] = tmpvec3[1]; + out[2] = tmpvec3[2]; + out[3] = 1 + dot$$1; + return normalize$2(out, out); + } + }; +})(); +const sqlerp = (function () { + let temp1 = create$4(); + let temp2 = create$4(); + return function (out, a, b, c, d, t) { + slerp(temp1, a, d, t); + slerp(temp2, b, c, t); + slerp(out, temp1, temp2, 2 * t * (1 - t)); + return out; + }; +}()); +const setAxes = (function() { + let matr = create$2(); + return function(out, view, right, up) { + matr[0] = right[0]; + matr[3] = right[1]; + matr[6] = right[2]; + matr[1] = up[0]; + matr[4] = up[1]; + matr[7] = up[2]; + matr[2] = -view[0]; + matr[5] = -view[1]; + matr[8] = -view[2]; + return normalize$2(out, fromMat3(out, matr)); + }; +})(); + +const PRIVATE$3 = Symbol('@@webxr-polyfill/XRRigidTransform'); +class XRRigidTransform$1 { + constructor() { + this[PRIVATE$3] = { + matrix: null, + position: null, + orientation: null, + inverse: null, }; - polyfill.addEventListener('@@webxr-polyfill/input-select-start', _this[PRIVATE$10].onSelectStart); - _this[PRIVATE$10].onSelectEnd = function (evt) { - if (evt.sessionId !== _this[PRIVATE$10].id) { - return; + if (arguments.length === 0) { + this[PRIVATE$3].matrix = identity(new Float32Array(16)); + } else if (arguments.length === 1) { + if (arguments[0] instanceof Float32Array) { + this[PRIVATE$3].matrix = arguments[0]; + } else { + this[PRIVATE$3].position = this._getPoint(arguments[0]); + this[PRIVATE$3].orientation = DOMPointReadOnly.fromPoint({ + x: 0, y: 0, z: 0, w: 1 + }); } - _this.dispatchEvent('selectend', { - frame: _this[PRIVATE$10].frame, - inputSource: evt.inputSource - }); - _this.dispatchEvent('select', { - frame: _this[PRIVATE$10].frame, - inputSource: evt.inputSource - }); + } else if (arguments.length === 2) { + this[PRIVATE$3].position = this._getPoint(arguments[0]); + this[PRIVATE$3].orientation = this._getPoint(arguments[1]); + } else { + throw new Error("Too many arguments!"); + } + if (this[PRIVATE$3].matrix) { + let position = create$1(); + getTranslation(position, this[PRIVATE$3].matrix); + this[PRIVATE$3].position = DOMPointReadOnly.fromPoint({ + x: position[0], + y: position[1], + z: position[2] + }); + let orientation = create$4(); + getRotation(orientation, this[PRIVATE$3].matrix); + this[PRIVATE$3].orientation = DOMPointReadOnly.fromPoint({ + x: orientation[0], + y: orientation[1], + z: orientation[2], + w: orientation[3] + }); + } else { + this[PRIVATE$3].matrix = identity(new Float32Array(16)); + fromRotationTranslation( + this[PRIVATE$3].matrix, + fromValues$4( + this[PRIVATE$3].orientation.x, + this[PRIVATE$3].orientation.y, + this[PRIVATE$3].orientation.z, + this[PRIVATE$3].orientation.w), + fromValues$1( + this[PRIVATE$3].position.x, + this[PRIVATE$3].position.y, + this[PRIVATE$3].position.z) + ); + } + } + _getPoint(arg) { + if (arg instanceof DOMPointReadOnly) { + return arg; + } + return DOMPointReadOnly.fromPoint(arg); + } + get matrix() { return this[PRIVATE$3].matrix; } + get position() { return this[PRIVATE$3].position; } + get orientation() { return this[PRIVATE$3].orientation; } + get inverse() { + if (this[PRIVATE$3].inverse === null) { + let invMatrix = identity(new Float32Array(16)); + invert(invMatrix, this[PRIVATE$3].matrix); + this[PRIVATE$3].inverse = new XRRigidTransform$1(invMatrix); + this[PRIVATE$3].inverse[PRIVATE$3].inverse = this; + } + return this[PRIVATE$3].inverse; + } +} + +const PRIVATE$4 = Symbol('@@webxr-polyfill/XRViewerPose'); +class XRViewerPose extends XRPose$1 { + constructor(device, views) { + super(new XRRigidTransform$1(), false); + this[PRIVATE$4] = { + device, + views, + leftViewMatrix: identity(new Float32Array(16)), + rightViewMatrix: identity(new Float32Array(16)), + poseModelMatrix: identity(new Float32Array(16)), }; - polyfill.addEventListener('@@webxr-polyfill/input-select-end', _this[PRIVATE$10].onSelectEnd); - _this.onblur = undefined; - _this.onfocus = undefined; - _this.onresetpose = undefined; - _this.onend = undefined; - _this.onselect = undefined; - _this.onselectstart = undefined; - _this.onselectend = undefined; - return _this; - } - createClass(XRSession, [{ - key: 'requestFrameOfReference', - value: function requestFrameOfReference(type) { - var $args = arguments;return new Promise(function ($return, $error) { - var options, transform, bounds; - options = $args.length > 1 && $args[1] !== undefined ? $args[1] : {}; - if (this[PRIVATE$10].ended) { - return $return(); - } - options = Object.assign({}, XRFrameOfReferenceOptions, options); - if (!XRFrameOfReferenceTypes.includes(type)) { - return $error(new TypeError('XRFrameOfReferenceType must be one of ' + XRFrameOfReferenceTypes)); - } - transform = null; - bounds = null; - var $Try_1_Post = function () { - try { - if (type === 'stage' && transform) { - bounds = this[PRIVATE$10].polyfill.requestStageBounds(); - if (bounds) { - bounds = new XRStageBounds(bounds); - } - } - return $return(new XRFrameOfReference(this[PRIVATE$10].polyfill, type, options, transform, bounds)); - } catch ($boundEx) { - return $error($boundEx); - } - }.bind(this);var $Try_1_Catch = function (e) { - try { - if (type !== 'stage' || options.disableStageEmulation) { - throw e; - } - return $Try_1_Post(); - } catch ($boundEx) { - return $error($boundEx); - } - }.bind(this); - try { - return Promise.resolve(this[PRIVATE$10].polyfill.requestFrameOfReferenceTransform(type, options)).then(function ($await_2) { - try { - transform = $await_2; - return $Try_1_Post(); - } catch ($boundEx) { - return $Try_1_Catch($boundEx); - } - }.bind(this), $Try_1_Catch); - } catch (e) { - $Try_1_Catch(e); - } - }.bind(this)); - } - }, { - key: 'requestAnimationFrame', - value: function requestAnimationFrame(callback) { - var _this2 = this; - if (this[PRIVATE$10].ended) { - return; - } - if (this[PRIVATE$10].suspended && this[PRIVATE$10].suspendedCallback) { - return; - } - if (this[PRIVATE$10].suspended && !this[PRIVATE$10].suspendedCallback) { - this[PRIVATE$10].suspendedCallback = callback; - } - return this[PRIVATE$10].polyfill.requestAnimationFrame(function () { - _this2[PRIVATE$10].polyfill.onFrameStart(_this2[PRIVATE$10].id); - callback(now$1(), _this2[PRIVATE$10].frame); - _this2[PRIVATE$10].polyfill.onFrameEnd(_this2[PRIVATE$10].id); - }); - } - }, { - key: 'cancelAnimationFrame', - value: function cancelAnimationFrame(handle) { - if (this[PRIVATE$10].ended) { - return; + } + get poseModelMatrix() { return this[PRIVATE$4].poseModelMatrix; } + get views() { + return this[PRIVATE$4].views; + } + updateFromReferenceSpace(refSpace) { + const pose = this[PRIVATE$4].device.getBasePoseMatrix(); + const leftViewMatrix = this[PRIVATE$4].device.getBaseViewMatrix('left'); + const rightViewMatrix = this[PRIVATE$4].device.getBaseViewMatrix('right'); + if (pose) { + refSpace.transformBasePoseMatrix(this[PRIVATE$4].poseModelMatrix, pose); + refSpace._adjustForOriginOffset(this[PRIVATE$4].poseModelMatrix); + super._setTransform(new XRRigidTransform$1(this[PRIVATE$4].poseModelMatrix)); + } + if (leftViewMatrix && rightViewMatrix) { + refSpace.transformBaseViewMatrix( + this[PRIVATE$4].leftViewMatrix, + leftViewMatrix, + this[PRIVATE$4].poseModelMatrix); + refSpace.transformBaseViewMatrix( + this[PRIVATE$4].rightViewMatrix, + rightViewMatrix, + this[PRIVATE$4].poseModelMatrix); + multiply( + this[PRIVATE$4].leftViewMatrix, + this[PRIVATE$4].leftViewMatrix, + refSpace._originOffsetMatrix()); + multiply( + this[PRIVATE$4].rightViewMatrix, + this[PRIVATE$4].rightViewMatrix, + refSpace._originOffsetMatrix()); + } + for (let view of this[PRIVATE$4].views) { + if (view.eye == "left") { + view._updateViewMatrix(this[PRIVATE$4].leftViewMatrix); + } else if (view.eye == "right") { + view._updateViewMatrix(this[PRIVATE$4].rightViewMatrix); } - this[PRIVATE$10].polyfill.cancelAnimationFrame(handle); - } - }, { - key: 'getInputSources', - value: function getInputSources() { - return this[PRIVATE$10].polyfill.getInputSources(); } - }, { - key: 'end', - value: function end() { - return new Promise(function ($return, $error) { - if (this[PRIVATE$10].ended) { - return $return(); - } - if (!this.immersive) { - this[PRIVATE$10].ended = true; - this[PRIVATE$10].polyfill.removeEventListener('@@webvr-polyfill/vr-present-start', this[PRIVATE$10].onPresentationStart); - this[PRIVATE$10].polyfill.removeEventListener('@@webvr-polyfill/vr-present-end', this[PRIVATE$10].onPresentationEnd); - this[PRIVATE$10].polyfill.removeEventListener('@@webvr-polyfill/input-select-start', this[PRIVATE$10].onSelectStart); - this[PRIVATE$10].polyfill.removeEventListener('@@webvr-polyfill/input-select-end', this[PRIVATE$10].onSelectEnd); - this.dispatchEvent('end', { session: this }); - } - return $return(this[PRIVATE$10].polyfill.endSession(this[PRIVATE$10].id)); - }.bind(this)); - } - }, { - key: 'device', - get: function get$$1() { - return this[PRIVATE$10].device; - } - }, { - key: 'immersive', - get: function get$$1() { - return this[PRIVATE$10].immersive; - } - }, { - key: 'outputContext', - get: function get$$1() { - return this[PRIVATE$10].outputContext; - } - }, { - key: 'depthNear', - get: function get$$1() { - return this[PRIVATE$10].polyfill.depthNear; - } - , - set: function set$$1(value) { - this[PRIVATE$10].polyfill.depthNear = value; - } - }, { - key: 'depthFar', - get: function get$$1() { - return this[PRIVATE$10].polyfill.depthFar; - } - , - set: function set$$1(value) { - this[PRIVATE$10].polyfill.depthFar = value; - } - }, { - key: 'environmentBlendMode', - get: function get$$1() { - return this[PRIVATE$10].polyfill.environmentBlendMode || 'opaque'; - } - }, { - key: 'baseLayer', - get: function get$$1() { - return this[PRIVATE$10].baseLayer; - } - , - set: function set$$1(value) { - if (this[PRIVATE$10].ended) { - return; - } - this[PRIVATE$10].baseLayer = value; - this[PRIVATE$10].polyfill.onBaseLayerSet(this[PRIVATE$10].id, value); + } +} + +const PRIVATE$5 = Symbol('@@webxr-polyfill/XRViewport'); +class XRViewport { + constructor(target) { + this[PRIVATE$5] = { target }; + } + get x() { return this[PRIVATE$5].target.x; } + get y() { return this[PRIVATE$5].target.y; } + get width() { return this[PRIVATE$5].target.width; } + get height() { return this[PRIVATE$5].target.height; } +} + +const XREyes = ['left', 'right']; +const PRIVATE$6 = Symbol('@@webxr-polyfill/XRView'); +class XRView { + constructor(device, eye, sessionId) { + if (!XREyes.includes(eye)) { + throw new Error(`XREye must be one of: ${XREyes}`); } - }]); - return XRSession; -}(EventTarget); - -var PRIVATE$11 = Symbol('@@webxr-polyfill/XRDevice'); -var XRDevice = function (_EventTarget) { - inherits(XRDevice, _EventTarget); - function XRDevice(polyfill) { - classCallCheck(this, XRDevice); - if (!polyfill) { - throw new Error('XRDevice must receive a PolyfilledXRDevice.'); - } - var _this = possibleConstructorReturn(this, (XRDevice.__proto__ || Object.getPrototypeOf(XRDevice)).call(this)); - _this[PRIVATE$11] = { - polyfill: polyfill, - immersiveSession: null, - nonImmersiveSessions: new Set() + const temp = Object.create(null); + const viewport = new XRViewport(temp); + this[PRIVATE$6] = { + device, + eye, + viewport, + temp, + sessionId, + transform: null, }; - _this.ondeactive = undefined; - return _this; - } - createClass(XRDevice, [{ - key: 'supportsSession', - value: function supportsSession() { - var $args = arguments;return new Promise(function ($return, $error) { - var sessionOptions = $args.length > 0 && $args[0] !== undefined ? $args[0] : {}; - sessionOptions = Object.assign({}, XRSessionCreationOptions, sessionOptions); - if (!validateSessionOptions(sessionOptions)) { - return $return(Promise.reject(null)); - } - if (!this[PRIVATE$11].polyfill.supportsSession(sessionOptions)) { - return $return(Promise.reject(null)); - } - return $return(null); - }.bind(this)); - } - }, { - key: 'requestSession', - value: function requestSession(sessionOptions) { - return new Promise(function ($return, $error) { - var _this2, sessionId, session, onSessionEnd; - _this2 = this; - sessionOptions = Object.assign({}, XRSessionCreationOptions, sessionOptions); - if (!validateSessionOptions(sessionOptions)) { - return $error(new Error('NotSupportedError')); - } - if (this[PRIVATE$11].immersiveSession && sessionOptions.immersive) { - return $error(new Error('InvalidStateError')); - } - return Promise.resolve(this[PRIVATE$11].polyfill.requestSession(sessionOptions)).then(function ($await_1) { - try { - sessionId = $await_1; - session = new XRSession(this[PRIVATE$11].polyfill, this, sessionOptions, sessionId); - if (sessionOptions.immersive) { - this[PRIVATE$11].immersiveSession = session; - } else { - this[PRIVATE$11].nonImmersiveSessions.add(session); - } - onSessionEnd = function onSessionEnd() { - if (session.immersive) { - _this2[PRIVATE$11].immersiveSession = null; - } else { - _this2[PRIVATE$11].nonImmersiveSessions.delete(session); - } - session.removeEventListener('end', onSessionEnd); - }; - session.addEventListener('end', onSessionEnd); - return $return(session); - } catch ($boundEx) { - return $error($boundEx); - } - }.bind(this), $error); - }.bind(this)); - } - }]); - return XRDevice; -}(EventTarget); - -var domPointROExport = 'DOMPointReadOnly' in _global ? DOMPointReadOnly : null; -if (!domPointROExport) { - var PRIVATE$12 = Symbol('@@webxr-polyfill/DOMPointReadOnly'); - domPointROExport = function () { - function DOMPointReadOnly(x, y, z, w) { - classCallCheck(this, DOMPointReadOnly); - if (arguments.length === 1) { - this[PRIVATE$12] = { - x: x.x, - y: x.y, - z: x.z, - w: x.w - }; - } else if (arguments.length === 4) { - this[PRIVATE$12] = { - x: x, - y: y, - z: z, - w: w - }; - } else { - throw new TypeError('Must supply either 1 or 4 arguments'); - } + } + get eye() { return this[PRIVATE$6].eye; } + get projectionMatrix() { return this[PRIVATE$6].device.getProjectionMatrix(this.eye); } + get transform() { return this[PRIVATE$6].transform; } + _updateViewMatrix(viewMatrix) { + let invMatrix = identity(new Float32Array(16)); + invert(invMatrix, viewMatrix); + this[PRIVATE$6].transform = new XRRigidTransform$1(invMatrix); + } + _getViewport(layer) { + if (this[PRIVATE$6].device.getViewport(this[PRIVATE$6].sessionId, + this.eye, + layer, + this[PRIVATE$6].temp)) { + return this[PRIVATE$6].viewport; } - createClass(DOMPointReadOnly, [{ - key: 'x', - get: function get$$1() { - return this[PRIVATE$12].x; - } - }, { - key: 'y', - get: function get$$1() { - return this[PRIVATE$12].y; - } - }, { - key: 'z', - get: function get$$1() { - return this[PRIVATE$12].z; - } - }, { - key: 'w', - get: function get$$1() { - return this[PRIVATE$12].w; - } - }]); - return DOMPointReadOnly; - }(); + return undefined; + } +} + +var EPSILON$1 = 0.000001; +var ARRAY_TYPE$1 = typeof Float32Array !== 'undefined' ? Float32Array : Array; + + +var degree$1 = Math.PI / 180; + +function create$7() { + var out = new ARRAY_TYPE$1(9); + if (ARRAY_TYPE$1 != Float32Array) { + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; + } + out[0] = 1; + out[4] = 1; + out[8] = 1; + return out; } -var DOMPointReadOnly$1 = domPointROExport; -var XRRay = -function XRRay() { - var origin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new DOMPointReadOnly$1(0, 0, 0, 1); - var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new DOMPointReadOnly$1(0, 0, -1, 0); - var transformMatrix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Float32Array(16); - classCallCheck(this, XRRay); - if (!(origin instanceof DOMPointReadOnly$1)) { - throw new Error('origin must be a DOMPointReadOnly'); - } - if (!(direction instanceof DOMPointReadOnly$1)) { - throw new Error('direction must be a DOMPointReadOnly'); - } - if (!(transformMatrix instanceof Float32Array)) { - throw new Error('transformMatrix must be a Float32Array'); - } - Object.defineProperties(this, { - origin: { - value: origin, - writable: false - }, - direction: { - value: direction, - writable: false - }, - transformMatrix: { - value: transformMatrix, - writable: false - } - }); -}; +function create$9() { + var out = new ARRAY_TYPE$1(3); + if (ARRAY_TYPE$1 != Float32Array) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + } + return out; +} + +function length$3(a) { + var x = a[0]; + var y = a[1]; + var z = a[2]; + return Math.sqrt(x * x + y * y + z * z); +} +function fromValues$9(x, y, z) { + var out = new ARRAY_TYPE$1(3); + out[0] = x; + out[1] = y; + out[2] = z; + return out; +} + + + + + + + + + + + + + + + + + + +function normalize$3(out, a) { + var x = a[0]; + var y = a[1]; + var z = a[2]; + var len = x * x + y * y + z * z; + if (len > 0) { + len = 1 / Math.sqrt(len); + out[0] = a[0] * len; + out[1] = a[1] * len; + out[2] = a[2] * len; + } + return out; +} +function dot$3(a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; +} +function cross$1(out, a, b) { + var ax = a[0], + ay = a[1], + az = a[2]; + var bx = b[0], + by = b[1], + bz = b[2]; + out[0] = ay * bz - az * by; + out[1] = az * bx - ax * bz; + out[2] = ax * by - ay * bx; + return out; +} + + + + + -var PRIVATE$13 = Symbol('@@webxr-polyfill/XRInputPose'); -var XRInputPose = function () { - function XRInputPose(inputSourceImpl, hasGripMatrix) { - classCallCheck(this, XRInputPose); - this[PRIVATE$13] = { - inputSourceImpl: inputSourceImpl, - targetRay: new XRRay(), - gripMatrix: hasGripMatrix ? create() : null - }; - } - createClass(XRInputPose, [{ - key: 'targetRay', - get: function get$$1() { - return this[PRIVATE$13].targetRay; - } - , - set: function set$$1(value) { - this[PRIVATE$13].targetRay = value; - } - }, { - key: 'emulatedPosition', - get: function get$$1() { - return this[PRIVATE$13].inputSourceImpl.emulatedPosition; - } - }, { - key: 'gripMatrix', - get: function get$$1() { - return this[PRIVATE$13].gripMatrix; - } - }]); - return XRInputPose; -}(); -var PRIVATE$14 = Symbol('@@webxr-polyfill/XRInputSource'); -var XRInputSource = function () { - function XRInputSource(impl) { - classCallCheck(this, XRInputSource); - this[PRIVATE$14] = { - impl: impl - }; - } - createClass(XRInputSource, [{ - key: 'handedness', - get: function get$$1() { - return this[PRIVATE$14].impl.handedness; - } - }, { - key: 'targetRayMode', - get: function get$$1() { - return this[PRIVATE$14].impl.targetRayMode; - } - }]); - return XRInputSource; -}(); -var XRLayer = function () { - function XRLayer() { - classCallCheck(this, XRLayer); - } - createClass(XRLayer, [{ - key: "getViewport", - value: function getViewport(view) { - return view._getViewport(this); - } - }]); - return XRLayer; -}(); -var POLYFILLED_COMPATIBLE_XR_DEVICE = Symbol('@@webxr-polyfill/polyfilled-compatible-xr-device'); -var COMPATIBLE_XR_DEVICE = Symbol('@@webxr-polyfill/compatible-xr-device'); -var PRIVATE$15 = Symbol('@@webxr-polyfill/XRWebGLLayer'); -var XRWebGLLayerInit = Object.freeze({ - antialias: true, - depth: false, - stencil: false, - alpha: true, - multiview: false, - framebufferScaleFactor: 0 -}); -var XRWebGLLayer = function (_XRLayer) { - inherits(XRWebGLLayer, _XRLayer); - function XRWebGLLayer(session, context) { - var layerInit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - classCallCheck(this, XRWebGLLayer); - var config = Object.assign({}, XRWebGLLayerInit, layerInit); - if (!(session instanceof XRSession)) { - throw new Error('session must be a XRSession'); - } - if (session.ended) { - throw new Error('InvalidStateError'); - } - if (context[POLYFILLED_COMPATIBLE_XR_DEVICE]) { - if (context[COMPATIBLE_XR_DEVICE] !== session.device) { - throw new Error('InvalidStateError'); - } - } - var framebuffer = context.getParameter(context.FRAMEBUFFER_BINDING); - var _this = possibleConstructorReturn(this, (XRWebGLLayer.__proto__ || Object.getPrototypeOf(XRWebGLLayer)).call(this)); - _this[PRIVATE$15] = { - context: context, - config: config, - framebuffer: framebuffer - }; - return _this; - } - createClass(XRWebGLLayer, [{ - key: 'requestViewportScaling', - value: function requestViewportScaling(viewportScaleFactor) { - console.warn('requestViewportScaling is not yet implemented'); - } - }, { - key: 'context', - get: function get$$1() { - return this[PRIVATE$15].context; - } - }, { - key: 'antialias', - get: function get$$1() { - return this[PRIVATE$15].config.antialias; - } - }, { - key: 'depth', - get: function get$$1() { - return this[PRIVATE$15].config.depth; - } - }, { - key: 'stencil', - get: function get$$1() { - return this[PRIVATE$15].config.stencil; - } - }, { - key: 'alpha', - get: function get$$1() { - return this[PRIVATE$15].config.alpha; - } - }, { - key: 'multiview', - get: function get$$1() { - return false; - } - }, { - key: 'framebuffer', - get: function get$$1() { - return this[PRIVATE$15].framebuffer; - } - }, { - key: 'framebufferWidth', - get: function get$$1() { - return this[PRIVATE$15].context.drawingBufferWidth; + + + + + + + + + +var len$3 = length$3; + +var forEach$2 = function () { + var vec = create$9(); + return function (a, stride, offset, count, fn, arg) { + var i = void 0, + l = void 0; + if (!stride) { + stride = 3; } - }, { - key: 'framebufferHeight', - get: function get$$1() { - return this[PRIVATE$15].context.drawingBufferHeight; + if (!offset) { + offset = 0; } - }]); - return XRWebGLLayer; -}(XRLayer); - -var API = { - XR: XR, - XRDevice: XRDevice, - XRSession: XRSession, - XRFrame: XRFrame, - XRView: XRView, - XRViewport: XRViewport, - XRDevicePose: XRDevicePose, - XRLayer: XRLayer, - XRWebGLLayer: XRWebGLLayer, - XRPresentationContext: XRPresentationContext, - XRCoordinateSystem: XRCoordinateSystem, - XRFrameOfReference: XRFrameOfReference, - XRStageBounds: XRStageBounds, - XRStageBoundsPoint: XRStageBoundsPoint, - XRInputPose: XRInputPose, - XRInputSource: XRInputSource, - XRRay: XRRay -}; - -var extendContextCompatibleXRDevice = function extendContextCompatibleXRDevice(Context) { - if (typeof Context.prototype.setCompatibleXRDevice === 'function') { - return false; - } - Context.prototype.setCompatibleXRDevice = function (xrDevice) { - var _this = this; - return new Promise(function (resolve, reject) { - if (xrDevice && typeof xrDevice.requestSession === 'function') { - resolve(); - } else { - reject(); - } - }).then(function () { - return _this[COMPATIBLE_XR_DEVICE] = xrDevice; - }); - }; - return true; -}; -var extendGetContext = function extendGetContext(Canvas) { - var getContext = HTMLCanvasElement.prototype.getContext; - HTMLCanvasElement.prototype.getContext = function (contextType, glAttribs) { - if (contextType === 'xrpresent') { - var _ctx = getContext.call(this, '2d', glAttribs); - return new XRPresentationContext(this, _ctx, glAttribs); + if (count) { + l = Math.min(count * stride + offset, a.length); + } else { + l = a.length; } - var ctx = getContext.call(this, contextType, glAttribs); - ctx[POLYFILLED_COMPATIBLE_XR_DEVICE] = true; - if (glAttribs && 'compatibleXRDevice' in glAttribs) { - ctx[COMPATIBLE_XR_DEVICE] = glAttribs.compatibleXRDevice; + for (i = offset; i < l; i += stride) { + vec[0] = a[i];vec[1] = a[i + 1];vec[2] = a[i + 2]; + fn(vec, vec, arg); + a[i] = vec[0];a[i + 1] = vec[1];a[i + 2] = vec[2]; } - return ctx; + return a; }; -}; +}(); -function create$1() { - var out = new ARRAY_TYPE(3); - out[0] = 0; - out[1] = 0; - out[2] = 0; - return out; -} -function clone$1(a) { - var out = new ARRAY_TYPE(3); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; +function create$10() { + var out = new ARRAY_TYPE$1(4); + if (ARRAY_TYPE$1 != Float32Array) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 0; + } return out; } -function length(a) { + + + + + + + + + + + + + + + + + + + + + +function normalize$4(out, a) { var x = a[0]; var y = a[1]; var z = a[2]; - return Math.sqrt(x * x + y * y + z * z); -} -function fromValues$1(x, y, z) { - var out = new ARRAY_TYPE(3); - out[0] = x; - out[1] = y; - out[2] = z; + var w = a[3]; + var len = x * x + y * y + z * z + w * w; + if (len > 0) { + len = 1 / Math.sqrt(len); + out[0] = x * len; + out[1] = y * len; + out[2] = z * len; + out[3] = w * len; + } return out; } -function copy$1(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; + + + + + + + + + + + + + + + +var forEach$3 = function () { + var vec = create$10(); + return function (a, stride, offset, count, fn, arg) { + var i = void 0, + l = void 0; + if (!stride) { + stride = 4; + } + if (!offset) { + offset = 0; + } + if (count) { + l = Math.min(count * stride + offset, a.length); + } else { + l = a.length; + } + for (i = offset; i < l; i += stride) { + vec[0] = a[i];vec[1] = a[i + 1];vec[2] = a[i + 2];vec[3] = a[i + 3]; + fn(vec, vec, arg); + a[i] = vec[0];a[i + 1] = vec[1];a[i + 2] = vec[2];a[i + 3] = vec[3]; + } + return a; + }; +}(); + +function create$11() { + var out = new ARRAY_TYPE$1(4); + if (ARRAY_TYPE$1 != Float32Array) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + } + out[3] = 1; return out; } -function set$2(out, x, y, z) { - out[0] = x; - out[1] = y; - out[2] = z; + +function setAxisAngle$1(out, axis, rad) { + rad = rad * 0.5; + var s = Math.sin(rad); + out[0] = s * axis[0]; + out[1] = s * axis[1]; + out[2] = s * axis[2]; + out[3] = Math.cos(rad); return out; } -function add$1(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; + + + + + + +function slerp$1(out, a, b, t) { + var ax = a[0], + ay = a[1], + az = a[2], + aw = a[3]; + var bx = b[0], + by = b[1], + bz = b[2], + bw = b[3]; + var omega = void 0, + cosom = void 0, + sinom = void 0, + scale0 = void 0, + scale1 = void 0; + cosom = ax * bx + ay * by + az * bz + aw * bw; + if (cosom < 0.0) { + cosom = -cosom; + bx = -bx; + by = -by; + bz = -bz; + bw = -bw; + } + if (1.0 - cosom > EPSILON$1) { + omega = Math.acos(cosom); + sinom = Math.sin(omega); + scale0 = Math.sin((1.0 - t) * omega) / sinom; + scale1 = Math.sin(t * omega) / sinom; + } else { + scale0 = 1.0 - t; + scale1 = t; + } + out[0] = scale0 * ax + scale1 * bx; + out[1] = scale0 * ay + scale1 * by; + out[2] = scale0 * az + scale1 * bz; + out[3] = scale0 * aw + scale1 * bw; return out; } -function subtract$1(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; + + + +function fromMat3$1(out, m) { + var fTrace = m[0] + m[4] + m[8]; + var fRoot = void 0; + if (fTrace > 0.0) { + fRoot = Math.sqrt(fTrace + 1.0); + out[3] = 0.5 * fRoot; + fRoot = 0.5 / fRoot; + out[0] = (m[5] - m[7]) * fRoot; + out[1] = (m[6] - m[2]) * fRoot; + out[2] = (m[1] - m[3]) * fRoot; + } else { + var i = 0; + if (m[4] > m[0]) i = 1; + if (m[8] > m[i * 3 + i]) i = 2; + var j = (i + 1) % 3; + var k = (i + 2) % 3; + fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1.0); + out[i] = 0.5 * fRoot; + fRoot = 0.5 / fRoot; + out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot; + out[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot; + out[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot; + } return out; } @@ -1574,122 +1446,128 @@ function subtract$1(out, a, b) { -function scale$1(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - return out; -} -function normalize(out, a) { - var x = a[0]; - var y = a[1]; - var z = a[2]; - var len = x * x + y * y + z * z; - if (len > 0) { - len = 1 / Math.sqrt(len); - out[0] = a[0] * len; - out[1] = a[1] * len; - out[2] = a[2] * len; + + +var normalize$5 = normalize$4; + + +var rotationTo$1 = function () { + var tmpvec3 = create$9(); + var xUnitVec3 = fromValues$9(1, 0, 0); + var yUnitVec3 = fromValues$9(0, 1, 0); + return function (out, a, b) { + var dot = dot$3(a, b); + if (dot < -0.999999) { + cross$1(tmpvec3, xUnitVec3, a); + if (len$3(tmpvec3) < 0.000001) cross$1(tmpvec3, yUnitVec3, a); + normalize$3(tmpvec3, tmpvec3); + setAxisAngle$1(out, tmpvec3, Math.PI); + return out; + } else if (dot > 0.999999) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 1; + return out; + } else { + cross$1(tmpvec3, a, b); + out[0] = tmpvec3[0]; + out[1] = tmpvec3[1]; + out[2] = tmpvec3[2]; + out[3] = 1 + dot; + return normalize$5(out, out); + } + }; +}(); +var sqlerp$1 = function () { + var temp1 = create$11(); + var temp2 = create$11(); + return function (out, a, b, c, d, t) { + slerp$1(temp1, a, d, t); + slerp$1(temp2, b, c, t); + slerp$1(out, temp1, temp2, 2 * t * (1 - t)); + return out; + }; +}(); +var setAxes$1 = function () { + var matr = create$7(); + return function (out, view, right, up) { + matr[0] = right[0]; + matr[3] = right[1]; + matr[6] = right[2]; + matr[1] = up[0]; + matr[4] = up[1]; + matr[7] = up[2]; + matr[2] = -view[0]; + matr[5] = -view[1]; + matr[8] = -view[2]; + return normalize$5(out, fromMat3$1(out, matr)); + }; +}(); + +function create$13() { + var out = new ARRAY_TYPE$1(2); + if (ARRAY_TYPE$1 != Float32Array) { + out[0] = 0; + out[1] = 0; } return out; } -function dot(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; -} -function cross(out, a, b) { - var ax = a[0], - ay = a[1], - az = a[2]; - var bx = b[0], - by = b[1], - bz = b[2]; - out[0] = ay * bz - az * by; - out[1] = az * bx - ax * bz; - out[2] = ax * by - ay * bx; - return out; -} -function transformMat4(out, a, m) { - var x = a[0], - y = a[1], - z = a[2]; - var w = m[3] * x + m[7] * y + m[11] * z + m[15]; - w = w || 1.0; - out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w; - out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w; - out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w; - return out; -} -function transformQuat(out, a, q) { - var qx = q[0], - qy = q[1], - qz = q[2], - qw = q[3]; - var x = a[0], - y = a[1], - z = a[2]; - var uvx = qy * z - qz * y, - uvy = qz * x - qx * z, - uvz = qx * y - qy * x; - var uuvx = qy * uvz - qz * uvy, - uuvy = qz * uvx - qx * uvz, - uuvz = qx * uvy - qy * uvx; - var w2 = qw * 2; - uvx *= w2; - uvy *= w2; - uvz *= w2; - uuvx *= 2; - uuvy *= 2; - uuvz *= 2; - out[0] = x + uvx + uuvx; - out[1] = y + uvy + uuvy; - out[2] = z + uvz + uuvz; - return out; -} -function angle(a, b) { - var tempA = fromValues$1(a[0], a[1], a[2]); - var tempB = fromValues$1(b[0], b[1], b[2]); - normalize(tempA, tempA); - normalize(tempB, tempB); - var cosine = dot(tempA, tempB); - if (cosine > 1.0) { - return 0; - } else if (cosine < -1.0) { - return Math.PI; - } else { - return Math.acos(cosine); - } -} -var sub$1 = subtract$1; -var len = length; -var forEach = function () { - var vec = create$1(); + + + + + + + + + + + + + + + + + + + + + + + + + + +var forEach$4 = function () { + var vec = create$13(); return function (a, stride, offset, count, fn, arg) { var i = void 0, l = void 0; if (!stride) { - stride = 3; + stride = 2; } if (!offset) { offset = 0; @@ -1700,33 +1578,511 @@ var forEach = function () { l = a.length; } for (i = offset; i < l; i += stride) { - vec[0] = a[i];vec[1] = a[i + 1];vec[2] = a[i + 2]; + vec[0] = a[i];vec[1] = a[i + 1]; fn(vec, vec, arg); - a[i] = vec[0];a[i + 1] = vec[1];a[i + 2] = vec[2]; + a[i] = vec[0];a[i + 1] = vec[1]; + } + return a; + }; +}(); + +const PRIVATE$7 = Symbol('@@webxr-polyfill/XRFrame'); +class XRFrame { + constructor(device, session, sessionId) { + const views = [ + new XRView(device, 'left', sessionId), + ]; + if (session.immersive) { + views.push(new XRView(device, 'right', sessionId)); + } + this[PRIVATE$7] = { + device, + viewerPose: new XRViewerPose(device, views), + views, + session, + }; + } + get session() { return this[PRIVATE$7].session; } + getViewerPose(space) { + this[PRIVATE$7].viewerPose.updateFromReferenceSpace(space); + return this[PRIVATE$7].viewerPose; + } + getPose(space, baseSpace) { + if (space._specialType === "viewer") { + let viewerPose = this.getViewerPose(baseSpace); + return new XRPose( + new XRRigidTransform(viewerPose.poseModelMatrix), + viewerPose.emulatedPosition); + } + if (space._specialType === "target-ray" || space._specialType === "grip") { + return this[PRIVATE$7].device.getInputPose( + space._inputSource, baseSpace, space._specialType); + } + return null; + } +} + +const PRIVATE$8 = Symbol('@@webxr-polyfill/XRStageBoundsPoint'); +class XRStageBoundsPoint { + constructor(x, z) { + this[PRIVATE$8] = { x, z }; + } + get x() { return this[PRIVATE$8].x; } + get z() { return this[PRIVATE$8].z; } +} + +const PRIVATE$9 = Symbol('@@webxr-polyfill/XRStageBounds'); +class XRStageBounds { + constructor(boundsData) { + const geometry = []; + for (let i = 0; i < boundsData.length; i += 2) { + geometry.push(new XRStageBoundsPoint(boundsData[i], boundsData[i + 1])); + } + this[PRIVATE$9] = { geometry }; + } + get geometry() { return this[PRIVATE$9].geometry; } +} + +const PRIVATE$10 = Symbol('@@webxr-polyfill/XRSpace'); +class XRSpace { + constructor(specialType = null, inputSource = null) { + this[PRIVATE$10] = { + specialType, + inputSource, + }; + } + get _specialType() { + return this[PRIVATE$10].specialType; + } + get _inputSource() { + return this[PRIVATE$10].inputSource; + } +} + +const DEFAULT_EMULATION_HEIGHT = 1.6; +const PRIVATE$11 = Symbol('@@webxr-polyfill/XRReferenceSpace'); +const XRReferenceSpaceTypes = [ + 'viewer', + 'local', + 'local-floor', + 'bounded-floor', + 'unbounded' +]; +const XRReferenceSpaceOptions = Object.freeze({ + disableStageEmulation: false, + stageEmulationHeight: 0, +}); +class XRReferenceSpace extends XRSpace { + constructor(device, type, options, transform, bounds) { + options = Object.assign({}, XRReferenceSpaceOptions, options); + if (!XRReferenceSpaceTypes.includes(type)) { + throw new Error(`XRReferenceSpaceType must be one of ${XRReferenceSpaceTypes}`); + } + super((type === 'viewer') ? 'viewer' : null); + if (this._isFloor(type) && options.disableStageEmulation && !transform) { + throw new Error(`XRReferenceSpace cannot use 'bounded-floor' type, if disabling emulation and platform does not provide`); + } + if (type === 'bounded-floor') { + throw new Error('The polyfill does not support creating bounded reference spaces.'); + } + const { disableStageEmulation, stageEmulationHeight } = options; + let emulatedHeight = 0; + if (this._isFloor(type) && !transform) { + emulatedHeight = stageEmulationHeight !== 0 ? stageEmulationHeight : DEFAULT_EMULATION_HEIGHT; + transform = identity(new Float32Array(16)); + transform[13] = emulatedHeight; + } + if (!transform) { + transform = identity(new Float32Array(16)); + } + this[PRIVATE$11] = { + disableStageEmulation, + stageEmulationHeight, + emulatedHeight, + type, + transform, + device, + bounds, + options, + originOffset : identity(new Float32Array(16)), + }; + this.onboundschange = undefined; + } + _isFloor(type) { + return type === 'bounded-floor' || type === 'local-floor'; + } + get bounds() { return this[PRIVATE$11].bounds; } + get emulatedHeight() { return this[PRIVATE$11].emulatedHeight; } + get type() { return this[PRIVATE$11].type; } + transformBasePoseMatrix(out, pose) { + multiply(out, this[PRIVATE$11].transform, pose); + } + transformBaseViewMatrix(out, view) { + invert(out, this[PRIVATE$11].transform); + multiply(out, view, out); + } + _originOffsetMatrix() { + return this[PRIVATE$11].originOffset; + } + _adjustForOriginOffset(transformMatrix) { + let inverseOriginOffsetMatrix = identity(new Float32Array(16)); + invert(inverseOriginOffsetMatrix, this[PRIVATE$11].originOffset); + multiply(transformMatrix, inverseOriginOffsetMatrix, transformMatrix); + } + getOffsetReferenceSpace(additionalOffset) { + let newSpace = new XRReferenceSpace( + this[PRIVATE$11].device, + this[PRIVATE$11].type, + this[PRIVATE$11].options, + this[PRIVATE$11].transform, + this[PRIVATE$11].bounds); + multiply(newSpace[PRIVATE$11].originOffset, this[PRIVATE$11].originOffset, additionalOffset.matrix); + return newSpace; + } +} + +const POLYFILLED_XR_COMPATIBLE = Symbol('@@webxr-polyfill/polyfilled-xr-compatible'); +const XR_COMPATIBLE = Symbol('@@webxr-polyfill/xr-compatible'); + +const PRIVATE$12 = Symbol('@@webxr-polyfill/XRWebGLLayer'); +const XRWebGLLayerInit = Object.freeze({ + antialias: true, + depth: false, + stencil: false, + alpha: true, + multiview: false, + ignoreDepthValues: false, + framebufferScaleFactor: 1.0, +}); +class XRWebGLLayer { + constructor(session, context, layerInit={}) { + const config = Object.assign({}, XRWebGLLayerInit, layerInit); + if (!(session instanceof XRSession$1)) { + throw new Error('session must be a XRSession'); + } + if (session.ended) { + throw new Error(`InvalidStateError`); + } + if (context[POLYFILLED_XR_COMPATIBLE]) { + if (context[XR_COMPATIBLE] !== true) { + throw new Error(`InvalidStateError`); + } + } + const framebuffer = context.getParameter(context.FRAMEBUFFER_BINDING); + this[PRIVATE$12] = { + context, + config, + framebuffer, + session, + }; + } + get context() { return this[PRIVATE$12].context; } + get antialias() { return this[PRIVATE$12].config.antialias; } + get ignoreDepthValues() { return true; } + get framebuffer() { return this[PRIVATE$12].framebuffer; } + get framebufferWidth() { return this[PRIVATE$12].context.drawingBufferWidth; } + get framebufferHeight() { return this[PRIVATE$12].context.drawingBufferHeight; } + get _session() { return this[PRIVATE$12].session; } + getViewport(view) { + return view._getViewport(this); + } +} + +const PRIVATE$13 = Symbol('@@webxr-polyfill/XRSession'); +class XRSession$1 extends EventTarget { + constructor(device, mode, id) { + super(); + let immersive = mode != 'inline'; + let outputContext = null; + this[PRIVATE$13] = { + device, + mode, + immersive, + outputContext, + ended: false, + suspended: false, + suspendedCallback: null, + id, + activeRenderState: null, + pendingRenderState: null, + }; + const frame = new XRFrame(device, this, this[PRIVATE$13].id); + this[PRIVATE$13].frame = frame; + this[PRIVATE$13].onPresentationEnd = sessionId => { + if (sessionId !== this[PRIVATE$13].id) { + this[PRIVATE$13].suspended = false; + this.dispatchEvent('focus', { session: this }); + const suspendedCallback = this[PRIVATE$13].suspendedCallback; + this[PRIVATE$13].suspendedCallback = null; + if (suspendedCallback) { + this.requestAnimationFrame(suspendedCallback); + } + return; + } + this[PRIVATE$13].ended = true; + device.removeEventListener('@webvr-polyfill/vr-present-end', this[PRIVATE$13].onPresentationEnd); + device.removeEventListener('@webvr-polyfill/vr-present-start', this[PRIVATE$13].onPresentationStart); + device.removeEventListener('@@webvr-polyfill/input-select-start', this[PRIVATE$13].onSelectStart); + device.removeEventListener('@@webvr-polyfill/input-select-end', this[PRIVATE$13].onSelectEnd); + this.dispatchEvent('end', { session: this }); + }; + device.addEventListener('@@webxr-polyfill/vr-present-end', this[PRIVATE$13].onPresentationEnd); + this[PRIVATE$13].onPresentationStart = sessionId => { + if (sessionId === this[PRIVATE$13].id) { + return; + } + this[PRIVATE$13].suspended = true; + this.dispatchEvent('blur', { session: this }); + }; + device.addEventListener('@@webxr-polyfill/vr-present-start', this[PRIVATE$13].onPresentationStart); + this[PRIVATE$13].onSelectStart = evt => { + if (evt.sessionId !== this[PRIVATE$13].id) { + return; + } + this.dispatchEvent('selectstart', { + frame: this[PRIVATE$13].frame, + inputSource: evt.inputSource + }); + }; + device.addEventListener('@@webxr-polyfill/input-select-start', this[PRIVATE$13].onSelectStart); + this[PRIVATE$13].onSelectEnd = evt => { + if (evt.sessionId !== this[PRIVATE$13].id) { + return; + } + this.dispatchEvent('selectend', { + frame: this[PRIVATE$13].frame, + inputSource: evt.inputSource + }); + this.dispatchEvent('select', { + frame: this[PRIVATE$13].frame, + inputSource: evt.inputSource + }); + }; + device.addEventListener('@@webxr-polyfill/input-select-end', this[PRIVATE$13].onSelectEnd); + this.onblur = undefined; + this.onfocus = undefined; + this.onresetpose = undefined; + this.onend = undefined; + this.onselect = undefined; + this.onselectstart = undefined; + this.onselectend = undefined; + } + get renderState() { return this[PRIVATE$13].activeRenderState; } + get immersive() { return this[PRIVATE$13].immersive; } + get outputContext() { return this[PRIVATE$13].outputContext; } + get depthNear() { return this[PRIVATE$13].device.depthNear; } + set depthNear(value) { this[PRIVATE$13].device.depthNear = value; } + get depthFar() { return this[PRIVATE$13].device.depthFar; } + set depthFar(value) { this[PRIVATE$13].device.depthFar = value; } + get environmentBlendMode() { + return this[PRIVATE$13].device.environmentBlendMode || 'opaque'; + } + get baseLayer() { return this[PRIVATE$13].baseLayer; } + set baseLayer(value) { + if (this[PRIVATE$13].ended) { + return; + } + this[PRIVATE$13].baseLayer = value; + this[PRIVATE$13].device.onBaseLayerSet(this[PRIVATE$13].id, value); + } + async requestReferenceSpace(type, options={}) { + if (this[PRIVATE$13].ended) { + return; + } + options = Object.assign({}, XRReferenceSpaceOptions, options); + if (!XRReferenceSpaceTypes.includes(type)) { + throw new TypeError(`XRReferenceSpaceType must be one of ${XRReferenceSpaceTypes}`); + } + let transform = null; + let bounds = null; + try { + transform = await this[PRIVATE$13].device.requestFrameOfReferenceTransform(type, options); + } catch (e) { + if (type !== 'stage' || options.disableStageEmulation) { + throw e; + } + } + if (type === 'stage' && transform) { + bounds = this[PRIVATE$13].device.requestStageBounds(); + if (bounds) { + bounds = new XRStageBounds(bounds); + } + } + return new XRReferenceSpace(this[PRIVATE$13].device, type, options, transform, bounds); + } + requestAnimationFrame(callback) { + if (this[PRIVATE$13].ended) { + return; + } + if (this[PRIVATE$13].suspended && this[PRIVATE$13].suspendedCallback) { + return; + } + if (this[PRIVATE$13].suspended && !this[PRIVATE$13].suspendedCallback) { + this[PRIVATE$13].suspendedCallback = callback; + } + return this[PRIVATE$13].device.requestAnimationFrame(() => { + if (this[PRIVATE$13].pendingRenderState !== null) { + this[PRIVATE$13].activeRenderState = this[PRIVATE$13].pendingRenderState; + this[PRIVATE$13].pendingRenderState = null; + if (this[PRIVATE$13].activeRenderState.baseLayer) { + this[PRIVATE$13].device.onBaseLayerSet( + this[PRIVATE$13].id, + this[PRIVATE$13].activeRenderState.baseLayer); + } + if (this[PRIVATE$13].activeRenderState.inlineVerticalFieldOfView) { + this[PRIVATE$13].device.onInlineVerticalFieldOfViewSet( + this[PRIVATE$13].id, + this[PRIVATE$13].activeRenderState.inlineVerticalFieldOfView); + } + } + this[PRIVATE$13].device.onFrameStart(this[PRIVATE$13].id); + callback(now$1(), this[PRIVATE$13].frame); + this[PRIVATE$13].device.onFrameEnd(this[PRIVATE$13].id); + }); + } + cancelAnimationFrame(handle) { + if (this[PRIVATE$13].ended) { + return; + } + this[PRIVATE$13].device.cancelAnimationFrame(handle); + } + get inputSources() { + return this[PRIVATE$13].device.getInputSources(); + } + async end() { + if (this[PRIVATE$13].ended) { + return; + } + if (!this.immersive) { + this[PRIVATE$13].ended = true; + this[PRIVATE$13].device.removeEventListener('@@webvr-polyfill/vr-present-start', + this[PRIVATE$13].onPresentationStart); + this[PRIVATE$13].device.removeEventListener('@@webvr-polyfill/vr-present-end', + this[PRIVATE$13].onPresentationEnd); + this[PRIVATE$13].device.removeEventListener('@@webvr-polyfill/input-select-start', + this[PRIVATE$13].onSelectStart); + this[PRIVATE$13].device.removeEventListener('@@webvr-polyfill/input-select-end', + this[PRIVATE$13].onSelectEnd); + this.dispatchEvent('end', { session: this }); + } + return this[PRIVATE$13].device.endSession(this[PRIVATE$13].id); + } + updateRenderState(newState) { + if (this[PRIVATE$13].ended) { + const message = "Can't call updateRenderState on an XRSession " + + "that has already ended."; + throw new Error(message); + } + if (newState.baseLayer && (newState.baseLayer._session !== this)) { + const message = "Called updateRenderState with a base layer that was " + + "created by a different session."; + throw new Error(message); + } + const fovSet = (newState.inlineVerticalFieldOfView !== null) && + (newState.inlineVerticalFieldOfView !== undefined); + if (fovSet) { + if (this[PRIVATE$13].immersive) { + const message = "inlineVerticalFieldOfView must not be set for an " + + "XRRenderState passed to updateRenderState for an " + + "immersive session."; + throw new Error(message); + } else { + newState.inlineVerticalFieldOfView = Math.min( + 3.13, Math.max(0.01, newState.inlineVerticalFieldOfView)); + } + } + if (this[PRIVATE$13].pendingRenderState === null) { + this[PRIVATE$13].pendingRenderState = Object.assign( + {}, this[PRIVATE$13].activeRenderState, newState); + } + } +} + +const PRIVATE$14 = Symbol('@@webxr-polyfill/XRInputSource'); +class XRInputSource { + constructor(impl) { + this[PRIVATE$14] = { + impl, + gripSpace: new XRSpace("grip", this), + targetRaySpace: new XRSpace("target-ray", this) + }; + } + get handedness() { return this[PRIVATE$14].impl.handedness; } + get targetRayMode() { return this[PRIVATE$14].impl.targetRayMode; } + get gripSpace() { + let mode = this[PRIVATE$14].impl.targetRayMode; + if (mode === "gaze" || mode === "screen") { + return null; + } + return this[PRIVATE$14].gripSpace; + } + get targetRaySpace() { return this[PRIVATE$14].targetRaySpace; } + get gamepad() { return this[PRIVATE$14].impl.gamepad; } +} + +const PRIVATE$15 = Symbol('@@webxr-polyfill/XRRenderState'); +const XRRenderStateInit = Object.freeze({ + depthNear: 0.1, + depthFar: 1000.0, + inlineVerticalFieldOfView: null, + baseLayer: null +}); +class XRRenderState { + constructor(stateInit = {}) { + const config = Object.assign({}, XRRenderStateInit, stateInit); + this[PRIVATE$15] = { config }; + } + get depthNear() { return this[PRIVATE$15].depthNear; } + get depthFar() { return this[PRIVATE$15].depthFar; } + get inlineVerticalFieldOfView() { return this[PRIVATE$15].inlineVerticalFieldOfView; } + get baseLayer() { return this[PRIVATE$15].baseLayer; } +} + +var API = { + XR: XR$1, + XRSession: XRSession$1, + XRFrame, + XRView, + XRViewport, + XRViewerPose, + XRWebGLLayer, + XRSpace, + XRReferenceSpace, + XRStageBounds, + XRStageBoundsPoint, + XRInputSource, + XRRenderState, + XRRigidTransform: XRRigidTransform$1, + XRPose: XRPose$1, +}; + +const polyfillMakeXRCompatible = Context => { + if (typeof Context.prototype.makeXRCompatible === 'function') { + return false; + } + Context.prototype.makeXRCompatible = function () { + this[XR_COMPATIBLE] = true; + return Promise.resolve(); + }; + return true; +}; +const polyfillGetContext = (Canvas) => { + const getContext = Canvas.prototype.getContext; + Canvas.prototype.getContext = function (contextType, glAttribs) { + const ctx = getContext.call(this, contextType, glAttribs); + ctx[POLYFILLED_XR_COMPATIBLE] = true; + if (glAttribs && ('xrCompatible' in glAttribs)) { + ctx[XR_COMPATIBLE] = glAttribs.xrCompatible; } - return a; + return ctx; }; -}(); - -var poseMatrixToXRRay = function poseMatrixToXRRay(poseMatrix) { - var rayOrigin = []; - var rayDirection = []; - set$2(rayOrigin, 0, 0, 0); - transformMat4(rayOrigin, rayOrigin, poseMatrix); - set$2(rayDirection, 0, 0, -1); - transformMat4(rayDirection, rayDirection, poseMatrix); - sub$1(rayDirection, rayDirection, rayOrigin); - normalize(rayDirection, rayDirection); - return new XRRay(new DOMPointReadOnly$1(rayOrigin[0], rayOrigin[1], rayOrigin[2], 1.0), new DOMPointReadOnly$1(rayDirection[0], rayDirection[1], rayDirection[2], 0.0), poseMatrix); -}; -var isMobile = function isMobile(global) { - var check = false; - (function (a) { - if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; - })(global.navigator.userAgent || global.navigator.vendor || global.opera); - return check; }; -var applyCanvasStylesForMinimalRendering = function applyCanvasStylesForMinimalRendering(canvas) { + +const isImageBitmapSupported = global => + !!(global.ImageBitmapRenderingContext && + global.createImageBitmap); + +const applyCanvasStylesForMinimalRendering = canvas => { canvas.style.display = 'block'; canvas.style.position = 'absolute'; canvas.style.width = canvas.style.height = '1px'; @@ -1804,8 +2160,8 @@ var slicedToArray = function () { }(); var MIN_TIMESTEP = 0.001; var MAX_TIMESTEP = 1; -var base64 = function base64(mimeType, _base) { - return 'data:' + mimeType + ';base64,' + _base; +var dataUri = function dataUri(mimeType, svg) { + return 'data:' + mimeType + ',' + encodeURIComponent(svg); }; var lerp = function lerp(a, b, t) { return a + (b - a) * t; @@ -3408,8 +3764,8 @@ function CardboardViewer(params) { } DeviceInfo.Viewers = Viewers; var format = 1; -var last_updated = "2018-02-20T22:55:10Z"; -var devices = [{"type":"android","rules":[{"mdmh":"asus/*/Nexus 7/*"},{"ua":"Nexus 7"}],"dpi":[320.8,323],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"asus/*/ASUS_Z00AD/*"},{"ua":"ASUS_Z00AD"}],"dpi":[403,404.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Google/*/Pixel XL/*"},{"ua":"Pixel XL"}],"dpi":[537.9,533],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Google/*/Pixel/*"},{"ua":"Pixel"}],"dpi":[432.6,436.7],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"HTC/*/HTC6435LVW/*"},{"ua":"HTC6435LVW"}],"dpi":[449.7,443.3],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"HTC/*/HTC One XL/*"},{"ua":"HTC One XL"}],"dpi":[315.3,314.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"htc/*/Nexus 9/*"},{"ua":"Nexus 9"}],"dpi":289,"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"HTC/*/HTC One M9/*"},{"ua":"HTC One M9"}],"dpi":[442.5,443.3],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"HTC/*/HTC One_M8/*"},{"ua":"HTC One_M8"}],"dpi":[449.7,447.4],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"HTC/*/HTC One/*"},{"ua":"HTC One"}],"dpi":472.8,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Huawei/*/Nexus 6P/*"},{"ua":"Nexus 6P"}],"dpi":[515.1,518],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"LENOVO/*/Lenovo PB2-690Y/*"},{"ua":"Lenovo PB2-690Y"}],"dpi":[457.2,454.713],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"LGE/*/Nexus 5X/*"},{"ua":"Nexus 5X"}],"dpi":[422,419.9],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"LGE/*/LGMS345/*"},{"ua":"LGMS345"}],"dpi":[221.7,219.1],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"LGE/*/LG-D800/*"},{"ua":"LG-D800"}],"dpi":[422,424.1],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"LGE/*/LG-D850/*"},{"ua":"LG-D850"}],"dpi":[537.9,541.9],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"LGE/*/VS985 4G/*"},{"ua":"VS985 4G"}],"dpi":[537.9,535.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"LGE/*/Nexus 5/*"},{"ua":"Nexus 5 B"}],"dpi":[442.4,444.8],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"LGE/*/Nexus 4/*"},{"ua":"Nexus 4"}],"dpi":[319.8,318.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"LGE/*/LG-P769/*"},{"ua":"LG-P769"}],"dpi":[240.6,247.5],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"LGE/*/LGMS323/*"},{"ua":"LGMS323"}],"dpi":[206.6,204.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"LGE/*/LGLS996/*"},{"ua":"LGLS996"}],"dpi":[403.4,401.5],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Micromax/*/4560MMX/*"},{"ua":"4560MMX"}],"dpi":[240,219.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Micromax/*/A250/*"},{"ua":"Micromax A250"}],"dpi":[480,446.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Micromax/*/Micromax AQ4501/*"},{"ua":"Micromax AQ4501"}],"dpi":240,"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"motorola/*/G5/*"},{"ua":"Moto G (5) Plus"}],"dpi":[403.4,403],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/DROID RAZR/*"},{"ua":"DROID RAZR"}],"dpi":[368.1,256.7],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/XT830C/*"},{"ua":"XT830C"}],"dpi":[254,255.9],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/XT1021/*"},{"ua":"XT1021"}],"dpi":[254,256.7],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"motorola/*/XT1023/*"},{"ua":"XT1023"}],"dpi":[254,256.7],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"motorola/*/XT1028/*"},{"ua":"XT1028"}],"dpi":[326.6,327.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/XT1034/*"},{"ua":"XT1034"}],"dpi":[326.6,328.4],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"motorola/*/XT1053/*"},{"ua":"XT1053"}],"dpi":[315.3,316.1],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/XT1562/*"},{"ua":"XT1562"}],"dpi":[403.4,402.7],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/Nexus 6/*"},{"ua":"Nexus 6 B"}],"dpi":[494.3,489.7],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/XT1063/*"},{"ua":"XT1063"}],"dpi":[295,296.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/XT1064/*"},{"ua":"XT1064"}],"dpi":[295,295.6],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"motorola/*/XT1092/*"},{"ua":"XT1092"}],"dpi":[422,424.1],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"motorola/*/XT1095/*"},{"ua":"XT1095"}],"dpi":[422,423.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/G4/*"},{"ua":"Moto G (4)"}],"dpi":401,"bw":4,"ac":1000},{"type":"android","rules":[{"mdmh":"OnePlus/*/A0001/*"},{"ua":"A0001"}],"dpi":[403.4,401],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"OnePlus/*/ONE E1005/*"},{"ua":"ONE E1005"}],"dpi":[442.4,441.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"OnePlus/*/ONE A2005/*"},{"ua":"ONE A2005"}],"dpi":[391.9,405.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"OnePlus/*/ONEPLUS A5000/*"},{"ua":"ONEPLUS A5000 "}],"dpi":[403.411,399.737],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"OnePlus/*/ONE A5010/*"},{"ua":"ONEPLUS A5010"}],"dpi":[403,400],"bw":2,"ac":1000},{"type":"android","rules":[{"mdmh":"OPPO/*/X909/*"},{"ua":"X909"}],"dpi":[442.4,444.1],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/GT-I9082/*"},{"ua":"GT-I9082"}],"dpi":[184.7,185.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G360P/*"},{"ua":"SM-G360P"}],"dpi":[196.7,205.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/Nexus S/*"},{"ua":"Nexus S"}],"dpi":[234.5,229.8],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/GT-I9300/*"},{"ua":"GT-I9300"}],"dpi":[304.8,303.9],"bw":5,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-T230NU/*"},{"ua":"SM-T230NU"}],"dpi":216,"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SGH-T399/*"},{"ua":"SGH-T399"}],"dpi":[217.7,231.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SGH-M919/*"},{"ua":"SGH-M919"}],"dpi":[440.8,437.7],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-N9005/*"},{"ua":"SM-N9005"}],"dpi":[386.4,387],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SAMSUNG-SM-N900A/*"},{"ua":"SAMSUNG-SM-N900A"}],"dpi":[386.4,387.7],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/GT-I9500/*"},{"ua":"GT-I9500"}],"dpi":[442.5,443.3],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/GT-I9505/*"},{"ua":"GT-I9505"}],"dpi":439.4,"bw":4,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G900F/*"},{"ua":"SM-G900F"}],"dpi":[415.6,431.6],"bw":5,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G900M/*"},{"ua":"SM-G900M"}],"dpi":[415.6,431.6],"bw":5,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G800F/*"},{"ua":"SM-G800F"}],"dpi":326.8,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G906S/*"},{"ua":"SM-G906S"}],"dpi":[562.7,572.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/GT-I9300/*"},{"ua":"GT-I9300"}],"dpi":[306.7,304.8],"bw":5,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-T535/*"},{"ua":"SM-T535"}],"dpi":[142.6,136.4],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-N920C/*"},{"ua":"SM-N920C"}],"dpi":[515.1,518.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-N920P/*"},{"ua":"SM-N920P"}],"dpi":[386.3655,390.144],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-N920W8/*"},{"ua":"SM-N920W8"}],"dpi":[515.1,518.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/GT-I9300I/*"},{"ua":"GT-I9300I"}],"dpi":[304.8,305.8],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/GT-I9195/*"},{"ua":"GT-I9195"}],"dpi":[249.4,256.7],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SPH-L520/*"},{"ua":"SPH-L520"}],"dpi":[249.4,255.9],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SAMSUNG-SGH-I717/*"},{"ua":"SAMSUNG-SGH-I717"}],"dpi":285.8,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SPH-D710/*"},{"ua":"SPH-D710"}],"dpi":[217.7,204.2],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/GT-N7100/*"},{"ua":"GT-N7100"}],"dpi":265.1,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SCH-I605/*"},{"ua":"SCH-I605"}],"dpi":265.1,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/Galaxy Nexus/*"},{"ua":"Galaxy Nexus"}],"dpi":[315.3,314.2],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-N910H/*"},{"ua":"SM-N910H"}],"dpi":[515.1,518],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-N910C/*"},{"ua":"SM-N910C"}],"dpi":[515.2,520.2],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G130M/*"},{"ua":"SM-G130M"}],"dpi":[165.9,164.8],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G928I/*"},{"ua":"SM-G928I"}],"dpi":[515.1,518.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G920F/*"},{"ua":"SM-G920F"}],"dpi":580.6,"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G920P/*"},{"ua":"SM-G920P"}],"dpi":[522.5,577],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G925F/*"},{"ua":"SM-G925F"}],"dpi":580.6,"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G925V/*"},{"ua":"SM-G925V"}],"dpi":[522.5,576.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G930F/*"},{"ua":"SM-G930F"}],"dpi":576.6,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G935F/*"},{"ua":"SM-G935F"}],"dpi":533,"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G950F/*"},{"ua":"SM-G950F"}],"dpi":[562.707,565.293],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G955U/*"},{"ua":"SM-G955U"}],"dpi":[522.514,525.762],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"Sony/*/C6903/*"},{"ua":"C6903"}],"dpi":[442.5,443.3],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"Sony/*/D6653/*"},{"ua":"D6653"}],"dpi":[428.6,427.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Sony/*/E6653/*"},{"ua":"E6653"}],"dpi":[428.6,425.7],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Sony/*/E6853/*"},{"ua":"E6853"}],"dpi":[403.4,401.9],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Sony/*/SGP321/*"},{"ua":"SGP321"}],"dpi":[224.7,224.1],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"TCT/*/ALCATEL ONE TOUCH Fierce/*"},{"ua":"ALCATEL ONE TOUCH Fierce"}],"dpi":[240,247.5],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"THL/*/thl 5000/*"},{"ua":"thl 5000"}],"dpi":[480,443.3],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Fly/*/IQ4412/*"},{"ua":"IQ4412"}],"dpi":307.9,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"ZTE/*/ZTE Blade L2/*"},{"ua":"ZTE Blade L2"}],"dpi":240,"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"BENEVE/*/VR518/*"},{"ua":"VR518"}],"dpi":480,"bw":3,"ac":500},{"type":"ios","rules":[{"res":[640,960]}],"dpi":[325.1,328.4],"bw":4,"ac":1000},{"type":"ios","rules":[{"res":[640,1136]}],"dpi":[317.1,320.2],"bw":3,"ac":1000},{"type":"ios","rules":[{"res":[750,1334]}],"dpi":326.4,"bw":4,"ac":1000},{"type":"ios","rules":[{"res":[1242,2208]}],"dpi":[453.6,458.4],"bw":4,"ac":1000},{"type":"ios","rules":[{"res":[1125,2001]}],"dpi":[410.9,415.4],"bw":4,"ac":1000},{"type":"ios","rules":[{"res":[1125,2436]}],"dpi":458,"bw":4,"ac":1000}]; +var last_updated = "2018-12-10T17:01:42Z"; +var devices = [{"type":"android","rules":[{"mdmh":"asus/*/Nexus 7/*"},{"ua":"Nexus 7"}],"dpi":[320.8,323],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"asus/*/ASUS_Z00AD/*"},{"ua":"ASUS_Z00AD"}],"dpi":[403,404.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Google/*/Pixel 2 XL/*"},{"ua":"Pixel 2 XL"}],"dpi":537.9,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Google/*/Pixel 3 XL/*"},{"ua":"Pixel 3 XL"}],"dpi":[558.5,553.8],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Google/*/Pixel XL/*"},{"ua":"Pixel XL"}],"dpi":[537.9,533],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Google/*/Pixel 3/*"},{"ua":"Pixel 3"}],"dpi":442.4,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Google/*/Pixel 2/*"},{"ua":"Pixel 2"}],"dpi":441,"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"Google/*/Pixel/*"},{"ua":"Pixel"}],"dpi":[432.6,436.7],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"HTC/*/HTC6435LVW/*"},{"ua":"HTC6435LVW"}],"dpi":[449.7,443.3],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"HTC/*/HTC One XL/*"},{"ua":"HTC One XL"}],"dpi":[315.3,314.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"htc/*/Nexus 9/*"},{"ua":"Nexus 9"}],"dpi":289,"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"HTC/*/HTC One M9/*"},{"ua":"HTC One M9"}],"dpi":[442.5,443.3],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"HTC/*/HTC One_M8/*"},{"ua":"HTC One_M8"}],"dpi":[449.7,447.4],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"HTC/*/HTC One/*"},{"ua":"HTC One"}],"dpi":472.8,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Huawei/*/Nexus 6P/*"},{"ua":"Nexus 6P"}],"dpi":[515.1,518],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Huawei/*/BLN-L24/*"},{"ua":"HONORBLN-L24"}],"dpi":480,"bw":4,"ac":500},{"type":"android","rules":[{"mdmh":"Huawei/*/BKL-L09/*"},{"ua":"BKL-L09"}],"dpi":403,"bw":3.47,"ac":500},{"type":"android","rules":[{"mdmh":"LENOVO/*/Lenovo PB2-690Y/*"},{"ua":"Lenovo PB2-690Y"}],"dpi":[457.2,454.713],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"LGE/*/Nexus 5X/*"},{"ua":"Nexus 5X"}],"dpi":[422,419.9],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"LGE/*/LGMS345/*"},{"ua":"LGMS345"}],"dpi":[221.7,219.1],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"LGE/*/LG-D800/*"},{"ua":"LG-D800"}],"dpi":[422,424.1],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"LGE/*/LG-D850/*"},{"ua":"LG-D850"}],"dpi":[537.9,541.9],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"LGE/*/VS985 4G/*"},{"ua":"VS985 4G"}],"dpi":[537.9,535.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"LGE/*/Nexus 5/*"},{"ua":"Nexus 5 B"}],"dpi":[442.4,444.8],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"LGE/*/Nexus 4/*"},{"ua":"Nexus 4"}],"dpi":[319.8,318.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"LGE/*/LG-P769/*"},{"ua":"LG-P769"}],"dpi":[240.6,247.5],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"LGE/*/LGMS323/*"},{"ua":"LGMS323"}],"dpi":[206.6,204.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"LGE/*/LGLS996/*"},{"ua":"LGLS996"}],"dpi":[403.4,401.5],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Micromax/*/4560MMX/*"},{"ua":"4560MMX"}],"dpi":[240,219.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Micromax/*/A250/*"},{"ua":"Micromax A250"}],"dpi":[480,446.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Micromax/*/Micromax AQ4501/*"},{"ua":"Micromax AQ4501"}],"dpi":240,"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"motorola/*/G5/*"},{"ua":"Moto G (5) Plus"}],"dpi":[403.4,403],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/DROID RAZR/*"},{"ua":"DROID RAZR"}],"dpi":[368.1,256.7],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/XT830C/*"},{"ua":"XT830C"}],"dpi":[254,255.9],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/XT1021/*"},{"ua":"XT1021"}],"dpi":[254,256.7],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"motorola/*/XT1023/*"},{"ua":"XT1023"}],"dpi":[254,256.7],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"motorola/*/XT1028/*"},{"ua":"XT1028"}],"dpi":[326.6,327.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/XT1034/*"},{"ua":"XT1034"}],"dpi":[326.6,328.4],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"motorola/*/XT1053/*"},{"ua":"XT1053"}],"dpi":[315.3,316.1],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/XT1562/*"},{"ua":"XT1562"}],"dpi":[403.4,402.7],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/Nexus 6/*"},{"ua":"Nexus 6 B"}],"dpi":[494.3,489.7],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/XT1063/*"},{"ua":"XT1063"}],"dpi":[295,296.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/XT1064/*"},{"ua":"XT1064"}],"dpi":[295,295.6],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"motorola/*/XT1092/*"},{"ua":"XT1092"}],"dpi":[422,424.1],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"motorola/*/XT1095/*"},{"ua":"XT1095"}],"dpi":[422,423.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"motorola/*/G4/*"},{"ua":"Moto G (4)"}],"dpi":401,"bw":4,"ac":1000},{"type":"android","rules":[{"mdmh":"OnePlus/*/A0001/*"},{"ua":"A0001"}],"dpi":[403.4,401],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"OnePlus/*/ONE E1005/*"},{"ua":"ONE E1005"}],"dpi":[442.4,441.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"OnePlus/*/ONE A2005/*"},{"ua":"ONE A2005"}],"dpi":[391.9,405.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"OnePlus/*/ONEPLUS A5000/*"},{"ua":"ONEPLUS A5000 "}],"dpi":[403.411,399.737],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"OnePlus/*/ONE A5010/*"},{"ua":"ONEPLUS A5010"}],"dpi":[403,400],"bw":2,"ac":1000},{"type":"android","rules":[{"mdmh":"OPPO/*/X909/*"},{"ua":"X909"}],"dpi":[442.4,444.1],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/GT-I9082/*"},{"ua":"GT-I9082"}],"dpi":[184.7,185.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G360P/*"},{"ua":"SM-G360P"}],"dpi":[196.7,205.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/Nexus S/*"},{"ua":"Nexus S"}],"dpi":[234.5,229.8],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/GT-I9300/*"},{"ua":"GT-I9300"}],"dpi":[304.8,303.9],"bw":5,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-T230NU/*"},{"ua":"SM-T230NU"}],"dpi":216,"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SGH-T399/*"},{"ua":"SGH-T399"}],"dpi":[217.7,231.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SGH-M919/*"},{"ua":"SGH-M919"}],"dpi":[440.8,437.7],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-N9005/*"},{"ua":"SM-N9005"}],"dpi":[386.4,387],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SAMSUNG-SM-N900A/*"},{"ua":"SAMSUNG-SM-N900A"}],"dpi":[386.4,387.7],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/GT-I9500/*"},{"ua":"GT-I9500"}],"dpi":[442.5,443.3],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/GT-I9505/*"},{"ua":"GT-I9505"}],"dpi":439.4,"bw":4,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G900F/*"},{"ua":"SM-G900F"}],"dpi":[415.6,431.6],"bw":5,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G900M/*"},{"ua":"SM-G900M"}],"dpi":[415.6,431.6],"bw":5,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G800F/*"},{"ua":"SM-G800F"}],"dpi":326.8,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G906S/*"},{"ua":"SM-G906S"}],"dpi":[562.7,572.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/GT-I9300/*"},{"ua":"GT-I9300"}],"dpi":[306.7,304.8],"bw":5,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-T535/*"},{"ua":"SM-T535"}],"dpi":[142.6,136.4],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-N920C/*"},{"ua":"SM-N920C"}],"dpi":[515.1,518.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-N920P/*"},{"ua":"SM-N920P"}],"dpi":[386.3655,390.144],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-N920W8/*"},{"ua":"SM-N920W8"}],"dpi":[515.1,518.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/GT-I9300I/*"},{"ua":"GT-I9300I"}],"dpi":[304.8,305.8],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/GT-I9195/*"},{"ua":"GT-I9195"}],"dpi":[249.4,256.7],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SPH-L520/*"},{"ua":"SPH-L520"}],"dpi":[249.4,255.9],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SAMSUNG-SGH-I717/*"},{"ua":"SAMSUNG-SGH-I717"}],"dpi":285.8,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SPH-D710/*"},{"ua":"SPH-D710"}],"dpi":[217.7,204.2],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/GT-N7100/*"},{"ua":"GT-N7100"}],"dpi":265.1,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SCH-I605/*"},{"ua":"SCH-I605"}],"dpi":265.1,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/Galaxy Nexus/*"},{"ua":"Galaxy Nexus"}],"dpi":[315.3,314.2],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-N910H/*"},{"ua":"SM-N910H"}],"dpi":[515.1,518],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-N910C/*"},{"ua":"SM-N910C"}],"dpi":[515.2,520.2],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G130M/*"},{"ua":"SM-G130M"}],"dpi":[165.9,164.8],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G928I/*"},{"ua":"SM-G928I"}],"dpi":[515.1,518.4],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G920F/*"},{"ua":"SM-G920F"}],"dpi":580.6,"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G920P/*"},{"ua":"SM-G920P"}],"dpi":[522.5,577],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G925F/*"},{"ua":"SM-G925F"}],"dpi":580.6,"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G925V/*"},{"ua":"SM-G925V"}],"dpi":[522.5,576.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G930F/*"},{"ua":"SM-G930F"}],"dpi":576.6,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G935F/*"},{"ua":"SM-G935F"}],"dpi":533,"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G950F/*"},{"ua":"SM-G950F"}],"dpi":[562.707,565.293],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G955U/*"},{"ua":"SM-G955U"}],"dpi":[522.514,525.762],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"samsung/*/SM-G955F/*"},{"ua":"SM-G955F"}],"dpi":[522.514,525.762],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"Sony/*/C6903/*"},{"ua":"C6903"}],"dpi":[442.5,443.3],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"Sony/*/D6653/*"},{"ua":"D6653"}],"dpi":[428.6,427.6],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Sony/*/E6653/*"},{"ua":"E6653"}],"dpi":[428.6,425.7],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Sony/*/E6853/*"},{"ua":"E6853"}],"dpi":[403.4,401.9],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Sony/*/SGP321/*"},{"ua":"SGP321"}],"dpi":[224.7,224.1],"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"TCT/*/ALCATEL ONE TOUCH Fierce/*"},{"ua":"ALCATEL ONE TOUCH Fierce"}],"dpi":[240,247.5],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"THL/*/thl 5000/*"},{"ua":"thl 5000"}],"dpi":[480,443.3],"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"Fly/*/IQ4412/*"},{"ua":"IQ4412"}],"dpi":307.9,"bw":3,"ac":1000},{"type":"android","rules":[{"mdmh":"ZTE/*/ZTE Blade L2/*"},{"ua":"ZTE Blade L2"}],"dpi":240,"bw":3,"ac":500},{"type":"android","rules":[{"mdmh":"BENEVE/*/VR518/*"},{"ua":"VR518"}],"dpi":480,"bw":3,"ac":500},{"type":"ios","rules":[{"res":[640,960]}],"dpi":[325.1,328.4],"bw":4,"ac":1000},{"type":"ios","rules":[{"res":[640,1136]}],"dpi":[317.1,320.2],"bw":3,"ac":1000},{"type":"ios","rules":[{"res":[750,1334]}],"dpi":326.4,"bw":4,"ac":1000},{"type":"ios","rules":[{"res":[1242,2208]}],"dpi":[453.6,458.4],"bw":4,"ac":1000},{"type":"ios","rules":[{"res":[1125,2001]}],"dpi":[410.9,415.4],"bw":4,"ac":1000},{"type":"ios","rules":[{"res":[1125,2436]}],"dpi":458,"bw":4,"ac":1000}]; var DPDB_CACHE = { format: format, last_updated: last_updated, @@ -3484,7 +3840,7 @@ Dpdb.prototype.calcDeviceParams_ = function () { var matched = false; for (var j = 0; j < device.rules.length; j++) { var rule = device.rules[j]; - if (this.matchRule_(rule, userAgent, width, height)) { + if (this.ruleMatches_(rule, userAgent, width, height)) { matched = true; break; } @@ -3497,8 +3853,9 @@ Dpdb.prototype.calcDeviceParams_ = function () { console.warn('No DPDB device match.'); return null; }; -Dpdb.prototype.matchRule_ = function (rule, ua, screenWidth, screenHeight) { +Dpdb.prototype.ruleMatches_ = function (rule, ua, screenWidth, screenHeight) { if (!rule.ua && !rule.res) return false; + if (rule.ua && rule.ua.substring(0, 2) === 'SM') rule.ua = rule.ua.substring(0, 7); if (rule.ua && ua.indexOf(rule.ua) < 0) return false; if (rule.res) { if (!rule.res[0] || !rule.res[1]) return false; @@ -3834,18 +4191,6 @@ FusionPoseSensor.prototype.stop = function () { var SENSOR_FREQUENCY = 60; var X_AXIS = new Vector3(1, 0, 0); var Z_AXIS = new Vector3(0, 0, 1); -var orientation = {}; -if (screen.orientation) { - orientation = screen.orientation; -} else if (screen.msOrientation) { - orientation = screen.msOrientation; -} else { - Object.defineProperty(orientation, 'angle', { - get: function get$$1() { - return window.orientation || 0; - } - }); -} var SENSOR_TO_VR = new Quaternion(); SENSOR_TO_VR.setFromAxisAngle(X_AXIS, -Math.PI / 2); SENSOR_TO_VR.multiply(new Quaternion().setFromAxisAngle(Z_AXIS, Math.PI / 2)); @@ -3859,12 +4204,9 @@ var PoseSensor = function () { this.api = null; this.errors = []; this._sensorQ = new Quaternion(); - this._worldToScreenQ = new Quaternion(); this._outQ = new Quaternion(); this._onSensorRead = this._onSensorRead.bind(this); this._onSensorError = this._onSensorError.bind(this); - this._onOrientationChange = this._onOrientationChange.bind(this); - this._onOrientationChange(); this.init(); } createClass(PoseSensor, [{ @@ -3872,7 +4214,10 @@ var PoseSensor = function () { value: function init() { var sensor = null; try { - sensor = new RelativeOrientationSensor({ frequency: SENSOR_FREQUENCY }); + sensor = new RelativeOrientationSensor({ + frequency: SENSOR_FREQUENCY, + referenceFrame: 'screen' + }); sensor.addEventListener('error', this._onSensorError); } catch (error) { this.errors.push(error); @@ -3892,7 +4237,6 @@ var PoseSensor = function () { this.sensor.addEventListener('reading', this._onSensorRead); this.sensor.start(); } - window.addEventListener('orientationchange', this._onOrientationChange); } }, { key: 'useDeviceMotion', @@ -3921,7 +4265,6 @@ var PoseSensor = function () { var out = this._outQ; out.copy(SENSOR_TO_VR); out.multiply(this._sensorQ); - out.multiply(this._worldToScreenQ); if (this.config.YAW_ONLY) { out.x = out.z = 0; out.normalize(); @@ -3948,16 +4291,10 @@ var PoseSensor = function () { }, { key: '_onSensorRead', value: function _onSensorRead() {} - }, { - key: '_onOrientationChange', - value: function _onOrientationChange() { - var angle = -orientation.angle * Math.PI / 180; - this._worldToScreenQ.setFromAxisAngle(Z_AXIS, angle); - } }]); return PoseSensor; }(); -var rotateInstructionsAsset = 'PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjE5OHB4IiBoZWlnaHQ9IjI0MHB4IiB2aWV3Qm94PSIwIDAgMTk4IDI0MCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWxuczpza2V0Y2g9Imh0dHA6Ly93d3cuYm9oZW1pYW5jb2RpbmcuY29tL3NrZXRjaC9ucyI+CiAgICA8IS0tIEdlbmVyYXRvcjogU2tldGNoIDMuMy4zICgxMjA4MSkgLSBodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2ggLS0+CiAgICA8dGl0bGU+dHJhbnNpdGlvbjwvdGl0bGU+CiAgICA8ZGV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NzUgTDEwLjA4Myw0Ni40MjEgTDEwLjE0Niw0Ni4zODUgTDc3LjQwMyw3LjU1NCBMNzcuNDAzLDUxLjUwOCBMNzcuMzQxLDUxLjU0NCBMMTAuMDgzLDkwLjM3NSBMMTAuMDgzLDkwLjM3NSBaIE0xMC4zMzMsNDYuNTY0IEwxMC4zMzMsODkuOTQ0IEw3Ny4xNTQsNTEuMzY1IEw3Ny4xNTQsNy45ODUgTDEwLjMzMyw0Ni41NjQgTDEwLjMzMyw0Ni41NjQgWiIgaWQ9IkZpbGwtMjAiIGZpbGw9IiM2MDdEOEIiPjwvcGF0aD4KICAgICAgICAgICAgICAgIDwvZz4KICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0xMjUuNzM3LDg4LjY0NyBMMTE4LjA5OCw5MS45ODEgTDExOC4wOTgsODQgTDEwNi42MzksODguNzEzIEwxMDYuNjM5LDk2Ljk4MiBMOTksMTAwLjMxNSBMMTEyLjM2OSwxMDMuOTYxIEwxMjUuNzM3LDg4LjY0NyIgaWQ9IkltcG9ydGVkLUxheWVycy1Db3B5LTIiIGZpbGw9IiM0NTVBNjQiIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+'; +var rotateInstructionsAsset = ""; function RotateInstructions() { this.loadIcon_(); var overlay = document.createElement('div'); @@ -4057,7 +4394,7 @@ RotateInstructions.prototype.update = function () { } }; RotateInstructions.prototype.loadIcon_ = function () { - this.icon = base64('image/svg+xml', rotateInstructionsAsset); + this.icon = dataUri('image/svg+xml', rotateInstructionsAsset); }; var DEFAULT_VIEWER = 'CardboardV1'; var VIEWER_KEY = 'WEBVR_CARDBOARD_VIEWER'; @@ -4202,7 +4539,7 @@ ViewerSelector.prototype.createButton_ = function (label, onclick) { }; var commonjsGlobal$$1 = typeof window !== 'undefined' ? window : typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : typeof self !== 'undefined' ? self : {}; function unwrapExports$$1 (x) { - return x && x.__esModule ? x['default'] : x; + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } function createCommonjsModule$$1(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; @@ -4813,585 +5150,235 @@ CardboardVRDisplay.prototype.beginPresent_ = function () { e.stopPropagation(); e.preventDefault(); }.bind(this), function (e) { - this.exitPresent(); - e.stopPropagation(); - e.preventDefault(); - }.bind(this)); - } - if (this.rotateInstructions_) { - if (isLandscapeMode() && isMobile()) { - this.rotateInstructions_.showTemporarily(3000, this.layer_.source.parentElement); - } else { - this.rotateInstructions_.update(); - } - } - this.orientationHandler = this.onOrientationChange_.bind(this); - window.addEventListener('orientationchange', this.orientationHandler); - this.vrdisplaypresentchangeHandler = this.updateBounds_.bind(this); - window.addEventListener('vrdisplaypresentchange', this.vrdisplaypresentchangeHandler); - this.fireVRDisplayDeviceParamsChange_(); -}; -CardboardVRDisplay.prototype.endPresent_ = function () { - if (this.distorter_) { - this.distorter_.destroy(); - this.distorter_ = null; - } - if (this.cardboardUI_) { - this.cardboardUI_.destroy(); - this.cardboardUI_ = null; - } - if (this.rotateInstructions_) { - this.rotateInstructions_.hide(); - } - this.viewerSelector_.hide(); - window.removeEventListener('orientationchange', this.orientationHandler); - window.removeEventListener('vrdisplaypresentchange', this.vrdisplaypresentchangeHandler); -}; -CardboardVRDisplay.prototype.updatePresent_ = function () { - this.endPresent_(); - this.beginPresent_(); -}; -CardboardVRDisplay.prototype.submitFrame = function (pose) { - if (this.distorter_) { - this.updateBounds_(); - this.distorter_.submitFrame(); - } else if (this.cardboardUI_ && this.layer_) { - var canvas = this.layer_.source.getContext('webgl').canvas; - if (canvas.width != this.lastWidth || canvas.height != this.lastHeight) { - this.cardboardUI_.onResize(); - } - this.lastWidth = canvas.width; - this.lastHeight = canvas.height; - this.cardboardUI_.render(); - } -}; -CardboardVRDisplay.prototype.onOrientationChange_ = function (e) { - this.viewerSelector_.hide(); - if (this.rotateInstructions_) { - this.rotateInstructions_.update(); - } - this.onResize_(); -}; -CardboardVRDisplay.prototype.onResize_ = function (e) { - if (this.layer_) { - var gl = this.layer_.source.getContext('webgl'); - var cssProperties = ['position: absolute', 'top: 0', 'left: 0', - 'width: 100vw', 'height: 100vh', 'border: 0', 'margin: 0', - 'padding: 0px', 'box-sizing: content-box']; - gl.canvas.setAttribute('style', cssProperties.join('; ') + ';'); - safariCssSizeWorkaround(gl.canvas); - } -}; -CardboardVRDisplay.prototype.onViewerChanged_ = function (viewer) { - this.deviceInfo_.setViewer(viewer); - if (this.distorter_) { - this.distorter_.updateDeviceInfo(this.deviceInfo_); - } - this.fireVRDisplayDeviceParamsChange_(); -}; -CardboardVRDisplay.prototype.fireVRDisplayDeviceParamsChange_ = function () { - var event = new CustomEvent('vrdisplaydeviceparamschange', { - detail: { - vrdisplay: this, - deviceInfo: this.deviceInfo_ - } - }); - window.dispatchEvent(event); -}; -CardboardVRDisplay.VRFrameData = VRFrameData; -CardboardVRDisplay.VRDisplay = VRDisplay; -return CardboardVRDisplay; -}))); -}); -var CardboardVRDisplay = unwrapExports(cardboardVrDisplay); - -var PolyfilledXRDevice = function (_EventTarget) { - inherits(PolyfilledXRDevice, _EventTarget); - function PolyfilledXRDevice(global) { - classCallCheck(this, PolyfilledXRDevice); - var _this = possibleConstructorReturn(this, (PolyfilledXRDevice.__proto__ || Object.getPrototypeOf(PolyfilledXRDevice)).call(this)); - _this.global = global; - _this.onWindowResize = _this.onWindowResize.bind(_this); - _this.global.window.addEventListener('resize', _this.onWindowResize); - _this.environmentBlendMode = 'opaque'; - return _this; - } - createClass(PolyfilledXRDevice, [{ - key: 'onBaseLayerSet', - value: function onBaseLayerSet(sessionId, layer) { - throw new Error('Not implemented'); - } - }, { - key: 'supportsSession', - value: function supportsSession() { - throw new Error('Not implemented'); - } - }, { - key: 'requestSession', - value: function requestSession() { - return new Promise(function ($return, $error) { - return $error(new Error('Not implemented')); - }.bind(this)); - } - }, { - key: 'requestAnimationFrame', - value: function requestAnimationFrame(callback) { - throw new Error('Not implemented'); - } - }, { - key: 'onFrameStart', - value: function onFrameStart(sessionId) { - throw new Error('Not implemented'); - } - }, { - key: 'onFrameEnd', - value: function onFrameEnd(sessionId) { - throw new Error('Not implemented'); - } - }, { - key: 'requestStageBounds', - value: function requestStageBounds() { - throw new Error('Not implemented'); - } - }, { - key: 'requestFrameOfReferenceTransform', - value: function requestFrameOfReferenceTransform(type, options) { - return new Promise(function ($return, $error) { - return $return(undefined); - }.bind(this)); - } - }, { - key: 'cancelAnimationFrame', - value: function cancelAnimationFrame(handle) { - throw new Error('Not implemented'); - } - }, { - key: 'endSession', - value: function endSession(sessionId) { - throw new Error('Not implemented'); - } - }, { - key: 'getViewport', - value: function getViewport(sessionId, eye, layer, target) { - throw new Error('Not implemented'); - } - }, { - key: 'getProjectionMatrix', - value: function getProjectionMatrix(eye) { - throw new Error('Not implemented'); - } - }, { - key: 'getBasePoseMatrix', - value: function getBasePoseMatrix() { - throw new Error('Not implemented'); - } - }, { - key: 'getBaseViewMatrix', - value: function getBaseViewMatrix(eye) { - throw new Error('Not implemented'); - } - }, { - key: 'getInputSources', - value: function getInputSources() { - throw new Error('Not implemented'); - } - }, { - key: 'getInputPose', - value: function getInputPose(inputSource, coordinateSystem) { - throw new Error('Not implemented'); - } - }, { - key: 'onWindowResize', - value: function onWindowResize() { - this.onWindowResize(); - } - }, { - key: 'depthNear', - get: function get$$1() { - throw new Error('Not implemented'); - } - , - set: function set$$1(val) { - throw new Error('Not implemented'); - } - }, { - key: 'depthFar', - get: function get$$1() { - throw new Error('Not implemented'); - } - , - set: function set$$1(val) { - throw new Error('Not implemented'); - } - }]); - return PolyfilledXRDevice; -}(EventTarget); - -function create$2() { - var out = new ARRAY_TYPE(9); - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 1; - out[5] = 0; - out[6] = 0; - out[7] = 0; - out[8] = 1; - return out; -} - -function create$3() { - var out = new ARRAY_TYPE(4); - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 0; - return out; -} -function clone$3(a) { - var out = new ARRAY_TYPE(4); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - return out; -} - -function copy$3(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - return out; -} - - - - - - - - - - - - - - - - - - -function normalize$1(out, a) { - var x = a[0]; - var y = a[1]; - var z = a[2]; - var w = a[3]; - var len = x * x + y * y + z * z + w * w; - if (len > 0) { - len = 1 / Math.sqrt(len); - out[0] = x * len; - out[1] = y * len; - out[2] = z * len; - out[3] = w * len; - } - return out; -} - - - - - - - - - - - - - - - -var forEach$1 = function () { - var vec = create$3(); - return function (a, stride, offset, count, fn, arg) { - var i = void 0, - l = void 0; - if (!stride) { - stride = 4; - } - if (!offset) { - offset = 0; - } - if (count) { - l = Math.min(count * stride + offset, a.length); + this.exitPresent(); + e.stopPropagation(); + e.preventDefault(); + }.bind(this)); + } + if (this.rotateInstructions_) { + if (isLandscapeMode() && isMobile()) { + this.rotateInstructions_.showTemporarily(3000, this.layer_.source.parentElement); } else { - l = a.length; + this.rotateInstructions_.update(); } - for (i = offset; i < l; i += stride) { - vec[0] = a[i];vec[1] = a[i + 1];vec[2] = a[i + 2];vec[3] = a[i + 3]; - fn(vec, vec, arg); - a[i] = vec[0];a[i + 1] = vec[1];a[i + 2] = vec[2];a[i + 3] = vec[3]; + } + this.orientationHandler = this.onOrientationChange_.bind(this); + window.addEventListener('orientationchange', this.orientationHandler); + this.vrdisplaypresentchangeHandler = this.updateBounds_.bind(this); + window.addEventListener('vrdisplaypresentchange', this.vrdisplaypresentchangeHandler); + this.fireVRDisplayDeviceParamsChange_(); +}; +CardboardVRDisplay.prototype.endPresent_ = function () { + if (this.distorter_) { + this.distorter_.destroy(); + this.distorter_ = null; + } + if (this.cardboardUI_) { + this.cardboardUI_.destroy(); + this.cardboardUI_ = null; + } + if (this.rotateInstructions_) { + this.rotateInstructions_.hide(); + } + this.viewerSelector_.hide(); + window.removeEventListener('orientationchange', this.orientationHandler); + window.removeEventListener('vrdisplaypresentchange', this.vrdisplaypresentchangeHandler); +}; +CardboardVRDisplay.prototype.updatePresent_ = function () { + this.endPresent_(); + this.beginPresent_(); +}; +CardboardVRDisplay.prototype.submitFrame = function (pose) { + if (this.distorter_) { + this.updateBounds_(); + this.distorter_.submitFrame(); + } else if (this.cardboardUI_ && this.layer_) { + var canvas = this.layer_.source.getContext('webgl').canvas; + if (canvas.width != this.lastWidth || canvas.height != this.lastHeight) { + this.cardboardUI_.onResize(); } - return a; - }; -}(); - -function create$4() { - var out = new ARRAY_TYPE(4); - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 1; - return out; -} - -function setAxisAngle(out, axis, rad) { - rad = rad * 0.5; - var s = Math.sin(rad); - out[0] = s * axis[0]; - out[1] = s * axis[1]; - out[2] = s * axis[2]; - out[3] = Math.cos(rad); - return out; -} - -function multiply$4(out, a, b) { - var ax = a[0], - ay = a[1], - az = a[2], - aw = a[3]; - var bx = b[0], - by = b[1], - bz = b[2], - bw = b[3]; - out[0] = ax * bw + aw * bx + ay * bz - az * by; - out[1] = ay * bw + aw * by + az * bx - ax * bz; - out[2] = az * bw + aw * bz + ax * by - ay * bx; - out[3] = aw * bw - ax * bx - ay * by - az * bz; - return out; -} - - - - -function slerp(out, a, b, t) { - var ax = a[0], - ay = a[1], - az = a[2], - aw = a[3]; - var bx = b[0], - by = b[1], - bz = b[2], - bw = b[3]; - var omega = void 0, - cosom = void 0, - sinom = void 0, - scale0 = void 0, - scale1 = void 0; - cosom = ax * bx + ay * by + az * bz + aw * bw; - if (cosom < 0.0) { - cosom = -cosom; - bx = -bx; - by = -by; - bz = -bz; - bw = -bw; + this.lastWidth = canvas.width; + this.lastHeight = canvas.height; + this.cardboardUI_.render(); } - if (1.0 - cosom > 0.000001) { - omega = Math.acos(cosom); - sinom = Math.sin(omega); - scale0 = Math.sin((1.0 - t) * omega) / sinom; - scale1 = Math.sin(t * omega) / sinom; - } else { - scale0 = 1.0 - t; - scale1 = t; +}; +CardboardVRDisplay.prototype.onOrientationChange_ = function (e) { + this.viewerSelector_.hide(); + if (this.rotateInstructions_) { + this.rotateInstructions_.update(); } - out[0] = scale0 * ax + scale1 * bx; - out[1] = scale0 * ay + scale1 * by; - out[2] = scale0 * az + scale1 * bz; - out[3] = scale0 * aw + scale1 * bw; - return out; -} -function invert$2(out, a) { - var a0 = a[0], - a1 = a[1], - a2 = a[2], - a3 = a[3]; - var dot$$1 = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; - var invDot = dot$$1 ? 1.0 / dot$$1 : 0; - out[0] = -a0 * invDot; - out[1] = -a1 * invDot; - out[2] = -a2 * invDot; - out[3] = a3 * invDot; - return out; -} + this.onResize_(); +}; +CardboardVRDisplay.prototype.onResize_ = function (e) { + if (this.layer_) { + var gl = this.layer_.source.getContext('webgl'); + var cssProperties = ['position: absolute', 'top: 0', 'left: 0', + 'width: 100vw', 'height: 100vh', 'border: 0', 'margin: 0', + 'padding: 0px', 'box-sizing: content-box']; + gl.canvas.setAttribute('style', cssProperties.join('; ') + ';'); + safariCssSizeWorkaround(gl.canvas); + } +}; +CardboardVRDisplay.prototype.onViewerChanged_ = function (viewer) { + this.deviceInfo_.setViewer(viewer); + if (this.distorter_) { + this.distorter_.updateDeviceInfo(this.deviceInfo_); + } + this.fireVRDisplayDeviceParamsChange_(); +}; +CardboardVRDisplay.prototype.fireVRDisplayDeviceParamsChange_ = function () { + var event = new CustomEvent('vrdisplaydeviceparamschange', { + detail: { + vrdisplay: this, + deviceInfo: this.deviceInfo_ + } + }); + window.dispatchEvent(event); +}; +CardboardVRDisplay.VRFrameData = VRFrameData; +CardboardVRDisplay.VRDisplay = VRDisplay; +return CardboardVRDisplay; +}))); +}); +var CardboardVRDisplay = unwrapExports(cardboardVrDisplay); -function fromMat3(out, m) { - var fTrace = m[0] + m[4] + m[8]; - var fRoot = void 0; - if (fTrace > 0.0) { - fRoot = Math.sqrt(fTrace + 1.0); - out[3] = 0.5 * fRoot; - fRoot = 0.5 / fRoot; - out[0] = (m[5] - m[7]) * fRoot; - out[1] = (m[6] - m[2]) * fRoot; - out[2] = (m[1] - m[3]) * fRoot; - } else { - var i = 0; - if (m[4] > m[0]) i = 1; - if (m[8] > m[i * 3 + i]) i = 2; - var j = (i + 1) % 3; - var k = (i + 2) % 3; - fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1.0); - out[i] = 0.5 * fRoot; - fRoot = 0.5 / fRoot; - out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot; - out[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot; - out[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot; +class XRDevice extends EventTarget { + constructor(global) { + super(); + this.global = global; + this.onWindowResize = this.onWindowResize.bind(this); + this.global.window.addEventListener('resize', this.onWindowResize); + this.environmentBlendMode = 'opaque'; + } + get depthNear() { throw new Error('Not implemented'); } + set depthNear(val) { throw new Error('Not implemented'); } + get depthFar() { throw new Error('Not implemented'); } + set depthFar(val) { throw new Error('Not implemented'); } + onBaseLayerSet(sessionId, layer) { throw new Error('Not implemented'); } + onInlineVerticalFieldOfViewSet(sessionId, value) { throw new Error('Not implemented'); } + supportsSession(mode) { throw new Error('Not implemented'); } + async requestSession(mode) { throw new Error('Not implemented'); } + requestAnimationFrame(callback) { throw new Error('Not implemented'); } + onFrameStart(sessionId) { throw new Error('Not implemented'); } + onFrameEnd(sessionId) { throw new Error('Not implemented'); } + requestStageBounds() { throw new Error('Not implemented'); } + async requestFrameOfReferenceTransform(type, options) { + return undefined; + } + cancelAnimationFrame(handle) { throw new Error('Not implemented'); } + endSession(sessionId) { throw new Error('Not implemented'); } + getViewport(sessionId, eye, layer, target) { throw new Error('Not implemented'); } + getProjectionMatrix(eye) { throw new Error('Not implemented'); } + getBasePoseMatrix() { throw new Error('Not implemented'); } + getBaseViewMatrix(eye) { throw new Error('Not implemented'); } + getInputSources() { throw new Error('Not implemented'); } + getInputPose(inputSource, coordinateSystem, poseType) { throw new Error('Not implemented'); } + onWindowResize() { + this.onWindowResize(); } - return out; -} -function fromEuler(out, x, y, z) { - var halfToRad = 0.5 * Math.PI / 180.0; - x *= halfToRad; - y *= halfToRad; - z *= halfToRad; - var sx = Math.sin(x); - var cx = Math.cos(x); - var sy = Math.sin(y); - var cy = Math.cos(y); - var sz = Math.sin(z); - var cz = Math.cos(z); - out[0] = sx * cy * cz - cx * sy * sz; - out[1] = cx * sy * cz + sx * cy * sz; - out[2] = cx * cy * sz - sx * sy * cz; - out[3] = cx * cy * cz + sx * sy * sz; - return out; } -var clone$4 = clone$3; - -var copy$4 = copy$3; - - - - - - - - - - -var normalize$2 = normalize$1; - - -var rotationTo = function () { - var tmpvec3 = create$1(); - var xUnitVec3 = fromValues$1(1, 0, 0); - var yUnitVec3 = fromValues$1(0, 1, 0); - return function (out, a, b) { - var dot$$1 = dot(a, b); - if (dot$$1 < -0.999999) { - cross(tmpvec3, xUnitVec3, a); - if (len(tmpvec3) < 0.000001) cross(tmpvec3, yUnitVec3, a); - normalize(tmpvec3, tmpvec3); - setAxisAngle(out, tmpvec3, Math.PI); - return out; - } else if (dot$$1 > 0.999999) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 1; - return out; - } else { - cross(tmpvec3, a, b); - out[0] = tmpvec3[0]; - out[1] = tmpvec3[1]; - out[2] = tmpvec3[2]; - out[3] = 1 + dot$$1; - return normalize$2(out, out); +let oculusTouch = { + mapping: 'xr-standard', + id: 'oculus-touch', + buttons: { + length: 6, + 0: 1, + 1: 0, + 2: 2, + 3: null, + 4: 3, + 5: 4 + }, + gripTransform: { + position: [0, -0.02, 0.04, 1], + orientation: [Math.PI * 0.11, 0, 0, 1] + } +}; +let windowsMixedReality = { + mapping: 'xr-standard', + id: 'windows-mixed-reality', + buttons: { + length: 4, + 0: 1, + 1: 0, + 2: 2, + 3: 4, + }, + gripTransform: { + position: [0, -0.02, 0.04, 1], + orientation: [Math.PI * 0.11, 0, 0, 1] + } +}; +let GamepadMappings = { + "Oculus Touch (Right)": oculusTouch, + "Oculus Touch (Left)": oculusTouch, + "Oculus Go Controller": { + mapping: 'xr-standard', + id: 'oculus-go', + buttons: { + 0: 1, + 1: 0, + }, + gripTransform: { + orientation: [Math.PI * 0.11, 0, 0, 1] } - }; -}(); -var sqlerp = function () { - var temp1 = create$4(); - var temp2 = create$4(); - return function (out, a, b, c, d, t) { - slerp(temp1, a, d, t); - slerp(temp2, b, c, t); - slerp(out, temp1, temp2, 2 * t * (1 - t)); - return out; - }; -}(); -var setAxes = function () { - var matr = create$2(); - return function (out, view, right, up) { - matr[0] = right[0]; - matr[3] = right[1]; - matr[6] = right[2]; - matr[1] = up[0]; - matr[4] = up[1]; - matr[7] = up[2]; - matr[2] = -view[0]; - matr[5] = -view[1]; - matr[8] = -view[2]; - return normalize$2(out, fromMat3(out, matr)); - }; -}(); - -var HEAD_ELBOW_OFFSET_RIGHTHANDED = fromValues$1(0.155, -0.465, -0.15); -var HEAD_ELBOW_OFFSET_LEFTHANDED = fromValues$1(-0.155, -0.465, -0.15); -var ELBOW_WRIST_OFFSET = fromValues$1(0, 0, -0.25); -var WRIST_CONTROLLER_OFFSET = fromValues$1(0, 0, 0.05); -var ARM_EXTENSION_OFFSET = fromValues$1(-0.08, 0.14, 0.08); -var ELBOW_BEND_RATIO = 0.4; -var EXTENSION_RATIO_WEIGHT = 0.4; -var MIN_ANGULAR_SPEED = 0.61; -var MIN_ANGLE_DELTA = 0.175; -var MIN_EXTENSION_COS = 0.12; -var MAX_EXTENSION_COS = 0.87; -var RAD_TO_DEG = 180 / Math.PI; + }, + "Windows Mixed Reality (Right)": windowsMixedReality, + "Windows Mixed Reality (Left)": windowsMixedReality, +}; + +const HEAD_ELBOW_OFFSET_RIGHTHANDED = fromValues$1(0.155, -0.465, -0.15); +const HEAD_ELBOW_OFFSET_LEFTHANDED = fromValues$1(-0.155, -0.465, -0.15); +const ELBOW_WRIST_OFFSET = fromValues$1(0, 0, -0.25); +const WRIST_CONTROLLER_OFFSET = fromValues$1(0, 0, 0.05); +const ARM_EXTENSION_OFFSET = fromValues$1(-0.08, 0.14, 0.08); +const ELBOW_BEND_RATIO = 0.4; +const EXTENSION_RATIO_WEIGHT = 0.4; +const MIN_ANGULAR_SPEED = 0.61; +const MIN_ANGLE_DELTA = 0.175; +const MIN_EXTENSION_COS = 0.12; +const MAX_EXTENSION_COS = 0.87; +const RAD_TO_DEG = 180 / Math.PI; function eulerFromQuaternion(out, q, order) { function clamp(value, min$$1, max$$1) { - return value < min$$1 ? min$$1 : value > max$$1 ? max$$1 : value; + return (value < min$$1 ? min$$1 : (value > max$$1 ? max$$1 : value)); } var sqx = q[0] * q[0]; var sqy = q[1] * q[1]; var sqz = q[2] * q[2]; var sqw = q[3] * q[3]; - if (order === 'XYZ') { - out[0] = Math.atan2(2 * (q[0] * q[3] - q[1] * q[2]), sqw - sqx - sqy + sqz); - out[1] = Math.asin(clamp(2 * (q[0] * q[2] + q[1] * q[3]), -1, 1)); - out[2] = Math.atan2(2 * (q[2] * q[3] - q[0] * q[1]), sqw + sqx - sqy - sqz); - } else if (order === 'YXZ') { - out[0] = Math.asin(clamp(2 * (q[0] * q[3] - q[1] * q[2]), -1, 1)); - out[1] = Math.atan2(2 * (q[0] * q[2] + q[1] * q[3]), sqw - sqx - sqy + sqz); - out[2] = Math.atan2(2 * (q[0] * q[1] + q[2] * q[3]), sqw - sqx + sqy - sqz); - } else if (order === 'ZXY') { - out[0] = Math.asin(clamp(2 * (q[0] * q[3] + q[1] * q[2]), -1, 1)); - out[1] = Math.atan2(2 * (q[1] * q[3] - q[2] * q[0]), sqw - sqx - sqy + sqz); - out[2] = Math.atan2(2 * (q[2] * q[3] - q[0] * q[1]), sqw - sqx + sqy - sqz); - } else if (order === 'ZYX') { - out[0] = Math.atan2(2 * (q[0] * q[3] + q[2] * q[1]), sqw - sqx - sqy + sqz); - out[1] = Math.asin(clamp(2 * (q[1] * q[3] - q[0] * q[2]), -1, 1)); - out[2] = Math.atan2(2 * (q[0] * q[1] + q[2] * q[3]), sqw + sqx - sqy - sqz); - } else if (order === 'YZX') { - out[0] = Math.atan2(2 * (q[0] * q[3] - q[2] * q[1]), sqw - sqx + sqy - sqz); - out[1] = Math.atan2(2 * (q[1] * q[3] - q[0] * q[2]), sqw + sqx - sqy - sqz); - out[2] = Math.asin(clamp(2 * (q[0] * q[1] + q[2] * q[3]), -1, 1)); - } else if (order === 'XZY') { - out[0] = Math.atan2(2 * (q[0] * q[3] + q[1] * q[2]), sqw - sqx + sqy - sqz); - out[1] = Math.atan2(2 * (q[0] * q[2] + q[1] * q[3]), sqw + sqx - sqy - sqz); - out[2] = Math.asin(clamp(2 * (q[2] * q[3] - q[0] * q[1]), -1, 1)); + if ( order === 'XYZ' ) { + out[0] = Math.atan2( 2 * ( q[0] * q[3] - q[1] * q[2] ), ( sqw - sqx - sqy + sqz ) ); + out[1] = Math.asin( clamp( 2 * ( q[0] * q[2] + q[1] * q[3] ), -1, 1 ) ); + out[2] = Math.atan2( 2 * ( q[2] * q[3] - q[0] * q[1] ), ( sqw + sqx - sqy - sqz ) ); + } else if ( order === 'YXZ' ) { + out[0] = Math.asin( clamp( 2 * ( q[0] * q[3] - q[1] * q[2] ), -1, 1 ) ); + out[1] = Math.atan2( 2 * ( q[0] * q[2] + q[1] * q[3] ), ( sqw - sqx - sqy + sqz ) ); + out[2] = Math.atan2( 2 * ( q[0] * q[1] + q[2] * q[3] ), ( sqw - sqx + sqy - sqz ) ); + } else if ( order === 'ZXY' ) { + out[0] = Math.asin( clamp( 2 * ( q[0] * q[3] + q[1] * q[2] ), -1, 1 ) ); + out[1] = Math.atan2( 2 * ( q[1] * q[3] - q[2] * q[0] ), ( sqw - sqx - sqy + sqz ) ); + out[2] = Math.atan2( 2 * ( q[2] * q[3] - q[0] * q[1] ), ( sqw - sqx + sqy - sqz ) ); + } else if ( order === 'ZYX' ) { + out[0] = Math.atan2( 2 * ( q[0] * q[3] + q[2] * q[1] ), ( sqw - sqx - sqy + sqz ) ); + out[1] = Math.asin( clamp( 2 * ( q[1] * q[3] - q[0] * q[2] ), -1, 1 ) ); + out[2] = Math.atan2( 2 * ( q[0] * q[1] + q[2] * q[3] ), ( sqw + sqx - sqy - sqz ) ); + } else if ( order === 'YZX' ) { + out[0] = Math.atan2( 2 * ( q[0] * q[3] - q[2] * q[1] ), ( sqw - sqx + sqy - sqz ) ); + out[1] = Math.atan2( 2 * ( q[1] * q[3] - q[0] * q[2] ), ( sqw + sqx - sqy - sqz ) ); + out[2] = Math.asin( clamp( 2 * ( q[0] * q[1] + q[2] * q[3] ), -1, 1 ) ); + } else if ( order === 'XZY' ) { + out[0] = Math.atan2( 2 * ( q[0] * q[3] + q[1] * q[2] ), ( sqw - sqx + sqy - sqz ) ); + out[1] = Math.atan2( 2 * ( q[0] * q[2] + q[1] * q[3] ), ( sqw + sqx - sqy - sqz ) ); + out[2] = Math.asin( clamp( 2 * ( q[2] * q[3] - q[0] * q[1] ), -1, 1 ) ); } else { console.log('No order given for quaternion to euler conversion.'); return; } } -var OrientationArmModel = function () { - function OrientationArmModel() { - classCallCheck(this, OrientationArmModel); +class OrientationArmModel { + constructor() { this.hand = 'right'; this.headElbowOffset = HEAD_ELBOW_OFFSET_RIGHTHANDED; this.controllerQ = create$4(); @@ -5405,115 +5392,196 @@ var OrientationArmModel = function () { this.rootQ = create$4(); this.position = create$1(); } - createClass(OrientationArmModel, [{ - key: 'setHandedness', - value: function setHandedness(hand) { - if (this.hand != hand) { - this.hand = hand; - if (this.hand == 'left') { - this.headElbowOffset = HEAD_ELBOW_OFFSET_LEFTHANDED; + setHandedness(hand) { + if (this.hand != hand) { + this.hand = hand; + if (this.hand == 'left') { + this.headElbowOffset = HEAD_ELBOW_OFFSET_LEFTHANDED; + } else { + this.headElbowOffset = HEAD_ELBOW_OFFSET_RIGHTHANDED; + } + } + } + update(controllerOrientation, headPoseMatrix) { + this.time = now$1(); + if (controllerOrientation) { + copy$4(this.lastControllerQ, this.controllerQ); + copy$4(this.controllerQ, controllerOrientation); + } + if (headPoseMatrix) { + getTranslation(this.headPos, headPoseMatrix); + getRotation(this.headQ, headPoseMatrix); + } + let headYawQ = this.getHeadYawOrientation_(); + let angleDelta = this.quatAngle_(this.lastControllerQ, this.controllerQ); + let timeDelta = (this.time - this.lastTime) / 1000; + let controllerAngularSpeed = angleDelta / timeDelta; + if (controllerAngularSpeed > MIN_ANGULAR_SPEED) { + slerp(this.rootQ, this.rootQ, headYawQ, + Math.min(angleDelta / MIN_ANGLE_DELTA, 1.0)); + } else { + copy$4(this.rootQ, headYawQ); + } + let controllerForward = fromValues$1(0, 0, -1.0); + transformQuat(controllerForward, controllerForward, this.controllerQ); + let controllerDotY = dot(controllerForward, [0, 1, 0]); + let extensionRatio = this.clamp_( + (controllerDotY - MIN_EXTENSION_COS) / MAX_EXTENSION_COS, 0.0, 1.0); + let controllerCameraQ = clone$4(this.rootQ); + invert$2(controllerCameraQ, controllerCameraQ); + multiply$4(controllerCameraQ, controllerCameraQ, this.controllerQ); + let elbowPos = this.elbowPos; + copy$1(elbowPos, this.headPos); + add$1(elbowPos, elbowPos, this.headElbowOffset); + let elbowOffset = clone$1(ARM_EXTENSION_OFFSET); + scale$1(elbowOffset, elbowOffset, extensionRatio); + add$1(elbowPos, elbowPos, elbowOffset); + let totalAngle = this.quatAngle_(controllerCameraQ, create$4()); + let totalAngleDeg = totalAngle * RAD_TO_DEG; + let lerpSuppression = 1 - Math.pow(totalAngleDeg / 180, 4);let elbowRatio = ELBOW_BEND_RATIO; + let wristRatio = 1 - ELBOW_BEND_RATIO; + let lerpValue = lerpSuppression * + (elbowRatio + wristRatio * extensionRatio * EXTENSION_RATIO_WEIGHT); + let wristQ = create$4(); + slerp(wristQ, wristQ, controllerCameraQ, lerpValue); + let invWristQ = invert$2(create$4(), wristQ); + let elbowQ = clone$4(controllerCameraQ); + multiply$4(elbowQ, elbowQ, invWristQ); + let wristPos = this.wristPos; + copy$1(wristPos, WRIST_CONTROLLER_OFFSET); + transformQuat(wristPos, wristPos, wristQ); + add$1(wristPos, wristPos, ELBOW_WRIST_OFFSET); + transformQuat(wristPos, wristPos, elbowQ); + add$1(wristPos, wristPos, elbowPos); + let offset = clone$1(ARM_EXTENSION_OFFSET); + scale$1(offset, offset, extensionRatio); + add$1(this.position, this.wristPos, offset); + transformQuat(this.position, this.position, this.rootQ); + this.lastTime = this.time; + } + getPosition() { + return this.position; + } + getHeadYawOrientation_() { + let headEuler = create$1(); + eulerFromQuaternion(headEuler, this.headQ, 'YXZ'); + let destinationQ = fromEuler(create$4(), 0, headEuler[1] * RAD_TO_DEG, 0); + return destinationQ; + } + clamp_(value, min$$1, max$$1) { + return Math.min(Math.max(value, min$$1), max$$1); + } + quatAngle_(q1, q2) { + let vec1 = [0, 0, -1]; + let vec2 = [0, 0, -1]; + transformQuat(vec1, vec1, q1); + transformQuat(vec2, vec2, q2); + return angle(vec1, vec2); + } +} + +const PRIVATE$16 = Symbol('@@webxr-polyfill/XRRemappedGamepad'); +const PLACEHOLDER_BUTTON = { pressed: false, touched: false, value: 0.0 }; +Object.freeze(PLACEHOLDER_BUTTON); +class XRRemappedGamepad { + constructor(gamepad, map) { + if (!map) { + map = {}; + } + let axes = new Array(map.axes ? map.axes.length : gamepad.axes.length); + let buttons = new Array(map.buttons ? map.buttons.length : gamepad.buttons.length); + let gripTransform = null; + if (map.gripTransform) { + let orientation = map.gripTransform.orientation || [0, 0, 0, 1]; + gripTransform = create(); + fromRotationTranslation( + gripTransform, + normalize$2(orientation, orientation), + map.gripTransform.position || [0, 0, 0] + ); + } + let targetRayTransform = null; + if (map.targetRayTransform) { + let orientation = map.targetRayTransform.orientation || [0, 0, 0, 1]; + targetRayTransform = create(); + fromRotationTranslation( + targetRayTransform, + normalize$2(orientation, orientation), + map.targetRayTransform.position || [0, 0, 0] + ); + } + this[PRIVATE$16] = { + gamepad, + map, + id: map.id || gamepad.id, + mapping: map.mapping || gamepad.mapping, + axes, + buttons, + gripTransform, + targetRayTransform, + }; + this._update(); + } + _update() { + let gamepad = this[PRIVATE$16].gamepad; + let map = this[PRIVATE$16].map; + let axes = this[PRIVATE$16].axes; + for (let i = 0; i < axes.length; ++i) { + if (map.axes && i in map.axes) { + if (map.axes[i] === null) { + axes[i] = 0; } else { - this.headElbowOffset = HEAD_ELBOW_OFFSET_RIGHTHANDED; + axes[i] = gamepad.axes[map.axes[i]]; } + } else { + axes[i] = gamepad.axes[i]; } } - }, { - key: 'update', - value: function update(controllerOrientation, headPoseMatrix) { - this.time = now$1(); - if (controllerOrientation) { - copy$4(this.lastControllerQ, this.controllerQ); - copy$4(this.controllerQ, controllerOrientation); - } - if (headPoseMatrix) { - getTranslation(this.headPos, headPoseMatrix); - getRotation(this.headQ, headPoseMatrix); - } - var headYawQ = this.getHeadYawOrientation_(); - var angleDelta = this.quatAngle_(this.lastControllerQ, this.controllerQ); - var timeDelta = (this.time - this.lastTime) / 1000; - var controllerAngularSpeed = angleDelta / timeDelta; - if (controllerAngularSpeed > MIN_ANGULAR_SPEED) { - slerp(this.rootQ, this.rootQ, headYawQ, Math.min(angleDelta / MIN_ANGLE_DELTA, 1.0)); + let buttons = this[PRIVATE$16].buttons; + for (let i = 0; i < buttons.length; ++i) { + if (map.buttons && i in map.buttons) { + if (map.buttons[i] === null) { + buttons[i] = PLACEHOLDER_BUTTON; + } else { + buttons[i] = gamepad.buttons[map.buttons[i]]; + } } else { - copy$4(this.rootQ, headYawQ); + buttons[i] = gamepad.buttons[i]; } - var controllerForward = fromValues$1(0, 0, -1.0); - transformQuat(controllerForward, controllerForward, this.controllerQ); - var controllerDotY = dot(controllerForward, [0, 1, 0]); - var extensionRatio = this.clamp_((controllerDotY - MIN_EXTENSION_COS) / MAX_EXTENSION_COS, 0.0, 1.0); - var controllerCameraQ = clone$4(this.rootQ); - invert$2(controllerCameraQ, controllerCameraQ); - multiply$4(controllerCameraQ, controllerCameraQ, this.controllerQ); - var elbowPos = this.elbowPos; - copy$1(elbowPos, this.headPos); - add$1(elbowPos, elbowPos, this.headElbowOffset); - var elbowOffset = clone$1(ARM_EXTENSION_OFFSET); - scale$1(elbowOffset, elbowOffset, extensionRatio); - add$1(elbowPos, elbowPos, elbowOffset); - var totalAngle = this.quatAngle_(controllerCameraQ, create$4()); - var totalAngleDeg = totalAngle * RAD_TO_DEG; - var lerpSuppression = 1 - Math.pow(totalAngleDeg / 180, 4);var elbowRatio = ELBOW_BEND_RATIO; - var wristRatio = 1 - ELBOW_BEND_RATIO; - var lerpValue = lerpSuppression * (elbowRatio + wristRatio * extensionRatio * EXTENSION_RATIO_WEIGHT); - var wristQ = create$4(); - slerp(wristQ, wristQ, controllerCameraQ, lerpValue); - var invWristQ = invert$2(create$4(), wristQ); - var elbowQ = clone$4(controllerCameraQ); - multiply$4(elbowQ, elbowQ, invWristQ); - var wristPos = this.wristPos; - copy$1(wristPos, WRIST_CONTROLLER_OFFSET); - transformQuat(wristPos, wristPos, wristQ); - add$1(wristPos, wristPos, ELBOW_WRIST_OFFSET); - transformQuat(wristPos, wristPos, elbowQ); - add$1(wristPos, wristPos, elbowPos); - var offset = clone$1(ARM_EXTENSION_OFFSET); - scale$1(offset, offset, extensionRatio); - add$1(this.position, this.wristPos, offset); - transformQuat(this.position, this.position, this.rootQ); - this.lastTime = this.time; - } - }, { - key: 'getPosition', - value: function getPosition() { - return this.position; } - }, { - key: 'getHeadYawOrientation_', - value: function getHeadYawOrientation_() { - var headEuler = create$1(); - eulerFromQuaternion(headEuler, this.headQ, 'YXZ'); - var destinationQ = fromEuler(create$4(), 0, headEuler[1] * RAD_TO_DEG, 0); - return destinationQ; - } - }, { - key: 'clamp_', - value: function clamp_(value, min$$1, max$$1) { - return Math.min(Math.max(value, min$$1), max$$1); - } - }, { - key: 'quatAngle_', - value: function quatAngle_(q1, q2) { - var vec1 = [0, 0, -1]; - var vec2 = [0, 0, -1]; - transformQuat(vec1, vec1, q1); - transformQuat(vec2, vec2, q2); - return angle(vec1, vec2); - } - }]); - return OrientationArmModel; -}(); - -var GamepadXRInputSource = function () { - function GamepadXRInputSource(polyfill) { - var primaryButtonIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - classCallCheck(this, GamepadXRInputSource); + } + get id() { + return this[PRIVATE$16].id; + } + get index() { + return 0; + } + get connected() { + return this[PRIVATE$16].gamepad.connected; + } + get timestamp() { + return this[PRIVATE$16].gamepad.timestamp; + } + get mapping() { + return this[PRIVATE$16].mapping; + } + get axes() { + return this[PRIVATE$16].axes; + } + get buttons() { + return this[PRIVATE$16].buttons; + } +} +class GamepadXRInputSource { + constructor(polyfill, primaryButtonIndex = 0) { this.polyfill = polyfill; + this.nativeGamepad = null; this.gamepad = null; this.inputSource = new XRInputSource(this); this.lastPosition = create$1(); this.emulatedPosition = false; this.basePoseMatrix = create(); + this.outputMatrix = create(); this.inputPoses = new WeakMap(); this.primaryButtonIndex = primaryButtonIndex; this.primaryActionPressed = false; @@ -5521,676 +5589,534 @@ var GamepadXRInputSource = function () { this.targetRayMode = 'gaze'; this.armModel = null; } - createClass(GamepadXRInputSource, [{ - key: 'updateFromGamepad', - value: function updateFromGamepad(gamepad) { - this.gamepad = gamepad; - this.handedness = gamepad.hand; - if (gamepad.pose) { - this.targetRayMode = 'tracked-pointer'; - this.emulatedPosition = !gamepad.pose.hasPosition; - } else if (gamepad.hand === '') { - this.targetRayMode = 'gaze'; - this.emulatedPosition = false; + updateFromGamepad(gamepad) { + if (this.nativeGamepad !== gamepad) { + this.nativeGamepad = gamepad; + if (gamepad) { + this.gamepad = new XRRemappedGamepad(gamepad, GamepadMappings[gamepad.id]); + } else { + this.gamepad = null; } } - }, { - key: 'updateBasePoseMatrix', - value: function updateBasePoseMatrix() { - if (this.gamepad && this.gamepad.pose) { - var pose = this.gamepad.pose; - var position = pose.position; - var orientation = pose.orientation; - if (!position && !orientation) { - return; - } - if (!position) { - if (!pose.hasPosition) { - if (!this.armModel) { - this.armModel = new OrientationArmModel(); - } - this.armModel.setHandedness(this.gamepad.hand); - this.armModel.update(orientation, this.polyfill.getBasePoseMatrix()); - position = this.armModel.getPosition(); - } else { - position = this.lastPosition; + this.handedness = gamepad.hand; + if (this.gamepad) { + this.gamepad._update(); + } + if (gamepad.pose) { + this.targetRayMode = 'tracked-pointer'; + this.emulatedPosition = !gamepad.pose.hasPosition; + } else if (gamepad.hand === '') { + this.targetRayMode = 'gaze'; + this.emulatedPosition = false; + } + } + updateBasePoseMatrix() { + if (this.nativeGamepad && this.nativeGamepad.pose) { + let pose = this.nativeGamepad.pose; + let position = pose.position; + let orientation = pose.orientation; + if (!position && !orientation) { + return; + } + if (!position) { + if (!pose.hasPosition) { + if (!this.armModel) { + this.armModel = new OrientationArmModel(); } + this.armModel.setHandedness(this.nativeGamepad.hand); + this.armModel.update(orientation, this.polyfill.getBasePoseMatrix()); + position = this.armModel.getPosition(); } else { - this.lastPosition[0] = position[0]; - this.lastPosition[1] = position[1]; - this.lastPosition[2] = position[2]; + position = this.lastPosition; } - fromRotationTranslation(this.basePoseMatrix, orientation, position); } else { - copy(this.basePoseMatrix, this.polyfill.getBasePoseMatrix()); + this.lastPosition[0] = position[0]; + this.lastPosition[1] = position[1]; + this.lastPosition[2] = position[2]; } - return this.basePoseMatrix; + fromRotationTranslation(this.basePoseMatrix, orientation, position); + } else { + copy(this.basePoseMatrix, this.polyfill.getBasePoseMatrix()); } - }, { - key: 'getXRInputPose', - value: function getXRInputPose(coordinateSystem) { - this.updateBasePoseMatrix(); - var inputPose = this.inputPoses.get(coordinateSystem); - if (!inputPose) { - inputPose = new XRInputPose(this, this.gamepad && this.gamepad.pose); - this.inputPoses.set(coordinateSystem, inputPose); - } - var rayTransformMatrix = new Float32Array(16); - coordinateSystem.transformBasePoseMatrix(rayTransformMatrix, this.basePoseMatrix); - inputPose.targetRay = poseMatrixToXRRay(rayTransformMatrix); - if (inputPose.gripMatrix) { - coordinateSystem.transformBasePoseMatrix(inputPose.gripMatrix, this.basePoseMatrix); - } - return inputPose; + return this.basePoseMatrix; + } + getXRPose(coordinateSystem, poseType) { + this.updateBasePoseMatrix(); + switch(poseType) { + case "target-ray": + coordinateSystem.transformBasePoseMatrix(this.outputMatrix, this.basePoseMatrix); + if (this.gamepad && this.gamepad[PRIVATE$16].targetRayTransform) { + multiply(this.outputMatrix, this.outputMatrix, this.gamepad[PRIVATE$16].targetRayTransform); + } + break; + case "grip": + if (!this.nativeGamepad || !this.nativeGamepad.pose) { + return null; + } + coordinateSystem.transformBasePoseMatrix(this.outputMatrix, this.basePoseMatrix); + if (this.gamepad && this.gamepad[PRIVATE$16].gripTransform) { + multiply(this.outputMatrix, this.outputMatrix, this.gamepad[PRIVATE$16].gripTransform); + } + break; + default: + return null; } - }]); - return GamepadXRInputSource; -}(); + coordinateSystem._adjustForOriginOffset(this.outputMatrix); + return new XRPose(new XRRigidTransform(this.outputMatrix), this.emulatedPosition); + } +} -var EXTRA_PRESENTATION_ATTRIBUTES = { - highRefreshRate: true +const TEST_ENV = "production" === 'test'; +const EXTRA_PRESENTATION_ATTRIBUTES = { + highRefreshRate: true, }; -var PRIMARY_BUTTON_MAP = { +const PRIMARY_BUTTON_MAP = { oculus: 1, - openvr: 1 -}; -var CAN_USE_GAMEPAD = _global.navigator && 'getGamepads' in _global.navigator; -var SESSION_ID = 0; -var Session = function Session(sessionOptions) { - classCallCheck(this, Session); - this.outputContext = sessionOptions.outputContext; - this.immersive = sessionOptions.immersive; - this.ended = null; - this.baseLayer = null; - this.id = ++SESSION_ID; - this.modifiedCanvasLayer = false; -}; - -var WebVRDevice = function (_PolyfilledXRDevice) { - inherits(WebVRDevice, _PolyfilledXRDevice); - function WebVRDevice(global, display) { - classCallCheck(this, WebVRDevice); - var canPresent = display.capabilities.canPresent; - var _this = possibleConstructorReturn(this, (WebVRDevice.__proto__ || Object.getPrototypeOf(WebVRDevice)).call(this, global)); - _this.display = display; - _this.frame = new global.VRFrameData(); - _this.sessions = new Map(); - _this.immersiveSession = null; - _this.canPresent = canPresent; - _this.baseModelMatrix = create(); - _this.gamepadInputSources = {}; - _this.tempVec3 = new Float32Array(3); - _this.onVRDisplayPresentChange = _this.onVRDisplayPresentChange.bind(_this); - global.window.addEventListener('vrdisplaypresentchange', _this.onVRDisplayPresentChange); - return _this; - } - createClass(WebVRDevice, [{ - key: 'onBaseLayerSet', - value: function onBaseLayerSet(sessionId, layer) { - var _this2 = this; - var session = this.sessions.get(sessionId); - var canvas = layer.context.canvas; - if (session.immersive) { - var left = this.display.getEyeParameters('left'); - var right = this.display.getEyeParameters('right'); - canvas.width = Math.max(left.renderWidth, right.renderWidth) * 2; - canvas.height = Math.max(left.renderHeight, right.renderHeight); - this.display.requestPresent([{ + openvr: 1, + 'spatial controller (spatial interaction source)': 1 +}; +let SESSION_ID = 0; +class Session { + constructor(mode, polyfillOptions={}) { + this.mode = mode; + this.outputContext = null; + this.immersive = mode == 'immersive-vr' || mode == 'immersive-ar'; + this.ended = null; + this.baseLayer = null; + this.inlineVerticalFieldOfView = Math.PI * 0.5; + this.id = ++SESSION_ID; + this.modifiedCanvasLayer = false; + if (this.outputContext && !TEST_ENV) { + const renderContextType = polyfillOptions.renderContextType || '2d'; + this.renderContext = this.outputContext.canvas.getContext(renderContextType); + } + } +} +class WebVRDevice extends XRDevice { + constructor(global, display) { + const { canPresent } = display.capabilities; + super(global); + this.display = display; + this.frame = new global.VRFrameData(); + this.sessions = new Map(); + this.immersiveSession = null; + this.canPresent = canPresent; + this.baseModelMatrix = create(); + this.gamepadInputSources = {}; + this.tempVec3 = new Float32Array(3); + this.onVRDisplayPresentChange = this.onVRDisplayPresentChange.bind(this); + global.window.addEventListener('vrdisplaypresentchange', this.onVRDisplayPresentChange); + this.CAN_USE_GAMEPAD = global.navigator && ('getGamepads' in global.navigator); + this.HAS_BITMAP_SUPPORT = isImageBitmapSupported(global); + } + get depthNear() { return this.display.depthNear; } + set depthNear(val) { this.display.depthNear = val; } + get depthFar() { return this.display.depthFar; } + set depthFar(val) { this.display.depthFar = val; } + onBaseLayerSet(sessionId, layer) { + const session = this.sessions.get(sessionId); + const canvas = layer.context.canvas; + if (session.immersive) { + const left = this.display.getEyeParameters('left'); + const right = this.display.getEyeParameters('right'); + canvas.width = Math.max(left.renderWidth, right.renderWidth) * 2; + canvas.height = Math.max(left.renderHeight, right.renderHeight); + this.display.requestPresent([{ source: canvas, attributes: EXTRA_PRESENTATION_ATTRIBUTES - }]).then(function () { - if ("production" !== 'test' && !_this2.global.document.body.contains(canvas)) { - session.modifiedCanvasLayer = true; - _this2.global.document.body.appendChild(canvas); - applyCanvasStylesForMinimalRendering(canvas); - } - session.baseLayer = layer; - }); - } - else if (session.outputContext) { - session.baseLayer = layer; + }]).then(() => { + if (!TEST_ENV && !this.global.document.body.contains(canvas)) { + session.modifiedCanvasLayer = true; + this.global.document.body.appendChild(canvas); + applyCanvasStylesForMinimalRendering(canvas); } + session.baseLayer = layer; + }); } - }, { - key: 'supportsSession', - value: function supportsSession() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - if (options.immersive === true && this.canPresent === false) { - return false; - } - return true; + else { + session.baseLayer = layer; } - }, { - key: 'requestSession', - value: function requestSession() { - var $args = arguments;return new Promise(function ($return, $error) { - var options, canvas, ctx, session; - options = $args.length > 0 && $args[0] !== undefined ? $args[0] : {}; - if (!this.supportsSession(options)) { - return $return(Promise.reject()); - } - if (options.immersive) { - canvas = this.global.document.createElement('canvas'); - { - ctx = canvas.getContext('webgl'); - } - return Promise.resolve(this.display.requestPresent([{ - source: canvas, attributes: EXTRA_PRESENTATION_ATTRIBUTES }])).then(function ($await_2) { - try { - return $If_1.call(this); - } catch ($boundEx) { - return $error($boundEx); - } - }.bind(this), $error); - } - function $If_1() { - session = new Session(options); - this.sessions.set(session.id, session); - if (options.immersive) { - this.immersiveSession = session; - this.dispatchEvent('@@webxr-polyfill/vr-present-start', session.id); - } - return $return(Promise.resolve(session.id)); - } - return $If_1.call(this); - }.bind(this)); + } + onInlineVerticalFieldOfViewSet(sessionId, value) { + const session = this.sessions.get(sessionId); + session.inlineVerticalFieldOfView = value; + } + supportsSession(mode) { + if (XRSessionModes.indexOf(mode) == -1) { + throw new TypeError( + `The provided value '${mode}' is not a valid enum value of type XRSessionMode`); } - }, { - key: 'requestAnimationFrame', - value: function requestAnimationFrame(callback) { - return this.display.requestAnimationFrame(callback); + if (mode == 'immersive-ar') { + return false; } - }, { - key: 'getPrimaryButtonIndex', - value: function getPrimaryButtonIndex(gamepad) { - var primaryButton = 0; - var name = gamepad.id.toLowerCase(); - for (var key in PRIMARY_BUTTON_MAP) { - if (name.includes(key)) { - primaryButton = PRIMARY_BUTTON_MAP[key]; - break; - } + if (mode == 'immersive-vr' && this.canPresent === false) { + return false; + } + return true; + } + async requestSession(mode) { + if (!this.supportsSession(mode)) { + return Promise.reject(); + } + let immersive = mode == 'immersive-vr'; + if (immersive) { + const canvas = this.global.document.createElement('canvas'); + if (!TEST_ENV) { + const ctx = canvas.getContext('webgl'); } - return Math.min(primaryButton, gamepad.buttons.length - 1); + await this.display.requestPresent([{ + source: canvas, attributes: EXTRA_PRESENTATION_ATTRIBUTES }]); } - }, { - key: 'onFrameStart', - value: function onFrameStart(sessionId) { - this.display.getFrameData(this.frame); - var session = this.sessions.get(sessionId); - if (session.immersive && CAN_USE_GAMEPAD) { - var prevInputSources = this.gamepadInputSources; - this.gamepadInputSources = {}; - var gamepads = _global.navigator.getGamepads(); - for (var i = 0; i < gamepads.length; ++i) { - var gamepad = gamepads[i]; - if (gamepad && gamepad.displayId === this.display.displayId) { - var inputSourceImpl = prevInputSources[i]; - if (!inputSourceImpl) { - inputSourceImpl = new GamepadXRInputSource(this, this.getPrimaryButtonIndex(gamepad)); - } - inputSourceImpl.updateFromGamepad(gamepad); - this.gamepadInputSources[i] = inputSourceImpl; - if (inputSourceImpl.primaryButtonIndex != -1) { - var primaryActionPressed = gamepad.buttons[inputSourceImpl.primaryButtonIndex].pressed; - if (primaryActionPressed && !inputSourceImpl.primaryActionPressed) { - this.dispatchEvent('@@webxr-polyfill/input-select-start', { sessionId: session.id, inputSource: inputSourceImpl.inputSource }); - } else if (!primaryActionPressed && inputSourceImpl.primaryActionPressed) { - this.dispatchEvent('@@webxr-polyfill/input-select-end', { sessionId: session.id, inputSource: inputSourceImpl.inputSource }); - } - inputSourceImpl.primaryActionPressed = primaryActionPressed; - } - } - } + const session = new Session(mode, { + renderContextType: this.HAS_BITMAP_SUPPORT ? 'bitmaprenderer' : '2d' + }); + this.sessions.set(session.id, session); + if (immersive) { + this.immersiveSession = session; + this.dispatchEvent('@@webxr-polyfill/vr-present-start', session.id); + } + return Promise.resolve(session.id); + } + requestAnimationFrame(callback) { + return this.display.requestAnimationFrame(callback); + } + getPrimaryButtonIndex(gamepad) { + let primaryButton = 0; + let name = gamepad.id.toLowerCase(); + for (let key in PRIMARY_BUTTON_MAP) { + if (name.includes(key)) { + primaryButton = PRIMARY_BUTTON_MAP[key]; + break; } - if (session.outputContext && !session.immersive) { - var outputCanvas = session.outputContext.canvas; - var oWidth = outputCanvas.offsetWidth; - var oHeight = outputCanvas.offsetHeight; - if (outputCanvas.width != oWidth) { - outputCanvas.width = oWidth; - } - if (outputCanvas.height != oHeight) { - outputCanvas.height = oHeight; - } - var canvas = session.baseLayer.context.canvas; - if (!this.immersiveSession || canvas !== this.immersiveSession.baseLayer.context.canvas) { - if (canvas.width != oWidth) { - canvas.width = oWidth; + } + return Math.min(primaryButton, gamepad.buttons.length - 1); + } + onFrameStart(sessionId) { + this.display.getFrameData(this.frame); + const session = this.sessions.get(sessionId); + if (session.immersive && this.CAN_USE_GAMEPAD) { + let prevInputSources = this.gamepadInputSources; + this.gamepadInputSources = {}; + let gamepads = this.global.navigator.getGamepads(); + for (let i = 0; i < gamepads.length; ++i) { + let gamepad = gamepads[i]; + if (gamepad && gamepad.displayId > 0) { + let inputSourceImpl = prevInputSources[i]; + if (!inputSourceImpl) { + inputSourceImpl = new GamepadXRInputSource(this, this.getPrimaryButtonIndex(gamepad)); } - if (canvas.height != oHeight) { - canvas.height = oHeight; + inputSourceImpl.updateFromGamepad(gamepad); + this.gamepadInputSources[i] = inputSourceImpl; + if (inputSourceImpl.primaryButtonIndex != -1) { + let primaryActionPressed = gamepad.buttons[inputSourceImpl.primaryButtonIndex].pressed; + if (primaryActionPressed && !inputSourceImpl.primaryActionPressed) { + this.dispatchEvent('@@webxr-polyfill/input-select-start', { sessionId: session.id, inputSource: inputSourceImpl.inputSource }); + } else if (!primaryActionPressed && inputSourceImpl.primaryActionPressed) { + this.dispatchEvent('@@webxr-polyfill/input-select-end', { sessionId: session.id, inputSource: inputSourceImpl.inputSource }); + } + inputSourceImpl.primaryActionPressed = primaryActionPressed; } - perspective(this.frame.leftProjectionMatrix, Math.PI * 0.4, oWidth / oHeight, this.depthNear, this.depthFar); } } } - }, { - key: 'onFrameEnd', - value: function onFrameEnd(sessionId) { - var session = this.sessions.get(sessionId); - if (session.ended || !session.baseLayer) { - return; - } - if (session.outputContext && !(session.immersive && !this.display.capabilities.hasExternalDisplay)) { - var mirroring = session.immersive && this.display.capabilities.hasExternalDisplay; - var canvas = session.baseLayer.context.canvas; - var iWidth = mirroring ? canvas.width / 2 : canvas.width; - var iHeight = canvas.height; - { - var outputCanvas = session.outputContext.canvas; - var outputContext = outputCanvas.getContext('2d'); - var oWidth = outputCanvas.width; - var oHeight = outputCanvas.height; - outputContext.drawImage(canvas, 0, 0, iWidth, iHeight, 0, 0, oWidth, oHeight); - } - } - if (session.immersive && session.baseLayer) { - this.display.submitFrame(); - } + if (TEST_ENV) { + return; } - }, { - key: 'cancelAnimationFrame', - value: function cancelAnimationFrame(handle) { - this.display.cancelAnimationFrame(handle); + if (!session.immersive && session.baseLayer) { + const canvas = session.baseLayer.context.canvas; + perspective(this.frame.leftProjectionMatrix, session.inlineVerticalFieldOfView, + canvas.width/canvas.height, this.depthNear, this.depthFar); } - }, { - key: 'endSession', - value: function endSession(sessionId) { - return new Promise(function ($return, $error) { - var session = this.sessions.get(sessionId); - if (session.ended) { - return $return(); - } - if (session.immersive) { - return $return(this.display.exitPresent()); + } + onFrameEnd(sessionId) { + const session = this.sessions.get(sessionId); + if (session.ended || !session.baseLayer) { + return; + } + if (session.outputContext && + !(session.immersive && !this.display.capabilities.hasExternalDisplay)) { + const mirroring = + session.immersive && this.display.capabilities.hasExternalDisplay; + const iCanvas = session.baseLayer.context.canvas; + const iWidth = mirroring ? iCanvas.width / 2 : iCanvas.width; + const iHeight = iCanvas.height; + if (!TEST_ENV) { + const oCanvas = session.outputContext.canvas; + const oWidth = oCanvas.width; + const oHeight = oCanvas.height; + const renderContext = session.renderContext; + if (this.HAS_BITMAP_SUPPORT) { + if (iCanvas.transferToImageBitmap) { + renderContext.transferFromImageBitmap(iCanvas.transferToImageBitmap()); + } + else { + this.global.createImageBitmap(iCanvas, 0, 0, iWidth, iHeight, { + resizeWidth: oWidth, + resizeHeight: oHeight, + }).then(bitmap => renderContext.transferFromImageBitmap(bitmap)); + } } else { - session.ended = true; + renderContext.drawImage(iCanvas, 0, 0, iWidth, iHeight, + 0, 0, oWidth, oHeight); } - return $return(); - }.bind(this)); - } - }, { - key: 'requestStageBounds', - value: function requestStageBounds() { - if (this.display.stageParameters) { - var width = this.display.stageParameters.sizeX; - var depth = this.display.stageParameters.sizeZ; - var data = []; - data.push(-width / 2); - data.push(-depth / 2); - data.push(width / 2); - data.push(-depth / 2); - data.push(width / 2); - data.push(depth / 2); - data.push(-width / 2); - data.push(depth / 2); - return data; } - return null; } - }, { - key: 'requestFrameOfReferenceTransform', - value: function requestFrameOfReferenceTransform(type, options) { - return new Promise(function ($return, $error) { - if (type === 'stage' && this.display.stageParameters && this.display.stageParameters.sittingToStandingTransform) { - return $return(this.display.stageParameters.sittingToStandingTransform); - } - return $return(); - }.bind(this)); + if (session.immersive && session.baseLayer) { + this.display.submitFrame(); } - }, { - key: 'getProjectionMatrix', - value: function getProjectionMatrix(eye) { - if (eye === 'left') { - return this.frame.leftProjectionMatrix; - } else if (eye === 'right') { - return this.frame.rightProjectionMatrix; - } else { - throw new Error('eye must be of type \'left\' or \'right\''); - } + } + cancelAnimationFrame(handle) { + this.display.cancelAnimationFrame(handle); + } + async endSession(sessionId) { + const session = this.sessions.get(sessionId); + if (session.ended) { + return; } - }, { - key: 'getViewport', - value: function getViewport(sessionId, eye, layer, target) { - var session = this.sessions.get(sessionId); - var _layer$context$canvas = layer.context.canvas, - width = _layer$context$canvas.width, - height = _layer$context$canvas.height; - if (!session.immersive) { - target.x = target.y = 0; - target.width = width; - target.height = height; - return true; - } - if (eye === 'left') { - target.x = 0; - } else if (eye === 'right') { - target.x = width / 2; - } else { - return false; - } - target.y = 0; - target.width = width / 2; + if (session.immersive) { + return this.display.exitPresent(); + } else { + session.ended = true; + } + } + requestStageBounds() { + if (this.display.stageParameters) { + const width = this.display.stageParameters.sizeX; + const depth = this.display.stageParameters.sizeZ; + const data = []; + data.push(-width / 2); + data.push(-depth / 2); + data.push(width / 2); + data.push(-depth / 2); + data.push(width / 2); + data.push(depth / 2); + data.push(-width / 2); + data.push(depth / 2); + return data; + } + return null; + } + async requestFrameOfReferenceTransform(type, options) { + if (type === 'stage' && this.display.stageParameters && + this.display.stageParameters.sittingToStandingTransform) { + return this.display.stageParameters.sittingToStandingTransform; + } + } + getProjectionMatrix(eye) { + if (eye === 'left') { + return this.frame.leftProjectionMatrix; + } else if (eye === 'right') { + return this.frame.rightProjectionMatrix; + } else if (eye === 'none') { + return this.frame.leftProjectionMatrix; + } else { + throw new Error(`eye must be of type 'left' or 'right'`); + } + } + getViewport(sessionId, eye, layer, target) { + const session = this.sessions.get(sessionId); + const { width, height } = layer.context.canvas; + if (!session.immersive) { + target.x = target.y = 0; + target.width = width; target.height = height; return true; } - }, { - key: 'getBasePoseMatrix', - value: function getBasePoseMatrix() { - var _frame$pose = this.frame.pose, - position = _frame$pose.position, - orientation = _frame$pose.orientation; - if (!position && !orientation) { - return this.baseModelMatrix; - } - if (!position) { - position = this.tempVec3; - position[0] = position[1] = position[2] = 0; - } - fromRotationTranslation(this.baseModelMatrix, orientation, position); + if (eye === 'left') { + target.x = 0; + } else if (eye === 'right') { + target.x = width / 2; + } else { + return false; + } + target.y = 0; + target.width = width / 2; + target.height = height; + return true; + } + getBasePoseMatrix() { + let { position, orientation } = this.frame.pose; + if (!position && !orientation) { return this.baseModelMatrix; } - }, { - key: 'getBaseViewMatrix', - value: function getBaseViewMatrix(eye) { - if (eye === 'left') { - return this.frame.leftViewMatrix; - } else if (eye === 'right') { - return this.frame.rightViewMatrix; - } else { - throw new Error('eye must be of type \'left\' or \'right\''); - } + if (!position) { + position = this.tempVec3; + position[0] = position[1] = position[2] = 0; } - }, { - key: 'getInputSources', - value: function getInputSources() { - var inputSources = []; - for (var i in this.gamepadInputSources) { - inputSources.push(this.gamepadInputSources[i].inputSource); - } - return inputSources; + fromRotationTranslation(this.baseModelMatrix, orientation, position); + return this.baseModelMatrix; + } + getBaseViewMatrix(eye) { + if (eye === 'left') { + return this.frame.leftViewMatrix; + } else if (eye === 'right') { + return this.frame.rightViewMatrix; + } else { + throw new Error(`eye must be of type 'left' or 'right'`); } - }, { - key: 'getInputPose', - value: function getInputPose(inputSource, coordinateSystem) { - if (!coordinateSystem) { - return null; - } - for (var i in this.gamepadInputSources) { - var inputSourceImpl = this.gamepadInputSources[i]; - if (inputSourceImpl.inputSource === inputSource) { - return inputSourceImpl.getXRInputPose(coordinateSystem); - } - } + } + getInputSources() { + let inputSources = []; + for (let i in this.gamepadInputSources) { + inputSources.push(this.gamepadInputSources[i].inputSource); + } + return inputSources; + } + getInputPose(inputSource, coordinateSystem, poseType) { + if (!coordinateSystem) { return null; } - }, { - key: 'onWindowResize', - value: function onWindowResize() {} - }, { - key: 'onVRDisplayPresentChange', - value: function onVRDisplayPresentChange(e) { - var _this3 = this; - if (!this.display.isPresenting) { - this.sessions.forEach(function (session) { - if (session.immersive && !session.ended) { - if (session.modifiedCanvasLayer) { - var canvas = session.baseLayer.context.canvas; - document.body.removeChild(canvas); - canvas.setAttribute('style', ''); - } - if (_this3.immersiveSession === session) { - _this3.immersiveSession = null; - } - _this3.dispatchEvent('@@webxr-polyfill/vr-present-end', session.id); - } - }); + for (let i in this.gamepadInputSources) { + let inputSourceImpl = this.gamepadInputSources[i]; + if (inputSourceImpl.inputSource === inputSource) { + return inputSourceImpl.getXRPose(coordinateSystem, poseType); } } - }, { - key: 'depthNear', - get: function get$$1() { - return this.display.depthNear; - } - , - set: function set$$1(val) { - this.display.depthNear = val; - } - }, { - key: 'depthFar', - get: function get$$1() { - return this.display.depthFar; - } - , - set: function set$$1(val) { - this.display.depthFar = val; + return null; + } + onWindowResize() { + } + onVRDisplayPresentChange(e) { + if (!this.display.isPresenting) { + this.sessions.forEach(session => { + if (session.immersive && !session.ended) { + if (session.modifiedCanvasLayer) { + const canvas = session.baseLayer.context.canvas; + document.body.removeChild(canvas); + canvas.setAttribute('style', ''); + } + if (this.immersiveSession === session) { + this.immersiveSession = null; + } + this.dispatchEvent('@@webxr-polyfill/vr-present-end', session.id); + } + }); } - }]); - return WebVRDevice; -}(PolyfilledXRDevice); - -var CardboardXRDevice = function (_WebVRDevice) { - inherits(CardboardXRDevice, _WebVRDevice); - function CardboardXRDevice(global) { - classCallCheck(this, CardboardXRDevice); - var display = new CardboardVRDisplay(); - var _this = possibleConstructorReturn(this, (CardboardXRDevice.__proto__ || Object.getPrototypeOf(CardboardXRDevice)).call(this, global, display)); - _this.display = display; - _this.frame = { + } +} + +class CardboardXRDevice extends WebVRDevice { + constructor(global, cardboardConfig) { + const display = new CardboardVRDisplay(cardboardConfig || {}); + super(global, display); + this.display = display; + this.frame = { rightViewMatrix: new Float32Array(16), leftViewMatrix: new Float32Array(16), rightProjectionMatrix: new Float32Array(16), leftProjectionMatrix: new Float32Array(16), pose: null, - timestamp: null + timestamp: null, }; - return _this; - } - return CardboardXRDevice; -}(WebVRDevice); - -var getXRDevice = function getXRDevice(global) { - return new Promise(function ($return, $error) { - var device; - device = null; - if ('xr' in global.navigator) { - var $Try_1_Post = function () { - try { - return $If_3.call(this); - } catch ($boundEx) { - return $error($boundEx); - } - }.bind(this);var $Try_1_Catch = function (e) { - try { - return $Try_1_Post(); - } catch ($boundEx) { - return $error($boundEx); - } - }.bind(this); - try { - return Promise.resolve(global.navigator.xr.requestDevice()).then(function ($await_6) { - try { - device = $await_6; - return $Try_1_Post(); - } catch ($boundEx) { - return $Try_1_Catch($boundEx); - } - }.bind(this), $Try_1_Catch); - } catch (e) { - $Try_1_Catch(e); - } - } - function $If_3() { - return $return(device); - } - return $If_3.call(this); - }.bind(this)); -}; -var getVRDisplay = function getVRDisplay(global) { - return new Promise(function ($return, $error) { - var device, displays; - device = null; - if ('getVRDisplays' in global.navigator) { - var $Try_2_Post = function () { - try { - return $If_4.call(this); - } catch ($boundEx) { - return $error($boundEx); - } - }.bind(this);var $Try_2_Catch = function (e) { - try { - return $Try_2_Post(); - } catch ($boundEx) { - return $error($boundEx); - } - }.bind(this); - try { - return Promise.resolve(global.navigator.getVRDisplays()).then(function ($await_7) { - try { - displays = $await_7; - if (displays && displays.length) { - device = new WebVRDevice(global, displays[0]); - } - return $Try_2_Post(); - } catch ($boundEx) { - return $Try_2_Catch($boundEx); - } - }.bind(this), $Try_2_Catch); - } catch (e) { - $Try_2_Catch(e); + } +} + +const getWebVRDevice = async function (global) { + let device = null; + if ('getVRDisplays' in global.navigator) { + try { + const displays = await global.navigator.getVRDisplays(); + if (displays && displays.length) { + device = new WebVRDevice(global, displays[0]); } - } - function $If_4() { - return $return(device); - } - return $If_4.call(this); - }.bind(this)); + } catch (e) {} + } + return device; }; -var requestDevice = function requestDevice(global, config) { - return new Promise(function ($return, $error) { - var device; - return Promise.resolve(getXRDevice(global)).then(function ($await_8) { - try { - device = $await_8; - if (device) { - return $return(device); - } - if (config.webvr) { - return Promise.resolve(getVRDisplay(global)).then(function ($await_9) { - try { - device = $await_9; - if (device) { - return $return(new XRDevice(device)); - } - return $If_5.call(this); - } catch ($boundEx) { - return $error($boundEx); - } - }.bind(this), $error); - } - function $If_5() { - if (config.cardboard && isMobile(global)) { - if (!global.VRFrameData) { - global.VRFrameData = function () { - this.rightViewMatrix = new Float32Array(16); - this.leftViewMatrix = new Float32Array(16); - this.rightProjectionMatrix = new Float32Array(16); - this.leftProjectionMatrix = new Float32Array(16); - this.pose = null; - }; - } - return $return(new XRDevice(new CardboardXRDevice(global))); - } - return $return(null); - } - return $If_5.call(this); - } catch ($boundEx) { - return $error($boundEx); - } - }.bind(this), $error); - }.bind(this)); +const requestXRDevice = async function (global, config) { + if (config.webvr) { + let xr = await getWebVRDevice(global); + if (xr) { + return xr; + } + } + if (!global.VRFrameData) { + global.VRFrameData = function () { + this.rightViewMatrix = new Float32Array(16); + this.leftViewMatrix = new Float32Array(16); + this.rightProjectionMatrix = new Float32Array(16); + this.leftProjectionMatrix = new Float32Array(16); + this.pose = null; + }; + } + return new CardboardXRDevice(global, config.cardboardConfig); }; -var CONFIG_DEFAULTS = { +const CONFIG_DEFAULTS = { + global: _global, webvr: true, - cardboard: true -}; -var partials = ['navigator', 'HTMLCanvasElement', 'WebGLRenderingContext']; -var WebXRPolyfill = function () { - function WebXRPolyfill(global) { - var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - classCallCheck(this, WebXRPolyfill); - this.global = global || _global; + cardboard: true, + cardboardConfig: null, + allowCardboardOnDesktop: false, +}; +const partials = ['navigator', 'HTMLCanvasElement', 'WebGLRenderingContext']; +class WebXRPolyfill { + constructor(config={}) { this.config = Object.freeze(Object.assign({}, CONFIG_DEFAULTS, config)); + this.global = this.config.global; this.nativeWebXR = 'xr' in this.global.navigator; this.injected = false; if (!this.nativeWebXR) { this._injectPolyfill(this.global); + } else { + this._injectCompatibilityShims(this.global); } - else if (this.config.cardboard && isMobile(this.global)) { - this._patchRequestDevice(); - } } - createClass(WebXRPolyfill, [{ - key: '_injectPolyfill', - value: function _injectPolyfill(global) { - if (!partials.every(function (iface) { - return !!global[iface]; - })) { - throw new Error('Global must have the following attributes : ' + partials); + _injectPolyfill(global) { + if (!partials.every(iface => !!global[iface])) { + throw new Error(`Global must have the following attributes : ${partials}`); + } + for (const className of Object.keys(API)) { + if (global[className] !== undefined) { + console.warn(`${className} already defined on global.`); + } else { + global[className] = API[className]; } - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - try { - for (var _iterator = Object.keys(API)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var className = _step.value; - if (global[className] !== undefined) { - console.warn(className + ' already defined on global.'); - } else { - global[className] = API[className]; - } - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } + } + { + const polyfilledCtx = polyfillMakeXRCompatible(global.WebGLRenderingContext); + if (polyfilledCtx) { + polyfillGetContext(global.HTMLCanvasElement); + if (global.OffscreenCanvas) { + polyfillGetContext(global.OffscreenCanvas); } - } - { - var polyfilledCtx = extendContextCompatibleXRDevice(global.WebGLRenderingContext); - if (polyfilledCtx) { - extendGetContext(global.HTMLCanvasElement); - if (global.WebGL2RenderingContext) { - extendContextCompatibleXRDevice(global.WebGL2RenderingContext); - } + if (global.WebGL2RenderingContext){ + polyfillMakeXRCompatible(global.WebGL2RenderingContext); } } - this.injected = true; - this._patchRequestDevice(); } - }, { - key: '_patchRequestDevice', - value: function _patchRequestDevice() { - var device = requestDevice(this.global, this.config); - this.xr = new XR(device); - Object.defineProperty(this.global.navigator, 'xr', { - value: this.xr, - configurable: true - }); + this.injected = true; + this._patchNavigatorXR(); + } + _patchNavigatorXR() { + let devicePromise = requestXRDevice(this.global, this.config); + this.xr = new XR(devicePromise); + Object.defineProperty(this.global.navigator, 'xr', { + value: this.xr, + configurable: true, + }); + } + _injectCompatibilityShims(global) { + if (!partials.every(iface => !!global[iface])) { + throw new Error(`Global must have the following attributes : ${partials}`); } - }]); - return WebXRPolyfill; -}(); - -return WebXRPolyfill; + if (global.XRWebGLLayer) { + let originalRequestSession = global.navigator.xr.requestSession; + global.navigator.xr.requestSession = function(mode, options) { + return originalRequestSession.call(this, mode, options).then((session) => { + session._session_mode = mode; + return session; + }); + }; + var originalXRLayer = global.XRWebGLLayer; + global.XRWebGLLayer = function(session, gl, options) { + if (!options) { + options = {}; + } + options.compositionDisabled = (session._session_mode === "inline"); + return new originalXRLayer(session, gl, options); + }; + } + } +} -}))); +export default WebXRPolyfill; diff --git a/js/util/inline-viewer-helper.js b/js/util/inline-viewer-helper.js new file mode 100644 index 000000000..0bf0cbc81 --- /dev/null +++ b/js/util/inline-viewer-helper.js @@ -0,0 +1,140 @@ +// Copyright 2019 The Immersive Web Community Group +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +/* +Provides a simple method for tracking which XRReferenceSpace is associated with +which XRSession. Also handles the necessary logic for enabling mouse/touch-based +view rotation for inline sessions if desired. +*/ + +import {quat} from '../render/math/gl-matrix.js'; + +const LOOK_SPEED = 0.0025; + +export class InlineViewerHelper { + constructor(canvas, referenceSpace) { + this.lookYaw = 0; + this.lookPitch = 0; + this.viewerHeight = 0; + + this.canvas = canvas; + this.baseRefSpace = referenceSpace; + this.refSpace = referenceSpace; + + this.dirty = false; + + canvas.style.cursor = 'grab'; + + canvas.addEventListener('mousemove', (event) => { + // Only rotate when the left button is pressed + if (event.buttons & 1) { + this.rotateView(event.movementX, event.movementY); + } + }); + + // Keep track of touch-related state so that users can touch and drag on + // the canvas to adjust the viewer pose in an inline session. + let primaryTouch = undefined; + let prevTouchX = undefined; + let prevTouchY = undefined; + + canvas.addEventListener("touchstart", (event) => { + if (primaryTouch == undefined) { + let touch = event.changedTouches[0]; + primaryTouch = touch.identifier; + prevTouchX = touch.pageX; + prevTouchY = touch.pageY; + } + }); + + canvas.addEventListener("touchend", (event) => { + for (let touch of event.changedTouches) { + if (primaryTouch == touch.identifier) { + primaryTouch = undefined; + this.rotateView(touch.pageX - prevTouchX, touch.pageY - prevTouchY); + } + } + }); + + canvas.addEventListener("touchcancel", (event) => { + for (let touch of event.changedTouches) { + if (primaryTouch == touch.identifier) { + primaryTouch = undefined; + } + } + }); + + canvas.addEventListener("touchmove", (event) => { + for (let touch of event.changedTouches) { + if (primaryTouch == touch.identifier) { + this.rotateView(touch.pageX - prevTouchX, touch.pageY - prevTouchY); + prevTouchX = touch.pageX; + prevTouchY = touch.pageY; + } + } + }); + } + + setHeight(value) { + if (this.viewerHeight != value) { + this.viewerHeight = value; + } + this.dirty = true; + } + + rotateView(dx, dy) { + this.lookYaw += dx * LOOK_SPEED; + this.lookPitch += dy * LOOK_SPEED; + if (this.lookPitch < -Math.PI*0.5) { + this.lookPitch = -Math.PI*0.5; + } + if (this.lookPitch > Math.PI*0.5) { + this.lookPitch = Math.PI*0.5; + } + this.dirty = true; + } + + reset() { + this.lookYaw = 0; + this.lookPitch = 0; + this.refSpace = this.baseRefSpace; + this.dirty = false; + } + + // XRReferenceSpace offset is immutable, so return a new reference space + // that has an updated orientation. + get referenceSpace() { + if (this.dirty) { + // Represent the rotational component of the reference space as a + // quaternion. + let invOrient = quat.create(); + quat.rotateX(invOrient, invOrient, -this.lookPitch); + quat.rotateY(invOrient, invOrient, -this.lookYaw); + let xform = new XRRigidTransform( + {}, + {x: invOrient[0], y: invOrient[1], z: invOrient[2], w: invOrient[3]}); + this.refSpace = this.baseRefSpace.getOffsetReferenceSpace(xform); + xform = new XRRigidTransform({y: -this.viewerHeight}); + this.refSpace = this.refSpace.getOffsetReferenceSpace(xform); + this.dirty = false; + } + return this.refSpace; + } +} diff --git a/js/cottontail/src/util/query-args.js b/js/util/query-args.js similarity index 100% rename from js/cottontail/src/util/query-args.js rename to js/util/query-args.js diff --git a/js/webxr-button.js b/js/util/webxr-button.js similarity index 99% rename from js/webxr-button.js rename to js/util/webxr-button.js index 1a4dcaa42..849d4c843 100644 --- a/js/webxr-button.js +++ b/js/util/webxr-button.js @@ -19,8 +19,6 @@ // is intentionally left out so that the sample pages can demonstrate them more // clearly. -window.XRDeviceButton = (function () { - // // State consts // @@ -267,7 +265,7 @@ const generateCSS = (options, fontSize=18)=> { // Button class // -class EnterXRButton { +export class WebXRButton { /** * Construct a new Enter XR Button * @constructor @@ -489,7 +487,3 @@ const ifChild = (el, cssPrefix, suffix, fn)=> { const c = el.querySelector('.' + cssPrefix + '-' + suffix); c && fn(c); }; - -return EnterXRButton; - -})(); diff --git a/js/webxr-sample-app.js b/js/webxr-sample-app.js new file mode 100644 index 000000000..d7d1efad6 --- /dev/null +++ b/js/webxr-sample-app.js @@ -0,0 +1,190 @@ +// Copyright 2019 The Immersive Web Community Group +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +import {WebXRButton} from './util/webxr-button.js'; +import {Scene} from './render/scenes/scene.js'; +import {Renderer, createWebGLContext} from './render/core/renderer.js'; +import {InlineViewerHelper} from './util/inline-viewer-helper.js'; + +export class WebXRSampleApp { + constructor(options) { + // Application options and defaults + if (!options) { options = {}; } + + this.options = { + inline: 'inline' in options ? options.inline : true, + immersiveMode: options.immersiveMode || 'immersive-vr', + referenceSpace: options.referenceSpace || 'local', + defaultInputHandling: 'defaultInputHandling' in options ? options.defaultInputHandling : true, + controllerMesh: options.controllerMesh + }; + + this.gl = null; + this.renderer = null; + this.scene = new Scene(); + + this.xrButton = new WebXRButton({ + onRequestSession: () => { this.onRequestSession(); }, + onEndSession: (session) => { this.onEndSession(session); } + }); + + this.immersiveRefSpace = null; + this.inlineViewerHelper = null; + + this.frameCallback = (time, frame) => { + let session = frame.session; + let refSpace = this.getSessionReferenceSpace(session); + + session.requestAnimationFrame(this.frameCallback); + this.scene.startFrame(); + + this.onXRFrame(time, frame, refSpace); + + this.scene.endFrame(); + }; + } + + getSessionReferenceSpace(session) { + return session.isImmersive ? this.immersiveRefSpace : this.inlineViewerHelper.referenceSpace; + } + + run() { + this.onInitXR(); + } + + onInitXR() { + if (navigator.xr) { + navigator.xr.supportsSession('immersive-vr').then(() => { + this.xrButton.enabled = true; + }); + + // Request an inline session if needed. + if (this.options.inline) { + navigator.xr.requestSession('inline').then((session) => { + this.onSessionStarted(session); + }); + } + } + } + + onCreateGL() { + return createWebGLContext({ + xrCompatible: true + }); + } + + onInitRenderer() { + if (this.gl) + return; + + this.gl = this.onCreateGL(); + + if(this.gl) { + let canvas = this.gl.canvas; + if (canvas instanceof HTMLCanvasElement) { + document.body.append(this.gl.canvas); + function onResize() { + canvas.width = canvas.clientWidth * window.devicePixelRatio; + canvas.height = canvas.clientHeight * window.devicePixelRatio; + } + window.addEventListener('resize', onResize); + onResize(); + } + + this.renderer = new Renderer(this.gl); + this.scene.setRenderer(this.renderer); + + if (this.options.controllerMesh) { + this.scene.inputRenderer.setControllerMesh(this.options.controllerMesh); + } + } + } + + onRequestSession() { + // Called when the button gets clicked. Requests an immersive session. + navigator.xr.requestSession(this.options.immersiveMode, { + requiredFeatures: [this.options.referenceSpace] + }).then((session) => { + this.xrButton.setSession(session); + session.isImmersive = true; + this.onSessionStarted(session); + }); + } + + onEndSession(session) { + session.end(); + } + + onSessionStarted(session) { + session.addEventListener('end', (event) => { + this.onSessionEnded(event.session); + }); + + if (this.options.defaultInputHandling) { + session.addEventListener('select', (event) => { + let refSpace = this.getSessionReferenceSpace(event.frame.session); + this.scene.handleSelect(event.inputSource, event.frame, refSpace); + }); + } + + this.onInitRenderer(); + + session.updateRenderState({ + baseLayer: new XRWebGLLayer(session, this.gl) + }); + + this.onRequestReferenceSpace(session).then((refSpace) => { + if (session.isImmersive) { + this.immersiveRefSpace = refSpace; + } else { + this.inlineViewerHelper = new InlineViewerHelper(this.gl.canvas, refSpace); + if (this.options.referenceSpace == 'local-floor' || + this.options.referenceSpace == 'bounded-floor') { + this.inlineViewerHelper.setHeight(1.6); + } + } + + session.requestAnimationFrame(this.frameCallback); + }); + } + + onRequestReferenceSpace(session) { + if (this.options.referenceSpace && session.isImmersive) { + return session.requestReferenceSpace(this.options.referenceSpace); + } else { + return session.requestReferenceSpace('viewer'); + } + } + + onSessionEnded(session) { + if (session == this.xrButton.session) { + this.xrButton.setSession(null); + } + } + + // Override to customize frame handling + onXRFrame(time, frame, refSpace) { + let pose = frame.getViewerPose(refSpace); + if (this.options.defaultInputHandling) { + this.scene.updateInputSources(frame, refSpace); + } + this.scene.drawXRFrame(frame, pose); + } +} diff --git a/js/webxr-version-shim.js b/js/webxr-version-shim.js deleted file mode 100644 index 7e2680379..000000000 --- a/js/webxr-version-shim.js +++ /dev/null @@ -1,527 +0,0 @@ -// Copyright 2018 The Immersive Web Community Group -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -// This file contains various patches to adjust for differences in outdated browser -// implementations of the WebXR API and allow the samples to be coded exclusively -// against the most recent version. - -function mat4_fromRotationTranslation(out, q, v) { - // Quaternion math - let x = q.x, y = q.y, z = q.z, w = q.w; - let x2 = x + x; - let y2 = y + y; - let z2 = z + z; - let xx = x * x2; - let xy = x * y2; - let xz = x * z2; - let yy = y * y2; - let yz = y * z2; - let zz = z * z2; - let wx = w * x2; - let wy = w * y2; - let wz = w * z2; - out[0] = 1 - (yy + zz); - out[1] = xy + wz; - out[2] = xz - wy; - out[3] = 0; - out[4] = xy - wz; - out[5] = 1 - (xx + zz); - out[6] = yz + wx; - out[7] = 0; - out[8] = xz + wy; - out[9] = yz - wx; - out[10] = 1 - (xx + yy); - out[11] = 0; - out[12] = v.x; - out[13] = v.y; - out[14] = v.z; - out[15] = 1; - return out; -} - -class XRRayShim { - constructor(rayMatrix) { - this._transformMatrix = rayMatrix; - - // TODO: Don't rely on these types for the shim. - // Some browsers don't support them yet. - let o = new DOMPointReadOnly(0, 0, 0, 1); - let d = new DOMPointReadOnly(0, 0, -1, 0); - let t = new DOMMatrix(rayMatrix); - - this._origin = DOMPointReadOnly.fromPoint(t.transformPoint(o)); - this._direction = DOMPointReadOnly.fromPoint(t.transformPoint(d)); - } - - get origin() { - return this._origin; - } - - get direction() { - return this._direction; - } - - get transformMatrix() { - return this._transformMatrix; - } -} - -class XRRigidTransformShim { - constructor(position, orientation) { - // TODO: Don't rely on these types for the shim. - // Some browsers don't support them yet. - this._position = DOMPointReadOnly.fromPoint(position); - this._orientation = DOMPointReadOnly.fromPoint(orientation); - this._matrix = null; - } - - get position() { - return this._position; - } - - get orientation() { - return this._orientation; - } - - get matrix() { - if (!this._matrix) { - this._matrix = new Float32Array(16); - mat4_fromRotationTranslation(this._matrix, this._orientation, this._position); - } - return this._matrix; - } -} - -class XRViewShim { - constructor(legacyView, devicePose) { - this._view = legacyView; - this._pose = devicePose; - this._transform = null; - } - - get eye() { - return this._view.projectionMatrix; - } - - get projectionMatrix() { - return this._view.projectionMatrix; - } - - get viewMatrix() { - return this._pose.getViewMatrix(this._view); - } - - get transform() { - // FIXME: Return a transform based on the inverted view matrix - return null; - } -} - -class WebXRVersionShim { - constructor() { - if (this._shouldApplyPatch()) { - this._applyPatch(); - } - - this._defaultDevicePromise = null; - this._defaultDevice = null; - } - - _isMobile() { - return /Android/i.test(navigator.userAgent) || - /iPhone|iPad|iPod/i.test(navigator.userAgent);s - } - - _shouldApplyPatch() { - // Don't apply the patch with WebXR isn't available. - if (!('xr' in navigator)) { - return false; - } - - // Allow for universally disabling the version shim with a URL arg, which will - // make it easier to test updates to native implementations. - let query = window.location.search.substring(1) || window.location.hash.substring(1); - let vars = query.split('&'); - for (let i = 0; i < vars.length; i++) { - let pair = vars[i].split('='); - if (pair[0].toLowerCase() == 'nowebxrversionshim') { - return false; - } - } - - return true; - } - - _ensureDefaultDevice() { - if (!this._defaultDevicePromise) { - this._defaultDevicePromise = navigator.xr.requestDevice().then((device) => { - this._defaultDevice = device; - return device; - }); - } - return this._defaultDevicePromise; - } - - _makeCanvas() { - // Create a fullscreen canvas element for use with legacy AR mode. - let canvas = document.createElement('canvas'); - canvas.style.width = '100%'; - canvas.style.height = '100%'; - canvas.style.left = 0; - canvas.style.top = 0; - canvas.style.right = 0; - canvas.style.bottom = 0; - canvas.style.margin = 0; - return canvas; - } - - _applyPatch() { - //=========================== - // Chrome 72 and older - //=========================== - - let shim = this; - - if ('requestDevice' in XR.prototype) { - console.log('[WebXR version shim] Installing navigator.xr.requestSession shim.'); - console.log('[WebXR version shim] Installing navigator.xr.supportsSessionMode shim.'); - - XR.prototype.requestSession = function(options) { - return shim._ensureDefaultDevice().then((device) => { - let newOptions = {}; - if (options.outputContext) { - newOptions.outputContext = options.outputContext; - } - - if (options.mode == 'immersive-vr') { - newOptions.immersive = true; - } else if (options.mode == 'immersive-ar') { - // These Chrome versions don't support immersive AR mode, they need - // a canvas in the DOM for use as output context. - newOptions.immersive = false; - newOptions.environmentIntegration = true; - - shim._outputCanvasForAR = shim._makeCanvas(); - newOptions.outputContext = shim._outputCanvasForAR.getContext('xrpresent'); - } else if (!options.mode || options.mode == 'inline') { - newOptions.immersive = false; - } else { - throw new TypeError('Invalid mode'); - } - - return device.requestSession(newOptions).then((session) => { - if (shim._outputCanvasForAR) { - // If we're using the backwards compatible output canvas, add it - // to the DOM now and clean it up on session end. - document.body.appendChild(shim._outputCanvasForAR); - session.addEventListener('end', () => { - document.body.removeChild(shim._outputCanvasForAR); - shim._outputCanvasForAR = null; - }); - } - session.mode = options.mode; - return session; - }); - }); - }; - - XR.prototype.supportsSessionMode = function(mode) { - return shim._ensureDefaultDevice().then((device) => { - let newOptions = {}; - - if (mode == 'immersive-vr') { - newOptions.immersive = true; - } else if (mode == 'immersive-ar') { - // These Chrome versions don't support immersive AR mode, they need - // a canvas in the DOM for use as output context. - newOptions.immersive = false; - newOptions.environmentIntegration = true; - - // Make a temporary canvas for checking support, but don't attach it - // to the DOM. The actual output canvas will be created later if/when - // a session is created. - let tempCanvas = shim._makeCanvas(); - newOptions.outputContext = tempCanvas.getContext('xrpresent'); - } else if (mode == 'inline') { - return Promise.resolve(); - } else { - throw new TypeError('Invalid mode'); - } - - return device.supportsSession(newOptions); - }); - }; - } - - if ('XRRigidTransform' in window) { - console.log('[WebXR version shim] Installing XRRigidTransform shim.'); - window.XRRigidTransform = XRRigidTransformShim; - } - - if ('transformMatrix' in XRRay.prototype) { - console.log('[WebXR version shim] Installing XRRay.matrix shim.'); - Object.defineProperty(XRRay.prototype, 'matrix', { - enumerable: true, configurable: false, writeable: false, - get: function() { return this.transformMatrix; } - }); - } - - if ('requestFrameOfReference' in XRSession.prototype) { - console.log('[WebXR version shim] Installing XRSession.requestReferenceSpace shim.'); - XRSession.prototype.requestReferenceSpace = function(options) { - if (options.type == 'stationary') { - if (options.subtype == 'eye-level') { - return this.requestFrameOfReference('eye-level'); - } else if (options.subtype == 'floor-level') { - return this.requestFrameOfReference('stage'); - } else if (options.subtype == 'position-disabled') { - return this.requestFrameOfReference('head-model'); - } - } else if (options.type == 'bounded') { - return this.requestFrameOfReference('stage', { disableStageEmulation: true }); - } - - // Covers 'unbounded', which didn't have an equivalent in the older spec - return Promise.reject(new Error('Unsupported reference space')); - }; - } - - let usingViewsShim = false; - - if ('getDevicePose' in XRFrame.prototype) { - console.log('[WebXR version shim] Installing XRSession.getViewerPose shim.'); - usingViewsShim = true; - XRFrame.prototype.getViewerPose = function(referenceSpace) { - let pose = this.getDevicePose(referenceSpace); - if (pose && `views` in XRFrame.prototype) { - pose.views = []; - for (let view of this.views) { - pose.views.push(new XRViewShim(view, pose)); - } - } - return pose; - } - } else if (!('views' in XRViewerPose.prototype)) { - console.log('[WebXR version shim] Installing XRViewerPose.views shim.'); - usingViewsShim = true; - const NATIVE_GET_VIEWER_POSE = XRFrame.prototype.getViewerPose; - XRFrame.prototype.getViewerPose = function(referenceSpace) { - let pose = NATIVE_GET_VIEWER_POSE.call(this, referenceSpace); - if (pose && `views` in XRFrame.prototype) { - pose.views = []; - for (let view of this.views) { - pose.views.push(new XRViewShim(view, pose)); - } - } - return pose; - } - } - - if (usingViewsShim) { - const NATIVE_GET_VIEWPORT = XRWebGLLayer.prototype.getViewport; - XRWebGLLayer.prototype.getViewport = function(view) { - if (view instanceof XRViewShim) { - view = view._view; - } - return NATIVE_GET_VIEWPORT.call(this, view); - } - } - - if ('XRDevicePose' in window) { - if ('poseModelMatrix' in XRDevicePose.prototype) { - console.log('[WebXR version shim] Installing XRViewerPose.transform shim.'); - Object.defineProperty(XRDevicePose.prototype, 'transform', { - enumerable: true, configurable: false, writeable: false, - get: function() { - // FIXME: Convert pose matrix into transform - return null; - } - }); - } - } - - if ('setCompatibleXRDevice' in WebGLRenderingContext.prototype) { - console.log('[WebXR version shim] Installing WebGL XR compatibility shim.'); - - WebGL2RenderingContext.prototype.makeXRCompatible = - WebGLRenderingContext.prototype.makeXRCompatible = function() { - return shim._ensureDefaultDevice().then((device) => { - return this.setCompatibleXRDevice(device); - }); - } - - // TODO: In order for this to work currently it must be called after - // either a supportsSessionMode or requestSession resolves. - const NATIVE_GET_CONTEXT = HTMLCanvasElement.prototype.getContext; - HTMLCanvasElement.prototype.getContext = function(type, options) { - if (type == 'webgl' || type == 'webgl2') { - if (options && options.xrCompatible) { - options.compatibleXRDevice = shim._defaultDevice; - } - } - return NATIVE_GET_CONTEXT.call(this, type, options); - }; - - if ('OffscreenCanvas' in window) { - const NATIVE_OFFSCREEN_GET_CONTEXT = OffscreenCanvas.prototype.getContext; - OffscreenCanvas.prototype.getContext = function(type, options) { - if (type == 'webgl' || type == 'webgl2') { - if (options && options.xrCompatible) { - options.compatibleXRDevice = shim._defaultDevice; - } - } - return NATIVE_OFFSCREEN_GET_CONTEXT.call(this, type, options); - }; - } - } - - //=========================== - // Chrome 67/68 - //=========================== - - // Map 'immersive' to the old 'exclusive' verbiage if needed. - if ('exclusive' in XRSession.prototype) { - const NATIVE_SUPPORTS_SESSION = XRDevice.prototype.supportsSession; - XRDevice.prototype.supportsSession = function(options) { - options.exclusive = !!options.immersive; - return NATIVE_SUPPORTS_SESSION.call(this, options); - }; - - const NATIVE_REQUEST_SESSION = XRDevice.prototype.requestSession; - XRDevice.prototype.requestSession = function(options) { - options.exclusive = !!options.immersive; - return NATIVE_REQUEST_SESSION.call(this, options); - }; - - Object.defineProperty(XRSession.prototype, 'immersive', { - enumerable: true, configurable: false, writeable: false, - get: function() { return this.exclusive; } - }); - } - - // We can't test for the existence of the enums in question directly, so this code - // will just try to create the requested type and fall back if it fails. - const NATIVE_REQUEST_FRAME_OF_REFERENCE = XRSession.prototype.requestFrameOfReference; - XRSession.prototype.requestFrameOfReference = function(type, options) { - let session = this; - // Try the current type. - return NATIVE_REQUEST_FRAME_OF_REFERENCE.call(session, type, options).catch((error)=>{ - // FIXME: Should be checking for TypeError specifically. Requires a polyfill update. - if(error instanceof Error) { - // If the current type fails, switch to the other version. - switch(type) { - case 'eye-level': - type = 'eyeLevel'; - break; - case 'head-model': - type = 'headModel'; - break; - default: - return Promise.reject(error); - } - return Promise.resolve(NATIVE_REQUEST_FRAME_OF_REFERENCE.call(session, type, options)); - } else { - return Promise.reject(error); - } - }); - }; - - // Make sure that requestAnimationFrame is always supplied with a timestamp - const NATIVE_REQUEST_ANIMATION_FRAME = XRSession.prototype.requestAnimationFrame; - XRSession.prototype.requestAnimationFrame = function(callback) { - return NATIVE_REQUEST_ANIMATION_FRAME.call(this, (timestamp, frame) => { - callback(timestamp ? timestamp : performance.now(), frame); - }); - }; - - if (!('getNativeFramebufferScaleFactor' in XRWebGLLayer)) { - if (this._isMobile()) { - const NATIVE_WEBGL_LAYER = XRWebGLLayer; - const NATIVE_WEBGL_LAYER_PROTOTYPE = XRWebGLLayer.prototype; - XRWebGLLayer = function(session, gl, options) { - if (options && options.framebufferScaleFactor) { - // On Chrome 67/68 mobile the default framebuffer returned is 0.7 of full res. - options.framebufferScaleFactor = 0.7 * options.framebufferScaleFactor; - } - - return new NATIVE_WEBGL_LAYER(session, gl, options); - }; - - XRWebGLLayer.prototype = NATIVE_WEBGL_LAYER_PROTOTYPE; - - Object.defineProperty(XRWebGLLayer, 'getNativeFramebufferScaleFactor', { - enumerable: true, configurable: false, writeable: false, - value: function(session) { - if (!session) { - throw new TypeError('No XRSession specified'); - } - if (isMobile()) { - // On Chrome 67/68 mobile the default framebuffer returned is 0.7 of full res. - return 1.42857; - } else { - // On Chrome 67/68 desktop the full res buffer is already returned. - return 1.0; - } - } - }); - } - } - - // If the environmentBlendMode isn't available report it as 'opaque', since any - // implementations lacking this property only really worked on VR headsets. - if (!('environmentBlendMode' in XRSession.prototype)) { - Object.defineProperty(XRSession.prototype, 'environmentBlendMode', { - enumerable: true, configurable: false, writeable: false, - get: function() { return 'opaque'; } - }); - } - - if (!('targetRayMode' in XRInputSource.prototype)) { - Object.defineProperty(XRInputSource.prototype, 'targetRayMode', { - enumerable: true, configurable: false, writeable: false, - get: function() { - switch (this.pointerOrigin) { - case 'head': return 'gaze'; - case 'hand': return 'tracked-pointer'; - case 'screen': return 'screen'; - - default: throw new ValueError('Unrecognized pointerOrigin: ' + this.pointerOrigin); - } - } - }); - } - - if (!('targetRay' in XRInputPose.prototype)) { - Object.defineProperty(XRInputPose.prototype, 'targetRay', { - enumerable: true, configurable: false, writeable: false, - get: function() { - if (!this._targetRay) { - if (this.targetRayMatrix) { - this._targetRay = new XRRayShim(this.targetRayMatrix); - } else if (this.pointerMatrix) { - this._targetRay = new XRRayShim(this.pointerMatrix); - } - } - return this._targetRay || null; - } - }); - } - } -} diff --git a/magic-window.html b/magic-window.html deleted file mode 100644 index 0c4ddcc6e..000000000 --- a/magic-window.html +++ /dev/null @@ -1,215 +0,0 @@ - - - - - - - - - - - - - Magic Window - - - - - - - - - - - - - - - -
-
- Magic Window -

- This sample demonstrates use of a non-immersive XRSession to present - 'Magic Window' content prior to entering XR presentation with an - immersive session. - Back -

-
-
- - - diff --git a/media/logo/webxr-logo-mark.svg b/media/logo/webxr-logo-mark.svg new file mode 100644 index 000000000..e193885ce --- /dev/null +++ b/media/logo/webxr-logo-mark.svg @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/logo/webxr-logo-square.svg b/media/logo/webxr-logo-square.svg new file mode 100644 index 000000000..2ab14c7ec --- /dev/null +++ b/media/logo/webxr-logo-square.svg @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/logo/webxr-logo.svg b/media/logo/webxr-logo.svg new file mode 100644 index 000000000..dfdd7a5ab --- /dev/null +++ b/media/logo/webxr-logo.svg @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/textures/cube-sea.png b/media/textures/cube-sea.png index 460f23a36..7f675a1df 100644 Binary files a/media/textures/cube-sea.png and b/media/textures/cube-sea.png differ diff --git a/mirroring.html b/mirroring.html deleted file mode 100644 index 1d1b07be1..000000000 --- a/mirroring.html +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - Mirroring - - - - - - - - - - - - - - - -
-
- Mirroring -

- This sample demonstrates how to present a simple WebGL scene to a - XRDevice while mirroring to a context. The scene is not rendered to - the page prior to XR presentation. Mirroring has no effect on mobile - or standalone devices. - Back -

-
-
-
-

Click 'Enter XR' to see content

-
- - - diff --git a/module-tester.html b/module-tester.html deleted file mode 100644 index 5d3de9e27..000000000 --- a/module-tester.html +++ /dev/null @@ -1,301 +0,0 @@ - - - - - - - - - - - - - Scene tester - - - - - - - - - - - - - - - -
-
- Module Tester -

- Just a simple test page to allow developers to test sample scenes - without a headset.
- WASD + Mouse Click/Drag to move. -

- -
-
- - - - diff --git a/positional-audio.html b/positional-audio.html index d5c0fc438..6e279773a 100644 --- a/positional-audio.html +++ b/positional-audio.html @@ -25,29 +25,14 @@ - - - + + Positional Audio - - - - - - - - - - -
@@ -61,20 +46,23 @@

- diff --git a/proposals/index.html b/proposals/index.html index 41310ae48..116bb550d 100644 --- a/proposals/index.html +++ b/proposals/index.html @@ -73,6 +73,10 @@ .github-link { font-size: 0.8em; } + + .wordmark img { + width: 70%; + } - + + AR Hit Test - - - - - - - - - - -
@@ -61,17 +46,16 @@

- diff --git a/proposals/phone-ar.html b/proposals/phone-ar.html index b5cbfb955..ec3bc2d50 100644 --- a/proposals/phone-ar.html +++ b/proposals/phone-ar.html @@ -25,27 +25,12 @@ - - - + + Phone AR - - - - - - - - - - -
@@ -58,17 +43,11 @@

- diff --git a/reduced-bind-rendering.html b/reduced-bind-rendering.html index c64e9cb80..ee643a2bf 100644 --- a/reduced-bind-rendering.html +++ b/reduced-bind-rendering.html @@ -25,27 +25,12 @@ - - - + + Reduced Bind Rendering - - - - - - - - - - -
@@ -59,22 +44,25 @@

- diff --git a/room-scale.html b/room-scale.html index 2c8940c14..830a9fa79 100644 --- a/room-scale.html +++ b/room-scale.html @@ -25,27 +25,12 @@ - - - + + Room Scale - - - - - - - - - - -
@@ -59,22 +44,27 @@

- diff --git a/spectator-mode.html b/spectator-mode.html index 52ca40f1e..02ea8ee46 100644 --- a/spectator-mode.html +++ b/spectator-mode.html @@ -25,27 +25,12 @@ - - - + + Spectator Mode - - - - - - - - - - -
@@ -61,25 +46,28 @@
- diff --git a/stereo-video.html b/stereo-video.html index f1719ad4f..de94fad81 100644 --- a/stereo-video.html +++ b/stereo-video.html @@ -25,27 +25,12 @@ - - - + + Stereo Video Player - - - - - - - - - - -
@@ -57,22 +42,28 @@

- diff --git a/teleportation.html b/teleportation.html new file mode 100644 index 000000000..5d2d69459 --- /dev/null +++ b/teleportation.html @@ -0,0 +1,416 @@ + + + + + + + + + + + + Teleportation + + + + +
+
+ Teleportation +

+ This sample demonstrates teleporting the viewer by updating the + XRSession reference space. Select a point on the floor with a + controller to teleport to it. Select the leftmost box to rotate to the + left by 30 degrees. Selecting the rightmost box rotates the viewer by + 30 degress to the right. Select the middle box to reset the + viewer orientation. + Back +

+
+
+ + + \ No newline at end of file diff --git a/tests/cube-sea.html b/tests/cube-sea.html index 3e13e7a69..55f38619b 100644 --- a/tests/cube-sea.html +++ b/tests/cube-sea.html @@ -25,28 +25,14 @@ - - - + + Cube Sea - - - - - - - - - -
@@ -59,17 +45,21 @@

- diff --git a/tests/index.html b/tests/index.html index d975c8d9c..1e2171692 100644 --- a/tests/index.html +++ b/tests/index.html @@ -73,6 +73,10 @@ .github-link { font-size: 0.8em; } + + .wordmark img { + width: 70%; + } Test Pages -

WebXR

+

+ + WebXR Logo + +

Test Pages

@@ -150,21 +158,18 @@

Test Pages

let links = document.createElement('div'); links.classList.add('links'); - let liveLink = document.createElement('a'); - liveLink.href = page.path; - liveLink.innerHTML = 'Open'; - links.appendChild(liveLink); - - let polyfillLink = document.createElement('a'); - polyfillLink.href = page.path + '?allowPolyfill=1'; - polyfillLink.innerHTML = 'Open with Polyfill'; - links.appendChild(polyfillLink); - let sourceLink = document.createElement('a'); sourceLink.href = 'https://github.com/immersive-web/webxr-samples/blob/master/tests/' + page.path; sourceLink.innerHTML = 'Source'; links.appendChild(sourceLink); + if (!page.noPolyfill) { + let polyfillLink = document.createElement('a'); + polyfillLink.href = page.path + '?usePolyfill=1'; + polyfillLink.innerHTML = 'Run with Polyfill'; + links.appendChild(polyfillLink); + } + article.appendChild(links); mainElement.appendChild(article); diff --git a/tests/offscreen-canvas.html b/tests/offscreen-canvas.html index b70143062..b54950996 100644 --- a/tests/offscreen-canvas.html +++ b/tests/offscreen-canvas.html @@ -25,28 +25,14 @@ - - - + + Offscreen Canvas - - - - - - - - - -
@@ -59,129 +45,41 @@

- diff --git a/tests/permission-request.html b/tests/permission-request.html index 2ebd3da50..8809f4bc5 100644 --- a/tests/permission-request.html +++ b/tests/permission-request.html @@ -25,27 +25,12 @@ - - - + + Permission Requests - - - - - - - - - - -
@@ -58,17 +43,20 @@

- diff --git a/tests/pointer-painter.html b/tests/pointer-painter.html index b220cdc52..c848324b2 100644 --- a/tests/pointer-painter.html +++ b/tests/pointer-painter.html @@ -25,27 +25,12 @@ - - - + + Pointer Painter - - - - - - - - - - -
@@ -58,202 +43,101 @@

- diff --git a/tests/sponza.html b/tests/sponza.html index e34eacf12..59f38d6fd 100644 --- a/tests/sponza.html +++ b/tests/sponza.html @@ -25,27 +25,12 @@ - - - + + Sponza - - - - - - - - - - -
@@ -57,159 +42,46 @@

- diff --git a/viewport-scaling.html b/viewport-scaling.html deleted file mode 100644 index f7ad840ae..000000000 --- a/viewport-scaling.html +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - - - - - - - - Viewport Scaling - - - - - - - - - - - - - - - -
-
- Viewport Scaling -

- This sample demonstrates scaling the viewports used for a WebXR layer - at runtime to dynamically adjust the fillrate required and improve - performance or quality as needed. - - Viewport scaling should be used to make a performance/quality tradeoff - in response to realtime performance monitoring. - Back -

-
-
- - - diff --git a/xr-barebones.html b/xr-barebones.html index 9c3ef6bcb..38c891b23 100644 --- a/xr-barebones.html +++ b/xr-barebones.html @@ -25,18 +25,12 @@ - - - + + Barebones WebXR - - -
@@ -58,8 +52,6 @@ (function () { 'use strict'; - var versionShim = new WebXRVersionShim(); - // XR globals. let xrButton = document.getElementById('xr-button'); let xrSession = null; @@ -76,7 +68,7 @@ if (navigator.xr) { // If the device allows creation of exclusive sessions set it as the // target of the 'Enter XR' button. - navigator.xr.supportsSessionMode('immersive-vr').then(() => { + navigator.xr.supportsSession('immersive-vr').then(() => { // Updates the button to start an XR session when clicked. xrButton.addEventListener('click', onButtonClicked); xrButton.innerHTML = 'Enter XR'; @@ -86,10 +78,10 @@ } // Called when the user clicks the button to enter XR. If we don't have a - // session already we'll request one, and if we do we'll end it. + // session we'll request one, and if we do have a session we'll end it. function onButtonClicked() { if (!xrSession) { - navigator.xr.requestSession({mode: 'immersive-vr'}).then(onSessionStarted); + navigator.xr.requestSession('immersive-vr').then(onSessionStarted); } else { xrSession.end(); } @@ -108,19 +100,17 @@ // Create a WebGL context to render with, initialized to be compatible // with the XRDisplay we're presenting to. let canvas = document.createElement('canvas'); - gl = canvas.getContext('webgl', { - xrCompatible: true - }); + gl = canvas.getContext('webgl', { xrCompatible: true }); // Use the new WebGL context to create a XRWebGLLayer and set it as the // sessions baseLayer. This allows any content rendered to the layer to // be displayed on the XRDevice. session.updateRenderState({ baseLayer: new XRWebGLLayer(session, gl) }); - // Get a frame of reference, which is required for querying poses. In - // this case an 'eye-level' frame of reference means that all poses will - // be relative to the location where the XRDevice was first detected. - session.requestReferenceSpace({ type: 'stationary', subtype: 'eye-level' }).then((refSpace) => { + // Get a reference space, which is required for querying poses. In this + // case an 'local' reference space means that all poses will be relative + // to the location where the XRDevice was first detected. + session.requestReferenceSpace('local').then((refSpace) => { xrRefSpace = refSpace; // Inform the session that we're ready to begin drawing. @@ -128,14 +118,8 @@ }); } - // Called when the user clicks the 'Exit XR' button. In response we end - // the session. - function onEndSession(session) { - session.end(); - } - - // Called either when the user has explicitly ended the session (like in - // onEndSession()) or when the UA has ended the session for any reason. + // Called either when the user has explicitly ended the session by calling + // session.end() or when the UA has ended the session for any reason. // At this point the session object is no longer usable and should be // discarded. function onSessionEnded(event) { @@ -148,13 +132,13 @@ } // Called every time the XRSession requests that a new frame be drawn. - function onXRFrame(t, frame) { + function onXRFrame(time, frame) { let session = frame.session; // Inform the session that we're ready for the next frame. session.requestAnimationFrame(onXRFrame); - // Get the XRDevice pose relative to the Frame of Reference we created + // Get the XRDevice pose relative to the reference space we created // earlier. let pose = frame.getViewerPose(xrRefSpace); @@ -162,7 +146,7 @@ // have to check to make sure that we got a valid pose before attempting // to render with it. If not in this case we'll just leave the // framebuffer cleared, so tracking loss means the scene will simply - // dissapear. + // disappear. if (pose) { let glLayer = session.renderState.baseLayer; @@ -173,8 +157,9 @@ // Update the clear color so that we can observe the color in the // headset changing over time. - let time = Date.now(); - gl.clearColor(Math.cos(time / 2000), Math.cos(time / 4000), Math.cos(time / 6000), 1.0); + gl.clearColor(Math.cos(time / 2000), + Math.cos(time / 4000), + Math.cos(time / 6000), 1.0); // Clear the framebuffer gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); @@ -188,7 +173,9 @@ gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); - // Draw something. + // Draw a scene using view.projectionMatrix as the projection matrix + // and view.transform to position the virtual camera. If you need a + // view matrix, use view.transform.inverse.matrix. }*/ } }