diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..499e130 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +dist/index.bundle.js diff --git a/.gitigore b/.gitigore new file mode 100644 index 0000000..5e43aa6 --- /dev/null +++ b/.gitigore @@ -0,0 +1 @@ +dist/index.bundle.js diff --git a/README.md b/README.md index b1b5672..037eedb 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,32 @@ A websperience by Vi Hart, Andrea Hawksley, and Henry Segerman, using the hyperb Try it at: https://hawksley.github.io/hypVR/ + +## Installing Locally + +The version 1.1.0 requires node.js version > 6 and should work with every os. + +### Steps: +- git clone this project +- run "npm install" where you cloned this project +- run "npm start" + +you should see the application run on http://localhost:8080 + Enjoy. + +### Release Notes: +1.1.0: + - The application can be compiled with webpack to reduce dramatically the file size of the imported code + - Less pollution of the global scope + - using webVR polyfill, the application runs on browsers + - the package host it own dev server to compile the code as each file save + - the dev server can be run from an npm command + +### Further Enhancements: +- finishing polishing the code to make it more granular and easy to modify +- introducing performance testing for big functions like gramShmidt +- introducing unit tests + ## Links - http://vihart.com - http://andreahawksley.com @@ -15,3 +41,4 @@ Try it at: https://hawksley.github.io/hypVR/ - http://www.geometrygames.org/CurvedSpaces/ - http://www.marctenbosch.com - https://github.com/MozVR/vr-web-examples/tree/master/threejs-vr-boilerplate +- https://github.com/AbdoulSy diff --git a/CNAME b/dist/CNAME similarity index 100% rename from CNAME rename to dist/CNAME diff --git a/index.html b/dist/index.html similarity index 83% rename from index.html rename to dist/index.html index d0f40a4..e680a46 100644 --- a/index.html +++ b/dist/index.html @@ -37,6 +37,32 @@ + + + + + + - - - - - - - - - - - - - - - - - + + diff --git a/dist/js/third-party/webvr-polyfill.js b/dist/js/third-party/webvr-polyfill.js new file mode 100644 index 0000000..749b946 --- /dev/null +++ b/dist/js/third-party/webvr-polyfill.js @@ -0,0 +1,6917 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WebVRPolyfill = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o self.capabilities.maxLayers) { + reject(new Error('Invalid number of layers.')); + return; + } + + var incomingLayer = layers[0]; + if (!incomingLayer.source) { + /* + todo: figure out the correct behavior if the source is not provided. + see https://github.com/w3c/webvr/issues/58 + */ + resolve(); + return; + } + + var leftBounds = incomingLayer.leftBounds || defaultLeftBounds; + var rightBounds = incomingLayer.rightBounds || defaultRightBounds; + if (wasPresenting) { + // Already presenting, just changing configuration + var layer = self.layer_; + if (layer.source !== incomingLayer.source) { + layer.source = incomingLayer.source; + } + + for (var i = 0; i < 4; i++) { + layer.leftBounds[i] = leftBounds[i]; + layer.rightBounds[i] = rightBounds[i]; + } + + resolve(); + return; + } + + // Was not already presenting. + self.layer_ = { + predistorted: incomingLayer.predistorted, + source: incomingLayer.source, + leftBounds: leftBounds.slice(0), + rightBounds: rightBounds.slice(0) + }; + + self.waitingForPresent_ = false; + if (self.layer_ && self.layer_.source) { + var fullscreenElement = self.wrapForFullscreen(self.layer_.source); + + var onFullscreenChange = function() { + var actualFullscreenElement = Util.getFullscreenElement(); + + self.isPresenting = (fullscreenElement === actualFullscreenElement); + if (self.isPresenting) { + if (screen.orientation && screen.orientation.lock) { + screen.orientation.lock('landscape-primary').catch(function(error){ + console.error('screen.orientation.lock() failed due to', error.message) + }); + } + self.waitingForPresent_ = false; + self.beginPresent_(); + resolve(); + } else { + if (screen.orientation && screen.orientation.unlock) { + screen.orientation.unlock(); + } + self.removeFullscreenWrapper(); + self.wakelock_.release(); + self.endPresent_(); + self.removeFullscreenListeners_(); + } + self.fireVRDisplayPresentChange_(); + } + var onFullscreenError = function() { + if (!self.waitingForPresent_) { + return; + } + + self.removeFullscreenWrapper(); + self.removeFullscreenListeners_(); + + self.wakelock_.release(); + self.waitingForPresent_ = false; + self.isPresenting = false; + + reject(new Error('Unable to present.')); + } + + self.addFullscreenListeners_(fullscreenElement, + onFullscreenChange, onFullscreenError); + + if (Util.requestFullscreen(fullscreenElement)) { + self.wakelock_.request(); + self.waitingForPresent_ = true; + } else if (Util.isIOS() || Util.isWebViewAndroid()) { + // *sigh* Just fake it. + self.wakelock_.request(); + self.isPresenting = true; + self.beginPresent_(); + self.fireVRDisplayPresentChange_(); + resolve(); + } + } + + if (!self.waitingForPresent_ && !Util.isIOS()) { + Util.exitFullscreen(); + reject(new Error('Unable to present.')); + } + }); +}; + +VRDisplay.prototype.exitPresent = function() { + var wasPresenting = this.isPresenting; + var self = this; + this.isPresenting = false; + this.layer_ = null; + this.wakelock_.release(); + + return new Promise(function(resolve, reject) { + if (wasPresenting) { + if (!Util.exitFullscreen() && Util.isIOS()) { + self.endPresent_(); + self.fireVRDisplayPresentChange_(); + } + + if (Util.isWebViewAndroid()) { + self.removeFullscreenWrapper(); + self.removeFullscreenListeners_(); + self.endPresent_(); + self.fireVRDisplayPresentChange_(); + } + + resolve(); + } else { + reject(new Error('Was not presenting to VRDisplay.')); + } + }); +}; + +VRDisplay.prototype.getLayers = function() { + if (this.layer_) { + return [this.layer_]; + } + return []; +}; + +VRDisplay.prototype.fireVRDisplayPresentChange_ = function() { + // Important: unfortunately we cannot have full spec compliance here. + // CustomEvent custom fields all go under e.detail (so the VRDisplay ends up + // being e.detail.display, instead of e.display as per WebVR spec). + var event = new CustomEvent('vrdisplaypresentchange', {detail: {display: this}}); + window.dispatchEvent(event); +}; + +VRDisplay.prototype.addFullscreenListeners_ = function(element, changeHandler, errorHandler) { + this.removeFullscreenListeners_(); + + this.fullscreenEventTarget_ = element; + this.fullscreenChangeHandler_ = changeHandler; + this.fullscreenErrorHandler_ = errorHandler; + + if (changeHandler) { + if (document.fullscreenEnabled) { + element.addEventListener('fullscreenchange', changeHandler, false); + } else if (document.webkitFullscreenEnabled) { + element.addEventListener('webkitfullscreenchange', changeHandler, false); + } else if (document.mozFullScreenEnabled) { + document.addEventListener('mozfullscreenchange', changeHandler, false); + } else if (document.msFullscreenEnabled) { + element.addEventListener('msfullscreenchange', changeHandler, false); + } + } + + if (errorHandler) { + if (document.fullscreenEnabled) { + element.addEventListener('fullscreenerror', errorHandler, false); + } else if (document.webkitFullscreenEnabled) { + element.addEventListener('webkitfullscreenerror', errorHandler, false); + } else if (document.mozFullScreenEnabled) { + document.addEventListener('mozfullscreenerror', errorHandler, false); + } else if (document.msFullscreenEnabled) { + element.addEventListener('msfullscreenerror', errorHandler, false); + } + } +}; + +VRDisplay.prototype.removeFullscreenListeners_ = function() { + if (!this.fullscreenEventTarget_) + return; + + var element = this.fullscreenEventTarget_; + + if (this.fullscreenChangeHandler_) { + var changeHandler = this.fullscreenChangeHandler_; + element.removeEventListener('fullscreenchange', changeHandler, false); + element.removeEventListener('webkitfullscreenchange', changeHandler, false); + document.removeEventListener('mozfullscreenchange', changeHandler, false); + element.removeEventListener('msfullscreenchange', changeHandler, false); + } + + if (this.fullscreenErrorHandler_) { + var errorHandler = this.fullscreenErrorHandler_; + element.removeEventListener('fullscreenerror', errorHandler, false); + element.removeEventListener('webkitfullscreenerror', errorHandler, false); + document.removeEventListener('mozfullscreenerror', errorHandler, false); + element.removeEventListener('msfullscreenerror', errorHandler, false); + } + + this.fullscreenEventTarget_ = null; + this.fullscreenChangeHandler_ = null; + this.fullscreenErrorHandler_ = null; +}; + +VRDisplay.prototype.beginPresent_ = function() { + // Override to add custom behavior when presentation begins. +}; + +VRDisplay.prototype.endPresent_ = function() { + // Override to add custom behavior when presentation ends. +}; + +VRDisplay.prototype.submitFrame = function(pose) { + // Override to add custom behavior for frame submission. +}; + +VRDisplay.prototype.getEyeParameters = function(whichEye) { + // Override to return accurate eye parameters if canPresent is true. + return null; +}; + +/* + * Deprecated classes + */ + +/** + * The base class for all VR devices. (Deprecated) + */ +function VRDevice() { + this.isPolyfilled = true; + this.hardwareUnitId = 'webvr-polyfill hardwareUnitId'; + this.deviceId = 'webvr-polyfill deviceId'; + this.deviceName = 'webvr-polyfill deviceName'; +} + +/** + * The base class for all VR HMD devices. (Deprecated) + */ +function HMDVRDevice() { +} +HMDVRDevice.prototype = new VRDevice(); + +/** + * The base class for all VR position sensor devices. (Deprecated) + */ +function PositionSensorVRDevice() { +} +PositionSensorVRDevice.prototype = new VRDevice(); + +module.exports.VRFrameData = VRFrameData; +module.exports.VRDisplay = VRDisplay; +module.exports.VRDevice = VRDevice; +module.exports.HMDVRDevice = HMDVRDevice; +module.exports.PositionSensorVRDevice = PositionSensorVRDevice; + +},{"./util.js":22,"./wakelock.js":24}],4:[function(_dereq_,module,exports){ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * 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. + */ + +var CardboardUI = _dereq_('./cardboard-ui.js'); +var Util = _dereq_('./util.js'); +var WGLUPreserveGLState = _dereq_('./deps/wglu-preserve-state.js'); + +var distortionVS = [ + 'attribute vec2 position;', + 'attribute vec3 texCoord;', + + 'varying vec2 vTexCoord;', + + 'uniform vec4 viewportOffsetScale[2];', + + 'void main() {', + ' vec4 viewport = viewportOffsetScale[int(texCoord.z)];', + ' vTexCoord = (texCoord.xy * viewport.zw) + viewport.xy;', + ' gl_Position = vec4( position, 1.0, 1.0 );', + '}', +].join('\n'); + +var distortionFS = [ + 'precision mediump float;', + 'uniform sampler2D diffuse;', + + 'varying vec2 vTexCoord;', + + 'void main() {', + ' gl_FragColor = texture2D(diffuse, vTexCoord);', + '}', +].join('\n'); + +/** + * A mesh-based distorter. + */ +function CardboardDistorter(gl) { + this.gl = gl; + this.ctxAttribs = gl.getContextAttributes(); + + this.meshWidth = 20; + this.meshHeight = 20; + + this.bufferScale = window.WebVRConfig.BUFFER_SCALE; + + this.bufferWidth = gl.drawingBufferWidth; + this.bufferHeight = gl.drawingBufferHeight; + + // Patching support + this.realBindFramebuffer = gl.bindFramebuffer; + this.realEnable = gl.enable; + this.realDisable = gl.disable; + this.realColorMask = gl.colorMask; + this.realClearColor = gl.clearColor; + this.realViewport = gl.viewport; + + if (!Util.isIOS()) { + this.realCanvasWidth = Object.getOwnPropertyDescriptor(gl.canvas.__proto__, 'width'); + this.realCanvasHeight = Object.getOwnPropertyDescriptor(gl.canvas.__proto__, 'height'); + } + + this.isPatched = false; + + // State tracking + this.lastBoundFramebuffer = null; + this.cullFace = false; + this.depthTest = false; + this.blend = false; + this.scissorTest = false; + this.stencilTest = false; + this.viewport = [0, 0, 0, 0]; + this.colorMask = [true, true, true, true]; + this.clearColor = [0, 0, 0, 0]; + + this.attribs = { + position: 0, + texCoord: 1 + }; + this.program = Util.linkProgram(gl, distortionVS, distortionFS, this.attribs); + this.uniforms = Util.getProgramUniforms(gl, this.program); + + this.viewportOffsetScale = new Float32Array(8); + this.setTextureBounds(); + + this.vertexBuffer = gl.createBuffer(); + this.indexBuffer = gl.createBuffer(); + this.indexCount = 0; + + this.renderTarget = gl.createTexture(); + this.framebuffer = gl.createFramebuffer(); + + this.depthStencilBuffer = null; + this.depthBuffer = null; + this.stencilBuffer = null; + + if (this.ctxAttribs.depth && this.ctxAttribs.stencil) { + this.depthStencilBuffer = gl.createRenderbuffer(); + } else if (this.ctxAttribs.depth) { + this.depthBuffer = gl.createRenderbuffer(); + } else if (this.ctxAttribs.stencil) { + this.stencilBuffer = gl.createRenderbuffer(); + } + + this.patch(); + + this.onResize(); + + if (!window.WebVRConfig.CARDBOARD_UI_DISABLED) { + this.cardboardUI = new CardboardUI(gl); + } +}; + +/** + * Tears down all the resources created by the distorter and removes any + * patches. + */ +CardboardDistorter.prototype.destroy = function() { + var gl = this.gl; + + this.unpatch(); + + gl.deleteProgram(this.program); + gl.deleteBuffer(this.vertexBuffer); + gl.deleteBuffer(this.indexBuffer); + gl.deleteTexture(this.renderTarget); + gl.deleteFramebuffer(this.framebuffer); + if (this.depthStencilBuffer) { + gl.deleteRenderbuffer(this.depthStencilBuffer); + } + if (this.depthBuffer) { + gl.deleteRenderbuffer(this.depthBuffer); + } + if (this.stencilBuffer) { + gl.deleteRenderbuffer(this.stencilBuffer); + } + + if (this.cardboardUI) { + this.cardboardUI.destroy(); + } +}; + + +/** + * Resizes the backbuffer to match the canvas width and height. + */ +CardboardDistorter.prototype.onResize = function() { + var gl = this.gl; + var self = this; + + var glState = [ + gl.RENDERBUFFER_BINDING, + gl.TEXTURE_BINDING_2D, gl.TEXTURE0 + ]; + + WGLUPreserveGLState(gl, glState, function(gl) { + // Bind real backbuffer and clear it once. We don't need to clear it again + // after that because we're overwriting the same area every frame. + self.realBindFramebuffer.call(gl, gl.FRAMEBUFFER, null); + + // Put things in a good state + if (self.scissorTest) { self.realDisable.call(gl, gl.SCISSOR_TEST); } + self.realColorMask.call(gl, true, true, true, true); + self.realViewport.call(gl, 0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); + self.realClearColor.call(gl, 0, 0, 0, 1); + + gl.clear(gl.COLOR_BUFFER_BIT); + + // Now bind and resize the fake backbuffer + self.realBindFramebuffer.call(gl, gl.FRAMEBUFFER, self.framebuffer); + + gl.bindTexture(gl.TEXTURE_2D, self.renderTarget); + gl.texImage2D(gl.TEXTURE_2D, 0, self.ctxAttribs.alpha ? gl.RGBA : gl.RGB, + self.bufferWidth, self.bufferHeight, 0, + self.ctxAttribs.alpha ? gl.RGBA : gl.RGB, gl.UNSIGNED_BYTE, null); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, self.renderTarget, 0); + + if (self.ctxAttribs.depth && self.ctxAttribs.stencil) { + gl.bindRenderbuffer(gl.RENDERBUFFER, self.depthStencilBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, + self.bufferWidth, self.bufferHeight); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, + gl.RENDERBUFFER, self.depthStencilBuffer); + } else if (self.ctxAttribs.depth) { + gl.bindRenderbuffer(gl.RENDERBUFFER, self.depthBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, + self.bufferWidth, self.bufferHeight); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, + gl.RENDERBUFFER, self.depthBuffer); + } else if (self.ctxAttribs.stencil) { + gl.bindRenderbuffer(gl.RENDERBUFFER, self.stencilBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.STENCIL_INDEX8, + self.bufferWidth, self.bufferHeight); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.STENCIL_ATTACHMENT, + gl.RENDERBUFFER, self.stencilBuffer); + } + + if (!gl.checkFramebufferStatus(gl.FRAMEBUFFER) === gl.FRAMEBUFFER_COMPLETE) { + console.error('Framebuffer incomplete!'); + } + + self.realBindFramebuffer.call(gl, gl.FRAMEBUFFER, self.lastBoundFramebuffer); + + if (self.scissorTest) { self.realEnable.call(gl, gl.SCISSOR_TEST); } + + self.realColorMask.apply(gl, self.colorMask); + self.realViewport.apply(gl, self.viewport); + self.realClearColor.apply(gl, self.clearColor); + }); + + if (this.cardboardUI) { + this.cardboardUI.onResize(); + } +}; + +CardboardDistorter.prototype.patch = function() { + if (this.isPatched) { + return; + } + + var self = this; + var canvas = this.gl.canvas; + var gl = this.gl; + + if (!Util.isIOS()) { + canvas.width = Util.getScreenWidth() * this.bufferScale; + canvas.height = Util.getScreenHeight() * this.bufferScale; + + Object.defineProperty(canvas, 'width', { + configurable: true, + enumerable: true, + get: function() { + return self.bufferWidth; + }, + set: function(value) { + self.bufferWidth = value; + self.realCanvasWidth.set.call(canvas, value); + self.onResize(); + } + }); + + Object.defineProperty(canvas, 'height', { + configurable: true, + enumerable: true, + get: function() { + return self.bufferHeight; + }, + set: function(value) { + self.bufferHeight = value; + self.realCanvasHeight.set.call(canvas, value); + self.onResize(); + } + }); + } + + this.lastBoundFramebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING); + + if (this.lastBoundFramebuffer == null) { + this.lastBoundFramebuffer = this.framebuffer; + this.gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer); + } + + this.gl.bindFramebuffer = function(target, framebuffer) { + self.lastBoundFramebuffer = framebuffer ? framebuffer : self.framebuffer; + // Silently make calls to bind the default framebuffer bind ours instead. + self.realBindFramebuffer.call(gl, target, self.lastBoundFramebuffer); + }; + + this.cullFace = gl.getParameter(gl.CULL_FACE); + this.depthTest = gl.getParameter(gl.DEPTH_TEST); + this.blend = gl.getParameter(gl.BLEND); + this.scissorTest = gl.getParameter(gl.SCISSOR_TEST); + this.stencilTest = gl.getParameter(gl.STENCIL_TEST); + + gl.enable = function(pname) { + switch (pname) { + case gl.CULL_FACE: self.cullFace = true; break; + case gl.DEPTH_TEST: self.depthTest = true; break; + case gl.BLEND: self.blend = true; break; + case gl.SCISSOR_TEST: self.scissorTest = true; break; + case gl.STENCIL_TEST: self.stencilTest = true; break; + } + self.realEnable.call(gl, pname); + }; + + gl.disable = function(pname) { + switch (pname) { + case gl.CULL_FACE: self.cullFace = false; break; + case gl.DEPTH_TEST: self.depthTest = false; break; + case gl.BLEND: self.blend = false; break; + case gl.SCISSOR_TEST: self.scissorTest = false; break; + case gl.STENCIL_TEST: self.stencilTest = false; break; + } + self.realDisable.call(gl, pname); + }; + + this.colorMask = gl.getParameter(gl.COLOR_WRITEMASK); + gl.colorMask = function(r, g, b, a) { + self.colorMask[0] = r; + self.colorMask[1] = g; + self.colorMask[2] = b; + self.colorMask[3] = a; + self.realColorMask.call(gl, r, g, b, a); + }; + + this.clearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE); + gl.clearColor = function(r, g, b, a) { + self.clearColor[0] = r; + self.clearColor[1] = g; + self.clearColor[2] = b; + self.clearColor[3] = a; + self.realClearColor.call(gl, r, g, b, a); + }; + + this.viewport = gl.getParameter(gl.VIEWPORT); + gl.viewport = function(x, y, w, h) { + self.viewport[0] = x; + self.viewport[1] = y; + self.viewport[2] = w; + self.viewport[3] = h; + self.realViewport.call(gl, x, y, w, h); + }; + + this.isPatched = true; + Util.safariCssSizeWorkaround(canvas); +}; + +CardboardDistorter.prototype.unpatch = function() { + if (!this.isPatched) { + return; + } + + var gl = this.gl; + var canvas = this.gl.canvas; + + if (!Util.isIOS()) { + Object.defineProperty(canvas, 'width', this.realCanvasWidth); + Object.defineProperty(canvas, 'height', this.realCanvasHeight); + } + canvas.width = this.bufferWidth; + canvas.height = this.bufferHeight; + + gl.bindFramebuffer = this.realBindFramebuffer; + gl.enable = this.realEnable; + gl.disable = this.realDisable; + gl.colorMask = this.realColorMask; + gl.clearColor = this.realClearColor; + gl.viewport = this.realViewport; + + // Check to see if our fake backbuffer is bound and bind the real backbuffer + // if that's the case. + if (this.lastBoundFramebuffer == this.framebuffer) { + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + } + + this.isPatched = false; + + setTimeout(function() { + Util.safariCssSizeWorkaround(canvas); + }, 1); +}; + +CardboardDistorter.prototype.setTextureBounds = function(leftBounds, rightBounds) { + if (!leftBounds) { + leftBounds = [0, 0, 0.5, 1]; + } + + if (!rightBounds) { + rightBounds = [0.5, 0, 0.5, 1]; + } + + // Left eye + this.viewportOffsetScale[0] = leftBounds[0]; // X + this.viewportOffsetScale[1] = leftBounds[1]; // Y + this.viewportOffsetScale[2] = leftBounds[2]; // Width + this.viewportOffsetScale[3] = leftBounds[3]; // Height + + // Right eye + this.viewportOffsetScale[4] = rightBounds[0]; // X + this.viewportOffsetScale[5] = rightBounds[1]; // Y + this.viewportOffsetScale[6] = rightBounds[2]; // Width + this.viewportOffsetScale[7] = rightBounds[3]; // Height +}; + +/** + * Performs distortion pass on the injected backbuffer, rendering it to the real + * backbuffer. + */ +CardboardDistorter.prototype.submitFrame = function() { + var gl = this.gl; + var self = this; + + var glState = []; + + if (!window.WebVRConfig.DIRTY_SUBMIT_FRAME_BINDINGS) { + glState.push( + gl.CURRENT_PROGRAM, + gl.ARRAY_BUFFER_BINDING, + gl.ELEMENT_ARRAY_BUFFER_BINDING, + gl.TEXTURE_BINDING_2D, gl.TEXTURE0 + ); + } + + WGLUPreserveGLState(gl, glState, function(gl) { + // Bind the real default framebuffer + self.realBindFramebuffer.call(gl, gl.FRAMEBUFFER, null); + + // Make sure the GL state is in a good place + if (self.cullFace) { self.realDisable.call(gl, gl.CULL_FACE); } + if (self.depthTest) { self.realDisable.call(gl, gl.DEPTH_TEST); } + if (self.blend) { self.realDisable.call(gl, gl.BLEND); } + if (self.scissorTest) { self.realDisable.call(gl, gl.SCISSOR_TEST); } + if (self.stencilTest) { self.realDisable.call(gl, gl.STENCIL_TEST); } + self.realColorMask.call(gl, true, true, true, true); + self.realViewport.call(gl, 0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); + + // If the backbuffer has an alpha channel clear every frame so the page + // doesn't show through. + if (self.ctxAttribs.alpha || Util.isIOS()) { + self.realClearColor.call(gl, 0, 0, 0, 1); + gl.clear(gl.COLOR_BUFFER_BIT); + } + + // Bind distortion program and mesh + gl.useProgram(self.program); + + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, self.indexBuffer); + + gl.bindBuffer(gl.ARRAY_BUFFER, self.vertexBuffer); + gl.enableVertexAttribArray(self.attribs.position); + gl.enableVertexAttribArray(self.attribs.texCoord); + gl.vertexAttribPointer(self.attribs.position, 2, gl.FLOAT, false, 20, 0); + gl.vertexAttribPointer(self.attribs.texCoord, 3, gl.FLOAT, false, 20, 8); + + gl.activeTexture(gl.TEXTURE0); + gl.uniform1i(self.uniforms.diffuse, 0); + gl.bindTexture(gl.TEXTURE_2D, self.renderTarget); + + gl.uniform4fv(self.uniforms.viewportOffsetScale, self.viewportOffsetScale); + + // Draws both eyes + gl.drawElements(gl.TRIANGLES, self.indexCount, gl.UNSIGNED_SHORT, 0); + + if (self.cardboardUI) { + self.cardboardUI.renderNoState(); + } + + // Bind the fake default framebuffer again + self.realBindFramebuffer.call(self.gl, gl.FRAMEBUFFER, self.framebuffer); + + // If preserveDrawingBuffer == false clear the framebuffer + if (!self.ctxAttribs.preserveDrawingBuffer) { + self.realClearColor.call(gl, 0, 0, 0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + } + + if (!window.WebVRConfig.DIRTY_SUBMIT_FRAME_BINDINGS) { + self.realBindFramebuffer.call(gl, gl.FRAMEBUFFER, self.lastBoundFramebuffer); + } + + // Restore state + if (self.cullFace) { self.realEnable.call(gl, gl.CULL_FACE); } + if (self.depthTest) { self.realEnable.call(gl, gl.DEPTH_TEST); } + if (self.blend) { self.realEnable.call(gl, gl.BLEND); } + if (self.scissorTest) { self.realEnable.call(gl, gl.SCISSOR_TEST); } + if (self.stencilTest) { self.realEnable.call(gl, gl.STENCIL_TEST); } + + self.realColorMask.apply(gl, self.colorMask); + self.realViewport.apply(gl, self.viewport); + if (self.ctxAttribs.alpha || !self.ctxAttribs.preserveDrawingBuffer) { + self.realClearColor.apply(gl, self.clearColor); + } + }); + + // Workaround for the fact that Safari doesn't allow us to patch the canvas + // width and height correctly. After each submit frame check to see what the + // real backbuffer size has been set to and resize the fake backbuffer size + // to match. + if (Util.isIOS()) { + var canvas = gl.canvas; + if (canvas.width != self.bufferWidth || canvas.height != self.bufferHeight) { + self.bufferWidth = canvas.width; + self.bufferHeight = canvas.height; + self.onResize(); + } + } +}; + +/** + * Call when the deviceInfo has changed. At this point we need + * to re-calculate the distortion mesh. + */ +CardboardDistorter.prototype.updateDeviceInfo = function(deviceInfo) { + var gl = this.gl; + var self = this; + + var glState = [gl.ARRAY_BUFFER_BINDING, gl.ELEMENT_ARRAY_BUFFER_BINDING]; + WGLUPreserveGLState(gl, glState, function(gl) { + var vertices = self.computeMeshVertices_(self.meshWidth, self.meshHeight, deviceInfo); + gl.bindBuffer(gl.ARRAY_BUFFER, self.vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW); + + // Indices don't change based on device parameters, so only compute once. + if (!self.indexCount) { + var indices = self.computeMeshIndices_(self.meshWidth, self.meshHeight); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, self.indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW); + self.indexCount = indices.length; + } + }); +}; + +/** + * Build the distortion mesh vertices. + * Based on code from the Unity cardboard plugin. + */ +CardboardDistorter.prototype.computeMeshVertices_ = function(width, height, deviceInfo) { + var vertices = new Float32Array(2 * width * height * 5); + + var lensFrustum = deviceInfo.getLeftEyeVisibleTanAngles(); + var noLensFrustum = deviceInfo.getLeftEyeNoLensTanAngles(); + var viewport = deviceInfo.getLeftEyeVisibleScreenRect(noLensFrustum); + var vidx = 0; + var iidx = 0; + for (var e = 0; e < 2; e++) { + for (var j = 0; j < height; j++) { + for (var i = 0; i < width; i++, vidx++) { + var u = i / (width - 1); + var v = j / (height - 1); + + // Grid points regularly spaced in StreoScreen, and barrel distorted in + // the mesh. + var s = u; + var t = v; + var x = Util.lerp(lensFrustum[0], lensFrustum[2], u); + var y = Util.lerp(lensFrustum[3], lensFrustum[1], v); + var d = Math.sqrt(x * x + y * y); + var r = deviceInfo.distortion.distortInverse(d); + var p = x * r / d; + var q = y * r / d; + u = (p - noLensFrustum[0]) / (noLensFrustum[2] - noLensFrustum[0]); + v = (q - noLensFrustum[3]) / (noLensFrustum[1] - noLensFrustum[3]); + + // Convert u,v to mesh screen coordinates. + var aspect = deviceInfo.device.widthMeters / deviceInfo.device.heightMeters; + + // FIXME: The original Unity plugin multiplied U by the aspect ratio + // and didn't multiply either value by 2, but that seems to get it + // really close to correct looking for me. I hate this kind of "Don't + // know why it works" code though, and wold love a more logical + // explanation of what needs to happen here. + u = (viewport.x + u * viewport.width - 0.5) * 2.0; //* aspect; + v = (viewport.y + v * viewport.height - 0.5) * 2.0; + + vertices[(vidx * 5) + 0] = u; // position.x + vertices[(vidx * 5) + 1] = v; // position.y + vertices[(vidx * 5) + 2] = s; // texCoord.x + vertices[(vidx * 5) + 3] = t; // texCoord.y + vertices[(vidx * 5) + 4] = e; // texCoord.z (viewport index) + } + } + var w = lensFrustum[2] - lensFrustum[0]; + lensFrustum[0] = -(w + lensFrustum[0]); + lensFrustum[2] = w - lensFrustum[2]; + w = noLensFrustum[2] - noLensFrustum[0]; + noLensFrustum[0] = -(w + noLensFrustum[0]); + noLensFrustum[2] = w - noLensFrustum[2]; + viewport.x = 1 - (viewport.x + viewport.width); + } + return vertices; +} + +/** + * Build the distortion mesh indices. + * Based on code from the Unity cardboard plugin. + */ +CardboardDistorter.prototype.computeMeshIndices_ = function(width, height) { + var indices = new Uint16Array(2 * (width - 1) * (height - 1) * 6); + var halfwidth = width / 2; + var halfheight = height / 2; + var vidx = 0; + var iidx = 0; + for (var e = 0; e < 2; e++) { + for (var j = 0; j < height; j++) { + for (var i = 0; i < width; i++, vidx++) { + if (i == 0 || j == 0) + continue; + // Build a quad. Lower right and upper left quadrants have quads with + // the triangle diagonal flipped to get the vignette to interpolate + // correctly. + if ((i <= halfwidth) == (j <= halfheight)) { + // Quad diagonal lower left to upper right. + indices[iidx++] = vidx; + indices[iidx++] = vidx - width - 1; + indices[iidx++] = vidx - width; + indices[iidx++] = vidx - width - 1; + indices[iidx++] = vidx; + indices[iidx++] = vidx - 1; + } else { + // Quad diagonal upper left to lower right. + indices[iidx++] = vidx - 1; + indices[iidx++] = vidx - width; + indices[iidx++] = vidx; + indices[iidx++] = vidx - width; + indices[iidx++] = vidx - 1; + indices[iidx++] = vidx - width - 1; + } + } + } + } + return indices; +}; + +CardboardDistorter.prototype.getOwnPropertyDescriptor_ = function(proto, attrName) { + var descriptor = Object.getOwnPropertyDescriptor(proto, attrName); + // In some cases (ahem... Safari), the descriptor returns undefined get and + // set fields. In this case, we need to create a synthetic property + // descriptor. This works around some of the issues in + // https://github.com/borismus/webvr-polyfill/issues/46 + if (descriptor.get === undefined || descriptor.set === undefined) { + descriptor.configurable = true; + descriptor.enumerable = true; + descriptor.get = function() { + return this.getAttribute(attrName); + }; + descriptor.set = function(val) { + this.setAttribute(attrName, val); + }; + } + return descriptor; +}; + +module.exports = CardboardDistorter; + +},{"./cardboard-ui.js":5,"./deps/wglu-preserve-state.js":7,"./util.js":22}],5:[function(_dereq_,module,exports){ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * 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. + */ + +var Util = _dereq_('./util.js'); +var WGLUPreserveGLState = _dereq_('./deps/wglu-preserve-state.js'); + +var uiVS = [ + 'attribute vec2 position;', + + 'uniform mat4 projectionMat;', + + 'void main() {', + ' gl_Position = projectionMat * vec4( position, -1.0, 1.0 );', + '}', +].join('\n'); + +var uiFS = [ + 'precision mediump float;', + + 'uniform vec4 color;', + + 'void main() {', + ' gl_FragColor = color;', + '}', +].join('\n'); + +var DEG2RAD = Math.PI/180.0; + +// The gear has 6 identical sections, each spanning 60 degrees. +var kAnglePerGearSection = 60; + +// Half-angle of the span of the outer rim. +var kOuterRimEndAngle = 12; + +// Angle between the middle of the outer rim and the start of the inner rim. +var kInnerRimBeginAngle = 20; + +// Distance from center to outer rim, normalized so that the entire model +// fits in a [-1, 1] x [-1, 1] square. +var kOuterRadius = 1; + +// Distance from center to depressed rim, in model units. +var kMiddleRadius = 0.75; + +// Radius of the inner hollow circle, in model units. +var kInnerRadius = 0.3125; + +// Center line thickness in DP. +var kCenterLineThicknessDp = 4; + +// Button width in DP. +var kButtonWidthDp = 28; + +// Factor to scale the touch area that responds to the touch. +var kTouchSlopFactor = 1.5; + +var Angles = [ + 0, kOuterRimEndAngle, kInnerRimBeginAngle, + kAnglePerGearSection - kInnerRimBeginAngle, + kAnglePerGearSection - kOuterRimEndAngle +]; + +/** + * Renders the alignment line and "options" gear. It is assumed that the canvas + * this is rendered into covers the entire screen (or close to it.) + */ +function CardboardUI(gl) { + this.gl = gl; + + this.attribs = { + position: 0 + }; + this.program = Util.linkProgram(gl, uiVS, uiFS, this.attribs); + this.uniforms = Util.getProgramUniforms(gl, this.program); + + this.vertexBuffer = gl.createBuffer(); + this.gearOffset = 0; + this.gearVertexCount = 0; + this.arrowOffset = 0; + this.arrowVertexCount = 0; + + this.projMat = new Float32Array(16); + + this.listener = null; + + this.onResize(); +}; + +/** + * Tears down all the resources created by the UI renderer. + */ +CardboardUI.prototype.destroy = function() { + var gl = this.gl; + + if (this.listener) { + gl.canvas.removeEventListener('click', this.listener, false); + } + + gl.deleteProgram(this.program); + gl.deleteBuffer(this.vertexBuffer); +}; + +/** + * Adds a listener to clicks on the gear and back icons + */ +CardboardUI.prototype.listen = function(optionsCallback, backCallback) { + var canvas = this.gl.canvas; + this.listener = function(event) { + var midline = canvas.clientWidth / 2; + var buttonSize = kButtonWidthDp * kTouchSlopFactor; + // Check to see if the user clicked on (or around) the gear icon + if (event.clientX > midline - buttonSize && + event.clientX < midline + buttonSize && + event.clientY > canvas.clientHeight - buttonSize) { + optionsCallback(event); + } + // Check to see if the user clicked on (or around) the back icon + else if (event.clientX < buttonSize && event.clientY < buttonSize) { + backCallback(event); + } + }; + canvas.addEventListener('click', this.listener, false); +}; + +/** + * Builds the UI mesh. + */ +CardboardUI.prototype.onResize = function() { + var gl = this.gl; + var self = this; + + var glState = [ + gl.ARRAY_BUFFER_BINDING + ]; + + WGLUPreserveGLState(gl, glState, function(gl) { + var vertices = []; + + var midline = gl.drawingBufferWidth / 2; + + // The gl buffer size will likely be smaller than the physical pixel count. + // So we need to scale the dps down based on the actual buffer size vs physical pixel count. + // This will properly size the ui elements no matter what the gl buffer resolution is + var physicalPixels = Math.max(screen.width, screen.height) * window.devicePixelRatio; + var scalingRatio = gl.drawingBufferWidth / physicalPixels; + var dps = scalingRatio * window.devicePixelRatio; + + var lineWidth = kCenterLineThicknessDp * dps / 2; + var buttonSize = kButtonWidthDp * kTouchSlopFactor * dps; + var buttonScale = kButtonWidthDp * dps / 2; + var buttonBorder = ((kButtonWidthDp * kTouchSlopFactor) - kButtonWidthDp) * dps; + + // Build centerline + vertices.push(midline - lineWidth, buttonSize); + vertices.push(midline - lineWidth, gl.drawingBufferHeight); + vertices.push(midline + lineWidth, buttonSize); + vertices.push(midline + lineWidth, gl.drawingBufferHeight); + + // Build gear + self.gearOffset = (vertices.length / 2); + + function addGearSegment(theta, r) { + var angle = (90 - theta) * DEG2RAD; + var x = Math.cos(angle); + var y = Math.sin(angle); + vertices.push(kInnerRadius * x * buttonScale + midline, kInnerRadius * y * buttonScale + buttonScale); + vertices.push(r * x * buttonScale + midline, r * y * buttonScale + buttonScale); + } + + for (var i = 0; i <= 6; i++) { + var segmentTheta = i * kAnglePerGearSection; + + addGearSegment(segmentTheta, kOuterRadius); + addGearSegment(segmentTheta + kOuterRimEndAngle, kOuterRadius); + addGearSegment(segmentTheta + kInnerRimBeginAngle, kMiddleRadius); + addGearSegment(segmentTheta + (kAnglePerGearSection - kInnerRimBeginAngle), kMiddleRadius); + addGearSegment(segmentTheta + (kAnglePerGearSection - kOuterRimEndAngle), kOuterRadius); + } + + self.gearVertexCount = (vertices.length / 2) - self.gearOffset; + + // Build back arrow + self.arrowOffset = (vertices.length / 2); + + function addArrowVertex(x, y) { + vertices.push(buttonBorder + x, gl.drawingBufferHeight - buttonBorder - y); + } + + var angledLineWidth = lineWidth / Math.sin(45 * DEG2RAD); + + addArrowVertex(0, buttonScale); + addArrowVertex(buttonScale, 0); + addArrowVertex(buttonScale + angledLineWidth, angledLineWidth); + addArrowVertex(angledLineWidth, buttonScale + angledLineWidth); + + addArrowVertex(angledLineWidth, buttonScale - angledLineWidth); + addArrowVertex(0, buttonScale); + addArrowVertex(buttonScale, buttonScale * 2); + addArrowVertex(buttonScale + angledLineWidth, (buttonScale * 2) - angledLineWidth); + + addArrowVertex(angledLineWidth, buttonScale - angledLineWidth); + addArrowVertex(0, buttonScale); + + addArrowVertex(angledLineWidth, buttonScale - lineWidth); + addArrowVertex(kButtonWidthDp * dps, buttonScale - lineWidth); + addArrowVertex(angledLineWidth, buttonScale + lineWidth); + addArrowVertex(kButtonWidthDp * dps, buttonScale + lineWidth); + + self.arrowVertexCount = (vertices.length / 2) - self.arrowOffset; + + // Buffer data + gl.bindBuffer(gl.ARRAY_BUFFER, self.vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + }); +}; + +/** + * Performs distortion pass on the injected backbuffer, rendering it to the real + * backbuffer. + */ +CardboardUI.prototype.render = function() { + var gl = this.gl; + var self = this; + + var glState = [ + gl.CULL_FACE, + gl.DEPTH_TEST, + gl.BLEND, + gl.SCISSOR_TEST, + gl.STENCIL_TEST, + gl.COLOR_WRITEMASK, + gl.VIEWPORT, + + gl.CURRENT_PROGRAM, + gl.ARRAY_BUFFER_BINDING + ]; + + WGLUPreserveGLState(gl, glState, function(gl) { + // Make sure the GL state is in a good place + gl.disable(gl.CULL_FACE); + gl.disable(gl.DEPTH_TEST); + gl.disable(gl.BLEND); + gl.disable(gl.SCISSOR_TEST); + gl.disable(gl.STENCIL_TEST); + gl.colorMask(true, true, true, true); + gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); + + self.renderNoState(); + }); +}; + +CardboardUI.prototype.renderNoState = function() { + var gl = this.gl; + + // Bind distortion program and mesh + gl.useProgram(this.program); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); + gl.enableVertexAttribArray(this.attribs.position); + gl.vertexAttribPointer(this.attribs.position, 2, gl.FLOAT, false, 8, 0); + + gl.uniform4f(this.uniforms.color, 1.0, 1.0, 1.0, 1.0); + + Util.orthoMatrix(this.projMat, 0, gl.drawingBufferWidth, 0, gl.drawingBufferHeight, 0.1, 1024.0); + gl.uniformMatrix4fv(this.uniforms.projectionMat, false, this.projMat); + + // Draws UI element + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + gl.drawArrays(gl.TRIANGLE_STRIP, this.gearOffset, this.gearVertexCount); + gl.drawArrays(gl.TRIANGLE_STRIP, this.arrowOffset, this.arrowVertexCount); +}; + +module.exports = CardboardUI; + +},{"./deps/wglu-preserve-state.js":7,"./util.js":22}],6:[function(_dereq_,module,exports){ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * 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. + */ + +var CardboardDistorter = _dereq_('./cardboard-distorter.js'); +var CardboardUI = _dereq_('./cardboard-ui.js'); +var DeviceInfo = _dereq_('./device-info.js'); +var Dpdb = _dereq_('./dpdb/dpdb.js'); +var FusionPoseSensor = _dereq_('./sensor-fusion/fusion-pose-sensor.js'); +var RotateInstructions = _dereq_('./rotate-instructions.js'); +var ViewerSelector = _dereq_('./viewer-selector.js'); +var VRDisplay = _dereq_('./base.js').VRDisplay; +var Util = _dereq_('./util.js'); + +var Eye = { + LEFT: 'left', + RIGHT: 'right' +}; + +/** + * VRDisplay based on mobile device parameters and DeviceMotion APIs. + */ +function CardboardVRDisplay() { + this.displayName = 'Cardboard VRDisplay (webvr-polyfill)'; + + this.capabilities.hasOrientation = true; + this.capabilities.canPresent = true; + + // "Private" members. + this.bufferScale_ = window.WebVRConfig.BUFFER_SCALE; + this.poseSensor_ = new FusionPoseSensor(); + this.distorter_ = null; + this.cardboardUI_ = null; + + this.dpdb_ = new Dpdb(true, this.onDeviceParamsUpdated_.bind(this)); + this.deviceInfo_ = new DeviceInfo(this.dpdb_.getDeviceParams()); + + this.viewerSelector_ = new ViewerSelector(); + this.viewerSelector_.on('change', this.onViewerChanged_.bind(this)); + + // Set the correct initial viewer. + this.deviceInfo_.setViewer(this.viewerSelector_.getCurrentViewer()); + + if (!window.WebVRConfig.ROTATE_INSTRUCTIONS_DISABLED) { + this.rotateInstructions_ = new RotateInstructions(); + } + + if (Util.isIOS()) { + // Listen for resize events to workaround this awful Safari bug. + window.addEventListener('resize', this.onResize_.bind(this)); + } +} +CardboardVRDisplay.prototype = new VRDisplay(); + +CardboardVRDisplay.prototype.getImmediatePose = function() { + return { + position: this.poseSensor_.getPosition(), + orientation: this.poseSensor_.getOrientation(), + linearVelocity: null, + linearAcceleration: null, + angularVelocity: null, + angularAcceleration: null + }; +}; + +CardboardVRDisplay.prototype.resetPose = function() { + this.poseSensor_.resetPose(); +}; + +CardboardVRDisplay.prototype.getEyeParameters = function(whichEye) { + var offset = [this.deviceInfo_.viewer.interLensDistance * 0.5, 0.0, 0.0]; + var fieldOfView; + + // TODO: FoV can be a little expensive to compute. Cache when device params change. + if (whichEye == Eye.LEFT) { + offset[0] *= -1.0; + fieldOfView = this.deviceInfo_.getFieldOfViewLeftEye(); + } else if (whichEye == Eye.RIGHT) { + fieldOfView = this.deviceInfo_.getFieldOfViewRightEye(); + } else { + console.error('Invalid eye provided: %s', whichEye); + return null; + } + + return { + fieldOfView: fieldOfView, + offset: offset, + // TODO: Should be able to provide better values than these. + renderWidth: this.deviceInfo_.device.width * 0.5 * this.bufferScale_, + renderHeight: this.deviceInfo_.device.height * this.bufferScale_, + }; +}; + +CardboardVRDisplay.prototype.onDeviceParamsUpdated_ = function(newParams) { + if (Util.isDebug()) { + console.log('DPDB reported that device params were updated.'); + } + this.deviceInfo_.updateDeviceParams(newParams); + + if (this.distorter_) { + this.distorter_.updateDeviceInfo(this.deviceInfo_); + } +}; + +CardboardVRDisplay.prototype.updateBounds_ = function () { + if (this.layer_ && this.distorter_ && (this.layer_.leftBounds || this.layer_.rightBounds)) { + this.distorter_.setTextureBounds(this.layer_.leftBounds, this.layer_.rightBounds); + } +}; + +CardboardVRDisplay.prototype.beginPresent_ = function() { + var gl = this.layer_.source.getContext('webgl'); + if (!gl) + gl = this.layer_.source.getContext('experimental-webgl'); + if (!gl) + gl = this.layer_.source.getContext('webgl2'); + + if (!gl) + return; // Can't do distortion without a WebGL context. + + // Provides a way to opt out of distortion + if (this.layer_.predistorted) { + if (!window.WebVRConfig.CARDBOARD_UI_DISABLED) { + gl.canvas.width = Util.getScreenWidth() * this.bufferScale_; + gl.canvas.height = Util.getScreenHeight() * this.bufferScale_; + this.cardboardUI_ = new CardboardUI(gl); + } + } else { + // Create a new distorter for the target context + this.distorter_ = new CardboardDistorter(gl); + this.distorter_.updateDeviceInfo(this.deviceInfo_); + this.cardboardUI_ = this.distorter_.cardboardUI; + } + + if (this.cardboardUI_) { + this.cardboardUI_.listen(function(e) { + // Options clicked. + this.viewerSelector_.show(this.layer_.source.parentElement); + e.stopPropagation(); + e.preventDefault(); + }.bind(this), function(e) { + // Back clicked. + this.exitPresent(); + e.stopPropagation(); + e.preventDefault(); + }.bind(this)); + } + + if (this.rotateInstructions_) { + if (Util.isLandscapeMode() && Util.isMobile()) { + // In landscape mode, temporarily show the "put into Cardboard" + // interstitial. Otherwise, do the default thing. + this.rotateInstructions_.showTemporarily(3000, this.layer_.source.parentElement); + } else { + this.rotateInstructions_.update(); + } + } + + // Listen for orientation change events in order to show interstitial. + this.orientationHandler = this.onOrientationChange_.bind(this); + window.addEventListener('orientationchange', this.orientationHandler); + + // Listen for present display change events in order to update distorter dimensions + this.vrdisplaypresentchangeHandler = this.updateBounds_.bind(this); + window.addEventListener('vrdisplaypresentchange', this.vrdisplaypresentchangeHandler); + + // Fire this event initially, to give geometry-distortion clients the chance + // to do something custom. + 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.submitFrame = function(pose) { + if (this.distorter_) { + this.updateBounds_(); + this.distorter_.submitFrame(); + } else if (this.cardboardUI_ && this.layer_) { + // Hack for predistorted: true. + 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; + + // Render the Cardboard UI. + this.cardboardUI_.render(); + } +}; + +CardboardVRDisplay.prototype.onOrientationChange_ = function(e) { + // Hide the viewer selector. + this.viewerSelector_.hide(); + + // Update the rotate instructions. + if (this.rotateInstructions_) { + this.rotateInstructions_.update(); + } + + this.onResize_(); +}; + +CardboardVRDisplay.prototype.onResize_ = function(e) { + if (this.layer_) { + var gl = this.layer_.source.getContext('webgl'); + // Size the CSS canvas. + // Added padding on right and bottom because iPhone 5 will not + // hide the URL bar unless content is bigger than the screen. + // This will not be visible as long as the container element (e.g. body) + // is set to 'overflow: hidden'. + // Additionally, 'box-sizing: content-box' ensures renderWidth = width + padding. + // This is required when 'box-sizing: border-box' is used elsewhere in the page. + var cssProperties = [ + 'position: absolute', + 'top: 0', + 'left: 0', + 'width: ' + Math.max(screen.width, screen.height) + 'px', + 'height: ' + Math.min(screen.height, screen.width) + 'px', + 'border: 0', + 'margin: 0', + 'padding: 0 10px 10px 0', + 'box-sizing: content-box', + ]; + gl.canvas.setAttribute('style', cssProperties.join('; ') + ';'); + + Util.safariCssSizeWorkaround(gl.canvas); + } +}; + +CardboardVRDisplay.prototype.onViewerChanged_ = function(viewer) { + this.deviceInfo_.setViewer(viewer); + + if (this.distorter_) { + // Update the distortion appropriately. + this.distorter_.updateDeviceInfo(this.deviceInfo_); + } + + // Fire a new event containing viewer and device parameters for clients that + // want to implement their own geometry-based distortion. + this.fireVRDisplayDeviceParamsChange_(); +}; + +CardboardVRDisplay.prototype.fireVRDisplayDeviceParamsChange_ = function() { + var event = new CustomEvent('vrdisplaydeviceparamschange', { + detail: { + vrdisplay: this, + deviceInfo: this.deviceInfo_, + } + }); + window.dispatchEvent(event); +}; + +module.exports = CardboardVRDisplay; + +},{"./base.js":3,"./cardboard-distorter.js":4,"./cardboard-ui.js":5,"./device-info.js":8,"./dpdb/dpdb.js":12,"./rotate-instructions.js":16,"./sensor-fusion/fusion-pose-sensor.js":18,"./util.js":22,"./viewer-selector.js":23}],7:[function(_dereq_,module,exports){ +/* +Copyright (c) 2016, Brandon Jones. + +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. +*/ + +/* +Caches specified GL state, runs a callback, and restores the cached state when +done. + +Example usage: + +var savedState = [ + gl.ARRAY_BUFFER_BINDING, + + // TEXTURE_BINDING_2D or _CUBE_MAP must always be followed by the texure unit. + gl.TEXTURE_BINDING_2D, gl.TEXTURE0, + + gl.CLEAR_COLOR, +]; +// After this call the array buffer, texture unit 0, active texture, and clear +// color will be restored. The viewport will remain changed, however, because +// gl.VIEWPORT was not included in the savedState list. +WGLUPreserveGLState(gl, savedState, function(gl) { + gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); + + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, ....); + + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.texImage2D(gl.TEXTURE_2D, ...); + + gl.clearColor(1, 0, 0, 1); + gl.clear(gl.COLOR_BUFFER_BIT); +}); + +Note that this is not intended to be fast. Managing state in your own code to +avoid redundant state setting and querying will always be faster. This function +is most useful for cases where you may not have full control over the WebGL +calls being made, such as tooling or effect injectors. +*/ + +function WGLUPreserveGLState(gl, bindings, callback) { + if (!bindings) { + callback(gl); + return; + } + + var boundValues = []; + + var activeTexture = null; + for (var i = 0; i < bindings.length; ++i) { + var binding = bindings[i]; + switch (binding) { + case gl.TEXTURE_BINDING_2D: + case gl.TEXTURE_BINDING_CUBE_MAP: + var textureUnit = bindings[++i]; + if (textureUnit < gl.TEXTURE0 || textureUnit > gl.TEXTURE31) { + console.error("TEXTURE_BINDING_2D or TEXTURE_BINDING_CUBE_MAP must be followed by a valid texture unit"); + boundValues.push(null, null); + break; + } + if (!activeTexture) { + activeTexture = gl.getParameter(gl.ACTIVE_TEXTURE); + } + gl.activeTexture(textureUnit); + boundValues.push(gl.getParameter(binding), null); + break; + case gl.ACTIVE_TEXTURE: + activeTexture = gl.getParameter(gl.ACTIVE_TEXTURE); + boundValues.push(null); + break; + default: + boundValues.push(gl.getParameter(binding)); + break; + } + } + + callback(gl); + + for (var i = 0; i < bindings.length; ++i) { + var binding = bindings[i]; + var boundValue = boundValues[i]; + switch (binding) { + case gl.ACTIVE_TEXTURE: + break; // Ignore this binding, since we special-case it to happen last. + case gl.ARRAY_BUFFER_BINDING: + gl.bindBuffer(gl.ARRAY_BUFFER, boundValue); + break; + case gl.COLOR_CLEAR_VALUE: + gl.clearColor(boundValue[0], boundValue[1], boundValue[2], boundValue[3]); + break; + case gl.COLOR_WRITEMASK: + gl.colorMask(boundValue[0], boundValue[1], boundValue[2], boundValue[3]); + break; + case gl.CURRENT_PROGRAM: + gl.useProgram(boundValue); + break; + case gl.ELEMENT_ARRAY_BUFFER_BINDING: + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, boundValue); + break; + case gl.FRAMEBUFFER_BINDING: + gl.bindFramebuffer(gl.FRAMEBUFFER, boundValue); + break; + case gl.RENDERBUFFER_BINDING: + gl.bindRenderbuffer(gl.RENDERBUFFER, boundValue); + break; + case gl.TEXTURE_BINDING_2D: + var textureUnit = bindings[++i]; + if (textureUnit < gl.TEXTURE0 || textureUnit > gl.TEXTURE31) + break; + gl.activeTexture(textureUnit); + gl.bindTexture(gl.TEXTURE_2D, boundValue); + break; + case gl.TEXTURE_BINDING_CUBE_MAP: + var textureUnit = bindings[++i]; + if (textureUnit < gl.TEXTURE0 || textureUnit > gl.TEXTURE31) + break; + gl.activeTexture(textureUnit); + gl.bindTexture(gl.TEXTURE_CUBE_MAP, boundValue); + break; + case gl.VIEWPORT: + gl.viewport(boundValue[0], boundValue[1], boundValue[2], boundValue[3]); + break; + case gl.BLEND: + case gl.CULL_FACE: + case gl.DEPTH_TEST: + case gl.SCISSOR_TEST: + case gl.STENCIL_TEST: + if (boundValue) { + gl.enable(binding); + } else { + gl.disable(binding); + } + break; + default: + console.log("No GL restore behavior for 0x" + binding.toString(16)); + break; + } + + if (activeTexture) { + gl.activeTexture(activeTexture); + } + } +} + +module.exports = WGLUPreserveGLState; +},{}],8:[function(_dereq_,module,exports){ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * 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. + */ + +var Distortion = _dereq_('./distortion/distortion.js'); +var MathUtil = _dereq_('./math-util.js'); +var Util = _dereq_('./util.js'); + +function Device(params) { + this.width = params.width || Util.getScreenWidth(); + this.height = params.height || Util.getScreenHeight(); + this.widthMeters = params.widthMeters; + this.heightMeters = params.heightMeters; + this.bevelMeters = params.bevelMeters; +} + + +// Fallback Android device (based on Nexus 5 measurements) for use when +// we can't recognize an Android device. +var DEFAULT_ANDROID = new Device({ + widthMeters: 0.110, + heightMeters: 0.062, + bevelMeters: 0.004 +}); + +// Fallback iOS device (based on iPhone6) for use when +// we can't recognize an Android device. +var DEFAULT_IOS = new Device({ + widthMeters: 0.1038, + heightMeters: 0.0584, + bevelMeters: 0.004 +}); + + +var Viewers = { + CardboardV1: new CardboardViewer({ + id: 'CardboardV1', + label: 'Cardboard I/O 2014', + fov: 40, + interLensDistance: 0.060, + baselineLensDistance: 0.035, + screenLensDistance: 0.042, + distortionCoefficients: [0.441, 0.156], + inverseCoefficients: [-0.4410035, 0.42756155, -0.4804439, 0.5460139, + -0.58821183, 0.5733938, -0.48303202, 0.33299083, -0.17573841, + 0.0651772, -0.01488963, 0.001559834] + }), + CardboardV2: new CardboardViewer({ + id: 'CardboardV2', + label: 'Cardboard I/O 2015', + fov: 60, + interLensDistance: 0.064, + baselineLensDistance: 0.035, + screenLensDistance: 0.039, + distortionCoefficients: [0.34, 0.55], + inverseCoefficients: [-0.33836704, -0.18162185, 0.862655, -1.2462051, + 1.0560602, -0.58208317, 0.21609078, -0.05444823, 0.009177956, + -9.904169E-4, 6.183535E-5, -1.6981803E-6] + }) +}; + + +var DEFAULT_LEFT_CENTER = {x: 0.5, y: 0.5}; +var DEFAULT_RIGHT_CENTER = {x: 0.5, y: 0.5}; + +/** + * Manages information about the device and the viewer. + * + * deviceParams indicates the parameters of the device to use (generally + * obtained from dpdb.getDeviceParams()). Can be null to mean no device + * params were found. + */ +function DeviceInfo(deviceParams) { + this.viewer = Viewers.CardboardV2; + this.updateDeviceParams(deviceParams); + this.distortion = new Distortion(this.viewer.distortionCoefficients); +} + +DeviceInfo.prototype.updateDeviceParams = function(deviceParams) { + this.device = this.determineDevice_(deviceParams) || this.device; +}; + +DeviceInfo.prototype.getDevice = function() { + return this.device; +}; + +DeviceInfo.prototype.setViewer = function(viewer) { + this.viewer = viewer; + this.distortion = new Distortion(this.viewer.distortionCoefficients); +}; + +DeviceInfo.prototype.determineDevice_ = function(deviceParams) { + if (!deviceParams) { + // No parameters, so use a default. + if (Util.isIOS()) { + console.warn('Using fallback iOS device measurements.'); + return DEFAULT_IOS; + } else { + console.warn('Using fallback Android device measurements.'); + return DEFAULT_ANDROID; + } + } + + // Compute device screen dimensions based on deviceParams. + var METERS_PER_INCH = 0.0254; + var metersPerPixelX = METERS_PER_INCH / deviceParams.xdpi; + var metersPerPixelY = METERS_PER_INCH / deviceParams.ydpi; + var width = Util.getScreenWidth(); + var height = Util.getScreenHeight(); + return new Device({ + widthMeters: metersPerPixelX * width, + heightMeters: metersPerPixelY * height, + bevelMeters: deviceParams.bevelMm * 0.001, + }); +}; + +/** + * Calculates field of view for the left eye. + */ +DeviceInfo.prototype.getDistortedFieldOfViewLeftEye = function() { + var viewer = this.viewer; + var device = this.device; + var distortion = this.distortion; + + // Device.height and device.width for device in portrait mode, so transpose. + var eyeToScreenDistance = viewer.screenLensDistance; + + var outerDist = (device.widthMeters - viewer.interLensDistance) / 2; + var innerDist = viewer.interLensDistance / 2; + var bottomDist = viewer.baselineLensDistance - device.bevelMeters; + var topDist = device.heightMeters - bottomDist; + + var outerAngle = MathUtil.radToDeg * Math.atan( + distortion.distort(outerDist / eyeToScreenDistance)); + var innerAngle = MathUtil.radToDeg * Math.atan( + distortion.distort(innerDist / eyeToScreenDistance)); + var bottomAngle = MathUtil.radToDeg * Math.atan( + distortion.distort(bottomDist / eyeToScreenDistance)); + var topAngle = MathUtil.radToDeg * Math.atan( + distortion.distort(topDist / eyeToScreenDistance)); + + return { + leftDegrees: Math.min(outerAngle, viewer.fov), + rightDegrees: Math.min(innerAngle, viewer.fov), + downDegrees: Math.min(bottomAngle, viewer.fov), + upDegrees: Math.min(topAngle, viewer.fov) + }; +}; + +/** + * Calculates the tan-angles from the maximum FOV for the left eye for the + * current device and screen parameters. + */ +DeviceInfo.prototype.getLeftEyeVisibleTanAngles = function() { + var viewer = this.viewer; + var device = this.device; + var distortion = this.distortion; + + // Tan-angles from the max FOV. + var fovLeft = Math.tan(-MathUtil.degToRad * viewer.fov); + var fovTop = Math.tan(MathUtil.degToRad * viewer.fov); + var fovRight = Math.tan(MathUtil.degToRad * viewer.fov); + var fovBottom = Math.tan(-MathUtil.degToRad * viewer.fov); + // Viewport size. + var halfWidth = device.widthMeters / 4; + var halfHeight = device.heightMeters / 2; + // Viewport center, measured from left lens position. + var verticalLensOffset = (viewer.baselineLensDistance - device.bevelMeters - halfHeight); + var centerX = viewer.interLensDistance / 2 - halfWidth; + var centerY = -verticalLensOffset; + var centerZ = viewer.screenLensDistance; + // Tan-angles of the viewport edges, as seen through the lens. + var screenLeft = distortion.distort((centerX - halfWidth) / centerZ); + var screenTop = distortion.distort((centerY + halfHeight) / centerZ); + var screenRight = distortion.distort((centerX + halfWidth) / centerZ); + var screenBottom = distortion.distort((centerY - halfHeight) / centerZ); + // Compare the two sets of tan-angles and take the value closer to zero on each side. + var result = new Float32Array(4); + result[0] = Math.max(fovLeft, screenLeft); + result[1] = Math.min(fovTop, screenTop); + result[2] = Math.min(fovRight, screenRight); + result[3] = Math.max(fovBottom, screenBottom); + return result; +}; + +/** + * Calculates the tan-angles from the maximum FOV for the left eye for the + * current device and screen parameters, assuming no lenses. + */ +DeviceInfo.prototype.getLeftEyeNoLensTanAngles = function() { + var viewer = this.viewer; + var device = this.device; + var distortion = this.distortion; + + var result = new Float32Array(4); + // Tan-angles from the max FOV. + var fovLeft = distortion.distortInverse(Math.tan(-MathUtil.degToRad * viewer.fov)); + var fovTop = distortion.distortInverse(Math.tan(MathUtil.degToRad * viewer.fov)); + var fovRight = distortion.distortInverse(Math.tan(MathUtil.degToRad * viewer.fov)); + var fovBottom = distortion.distortInverse(Math.tan(-MathUtil.degToRad * viewer.fov)); + // Viewport size. + var halfWidth = device.widthMeters / 4; + var halfHeight = device.heightMeters / 2; + // Viewport center, measured from left lens position. + var verticalLensOffset = (viewer.baselineLensDistance - device.bevelMeters - halfHeight); + var centerX = viewer.interLensDistance / 2 - halfWidth; + var centerY = -verticalLensOffset; + var centerZ = viewer.screenLensDistance; + // Tan-angles of the viewport edges, as seen through the lens. + var screenLeft = (centerX - halfWidth) / centerZ; + var screenTop = (centerY + halfHeight) / centerZ; + var screenRight = (centerX + halfWidth) / centerZ; + var screenBottom = (centerY - halfHeight) / centerZ; + // Compare the two sets of tan-angles and take the value closer to zero on each side. + result[0] = Math.max(fovLeft, screenLeft); + result[1] = Math.min(fovTop, screenTop); + result[2] = Math.min(fovRight, screenRight); + result[3] = Math.max(fovBottom, screenBottom); + return result; +}; + +/** + * Calculates the screen rectangle visible from the left eye for the + * current device and screen parameters. + */ +DeviceInfo.prototype.getLeftEyeVisibleScreenRect = function(undistortedFrustum) { + var viewer = this.viewer; + var device = this.device; + + var dist = viewer.screenLensDistance; + var eyeX = (device.widthMeters - viewer.interLensDistance) / 2; + var eyeY = viewer.baselineLensDistance - device.bevelMeters; + var left = (undistortedFrustum[0] * dist + eyeX) / device.widthMeters; + var top = (undistortedFrustum[1] * dist + eyeY) / device.heightMeters; + var right = (undistortedFrustum[2] * dist + eyeX) / device.widthMeters; + var bottom = (undistortedFrustum[3] * dist + eyeY) / device.heightMeters; + return { + x: left, + y: bottom, + width: right - left, + height: top - bottom + }; +}; + +DeviceInfo.prototype.getFieldOfViewLeftEye = function(opt_isUndistorted) { + return opt_isUndistorted ? this.getUndistortedFieldOfViewLeftEye() : + this.getDistortedFieldOfViewLeftEye(); +}; + +DeviceInfo.prototype.getFieldOfViewRightEye = function(opt_isUndistorted) { + var fov = this.getFieldOfViewLeftEye(opt_isUndistorted); + return { + leftDegrees: fov.rightDegrees, + rightDegrees: fov.leftDegrees, + upDegrees: fov.upDegrees, + downDegrees: fov.downDegrees + }; +}; + +/** + * Calculates undistorted field of view for the left eye. + */ +DeviceInfo.prototype.getUndistortedFieldOfViewLeftEye = function() { + var p = this.getUndistortedParams_(); + + return { + leftDegrees: MathUtil.radToDeg * Math.atan(p.outerDist), + rightDegrees: MathUtil.radToDeg * Math.atan(p.innerDist), + downDegrees: MathUtil.radToDeg * Math.atan(p.bottomDist), + upDegrees: MathUtil.radToDeg * Math.atan(p.topDist) + }; +}; + +DeviceInfo.prototype.getUndistortedViewportLeftEye = function() { + var p = this.getUndistortedParams_(); + var viewer = this.viewer; + var device = this.device; + + // Distances stored in local variables are in tan-angle units unless otherwise + // noted. + var eyeToScreenDistance = viewer.screenLensDistance; + var screenWidth = device.widthMeters / eyeToScreenDistance; + var screenHeight = device.heightMeters / eyeToScreenDistance; + var xPxPerTanAngle = device.width / screenWidth; + var yPxPerTanAngle = device.height / screenHeight; + + var x = Math.round((p.eyePosX - p.outerDist) * xPxPerTanAngle); + var y = Math.round((p.eyePosY - p.bottomDist) * yPxPerTanAngle); + return { + x: x, + y: y, + width: Math.round((p.eyePosX + p.innerDist) * xPxPerTanAngle) - x, + height: Math.round((p.eyePosY + p.topDist) * yPxPerTanAngle) - y + }; +}; + +DeviceInfo.prototype.getUndistortedParams_ = function() { + var viewer = this.viewer; + var device = this.device; + var distortion = this.distortion; + + // Most of these variables in tan-angle units. + var eyeToScreenDistance = viewer.screenLensDistance; + var halfLensDistance = viewer.interLensDistance / 2 / eyeToScreenDistance; + var screenWidth = device.widthMeters / eyeToScreenDistance; + var screenHeight = device.heightMeters / eyeToScreenDistance; + + var eyePosX = screenWidth / 2 - halfLensDistance; + var eyePosY = (viewer.baselineLensDistance - device.bevelMeters) / eyeToScreenDistance; + + var maxFov = viewer.fov; + var viewerMax = distortion.distortInverse(Math.tan(MathUtil.degToRad * maxFov)); + var outerDist = Math.min(eyePosX, viewerMax); + var innerDist = Math.min(halfLensDistance, viewerMax); + var bottomDist = Math.min(eyePosY, viewerMax); + var topDist = Math.min(screenHeight - eyePosY, viewerMax); + + return { + outerDist: outerDist, + innerDist: innerDist, + topDist: topDist, + bottomDist: bottomDist, + eyePosX: eyePosX, + eyePosY: eyePosY + }; +}; + + +function CardboardViewer(params) { + // A machine readable ID. + this.id = params.id; + // A human readable label. + this.label = params.label; + + // Field of view in degrees (per side). + this.fov = params.fov; + + // Distance between lens centers in meters. + this.interLensDistance = params.interLensDistance; + // Distance between viewer baseline and lens center in meters. + this.baselineLensDistance = params.baselineLensDistance; + // Screen-to-lens distance in meters. + this.screenLensDistance = params.screenLensDistance; + + // Distortion coefficients. + this.distortionCoefficients = params.distortionCoefficients; + // Inverse distortion coefficients. + // TODO: Calculate these from distortionCoefficients in the future. + this.inverseCoefficients = params.inverseCoefficients; +} + +// Export viewer information. +DeviceInfo.Viewers = Viewers; +module.exports = DeviceInfo; + +},{"./distortion/distortion.js":10,"./math-util.js":14,"./util.js":22}],9:[function(_dereq_,module,exports){ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * 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. + */ +var VRDisplay = _dereq_('./base.js').VRDisplay; +var HMDVRDevice = _dereq_('./base.js').HMDVRDevice; +var PositionSensorVRDevice = _dereq_('./base.js').PositionSensorVRDevice; + +/** + * Wraps a VRDisplay and exposes it as a HMDVRDevice + */ +function VRDisplayHMDDevice(display) { + this.display = display; + + this.hardwareUnitId = display.displayId; + this.deviceId = 'webvr-polyfill:HMD:' + display.displayId; + this.deviceName = display.displayName + ' (HMD)'; +} +VRDisplayHMDDevice.prototype = new HMDVRDevice(); + +VRDisplayHMDDevice.prototype.getEyeParameters = function(whichEye) { + var eyeParameters = this.display.getEyeParameters(whichEye); + + return { + currentFieldOfView: eyeParameters.fieldOfView, + maximumFieldOfView: eyeParameters.fieldOfView, + minimumFieldOfView: eyeParameters.fieldOfView, + recommendedFieldOfView: eyeParameters.fieldOfView, + eyeTranslation: { x: eyeParameters.offset[0], y: eyeParameters.offset[1], z: eyeParameters.offset[2] }, + renderRect: { + x: (whichEye == 'right') ? eyeParameters.renderWidth : 0, + y: 0, + width: eyeParameters.renderWidth, + height: eyeParameters.renderHeight + } + }; +}; + +VRDisplayHMDDevice.prototype.setFieldOfView = + function(opt_fovLeft, opt_fovRight, opt_zNear, opt_zFar) { + // Not supported. getEyeParameters reports that the min, max, and recommended + // FoV is all the same, so no adjustment can be made. +}; + +// TODO: Need to hook requestFullscreen to see if a wrapped VRDisplay was passed +// in as an option. If so we should prevent the default fullscreen behavior and +// call VRDisplay.requestPresent instead. + +/** + * Wraps a VRDisplay and exposes it as a PositionSensorVRDevice + */ +function VRDisplayPositionSensorDevice(display) { + this.display = display; + + this.hardwareUnitId = display.displayId; + this.deviceId = 'webvr-polyfill:PositionSensor: ' + display.displayId; + this.deviceName = display.displayName + ' (PositionSensor)'; +} +VRDisplayPositionSensorDevice.prototype = new PositionSensorVRDevice(); + +VRDisplayPositionSensorDevice.prototype.getState = function() { + var pose = this.display.getPose(); + return { + position: pose.position ? { x: pose.position[0], y: pose.position[1], z: pose.position[2] } : null, + orientation: pose.orientation ? { x: pose.orientation[0], y: pose.orientation[1], z: pose.orientation[2], w: pose.orientation[3] } : null, + linearVelocity: null, + linearAcceleration: null, + angularVelocity: null, + angularAcceleration: null + }; +}; + +VRDisplayPositionSensorDevice.prototype.resetState = function() { + return this.positionDevice.resetPose(); +}; + + +module.exports.VRDisplayHMDDevice = VRDisplayHMDDevice; +module.exports.VRDisplayPositionSensorDevice = VRDisplayPositionSensorDevice; + + +},{"./base.js":3}],10:[function(_dereq_,module,exports){ +/** + * TODO(smus): Implement coefficient inversion. + */ +function Distortion(coefficients) { + this.coefficients = coefficients; +} + +/** + * Calculates the inverse distortion for a radius. + *

+ * Allows to compute the original undistorted radius from a distorted one. + * See also getApproximateInverseDistortion() for a faster but potentially + * less accurate method. + * + * @param {Number} radius Distorted radius from the lens center in tan-angle units. + * @return {Number} The undistorted radius in tan-angle units. + */ +Distortion.prototype.distortInverse = function(radius) { + // Secant method. + var r0 = 0; + var r1 = 1; + var dr0 = radius - this.distort(r0); + while (Math.abs(r1 - r0) > 0.0001 /** 0.1mm */) { + var dr1 = radius - this.distort(r1); + var r2 = r1 - dr1 * ((r1 - r0) / (dr1 - dr0)); + r0 = r1; + r1 = r2; + dr0 = dr1; + } + return r1; +}; + +/** + * Distorts a radius by its distortion factor from the center of the lenses. + * + * @param {Number} radius Radius from the lens center in tan-angle units. + * @return {Number} The distorted radius in tan-angle units. + */ +Distortion.prototype.distort = function(radius) { + var r2 = radius * radius; + var ret = 0; + for (var i = 0; i < this.coefficients.length; i++) { + ret = r2 * (ret + this.coefficients[i]); + } + return (ret + 1) * radius; +}; + +// Functions below roughly ported from +// https://github.com/googlesamples/cardboard-unity/blob/master/Cardboard/Scripts/CardboardProfile.cs#L412 + +// Solves a small linear equation via destructive gaussian +// elimination and back substitution. This isn't generic numeric +// code, it's just a quick hack to work with the generally +// well-behaved symmetric matrices for least-squares fitting. +// Not intended for reuse. +// +// @param a Input positive definite symmetrical matrix. Destroyed +// during calculation. +// @param y Input right-hand-side values. Destroyed during calculation. +// @return Resulting x value vector. +// +Distortion.prototype.solveLinear_ = function(a, y) { + var n = a.length; + + // Gaussian elimination (no row exchange) to triangular matrix. + // The input matrix is a A^T A product which should be a positive + // definite symmetrical matrix, and if I remember my linear + // algebra right this implies that the pivots will be nonzero and + // calculations sufficiently accurate without needing row + // exchange. + for (var j = 0; j < n - 1; ++j) { + for (var k = j + 1; k < n; ++k) { + var p = a[j][k] / a[j][j]; + for (var i = j + 1; i < n; ++i) { + a[i][k] -= p * a[i][j]; + } + y[k] -= p * y[j]; + } + } + // From this point on, only the matrix elements a[j][i] with i>=j are + // valid. The elimination doesn't fill in eliminated 0 values. + + var x = new Array(n); + + // Back substitution. + for (var j = n - 1; j >= 0; --j) { + var v = y[j]; + for (var i = j + 1; i < n; ++i) { + v -= a[i][j] * x[i]; + } + x[j] = v / a[j][j]; + } + + return x; +}; + +// Solves a least-squares matrix equation. Given the equation A * x = y, calculate the +// least-square fit x = inverse(A * transpose(A)) * transpose(A) * y. The way this works +// is that, while A is typically not a square matrix (and hence not invertible), A * transpose(A) +// is always square. That is: +// A * x = y +// transpose(A) * (A * x) = transpose(A) * y <- multiply both sides by transpose(A) +// (transpose(A) * A) * x = transpose(A) * y <- associativity +// x = inverse(transpose(A) * A) * transpose(A) * y <- solve for x +// Matrix A's row count (first index) must match y's value count. A's column count (second index) +// determines the length of the result vector x. +Distortion.prototype.solveLeastSquares_ = function(matA, vecY) { + var i, j, k, sum; + var numSamples = matA.length; + var numCoefficients = matA[0].length; + if (numSamples != vecY.Length) { + throw new Error("Matrix / vector dimension mismatch"); + } + + // Calculate transpose(A) * A + var matATA = new Array(numCoefficients); + for (k = 0; k < numCoefficients; ++k) { + matATA[k] = new Array(numCoefficients); + for (j = 0; j < numCoefficients; ++j) { + sum = 0; + for (i = 0; i < numSamples; ++i) { + sum += matA[j][i] * matA[k][i]; + } + matATA[k][j] = sum; + } + } + + // Calculate transpose(A) * y + var vecATY = new Array(numCoefficients); + for (j = 0; j < numCoefficients; ++j) { + sum = 0; + for (i = 0; i < numSamples; ++i) { + sum += matA[j][i] * vecY[i]; + } + vecATY[j] = sum; + } + + // Now solve (A * transpose(A)) * x = transpose(A) * y. + return this.solveLinear_(matATA, vecATY); +}; + +/// Calculates an approximate inverse to the given radial distortion parameters. +Distortion.prototype.approximateInverse = function(maxRadius, numSamples) { + maxRadius = maxRadius || 1; + numSamples = numSamples || 100; + var numCoefficients = 6; + var i, j; + + // R + K1*R^3 + K2*R^5 = r, with R = rp = distort(r) + // Repeating for numSamples: + // [ R0^3, R0^5 ] * [ K1 ] = [ r0 - R0 ] + // [ R1^3, R1^5 ] [ K2 ] [ r1 - R1 ] + // [ R2^3, R2^5 ] [ r2 - R2 ] + // [ etc... ] [ etc... ] + // That is: + // matA * [K1, K2] = y + // Solve: + // [K1, K2] = inverse(transpose(matA) * matA) * transpose(matA) * y + var matA = new Array(numCoefficients); + for (j = 0; j < numCoefficients; ++j) { + matA[j] = new Array(numSamples); + } + var vecY = new Array(numSamples); + + for (i = 0; i < numSamples; ++i) { + var r = maxRadius * (i + 1) / numSamples; + var rp = this.distort(r); + var v = rp; + for (j = 0; j < numCoefficients; ++j) { + v *= rp * rp; + matA[j][i] = v; + } + vecY[i] = r - rp; + } + + var inverseCoefficients = this.solveLeastSquares_(matA, vecY); + + return new Distortion(inverseCoefficients); +}; + +module.exports = Distortion; + +},{}],11:[function(_dereq_,module,exports){ +module.exports={ + "format":1, + "last_updated":"2017-01-12T08:41:55Z", + "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":"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/*/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.0, + "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":"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/*/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-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":"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":"ZTE/*/ZTE Blade L2/*" + }, + { + "ua":"ZTE Blade L2" + } + ], + "dpi":240, + "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 + } + ] +} + +},{}],12:[function(_dereq_,module,exports){ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * 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. + */ + +// Offline cache of the DPDB, to be used until we load the online one (and +// as a fallback in case we can't load the online one). +var DPDB_CACHE = _dereq_('./dpdb.json'); +var Util = _dereq_('../util.js'); + +// Online DPDB URL. +var ONLINE_DPDB_URL = + 'https://dpdb.webvr.rocks/dpdb.json'; + +/** + * Calculates device parameters based on the DPDB (Device Parameter Database). + * Initially, uses the cached DPDB values. + * + * If fetchOnline == true, then this object tries to fetch the online version + * of the DPDB and updates the device info if a better match is found. + * Calls the onDeviceParamsUpdated callback when there is an update to the + * device information. + */ +function Dpdb(fetchOnline, onDeviceParamsUpdated) { + // Start with the offline DPDB cache while we are loading the real one. + this.dpdb = DPDB_CACHE; + + // Calculate device params based on the offline version of the DPDB. + this.recalculateDeviceParams_(); + + // XHR to fetch online DPDB file, if requested. + if (fetchOnline) { + // Set the callback. + this.onDeviceParamsUpdated = onDeviceParamsUpdated; + + var xhr = new XMLHttpRequest(); + var obj = this; + xhr.open('GET', ONLINE_DPDB_URL, true); + xhr.addEventListener('load', function() { + obj.loading = false; + if (xhr.status >= 200 && xhr.status <= 299) { + // Success. + obj.dpdb = JSON.parse(xhr.response); + obj.recalculateDeviceParams_(); + } else { + // Error loading the DPDB. + console.error('Error loading online DPDB!'); + } + }); + xhr.send(); + } +} + +// Returns the current device parameters. +Dpdb.prototype.getDeviceParams = function() { + return this.deviceParams; +}; + +// Recalculates this device's parameters based on the DPDB. +Dpdb.prototype.recalculateDeviceParams_ = function() { + var newDeviceParams = this.calcDeviceParams_(); + if (newDeviceParams) { + this.deviceParams = newDeviceParams; + // Invoke callback, if it is set. + if (this.onDeviceParamsUpdated) { + this.onDeviceParamsUpdated(this.deviceParams); + } + } else { + console.error('Failed to recalculate device parameters.'); + } +}; + +// Returns a DeviceParams object that represents the best guess as to this +// device's parameters. Can return null if the device does not match any +// known devices. +Dpdb.prototype.calcDeviceParams_ = function() { + var db = this.dpdb; // shorthand + if (!db) { + console.error('DPDB not available.'); + return null; + } + if (db.format != 1) { + console.error('DPDB has unexpected format version.'); + return null; + } + if (!db.devices || !db.devices.length) { + console.error('DPDB does not have a devices section.'); + return null; + } + + // Get the actual user agent and screen dimensions in pixels. + var userAgent = navigator.userAgent || navigator.vendor || window.opera; + var width = Util.getScreenWidth(); + var height = Util.getScreenHeight(); + + if (!db.devices) { + console.error('DPDB has no devices section.'); + return null; + } + + for (var i = 0; i < db.devices.length; i++) { + var device = db.devices[i]; + if (!device.rules) { + console.warn('Device[' + i + '] has no rules section.'); + continue; + } + + if (device.type != 'ios' && device.type != 'android') { + console.warn('Device[' + i + '] has invalid type.'); + continue; + } + + // See if this device is of the appropriate type. + if (Util.isIOS() != (device.type == 'ios')) continue; + + // See if this device matches any of the rules: + var matched = false; + for (var j = 0; j < device.rules.length; j++) { + var rule = device.rules[j]; + if (this.matchRule_(rule, userAgent, width, height)) { + matched = true; + break; + } + } + if (!matched) continue; + + // device.dpi might be an array of [ xdpi, ydpi] or just a scalar. + var xdpi = device.dpi[0] || device.dpi; + var ydpi = device.dpi[1] || device.dpi; + + return new DeviceParams({ xdpi: xdpi, ydpi: ydpi, bevelMm: device.bw }); + } + + console.warn('No DPDB device match.'); + return null; +}; + +Dpdb.prototype.matchRule_ = function(rule, ua, screenWidth, screenHeight) { + // We can only match 'ua' and 'res' rules, not other types like 'mdmh' + // (which are meant for native platforms). + if (!rule.ua && !rule.res) return false; + + // If our user agent string doesn't contain the indicated user agent string, + // the match fails. + if (rule.ua && ua.indexOf(rule.ua) < 0) return false; + + // If the rule specifies screen dimensions that don't correspond to ours, + // the match fails. + if (rule.res) { + if (!rule.res[0] || !rule.res[1]) return false; + var resX = rule.res[0]; + var resY = rule.res[1]; + // Compare min and max so as to make the order not matter, i.e., it should + // be true that 640x480 == 480x640. + if (Math.min(screenWidth, screenHeight) != Math.min(resX, resY) || + (Math.max(screenWidth, screenHeight) != Math.max(resX, resY))) { + return false; + } + } + + return true; +} + +function DeviceParams(params) { + this.xdpi = params.xdpi; + this.ydpi = params.ydpi; + this.bevelMm = params.bevelMm; +} + +module.exports = Dpdb; + +},{"../util.js":22,"./dpdb.json":11}],13:[function(_dereq_,module,exports){ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * 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. + */ +var Util = _dereq_('./util.js'); +var WebVRPolyfill = _dereq_('./webvr-polyfill.js').WebVRPolyfill; + +// Initialize a WebVRConfig just in case. +window.WebVRConfig = Util.extend({ + // Forces availability of VR mode, even for non-mobile devices. + FORCE_ENABLE_VR: false, + + // Complementary filter coefficient. 0 for accelerometer, 1 for gyro. + K_FILTER: 0.98, + + // How far into the future to predict during fast motion (in seconds). + PREDICTION_TIME_S: 0.040, + + // Flag to enable touch panner. In case you have your own touch controls. + TOUCH_PANNER_DISABLED: true, + + // Flag to disabled the UI in VR Mode. + CARDBOARD_UI_DISABLED: false, // Default: false + + // Flag to disable the instructions to rotate your device. + ROTATE_INSTRUCTIONS_DISABLED: false, // Default: false. + + // Enable yaw panning only, disabling roll and pitch. This can be useful + // for panoramas with nothing interesting above or below. + YAW_ONLY: false, + + // To disable keyboard and mouse controls, if you want to use your own + // implementation. + MOUSE_KEYBOARD_CONTROLS_DISABLED: false, + + // Prevent the polyfill from initializing immediately. Requires the app + // to call InitializeWebVRPolyfill() before it can be used. + DEFER_INITIALIZATION: false, + + // Enable the deprecated version of the API (navigator.getVRDevices). + ENABLE_DEPRECATED_API: false, + + // Scales the recommended buffer size reported by WebVR, which can improve + // performance. + // UPDATE(2016-05-03): Setting this to 0.5 by default since 1.0 does not + // perform well on many mobile devices. + BUFFER_SCALE: 0.5, + + // Allow VRDisplay.submitFrame to change gl bindings, which is more + // efficient if the application code will re-bind its resources on the + // next frame anyway. This has been seen to cause rendering glitches with + // THREE.js. + // Dirty bindings include: gl.FRAMEBUFFER_BINDING, gl.CURRENT_PROGRAM, + // gl.ARRAY_BUFFER_BINDING, gl.ELEMENT_ARRAY_BUFFER_BINDING, + // and gl.TEXTURE_BINDING_2D for texture unit 0. + DIRTY_SUBMIT_FRAME_BINDINGS: false, + + // When set to true, this will cause a polyfilled VRDisplay to always be + // appended to the list returned by navigator.getVRDisplays(), even if that + // list includes a native VRDisplay. + ALWAYS_APPEND_POLYFILL_DISPLAY: false +}, window.WebVRConfig); + +if (!window.WebVRConfig.DEFER_INITIALIZATION) { + new WebVRPolyfill(); +} else { + window.InitializeWebVRPolyfill = function() { + new WebVRPolyfill(); + } +} + +},{"./util.js":22,"./webvr-polyfill.js":25}],14:[function(_dereq_,module,exports){ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * 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. + */ + +var MathUtil = window.MathUtil || {}; + +MathUtil.degToRad = Math.PI / 180; +MathUtil.radToDeg = 180 / Math.PI; + +// Some minimal math functionality borrowed from THREE.Math and stripped down +// for the purposes of this library. + + +MathUtil.Vector2 = function ( x, y ) { + this.x = x || 0; + this.y = y || 0; +}; + +MathUtil.Vector2.prototype = { + constructor: MathUtil.Vector2, + + set: function ( x, y ) { + this.x = x; + this.y = y; + + return this; + }, + + copy: function ( v ) { + this.x = v.x; + this.y = v.y; + + return this; + }, + + subVectors: function ( a, b ) { + this.x = a.x - b.x; + this.y = a.y - b.y; + + return this; + }, +}; + +MathUtil.Vector3 = function ( x, y, z ) { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; +}; + +MathUtil.Vector3.prototype = { + constructor: MathUtil.Vector3, + + set: function ( x, y, z ) { + this.x = x; + this.y = y; + this.z = z; + + return this; + }, + + copy: function ( v ) { + this.x = v.x; + this.y = v.y; + this.z = v.z; + + return this; + }, + + length: function () { + return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z ); + }, + + normalize: function () { + var scalar = this.length(); + + if ( scalar !== 0 ) { + var invScalar = 1 / scalar; + + this.multiplyScalar(invScalar); + } else { + this.x = 0; + this.y = 0; + this.z = 0; + } + + return this; + }, + + multiplyScalar: function ( scalar ) { + this.x *= scalar; + this.y *= scalar; + this.z *= scalar; + }, + + applyQuaternion: function ( q ) { + var x = this.x; + var y = this.y; + var z = this.z; + + var qx = q.x; + var qy = q.y; + var qz = q.z; + var qw = q.w; + + // calculate quat * vector + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = - qx * x - qy * y - qz * z; + + // calculate result * inverse quat + this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy; + this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz; + this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx; + + return this; + }, + + dot: function ( v ) { + return this.x * v.x + this.y * v.y + this.z * v.z; + }, + + crossVectors: function ( a, b ) { + var ax = a.x, ay = a.y, az = a.z; + var bx = b.x, by = b.y, bz = b.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + }, +}; + +MathUtil.Quaternion = function ( x, y, z, w ) { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = ( w !== undefined ) ? w : 1; +}; + +MathUtil.Quaternion.prototype = { + constructor: MathUtil.Quaternion, + + set: function ( x, y, z, w ) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + + return this; + }, + + copy: function ( quaternion ) { + this.x = quaternion.x; + this.y = quaternion.y; + this.z = quaternion.z; + this.w = quaternion.w; + + return this; + }, + + setFromEulerXYZ: function( x, y, z ) { + var c1 = Math.cos( x / 2 ); + var c2 = Math.cos( y / 2 ); + var c3 = Math.cos( z / 2 ); + var s1 = Math.sin( x / 2 ); + var s2 = Math.sin( y / 2 ); + var s3 = Math.sin( z / 2 ); + + this.x = s1 * c2 * c3 + c1 * s2 * s3; + this.y = c1 * s2 * c3 - s1 * c2 * s3; + this.z = c1 * c2 * s3 + s1 * s2 * c3; + this.w = c1 * c2 * c3 - s1 * s2 * s3; + + return this; + }, + + setFromEulerYXZ: function( x, y, z ) { + var c1 = Math.cos( x / 2 ); + var c2 = Math.cos( y / 2 ); + var c3 = Math.cos( z / 2 ); + var s1 = Math.sin( x / 2 ); + var s2 = Math.sin( y / 2 ); + var s3 = Math.sin( z / 2 ); + + this.x = s1 * c2 * c3 + c1 * s2 * s3; + this.y = c1 * s2 * c3 - s1 * c2 * s3; + this.z = c1 * c2 * s3 - s1 * s2 * c3; + this.w = c1 * c2 * c3 + s1 * s2 * s3; + + return this; + }, + + setFromAxisAngle: function ( axis, angle ) { + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm + // assumes axis is normalized + + var halfAngle = angle / 2, s = Math.sin( halfAngle ); + + this.x = axis.x * s; + this.y = axis.y * s; + this.z = axis.z * s; + this.w = Math.cos( halfAngle ); + + return this; + }, + + multiply: function ( q ) { + return this.multiplyQuaternions( this, q ); + }, + + multiplyQuaternions: function ( a, b ) { + // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm + + var qax = a.x, qay = a.y, qaz = a.z, qaw = a.w; + var qbx = b.x, qby = b.y, qbz = b.z, qbw = b.w; + + this.x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby; + this.y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz; + this.z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx; + this.w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz; + + return this; + }, + + inverse: function () { + this.x *= -1; + this.y *= -1; + this.z *= -1; + + this.normalize(); + + return this; + }, + + normalize: function () { + var l = Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w ); + + if ( l === 0 ) { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 1; + } else { + l = 1 / l; + + this.x = this.x * l; + this.y = this.y * l; + this.z = this.z * l; + this.w = this.w * l; + } + + return this; + }, + + slerp: function ( qb, t ) { + if ( t === 0 ) return this; + if ( t === 1 ) return this.copy( qb ); + + var x = this.x, y = this.y, z = this.z, w = this.w; + + // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/ + + var cosHalfTheta = w * qb.w + x * qb.x + y * qb.y + z * qb.z; + + if ( cosHalfTheta < 0 ) { + this.w = - qb.w; + this.x = - qb.x; + this.y = - qb.y; + this.z = - qb.z; + + cosHalfTheta = - cosHalfTheta; + } else { + this.copy( qb ); + } + + if ( cosHalfTheta >= 1.0 ) { + this.w = w; + this.x = x; + this.y = y; + this.z = z; + + return this; + } + + var halfTheta = Math.acos( cosHalfTheta ); + var sinHalfTheta = Math.sqrt( 1.0 - cosHalfTheta * cosHalfTheta ); + + if ( Math.abs( sinHalfTheta ) < 0.001 ) { + this.w = 0.5 * ( w + this.w ); + this.x = 0.5 * ( x + this.x ); + this.y = 0.5 * ( y + this.y ); + this.z = 0.5 * ( z + this.z ); + + return this; + } + + var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta, + ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; + + this.w = ( w * ratioA + this.w * ratioB ); + this.x = ( x * ratioA + this.x * ratioB ); + this.y = ( y * ratioA + this.y * ratioB ); + this.z = ( z * ratioA + this.z * ratioB ); + + return this; + }, + + setFromUnitVectors: function () { + // http://lolengine.net/blog/2014/02/24/quaternion-from-two-vectors-final + // assumes direction vectors vFrom and vTo are normalized + + var v1, r; + var EPS = 0.000001; + + return function ( vFrom, vTo ) { + if ( v1 === undefined ) v1 = new MathUtil.Vector3(); + + r = vFrom.dot( vTo ) + 1; + + if ( r < EPS ) { + r = 0; + + if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) { + v1.set( - vFrom.y, vFrom.x, 0 ); + } else { + v1.set( 0, - vFrom.z, vFrom.y ); + } + } else { + v1.crossVectors( vFrom, vTo ); + } + + this.x = v1.x; + this.y = v1.y; + this.z = v1.z; + this.w = r; + + this.normalize(); + + return this; + } + }(), +}; + +module.exports = MathUtil; + +},{}],15:[function(_dereq_,module,exports){ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * 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. + */ + +var VRDisplay = _dereq_('./base.js').VRDisplay; +var MathUtil = _dereq_('./math-util.js'); +var Util = _dereq_('./util.js'); + +// How much to rotate per key stroke. +var KEY_SPEED = 0.15; +var KEY_ANIMATION_DURATION = 80; + +// How much to rotate for mouse events. +var MOUSE_SPEED_X = 0.5; +var MOUSE_SPEED_Y = 0.3; + +/** + * VRDisplay based on mouse and keyboard input. Designed for desktops/laptops + * where orientation events aren't supported. Cannot present. + */ +function MouseKeyboardVRDisplay() { + this.displayName = 'Mouse and Keyboard VRDisplay (webvr-polyfill)'; + + this.capabilities.hasOrientation = true; + + // Attach to mouse and keyboard events. + window.addEventListener('keydown', this.onKeyDown_.bind(this)); + window.addEventListener('mousemove', this.onMouseMove_.bind(this)); + window.addEventListener('mousedown', this.onMouseDown_.bind(this)); + window.addEventListener('mouseup', this.onMouseUp_.bind(this)); + + // "Private" members. + this.phi_ = 0; + this.theta_ = 0; + + // Variables for keyboard-based rotation animation. + this.targetAngle_ = null; + this.angleAnimation_ = null; + + // State variables for calculations. + this.orientation_ = new MathUtil.Quaternion(); + + // Variables for mouse-based rotation. + this.rotateStart_ = new MathUtil.Vector2(); + this.rotateEnd_ = new MathUtil.Vector2(); + this.rotateDelta_ = new MathUtil.Vector2(); + this.isDragging_ = false; + + this.orientationOut_ = new Float32Array(4); +} +MouseKeyboardVRDisplay.prototype = new VRDisplay(); + +MouseKeyboardVRDisplay.prototype.getImmediatePose = function() { + this.orientation_.setFromEulerYXZ(this.phi_, this.theta_, 0); + + this.orientationOut_[0] = this.orientation_.x; + this.orientationOut_[1] = this.orientation_.y; + this.orientationOut_[2] = this.orientation_.z; + this.orientationOut_[3] = this.orientation_.w; + + return { + position: null, + orientation: this.orientationOut_, + linearVelocity: null, + linearAcceleration: null, + angularVelocity: null, + angularAcceleration: null + }; +}; + +MouseKeyboardVRDisplay.prototype.onKeyDown_ = function(e) { + // Track WASD and arrow keys. + if (e.keyCode == 38) { // Up key. + this.animatePhi_(this.phi_ + KEY_SPEED); + } else if (e.keyCode == 39) { // Right key. + this.animateTheta_(this.theta_ - KEY_SPEED); + } else if (e.keyCode == 40) { // Down key. + this.animatePhi_(this.phi_ - KEY_SPEED); + } else if (e.keyCode == 37) { // Left key. + this.animateTheta_(this.theta_ + KEY_SPEED); + } +}; + +MouseKeyboardVRDisplay.prototype.animateTheta_ = function(targetAngle) { + this.animateKeyTransitions_('theta_', targetAngle); +}; + +MouseKeyboardVRDisplay.prototype.animatePhi_ = function(targetAngle) { + // Prevent looking too far up or down. + targetAngle = Util.clamp(targetAngle, -Math.PI/2, Math.PI/2); + this.animateKeyTransitions_('phi_', targetAngle); +}; + +/** + * Start an animation to transition an angle from one value to another. + */ +MouseKeyboardVRDisplay.prototype.animateKeyTransitions_ = function(angleName, targetAngle) { + // If an animation is currently running, cancel it. + if (this.angleAnimation_) { + cancelAnimationFrame(this.angleAnimation_); + } + var startAngle = this[angleName]; + var startTime = new Date(); + // Set up an interval timer to perform the animation. + this.angleAnimation_ = requestAnimationFrame(function animate() { + // Once we're finished the animation, we're done. + var elapsed = new Date() - startTime; + if (elapsed >= KEY_ANIMATION_DURATION) { + this[angleName] = targetAngle; + cancelAnimationFrame(this.angleAnimation_); + return; + } + // loop with requestAnimationFrame + this.angleAnimation_ = requestAnimationFrame(animate.bind(this)) + // Linearly interpolate the angle some amount. + var percent = elapsed / KEY_ANIMATION_DURATION; + this[angleName] = startAngle + (targetAngle - startAngle) * percent; + }.bind(this)); +}; + +MouseKeyboardVRDisplay.prototype.onMouseDown_ = function(e) { + this.rotateStart_.set(e.clientX, e.clientY); + this.isDragging_ = true; +}; + +// Very similar to https://gist.github.com/mrflix/8351020 +MouseKeyboardVRDisplay.prototype.onMouseMove_ = function(e) { + if (!this.isDragging_ && !this.isPointerLocked_()) { + return; + } + // Support pointer lock API. + if (this.isPointerLocked_()) { + var movementX = e.movementX || e.mozMovementX || 0; + var movementY = e.movementY || e.mozMovementY || 0; + this.rotateEnd_.set(this.rotateStart_.x - movementX, this.rotateStart_.y - movementY); + } else { + this.rotateEnd_.set(e.clientX, e.clientY); + } + // Calculate how much we moved in mouse space. + this.rotateDelta_.subVectors(this.rotateEnd_, this.rotateStart_); + this.rotateStart_.copy(this.rotateEnd_); + + // Keep track of the cumulative euler angles. + this.phi_ += 2 * Math.PI * this.rotateDelta_.y / screen.height * MOUSE_SPEED_Y; + this.theta_ += 2 * Math.PI * this.rotateDelta_.x / screen.width * MOUSE_SPEED_X; + + // Prevent looking too far up or down. + this.phi_ = Util.clamp(this.phi_, -Math.PI/2, Math.PI/2); +}; + +MouseKeyboardVRDisplay.prototype.onMouseUp_ = function(e) { + this.isDragging_ = false; +}; + +MouseKeyboardVRDisplay.prototype.isPointerLocked_ = function() { + var el = document.pointerLockElement || document.mozPointerLockElement || + document.webkitPointerLockElement; + return el !== undefined; +}; + +MouseKeyboardVRDisplay.prototype.resetPose = function() { + this.phi_ = 0; + this.theta_ = 0; +}; + +module.exports = MouseKeyboardVRDisplay; + +},{"./base.js":3,"./math-util.js":14,"./util.js":22}],16:[function(_dereq_,module,exports){ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * 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. + */ + +var Util = _dereq_('./util.js'); + +function RotateInstructions() { + this.loadIcon_(); + + var overlay = document.createElement('div'); + var s = overlay.style; + s.position = 'fixed'; + s.top = 0; + s.right = 0; + s.bottom = 0; + s.left = 0; + s.backgroundColor = 'gray'; + s.fontFamily = 'sans-serif'; + // Force this to be above the fullscreen canvas, which is at zIndex: 999999. + s.zIndex = 1000000; + + var img = document.createElement('img'); + img.src = this.icon; + var s = img.style; + s.marginLeft = '25%'; + s.marginTop = '25%'; + s.width = '50%'; + overlay.appendChild(img); + + var text = document.createElement('div'); + var s = text.style; + s.textAlign = 'center'; + s.fontSize = '16px'; + s.lineHeight = '24px'; + s.margin = '24px 25%'; + s.width = '50%'; + text.innerHTML = 'Place your phone into your Cardboard viewer.'; + overlay.appendChild(text); + + var snackbar = document.createElement('div'); + var s = snackbar.style; + s.backgroundColor = '#CFD8DC'; + s.position = 'fixed'; + s.bottom = 0; + s.width = '100%'; + s.height = '48px'; + s.padding = '14px 24px'; + s.boxSizing = 'border-box'; + s.color = '#656A6B'; + overlay.appendChild(snackbar); + + var snackbarText = document.createElement('div'); + snackbarText.style.float = 'left'; + snackbarText.innerHTML = 'No Cardboard viewer?'; + + var snackbarButton = document.createElement('a'); + snackbarButton.href = 'https://www.google.com/get/cardboard/get-cardboard/'; + snackbarButton.innerHTML = 'get one'; + snackbarButton.target = '_blank'; + var s = snackbarButton.style; + s.float = 'right'; + s.fontWeight = 600; + s.textTransform = 'uppercase'; + s.borderLeft = '1px solid gray'; + s.paddingLeft = '24px'; + s.textDecoration = 'none'; + s.color = '#656A6B'; + + snackbar.appendChild(snackbarText); + snackbar.appendChild(snackbarButton); + + this.overlay = overlay; + this.text = text; + + this.hide(); +} + +RotateInstructions.prototype.show = function(parent) { + if (!parent && !this.overlay.parentElement) { + document.body.appendChild(this.overlay); + } else if (parent) { + if (this.overlay.parentElement && this.overlay.parentElement != parent) + this.overlay.parentElement.removeChild(this.overlay); + + parent.appendChild(this.overlay); + } + + this.overlay.style.display = 'block'; + + var img = this.overlay.querySelector('img'); + var s = img.style; + + if (Util.isLandscapeMode()) { + s.width = '20%'; + s.marginLeft = '40%'; + s.marginTop = '3%'; + } else { + s.width = '50%'; + s.marginLeft = '25%'; + s.marginTop = '25%'; + } +}; + +RotateInstructions.prototype.hide = function() { + this.overlay.style.display = 'none'; +}; + +RotateInstructions.prototype.showTemporarily = function(ms, parent) { + this.show(parent); + this.timer = setTimeout(this.hide.bind(this), ms); +}; + +RotateInstructions.prototype.disableShowTemporarily = function() { + clearTimeout(this.timer); +}; + +RotateInstructions.prototype.update = function() { + this.disableShowTemporarily(); + // In portrait VR mode, tell the user to rotate to landscape. Otherwise, hide + // the instructions. + if (!Util.isLandscapeMode() && Util.isMobile()) { + this.show(); + } else { + this.hide(); + } +}; + +RotateInstructions.prototype.loadIcon_ = function() { + // Encoded asset_src/rotate-instructions.svg + this.icon = Util.base64('image/svg+xml', 'PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjE5OHB4Ii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AgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+'); +}; + +module.exports = RotateInstructions; + +},{"./util.js":22}],17:[function(_dereq_,module,exports){ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * 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. + */ + +var SensorSample = _dereq_('./sensor-sample.js'); +var MathUtil = _dereq_('../math-util.js'); +var Util = _dereq_('../util.js'); + +/** + * An implementation of a simple complementary filter, which fuses gyroscope and + * accelerometer data from the 'devicemotion' event. + * + * Accelerometer data is very noisy, but stable over the long term. + * Gyroscope data is smooth, but tends to drift over the long term. + * + * This fusion is relatively simple: + * 1. Get orientation estimates from accelerometer by applying a low-pass filter + * on that data. + * 2. Get orientation estimates from gyroscope by integrating over time. + * 3. Combine the two estimates, weighing (1) in the long term, but (2) for the + * short term. + */ +function ComplementaryFilter(kFilter) { + this.kFilter = kFilter; + + // Raw sensor measurements. + this.currentAccelMeasurement = new SensorSample(); + this.currentGyroMeasurement = new SensorSample(); + this.previousGyroMeasurement = new SensorSample(); + + // Set default look direction to be in the correct direction. + if (Util.isIOS()) { + this.filterQ = new MathUtil.Quaternion(-1, 0, 0, 1); + } else { + this.filterQ = new MathUtil.Quaternion(1, 0, 0, 1); + } + this.previousFilterQ = new MathUtil.Quaternion(); + this.previousFilterQ.copy(this.filterQ); + + // Orientation based on the accelerometer. + this.accelQ = new MathUtil.Quaternion(); + // Whether or not the orientation has been initialized. + this.isOrientationInitialized = false; + // Running estimate of gravity based on the current orientation. + this.estimatedGravity = new MathUtil.Vector3(); + // Measured gravity based on accelerometer. + this.measuredGravity = new MathUtil.Vector3(); + + // Debug only quaternion of gyro-based orientation. + this.gyroIntegralQ = new MathUtil.Quaternion(); +} + +ComplementaryFilter.prototype.addAccelMeasurement = function(vector, timestampS) { + this.currentAccelMeasurement.set(vector, timestampS); +}; + +ComplementaryFilter.prototype.addGyroMeasurement = function(vector, timestampS) { + this.currentGyroMeasurement.set(vector, timestampS); + + var deltaT = timestampS - this.previousGyroMeasurement.timestampS; + if (Util.isTimestampDeltaValid(deltaT)) { + this.run_(); + } + + this.previousGyroMeasurement.copy(this.currentGyroMeasurement); +}; + +ComplementaryFilter.prototype.run_ = function() { + + if (!this.isOrientationInitialized) { + this.accelQ = this.accelToQuaternion_(this.currentAccelMeasurement.sample); + this.previousFilterQ.copy(this.accelQ); + this.isOrientationInitialized = true; + return; + } + + var deltaT = this.currentGyroMeasurement.timestampS - + this.previousGyroMeasurement.timestampS; + + // Convert gyro rotation vector to a quaternion delta. + var gyroDeltaQ = this.gyroToQuaternionDelta_(this.currentGyroMeasurement.sample, deltaT); + this.gyroIntegralQ.multiply(gyroDeltaQ); + + // filter_1 = K * (filter_0 + gyro * dT) + (1 - K) * accel. + this.filterQ.copy(this.previousFilterQ); + this.filterQ.multiply(gyroDeltaQ); + + // Calculate the delta between the current estimated gravity and the real + // gravity vector from accelerometer. + var invFilterQ = new MathUtil.Quaternion(); + invFilterQ.copy(this.filterQ); + invFilterQ.inverse(); + + this.estimatedGravity.set(0, 0, -1); + this.estimatedGravity.applyQuaternion(invFilterQ); + this.estimatedGravity.normalize(); + + this.measuredGravity.copy(this.currentAccelMeasurement.sample); + this.measuredGravity.normalize(); + + // Compare estimated gravity with measured gravity, get the delta quaternion + // between the two. + var deltaQ = new MathUtil.Quaternion(); + deltaQ.setFromUnitVectors(this.estimatedGravity, this.measuredGravity); + deltaQ.inverse(); + + if (Util.isDebug()) { + console.log('Delta: %d deg, G_est: (%s, %s, %s), G_meas: (%s, %s, %s)', + MathUtil.radToDeg * Util.getQuaternionAngle(deltaQ), + (this.estimatedGravity.x).toFixed(1), + (this.estimatedGravity.y).toFixed(1), + (this.estimatedGravity.z).toFixed(1), + (this.measuredGravity.x).toFixed(1), + (this.measuredGravity.y).toFixed(1), + (this.measuredGravity.z).toFixed(1)); + } + + // Calculate the SLERP target: current orientation plus the measured-estimated + // quaternion delta. + var targetQ = new MathUtil.Quaternion(); + targetQ.copy(this.filterQ); + targetQ.multiply(deltaQ); + + // SLERP factor: 0 is pure gyro, 1 is pure accel. + this.filterQ.slerp(targetQ, 1 - this.kFilter); + + this.previousFilterQ.copy(this.filterQ); +}; + +ComplementaryFilter.prototype.getOrientation = function() { + return this.filterQ; +}; + +ComplementaryFilter.prototype.accelToQuaternion_ = function(accel) { + var normAccel = new MathUtil.Vector3(); + normAccel.copy(accel); + normAccel.normalize(); + var quat = new MathUtil.Quaternion(); + quat.setFromUnitVectors(new MathUtil.Vector3(0, 0, -1), normAccel); + quat.inverse(); + return quat; +}; + +ComplementaryFilter.prototype.gyroToQuaternionDelta_ = function(gyro, dt) { + // Extract axis and angle from the gyroscope data. + var quat = new MathUtil.Quaternion(); + var axis = new MathUtil.Vector3(); + axis.copy(gyro); + axis.normalize(); + quat.setFromAxisAngle(axis, gyro.length() * dt); + return quat; +}; + + +module.exports = ComplementaryFilter; + +},{"../math-util.js":14,"../util.js":22,"./sensor-sample.js":20}],18:[function(_dereq_,module,exports){ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * 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. + */ +var ComplementaryFilter = _dereq_('./complementary-filter.js'); +var PosePredictor = _dereq_('./pose-predictor.js'); +var TouchPanner = _dereq_('../touch-panner.js'); +var MathUtil = _dereq_('../math-util.js'); +var Util = _dereq_('../util.js'); + +/** + * The pose sensor, implemented using DeviceMotion APIs. + */ +function FusionPoseSensor() { + this.deviceId = 'webvr-polyfill:fused'; + this.deviceName = 'VR Position Device (webvr-polyfill:fused)'; + + this.accelerometer = new MathUtil.Vector3(); + this.gyroscope = new MathUtil.Vector3(); + + this.start(); + + this.filter = new ComplementaryFilter(window.WebVRConfig.K_FILTER); + this.posePredictor = new PosePredictor(window.WebVRConfig.PREDICTION_TIME_S); + this.touchPanner = new TouchPanner(); + + this.filterToWorldQ = new MathUtil.Quaternion(); + + // Set the filter to world transform, depending on OS. + if (Util.isIOS()) { + this.filterToWorldQ.setFromAxisAngle(new MathUtil.Vector3(1, 0, 0), Math.PI / 2); + } else { + this.filterToWorldQ.setFromAxisAngle(new MathUtil.Vector3(1, 0, 0), -Math.PI / 2); + } + + this.inverseWorldToScreenQ = new MathUtil.Quaternion(); + this.worldToScreenQ = new MathUtil.Quaternion(); + this.originalPoseAdjustQ = new MathUtil.Quaternion(); + this.originalPoseAdjustQ.setFromAxisAngle(new MathUtil.Vector3(0, 0, 1), + -window.orientation * Math.PI / 180); + + this.setScreenTransform_(); + // Adjust this filter for being in landscape mode. + if (Util.isLandscapeMode()) { + this.filterToWorldQ.multiply(this.inverseWorldToScreenQ); + } + + // Keep track of a reset transform for resetSensor. + this.resetQ = new MathUtil.Quaternion(); + + this.isFirefoxAndroid = Util.isFirefoxAndroid(); + this.isIOS = Util.isIOS(); + + this.orientationOut_ = new Float32Array(4); +} + +FusionPoseSensor.prototype.getPosition = function() { + // This PoseSensor doesn't support position + return null; +}; + +FusionPoseSensor.prototype.getOrientation = function() { + // Convert from filter space to the the same system used by the + // deviceorientation event. + var orientation = this.filter.getOrientation(); + + // Predict orientation. + this.predictedQ = this.posePredictor.getPrediction(orientation, this.gyroscope, this.previousTimestampS); + + // Convert to THREE coordinate system: -Z forward, Y up, X right. + var out = new MathUtil.Quaternion(); + out.copy(this.filterToWorldQ); + out.multiply(this.resetQ); + if (!window.WebVRConfig.TOUCH_PANNER_DISABLED) { + out.multiply(this.touchPanner.getOrientation()); + } + out.multiply(this.predictedQ); + out.multiply(this.worldToScreenQ); + + // Handle the yaw-only case. + if (window.WebVRConfig.YAW_ONLY) { + // Make a quaternion that only turns around the Y-axis. + out.x = 0; + out.z = 0; + out.normalize(); + } + + this.orientationOut_[0] = out.x; + this.orientationOut_[1] = out.y; + this.orientationOut_[2] = out.z; + this.orientationOut_[3] = out.w; + return this.orientationOut_; +}; + +FusionPoseSensor.prototype.resetPose = function() { + // Reduce to inverted yaw-only. + this.resetQ.copy(this.filter.getOrientation()); + this.resetQ.x = 0; + this.resetQ.y = 0; + this.resetQ.z *= -1; + this.resetQ.normalize(); + + // Take into account extra transformations in landscape mode. + if (Util.isLandscapeMode()) { + this.resetQ.multiply(this.inverseWorldToScreenQ); + } + + // Take into account original pose. + this.resetQ.multiply(this.originalPoseAdjustQ); + + if (!window.WebVRConfig.TOUCH_PANNER_DISABLED) { + this.touchPanner.resetSensor(); + } +}; + +FusionPoseSensor.prototype.onDeviceMotion_ = function(deviceMotion) { + this.updateDeviceMotion_(deviceMotion); +}; + +FusionPoseSensor.prototype.updateDeviceMotion_ = function(deviceMotion) { + var accGravity = deviceMotion.accelerationIncludingGravity; + var rotRate = deviceMotion.rotationRate; + var timestampS = deviceMotion.timeStamp / 1000; + + // Firefox Android timeStamp returns one thousandth of a millisecond. + if (this.isFirefoxAndroid) { + timestampS /= 1000; + } + + var deltaS = timestampS - this.previousTimestampS; + if (deltaS <= Util.MIN_TIMESTEP || deltaS > Util.MAX_TIMESTEP) { + console.warn('Invalid timestamps detected. Time step between successive ' + + 'gyroscope sensor samples is very small or not monotonic'); + this.previousTimestampS = timestampS; + return; + } + this.accelerometer.set(-accGravity.x, -accGravity.y, -accGravity.z); + this.gyroscope.set(rotRate.alpha, rotRate.beta, rotRate.gamma); + + // With iOS and Firefox Android, rotationRate is reported in degrees, + // so we first convert to radians. + if (this.isIOS || this.isFirefoxAndroid) { + this.gyroscope.multiplyScalar(Math.PI / 180); + } + + this.filter.addAccelMeasurement(this.accelerometer, timestampS); + this.filter.addGyroMeasurement(this.gyroscope, timestampS); + + this.previousTimestampS = timestampS; +}; + +FusionPoseSensor.prototype.onOrientationChange_ = function(screenOrientation) { + this.setScreenTransform_(); +}; + +/** + * This is only needed if we are in an cross origin iframe on iOS to work around + * this issue: https://bugs.webkit.org/show_bug.cgi?id=152299. + */ +FusionPoseSensor.prototype.onMessage_ = function(event) { + var message = event.data; + + // If there's no message type, ignore it. + if (!message || !message.type) { + return; + } + + // Ignore all messages that aren't devicemotion. + var type = message.type.toLowerCase(); + if (type !== 'devicemotion') { + return; + } + + // Update device motion. + this.updateDeviceMotion_(message.deviceMotionEvent); +}; + +FusionPoseSensor.prototype.setScreenTransform_ = function() { + this.worldToScreenQ.set(0, 0, 0, 1); + switch (window.orientation) { + case 0: + break; + case 90: + this.worldToScreenQ.setFromAxisAngle(new MathUtil.Vector3(0, 0, 1), -Math.PI / 2); + break; + case -90: + this.worldToScreenQ.setFromAxisAngle(new MathUtil.Vector3(0, 0, 1), Math.PI / 2); + break; + case 180: + // TODO. + break; + } + this.inverseWorldToScreenQ.copy(this.worldToScreenQ); + this.inverseWorldToScreenQ.inverse(); +}; + +FusionPoseSensor.prototype.start = function() { + this.onDeviceMotionCallback_ = this.onDeviceMotion_.bind(this); + this.onOrientationChangeCallback_ = this.onOrientationChange_.bind(this); + this.onMessageCallback_ = this.onMessage_.bind(this); + + // Only listen for postMessages if we're in an iOS and embedded inside a cross + // domain IFrame. In this case, the polyfill can still work if the containing + // page sends synthetic devicemotion events. For an example of this, see + // iframe-message-sender.js in VR View: https://goo.gl/XDtvFZ + if (Util.isIOS() && Util.isInsideCrossDomainIFrame()) { + window.addEventListener('message', this.onMessageCallback_); + } + window.addEventListener('orientationchange', this.onOrientationChangeCallback_); + window.addEventListener('devicemotion', this.onDeviceMotionCallback_); +}; + +FusionPoseSensor.prototype.stop = function() { + window.removeEventListener('devicemotion', this.onDeviceMotionCallback_); + window.removeEventListener('orientationchange', this.onOrientationChangeCallback_); + window.removeEventListener('message', this.onMessageCallback_); +}; + +module.exports = FusionPoseSensor; + +},{"../math-util.js":14,"../touch-panner.js":21,"../util.js":22,"./complementary-filter.js":17,"./pose-predictor.js":19}],19:[function(_dereq_,module,exports){ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * 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. + */ +var MathUtil = _dereq_('../math-util'); +var Util = _dereq_('../util'); + +/** + * Given an orientation and the gyroscope data, predicts the future orientation + * of the head. This makes rendering appear faster. + * + * Also see: http://msl.cs.uiuc.edu/~lavalle/papers/LavYerKatAnt14.pdf + * + * @param {Number} predictionTimeS time from head movement to the appearance of + * the corresponding image. + */ +function PosePredictor(predictionTimeS) { + this.predictionTimeS = predictionTimeS; + + // The quaternion corresponding to the previous state. + this.previousQ = new MathUtil.Quaternion(); + // Previous time a prediction occurred. + this.previousTimestampS = null; + + // The delta quaternion that adjusts the current pose. + this.deltaQ = new MathUtil.Quaternion(); + // The output quaternion. + this.outQ = new MathUtil.Quaternion(); +} + +PosePredictor.prototype.getPrediction = function(currentQ, gyro, timestampS) { + if (!this.previousTimestampS) { + this.previousQ.copy(currentQ); + this.previousTimestampS = timestampS; + return currentQ; + } + + // Calculate axis and angle based on gyroscope rotation rate data. + var axis = new MathUtil.Vector3(); + axis.copy(gyro); + axis.normalize(); + + var angularSpeed = gyro.length(); + + // If we're rotating slowly, don't do prediction. + if (angularSpeed < MathUtil.degToRad * 20) { + if (Util.isDebug()) { + console.log('Moving slowly, at %s deg/s: no prediction', + (MathUtil.radToDeg * angularSpeed).toFixed(1)); + } + this.outQ.copy(currentQ); + this.previousQ.copy(currentQ); + return this.outQ; + } + + // Get the predicted angle based on the time delta and latency. + var deltaT = timestampS - this.previousTimestampS; + var predictAngle = angularSpeed * this.predictionTimeS; + + this.deltaQ.setFromAxisAngle(axis, predictAngle); + this.outQ.copy(this.previousQ); + this.outQ.multiply(this.deltaQ); + + this.previousQ.copy(currentQ); + this.previousTimestampS = timestampS; + + return this.outQ; +}; + + +module.exports = PosePredictor; + +},{"../math-util":14,"../util":22}],20:[function(_dereq_,module,exports){ +function SensorSample(sample, timestampS) { + this.set(sample, timestampS); +}; + +SensorSample.prototype.set = function(sample, timestampS) { + this.sample = sample; + this.timestampS = timestampS; +}; + +SensorSample.prototype.copy = function(sensorSample) { + this.set(sensorSample.sample, sensorSample.timestampS); +}; + +module.exports = SensorSample; + +},{}],21:[function(_dereq_,module,exports){ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * 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. + */ +var MathUtil = _dereq_('./math-util.js'); +var Util = _dereq_('./util.js'); + +var ROTATE_SPEED = 0.5; +/** + * Provides a quaternion responsible for pre-panning the scene before further + * transformations due to device sensors. + */ +function TouchPanner() { + window.addEventListener('touchstart', this.onTouchStart_.bind(this)); + window.addEventListener('touchmove', this.onTouchMove_.bind(this)); + window.addEventListener('touchend', this.onTouchEnd_.bind(this)); + + this.isTouching = false; + this.rotateStart = new MathUtil.Vector2(); + this.rotateEnd = new MathUtil.Vector2(); + this.rotateDelta = new MathUtil.Vector2(); + + this.theta = 0; + this.orientation = new MathUtil.Quaternion(); +} + +TouchPanner.prototype.getOrientation = function() { + this.orientation.setFromEulerXYZ(0, 0, this.theta); + return this.orientation; +}; + +TouchPanner.prototype.resetSensor = function() { + this.theta = 0; +}; + +TouchPanner.prototype.onTouchStart_ = function(e) { + // Only respond if there is exactly one touch. + // Note that the Daydream controller passes in a `touchstart` event with + // no `touches` property, so we must check for that case too. + if (!e.touches || e.touches.length != 1) { + return; + } + this.rotateStart.set(e.touches[0].pageX, e.touches[0].pageY); + this.isTouching = true; +}; + +TouchPanner.prototype.onTouchMove_ = function(e) { + if (!this.isTouching) { + return; + } + this.rotateEnd.set(e.touches[0].pageX, e.touches[0].pageY); + this.rotateDelta.subVectors(this.rotateEnd, this.rotateStart); + this.rotateStart.copy(this.rotateEnd); + + // On iOS, direction is inverted. + if (Util.isIOS()) { + this.rotateDelta.x *= -1; + } + + var element = document.body; + this.theta += 2 * Math.PI * this.rotateDelta.x / element.clientWidth * ROTATE_SPEED; +}; + +TouchPanner.prototype.onTouchEnd_ = function(e) { + this.isTouching = false; +}; + +module.exports = TouchPanner; + +},{"./math-util.js":14,"./util.js":22}],22:[function(_dereq_,module,exports){ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * 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. + */ + +var objectAssign = _dereq_('object-assign'); + +var Util = window.Util || {}; + +Util.MIN_TIMESTEP = 0.001; +Util.MAX_TIMESTEP = 1; + +Util.base64 = function(mimeType, base64) { + return 'data:' + mimeType + ';base64,' + base64; +}; + +Util.clamp = function(value, min, max) { + return Math.min(Math.max(min, value), max); +}; + +Util.lerp = function(a, b, t) { + return a + ((b - a) * t); +}; + +Util.isIOS = (function() { + var isIOS = /iPad|iPhone|iPod/.test(navigator.platform); + return function() { + return isIOS; + }; +})(); + +Util.isWebViewAndroid = (function() { + var isWebViewAndroid = navigator.userAgent.indexOf('Version') !== -1 && + navigator.userAgent.indexOf('Android') !== -1 && + navigator.userAgent.indexOf('Chrome') !== -1; + return function() { + return isWebViewAndroid; + }; +})(); + +Util.isSafari = (function() { + var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); + return function() { + return isSafari; + }; +})(); + +Util.isFirefoxAndroid = (function() { + var isFirefoxAndroid = navigator.userAgent.indexOf('Firefox') !== -1 && + navigator.userAgent.indexOf('Android') !== -1; + return function() { + return isFirefoxAndroid; + }; +})(); + +Util.isLandscapeMode = function() { + return (window.orientation == 90 || window.orientation == -90); +}; + +// Helper method to validate the time steps of sensor timestamps. +Util.isTimestampDeltaValid = function(timestampDeltaS) { + if (isNaN(timestampDeltaS)) { + return false; + } + if (timestampDeltaS <= Util.MIN_TIMESTEP) { + return false; + } + if (timestampDeltaS > Util.MAX_TIMESTEP) { + return false; + } + return true; +}; + +Util.getScreenWidth = function() { + return Math.max(window.screen.width, window.screen.height) * + window.devicePixelRatio; +}; + +Util.getScreenHeight = function() { + return Math.min(window.screen.width, window.screen.height) * + window.devicePixelRatio; +}; + +Util.requestFullscreen = function(element) { + if (Util.isWebViewAndroid()) { + return false; + } + if (element.requestFullscreen) { + element.requestFullscreen(); + } else if (element.webkitRequestFullscreen) { + element.webkitRequestFullscreen(); + } else if (element.mozRequestFullScreen) { + element.mozRequestFullScreen(); + } else if (element.msRequestFullscreen) { + element.msRequestFullscreen(); + } else { + return false; + } + + return true; +}; + +Util.exitFullscreen = function() { + if (document.exitFullscreen) { + document.exitFullscreen(); + } else if (document.webkitExitFullscreen) { + document.webkitExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); + } else { + return false; + } + + return true; +}; + +Util.getFullscreenElement = function() { + return document.fullscreenElement || + document.webkitFullscreenElement || + document.mozFullScreenElement || + document.msFullscreenElement; +}; + +Util.linkProgram = function(gl, vertexSource, fragmentSource, attribLocationMap) { + // No error checking for brevity. + var vertexShader = gl.createShader(gl.VERTEX_SHADER); + gl.shaderSource(vertexShader, vertexSource); + gl.compileShader(vertexShader); + + var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); + gl.shaderSource(fragmentShader, fragmentSource); + gl.compileShader(fragmentShader); + + var program = gl.createProgram(); + gl.attachShader(program, vertexShader); + gl.attachShader(program, fragmentShader); + + for (var attribName in attribLocationMap) + gl.bindAttribLocation(program, attribLocationMap[attribName], attribName); + + gl.linkProgram(program); + + gl.deleteShader(vertexShader); + gl.deleteShader(fragmentShader); + + return program; +}; + +Util.getProgramUniforms = function(gl, program) { + var uniforms = {}; + var uniformCount = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS); + var uniformName = ''; + for (var i = 0; i < uniformCount; i++) { + var uniformInfo = gl.getActiveUniform(program, i); + uniformName = uniformInfo.name.replace('[0]', ''); + uniforms[uniformName] = gl.getUniformLocation(program, uniformName); + } + return uniforms; +}; + +Util.orthoMatrix = function (out, left, right, bottom, top, near, far) { + var lr = 1 / (left - right), + bt = 1 / (bottom - top), + 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; +}; + +Util.copyArray = function (source, dest) { + for (var i = 0, n = source.length; i < n; i++) { + dest[i] = source[i]; + } +}; + +Util.isMobile = function() { + 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})(navigator.userAgent||navigator.vendor||window.opera); + return check; +}; + +Util.extend = objectAssign; + +Util.safariCssSizeWorkaround = function(canvas) { + // TODO(smus): Remove this workaround when Safari for iOS is fixed. + // iOS only workaround (for https://bugs.webkit.org/show_bug.cgi?id=152556). + // + // "To the last I grapple with thee; + // from hell's heart I stab at thee; + // for hate's sake I spit my last breath at thee." + // -- Moby Dick, by Herman Melville + if (Util.isIOS()) { + var width = canvas.style.width; + var height = canvas.style.height; + canvas.style.width = (parseInt(width) + 1) + 'px'; + canvas.style.height = (parseInt(height)) + 'px'; + setTimeout(function() { + canvas.style.width = width; + canvas.style.height = height; + }, 100); + } + + // Debug only. + window.Util = Util; + window.canvas = canvas; +}; + +Util.isDebug = function() { + return Util.getQueryParameter('debug'); +}; + +Util.getQueryParameter = function(name) { + var name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); + var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), + results = regex.exec(location.search); + return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); +}; + +Util.frameDataFromPose = (function() { + var piOver180 = Math.PI / 180.0; + var rad45 = Math.PI * 0.25; + + // Borrowed from glMatrix. + function mat4_perspectiveFromFieldOfView(out, fov, near, far) { + var upTan = Math.tan(fov ? (fov.upDegrees * piOver180) : rad45), + downTan = Math.tan(fov ? (fov.downDegrees * piOver180) : rad45), + leftTan = Math.tan(fov ? (fov.leftDegrees * piOver180) : rad45), + rightTan = Math.tan(fov ? (fov.rightDegrees * piOver180) : rad45), + xScale = 2.0 / (leftTan + rightTan), + 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; + } + + function mat4_fromRotationTranslation(out, q, v) { + // Quaternion math + var x = q[0], y = q[1], z = q[2], w = q[3], + x2 = x + x, + y2 = y + y, + z2 = z + z, + + xx = x * x2, + xy = x * y2, + xz = x * z2, + yy = y * y2, + yz = y * z2, + zz = z * z2, + wx = w * x2, + wy = w * y2, + 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; + }; + + function mat4_translate(out, a, v) { + var x = v[0], y = v[1], z = v[2], + a00, a01, a02, a03, + a10, a11, a12, a13, + 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; + }; + + function mat4_invert(out, a) { + var 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], + a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15], + + b00 = a00 * a11 - a01 * a10, + b01 = a00 * a12 - a02 * a10, + b02 = a00 * a13 - a03 * a10, + b03 = a01 * a12 - a02 * a11, + b04 = a01 * a13 - a03 * a11, + b05 = a02 * a13 - a03 * a12, + b06 = a20 * a31 - a21 * a30, + b07 = a20 * a32 - a22 * a30, + b08 = a20 * a33 - a23 * a30, + b09 = a21 * a32 - a22 * a31, + b10 = a21 * a33 - a23 * a31, + b11 = a22 * a33 - a23 * a32, + + // Calculate the determinant + 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; + }; + + var defaultOrientation = new Float32Array([0, 0, 0, 1]); + var defaultPosition = new Float32Array([0, 0, 0]); + + function updateEyeMatrices(projection, view, pose, parameters, vrDisplay) { + mat4_perspectiveFromFieldOfView(projection, parameters ? parameters.fieldOfView : null, vrDisplay.depthNear, vrDisplay.depthFar); + + var orientation = pose.orientation || defaultOrientation; + var position = pose.position || defaultPosition; + + mat4_fromRotationTranslation(view, orientation, position); + if (parameters) + mat4_translate(view, view, parameters.offset); + mat4_invert(view, view); + } + + return function(frameData, pose, vrDisplay) { + if (!frameData || !pose) + return false; + + frameData.pose = pose; + frameData.timestamp = pose.timestamp; + + updateEyeMatrices( + frameData.leftProjectionMatrix, frameData.leftViewMatrix, + pose, vrDisplay.getEyeParameters("left"), vrDisplay); + updateEyeMatrices( + frameData.rightProjectionMatrix, frameData.rightViewMatrix, + pose, vrDisplay.getEyeParameters("right"), vrDisplay); + + return true; + }; +})(); + +Util.isInsideCrossDomainIFrame = function() { + var isFramed = (window.self !== window.top); + var refDomain = Util.getDomainFromUrl(document.referrer); + var thisDomain = Util.getDomainFromUrl(window.location.href); + + return isFramed && (refDomain !== thisDomain); +}; + +// From http://stackoverflow.com/a/23945027. +Util.getDomainFromUrl = function(url) { + var domain; + // Find & remove protocol (http, ftp, etc.) and get domain. + if (url.indexOf("://") > -1) { + domain = url.split('/')[2]; + } + else { + domain = url.split('/')[0]; + } + + //find & remove port number + domain = domain.split(':')[0]; + + return domain; +} + +module.exports = Util; + +},{"object-assign":2}],23:[function(_dereq_,module,exports){ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * 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. + */ + +var DeviceInfo = _dereq_('./device-info.js'); +var EventEmitter3 = _dereq_('eventemitter3'); +var Util = _dereq_('./util.js'); + +var DEFAULT_VIEWER = 'CardboardV1'; +var VIEWER_KEY = 'WEBVR_CARDBOARD_VIEWER'; +var CLASS_NAME = 'webvr-polyfill-viewer-selector'; + +/** + * Creates a viewer selector with the options specified. Supports being shown + * and hidden. Generates events when viewer parameters change. Also supports + * saving the currently selected index in localStorage. + */ +function ViewerSelector() { + // Try to load the selected key from local storage. + try { + this.selectedKey = localStorage.getItem(VIEWER_KEY); + } catch (error) { + console.error('Failed to load viewer profile: %s', error); + } + + //If none exists, or if localstorage is unavailable, use the default key. + if (!this.selectedKey) { + this.selectedKey = DEFAULT_VIEWER; + } + + this.dialog = this.createDialog_(DeviceInfo.Viewers); + this.root = null; +} +ViewerSelector.prototype = new EventEmitter3(); + +ViewerSelector.prototype.show = function(root) { + this.root = root; + + root.appendChild(this.dialog); + + // Ensure the currently selected item is checked. + var selected = this.dialog.querySelector('#' + this.selectedKey); + selected.checked = true; + + // Show the UI. + this.dialog.style.display = 'block'; +}; + +ViewerSelector.prototype.hide = function() { + if (this.root && this.root.contains(this.dialog)) { + this.root.removeChild(this.dialog); + } + this.dialog.style.display = 'none'; +}; + +ViewerSelector.prototype.getCurrentViewer = function() { + return DeviceInfo.Viewers[this.selectedKey]; +}; + +ViewerSelector.prototype.getSelectedKey_ = function() { + var input = this.dialog.querySelector('input[name=field]:checked'); + if (input) { + return input.id; + } + return null; +}; + +ViewerSelector.prototype.onSave_ = function() { + this.selectedKey = this.getSelectedKey_(); + if (!this.selectedKey || !DeviceInfo.Viewers[this.selectedKey]) { + console.error('ViewerSelector.onSave_: this should never happen!'); + return; + } + + this.emit('change', DeviceInfo.Viewers[this.selectedKey]); + + // Attempt to save the viewer profile, but fails in private mode. + try { + localStorage.setItem(VIEWER_KEY, this.selectedKey); + } catch(error) { + console.error('Failed to save viewer profile: %s', error); + } + this.hide(); +}; + +/** + * Creates the dialog. + */ +ViewerSelector.prototype.createDialog_ = function(options) { + var container = document.createElement('div'); + container.classList.add(CLASS_NAME); + container.style.display = 'none'; + // Create an overlay that dims the background, and which goes away when you + // tap it. + var overlay = document.createElement('div'); + var s = overlay.style; + s.position = 'fixed'; + s.left = 0; + s.top = 0; + s.width = '100%'; + s.height = '100%'; + s.background = 'rgba(0, 0, 0, 0.3)'; + overlay.addEventListener('click', this.hide.bind(this)); + + var width = 280; + var dialog = document.createElement('div'); + var s = dialog.style; + s.boxSizing = 'border-box'; + s.position = 'fixed'; + s.top = '24px'; + s.left = '50%'; + s.marginLeft = (-width/2) + 'px'; + s.width = width + 'px'; + s.padding = '24px'; + s.overflow = 'hidden'; + s.background = '#fafafa'; + s.fontFamily = "'Roboto', sans-serif"; + s.boxShadow = '0px 5px 20px #666'; + + dialog.appendChild(this.createH1_('Select your viewer')); + for (var id in options) { + dialog.appendChild(this.createChoice_(id, options[id].label)); + } + dialog.appendChild(this.createButton_('Save', this.onSave_.bind(this))); + + container.appendChild(overlay); + container.appendChild(dialog); + + return container; +}; + +ViewerSelector.prototype.createH1_ = function(name) { + var h1 = document.createElement('h1'); + var s = h1.style; + s.color = 'black'; + s.fontSize = '20px'; + s.fontWeight = 'bold'; + s.marginTop = 0; + s.marginBottom = '24px'; + h1.innerHTML = name; + return h1; +}; + +ViewerSelector.prototype.createChoice_ = function(id, name) { + /* +

+ + +
+ */ + var div = document.createElement('div'); + div.style.marginTop = '8px'; + div.style.color = 'black'; + + var input = document.createElement('input'); + input.style.fontSize = '30px'; + input.setAttribute('id', id); + input.setAttribute('type', 'radio'); + input.setAttribute('value', id); + input.setAttribute('name', 'field'); + + var label = document.createElement('label'); + label.style.marginLeft = '4px'; + label.setAttribute('for', id); + label.innerHTML = name; + + div.appendChild(input); + div.appendChild(label); + + return div; +}; + +ViewerSelector.prototype.createButton_ = function(label, onclick) { + var button = document.createElement('button'); + button.innerHTML = label; + var s = button.style; + s.float = 'right'; + s.textTransform = 'uppercase'; + s.color = '#1094f7'; + s.fontSize = '14px'; + s.letterSpacing = 0; + s.border = 0; + s.background = 'none'; + s.marginTop = '16px'; + + button.addEventListener('click', onclick); + + return button; +}; + +module.exports = ViewerSelector; + +},{"./device-info.js":8,"./util.js":22,"eventemitter3":1}],24:[function(_dereq_,module,exports){ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * 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. + */ + +var Util = _dereq_('./util.js'); + +/** + * Android and iOS compatible wakelock implementation. + * + * Refactored thanks to dkovalev@. + */ +function AndroidWakeLock() { + var video = document.createElement('video'); + video.setAttribute('loop', ''); + + function addSourceToVideo(element, type, dataURI) { + var source = document.createElement('source'); + source.src = dataURI; + source.type = 'video/' + type; + element.appendChild(source); + } + + addSourceToVideo(video,'webm', Util.base64('video/webm', 'GkXfo0AgQoaBAUL3gQFC8oEEQvOBCEKCQAR3ZWJtQoeBAkKFgQIYU4BnQI0VSalmQCgq17FAAw9CQE2AQAZ3aGFtbXlXQUAGd2hhbW15RIlACECPQAAAAAAAFlSua0AxrkAu14EBY8WBAZyBACK1nEADdW5kh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AAAAAAABAAAALAAAAGB1ZHRhAAAAWG1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAAK2lsc3QAAAAjqXRvbwAAABtkYXRhAAAAAQAAAABMYXZmNTIuNzguMw==')); + + this.request = function() { + if (video.paused) { + video.play(); + } + }; + + this.release = function() { + video.pause(); + }; +} + +function iOSWakeLock() { + var timer = null; + + this.request = function() { + if (!timer) { + timer = setInterval(function() { + window.location = window.location; + setTimeout(window.stop, 0); + }, 30000); + } + } + + this.release = function() { + if (timer) { + clearInterval(timer); + timer = null; + } + } +} + + +function getWakeLock() { + var userAgent = navigator.userAgent || navigator.vendor || window.opera; + if (userAgent.match(/iPhone/i) || userAgent.match(/iPod/i)) { + return iOSWakeLock; + } else { + return AndroidWakeLock; + } +} + +module.exports = getWakeLock(); +},{"./util.js":22}],25:[function(_dereq_,module,exports){ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * 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. + */ + +var Util = _dereq_('./util.js'); +var CardboardVRDisplay = _dereq_('./cardboard-vr-display.js'); +var MouseKeyboardVRDisplay = _dereq_('./mouse-keyboard-vr-display.js'); +// Uncomment to add positional tracking via webcam. +//var WebcamPositionSensorVRDevice = require('./webcam-position-sensor-vr-device.js'); +var VRDisplay = _dereq_('./base.js').VRDisplay; +var VRFrameData = _dereq_('./base.js').VRFrameData; +var HMDVRDevice = _dereq_('./base.js').HMDVRDevice; +var PositionSensorVRDevice = _dereq_('./base.js').PositionSensorVRDevice; +var VRDisplayHMDDevice = _dereq_('./display-wrappers.js').VRDisplayHMDDevice; +var VRDisplayPositionSensorDevice = _dereq_('./display-wrappers.js').VRDisplayPositionSensorDevice; + +function WebVRPolyfill() { + this.displays = []; + this.devices = []; // For deprecated objects + this.devicesPopulated = false; + this.nativeWebVRAvailable = this.isWebVRAvailable(); + this.nativeLegacyWebVRAvailable = this.isDeprecatedWebVRAvailable(); + this.nativeGetVRDisplaysFunc = this.nativeWebVRAvailable ? + navigator.getVRDisplays : + null; + + if (!this.nativeLegacyWebVRAvailable) { + this.enablePolyfill(); + if (window.WebVRConfig.ENABLE_DEPRECATED_API) { + this.enableDeprecatedPolyfill(); + } + } + + // Put a shim in place to update the API to 1.1 if needed. + InstallWebVRSpecShim(); +} + +WebVRPolyfill.prototype.isWebVRAvailable = function() { + return ('getVRDisplays' in navigator); +}; + +WebVRPolyfill.prototype.isDeprecatedWebVRAvailable = function() { + return ('getVRDevices' in navigator) || ('mozGetVRDevices' in navigator); +}; + +WebVRPolyfill.prototype.populateDevices = function() { + if (this.devicesPopulated) { + return; + } + + // Initialize our virtual VR devices. + var vrDisplay = null; + + // Add a Cardboard VRDisplay on compatible mobile devices + if (this.isCardboardCompatible()) { + vrDisplay = new CardboardVRDisplay(); + this.displays.push(vrDisplay); + + // For backwards compatibility + if (window.WebVRConfig.ENABLE_DEPRECATED_API) { + this.devices.push(new VRDisplayHMDDevice(vrDisplay)); + this.devices.push(new VRDisplayPositionSensorDevice(vrDisplay)); + } + } + + // Add a Mouse and Keyboard driven VRDisplay for desktops/laptops + if (!this.isMobile() && !window.WebVRConfig.MOUSE_KEYBOARD_CONTROLS_DISABLED) { + vrDisplay = new MouseKeyboardVRDisplay(); + this.displays.push(vrDisplay); + + // For backwards compatibility + if (window.WebVRConfig.ENABLE_DEPRECATED_API) { + this.devices.push(new VRDisplayHMDDevice(vrDisplay)); + this.devices.push(new VRDisplayPositionSensorDevice(vrDisplay)); + } + } + + // Uncomment to add positional tracking via webcam. + //if (!this.isMobile() && window.WebVRConfig.ENABLE_DEPRECATED_API) { + // positionDevice = new WebcamPositionSensorVRDevice(); + // this.devices.push(positionDevice); + //} + + this.devicesPopulated = true; +}; + +WebVRPolyfill.prototype.enablePolyfill = function() { + // Provide navigator.getVRDisplays. + navigator.getVRDisplays = this.getVRDisplays.bind(this); + + // Polyfill native VRDisplay.getFrameData + if (this.nativeWebVRAvailable && window.VRFrameData) { + var nativeFrameData = new window.VRFrameData(); + var nativeGetFrameData = window.VRDisplay.prototype.getFrameData; + window.VRFrameData = VRFrameData; + + window.VRDisplay.prototype.getFrameData = function(frameData) { + /* + Copy frame data from the native object into the polyfilled object. + */ + + nativeGetFrameData.call(this, nativeFrameData); + frameData.pose = nativeFrameData.pose; + Util.copyArray(nativeFrameData.leftProjectionMatrix, frameData.leftProjectionMatrix); + Util.copyArray(nativeFrameData.rightProjectionMatrix, frameData.rightProjectionMatrix); + Util.copyArray(nativeFrameData.leftViewMatrix, frameData.leftViewMatrix); + Util.copyArray(nativeFrameData.rightViewMatrix, frameData.rightViewMatrix); + //todo: copy + }; + } + + // Provide the `VRDisplay` object. + window.VRDisplay = VRDisplay; + + // Provide the `navigator.vrEnabled` property. + if (navigator && !navigator.vrEnabled) { + var self = this; + Object.defineProperty(navigator, 'vrEnabled', { + get: function () { + return self.isCardboardCompatible() && + (self.isFullScreenAvailable() || Util.isIOS()); + } + }); + } + + if (!('VRFrameData' in window)) { + // Provide the VRFrameData object. + window.VRFrameData = VRFrameData; + } +}; + +WebVRPolyfill.prototype.enableDeprecatedPolyfill = function() { + // Provide navigator.getVRDevices. + navigator.getVRDevices = this.getVRDevices.bind(this); + + // Provide the CardboardHMDVRDevice and PositionSensorVRDevice objects. + window.HMDVRDevice = HMDVRDevice; + window.PositionSensorVRDevice = PositionSensorVRDevice; +}; + +WebVRPolyfill.prototype.getVRDisplays = function() { + this.populateDevices(); + var polyfillDisplays = this.displays; + + if (this.nativeWebVRAvailable) { + return this.nativeGetVRDisplaysFunc.call(navigator).then(function(nativeDisplays) { + if (window.WebVRConfig.ALWAYS_APPEND_POLYFILL_DISPLAY) { + return nativeDisplays.concat(polyfillDisplays); + } else { + return nativeDisplays.length > 0 ? nativeDisplays : polyfillDisplays; + } + }); + } else { + return new Promise(function(resolve, reject) { + try { + resolve(polyfillDisplays); + } catch (e) { + reject(e); + } + }); + } +}; + +WebVRPolyfill.prototype.getVRDevices = function() { + console.warn('getVRDevices is deprecated. Please update your code to use getVRDisplays instead.'); + var self = this; + return new Promise(function(resolve, reject) { + try { + if (!self.devicesPopulated) { + if (self.nativeWebVRAvailable) { + return navigator.getVRDisplays(function(displays) { + for (var i = 0; i < displays.length; ++i) { + self.devices.push(new VRDisplayHMDDevice(displays[i])); + self.devices.push(new VRDisplayPositionSensorDevice(displays[i])); + } + self.devicesPopulated = true; + resolve(self.devices); + }, reject); + } + + if (self.nativeLegacyWebVRAvailable) { + return (navigator.getVRDDevices || navigator.mozGetVRDevices)(function(devices) { + for (var i = 0; i < devices.length; ++i) { + if (devices[i] instanceof HMDVRDevice) { + self.devices.push(devices[i]); + } + if (devices[i] instanceof PositionSensorVRDevice) { + self.devices.push(devices[i]); + } + } + self.devicesPopulated = true; + resolve(self.devices); + }, reject); + } + } + + self.populateDevices(); + resolve(self.devices); + } catch (e) { + reject(e); + } + }); +}; + +/** + * Determine if a device is mobile. + */ +WebVRPolyfill.prototype.isMobile = function() { + return /Android/i.test(navigator.userAgent) || + /iPhone|iPad|iPod/i.test(navigator.userAgent); +}; + +WebVRPolyfill.prototype.isCardboardCompatible = function() { + // For now, support all iOS and Android devices. + // Also enable the WebVRConfig.FORCE_VR flag for debugging. + return this.isMobile() || window.WebVRConfig.FORCE_ENABLE_VR; +}; + +WebVRPolyfill.prototype.isFullScreenAvailable = function() { + return (document.fullscreenEnabled || + document.mozFullScreenEnabled || + document.webkitFullscreenEnabled || + false); +}; + +// Installs a shim that updates a WebVR 1.0 spec implementation to WebVR 1.1 +function InstallWebVRSpecShim() { + if ('VRDisplay' in window && !('VRFrameData' in window)) { + // Provide the VRFrameData object. + window.VRFrameData = VRFrameData; + + // A lot of Chrome builds don't have depthNear and depthFar, even + // though they're in the WebVR 1.0 spec. Patch them in if they're not present. + if(!('depthNear' in window.VRDisplay.prototype)) { + window.VRDisplay.prototype.depthNear = 0.01; + } + + if(!('depthFar' in window.VRDisplay.prototype)) { + window.VRDisplay.prototype.depthFar = 10000.0; + } + + window.VRDisplay.prototype.getFrameData = function(frameData) { + return Util.frameDataFromPose(frameData, this.getPose(), this); + } + } +}; + +module.exports.WebVRPolyfill = WebVRPolyfill; + +},{"./base.js":3,"./cardboard-vr-display.js":6,"./display-wrappers.js":9,"./mouse-keyboard-vr-display.js":15,"./util.js":22}]},{},[13])(13) +}); diff --git a/dist/js/third-party/wglu/wglu-url.js b/dist/js/third-party/wglu/wglu-url.js new file mode 100644 index 0000000..0d489e6 --- /dev/null +++ b/dist/js/third-party/wglu/wglu-url.js @@ -0,0 +1,99 @@ +/* +Copyright (c) 2015, Brandon Jones. + +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 + +WGLUUrl.getInt("particleCount", 100); // URL overrides, returns 1000 +WGLUUrl.getInt("particleSize", 10); // Not in URL, returns default of 10 +*/ +var WGLUUrl = (function() { + + "use strict"; + + 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()] = unescape(pair[1]); + } + } + } + + function getString(name, defaultValue) { + ensureArgsCached(); + var lcaseName = name.toLowerCase(); + if (lcaseName in urlArgs) { + return urlArgs[lcaseName]; + } + return defaultValue; + } + + function getInt(name, defaultValue) { + ensureArgsCached(); + var lcaseName = name.toLowerCase(); + if (lcaseName in urlArgs) { + return parseInt(urlArgs[lcaseName], 10); + } + return defaultValue; + } + + function getFloat(name, defaultValue) { + ensureArgsCached(); + var lcaseName = name.toLowerCase(); + if (lcaseName in urlArgs) { + return parseFloat(urlArgs[lcaseName]); + } + return defaultValue; + } + + function getBool(name, defaultValue) { + ensureArgsCached(); + var lcaseName = name.toLowerCase(); + if (lcaseName in urlArgs) { + return parseInt(urlArgs[lcaseName], 10) != 0; + } + return defaultValue; + } + + return { + getString: getString, + getInt: getInt, + getFloat: getFloat, + getBool: getBool + }; +})(); diff --git a/media/cube.obj b/dist/media/cube.obj similarity index 100% rename from media/cube.obj rename to dist/media/cube.obj diff --git a/media/cubeDual.obj b/dist/media/cubeDual.obj similarity index 100% rename from media/cubeDual.obj rename to dist/media/cubeDual.obj diff --git a/media/cubeThickEdges.obj b/dist/media/cubeThickEdges.obj similarity index 100% rename from media/cubeThickEdges.obj rename to dist/media/cubeThickEdges.obj diff --git a/media/cube_old.obj b/dist/media/cube_old.obj similarity index 100% rename from media/cube_old.obj rename to dist/media/cube_old.obj diff --git a/media/euc_monkey_cut_1p5k.obj b/dist/media/euc_monkey_cut_1p5k.obj similarity index 100% rename from media/euc_monkey_cut_1p5k.obj rename to dist/media/euc_monkey_cut_1p5k.obj diff --git a/media/euc_monkey_cut_3k.obj b/dist/media/euc_monkey_cut_3k.obj similarity index 100% rename from media/euc_monkey_cut_3k.obj rename to dist/media/euc_monkey_cut_3k.obj diff --git a/media/euc_monkey_cut_750.obj b/dist/media/euc_monkey_cut_750.obj similarity index 100% rename from media/euc_monkey_cut_750.obj rename to dist/media/euc_monkey_cut_750.obj diff --git a/media/euc_monkey_cut_7p5k.obj b/dist/media/euc_monkey_cut_7p5k.obj similarity index 100% rename from media/euc_monkey_cut_7p5k.obj rename to dist/media/euc_monkey_cut_7p5k.obj diff --git a/media/rhombicDodec.obj b/dist/media/rhombicDodec.obj similarity index 100% rename from media/rhombicDodec.obj rename to dist/media/rhombicDodec.obj diff --git a/media/screen2Cube.obj b/dist/media/screen2Cube.obj similarity index 100% rename from media/screen2Cube.obj rename to dist/media/screen2Cube.obj diff --git a/media/truncatedCube.obj b/dist/media/truncatedCube.obj similarity index 100% rename from media/truncatedCube.obj rename to dist/media/truncatedCube.obj diff --git a/media/truncatedCubeBdry.obj b/dist/media/truncatedCubeBdry.obj similarity index 100% rename from media/truncatedCubeBdry.obj rename to dist/media/truncatedCubeBdry.obj diff --git a/media/truncatedCubeMinimal.obj b/dist/media/truncatedCubeMinimal.obj similarity index 100% rename from media/truncatedCubeMinimal.obj rename to dist/media/truncatedCubeMinimal.obj diff --git a/media/truncatedCubeTrisOnly.obj b/dist/media/truncatedCubeTrisOnly.obj similarity index 100% rename from media/truncatedCubeTrisOnly.obj rename to dist/media/truncatedCubeTrisOnly.obj diff --git a/js/436.js b/js/436.js deleted file mode 100644 index e9babc4..0000000 --- a/js/436.js +++ /dev/null @@ -1,87 +0,0 @@ -// Schlafli symbol {4,3,6} is cubes with 6 around each edge - -function acosh(arg) { - // discuss at: http://phpjs.org/functions/acosh/ - // original by: Onno Marsman - // example 1: acosh(8723321.4); - // returns 1: 16.674657798418625 - - return Math.log(arg + Math.sqrt(arg * arg - 1)); -} - -var dist = 2*acosh( Math.sqrt(1.5) ) - -//use translateByVector from VRControlsHyperbolic.js - -// var tilingGens = -// [ -// new THREE.Matrix4(), //id matrix -// translateByVector(new THREE.Vector3(dist,0,0)), -// translateByVector(new THREE.Vector3(-dist,0,0)), -// translateByVector(new THREE.Vector3(0,dist,0)), -// translateByVector(new THREE.Vector3(0,-dist,0)), -// translateByVector(new THREE.Vector3(0,0,dist)), -// translateByVector(new THREE.Vector3(0,0,-dist)) -// ]; - -var rotx = new THREE.Matrix4().makeRotationX( Math.PI/2 ); -var rotxi = new THREE.Matrix4().makeRotationX( -Math.PI/2 ); -var roty = new THREE.Matrix4().makeRotationY( Math.PI/2 ); -var rotyi = new THREE.Matrix4().makeRotationY( -Math.PI/2 ); -var rotz = new THREE.Matrix4().makeRotationZ( Math.PI/2 ); -var rotzi = new THREE.Matrix4().makeRotationZ( -Math.PI/2 ); - - -var tilingGens = -[ -new THREE.Matrix4().identity(), //id matrix -rotxi.multiply( translateByVector(new THREE.Vector3(dist,0,0)) ), -rotx.multiply( translateByVector(new THREE.Vector3(-dist,0,0)) ), -rotyi.multiply( translateByVector(new THREE.Vector3(0,dist,0)) ), -roty.multiply( translateByVector(new THREE.Vector3(0,-dist,0)) ), -rotzi.multiply( translateByVector(new THREE.Vector3(0,0,dist)) ), -rotz.multiply( translateByVector(new THREE.Vector3(0,0,-dist)) ) -]; ///these multiplies are consistent with left hand screw monkeys - -var genQuatsColourSchemes = -[ - [ //// 8 colours untwisted - new THREE.Quaternion(0,0,0,1), - new THREE.Quaternion(-1,0,0,0), - new THREE.Quaternion(1,0,0,0), - new THREE.Quaternion(0,-1,0,0), - new THREE.Quaternion(0,1,0,0), - new THREE.Quaternion(0,0,-1,0), - new THREE.Quaternion(0,0,1,0) - ], - [ //// 8 colours twisted - new THREE.Quaternion(0,0,0,1), - new THREE.Quaternion(1,0,0,0), - new THREE.Quaternion(-1,0,0,0), - new THREE.Quaternion(0,1,0,0), - new THREE.Quaternion(0,-1,0,0), - new THREE.Quaternion(0,0,1,0), - new THREE.Quaternion(0,0,-1,0) - ], - [ //// 2 colours - new THREE.Quaternion(0,0,0,1), - new THREE.Quaternion(0,0,0,-1), - new THREE.Quaternion(0,0,0,-1), - new THREE.Quaternion(0,0,0,-1), - new THREE.Quaternion(0,0,0,-1), - new THREE.Quaternion(0,0,0,-1), - new THREE.Quaternion(0,0,0,-1) - ] -]; - -function word2colorQuat(word) { - // word is a list of indexes into tilingGens - var quat = new THREE.Quaternion(0,0,0,1); - for (var j = 0; j < word.length; j++){ - quat.multiply( genQuatsColourSchemes[colourMode][word[j]] ) - } - return quat; -} - - - diff --git a/js/hypTiling.js b/js/hypTiling.js deleted file mode 100644 index 4d3b4c7..0000000 --- a/js/hypTiling.js +++ /dev/null @@ -1,291 +0,0 @@ -var camera; -var scene; -var renderer; -var mesh; - -var infoSprite = new THREE.Mesh(); -var effect; -var controls; -// var music = document.querySelector('#music'); -var clicky = 0; -var mouseX = 1; -var mouseY = 1; -var currentBoost = new THREE.Matrix4().set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1); - -var decorationArray = [ - 'cube', - 'cubeThickEdges', - 'truncatedCube', - 'truncatedCubeTrisOnly', - 'truncatedCubeBdry', - 'cubeDual', - 'monkey', - 'monkey2', - 'monkey3' - //'rhombicDodec' - ]; - -var decoration = "truncatedCube"; -var colourMode = 0; - -var doubleSided = false; - -var numObjects = 1; //number of obj files to load -var numGens = tilingGens.length; -var tilingDepth = 4; //default 4 - -var unpackTriple = makeTsfmsList( tilingGens, tilingDepth ); -var tsfms = unpackTriple[0]; -var words = unpackTriple[1]; -var cumulativeNumTsfms = unpackTriple[2]; - -var numTiles = tsfms.length; -var bigMatArray; - -var movedTowardsCentralCubeThisFrameIndex = false; - -function init() { - start = Date.now(); - scene = new THREE.Scene(); - camera = new THREE.PerspectiveCamera(80, window.innerWidth / window.innerHeight, 0.1, 100); - camera.position.x = 0; - camera.position.z = 0; - - renderer = new THREE.WebGLRenderer({ antialias: true }); - document.body.appendChild(renderer.domElement); - - controls = new THREE.VRControls(camera); - - effect = new THREE.VREffect(renderer); - effect.setSize(window.innerWidth, window.innerHeight); - - materialBase = new THREE.ShaderMaterial({ - uniforms: { // these are the parameters for the shader - time: { // global time - type: "f", - value: 0.0 - }, - translation: { // quaternion that moves shifts the object, set once per object - type: "m4", - value: new THREE.Matrix4().set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) - }, - boost: { - type: "m4", - value: new THREE.Matrix4().set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) - }, - cellColorQuat: { - type: "v4", - value: new THREE.Quaternion( 0,0,0,1 ) - }, - userCellColorQuat: { // which index colour the user is in - type: "v4", - value: new THREE.Quaternion( 0,0,0,1 ) - } - }, - vertexShader: document.getElementById('vertexShader').textContent, - fragmentShader: document.getElementById('fragmentShader').textContent - }); - - if (doubleSided) { - materialBase.side = THREE.DoubleSide; - } - - - - loadStuff(); - - ////// create info overlay - // var infoText = THREE.ImageUtils.loadTexture( "media/twelve-ui.png" ); - // var infoMaterial = new THREE.MeshBasicMaterial( {map: infoText, wireframe: false, color: 0x777777 }); - // var infoBox = new THREE.BoxGeometry(2,1,1); - // infoSprite = new THREE.Mesh( infoBox, infoMaterial ); - // infoSprite.position.z = -2; - // infoSprite.position.x = -.5; - // infoSprite.position.y = -1; - // infoSprite.rotation.x = -.3; - // scene.add( infoSprite ); - - effect.render(scene, camera, animate); -} - -function updateBigMatArray(){ - bigMatArray = new Array(numObjects * numTiles); - // one material per object, since they have a different positions - for (var i = 0; i < bigMatArray.length; i++) { - bigMatArray[i] = materialBase.clone(); - } -} - -function loadStuff(){ - var manager = new THREE.LoadingManager(); - var loader = new THREE.OBJLoader(manager); - - if (decoration == "monkey" || decoration == "monkey2" || decoration == "monkey3"){ - numObjects = 2; - updateBigMatArray(); - - if (decoration == "monkey"){ - var cubeDecoration = 'cube'; - } - else if (decoration == "monkey2"){ - var cubeDecoration = 'truncatedCube'; - } - else { - var cubeDecoration = 'truncatedCubeTrisOnly'; - } - /// first, coloured cube - loader.load('media/'.concat(cubeDecoration, '.obj'), function (object) { - for (var i = 0; i < numTiles; i++) { - var newObject = object.clone(); - newObject.children[0].material = bigMatArray[(i)]; - // newObject.children[0].frustumCulled = false; - scene.add(newObject); - } - }); - - /// then, non coloured monkeys - loader.load('media/euc_monkey_cut_7p5k.obj', function (object) { - for (var i = 0; i < cumulativeNumTsfms[1]; i++) { - var newObject = object.clone(); - newObject.children[0].material = bigMatArray[i + numTiles]; - // newObject.children[0].frustumCulled = false; - scene.add(newObject); - } - }); - - loader.load('media/euc_monkey_cut_3k.obj', function (object) { - for (var i = cumulativeNumTsfms[1]; i < cumulativeNumTsfms[2]; i++) { - var newObject = object.clone(); - newObject.children[0].material = bigMatArray[i + numTiles]; - // newObject.children[0].frustumCulled = false; - scene.add(newObject); - } - }); - - loader.load('media/euc_monkey_cut_1p5k.obj', function (object) { - for (var i = cumulativeNumTsfms[2]; i < cumulativeNumTsfms[3]; i++) { - var newObject = object.clone(); - newObject.children[0].material = bigMatArray[i + numTiles]; - // newObject.children[0].frustumCulled = false; - scene.add(newObject); - } - }); - - loader.load('media/euc_monkey_cut_750.obj', function (object) { - for (var i = cumulativeNumTsfms[3]; i < numTiles; i++) { - var newObject = object.clone(); - newObject.children[0].material = bigMatArray[i + numTiles]; - // newObject.children[0].frustumCulled = false; - scene.add(newObject); - } - }); - } - - else { - numObjects = 1; - updateBigMatArray(); - loader.load('media/'.concat(decoration, '.obj'), function (object) { - for (var i = 0; i < numTiles; i++) { - var newObject = object.clone(); - newObject.children[0].material = bigMatArray[(i)]; - // newObject.children[0].frustumCulled = false; - scene.add(newObject); - } - }); - } - for (var k = 0; k < numObjects; k++) { - for (var j = 0; j < numTiles; j++) { - var i = j + numTiles*k; - bigMatArray[i].uniforms['translation'].value = tsfms[j]; - if (k == 0){ - bigMatArray[i].uniforms['cellColorQuat'].value = word2colorQuat( words[j] ); - } - else { - bigMatArray[i].uniforms['cellColorQuat'].value = new THREE.Quaternion(0,0,0,0); - // all zeros quat is special cased to grey - } - // console.log(words[j]); - // console.log(word2colorQuat( words[j] )); - // console.log(bigMatArray[i].uniforms['userCellColorQuat'].value); - - - // bigMatArray[i].visible = phraseOnOffMaps[currentPhrase][k]; - } - } -} - - -function animate() { - controls.update(); // need to get movedTowardsCentralCubeThisFrameIndex before updating stuff - - - for (var k = 0; k < numObjects; k++) { - for (var j = 0; j < numTiles; j++) { - var i = j + numTiles*k; - bigMatArray[i].uniforms['boost'].value = currentBoost; - // console.log(bigMatArray[i].uniforms['userCellColorQuat'].value); - if (movedTowardsCentralCubeThisFrameIndex != false) { - - var tempQuat = new THREE.Quaternion(); - tempQuat.copy(bigMatArray[i].uniforms['userCellColorQuat'].value); - tempQuat.multiply(genQuatsColourSchemes[colourMode][movedTowardsCentralCubeThisFrameIndex]); - - bigMatArray[i].uniforms['userCellColorQuat'].value = tempQuat; - /// always act on a uniform by setting it equal to something, other stuff breaks in incomprehensible ways... - - - // console.log(movedTowardsCentralCubeThisFrameIndex); - // console.log(genQuats[movedTowardsCentralCubeThisFrameIndex]); - // console.log(bigMatArray[i].uniforms['userCellColorQuat'].value); - } - - - // bigMatArray[i].visible = phraseOnOffMaps[currentPhrase][k]; - } - } - - effect.render(scene, camera, animate); - // requestAnimationFrame(animate); -} - -document.addEventListener('keydown', function(event) { selectShape(event); }, false); - -function selectShape(event) { - - var keySelect = event.keyCode - 48; //1 is 49 - - if (keySelect > 0 && keySelect < 10){ - if (scene) { - while (scene.children.length > 0) { - scene.remove(scene.children[scene.children.length - 1]); - } - decoration = decorationArray[(keySelect-1)]; - loadStuff(); - } - } -} - -document.addEventListener('keydown', function(event) { changeColourMode(event); }, false); - -function changeColourMode(event) { - - var keySelect = event.keyCode; - - if (keySelect == 67){ //c - if (scene) { - while (scene.children.length > 0) { - scene.remove(scene.children[scene.children.length - 1]); - } - colourMode = (colourMode + 1) % genQuatsColourSchemes.length; - loadStuff(); - } - } -} - -init(); -animate(); - -//Listen for double click event to enter full-screen VR mode -document.body.addEventListener( 'click', function() { - effect.setFullScreen( true ); -}); diff --git a/js/lib/three.min.js b/js/lib/three.min.js deleted file mode 100755 index 47cb69e..0000000 --- a/js/lib/three.min.js +++ /dev/null @@ -1,838 +0,0 @@ -// threejs.org/license -(function(l,sa){"object"===typeof exports&&"undefined"!==typeof module?sa(exports):"function"===typeof define&&define.amd?define(["exports"],sa):sa(l.THREE=l.THREE||{})})(this,function(l){function sa(){}function B(a,b){this.x=a||0;this.y=b||0}function da(a,b,c,d,e,f,g,h,k,m){Object.defineProperty(this,"id",{value:ee++});this.uuid=T.generateUUID();this.sourceFile=this.name="";this.image=void 0!==a?a:da.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==b?b:da.DEFAULT_MAPPING;this.wrapS=void 0!==c? -c:1001;this.wrapT=void 0!==d?d:1001;this.magFilter=void 0!==e?e:1006;this.minFilter=void 0!==f?f:1008;this.anisotropy=void 0!==k?k:1;this.format=void 0!==g?g:1023;this.type=void 0!==h?h:1009;this.offset=new B(0,0);this.repeat=new B(1,1);this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.unpackAlignment=4;this.encoding=void 0!==m?m:3E3;this.version=0;this.onUpdate=null}function ga(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}function Db(a,b,c){this.uuid=T.generateUUID(); -this.width=a;this.height=b;this.scissor=new ga(0,0,a,b);this.scissorTest=!1;this.viewport=new ga(0,0,a,b);c=c||{};void 0===c.minFilter&&(c.minFilter=1006);this.texture=new da(void 0,void 0,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy,c.encoding);this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.depthTexture=void 0!==c.depthTexture?c.depthTexture:null}function Eb(a,b,c){Db.call(this,a,b,c);this.activeMipMapLevel= -this.activeCubeFace=0}function ba(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1}function q(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}function J(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);0= -d||0 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n")); -y.compileShader(P);y.compileShader(R);y.attachShader(N,P);y.attachShader(N,R);y.linkProgram(N);M=N;u=y.getAttribLocation(M,"position");v=y.getAttribLocation(M,"uv");c=y.getUniformLocation(M,"uvOffset");d=y.getUniformLocation(M,"uvScale");e=y.getUniformLocation(M,"rotation");f=y.getUniformLocation(M,"scale");g=y.getUniformLocation(M,"color");h=y.getUniformLocation(M,"map");k=y.getUniformLocation(M,"opacity");m=y.getUniformLocation(M,"modelViewMatrix");w=y.getUniformLocation(M,"projectionMatrix");n= -y.getUniformLocation(M,"fogType");p=y.getUniformLocation(M,"fogDensity");r=y.getUniformLocation(M,"fogNear");x=y.getUniformLocation(M,"fogFar");l=y.getUniformLocation(M,"fogColor");D=y.getUniformLocation(M,"alphaTest");N=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");N.width=8;N.height=8;P=N.getContext("2d");P.fillStyle="white";P.fillRect(0,0,8,8);ca=new da(N);ca.needsUpdate=!0}y.useProgram(M);E.initAttributes();E.enableAttribute(u);E.enableAttribute(v);E.disableUnusedAttributes(); -E.disable(y.CULL_FACE);E.enable(y.BLEND);y.bindBuffer(y.ARRAY_BUFFER,H);y.vertexAttribPointer(u,2,y.FLOAT,!1,16,0);y.vertexAttribPointer(v,2,y.FLOAT,!1,16,8);y.bindBuffer(y.ELEMENT_ARRAY_BUFFER,F);y.uniformMatrix4fv(w,!1,Ka.projectionMatrix.elements);E.activeTexture(y.TEXTURE0);y.uniform1i(h,0);P=N=0;(R=q.fog)?(y.uniform3f(l,R.color.r,R.color.g,R.color.b),R&&R.isFog?(y.uniform1f(r,R.near),y.uniform1f(x,R.far),y.uniform1i(n,1),P=N=1):R&&R.isFogExp2&&(y.uniform1f(p,R.density),y.uniform1i(n,2),P=N=2)): -(y.uniform1i(n,0),P=N=0);for(var R=0,S=b.length;R/g,function(a,c){var d=X[c];if(void 0===d)throw Error("Can not resolve #include <"+c+">");return Cd(d)})}function ve(a){return a.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(a,c,d,e){a="";for(c=parseInt(c);cb||a.height>b){var c=b/Math.max(a.width,a.height),d=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");d.width=Math.floor(a.width*c);d.height=Math.floor(a.height*c);d.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,d.width,d.height);console.warn("THREE.WebGLRenderer: image is too big ("+a.width+"x"+a.height+"). Resized to "+d.width+"x"+d.height,a);return d}return a} -function k(a){return T.isPowerOfTwo(a.width)&&T.isPowerOfTwo(a.height)}function m(b){return 1003===b||1004===b||1005===b?a.NEAREST:a.LINEAR}function w(b){b=b.target;b.removeEventListener("dispose",w);a:{var c=d.get(b);if(b.image&&c.__image__webglTextureCube)a.deleteTexture(c.__image__webglTextureCube);else{if(void 0===c.__webglInit)break a;a.deleteTexture(c.__webglTexture)}d["delete"](b)}q.textures--}function n(b){b=b.target;b.removeEventListener("dispose",n);var c=d.get(b),e=d.get(b.texture);if(b){void 0!== -e.__webglTexture&&a.deleteTexture(e.__webglTexture);b.depthTexture&&b.depthTexture.dispose();if(b&&b.isWebGLRenderTargetCube)for(e=0;6>e;e++)a.deleteFramebuffer(c.__webglFramebuffer[e]),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer[e]);else a.deleteFramebuffer(c.__webglFramebuffer),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer);d["delete"](b.texture);d["delete"](b)}q.textures--}function p(b,g){var m=d.get(b);if(0x;x++)l[x]=p||n?n?b.image[x].image:b.image[x]:h(b.image[x],e.maxCubemapSize);var t=k(l[0]),u=f(b.format),ja=f(b.type);r(a.TEXTURE_CUBE_MAP, -b,t);for(x=0;6>x;x++)if(p)for(var B,C=l[x].mipmaps,z=0,N=C.length;zm;m++)e.__webglFramebuffer[m]=a.createFramebuffer()}else e.__webglFramebuffer=a.createFramebuffer();if(g){c.bindTexture(a.TEXTURE_CUBE_MAP,f.__webglTexture);r(a.TEXTURE_CUBE_MAP,b.texture,h);for(m=0;6>m;m++)l(e.__webglFramebuffer[m],b,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+m);b.texture.generateMipmaps&&h&&a.generateMipmap(a.TEXTURE_CUBE_MAP);c.bindTexture(a.TEXTURE_CUBE_MAP, -null)}else c.bindTexture(a.TEXTURE_2D,f.__webglTexture),r(a.TEXTURE_2D,b.texture,h),l(e.__webglFramebuffer,b,a.COLOR_ATTACHMENT0,a.TEXTURE_2D),b.texture.generateMipmaps&&h&&a.generateMipmap(a.TEXTURE_2D),c.bindTexture(a.TEXTURE_2D,null);if(b.depthBuffer){e=d.get(b);f=b&&b.isWebGLRenderTargetCube;if(b.depthTexture){if(f)throw Error("target.depthTexture not supported in Cube render targets");if(b&&b.isWebGLRenderTargetCube)throw Error("Depth Texture with cube render targets is not supported!");a.bindFramebuffer(a.FRAMEBUFFER, -e.__webglFramebuffer);if(!b.depthTexture||!b.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");d.get(b.depthTexture).__webglTexture&&b.depthTexture.image.width===b.width&&b.depthTexture.image.height===b.height||(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0);p(b.depthTexture,0);e=d.get(b.depthTexture).__webglTexture;if(1026===b.depthTexture.format)a.framebufferTexture2D(a.FRAMEBUFFER, -a.DEPTH_ATTACHMENT,a.TEXTURE_2D,e,0);else if(1027===b.depthTexture.format)a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_STENCIL_ATTACHMENT,a.TEXTURE_2D,e,0);else throw Error("Unknown depthTexture format");}else if(f)for(e.__webglDepthbuffer=[],f=0;6>f;f++)a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer[f]),e.__webglDepthbuffer[f]=a.createRenderbuffer(),t(e.__webglDepthbuffer[f],b);else a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer),e.__webglDepthbuffer=a.createRenderbuffer(),t(e.__webglDepthbuffer, -b);a.bindFramebuffer(a.FRAMEBUFFER,null)}};this.updateRenderTargetMipmap=function(b){var e=b.texture;e.generateMipmaps&&k(b)&&1003!==e.minFilter&&1006!==e.minFilter&&(b=b&&b.isWebGLRenderTargetCube?a.TEXTURE_CUBE_MAP:a.TEXTURE_2D,e=d.get(e).__webglTexture,c.bindTexture(b,e),a.generateMipmap(b),c.bindTexture(b,null))}}function xf(){var a={};return{get:function(b){b=b.uuid;var c=a[b];void 0===c&&(c={},a[b]=c);return c},"delete":function(b){delete a[b.uuid]},clear:function(){a={}}}}function yf(a,b,c){function d(b, -c,d){var e=new Uint8Array(4),f=a.createTexture();a.bindTexture(b,f);a.texParameteri(b,a.TEXTURE_MIN_FILTER,a.NEAREST);a.texParameteri(b,a.TEXTURE_MAG_FILTER,a.NEAREST);for(b=0;b=ia.maxTextures&&console.warn("WebGLRenderer: trying to use "+a+" texture units while this GPU supports only "+ia.maxTextures);da+=1;return a};this.setTexture2D=function(){var a=!1;return function(b,c){b&&b.isWebGLRenderTarget&&(a||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."), -a=!0),b=b.texture);ua.setTexture2D(b,c)}}();this.setTexture=function(){var a=!1;return function(b,c){a||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),a=!0);ua.setTexture2D(b,c)}}();this.setTextureCube=function(){var a=!1;return function(b,c){b&&b.isWebGLRenderTargetCube&&(a||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),a=!0),b=b.texture);b&&b.isCubeTexture||Array.isArray(b.image)&& -6===b.image.length?ua.setTextureCube(b,c):ua.setTextureCubeDynamic(b,c)}}();this.getCurrentRenderTarget=function(){return V};this.setRenderTarget=function(a){(V=a)&&void 0===ea.get(a).__webglFramebuffer&&ua.setupRenderTarget(a);var b=a&&a.isWebGLRenderTargetCube,c;a?(c=ea.get(a),c=b?c.__webglFramebuffer[a.activeCubeFace]:c.__webglFramebuffer,X.copy(a.scissor),fb=a.scissorTest,$a.copy(a.viewport)):(c=null,X.copy(ha).multiplyScalar(Qa),fb=la,$a.copy(fa).multiplyScalar(Qa));T!==c&&(A.bindFramebuffer(A.FRAMEBUFFER, -c),T=c);Y.scissor(X);Y.setScissorTest(fb);Y.viewport($a);b&&(b=ea.get(a.texture),A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_CUBE_MAP_POSITIVE_X+a.activeCubeFace,b.__webglTexture,a.activeMipMapLevel))};this.readRenderTargetPixels=function(a,b,c,d,e,f){if(!1===(a&&a.isWebGLRenderTarget))console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");else{var g=ea.get(a).__webglFramebuffer;if(g){var h=!1;g!==T&&(A.bindFramebuffer(A.FRAMEBUFFER, -g),h=!0);try{var k=a.texture,m=k.format,n=k.type;1023!==m&&u(m)!==A.getParameter(A.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):1009===n||u(n)===A.getParameter(A.IMPLEMENTATION_COLOR_READ_TYPE)||1015===n&&(ka.get("OES_texture_float")||ka.get("WEBGL_color_buffer_float"))||1016===n&&ka.get("EXT_color_buffer_half_float")?A.checkFramebufferStatus(A.FRAMEBUFFER)===A.FRAMEBUFFER_COMPLETE?0<=b&& -b<=a.width-d&&0<=c&&c<=a.height-e&&A.readPixels(b,c,d,e,u(m),u(n),f):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{h&&A.bindFramebuffer(A.FRAMEBUFFER,T)}}}}}function Ib(a,b){this.name="";this.color=new O(a);this.density=void 0!==b?b:2.5E-4}function Jb(a,b,c){this.name="";this.color= -new O(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3}function jb(){z.call(this);this.type="Scene";this.overrideMaterial=this.fog=this.background=null;this.autoUpdate=!0}function Ed(a,b,c,d,e){z.call(this);this.lensFlares=[];this.positionScreen=new q;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,e)}function kb(a){U.call(this);this.type="SpriteMaterial";this.color=new O(16777215);this.map=null;this.rotation=0;this.lights=this.fog=!1;this.setValues(a)}function qc(a){z.call(this); -this.type="Sprite";this.material=void 0!==a?a:new kb}function rc(){z.call(this);this.type="LOD";Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function lb(a,b,c,d,e,f,g,h,k,m,w,n){da.call(this,null,f,g,h,k,m,d,e,w,n);this.image={data:a,width:b,height:c};this.magFilter=void 0!==k?k:1003;this.minFilter=void 0!==m?m:1003;this.flipY=this.generateMipmaps=!1;this.unpackAlignment=1}function bd(a,b,c){this.useVertexTexture=void 0!==c?c:!0;this.identityMatrix=new J;a=a||[];this.bones=a.slice(0); -this.useVertexTexture?(a=Math.sqrt(4*this.bones.length),a=T.nextPowerOfTwo(Math.ceil(a)),this.boneTextureHeight=this.boneTextureWidth=a=Math.max(a,4),this.boneMatrices=new Float32Array(this.boneTextureWidth*this.boneTextureHeight*4),this.boneTexture=new lb(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,1023,1015)):this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===b)this.calculateInverses();else if(this.bones.length===b.length)this.boneInverses=b.slice(0);else for(console.warn("THREE.Skeleton bonInverses is the wrong length."), -this.boneInverses=[],b=0,a=this.bones.length;b=a.HAVE_CURRENT_DATA&&(w.needsUpdate=!0)}da.call(this,a,b,c,d,e,f,g,h,k);this.generateMipmaps=!1;var w=this;m()}function Lb(a,b,c,d,e,f,g,h,k,m,w,n){da.call(this,null,f,g,h,k,m,d,e,w,n);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=this.flipY=!1}function fd(a,b,c,d,e,f,g,h,k){da.call(this,a,b,c,d,e,f,g,h,k);this.needsUpdate=!0}function tc(a,b,c,d,e,f,g, -h,k,m){m=void 0!==m?m:1026;if(1026!==m&&1027!==m)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");da.call(this,null,d,e,f,g,h,m,c,k);this.image={width:a,height:b};this.type=void 0!==c?c:1012;this.magFilter=void 0!==g?g:1003;this.minFilter=void 0!==h?h:1003;this.generateMipmaps=this.flipY=!1}function Mb(a){function b(a,b){return a-b}G.call(this);var c=[0,0],d={},e=["a","b","c"];if(a&&a.isGeometry){var f=a.vertices,g=a.faces,h=0,k=new Uint32Array(6*g.length); -a=0;for(var m=g.length;an;n++){c[0]=w[e[n]];c[1]=w[e[(n+1)%3]];c.sort(b);var p=c.toString();void 0===d[p]&&(k[2*h]=c[0],k[2*h+1]=c[1],d[p]=!0,h++)}c=new Float32Array(6*h);a=0;for(m=h;an;n++)d=f[k[2*a+n]],h=6*a+3*n,c[h+0]=d.x,c[h+1]=d.y,c[h+2]=d.z;this.addAttribute("position",new C(c,3))}else if(a&&a.isBufferGeometry){if(null!==a.index){m=a.index.array;f=a.attributes.position;e=a.groups;h=0;0===e.length&&a.addGroup(0,m.length);k=new Uint32Array(2*m.length); -g=0;for(w=e.length;gn;n++)c[0]=m[a+n],c[1]=m[a+(n+1)%3],c.sort(b),p=c.toString(),void 0===d[p]&&(k[2*h]=c[0],k[2*h+1]=c[1],d[p]=!0,h++)}c=new Float32Array(6*h);a=0;for(m=h;an;n++)h=6*a+3*n,d=k[2*a+n],c[h+0]=f.getX(d),c[h+1]=f.getY(d),c[h+2]=f.getZ(d)}else for(f=a.attributes.position.array,h=f.length/3,k=h/3,c=new Float32Array(6*h),a=0,m=k;an;n++)h=18*a+6*n,k=9*a+3*n,c[h+0]=f[k],c[h+1]=f[k+1], -c[h+2]=f[k+2],d=9*a+(n+1)%3*3,c[h+3]=f[d],c[h+4]=f[d+1],c[h+5]=f[d+2];this.addAttribute("position",new C(c,3))}}function Nb(a,b,c){G.call(this);this.type="ParametricBufferGeometry";this.parameters={func:a,slices:b,stacks:c};var d=[],e=[],f,g,h,k,m,w=b+1;for(f=0;f<=c;f++)for(m=f/c,g=0;g<=b;g++)k=g/b,h=a(k,m),d.push(h.x,h.y,h.z),e.push(k,m);a=[];var n;for(f=0;fd&&1===a.x&&(k[b]=a.x-1);0===c.x&&0===c.z&&(k[b]=d/2/Math.PI+.5)}G.call(this);this.type="PolyhedronBufferGeometry";this.parameters= -{vertices:a,indices:b,radius:c,detail:d};c=c||1;var h=[],k=[];(function(a){for(var c=new q,d=new q,g=new q,h=0;he&&(.2>b&&(k[a+0]+=1),.2>c&&(k[a+2]+=1),.2>d&&(k[a+4]+=1))})();this.addAttribute("position",ha(h,3));this.addAttribute("normal",ha(h.slice(),3));this.addAttribute("uv",ha(k,2));this.normalizeNormals();this.boundingSphere=new Ca(new q, -c)}function Ob(a,b){ua.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],a,b);this.type="TetrahedronBufferGeometry";this.parameters={radius:a,detail:b}}function vc(a,b){Q.call(this);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Ob(a,b));this.mergeVertices()}function Pb(a,b){ua.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],a,b);this.type="OctahedronBufferGeometry";this.parameters= -{radius:a,detail:b}}function wc(a,b){Q.call(this);this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Pb(a,b));this.mergeVertices()}function Qb(a,b){var c=(1+Math.sqrt(5))/2;ua.call(this,[-1,c,0,1,c,0,-1,-c,0,1,-c,0,0,-1,c,0,1,c,0,-1,-c,0,1,-c,c,0,-1,c,0,1,-c,0,-1,-c,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a,b);this.type="IcosahedronBufferGeometry";this.parameters= -{radius:a,detail:b}}function xc(a,b){Q.call(this);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Qb(a,b));this.mergeVertices()}function Rb(a,b){var c=(1+Math.sqrt(5))/2,d=1/c;ua.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-c,0,-d,c,0,d,-c,0,d,c,-d,-c,0,-d,c,0,d,-c,0,d,c,0,-c,0,-d,c,0,-d,-c,0,d,c,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2, -6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],a,b);this.type="DodecahedronBufferGeometry";this.parameters={radius:a,detail:b}}function yc(a,b){Q.call(this);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Rb(a,b));this.mergeVertices()}function zc(a,b,c,d){Q.call(this);this.type="PolyhedronGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d}; -this.fromBufferGeometry(new ua(a,b,c,d));this.mergeVertices()}function Sb(a,b,c,d,e){function f(e){var f=a.getPointAt(e/b),m=g.normals[e];e=g.binormals[e];for(n=0;n<=d;n++){var w=n/d*Math.PI*2,l=Math.sin(w),w=-Math.cos(w);k.x=w*m.x+l*e.x;k.y=w*m.y+l*e.y;k.z=w*m.z+l*e.z;k.normalize();r.push(k.x,k.y,k.z);h.x=f.x+c*k.x;h.y=f.y+c*k.y;h.z=f.z+c*k.z;p.push(h.x,h.y,h.z)}}G.call(this);this.type="TubeBufferGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};b=b||64;c=c|| -1;d=d||8;e=e||!1;var g=a.computeFrenetFrames(b,e);this.tangents=g.tangents;this.normals=g.normals;this.binormals=g.binormals;var h=new q,k=new q,m=new B,w,n,p=[],r=[],l=[],t=[];for(w=0;wp;p++){e[0]=n[g[p]];e[1]=n[g[(p+1)%3]];e.sort(c);var l=e.toString();void 0===f[l]?f[l]={vert1:e[0],vert2:e[1],face1:m,face2:void 0}:f[l].face2=m}e=[];for(l in f)if(g=f[l],void 0===g.face2||h[g.face1].normal.dot(h[g.face2].normal)<=d)m=k[g.vert1],e.push(m.x),e.push(m.y),e.push(m.z),m=k[g.vert2],e.push(m.x),e.push(m.y),e.push(m.z);this.addAttribute("position",new C(new Float32Array(e),3))}function Ua(a, -b,c,d,e,f,g,h){function k(c){var e,f,k,n=new B,p=new q,l=0,w=!0===c?a:b,I=!0===c?1:-1;f=u;for(e=1;e<=d;e++)x.setXYZ(u,0,y*I,0),t.setXYZ(u,0,I,0),n.x=.5,n.y=.5,D.setXY(u,n.x,n.y),u++;k=u;for(e=0;e<=d;e++){var z=e/d*h+g,C=Math.cos(z),z=Math.sin(z);p.x=w*z;p.y=y*I;p.z=w*C;x.setXYZ(u,p.x,p.y,p.z);t.setXYZ(u,0,I,0);n.x=.5*C+.5;n.y=.5*z*I+.5;D.setXY(u,n.x,n.y);u++}for(e=0;ethis.duration&&this.resetDuration();this.optimize()}function ud(a){this.manager=void 0!==a?a:Ga;this.textures={}}function Id(a){this.manager=void 0!==a?a:Ga}function wb(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}}function Jd(a){"boolean"=== -typeof a&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),a=void 0);this.manager=void 0!==a?a:Ga;this.withCredentials=!1}function xe(a){this.manager=void 0!==a?a:Ga;this.texturePath=""}function ia(){}function Sa(a,b){this.v1=a;this.v2=b}function Oc(){this.curves=[];this.autoClose=!1}function Va(a,b,c,d,e,f,g,h){this.aX=a;this.aY=b;this.xRadius=c;this.yRadius=d;this.aStartAngle=e;this.aEndAngle=f;this.aClockwise=g;this.aRotation=h||0}function xb(a){this.points= -void 0===a?[]:a}function yb(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d}function zb(a,b,c){this.v0=a;this.v1=b;this.v2=c}function Ab(){Pc.apply(this,arguments);this.holes=[]}function Pc(a){Oc.call(this);this.currentPoint=new B;a&&this.fromPoints(a)}function Kd(){this.subPaths=[];this.currentPath=null}function Ld(a){this.data=a}function ye(a){this.manager=void 0!==a?a:Ga}function Md(){void 0===Nd&&(Nd=new (window.AudioContext||window.webkitAudioContext));return Nd}function Od(a){this.manager= -void 0!==a?a:Ga}function ze(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064;this.cameraL=new Ea;this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new Ea;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=!1}function vd(a,b,c){z.call(this);this.type="CubeCamera";var d=new Ea(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new q(1,0,0));this.add(d);var e=new Ea(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new q(-1,0,0));this.add(e);var f=new Ea(90,1,a,b);f.up.set(0,0,1);f.lookAt(new q(0, -1,0));this.add(f);var g=new Ea(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new q(0,-1,0));this.add(g);var h=new Ea(90,1,a,b);h.up.set(0,-1,0);h.lookAt(new q(0,0,1));this.add(h);var k=new Ea(90,1,a,b);k.up.set(0,-1,0);k.lookAt(new q(0,0,-1));this.add(k);this.renderTarget=new Eb(c,c,{format:1022,magFilter:1006,minFilter:1006});this.updateCubeMap=function(a,b){null===this.parent&&this.updateMatrixWorld();var c=this.renderTarget,p=c.texture.generateMipmaps;c.texture.generateMipmaps=!1;c.activeCubeFace=0;a.render(b, -d,c);c.activeCubeFace=1;a.render(b,e,c);c.activeCubeFace=2;a.render(b,f,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.texture.generateMipmaps=p;c.activeCubeFace=5;a.render(b,k,c);a.setRenderTarget(null)}}function Pd(){z.call(this);this.type="AudioListener";this.context=Md();this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.filter=null}function dc(a){z.call(this);this.type="Audio";this.context=a.context;this.source=this.context.createBufferSource(); -this.source.onended=this.onEnded.bind(this);this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.startTime=0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filters=[]}function Qd(a){dc.call(this,a);this.panner=this.context.createPanner();this.panner.connect(this.gain)}function Rd(a,b){this.analyser=a.context.createAnalyser();this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount); -a.getOutput().connect(this.analyser)}function wd(a,b,c){this.binding=a;this.valueSize=c;a=Float64Array;switch(b){case "quaternion":b=this._slerp;break;case "string":case "bool":a=Array;b=this._select;break;default:b=this._lerp}this.buffer=new a(4*c);this._mixBufferRegion=b;this.referenceCount=this.useCount=this.cumulativeWeight=0}function fa(a,b,c){this.path=b;this.parsedPath=c||fa.parseTrackName(b);this.node=fa.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a}function Sd(a){this.uuid=T.generateUUID(); -this._objects=Array.prototype.slice.call(arguments);this.nCachedObjects_=0;var b={};this._indicesByUUID=b;for(var c=0,d=arguments.length;c!==d;++c)b[arguments[c].uuid]=c;this._paths=[];this._parsedPaths=[];this._bindings=[];this._bindingsIndicesByPath={};var e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}function Td(a,b,c){this._mixer=a;this._clip=b;this._localRoot=c||null;a=b.tracks; -b=a.length;c=Array(b);for(var d={endingStart:2400,endingEnd:2400},e=0;e!==b;++e){var f=a[e].createInterpolant(null);c[e]=f;f.settings=d}this._interpolantSettings=d;this._interpolants=c;this._propertyBindings=Array(b);this._weightInterpolant=this._timeScaleInterpolant=this._byClipCacheIndex=this._cacheIndex=null;this.loop=2201;this._loopCount=-1;this._startTime=null;this.time=0;this._effectiveWeight=this.weight=this._effectiveTimeScale=this.timeScale=1;this.repetitions=Infinity;this.paused=!1;this.enabled= -!0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd=this.zeroSlopeAtStart=!0}function Ud(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1}function Ae(a,b){"string"===typeof a&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),a=b);this.value=a}function Bb(){G.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0}function Vd(a,b,c,d){this.uuid=T.generateUUID();this.data=a;this.itemSize=b;this.offset=c;this.normalized=!0=== -d}function ec(a,b){this.uuid=T.generateUUID();this.array=a;this.stride=b;this.count=void 0!==a?a.length/b:0;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0}function fc(a,b,c){ec.call(this,a,b);this.meshPerAttribute=c||1}function gc(a,b,c){C.call(this,a,b);this.meshPerAttribute=c||1}function Wd(a,b,c,d){this.ray=new ab(a,b);this.near=c||0;this.far=d||Infinity;this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}};Object.defineProperties(this.params,{PointCloud:{get:function(){console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."); -return this.Points}}})}function Be(a,b){return a.distance-b.distance}function Xd(a,b,c,d){if(!1!==a.visible&&(a.raycast(b,c),!0===d)){a=a.children;d=0;for(var e=a.length;dc;c++,d++){var e=c/32*Math.PI*2,f=d/32*Math.PI*2;b.push(Math.cos(e),Math.sin(e),1,Math.cos(f),Math.sin(f),1)}a.addAttribute("position",new ha(b,3));b=new oa({fog:!1});this.cone=new la(a,b);this.add(this.cone);this.update()}function ic(a){this.bones=this.getBoneList(a);for(var b=new Q, -c=0;cd;d++)c.faces[d].color=this.colors[4>d?0:1];d=new Ma({vertexColors:1,wireframe:!0});this.lightSphere=new ya(c,d);this.add(this.lightSphere);this.update()}function Sc(a,b,c,d){b=b||1;c=new O(void 0!==c?c:4473924);d=new O(void 0!== -d?d:8947848);for(var e=b/2,f=2*a/b,g=[],h=[],k=0,m=0,l=-a;k<=b;k++,l+=f){g.push(-a,0,l,a,0,l);g.push(l,0,-a,l,0,a);var n=k===e?c:d;n.toArray(h,m);m+=3;n.toArray(h,m);m+=3;n.toArray(h,m);m+=3;n.toArray(h,m);m+=3}a=new G;a.addAttribute("position",new ha(g,3));a.addAttribute("color",new ha(h,3));g=new oa({vertexColors:2});la.call(this,a,g)}function Tc(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;a=void 0!==c?c:16776960;d=void 0!==d?d:1;b=0;(c=this.object.geometry)&&c.isGeometry?b=c.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead."); -c=new G;b=new ha(6*b,3);c.addAttribute("position",b);la.call(this,c,new oa({color:a,linewidth:d}));this.matrixAutoUpdate=!1;this.update()}function lc(a,b){z.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;void 0===b&&(b=1);var c=new G;c.addAttribute("position",new ha([-b,b,0,b,b,0,b,-b,0,-b,-b,0,-b,b,0],3));var d=new oa({fog:!1});this.add(new Ta(c,d));c=new G;c.addAttribute("position",new ha([0,0,0,0,0,1],3));this.add(new Ta(c,d));this.update()} -function Uc(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){d.vertices.push(new q);d.colors.push(new O(b));void 0===f[a]&&(f[a]=[]);f[a].push(d.vertices.length-1)}var d=new Q,e=new oa({color:16777215,vertexColors:1}),f={};b("n1","n2",16755200);b("n2","n4",16755200);b("n4","n3",16755200);b("n3","n1",16755200);b("f1","f2",16755200);b("f2","f4",16755200);b("f4","f3",16755200);b("f3","f1",16755200);b("n1","f1",16755200);b("n2","f2",16755200);b("n3","f3",16755200);b("n4","f4",16755200);b("p","n1",16711680); -b("p","n2",16711680);b("p","n3",16711680);b("p","n4",16711680);b("u1","u2",43775);b("u2","u3",43775);b("u3","u1",43775);b("c","t",16777215);b("p","c",3355443);b("cn1","cn2",3355443);b("cn3","cn4",3355443);b("cf1","cf2",3355443);b("cf3","cf4",3355443);la.call(this,d,e);this.camera=a;this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.pointMap=f;this.update()}function Vc(a,b){var c=void 0!==b?b:8947848;this.object=a;this.box= -new Ba;ya.call(this,new ob(1,1,1),new Ma({color:c,wireframe:!0}))}function Wc(a,b){void 0===b&&(b=16776960);var c=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),d=new Float32Array(24),e=new G;e.setIndex(new C(c,1));e.addAttribute("position",new C(d,3));la.call(this,e,new oa({color:b}));void 0!==a&&this.update(a)}function Cb(a,b,c,d,e,f){z.call(this);void 0===d&&(d=16776960);void 0===c&&(c=1);void 0===e&&(e=.2*c);void 0===f&&(f=.2*e);this.position.copy(b);this.line=new Ta(Ce,new oa({color:d})); -this.line.matrixAutoUpdate=!1;this.add(this.line);this.cone=new ya(De,new Ma({color:d}));this.cone.matrixAutoUpdate=!1;this.add(this.cone);this.setDirection(a);this.setLength(c,e,f)}function xd(a){a=a||1;var b=new Float32Array([0,0,0,a,0,0,0,0,0,0,a,0,0,0,0,0,0,a]),c=new Float32Array([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1]);a=new G;a.addAttribute("position",new C(b,3));a.addAttribute("color",new C(c,3));b=new oa({vertexColors:2});la.call(this,a,b)}function Ee(a){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Please use THREE.CatmullRomCurve3."); -$d.call(this,a);this.type="catmullrom";this.closed=!0}function yd(a,b,c,d,e,f){Va.call(this,a,b,c,c,d,e,f)}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52));void 0===Math.sign&&(Math.sign=function(a){return 0>a?-1:0e;e++)8===e||13===e||18===e||23===e?b[e]="-":14===e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,b[e]=a[19===e?d&3|8:d]);return b.join("")}}(),clamp:function(a,b,c){return Math.max(b,Math.min(c,a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},lerp:function(a,b,c){return(1-c)*a+c*b},smoothstep:function(a, -b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},random16:function(){console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead.");return Math.random()},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(a){return a* -T.DEG2RAD},radToDeg:function(a){return a*T.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},nearestPowerOfTwo:function(a){return Math.pow(2,Math.round(Math.log(a)/Math.LN2))},nextPowerOfTwo:function(a){a--;a|=a>>1;a|=a>>2;a|=a>>4;a|=a>>8;a|=a>>16;a++;return a}};B.prototype={constructor:B,isVector2:!0,get width(){return this.x},set width(a){this.x=a},get height(){return this.y},set height(a){this.y=a},set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x= -a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){if(void 0!== -b)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), -this.subVectors(a,b);this.x-=a.x;this.y-=a.y;return this},subScalar:function(a){this.x-=a;this.y-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*=a.y;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a):this.y=this.x=0;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y, -a.y);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new B,b=new B);a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.multiplyScalar(Math.max(a,Math.min(b,c))/c)},floor:function(){this.x=Math.floor(this.x);this.y= -Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x* -this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function(){var a=Math.atan2(this.y,this.x);0>a&&(a+=2*Math.PI);return a},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},distanceToManhattan:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)},setLength:function(a){return this.multiplyScalar(a/ -this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+ -1];return this},rotateAround:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=this.x-a.x,f=this.y-a.y;this.x=e*c-f*d+a.x;this.y=e*d+f*c+a.y;return this}};da.DEFAULT_IMAGE=void 0;da.DEFAULT_MAPPING=300;da.prototype={constructor:da,isTexture:!0,set needsUpdate(a){!0===a&&this.version++},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.image=a.image;this.mipmaps=a.mipmaps.slice(0);this.mapping=a.mapping;this.wrapS=a.wrapS;this.wrapT=a.wrapT;this.magFilter=a.magFilter;this.minFilter= -a.minFilter;this.anisotropy=a.anisotropy;this.format=a.format;this.type=a.type;this.offset.copy(a.offset);this.repeat.copy(a.repeat);this.generateMipmaps=a.generateMipmaps;this.premultiplyAlpha=a.premultiplyAlpha;this.flipY=a.flipY;this.unpackAlignment=a.unpackAlignment;this.encoding=a.encoding;return this},toJSON:function(a){if(void 0!==a.textures[this.uuid])return a.textures[this.uuid];var b={metadata:{version:4.4,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping, -repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var c=this.image;void 0===c.uuid&&(c.uuid=T.generateUUID());if(void 0===a.images[c.uuid]){var d=a.images,e=c.uuid,f=c.uuid,g;void 0!==c.toDataURL?g=c:(g=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),g.width=c.width,g.height=c.height,g.getContext("2d").drawImage(c, -0,0,c.width,c.height));g=2048a.x||1a.x?0:1;break;case 1002:a.x=1===Math.abs(Math.floor(a.x)%2)?Math.ceil(a.x)-a.x:a.x-Math.floor(a.x)}if(0> -a.y||1a.y?0:1;break;case 1002:a.y=1===Math.abs(Math.floor(a.y)%2)?Math.ceil(a.y)-a.y:a.y-Math.floor(a.y)}this.flipY&&(a.y=1-a.y)}}};Object.assign(da.prototype,sa.prototype);var ee=0;ga.prototype={constructor:ga,isVector4:!0,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a; -return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x, -this.y,this.z,this.w)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;this.w+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this}, -addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;this.w+=a.w*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;this.w-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},multiplyScalar:function(a){isFinite(a)? -(this.x*=a,this.y*=a,this.z*=a,this.w*=a):this.w=this.z=this.y=this.x=0;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=a[2]*b+a[6]*c+a[10]*d+a[14]*e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y= -0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d;a=a.elements;var e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],k=a[9];c=a[2];b=a[6];var m=a[10];if(.01>Math.abs(d-g)&&.01>Math.abs(f-c)&&.01>Math.abs(k-b)){if(.1>Math.abs(d+g)&&.1>Math.abs(f+c)&&.1>Math.abs(k+b)&&.1>Math.abs(e+h+m-3))return this.set(1,0,0,0),this;a=Math.PI;e=(e+1)/2;h=(h+1)/2;m=(m+1)/2;d=(d+g)/4;f=(f+c)/4;k=(k+b)/4;e>h&&e>m?.01>e?(b=0,d=c=.707106781):(b=Math.sqrt(e),c=d/b,d=f/b): -h>m?.01>h?(b=.707106781,c=0,d=.707106781):(c=Math.sqrt(h),b=d/c,d=k/c):.01>m?(c=b=.707106781,d=0):(d=Math.sqrt(m),b=f/d,c=k/d);this.set(b,c,d,a);return this}a=Math.sqrt((b-k)*(b-k)+(f-c)*(f-c)+(g-d)*(g-d));.001>Math.abs(a)&&(a=1);this.x=(b-k)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+m-1)/2);return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x); -this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);this.w=Math.max(this.w,a.w);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));this.w=Math.max(a.w,Math.min(b.w,this.w));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new ga,b=new ga);a.set(c,c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y); -this.z=Math.floor(this.z);this.w=Math.floor(this.w);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);this.w=Math.ceil(this.w);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);this.w=Math.round(this.w);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z); -this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}, -normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w= -a[b+3];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=this.w;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];this.w=a.array[b+3];return this}};Object.assign(Db.prototype,sa.prototype,{isWebGLRenderTarget:!0,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.dispose();this.viewport.set(0,0,a,b);this.scissor.set(0, -0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.depthTexture=a.depthTexture;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Eb.prototype=Object.create(Db.prototype);Eb.prototype.constructor=Eb;Eb.prototype.isWebGLRenderTargetCube=!0;ba.prototype={constructor:ba,get x(){return this._x}, -set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get w(){return this._w},set w(a){this._w=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z;this._w=a.w;this.onChangeCallback(); -return this},setFromEuler:function(a,b){if(!1===(a&&a.isEuler))throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var c=Math.cos(a._x/2),d=Math.cos(a._y/2),e=Math.cos(a._z/2),f=Math.sin(a._x/2),g=Math.sin(a._y/2),h=Math.sin(a._z/2),k=a.order;"XYZ"===k?(this._x=f*d*e+c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"YXZ"===k?(this._x=f*d*e+c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"ZXY"===k?(this._x= -f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"ZYX"===k?(this._x=f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"YZX"===k?(this._x=f*d*e+c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e-f*g*h):"XZY"===k&&(this._x=f*d*e-c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e+f*g*h);if(!1!==b)this.onChangeCallback();return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this._x=a.x*d;this._y=a.y*d;this._z=a.z*d;this._w= -Math.cos(c);this.onChangeCallback();return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],k=b[6],b=b[10],m=c+f+b;0f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=.25*c,this._z=(g+k)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+ -h)/c,this._y=(g+k)/c,this._z=.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(){var a,b;return function(c,d){void 0===a&&(a=new q);b=c.dot(d)+1;1E-6>b?(b=0,Math.abs(c.x)>Math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossVectors(c,d);this._x=a.x;this._y=a.y;this._z=a.z;this._w=b;return this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){this._x*=-1;this._y*=-1;this._z*=-1;this.onChangeCallback();return this},dot:function(a){return this._x* -a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this},multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."), -this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},premultiply:function(a){return this.multiplyQuaternions(a,this)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z,f=a._w,g=b._x,h=b._y,k=b._z,m=b._w;this._x=c*m+f*g+d*k-e*h;this._y=d*m+f*h+e*g-c*k;this._z=e*m+f*k+c*h-d*g;this._w=f*m-c*g-d*h-e*k;this.onChangeCallback();return this},slerp:function(a,b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z; -0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;var h=Math.sqrt(1-g*g);if(.001>Math.abs(h))return this._w=.5*(f+this._w),this._x=.5*(c+this._x),this._y=.5*(d+this._y),this._z=.5*(e+this._z),this;var k=Math.atan2(h,g),g=Math.sin((1-b)*k)/h,h=Math.sin(b*k)/h;this._w=f*g+this._w*h;this._x=c*g+this._x*h;this._y=d*g+this._y*h;this._z=e*g+this._z*h;this.onChangeCallback();return this},equals:function(a){return a._x=== -this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];this._w=a[b+3];this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._w;return a},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}};Object.assign(ba,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a, -b,c,d,e,f,g){var h=c[d+0],k=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var l=e[f+1],n=e[f+2];e=e[f+3];if(c!==e||h!==d||k!==l||m!==n){f=1-g;var p=h*d+k*l+m*n+c*e,r=0<=p?1:-1,x=1-p*p;x>Number.EPSILON&&(x=Math.sqrt(x),p=Math.atan2(x,p*r),f=Math.sin(f*p)/x,g=Math.sin(g*p)/x);r*=g;h=h*f+d*r;k=k*f+l*r;m=m*f+n*r;c=c*f+e*r;f===1-g&&(g=1/Math.sqrt(h*h+k*k+m*m+c*c),h*=g,k*=g,m*=g,c*=g)}a[b]=h;a[b+1]=k;a[b+2]=m;a[b+3]=c}});q.prototype={constructor:q,isVector3:!0,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this}, -setScalar:function(a){this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x, -this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+= -a.z*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},multiply:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."), -this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a,this.z*=a):this.z=this.y=this.x=0;return this},multiplyVectors:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(){var a;return function(b){!1===(b&&b.isEuler)&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");void 0===a&&(a=new ba);return this.applyQuaternion(a.setFromEuler(b))}}(), -applyAxisAngle:function(){var a;return function(b,c){void 0===a&&(a=new ba);return this.applyQuaternion(a.setFromAxisAngle(b,c))}}(),applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*d;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12];this.y=a[1]*b+a[5]*c+a[9]*d+a[13];this.z=a[2]*b+a[6]*c+a[10]*d+a[14];return this},applyProjection:function(a){var b= -this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e;this.y=(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e;return this},applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,m=a*d+e*c-f*b,b=-e*b-f*c-g*d;this.x=h*a+b*-e+k*-g-m*-f;this.y=k*a+b*-f+m*-e-h*-g;this.z=m*a+b*-g+h*-f-k*-e;return this},project:function(){var a;return function(b){void 0===a&&(a=new J); -a.multiplyMatrices(b.projectionMatrix,a.getInverse(b.matrixWorld));return this.applyProjection(a)}}(),unproject:function(){var a;return function(b){void 0===a&&(a=new J);a.multiplyMatrices(b.matrixWorld,a.getInverse(b.projectionMatrix));return this.applyProjection(a)}}(),transformDirection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;return this.normalize()},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/= -a.z;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));return this},clampScalar:function(){var a,b;return function(c, -d){void 0===a&&(a=new q,b=new q);a.set(c,c,c);b.set(d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.multiplyScalar(Math.max(a,Math.min(b,c))/c)},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this}, -roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+ -Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},cross:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a, -b);var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},crossVectors:function(a,b){var c=a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;this.x=d*h-e*g;this.y=e*f-c*h;this.z=c*g-d*f;return this},projectOnVector:function(a){var b=a.dot(this)/a.lengthSq();return this.copy(a).multiplyScalar(b)},projectOnPlane:function(){var a;return function(b){void 0===a&&(a=new q);a.copy(this).projectOnVector(b);return this.sub(a)}}(),reflect:function(){var a;return function(b){void 0=== -a&&(a=new q);return this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){a=this.dot(a)/Math.sqrt(this.lengthSq()*a.lengthSq());return Math.acos(T.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},distanceToManhattan:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)+Math.abs(this.z-a.z)},setFromSpherical:function(a){var b=Math.sin(a.phi)*a.radius; -this.x=b*Math.sin(a.theta);this.y=Math.cos(a.phi)*a.radius;this.z=b*Math.cos(a.theta);return this},setFromMatrixPosition:function(a){return this.setFromMatrixColumn(a,3)},setFromMatrixScale:function(a){var b=this.setFromMatrixColumn(a,0).length(),c=this.setFromMatrixColumn(a,1).length();a=this.setFromMatrixColumn(a,2).length();this.x=b;this.y=c;this.z=a;return this},setFromMatrixColumn:function(a,b){if("number"===typeof a){console.warn("THREE.Vector3: setFromMatrixColumn now expects ( matrix, index )."); -var c=a;a=b;b=c}return this.fromArray(a.elements,4*b)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];return this}};J.prototype={constructor:J,isMatrix4:!0, -set:function(a,b,c,d,e,f,g,h,k,m,l,n,p,r,x,t){var q=this.elements;q[0]=a;q[4]=b;q[8]=c;q[12]=d;q[1]=e;q[5]=f;q[9]=g;q[13]=h;q[2]=k;q[6]=m;q[10]=l;q[14]=n;q[3]=p;q[7]=r;q[11]=x;q[15]=t;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},clone:function(){return(new J).fromArray(this.elements)},copy:function(a){this.elements.set(a.elements);return this},copyPosition:function(a){var b=this.elements;a=a.elements;b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractBasis:function(a, -b,c){a.setFromMatrixColumn(this,0);b.setFromMatrixColumn(this,1);c.setFromMatrixColumn(this,2);return this},makeBasis:function(a,b,c){this.set(a.x,b.x,c.x,0,a.y,b.y,c.y,0,a.z,b.z,c.z,0,0,0,0,1);return this},extractRotation:function(){var a;return function(b){void 0===a&&(a=new q);var c=this.elements,d=b.elements,e=1/a.setFromMatrixColumn(b,0).length(),f=1/a.setFromMatrixColumn(b,1).length();b=1/a.setFromMatrixColumn(b,2).length();c[0]=d[0]*e;c[1]=d[1]*e;c[2]=d[2]*e;c[4]=d[4]*f;c[5]=d[5]*f;c[6]=d[6]* -f;c[8]=d[8]*b;c[9]=d[9]*b;c[10]=d[10]*b;return this}}(),makeRotationFromEuler:function(a){!1===(a&&a.isEuler)&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);if("XYZ"===a.order){a=f*h;var k=f*e,m=c*h,l=c*e;b[0]=g*h;b[4]=-g*e;b[8]=d;b[1]=k+m*d;b[5]=a-l*d;b[9]=-c*g;b[2]=l-a*d;b[6]=m+k*d;b[10]=f*g}else"YXZ"=== -a.order?(a=g*h,k=g*e,m=d*h,l=d*e,b[0]=a+l*c,b[4]=m*c-k,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=k*c-m,b[6]=l+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,k=g*e,m=d*h,l=d*e,b[0]=a-l*c,b[4]=-f*e,b[8]=m+k*c,b[1]=k+m*c,b[5]=f*h,b[9]=l-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,k=f*e,m=c*h,l=c*e,b[0]=g*h,b[4]=m*d-k,b[8]=a*d+l,b[1]=g*e,b[5]=l*d+a,b[9]=k*d-m,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,k=f*d,m=c*g,l=c*d,b[0]=g*h,b[4]=l-a*e,b[8]=m*e+k,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=k* -e+m,b[10]=a-l*e):"XZY"===a.order&&(a=f*g,k=f*d,m=c*g,l=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+l,b[5]=f*h,b[9]=k*e-m,b[2]=m*e-k,b[6]=c*h,b[10]=l*e+a);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromQuaternion:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w,g=c+c,h=d+d,k=e+e;a=c*g;var m=c*h,c=c*k,l=d*h,d=d*k,e=e*k,g=f*g,h=f*h,f=f*k;b[0]=1-(l+e);b[4]=m-f;b[8]=c+h;b[1]=m+f;b[5]=1-(a+e);b[9]=d-g;b[2]=c-h;b[6]=d+g;b[10]=1-(a+l);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]= -0;b[14]=0;b[15]=1;return this},lookAt:function(){var a,b,c;return function(d,e,f){void 0===a&&(a=new q,b=new q,c=new q);var g=this.elements;c.subVectors(d,e).normalize();0===c.lengthSq()&&(c.z=1);a.crossVectors(f,c).normalize();0===a.lengthSq()&&(c.z+=1E-4,a.crossVectors(f,c).normalize());b.crossVectors(c,a);g[0]=a.x;g[4]=b.x;g[8]=c.x;g[1]=a.y;g[5]=b.y;g[9]=c.y;g[2]=a.z;g[6]=b.z;g[10]=c.z;return this}}(),multiply:function(a,b){return void 0!==b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."), -this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],k=c[12],m=c[1],l=c[5],n=c[9],p=c[13],r=c[2],x=c[6],t=c[10],q=c[14],u=c[3],v=c[7],I=c[11],c=c[15],y=d[0],E=d[4],H=d[8],F=d[12],M=d[1],B=d[5],K=d[9],z=d[13],C=d[2],G=d[6],J=d[10],N=d[14],P=d[3],R=d[7],S=d[11],d=d[15];e[0]=f*y+g*M+h*C+k*P;e[4]=f*E+g*B+h*G+k*R;e[8]=f*H+g*K+h*J+k*S;e[12]= -f*F+g*z+h*N+k*d;e[1]=m*y+l*M+n*C+p*P;e[5]=m*E+l*B+n*G+p*R;e[9]=m*H+l*K+n*J+p*S;e[13]=m*F+l*z+n*N+p*d;e[2]=r*y+x*M+t*C+q*P;e[6]=r*E+x*B+t*G+q*R;e[10]=r*H+x*K+t*J+q*S;e[14]=r*F+x*z+t*N+q*d;e[3]=u*y+v*M+I*C+c*P;e[7]=u*E+v*B+I*G+c*R;e[11]=u*H+v*K+I*J+c*S;e[15]=u*F+v*z+I*N+c*d;return this},multiplyToArray:function(a,b,c){var d=this.elements;this.multiplyMatrices(a,b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12]; -c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},applyToVector3Array:function(){var a;return function(b,c,d){void 0===a&&(a=new q);void 0===c&&(c=0);void 0===d&&(d=b.length);for(var e=0;ethis.determinant()&&(g=-g);c.x=f[12];c.y=f[13];c.z=f[14];b.elements.set(this.elements);c=1/g;var f=1/h,m=1/k;b.elements[0]*=c;b.elements[1]*=c;b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=m;b.elements[9]*=m;b.elements[10]*=m;d.setFromRotationMatrix(b);e.x=g;e.y=h;e.z=k;return this}}(),makeFrustum:function(a,b,c,d,e,f){var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(d-c); -g[9]=(d+c)/(d-c);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makePerspective:function(a,b,c,d){a=c*Math.tan(T.DEG2RAD*a*.5);var e=-a;return this.makeFrustum(e*b,a*b,e,a,c,d)},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=1/(b-a),k=1/(c-d),m=1/(f-e);g[0]=2*h;g[4]=0;g[8]=0;g[12]=-((b+a)*h);g[1]=0;g[5]=2*k;g[9]=0;g[13]=-((c+d)*k);g[2]=0;g[6]=0;g[10]=-2*m;g[14]=-((f+e)*m);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},equals:function(a){var b= -this.elements;a=a.elements;for(var c=0;16>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;16>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a}};Xa.prototype=Object.create(da.prototype); -Xa.prototype.constructor=Xa;Xa.prototype.isCubeTexture=!0;Object.defineProperty(Xa.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}});var ie=new da,je=new Xa,fe=[],he=[];ne.prototype.setValue=function(a,b){for(var c=this.seq,d=0,e=c.length;d!==e;++d){var f=c[d];f.setValue(a,b[f.id])}};var zd=/([\w\d_]+)(\])?(\[|\.)?/g;Ya.prototype.setValue=function(a,b,c){b=this.map[b];void 0!==b&&b.setValue(a,c,this.renderer)};Ya.prototype.set=function(a,b,c){var d=this.map[c]; -void 0!==d&&d.setValue(a,b[c],this.renderer)};Ya.prototype.setOptional=function(a,b,c){b=b[c];void 0!==b&&this.setValue(a,c,b)};Ya.upload=function(a,b,c,d){for(var e=0,f=b.length;e!==f;++e){var g=b[e],h=c[g.id];!1!==h.needsUpdate&&g.setValue(a,h.value,d)}};Ya.seqWithValue=function(a,b){for(var c=[],d=0,e=a.length;d!==e;++d){var f=a[d];f.id in b&&c.push(f)}return c};var La={merge:function(a){for(var b={},c=0;c 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t\t}\n\t\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n", -bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n", -clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n", -clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n", -color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\n", -cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n", -defaultnormal_vertex:"#ifdef FLIP_SIDED\n\tobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normal * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n", -emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n return value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n float maxComponent = max( max( value.r, value.g ), value.b );\n float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n M = ceil( M * 255.0 ) / 255.0;\n return vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float D = max( maxRange / maxRGB, 1.0 );\n D = min( floor( D ) / 255.0, 1.0 );\n return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n vec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n vec4 vResult;\n vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n vResult.w = fract(Le);\n vResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n return vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n float Le = value.z * 255.0 + value.w;\n vec3 Xp_Y_XYZp;\n Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n vec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n return vec4( max(vRGB, 0.0), 1.0 );\n}\n", -envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\tvec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n", -envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntenstiy;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n", -envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n", -fog_fragment:"#ifdef USE_FOG\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\t#else\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t#endif\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif", -lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n", -lights_pars:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tif ( testLightInRange( lightDistance, pointLight.distance ) ) {\n\t\t\tdirectLight.color = pointLight.color;\n\t\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\t#include \n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\t#include \n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n", -lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n", -lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n", -lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n", -lights_template:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t \tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\t\t\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n", -logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n", -map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n", -metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.r;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n", -morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n", -normal_flip:"#ifdef DOUBLE_SIDED\n\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n#else\n\tfloat flipNormal = 1.0;\n#endif\n",normal_fragment:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal ) * flipNormal;\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n", -normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n", -packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 1.0 - 2.0 * rgb.xyz;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n return linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n", -premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"#ifdef USE_SKINNING\n\tvec4 mvPosition = modelViewMatrix * skinned;\n#else\n\tvec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.r;\n#endif\n", -roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn 1.0;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tfloat dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n", -shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n", -shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n", -shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n", -skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureWidth;\n\t\tuniform int boneTextureHeight;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n", -skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\tskinned = bindMatrixInverse * skinned;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n", -specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n return toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n", -uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n", -uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif", -uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\t#ifdef USE_SKINNING\n\t\tvec4 worldPosition = modelMatrix * skinned;\n\t#else\n\t\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\t#endif\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n", -cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n", -depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -distanceRGBA_frag:"uniform vec3 lightPos;\nvarying vec4 vWorldPosition;\n#include \n#include \n#include \nvoid main () {\n\t#include \n\tgl_FragColor = packDepthToRGBA( length( vWorldPosition.xyz - lightPos.xyz ) / 1000.0 );\n}\n",distanceRGBA_vert:"varying vec4 vWorldPosition;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition;\n}\n", -equirect_frag:"uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = saturate( tFlip * direction.y * -0.5 + 0.5 );\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n", -linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight;\n\treflectedLight.directDiffuse = vec3( 0.0 );\n\treflectedLight.directSpecular = vec3( 0.0 );\n\treflectedLight.indirectDiffuse = diffuseColor.rgb;\n\treflectedLight.indirectSpecular = vec3( 0.0 );\n\t#include \n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n", -meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nuniform float envMapIntensity;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n}\n", -normal_frag:"uniform float opacity;\nvarying vec3 vNormal;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( vNormal ), opacity );\n\t#include \n}\n",normal_vert:"varying vec3 vNormal;\n#include \n#include \n#include \n#include \nvoid main() {\n\tvNormal = normalize( normalMatrix * normal );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -shadow_frag:"uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( 0.0, 0.0, 0.0, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"};O.prototype={constructor:O, -isColor:!0,r:1,g:1,b:1,set:function(a){a&&a.isColor?this.copy(a):"number"===typeof a?this.setHex(a):"string"===typeof a&&this.setStyle(a);return this},setScalar:function(a){this.b=this.g=this.r=a;return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(){function a(a,c,d){0>d&&(d+=1);1d?c:d<2/3?a+6*(c-a)*(2/3-d):a}return function(b, -c,d){b=T.euclideanModulo(b,1);c=T.clamp(c,0,1);d=T.clamp(d,0,1);0===c?this.r=this.g=this.b=d:(c=.5>=d?d*(1+c):d+c-d*c,d=2*d-c,this.r=a(d,c,b+1/3),this.g=a(d,c,b),this.b=a(d,c,b-1/3));return this}}(),setStyle:function(a){function b(b){void 0!==b&&1>parseFloat(b)&&console.warn("THREE.Color: Alpha component of "+a+" will be ignored.")}var c;if(c=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var d=c[2];switch(c[1]){case "rgb":case "rgba":if(c=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r= -Math.min(255,parseInt(c[1],10))/255,this.g=Math.min(255,parseInt(c[2],10))/255,this.b=Math.min(255,parseInt(c[3],10))/255,b(c[5]),this;if(c=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(100,parseInt(c[1],10))/100,this.g=Math.min(100,parseInt(c[2],10))/100,this.b=Math.min(100,parseInt(c[3],10))/100,b(c[5]),this;break;case "hsl":case "hsla":if(c=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d)){var d=parseFloat(c[1])/ -360,e=parseInt(c[2],10)/100,f=parseInt(c[3],10)/100;b(c[5]);return this.setHSL(d,e,f)}}}else if(c=/^\#([A-Fa-f0-9]+)$/.exec(a)){c=c[1];d=c.length;if(3===d)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===d)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}a&&0=h?k/(e+f): -k/(2-e-f);switch(e){case b:g=(c-d)/k+(cthis.max.x||a.ythis.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&& -this.min.y<=a.min.y&&a.max.y<=this.max.y?!0:!1},getParameter:function(a,b){return(b||new B).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y?!1:!0},clampPoint:function(a,b){return(b||new B).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new B;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){this.min.max(a.min); -this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}};U.prototype={constructor:U,isMaterial:!0,get needsUpdate(){return this._needsUpdate},set needsUpdate(a){!0===a&&this.update();this._needsUpdate=a},setValues:function(a){if(void 0!==a)for(var b in a){var c=a[b];if(void 0===c)console.warn("THREE.Material: '"+ -b+"' parameter is undefined.");else{var d=this[b];void 0===d?console.warn("THREE."+this.type+": '"+b+"' is not a property of this material."):d&&d.isColor?d.set(c):d&&d.isVector3&&c&&c.isVector3?d.copy(c):this[b]="overdraw"===b?Number(c):c}}},toJSON:function(a){function b(a){var b=[],c;for(c in a){var d=a[c];delete d.metadata;b.push(d)}return b}var c=void 0===a;c&&(a={textures:{},images:{}});var d={metadata:{version:4.4,type:"Material",generator:"Material.toJSON"}};d.uuid=this.uuid;d.type=this.type; -""!==this.name&&(d.name=this.name);this.color&&this.color.isColor&&(d.color=this.color.getHex());void 0!==this.roughness&&(d.roughness=this.roughness);void 0!==this.metalness&&(d.metalness=this.metalness);this.emissive&&this.emissive.isColor&&(d.emissive=this.emissive.getHex());this.specular&&this.specular.isColor&&(d.specular=this.specular.getHex());void 0!==this.shininess&&(d.shininess=this.shininess);this.map&&this.map.isTexture&&(d.map=this.map.toJSON(a).uuid);this.alphaMap&&this.alphaMap.isTexture&& -(d.alphaMap=this.alphaMap.toJSON(a).uuid);this.lightMap&&this.lightMap.isTexture&&(d.lightMap=this.lightMap.toJSON(a).uuid);this.bumpMap&&this.bumpMap.isTexture&&(d.bumpMap=this.bumpMap.toJSON(a).uuid,d.bumpScale=this.bumpScale);this.normalMap&&this.normalMap.isTexture&&(d.normalMap=this.normalMap.toJSON(a).uuid,d.normalScale=this.normalScale.toArray());this.displacementMap&&this.displacementMap.isTexture&&(d.displacementMap=this.displacementMap.toJSON(a).uuid,d.displacementScale=this.displacementScale, -d.displacementBias=this.displacementBias);this.roughnessMap&&this.roughnessMap.isTexture&&(d.roughnessMap=this.roughnessMap.toJSON(a).uuid);this.metalnessMap&&this.metalnessMap.isTexture&&(d.metalnessMap=this.metalnessMap.toJSON(a).uuid);this.emissiveMap&&this.emissiveMap.isTexture&&(d.emissiveMap=this.emissiveMap.toJSON(a).uuid);this.specularMap&&this.specularMap.isTexture&&(d.specularMap=this.specularMap.toJSON(a).uuid);this.envMap&&this.envMap.isTexture&&(d.envMap=this.envMap.toJSON(a).uuid,d.reflectivity= -this.reflectivity);void 0!==this.size&&(d.size=this.size);void 0!==this.sizeAttenuation&&(d.sizeAttenuation=this.sizeAttenuation);1!==this.blending&&(d.blending=this.blending);2!==this.shading&&(d.shading=this.shading);0!==this.side&&(d.side=this.side);0!==this.vertexColors&&(d.vertexColors=this.vertexColors);1>this.opacity&&(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc;d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;0e&&(e=m);l>f&&(f=l);n>g&&(g=n)}this.min.set(b,c,d);this.max.set(e,f,g)},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;bthis.max.x||a.ythis.max.y|| -a.zthis.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z?!0:!1},getParameter:function(a,b){return(b||new q).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y||a.max.zthis.max.z?!1:!0},intersectsSphere:function(){var a;return function(b){void 0===a&&(a=new q);this.clampPoint(b.center,a);return a.distanceToSquared(b.center)<=b.radius*b.radius}}(),intersectsPlane:function(a){var b,c;0=a.constant},clampPoint:function(a,b){return(b||new q).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new q;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=new q;return function(b){b=b||new Ca;this.getCenter(b.center);b.radius=.5*this.getSize(a).length();return b}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max); -this.isEmpty()&&this.makeEmpty();return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(){var a=[new q,new q,new q,new q,new q,new q,new q,new q];return function(b){if(this.isEmpty())return this;a[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(b);a[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(b);a[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(b);a[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(b);a[4].set(this.max.x, -this.min.y,this.min.z).applyMatrix4(b);a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(b);a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(b);a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(b);this.setFromPoints(a);return this}}(),translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}};Ca.prototype={constructor:Ca,set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(){var a= -new Ba;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).getCenter(d);for(var e=0,f=0,g=b.length;f=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)- -this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},intersectsBox:function(a){return a.intersectsSphere(this)},intersectsPlane:function(a){return Math.abs(this.center.dot(a.normal)-a.constant)<=this.radius},clampPoint:function(a,b){var c=this.center.distanceToSquared(a),d=b||new q;d.copy(a);c>this.radius*this.radius&&(d.sub(this.center).normalize(),d.multiplyScalar(this.radius).add(this.center));return d},getBoundingBox:function(a){a= -a||new Ba;a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius}};Ia.prototype={constructor:Ia,isMatrix3:!0,set:function(a,b,c,d,e,f,g,h,k){var m=this.elements;m[0]=a;m[1]=d;m[2]=g;m[3]=b;m[4]=e;m[5]=h;m[6]=c;m[7]=f;m[8]=k;return this},identity:function(){this.set(1, -0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(a){a=a.elements;this.set(a[0],a[3],a[6],a[1],a[4],a[7],a[2],a[5],a[8]);return this},setFromMatrix4:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[1],a[5],a[9],a[2],a[6],a[10]);return this},applyToVector3Array:function(){var a;return function(b,c,d){void 0===a&&(a=new q);void 0===c&&(c=0);void 0===d&&(d=b.length);for(var e=0;ec;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];return a}};va.prototype={constructor:va,set:function(a,b){this.normal.copy(a); -this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new q,b=new q;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d,c);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal); -this.constant=a.constant;return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this},negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,b){return this.orthoPoint(a,b).sub(a).negate()},orthoPoint:function(a,b){var c=this.distanceToPoint(a);return(b|| -new q).copy(this.normal).multiplyScalar(c)},intersectLine:function(){var a=new q;return function(b,c){var d=c||new q,e=b.delta(a),f=this.normal.dot(e);if(0===f){if(0===this.distanceToPoint(b.start))return d.copy(b.start)}else return f=-(b.start.dot(this.normal)+this.constant)/f,0>f||1b&&0a&&0c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],m=c[7],l=c[8],n=c[9],p=c[10],r=c[11],q=c[12],t=c[13],D=c[14],c=c[15]; -b[0].setComponents(f-a,m-g,r-l,c-q).normalize();b[1].setComponents(f+a,m+g,r+l,c+q).normalize();b[2].setComponents(f+d,m+h,r+n,c+t).normalize();b[3].setComponents(f-d,m-h,r-n,c-t).normalize();b[4].setComponents(f-e,m-k,r-p,c-D).normalize();b[5].setComponents(f+e,m+k,r+p,c+D).normalize();return this},intersectsObject:function(){var a=new Ca;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere).applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(), -intersectsSprite:function(){var a=new Ca;return function(b){a.center.set(0,0,0);a.radius=.7071067811865476;a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes,c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)e;e++){var f=d[e];a.x=0g&&0>f)return!1}return!0}}(),containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}};ab.prototype={constructor:ab,set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.origin.copy(a.origin); -this.direction.copy(a.direction);return this},at:function(a,b){return(b||new q).copy(this.direction).multiplyScalar(a).add(this.origin)},lookAt:function(a){this.direction.copy(a).sub(this.origin).normalize();return this},recast:function(){var a=new q;return function(b){this.origin.copy(this.at(b,a));return this}}(),closestPointToPoint:function(a,b){var c=b||new q;c.subVectors(a,this.origin);var d=c.dot(this.direction);return 0>d?c.copy(this.origin):c.copy(this.direction).multiplyScalar(d).add(this.origin)}, -distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new q;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceToSquared(b);a.copy(this.direction).multiplyScalar(c).add(this.origin);return a.distanceToSquared(b)}}(),distanceSqToSegment:function(){var a=new q,b=new q,c=new q;return function(d,e,f,g){a.copy(d).add(e).multiplyScalar(.5);b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a); -var h=.5*d.distanceTo(e),k=-this.direction.dot(b),m=c.dot(this.direction),l=-c.dot(b),n=c.lengthSq(),p=Math.abs(1-k*k),r;0=-r?e<=r?(h=1/p,d*=h,e*=h,k=d*(d+k*e+2*m)+e*(k*d+e+2*l)+n):(e=h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+n):(e=-h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+n):e<=-r?(d=Math.max(0,-(-k*h+m)),e=0f)return null;f=Math.sqrt(f-e);e=d-f;d+=f;return 0>e&&0>d?null:0>e?this.at(d,c):this.at(e,c)}}(),intersectsSphere:function(a){return this.distanceToPoint(a.center)<= -a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){var c=this.distanceToPlane(a);return null===c?null:this.at(c,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},intersectBox:function(a,b){var c,d,e,f,g;d=1/this.direction.x;f=1/this.direction.y;g=1/this.direction.z; -var h=this.origin;0<=d?(c=(a.min.x-h.x)*d,d*=a.max.x-h.x):(c=(a.max.x-h.x)*d,d*=a.min.x-h.x);0<=f?(e=(a.min.y-h.y)*f,f*=a.max.y-h.y):(e=(a.max.y-h.y)*f,f*=a.min.y-h.y);if(c>f||e>d)return null;if(e>c||c!==c)c=e;if(fg||e>d)return null;if(e>c||c!==c)c=e;if(gd?null:this.at(0<=c?c:d,b)},intersectsBox:function(){var a=new q;return function(b){return null!==this.intersectBox(b,a)}}(),intersectTriangle:function(){var a= -new q,b=new q,c=new q,d=new q;return function(e,f,g,h,k){b.subVectors(f,e);c.subVectors(g,e);d.crossVectors(b,c);f=this.direction.dot(d);if(0f)h=-1,f=-f;else return null;a.subVectors(this.origin,e);e=h*this.direction.dot(c.crossVectors(a,c));if(0>e)return null;g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),applyMatrix4:function(a){this.direction.add(this.origin).applyMatrix4(a);this.origin.applyMatrix4(a); -this.direction.sub(this.origin);this.direction.normalize();return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}};bb.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" ");bb.DefaultOrder="XYZ";bb.prototype={constructor:bb,isEuler:!0,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get order(){return this._order}, -set order(a){this._order=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this.onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=T.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],h=e[1],k=e[5],m=e[9],l=e[2],n=e[6],e=e[10];b=b|| -this._order;"XYZ"===b?(this._y=Math.asin(d(g,-1,1)),.99999>Math.abs(g)?(this._x=Math.atan2(-m,e),this._z=Math.atan2(-f,a)):(this._x=Math.atan2(n,k),this._z=0)):"YXZ"===b?(this._x=Math.asin(-d(m,-1,1)),.99999>Math.abs(m)?(this._y=Math.atan2(g,e),this._z=Math.atan2(h,k)):(this._y=Math.atan2(-l,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(n,-1,1)),.99999>Math.abs(n)?(this._y=Math.atan2(-l,e),this._z=Math.atan2(-f,k)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(l,-1,1)),.99999> -Math.abs(l)?(this._x=Math.atan2(n,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-f,k))):"YZX"===b?(this._z=Math.asin(d(h,-1,1)),.99999>Math.abs(h)?(this._x=Math.atan2(-m,k),this._y=Math.atan2(-l,a)):(this._x=0,this._y=Math.atan2(g,e))):"XZY"===b?(this._z=Math.asin(-d(f,-1,1)),.99999>Math.abs(f)?(this._x=Math.atan2(n,k),this._y=Math.atan2(g,a)):(this._x=Math.atan2(-m,e),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b);this._order=b;if(!1!==c)this.onChangeCallback(); -return this},setFromQuaternion:function(){var a;return function(b,c,d){void 0===a&&(a=new J);a.makeRotationFromQuaternion(b);return this.setFromRotationMatrix(a,c,d)}}(),setFromVector3:function(a,b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(){var a=new ba;return function(b){a.setFromEuler(this);return this.setFromQuaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1]; -this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._order;return a},toVector3:function(a){return a?a.set(this._x,this._y,this._z):new q(this._x,this._y,this._z)},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}};Yc.prototype={constructor:Yc,set:function(a){this.mask=1<=b.x+b.y}}();wa.prototype={constructor:wa,set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c); -return this},area:function(){var a=new q,b=new q;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,this.b);return.5*a.cross(b).length()}}(),midpoint:function(a){return(a||new q).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(a){return wa.normal(this.a,this.b,this.c,a)},plane:function(a){return(a||new va).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(a,b){return wa.barycoordFromPoint(a,this.a,this.b,this.c,b)},containsPoint:function(a){return wa.containsPoint(a, -this.a,this.b,this.c)},closestPointToPoint:function(){var a,b,c,d;return function(e,f){void 0===a&&(a=new va,b=[new gb,new gb,new gb],c=new q,d=new q);var g=f||new q,h=Infinity;a.setFromCoplanarPoints(this.a,this.b,this.c);a.projectPoint(e,c);if(!0===this.containsPoint(c))g.copy(c);else{b[0].set(this.a,this.b);b[1].set(this.b,this.c);b[2].set(this.c,this.a);for(var k=0;kd;d++)if(e[d]===e[(d+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(e=a[f],this.faces.splice(e,1),c=0,g=this.faceVertexUvs.length;cb.far?null:{distance:c,point:u.clone(),object:a}}function c(c,d,e,f,m,l,n,w){g.fromArray(f,3*l);h.fromArray(f,3*n);k.fromArray(f, -3*w);if(c=b(c,d,e,g,h,k,D))m&&(p.fromArray(m,2*l),r.fromArray(m,2*n),x.fromArray(m,2*w),c.uv=a(D,g,h,k,p,r,x)),c.face=new ea(l,n,w,wa.normal(g,h,k)),c.faceIndex=l;return c}var d=new J,e=new ab,f=new Ca,g=new q,h=new q,k=new q,m=new q,l=new q,n=new q,p=new B,r=new B,x=new B,t=new q,D=new q,u=new q;return function(q,t){var u=this.geometry,E=this.material,H=this.matrixWorld;if(void 0!==E&&(null===u.boundingSphere&&u.computeBoundingSphere(),f.copy(u.boundingSphere),f.applyMatrix4(H),!1!==q.ray.intersectsSphere(f)&& -(d.getInverse(H),e.copy(q.ray).applyMatrix4(d),null===u.boundingBox||!1!==e.intersectsBox(u.boundingBox)))){var F,M;if(u&&u.isBufferGeometry){var B,K,E=u.index,H=u.attributes,u=H.position.array;void 0!==H.uv&&(F=H.uv.array);if(null!==E)for(var H=E.array,z=0,C=H.length;zthis.scale.x*this.scale.y/4||c.push({distance:Math.sqrt(d),point:this.position, -face:null,object:this})}}(),clone:function(){return(new this.constructor(this.material)).copy(this)}});rc.prototype=Object.assign(Object.create(z.prototype),{constructor:rc,copy:function(a){z.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b=d[e].distance)d[e- -1].object.visible=!1,d[e].object.visible=!0;else break;for(;ef||(l.applyMatrix4(this.matrixWorld),t=d.ray.origin.distanceTo(l),td.far||e.push({distance:t,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else for(g=0,x=r.length/3-1;gf||(l.applyMatrix4(this.matrixWorld),t=d.ray.origin.distanceTo(l),td.far||e.push({distance:t,point:h.clone().applyMatrix4(this.matrixWorld), -index:g,face:null,faceIndex:null,object:this}))}else if(g&&g.isGeometry)for(k=g.vertices,m=k.length,g=0;gf||(l.applyMatrix4(this.matrixWorld),t=d.ray.origin.distanceTo(l),td.far||e.push({distance:t,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}}(),clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});la.prototype=Object.assign(Object.create(Ta.prototype), -{constructor:la,isLineSegments:!0});xa.prototype=Object.create(U.prototype);xa.prototype.constructor=xa;xa.prototype.isPointsMaterial=!0;xa.prototype.copy=function(a){U.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.size=a.size;this.sizeAttenuation=a.sizeAttenuation;return this};Kb.prototype=Object.assign(Object.create(z.prototype),{constructor:Kb,isPoints:!0,raycast:function(){var a=new J,b=new ab,c=new Ca;return function(d,e){function f(a,c){var f=b.distanceSqToPoint(a); -if(fd.far||e.push({distance:m,distanceToRay:Math.sqrt(f),point:h.clone(),index:c,face:null,object:g})}}var g=this,h=this.geometry,k=this.matrixWorld,m=d.params.Points.threshold;null===h.boundingSphere&&h.computeBoundingSphere();c.copy(h.boundingSphere);c.applyMatrix4(k);if(!1!==d.ray.intersectsSphere(c)){a.getInverse(k);b.copy(d.ray).applyMatrix4(a);var m=m/((this.scale.x+this.scale.y+this.scale.z)/3), -l=m*m,m=new q;if(h&&h.isBufferGeometry){var n=h.index,h=h.attributes.position.array;if(null!==n)for(var p=n.array,n=0,r=p.length;nc)return null;var d=[],e=[],f=[],g,h,k;if(0=m--){console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()");break}g=h;c<=g&&(g=0);h=g+1;c<=h&&(h=0);k=h+1;c<=k&&(k=0);var l;a:{var n, -p,r,q,t,D,u,v;n=a[e[g]].x;p=a[e[g]].y;r=a[e[h]].x;q=a[e[h]].y;t=a[e[k]].x;D=a[e[k]].y;if(0>=(r-n)*(D-p)-(q-p)*(t-n))l=!1;else{var I,y,E,H,F,M,B,z,C,G;I=t-r;y=D-q;E=n-t;H=p-D;F=r-n;M=q-p;for(l=0;l=-Number.EPSILON&&z>=-Number.EPSILON&&B>=-Number.EPSILON)){l=!1;break a}l=!0}}if(l){d.push([a[e[g]],a[e[h]],a[e[k]]]);f.push([e[g],e[h],e[k]]);g=h;for(k=h+1;kNumber.EPSILON){if(0q||q>p)return[];k=m*l-k*n;if(0>k||k>p)return[]}else{if(0c?[]:k===c?f?[]:[g]:a<=c?[g,h]:[g,m]}function f(a,b,c,d){var e=b.x-a.x,f=b.y-a.y;b=c.x-a.x;c=c.y-a.y;var g=d.x-a.x;d=d.y-a.y;a=e*c-f*b;e=e*d-f*g;return Math.abs(a)>Number.EPSILON?(b=g*c-d*b,0e&&(e=d);var g=a+1;g>d&&(g=0);d=f(h[a],h[e],h[g],k[b]);if(!d)return!1;d=k.length-1;e=b-1;0>e&&(e=d);g=b+1;g>d&&(g=0);return(d=f(k[b],k[e],k[g],h[a]))?!0:!1}function d(a,b){var c,f;for(c=0;cN){console.log("Infinite Loop! Holes left:"+m.length+", Probably Hole outside Shape!");break}for(n=z;nk;k++)l=m[k].x+":"+m[k].y,l=n[l],void 0!==l&&(m[k]=l);return p.concat()},isClockWise:function(a){return 0>ra.area(a)},b2:function(){return function(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}}(),b3:function(){return function(a,b,c,d,e){var f=1-a,g=1-a;return f*f*f*b+3*g*g*a*c+3*(1-a)*a*a*d+a*a*a*e}}()};za.prototype=Object.create(Q.prototype);za.prototype.constructor= -za;za.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;dNumber.EPSILON){var k=Math.sqrt(h),m=Math.sqrt(d*d+g*g),h=b.x-f/k;b=b.y+e/k;g=((c.x-g/m-h)*g-(c.y+d/m-b)*d)/(e*g-f*d);d=h+e*g-a.x;e=b+f*g-a.y;f= -d*d+e*e;if(2>=f)return new B(d,e);f=Math.sqrt(f/2)}else a=!1,e>Number.EPSILON?d>Number.EPSILON&&(a=!0):e<-Number.EPSILON?d<-Number.EPSILON&&(a=!0):Math.sign(f)===Math.sign(g)&&(a=!0),a?(d=-f,f=Math.sqrt(h)):(d=e,e=f,f=Math.sqrt(h/2));return new B(d/f,e/f)}function e(a,b){var c,d;for(L=a.length;0<=--L;){c=L;d=L-1;0>d&&(d=a.length-1);var e,f=r+2*l;for(e=0;eMath.abs(b.y-c.y)?[new B(b.x,1-b.z),new B(c.x,1-c.z),new B(d.x,1-d.z),new B(e.x,1-e.z)]:[new B(b.y,1-b.z),new B(c.y,1-c.z),new B(d.y,1-d.z),new B(e.y, -1-e.z)]}};Dc.prototype=Object.create(za.prototype);Dc.prototype.constructor=Dc;mb.prototype=Object.create(G.prototype);mb.prototype.constructor=mb;Vb.prototype=Object.create(Q.prototype);Vb.prototype.constructor=Vb;Wb.prototype=Object.create(G.prototype);Wb.prototype.constructor=Wb;Ec.prototype=Object.create(Q.prototype);Ec.prototype.constructor=Ec;Fc.prototype=Object.create(Q.prototype);Fc.prototype.constructor=Fc;Xb.prototype=Object.create(G.prototype);Xb.prototype.constructor=Xb;Gc.prototype=Object.create(Q.prototype); -Gc.prototype.constructor=Gc;cb.prototype=Object.create(Q.prototype);cb.prototype.constructor=cb;cb.prototype.addShapeList=function(a,b){for(var c=0,d=a.length;c=e)break a;else{f=b[1];a=e)break b}d=c;c=0}}for(;c>>1,ab;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f,1),e=f-1),d=this.getValueSize(),this.times=ma.arraySlice(c,e,f),this.values=ma.arraySlice(this.values,e*d,f*d);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("invalid value size in track",this),a=!1);var c=this.times,b=this.values,d=c.length;0===d&&(console.error("track is empty", -this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("time is not a valid number",this,f,g);a=!1;break}if(null!==e&&e>g){console.error("out of order keys",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&ma.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("value is not a valid number",this,f,d);a=!1;break}return a},optimize:function(){for(var a=this.times,b=this.values,c=this.getValueSize(),d=2302===this.getInterpolation(),e=1, -f=a.length-1,g=1;gk.opacity&&(k.transparent=!0);c.setTextures(h);return c.parse(k)}}()};wb.Handlers={handlers:[],add:function(a,b){this.handlers.push(a,b)},get:function(a){for(var b=this.handlers,c=0,d=b.length;cg;g++)p=v[k++],u=D[2*p],p=D[2*p+1],u=new B(u,p),2!==g&&c.faceVertexUvs[d][h].push(u),0!==g&&c.faceVertexUvs[d][h+1].push(u);n&&(n=3*v[k++],r.normal.set(z[n++],z[n++],z[n]),t.normal.copy(r.normal));if(x)for(d=0;4>d;d++)n=3*v[k++],x=new q(z[n++],z[n++],z[n]),2!==d&&r.vertexNormals.push(x),0!==d&&t.vertexNormals.push(x);w&&(w=v[k++],w=y[w],r.color.setHex(w),t.color.setHex(w));if(b)for(d= -0;4>d;d++)w=v[k++],w=y[w],2!==d&&r.vertexColors.push(new O(w)),0!==d&&t.vertexColors.push(new O(w));c.faces.push(r);c.faces.push(t)}else{r=new ea;r.a=v[k++];r.b=v[k++];r.c=v[k++];h&&(h=v[k++],r.materialIndex=h);h=c.faces.length;if(d)for(d=0;dg;g++)p=v[k++],u=D[2*p],p=D[2*p+1],u=new B(u,p),c.faceVertexUvs[d][h].push(u);n&&(n=3*v[k++],r.normal.set(z[n++],z[n++],z[n]));if(x)for(d=0;3>d;d++)n=3*v[k++],x=new q(z[n++],z[n++],z[n]),r.vertexNormals.push(x); -w&&(w=v[k++],r.color.setHex(y[w]));if(b)for(d=0;3>d;d++)w=v[k++],r.vertexColors.push(new O(y[w]));c.faces.push(r)}})(d);(function(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var d=0,g=a.skinWeights.length;dk)g=d+1;else if(0b&&(b=0);1Number.EPSILON&&(g.normalize(),c=Math.acos(T.clamp(d[k-1].dot(d[k]),-1,1)),e[k].applyMatrix4(h.makeRotationAxis(g,c))),f[k].crossVectors(d[k],e[k]);if(!0===b)for(c=Math.acos(T.clamp(e[0].dot(e[a]),-1,1)),c/=a,0=b)return b=c[a]-b,a=this.curves[a],c=a.getLength(),a.getPointAt(0===c?0:1-b/c);a++}return null}, -getLength:function(){var a=this.getCurveLengths();return a[a.length-1]},updateArcLengths:function(){this.needsUpdate=!0;this.cacheLengths=null;this.getLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var a=[],b=0,c=0,d=this.curves.length;cc;)c+=b;for(;c>b;)c-=b;cb.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=Xc.interpolate;return new B(c(d.x,e.x,f.x,b.x,a),c(d.y,e.y,f.y,b.y,a))};yb.prototype=Object.create(ia.prototype); -yb.prototype.constructor=yb;yb.prototype.getPoint=function(a){var b=ra.b3;return new B(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y))};yb.prototype.getTangent=function(a){var b=Xc.tangentCubicBezier;return(new B(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y))).normalize()};zb.prototype=Object.create(ia.prototype);zb.prototype.constructor=zb;zb.prototype.getPoint=function(a){var b=ra.b2;return new B(b(a,this.v0.x, -this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y))};zb.prototype.getTangent=function(a){var b=Xc.tangentQuadraticBezier;return(new B(b(a,this.v0.x,this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y))).normalize()};var de=Object.assign(Object.create(Oc.prototype),{fromPoints:function(a){this.moveTo(a[0].x,a[0].y);for(var b=1,c=a.length;bNumber.EPSILON){if(0>l&&(g=b[f],k=-k,h=b[e],l=-l),!(a.yh.y))if(a.y=== -g.y){if(a.x===g.x)return!0}else{e=l*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x))return!0}return d}var e=ra.isClockWise,f=this.subPaths;if(0===f.length)return[];if(!0===b)return c(f);var g,h,k,l=[];if(1===f.length)return h=f[0],k=new Ab,k.curves=h.curves,l.push(k),l;var q=!e(f[0].getPoints()),q=a?!q:q;k=[];var n=[],p=[],r=0,x;n[r]=void 0;p[r]=[];for(var t=0,D=f.length;td&&this._mixBufferRegion(c,a,3*b,1-d,b);for(var d=b,f=b+b;d!==f;++d)if(c[d]!==c[d+b]){e.setValue(c,a);break}},saveOriginalState:function(){var a=this.buffer,b=this.valueSize,c=3*b;this.binding.getValue(a,c);for(var d= -b;d!==c;++d)a[d]=a[c+d%b];this.cumulativeWeight=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},_select:function(a,b,c,d,e){if(.5<=d)for(d=0;d!==e;++d)a[b+d]=a[c+d]},_slerp:function(a,b,c,d,e){ba.slerpFlat(a,b,a,b,a,c,d)},_lerp:function(a,b,c,d,e){for(var f=1-d,g=0;g!==e;++g){var h=b+g;a[h]=a[h]*f+a[c+g]*d}}};fa.prototype={constructor:fa,getValue:function(a,b){this.bind();this.getValue(a,b)},setValue:function(a,b){this.bind();this.setValue(a,b)},bind:function(){var a= -this.node,b=this.parsedPath,c=b.objectName,d=b.propertyName,e=b.propertyIndex;a||(this.node=a=fa.findNode(this.rootNode,b.nodeName)||this.rootNode);this.getValue=this._getValue_unavailable;this.setValue=this._setValue_unavailable;if(a){if(c){var f=b.objectIndex;switch(c){case "materials":if(!a.material){console.error(" can not bind to material as node does not have a material",this);return}if(!a.material.materials){console.error(" can not bind to material.materials as node.material does not have a materials array", -this);return}a=a.material.materials;break;case "bones":if(!a.skeleton){console.error(" can not bind to bones as node does not have a skeleton",this);return}a=a.skeleton.bones;for(c=0;c=c){var n=c++,p=b[n];d[p.uuid]=q;b[q]=p;d[l]=n;b[n]=k;k=0;for(l=f;k!==l;++k){var p=e[k],r=p[q];p[q]=p[n];p[n]=r}}}this.nCachedObjects_=c},uncache:function(a){for(var b=this._objects,c=b.length,d=this.nCachedObjects_,e=this._indicesByUUID,f=this._bindings,g=f.length,h=0,k=arguments.length;h!==k;++h){var l=arguments[h].uuid,q=e[l];if(void 0!== -q)if(delete e[l],qb||0===c)return;this._startTime=null;b*=c}b*=this._updateTimeScale(a);c=this._updateTime(b);a=this._updateWeight(a);if(0c.parameterPositions[1]&& -(this.stopFading(),0===d&&(this.enabled=!1))}}return this._effectiveWeight=b},_updateTimeScale:function(a){var b=0;if(!this.paused){var b=this.timeScale,c=this._timeScaleInterpolant;if(null!==c){var d=c.evaluate(a)[0],b=b*d;a>c.parameterPositions[1]&&(this.stopWarping(),0===b?this.paused=!0:this.timeScale=b)}}return this._effectiveTimeScale=b},_updateTime:function(a){var b=this.time+a;if(0===a)return b;var c=this._clip.duration,d=this.loop,e=this._loopCount;if(2200===d)a:{if(-1===e&&(this.loopCount= -0,this._setEndings(!0,!0,!1)),b>=c)b=c;else if(0>b)b=0;else break a;this.clampWhenFinished?this.paused=!0:this.enabled=!1;this._mixer.dispatchEvent({type:"finished",action:this,direction:0>a?-1:1})}else{d=2202===d;-1===e&&(0<=a?(e=0,this._setEndings(!0,0===this.repetitions,d)):this._setEndings(0===this.repetitions,!0,d));if(b>=c||0>b){var f=Math.floor(b/c),b=b-c*f,e=e+Math.abs(f),g=this.repetitions-e;0>g?(this.clampWhenFinished?this.paused=!0:this.enabled=!1,b=0a,this._setEndings(a,!a,d)):this._setEndings(!1,!1,d),this._loopCount=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:f}))}if(d&&1===(e&1))return this.time=b,c-b}return this.time=b},_setEndings:function(a,b,c){var d=this._interpolantSettings;c?(d.endingStart=2401,d.endingEnd=2401):(d.endingStart=a?this.zeroSlopeAtStart?2401:2400:2402,d.endingEnd=b?this.zeroSlopeAtEnd?2401:2400:2402)},_scheduleFading:function(a,b,c){var d=this._mixer,e=d.time, -f=this._weightInterpolant;null===f&&(this._weightInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;f[0]=b;d[1]=e+a;f[1]=c;return this}};Object.assign(Ud.prototype,sa.prototype,{clipAction:function(a,b){var c=b||this._root,d=c.uuid,e="string"===typeof a?Ha.findByName(c,a):a,c=null!==e?e.uuid:a,f=this._actionsByClip[c],g=null;if(void 0!==f){g=f.actionByRoot[d];if(void 0!==g)return g;g=f.knownActions[0];null===e&&(e=g._clip)}if(null===e)return null;e=new Td(this, -e,b);this._bindAction(e,g);this._addInactiveAction(e,c,d);return e},existingAction:function(a,b){var c=b||this._root,d=c.uuid,c="string"===typeof a?Ha.findByName(c,a):a,c=this._actionsByClip[c?c.uuid:a];return void 0!==c?c.actionByRoot[d]||null:null},stopAllAction:function(){for(var a=this._actions,b=this._nActiveActions,c=this._bindings,d=this._nActiveBindings,e=this._nActiveBindings=this._nActiveActions=0;e!==b;++e)a[e].reset();for(e=0;e!==d;++e)c[e].useCount=0;return this},update:function(a){a*= -this.timeScale;for(var b=this._actions,c=this._nActiveActions,d=this.time+=a,e=Math.sign(a),f=this._accuIndex^=1,g=0;g!==c;++g){var h=b[g];h.enabled&&h._update(d,a,e,f)}a=this._bindings;b=this._nActiveBindings;for(g=0;g!==b;++g)a[g].apply(f);return this},getRoot:function(){return this._root},uncacheClip:function(a){var b=this._actions;a=a.uuid;var c=this._actionsByClip,d=c[a];if(void 0!==d){for(var d=d.knownActions,e=0,f=d.length;e!==f;++e){var g=d[e];this._deactivateAction(g);var h=g._cacheIndex, -k=b[b.length-1];g._cacheIndex=null;g._byClipCacheIndex=null;k._cacheIndex=h;b[h]=k;b.pop();this._removeInactiveBindingsForAction(g)}delete c[a]}},uncacheRoot:function(a){a=a.uuid;var b=this._actionsByClip,c;for(c in b){var d=b[c].actionByRoot[a];void 0!==d&&(this._deactivateAction(d),this._removeInactiveAction(d))}c=this._bindingsByRootAndName[a];if(void 0!==c)for(var e in c)a=c[e],a.restoreOriginalState(),this._removeInactiveBinding(a)},uncacheAction:function(a,b){var c=this.existingAction(a,b); -null!==c&&(this._deactivateAction(c),this._removeInactiveAction(c))}});Object.assign(Ud.prototype,{_bindAction:function(a,b){var c=a._localRoot||this._root,d=a._clip.tracks,e=d.length,f=a._propertyBindings,g=a._interpolants,h=c.uuid,k=this._bindingsByRootAndName,l=k[h];void 0===l&&(l={},k[h]=l);for(k=0;k!==e;++k){var q=d[k],n=q.name,p=l[n];if(void 0===p){p=f[k];if(void 0!==p){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,h,n));continue}p=new wd(fa.create(c,n,b&&b._propertyBindings[k].binding.parsedPath), -q.ValueTypeName,q.getValueSize());++p.referenceCount;this._addInactiveBinding(p,h,n)}f[k]=p;g[k].resultBuffer=p.buffer}},_activateAction:function(a){if(!this._isActiveAction(a)){if(null===a._cacheIndex){var b=(a._localRoot||this._root).uuid,c=a._clip.uuid,d=this._actionsByClip[c];this._bindAction(a,d&&d.knownActions[0]);this._addInactiveAction(a,c,b)}b=a._propertyBindings;c=0;for(d=b.length;c!==d;++c){var e=b[c];0===e.useCount++&&(this._lendBinding(e),e.saveOriginalState())}this._lendAction(a)}}, -_deactivateAction:function(a){if(this._isActiveAction(a)){for(var b=a._propertyBindings,c=0,d=b.length;c!==d;++c){var e=b[c];0===--e.useCount&&(e.restoreOriginalState(),this._takeBackBinding(e))}this._takeBackAction(a)}},_initMemoryManager:function(){this._actions=[];this._nActiveActions=0;this._actionsByClip={};this._bindings=[];this._nActiveBindings=0;this._bindingsByRootAndName={};this._controlInterpolants=[];this._nActiveControlInterpolants=0;var a=this;this.stats={actions:{get total(){return a._actions.length}, -get inUse(){return a._nActiveActions}},bindings:{get total(){return a._bindings.length},get inUse(){return a._nActiveBindings}},controlInterpolants:{get total(){return a._controlInterpolants.length},get inUse(){return a._nActiveControlInterpolants}}}},_isActiveAction:function(a){a=a._cacheIndex;return null!==a&&ah.end&&(h.end=f);c||(c=k)}}for(k in d)h=d[k],this.createAnimation(k,h.start,h.end,a);this.firstAnimation=c};na.prototype.setAnimationDirectionForward=function(a){if(a=this.animationsMap[a])a.direction=1,a.directionBackwards=!1};na.prototype.setAnimationDirectionBackward=function(a){if(a=this.animationsMap[a])a.direction=-1,a.directionBackwards=!0};na.prototype.setAnimationFPS=function(a,b){var c= -this.animationsMap[a];c&&(c.fps=b,c.duration=(c.end-c.start)/c.fps)};na.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];c&&(c.duration=b,c.fps=(c.end-c.start)/c.duration)};na.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];c&&(c.weight=b)};na.prototype.setAnimationTime=function(a,b){var c=this.animationsMap[a];c&&(c.time=b)};na.prototype.getAnimationTime=function(a){var b=0;if(a=this.animationsMap[a])b=a.time;return b};na.prototype.getAnimationDuration= -function(a){var b=-1;if(a=this.animationsMap[a])b=a.duration;return b};na.prototype.playAnimation=function(a){var b=this.animationsMap[a];b?(b.time=0,b.active=!0):console.warn("THREE.MorphBlendMesh: animation["+a+"] undefined in .playAnimation()")};na.prototype.stopAnimation=function(a){if(a=this.animationsMap[a])a.active=!1};na.prototype.update=function(a){for(var b=0,c=this.animationsList.length;b -d.duration||0>d.time)d.direction*=-1,d.time>d.duration&&(d.time=d.duration,d.directionBackwards=!0),0>d.time&&(d.time=0,d.directionBackwards=!1)}else d.time%=d.duration,0>d.time&&(d.time+=d.duration);var f=d.start+T.clamp(Math.floor(d.time/e),0,d.length-1),g=d.weight;f!==d.currentFrame&&(this.morphTargetInfluences[d.lastFrame]=0,this.morphTargetInfluences[d.currentFrame]=1*g,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f);e=d.time%e/e;d.directionBackwards&&(e=1-e);d.currentFrame!== -d.lastFrame?(this.morphTargetInfluences[d.currentFrame]=e*g,this.morphTargetInfluences[d.lastFrame]=(1-e)*g):this.morphTargetInfluences[d.currentFrame]=g}}};Qc.prototype=Object.create(z.prototype);Qc.prototype.constructor=Qc;Qc.prototype.isImmediateRenderObject=!0;Rc.prototype=Object.create(la.prototype);Rc.prototype.constructor=Rc;Rc.prototype.update=function(){var a=new q,b=new q,c=new Ia;return function(){var d=["a","b","c"];this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld); -var e=this.object.matrixWorld,f=this.geometry.attributes.position,g=this.object.geometry;if(g&&g.isGeometry)for(var h=g.vertices,k=g.faces,l=g=0,q=k.length;lc.y?this.quaternion.set(1,0,0,0):(a.set(c.z,0,-c.x).normalize(),b=Math.acos(c.y),this.quaternion.setFromAxisAngle(a,b))}}();Cb.prototype.setLength=function(a,b,c){void 0===b&&(b=.2*a);void 0===c&&(c=.2*b);this.line.scale.set(1,Math.max(0,a-b),1);this.line.updateMatrix(); -this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};Cb.prototype.setColor=function(a){this.line.material.color.copy(a);this.cone.material.color.copy(a)};xd.prototype=Object.create(la.prototype);xd.prototype.constructor=xd;var $d=function(){function a(){}var b=new q,c=new a,d=new a,e=new a;a.prototype.init=function(a,b,c,d){this.c0=a;this.c1=c;this.c2=-3*a+3*b-2*c-d;this.c3=2*a-2*b+c+d};a.prototype.initNonuniformCatmullRom=function(a,b,c,d,e,l,n){this.init(b,c,((b-a)/e-(c-a)/ -(e+l)+(c-b)/l)*l,((c-b)/l-(d-b)/(l+n)+(d-c)/n)*l)};a.prototype.initCatmullRom=function(a,b,c,d,e){this.init(b,c,e*(c-a),e*(d-b))};a.prototype.calc=function(a){var b=a*a;return this.c0+this.c1*a+this.c2*b+this.c3*b*a};return ia.create(function(a){this.points=a||[];this.closed=!1},function(a){var g=this.points,h,k;k=g.length;2>k&&console.log("duh, you need at least 2 points");a*=k-(this.closed?0:1);h=Math.floor(a);a-=h;this.closed?h+=0h&&(h=1);1E-4>k&&(k=h);1E-4>p&&(p=h);c.initNonuniformCatmullRom(l.x,w.x,n.x,g.x,k, -h,p);d.initNonuniformCatmullRom(l.y,w.y,n.y,g.y,k,h,p);e.initNonuniformCatmullRom(l.z,w.z,n.z,g.z,k,h,p)}else"catmullrom"===this.type&&(k=void 0!==this.tension?this.tension:.5,c.initCatmullRom(l.x,w.x,n.x,g.x,k),d.initCatmullRom(l.y,w.y,n.y,g.y,k),e.initCatmullRom(l.z,w.z,n.z,g.z,k));return new q(c.calc(a),d.calc(a),e.calc(a))})}();Ee.prototype=Object.create($d.prototype);var Ef=ia.create(function(a){console.warn("THREE.SplineCurve3 will be deprecated. Please use THREE.CatmullRomCurve3");this.points= -void 0===a?[]:a},function(a){var b=this.points;a*=b.length-1;var c=Math.floor(a);a-=c;var d=b[0==c?c:c-1],e=b[c],f=b[c>b.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=Xc.interpolate;return new q(c(d.x,e.x,f.x,b.x,a),c(d.y,e.y,f.y,b.y,a),c(d.z,e.z,f.z,b.z,a))}),Ff=ia.create(function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d},function(a){var b=ra.b3;return new q(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y),b(a,this.v0.z,this.v1.z,this.v2.z, -this.v3.z))}),Gf=ia.create(function(a,b,c){this.v0=a;this.v1=b;this.v2=c},function(a){var b=ra.b2;return new q(b(a,this.v0.x,this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y),b(a,this.v0.z,this.v1.z,this.v2.z))}),Hf=ia.create(function(a,b){this.v1=a;this.v2=b},function(a){if(1===a)return this.v2.clone();var b=new q;b.subVectors(this.v2,this.v1);b.multiplyScalar(a);b.add(this.v1);return b});yd.prototype=Object.create(Va.prototype);yd.prototype.constructor=yd;Object.assign(mc.prototype,{center:function(a){console.warn("THREE.Box2: .center() has been renamed to .getCenter()."); -return this.getCenter(a)},empty:function(){console.warn("THREE.Box2: .empty() has been renamed to .isEmpty().");return this.isEmpty()},isIntersectionBox:function(a){console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)},size:function(a){console.warn("THREE.Box2: .size() has been renamed to .getSize().");return this.getSize(a)}});Object.assign(Ba.prototype,{center:function(a){console.warn("THREE.Box3: .center() has been renamed to .getCenter()."); -return this.getCenter(a)},empty:function(){console.warn("THREE.Box3: .empty() has been renamed to .isEmpty().");return this.isEmpty()},isIntersectionBox:function(a){console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)},isIntersectionSphere:function(a){console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)},size:function(a){console.warn("THREE.Box3: .size() has been renamed to .getSize()."); -return this.getSize(a)}});Object.assign(gb.prototype,{center:function(a){console.warn("THREE.Line3: .center() has been renamed to .getCenter().");return this.getCenter(a)}});Object.assign(Ia.prototype,{multiplyVector3:function(a){console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.");return a.applyMatrix3(this)},multiplyVector3Array:function(a){console.warn("THREE.Matrix3: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead."); -return this.applyToVector3Array(a)}});Object.assign(J.prototype,{extractPosition:function(a){console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().");return this.copyPosition(a)},setRotationFromQuaternion:function(a){console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().");return this.makeRotationFromQuaternion(a)},multiplyVector3:function(a){console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead."); -return a.applyProjection(this)},multiplyVector4:function(a){console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},multiplyVector3Array:function(a){console.warn("THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.");return this.applyToVector3Array(a)},rotateAxis:function(a){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."); -a.transformDirection(this)},crossVector:function(a){console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},translate:function(a){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(a){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(a){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(a){console.error("THREE.Matrix4: .rotateZ() has been removed.")}, -rotateByAxis:function(a,b){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")}});Object.assign(va.prototype,{isIntersectionLine:function(a){console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().");return this.intersectsLine(a)}});Object.assign(ba.prototype,{multiplyVector3:function(a){console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.");return a.applyQuaternion(this)}});Object.assign(ab.prototype, -{isIntersectionBox:function(a){console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)},isIntersectionPlane:function(a){console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().");return this.intersectsPlane(a)},isIntersectionSphere:function(a){console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)}});Object.assign(Ab.prototype,{extrude:function(a){console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."); -return new za(this,a)},makeGeometry:function(a){console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.");return new cb(this,a)}});Object.assign(q.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")}, -getPositionFromMatrix:function(a){console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().");return this.setFromMatrixPosition(a)},getScaleFromMatrix:function(a){console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().");return this.setFromMatrixScale(a)},getColumnFromMatrix:function(a,b){console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().");return this.setFromMatrixColumn(b, -a)}});Object.assign(z.prototype,{getChildByName:function(a){console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().");return this.getObjectByName(a)},renderDepth:function(a){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(a,b){console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.");return this.translateOnAxis(b,a)}});Object.defineProperties(z.prototype, -{eulerOrder:{get:function(){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");return this.rotation.order},set:function(a){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");this.rotation.order=a}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(a){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}); -Object.defineProperties(rc.prototype,{objects:{get:function(){console.warn("THREE.LOD: .objects has been renamed to .levels.");return this.levels}}});Ea.prototype.setLens=function(a,b){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup.");void 0!==b&&(this.filmGauge=b);this.setFocalLength(a)};Object.defineProperties(pa.prototype,{onlyShadow:{set:function(a){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(a){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."); -this.shadow.camera.fov=a}},shadowCameraLeft:{set:function(a){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left.");this.shadow.camera.left=a}},shadowCameraRight:{set:function(a){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right.");this.shadow.camera.right=a}},shadowCameraTop:{set:function(a){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top.");this.shadow.camera.top=a}},shadowCameraBottom:{set:function(a){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."); -this.shadow.camera.bottom=a}},shadowCameraNear:{set:function(a){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near.");this.shadow.camera.near=a}},shadowCameraFar:{set:function(a){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far.");this.shadow.camera.far=a}},shadowCameraVisible:{set:function(a){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(a){console.warn("THREE.Light: .shadowBias is now .shadow.bias."); -this.shadow.bias=a}},shadowDarkness:{set:function(a){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(a){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.");this.shadow.mapSize.width=a}},shadowMapHeight:{set:function(a){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.");this.shadow.mapSize.height=a}}});Object.defineProperties(C.prototype,{length:{get:function(){console.warn("THREE.BufferAttribute: .length has been deprecated. Please use .count."); -return this.array.length}}});Object.assign(G.prototype,{addIndex:function(a){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().");this.setIndex(a)},addDrawCall:function(a,b,c){void 0!==c&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.");console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup().");this.addGroup(a,b)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."); -this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}});Object.defineProperties(G.prototype,{drawcalls:{get:function(){console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups.");return this.groups}},offsets:{get:function(){console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups.");return this.groups}}}); -Object.defineProperties(U.prototype,{wrapAround:{get:function(){console.warn("THREE."+this.type+": .wrapAround has been removed.")},set:function(a){console.warn("THREE."+this.type+": .wrapAround has been removed.")}},wrapRGB:{get:function(){console.warn("THREE."+this.type+": .wrapRGB has been removed.");return new O}}});Object.defineProperties(db.prototype,{metal:{get:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.");return!1},set:function(a){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}); -Object.defineProperties(Fa.prototype,{derivatives:{get:function(){console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");return this.extensions.derivatives},set:function(a){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");this.extensions.derivatives=a}}});sa.prototype=Object.assign(Object.create({constructor:sa,apply:function(a){console.warn("THREE.EventDispatcher: .apply is deprecated, just inherit or Object.assign the prototype to mix-in."); -Object.assign(a,this)}}),sa.prototype);Object.defineProperties(Ae.prototype,{dynamic:{set:function(a){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.");return this}}});Object.assign(Dd.prototype,{supportsFloatTextures:function(){console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."); -return this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' ).");return this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' ).");return this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."); -return this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' ).");return this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' ).");return this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return this.capabilities.vertexTextures}, -supportsInstancedArrays:function(){console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' ).");return this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(a){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().");this.setScissorTest(a)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")}, -addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}});Object.defineProperties(Dd.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.");this.shadowMap.enabled=a}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."); -this.shadowMap.type=a}},shadowMapCullFace:{get:function(){return this.shadowMap.cullFace},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace.");this.shadowMap.cullFace=a}}});Object.defineProperties(pe.prototype,{cullFace:{get:function(){return this.renderReverseSided?2:1},set:function(a){a=1!==a;console.warn("WebGLRenderer: .shadowMap.cullFace is deprecated. Set .shadowMap.renderReverseSided to "+a+".");this.renderReverseSided=a}}});Object.defineProperties(Db.prototype, -{wrapS:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");return this.texture.wrapS},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");this.texture.wrapS=a}},wrapT:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");return this.texture.wrapT},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");this.texture.wrapT=a}},magFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."); -return this.texture.magFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");this.texture.magFilter=a}},minFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");return this.texture.minFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");this.texture.minFilter=a}},anisotropy:{get:function(){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."); -return this.texture.anisotropy},set:function(a){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");this.texture.anisotropy=a}},offset:{get:function(){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");return this.texture.offset},set:function(a){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");this.texture.offset=a}},repeat:{get:function(){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");return this.texture.repeat}, -set:function(a){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");this.texture.repeat=a}},format:{get:function(){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");return this.texture.format},set:function(a){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");this.texture.format=a}},type:{get:function(){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");return this.texture.type},set:function(a){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."); -this.texture.type=a}},generateMipmaps:{get:function(){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");return this.texture.generateMipmaps},set:function(a){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");this.texture.generateMipmaps=a}}});Object.assign(dc.prototype,{load:function(a){console.warn("THREE.Audio: .load has been deprecated. Please use THREE.AudioLoader.");var b=this;(new Od).load(a,function(a){b.setBuffer(a)}); -return this}});Object.assign(Rd.prototype,{getData:function(a){console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData().");return this.getFrequencyData()}});l.WebGLRenderTargetCube=Eb;l.WebGLRenderTarget=Db;l.WebGLRenderer=Dd;l.ShaderLib=Gb;l.UniformsLib=W;l.UniformsUtils=La;l.ShaderChunk=X;l.FogExp2=Ib;l.Fog=Jb;l.Scene=jb;l.LensFlare=Ed;l.Sprite=qc;l.LOD=rc;l.SkinnedMesh=dd;l.Skeleton=bd;l.Bone=cd;l.Mesh=ya;l.LineSegments=la;l.Line=Ta;l.Points=Kb;l.Group=sc;l.VideoTexture=ed;l.DataTexture= -lb;l.CompressedTexture=Lb;l.CubeTexture=Xa;l.CanvasTexture=fd;l.DepthTexture=tc;l.TextureIdCount=function(){return ee++};l.Texture=da;l.MaterialIdCount=function(){return oe++};l.CompressedTextureLoader=we;l.BinaryTextureLoader=Gd;l.DataTextureLoader=Gd;l.CubeTextureLoader=Hd;l.TextureLoader=gd;l.ObjectLoader=xe;l.MaterialLoader=ud;l.BufferGeometryLoader=Id;l.DefaultLoadingManager=Ga;l.LoadingManager=Fd;l.JSONLoader=Jd;l.ImageLoader=Lc;l.FontLoader=ye;l.XHRLoader=Ja;l.Loader=wb;l.Cache=ce;l.AudioLoader= -Od;l.SpotLightShadow=id;l.SpotLight=jd;l.PointLight=kd;l.HemisphereLight=hd;l.DirectionalLightShadow=ld;l.DirectionalLight=md;l.AmbientLight=nd;l.LightShadow=tb;l.Light=pa;l.StereoCamera=ze;l.PerspectiveCamera=Ea;l.OrthographicCamera=Hb;l.CubeCamera=vd;l.Camera=Z;l.AudioListener=Pd;l.PositionalAudio=Qd;l.getAudioContext=Md;l.AudioAnalyser=Rd;l.Audio=dc;l.VectorKeyframeTrack=bc;l.StringKeyframeTrack=rd;l.QuaternionKeyframeTrack=Nc;l.NumberKeyframeTrack=cc;l.ColorKeyframeTrack=td;l.BooleanKeyframeTrack= -sd;l.PropertyMixer=wd;l.PropertyBinding=fa;l.KeyframeTrack=vb;l.AnimationUtils=ma;l.AnimationObjectGroup=Sd;l.AnimationMixer=Ud;l.AnimationClip=Ha;l.Uniform=Ae;l.InstancedBufferGeometry=Bb;l.BufferGeometry=G;l.GeometryIdCount=function(){return ad++};l.Geometry=Q;l.InterleavedBufferAttribute=Vd;l.InstancedInterleavedBuffer=fc;l.InterleavedBuffer=ec;l.InstancedBufferAttribute=gc;l.DynamicBufferAttribute=function(a,b){console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead."); -return(new C(a,b)).setDynamic(!0)};l.Float64Attribute=function(a,b){return new C(new Float64Array(a),b)};l.Float32Attribute=ha;l.Uint32Attribute=$c;l.Int32Attribute=function(a,b){return new C(new Int32Array(a),b)};l.Uint16Attribute=Zc;l.Int16Attribute=function(a,b){return new C(new Int16Array(a),b)};l.Uint8ClampedAttribute=function(a,b){return new C(new Uint8ClampedArray(a),b)};l.Uint8Attribute=function(a,b){return new C(new Uint8Array(a),b)};l.Int8Attribute=function(a,b){return new C(new Int8Array(a), -b)};l.BufferAttribute=C;l.Face3=ea;l.Object3DIdCount=function(){return qe++};l.Object3D=z;l.Raycaster=Wd;l.Layers=Yc;l.EventDispatcher=sa;l.Clock=Yd;l.QuaternionLinearInterpolant=qd;l.LinearInterpolant=Mc;l.DiscreteInterpolant=pd;l.CubicInterpolant=od;l.Interpolant=qa;l.Triangle=wa;l.Spline=function(a){function b(a,b,c,d,e,f,g){a=.5*(c-a);d=.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,k,l,w,n,p;this.initFromArray=function(a){this.points=[]; -for(var b=0;bthis.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1:f+2;l=this.points[c[0]];w=this.points[c[1]];n=this.points[c[2]];p=this.points[c[3]];h=g*g;k=g*h;d.x=b(l.x,w.x,n.x,p.x,g,h,k);d.y=b(l.y,w.y,n.y,p.y,g,h,k);d.z=b(l.z,w.z,n.z,p.z,g,h,k);return d};this.getControlPointsArray=function(){var a, -b,c=this.points.length,d=[];for(a=0;a (new PerspectiveCamera(80, device.innerWidth / device.innerHeight, 0.1, 100)); + +export default getCamera; diff --git a/src/js/get-material-base.js b/src/js/get-material-base.js new file mode 100644 index 0000000..c50522b --- /dev/null +++ b/src/js/get-material-base.js @@ -0,0 +1,43 @@ +import { + DoubleSide, + Matrix, + Quaternion, + SHADER_MATERIAL +} from './three-utils'; + +const getMaterialBase = (doubleSided) => { + let materialBase = SHADER_MATERIAL({ + uniforms: { // these are the parameters for the shader + time: { // global time + type: "f", + value: 0.0 + }, + translation: { // quaternion that moves shifts the object, set once per object + type: "m4", + value: new Matrix().set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) + }, + boost: { + type: "m4", + value: new Matrix().set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) + }, + cellColorQuat: { + type: "v4", + value: new Quaternion( 0,0,0,1 ) + }, + userCellColorQuat: { // which index colour the user is in + type: "v4", + value: new Quaternion( 0,0,0,1 ) + } + }, + vertexShader: document.getElementById('vertexShader').textContent, + fragmentShader: document.getElementById('fragmentShader').textContent + }); + + if (doubleSided) { + materialBase.side = DoubleSide; + } + + return materialBase; +}; + +export default getMaterialBase; diff --git a/js/hypMath.js b/src/js/hypMath.js similarity index 64% rename from js/hypMath.js rename to src/js/hypMath.js index bc103d8..0cb93c5 100644 --- a/js/hypMath.js +++ b/src/js/hypMath.js @@ -1,41 +1,35 @@ //hyperbolic matrix functions +import 'three'; THREE.Matrix4.prototype.add = function (m) { this.set.apply(this, [].map.call(this.elements, function (c, i) { return c + m.elements[i] })); }; -// function areSameMatrix(mat1, mat2) { -// var delta = 0.0001; -// for (var coord=0; coord<16; coord++) { -// if (Math.abs(mat1.elements[coord] - mat2.elements[coord]) > delta) { -// return false; -// } -// } -// return true; -// } +Array.prototype.subarray = function(start,end){ + if(!end){ end=-1;} + return this.slice(start, this.length+1-(end*-1)); +}; -function areSameMatrix(mat1, mat2) { //look only at last column - center of cell +const areSameMatrix = (mat1, mat2) => { //look only at last column - center of cell var delta = 0.01; for (var coord=3; coord<16; coord+=4) { if (Math.abs(mat1.elements[coord] - mat2.elements[coord]) > delta) { return false; } } - // console.log('same matrix') - // console.log(mat1.elements) - // console.log(mat2.elements) + return true; -} +}; -function isMatrixInArray(mat, matArray) { +const isMatrixInArray = (mat, matArray) => { for (var i=0; i 3) { return true; } } + return false; -} +}; // function hypDistFromOrigin(v) { // // put the point onto Klein model @@ -43,56 +37,18 @@ function isMatrixInArray(mat, matArray) { // return Math.atanh(Math.sqrt((v.x*v.x + v.y*v.y + v.z*v.z) / (v.w*v.w))); // } //dont need this for calculating nearest point to origin - atanh is increasing function -function digitsDepth( digits ) { - numZeros = 0; +const digitsDepth = ( digits ) => { + var numZeros = 0; for (var i = 0; i < digits.length; i++) { if ( digits[i] == 0 ) { numZeros += 1; - } - } - return digits.length - numZeros; -} - -function makeTsfmsList( tilingGens, tilingDepth ) { - var numTsfmsEachDepth = []; - var cumulativeNumTsfms = []; - for (var l = 0; l < tilingDepth + 1; l++) { //initialise array to zeros - numTsfmsEachDepth[numTsfmsEachDepth.length] = 0; - cumulativeNumTsfms[cumulativeNumTsfms.length] = 0; - } - var numGens = tilingGens.length; - var tsfms = []; - var words = []; - for (var j = 0; j < Math.pow(numGens, tilingDepth); j++) { - var digits = []; - var jcopy = j; - for (var k = 0; k < tilingDepth; k++) { - digits[digits.length] = jcopy % numGens; - jcopy = (jcopy/numGens)|0; - } - // console.log(digits); - var newTsfm = new THREE.Matrix4(); - for (var l = 0; l < tilingDepth; l++) { - newTsfm = newTsfm.multiply(tilingGens[digits[l]]); - } - - if ( !isMatrixInArray(newTsfm, tsfms) ) { - tsfms[tsfms.length] = newTsfm; - words[words.length] = digits; - numTsfmsEachDepth[digitsDepth(digits)] += 1; - } - } - - for (var i = 0; i < tilingDepth; i++){ - cumulativeNumTsfms[i] = numTsfmsEachDepth[i]; - if (i>0){ - cumulativeNumTsfms[i] += cumulativeNumTsfms[i-1]; } } - return [tsfms, words, cumulativeNumTsfms]; + return digits.length - numZeros; } -function translateByVector(v) { // trickery stolen from Jeff Weeks' Curved Spaces app + const translateByVector = (v) => { + // trickery stolen from Jeff Weeks' Curved Spaces app var dx = v.x; var dy = v.y; var dz = v.z; @@ -114,9 +70,9 @@ function translateByVector(v) { // trickery stolen from Jeff Weeks' Curved Space result.add(m); result.add(m2); return result; -} +}; -function parabolicBy2DVector(v) { /// something is wrong here we think... +const parabolicBy2DVector = (v) => { /// something is wrong here we think... var dx = v.x; /// first make parabolic fixing point at infinity in pos z direction var dy = v.y; var m = new THREE.Matrix4().set( @@ -129,28 +85,21 @@ function parabolicBy2DVector(v) { /// something is wrong here we think... var result = new THREE.Matrix4().identity(); result.add(m); result.add(m2); - //now conjugate to get based on camera orientation + //now conjugate to get based on camera orientation var cameraM = new THREE.Matrix4(); cameraM.makeRotationFromQuaternion(camera.quaternion); var cameraMinv = new THREE.Matrix4().getInverse(cameraM); return cameraM.multiply(result).multiply(cameraMinv); -} +}; -function getFwdVector() { - return new THREE.Vector3(0,0,1).applyQuaternion(camera.quaternion); -} -function getRightVector() { - return new THREE.Vector3(-1,0,0).applyQuaternion(camera.quaternion); -} -function getUpVector() { - return new THREE.Vector3(0,-1,0).applyQuaternion(camera.quaternion); -} +const getFwdVector = () => ( new THREE.Vector3(0,0,1).applyQuaternion(camera.quaternion) ); +const getRightVector = () => ( new THREE.Vector3(-1,0,0).applyQuaternion(camera.quaternion) ); +const getUpVector = () => ( new THREE.Vector3(0,-1,0).applyQuaternion(camera.quaternion) ); // fastGramSchmidt from Jeff Week's CurvedSpaces. Causes some wobble when far from the origin... -function fastGramSchmidt( m ) -{ +const fastGramSchmidt = ( m ) => { // Numerical errors can accumulate and force aMatrix "out of round", // in the sense that its rows are no longer orthonormal. // This effect is small in spherical and flat spaces, @@ -173,7 +122,7 @@ function fastGramSchmidt( m ) // Normalize each row to unit length. for (var i = 0; i < 4; i++) { - var metric; + var metric; if (i==3){ metric = timeLike; } @@ -193,7 +142,7 @@ function fastGramSchmidt( m ) // Make the rows orthogonal. for (var i = 4; i-- > 0; ) // leaves the last row untouched { - var metric; + var metric; if (i==3){ metric = timeLike; } @@ -212,20 +161,19 @@ function fastGramSchmidt( m ) } } return m; -} - -///// better GramSchmidt...seem more stable out near infinity +}; -function lorentzDot( u, v ){ +const lorentzDot = ( u, v ) => { return u[0]*v[0] + u[1]*v[1] + u[2]*v[2] - u[3]*v[3]; -} +}; -function norm( v ){ +const norm = ( v ) => { return Math.sqrt(Math.abs(lorentzDot(v,v))); -} +}; + -function gramSchmidt( m ){ - // var m = mat.elements; +const gramSchmidt = ( m ) => { + // var m = mat.elements; for (var i = 0; i<4; i++) { ///normalise row var invRowNorm = 1.0 / norm( m.subarray(4*i, 4*i+4) ); for (var l = 0; l<4; l++) { @@ -239,22 +187,20 @@ function gramSchmidt( m ){ } } return m; -} - +}; ////////check if we are still inside the central fund dom... - -function fakeDist( v ){ //good enough for comparison of distances on the hyperboloid +const fakeDist = ( v ) => { //good enough for comparison of distances on the hyperboloid return v.x*v.x + v.y*v.y + v.z*v.z; -} +}; -function fixOutsideCentralCell( mat, gens ) { +const fixOutsideCentralCell = ( mat, gens ) => { //assume first in Gens is identity, should probably fix when we get a proper list of matrices var cPos = new THREE.Vector4(0,0,0,1).applyMatrix4( mat ); //central var bestDist = fakeDist(cPos); var bestIndex = 0; - for (var i=1; i < gens.length; i++){ - pos = new THREE.Vector4(0,0,0,1).applyMatrix4( gens[i] ).applyMatrix4( mat ); + for (var i=1; i < gens.length; i++){ + const pos = new THREE.Vector4(0,0,0,1).applyMatrix4( gens[i] ).applyMatrix4( mat ); if (fakeDist(pos) < bestDist) { bestDist = fakeDist(pos); bestIndex = i; @@ -263,12 +209,25 @@ function fixOutsideCentralCell( mat, gens ) { if (bestIndex != 0){ mat = mat.multiply(gens[bestIndex]); return bestIndex; - } + } else { return false; } -} - - - +}; +export { + areSameMatrix, + isMatrixInArray, + digitsDepth, + translateByVector, + parabolicBy2DVector, + getFwdVector, + getRightVector, + getUpVector, + fixOutsideCentralCell, + fakeDist, + gramSchmidt, + fastGramSchmidt, + norm, + lorentzDot +} diff --git a/src/js/hypTiling.js b/src/js/hypTiling.js new file mode 100644 index 0000000..3a480e3 --- /dev/null +++ b/src/js/hypTiling.js @@ -0,0 +1,271 @@ +//import { makeTsfmsList } from './lib/hypMath'; +import * as decorationArray from './decoration-array'; +import getMaterialBase from './get-material-base'; +import updateBigMatArray from './update-big-mat-array'; +import getCamera from './get-camera'; +import { + CONTROLS, + LOADING_MANAGER, + MESH, + MATRIX4, + OBJLOADER, + QUATERNION, + SCENE, + RENDERER, + VREFFECT +} from './three-utils'; + +import { + loadElement +} from './load-element'; + +let camera; +let scene; +let renderer; +let mesh; + +let infoSprite = MESH; +let effect; +let controls; +// var music = document.querySelector('#music'); +let clicky = 0; +let mouseX = 1; +let mouseY = 1; +window.currentBoost = MATRIX4.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1); + +let decoration = "truncatedCube"; +window.colourMode = 0; + +let doubleSided = false; + +let numObjects = 1; //number of obj files to load +let numGens = tilingGens.length; +let tilingDepth = 4; //default 4 + +let unpackTriple = makeTsfmsList( tilingGens, tilingDepth ); +let tsfms = unpackTriple[0]; +let words = unpackTriple[1]; +let cumulativeNumTsfms = unpackTriple[2]; + +var numTiles = tsfms.length; +var bigMatArray; + +let movedTowardsCentralCubeThisFrameIndex = false; +var materialBase; + +function init() { + var start = Date.now(); + scene = SCENE; + camera = getCamera(window); + camera.position.x = 0; + camera.position.z = 0; + + renderer = RENDERER({ antialias: true }); + document.body.appendChild(renderer.domElement); + + controls = CONTROLS(camera); + + effect = VREFFECT(renderer); + effect.setSize(window.innerWidth, window.innerHeight); + + materialBase = getMaterialBase(doubleSided); + + loadStuff(); + + ////// create info overlay + // var infoText = THREE.ImageUtils.loadTexture( "media/twelve-ui.png" ); + // var infoMaterial = new THREE.MeshBasicMaterial( {map: infoText, wireframe: false, color: 0x777777 }); + // var infoBox = new THREE.BoxGeometry(2,1,1); + // infoSprite = new THREE.Mesh( infoBox, infoMaterial ); + // infoSprite.position.z = -2; + // infoSprite.position.x = -.5; + // infoSprite.position.y = -1; + // infoSprite.rotation.x = -.3; + // scene.add( infoSprite ); + + effect.render(scene, camera, animate); +} + +function loadStuff(){ + var cubeDecoration; + var manager = LOADING_MANAGER; + var loader = OBJLOADER(manager); + + const isDecorationAMonkey = ([ + "monkey", + "monkey2", + "monkey3" + ].indexOf(decoration) > -1); + + if (isDecorationAMonkey) { + numObjects = 2; + bigMatArray = updateBigMatArray(bigMatArray, numObjects, numTiles, materialBase); + + switch( decoration) { + case "monkey": + cubeDecoration = 'cube'; + break; + case "monkey2": + cubeDecoration = 'truncatedCube'; + break; + default: + cubeDecoration = 'truncatedCubeTrisOnly'; + } + + loadElement({ + loader, + path: 'media/'.concat(cubeDecoration, '.obj'), + scene, + maxIterations: numTiles, + bigMatArray, + extra: 0 + }); + + loadElement({ + loader, + path: 'media/euc_monkey_cut_7p5k.obj', + scene, + maxIterations: cumulativeNumTsfms[1], + bigMatArray, + extra: numTiles + }); + + loadElement({ + loader, + path: 'media/euc_monkey_cut_3k.obj', + scene, + minIterations: cumulativeNumTsfms[1], + maxIterations: cumulativeNumTsfms[2], + bigMatArray, + extra: numTiles + }); + + loadElement({ + loader, + path: 'media/euc_monkey_cut_1p5k.obj', + scene, + minIterations: cumulativeNumTsfms[2], + maxIterations: cumulativeNumTsfms[3], + bigMatArray, + extra: numTiles + }); + + loadElement({ + loader, + path: 'media/euc_monkey_cut_750.obj', + scene, + minIterations: cumulativeNumTsfms[3], + maxIterations: cumulativeNumTsfms[4], + bigMatArray, + extra: numTiles + }); + } + + else { + numObjects = 1; + bigMatArray = updateBigMatArray(bigMatArray, numObjects, numTiles, materialBase); + loadElement({ + loader, + path: 'media/'.concat(decoration, '.obj'), + scene, + maxIterations: numTiles, + bigMatArray, + extra: 0 + }); + } + for (var k = 0; k < numObjects; k++) { + for (var j = 0; j < numTiles; j++) { + var i = j + numTiles*k; + bigMatArray[i].uniforms['translation'].value = tsfms[j]; + if (k == 0){ + bigMatArray[i].uniforms['cellColorQuat'].value = word2colorQuat( words[j] ); + } + else { + bigMatArray[i].uniforms['cellColorQuat'].value = new THREE.Quaternion(0,0,0,0); + // all zeros quat is special cased to grey + } + // console.log(words[j]); + // console.log(word2colorQuat( words[j] )); + // console.log(bigMatArray[i].uniforms['userCellColorQuat'].value); + + + // bigMatArray[i].visible = phraseOnOffMaps[currentPhrase][k]; + } + } +} + + +function animate() { + controls.update(); // need to get movedTowardsCentralCubeThisFrameIndex before updating stuff + + + for (var k = 0; k < numObjects; k++) { + for (var j = 0; j < numTiles; j++) { + var i = j + numTiles*k; + bigMatArray[i].uniforms['boost'].value = currentBoost; + // console.log(bigMatArray[i].uniforms['userCellColorQuat'].value); + if (movedTowardsCentralCubeThisFrameIndex != false) { + + var tempQuat = QUATERNION; + tempQuat.copy(bigMatArray[i].uniforms['userCellColorQuat'].value); + tempQuat.multiply(genQuatsColourSchemes[colourMode][movedTowardsCentralCubeThisFrameIndex]); + + bigMatArray[i].uniforms['userCellColorQuat'].value = tempQuat; + /// always act on a uniform by setting it equal to something, other stuff breaks in incomprehensible ways... + + + // console.log(movedTowardsCentralCubeThisFrameIndex); + // console.log(genQuats[movedTowardsCentralCubeThisFrameIndex]); + // console.log(bigMatArray[i].uniforms['userCellColorQuat'].value); + } + + + // bigMatArray[i].visible = phraseOnOffMaps[currentPhrase][k]; + } + } + + effect.render(scene, camera, animate); + // requestAnimationFrame(animate); +} + +document.addEventListener('keydown', function(event) { selectShape(event); }, false); + +function selectShape(event) { + + var keySelect = event.keyCode - 48; //1 is 49 + + if (keySelect > 0 && keySelect < 10){ + if (scene) { + while (scene.children.length > 0) { + scene.remove(scene.children[scene.children.length - 1]); + } + decoration = decorationArray[(keySelect-1)]; + loadStuff(); + } + } +} + +document.addEventListener('keydown', function(event) { changeColourMode(event); }, false); + +function changeColourMode(event) { + + var keySelect = event.keyCode; + + if (keySelect == 67){ //c + if (scene) { + while (scene.children.length > 0) { + scene.remove(scene.children[scene.children.length - 1]); + } + colourMode = (colourMode + 1) % genQuatsColourSchemes.length; + loadStuff(); + } + } +} + +init(); +animate(); + +//Listen for double click event to enter full-screen VR mode +document.body.addEventListener( 'click', function() { + effect.setFullScreen( true ); +}); diff --git a/src/js/index.js b/src/js/index.js new file mode 100644 index 0000000..162b37f --- /dev/null +++ b/src/js/index.js @@ -0,0 +1,14 @@ +window.THREE = require('three'); + +//VRControlsHyperbolic.js acquires positional information from connected VR devices and applies the transformations to a three.js camera object. Also deals with hyperbolic and parabolic motions. +require('./three-extras/VRControlsHyperbolic.js'); +//VREffect.js handles stereo camera setup and rendering. +require('./three-extras/VREffect.js'); +require('./three-extras/OBJLoader.js'); + +//class PhoneVR to manage VR on phones. +require('./PhoneVR.js'); +require('./hypMath.js'); +require('./436.js'); +// Main Code +require('./hypTiling.js'); diff --git a/src/js/lib/hypMath.js b/src/js/lib/hypMath.js new file mode 100644 index 0000000..ddb2813 --- /dev/null +++ b/src/js/lib/hypMath.js @@ -0,0 +1,61 @@ +import { Matrix } from '../three-utils'; +import { + isMatrixInArray, + digitsDepth +} from '../hypMath'; + +// discuss at: http://phpjs.org/functions/acosh/ +// original by: Onno Marsman +// example 1: acosh(8723321.4); +// returns 1: 16.674657798418625 +const acosh = (arg) => ( Math.log(arg + Math.sqrt(arg * arg - 1))); + +const makeTsfmsList = ( tilingGens, tilingDepth ) => { + let numTsfmsEachDepth = []; + let cumulativeNumTsfms = []; + + for (let l = 0; l < tilingDepth + 1; l++) { //initialise array to zeros + numTsfmsEachDepth[numTsfmsEachDepth.length] = 0; + cumulativeNumTsfms[cumulativeNumTsfms.length] = 0; + } + + let numGens = tilingGens.length; + let tsfms = []; + let words = []; + let genPower = 1; + for (let j = 0; j < genPower; j++) { + let digits = []; + let jcopy = j; + for (let k = 0; k < tilingDepth; k++) { + digits[digits.length] = jcopy % numGens; + jcopy = (jcopy/numGens)|0; + } + // console.log(digits); + var newTsfm = new Matrix(); + for (let l = 0; l < tilingDepth; l++) { + newTsfm = newTsfm.multiply(tilingGens[digits[l]]); + } + + if ( !isMatrixInArray(newTsfm, tsfms) ) { + tsfms[tsfms.length] = newTsfm; + words[words.length] = digits; + numTsfmsEachDepth[digitsDepth(digits)] += 1; + } + genPower = Math.pow(numGens, tilingDepth); + } + + for (let i = 0; i < tilingDepth; i++){ + cumulativeNumTsfms[i] = numTsfmsEachDepth[i]; + if (i>0){ + cumulativeNumTsfms[i] += cumulativeNumTsfms[i-1]; + } + } + return [tsfms, words, cumulativeNumTsfms]; +} + +window.makeTsfmsList = makeTsfmsList; + +export { + acosh, + makeTsfmsList +}; diff --git a/src/js/lib/matrix-rotations.js b/src/js/lib/matrix-rotations.js new file mode 100644 index 0000000..00608e8 --- /dev/null +++ b/src/js/lib/matrix-rotations.js @@ -0,0 +1,18 @@ +import { Matrix } from '../three-utils'; + +const RIGHT_ANGLE = Math.PI/2; +const rotx = new Matrix().makeRotationX( RIGHT_ANGLE ); +const rotxi = new Matrix().makeRotationX( -RIGHT_ANGLE ); +const roty = new Matrix().makeRotationY( RIGHT_ANGLE ); +const rotyi = new Matrix().makeRotationY( -RIGHT_ANGLE ); +const rotz = new Matrix().makeRotationZ( RIGHT_ANGLE ); +const rotzi = new Matrix().makeRotationZ( -RIGHT_ANGLE ); + +export { + rotx, + rotxi, + roty, + rotyi, + rotz, + rotzi +}; diff --git a/src/js/load-element.js b/src/js/load-element.js new file mode 100644 index 0000000..e647178 --- /dev/null +++ b/src/js/load-element.js @@ -0,0 +1,19 @@ +export const loadElement = ({ + loader, + path, + scene, + minIterations=0, + maxIterations, + bigMatArray, + extra +}) => { + /// first, coloured cube + loader.load(path, function (object) { + for (var i = 0; i < maxIterations; i++) { + var newObject = object.clone(); + newObject.children[0].material = bigMatArray[(i + extra)]; + // newObject.children[0].frustumCulled = false; + scene.add(newObject); + } + }); +}; diff --git a/js/loaders/OBJLoader.js b/src/js/three-extras/OBJLoader.js similarity index 99% rename from js/loaders/OBJLoader.js rename to src/js/three-extras/OBJLoader.js index 6d98321..a0f757a 100644 --- a/js/loaders/OBJLoader.js +++ b/src/js/three-extras/OBJLoader.js @@ -1,3 +1,5 @@ +import 'three'; + /** * @author mrdoob / http://mrdoob.com/ */ diff --git a/js/vr/VRControlsHyperbolic.js b/src/js/three-extras/VRControlsHyperbolic.js similarity index 97% rename from js/vr/VRControlsHyperbolic.js rename to src/js/three-extras/VRControlsHyperbolic.js index ee9f81a..c2799bc 100644 --- a/js/vr/VRControlsHyperbolic.js +++ b/src/js/three-extras/VRControlsHyperbolic.js @@ -1,6 +1,11 @@ +import 'three'; +import { + fixOutsideCentralCell, + gramSchmidt +} from '../hypMath'; /** * @author dmarcos / https://github.com/dmarcos - with additions by https://github.com/hawksley and https://github.com/henryseg + with additions by https://github.com/hawksley and https://github.com/henryseg and https://github.com/AbdoulSy */ THREE.VRControls = function ( camera, done ) { @@ -79,6 +84,7 @@ THREE.VRControls = function ( camera, done ) { this.update = function() { var camera = this._camera; + let movedTowardsCentralCubeThisFrameIndex = false; var vrState = this.getVRState(); var manualRotation = this.manualRotation; var oldTime = this.updateTime; @@ -94,7 +100,7 @@ THREE.VRControls = function ( camera, done ) { offset = new THREE.Vector3(); offset.x = vrState.hmd.lastPosition[0] - vrState.hmd.position[0]; offset.y = vrState.hmd.lastPosition[1] - vrState.hmd.position[1]; - offset.z = vrState.hmd.lastPosition[2] - vrState.hmd.position[2]; + offset.z = vrState.hmd.lastPosition[2] - vrState.hmd.position[2]; } else if (this.manualMoveRate[0] != 0 || this.manualMoveRate[1] != 0 || this.manualMoveRate[2] != 0) { offset = getFwdVector().multiplyScalar(0.2 * interval * this.manualMoveRate[0]).add( getRightVector().multiplyScalar(0.2 * interval * this.manualMoveRate[1])).add( @@ -247,7 +253,7 @@ function onkey(event) { fixOutside = !fixOutside; } else if (event.keyCode == 82) { // r fixOutsideCentralCell( currentBoost, tilingGens ); - } + } } window.addEventListener("keydown", onkey, true); diff --git a/js/vr/VREffect.js b/src/js/three-extras/VREffect.js similarity index 99% rename from js/vr/VREffect.js rename to src/js/three-extras/VREffect.js index 0b8ecfa..c35f7c9 100644 --- a/js/vr/VREffect.js +++ b/src/js/three-extras/VREffect.js @@ -1,3 +1,5 @@ +import 'three'; + /** * @author dmarcos / https://github.com/dmarcos * @author hawksley / https://github.com/hawksley (added phone VR support, and fixed full screen for all devices) diff --git a/src/js/three-utils.js b/src/js/three-utils.js new file mode 100644 index 0000000..17893c9 --- /dev/null +++ b/src/js/three-utils.js @@ -0,0 +1,17 @@ +import 'three'; + +export const MESH = new THREE.Mesh(); +export const MATRIX4 = new THREE.Matrix4(); +export const Matrix = THREE.Matrix4; +export const DoubleSide = THREE.DoubleSide; +export const SCENE = new THREE.Scene(); +export const RENDERER = (props) => (new THREE.WebGLRenderer(props)); +export const CONTROLS = (camera) => (new THREE.VRControls(camera)); +export const VREFFECT = (renderer) => (new THREE.VREffect(renderer)); +export const LOADING_MANAGER = new THREE.LoadingManager(); +export const OBJLOADER = (manager) => (new THREE.OBJLoader(manager)); +export const QUATERNION = new THREE.Quaternion(); +export const SHADER_MATERIAL = (props) => (new THREE.ShaderMaterial(props)); +export const Vector3 = THREE.Vector3; +export const Quaternion = THREE.Quaternion; +export const PerspectiveCamera = THREE.PerspectiveCamera; diff --git a/src/js/update-big-mat-array.js b/src/js/update-big-mat-array.js new file mode 100644 index 0000000..ac6cdc0 --- /dev/null +++ b/src/js/update-big-mat-array.js @@ -0,0 +1,11 @@ +const updateBigMatArray = (bigMatArray= [], numObjects=1, numTiles=1, materialBase) => { + bigMatArray = new Array(numObjects * numTiles); + // one material per object, since they have a different positions + for (var i = 0; i < bigMatArray.length; i++) { + bigMatArray[i] = materialBase.clone(); + } + + return bigMatArray; +} + +export default updateBigMatArray; diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..9e518bc --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,28 @@ +var path = require('path'); + +module.exports = { + entry: './src/js/index.js', + output: { + path: path.resolve(__dirname, './dist'), + filename: 'index.bundle.js' + }, + devServer: { + contentBase: path.join(__dirname, "dist"), + compress: true, + port: 9000 + }, + module: { + rules: [ + { + test: /\.js$/, + exclude: /(node_modules|bower_components)/, + use: { + loader: 'babel-loader', + options: { + presets: ['es2017'] + } + } + } + ] + } + };