From 042c09e65b8cf6d4bf88a3c082f9004e14e17213 Mon Sep 17 00:00:00 2001 From: Pavel Smirnov Date: Mon, 5 Feb 2018 16:20:29 +0300 Subject: [PATCH] 0.7.12 --- CHANGELOG.md | 17 +- dist/Miew.js | 3115 +++++++++++++++++++++++++------------- dist/Miew.min.js | 39 +- dist/Miew.module.js | 3115 +++++++++++++++++++++++++------------- package.json | 2 +- sonar-project.properties | 2 +- 6 files changed, 4142 insertions(+), 2148 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c81cb16..a7866dd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.7.12] - 2018-02-05 +### Added +- Add `Miew#exportCML()` method to retrieve a CML contents (including modified atom coordiantes) if + a CML file was loaded. +- Add a secondary structure assignment routine: `Miew#dssp()` method and `dssp` script command. + Available from UI too. + +### Changed +- Automatic bonding uses a faster approach (voxel grid). + +### Fixed +- Fix a crash in library when TextMode is used. +- Fix a couple of bugs with parameters of surface modes in UI. + ## [0.7.11] - 2018-01-17 ### Fixed - Fixed a loading error in IE11 when a relative URL is used. @@ -199,7 +213,8 @@ in [0.7.7+hotfix] and later releases. - Update dependencies to the latest supported versions. - Move the project to GitHub. -[Unreleased]: https://github.com/epam/miew/compare/v0.7.11...HEAD +[Unreleased]: https://github.com/epam/miew/compare/v0.7.12...HEAD +[0.7.12]: https://github.com/epam/miew/compare/v0.7.11...v0.7.12 [0.7.11]: https://github.com/epam/miew/compare/v0.7.10...v0.7.11 [0.7.10]: https://github.com/epam/miew/compare/v0.7.9...v0.7.10 [0.7.9]: https://github.com/epam/miew/compare/v0.7.8...v0.7.9 diff --git a/dist/Miew.js b/dist/Miew.js index 02c4be08..dcda0717 100644 --- a/dist/Miew.js +++ b/dist/Miew.js @@ -1,4 +1,4 @@ -/** Miew - 3D Molecular Viewer v0.7.11 Copyright (c) 2015-2018 EPAM Systems, Inc. */ +/** Miew - 3D Molecular Viewer v0.7.12 Copyright (c) 2015-2018 EPAM Systems, Inc. */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : @@ -33,7 +33,7 @@ var lodash = createCommonjsModule(function (module, exports) { var undefined; /** Used as the semantic version number. */ - var VERSION = '4.17.4'; + var VERSION = '4.17.5'; /** Used as the size to enable large array optimizations. */ var LARGE_ARRAY_SIZE = 200; @@ -164,7 +164,6 @@ var lodash = createCommonjsModule(function (module, exports) { /** Used to match property names within property paths. */ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, - reLeadingDot = /^\./, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; /** @@ -264,8 +263,8 @@ var lodash = createCommonjsModule(function (module, exports) { reOptMod = rsModifier + '?', rsOptVar = '[' + rsVarRange + ']?', rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', - rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)', - rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)', + rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', + rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', rsSeq = rsOptVar + reOptMod + rsOptJoin, rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; @@ -472,34 +471,6 @@ var lodash = createCommonjsModule(function (module, exports) { /*--------------------------------------------------------------------------*/ - /** - * Adds the key-value `pair` to `map`. - * - * @private - * @param {Object} map The map to modify. - * @param {Array} pair The key-value pair to add. - * @returns {Object} Returns `map`. - */ - function addMapEntry(map, pair) { - // Don't return `map.set` because it's not chainable in IE 11. - map.set(pair[0], pair[1]); - return map; - } - - /** - * Adds `value` to `set`. - * - * @private - * @param {Object} set The set to modify. - * @param {*} value The value to add. - * @returns {Object} Returns `set`. - */ - function addSetEntry(set, value) { - // Don't return `set.add` because it's not chainable in IE 11. - set.add(value); - return set; - } - /** * A faster alternative to `Function#apply`, this function invokes `func` * with the `this` binding of `thisArg` and the arguments of `args`. @@ -1266,6 +1237,20 @@ var lodash = createCommonjsModule(function (module, exports) { return result; } + /** + * Gets the value at `key`, unless `key` is "__proto__". + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ + function safeGet(object, key) { + return key == '__proto__' + ? undefined + : object[key]; + } + /** * Converts `set` to an array of its values. * @@ -2698,7 +2683,7 @@ var lodash = createCommonjsModule(function (module, exports) { if (!cloneableTags[tag]) { return object ? value : {}; } - result = initCloneByTag(value, tag, baseClone, isDeep); + result = initCloneByTag(value, tag, isDeep); } } // Check for circular references and return its corresponding clone. @@ -2709,6 +2694,22 @@ var lodash = createCommonjsModule(function (module, exports) { } stack.set(value, result); + if (isSet(value)) { + value.forEach(function(subValue) { + result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); + }); + + return result; + } + + if (isMap(value)) { + value.forEach(function(subValue, key) { + result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + + return result; + } + var keysFunc = isFull ? (isFlat ? getAllKeysIn : getAllKeys) : (isFlat ? keysIn : keys); @@ -3636,7 +3637,7 @@ var lodash = createCommonjsModule(function (module, exports) { } else { var newValue = customizer - ? customizer(object[key], srcValue, (key + ''), object, source, stack) + ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) : undefined; if (newValue === undefined) { @@ -3663,8 +3664,8 @@ var lodash = createCommonjsModule(function (module, exports) { * counterparts. */ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { - var objValue = object[key], - srcValue = source[key], + var objValue = safeGet(object, key), + srcValue = safeGet(source, key), stacked = stack.get(srcValue); if (stacked) { @@ -4572,20 +4573,6 @@ var lodash = createCommonjsModule(function (module, exports) { return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); } - /** - * Creates a clone of `map`. - * - * @private - * @param {Object} map The map to clone. - * @param {Function} cloneFunc The function to clone values. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned map. - */ - function cloneMap(map, isDeep, cloneFunc) { - var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map); - return arrayReduce(array, addMapEntry, new map.constructor); - } - /** * Creates a clone of `regexp`. * @@ -4599,20 +4586,6 @@ var lodash = createCommonjsModule(function (module, exports) { return result; } - /** - * Creates a clone of `set`. - * - * @private - * @param {Object} set The set to clone. - * @param {Function} cloneFunc The function to clone values. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned set. - */ - function cloneSet(set, isDeep, cloneFunc) { - var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set); - return arrayReduce(array, addSetEntry, new set.constructor); - } - /** * Creates a clone of the `symbol` object. * @@ -6207,7 +6180,7 @@ var lodash = createCommonjsModule(function (module, exports) { */ function initCloneArray(array) { var length = array.length, - result = array.constructor(length); + result = new array.constructor(length); // Add properties assigned by `RegExp#exec`. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { @@ -6234,16 +6207,15 @@ var lodash = createCommonjsModule(function (module, exports) { * Initializes an object clone based on its `toStringTag`. * * **Note:** This function only supports cloning values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. * * @private * @param {Object} object The object to clone. * @param {string} tag The `toStringTag` of the object to clone. - * @param {Function} cloneFunc The function to clone values. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the initialized clone. */ - function initCloneByTag(object, tag, cloneFunc, isDeep) { + function initCloneByTag(object, tag, isDeep) { var Ctor = object.constructor; switch (tag) { case arrayBufferTag: @@ -6262,7 +6234,7 @@ var lodash = createCommonjsModule(function (module, exports) { return cloneTypedArray(object, isDeep); case mapTag: - return cloneMap(object, isDeep, cloneFunc); + return new Ctor; case numberTag: case stringTag: @@ -6272,7 +6244,7 @@ var lodash = createCommonjsModule(function (module, exports) { return cloneRegExp(object); case setTag: - return cloneSet(object, isDeep, cloneFunc); + return new Ctor; case symbolTag: return cloneSymbol(object); @@ -6319,10 +6291,13 @@ var lodash = createCommonjsModule(function (module, exports) { * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. */ function isIndex(value, length) { + var type = typeof value; length = length == null ? MAX_SAFE_INTEGER : length; + return !!length && - (typeof value == 'number' || reIsUint.test(value)) && - (value > -1 && value % 1 == 0 && value < length); + (type == 'number' || + (type != 'symbol' && reIsUint.test(value))) && + (value > -1 && value % 1 == 0 && value < length); } /** @@ -6772,11 +6747,11 @@ var lodash = createCommonjsModule(function (module, exports) { */ var stringToPath = memoizeCapped(function(string) { var result = []; - if (reLeadingDot.test(string)) { + if (string.charCodeAt(0) === 46 /* . */) { result.push(''); } - string.replace(rePropName, function(match, number, quote, string) { - result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); + string.replace(rePropName, function(match, number, quote, subString) { + result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); }); return result; }); @@ -10384,9 +10359,11 @@ var lodash = createCommonjsModule(function (module, exports) { function remainingWait(time) { var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, - result = wait - timeSinceLastCall; + timeWaiting = wait - timeSinceLastCall; - return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result; + return maxing + ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) + : timeWaiting; } function shouldInvoke(time) { @@ -12818,9 +12795,35 @@ var lodash = createCommonjsModule(function (module, exports) { * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } */ - var defaults = baseRest(function(args) { - args.push(undefined, customDefaultsAssignIn); - return apply(assignInWith, undefined, args); + var defaults = baseRest(function(object, sources) { + object = Object(object); + + var index = -1; + var length = sources.length; + var guard = length > 2 ? sources[2] : undefined; + + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + length = 1; + } + + while (++index < length) { + var source = sources[index]; + var props = keysIn(source); + var propsIndex = -1; + var propsLength = props.length; + + while (++propsIndex < propsLength) { + var key = props[propsIndex]; + var value = object[key]; + + if (value === undefined || + (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { + object[key] = source[key]; + } + } + } + + return object; }); /** @@ -13217,6 +13220,11 @@ var lodash = createCommonjsModule(function (module, exports) { * // => { '1': 'c', '2': 'b' } */ var invert = createInverter(function(result, value, key) { + if (value != null && + typeof value.toString != 'function') { + value = nativeObjectToString.call(value); + } + result[value] = key; }, constant(identity)); @@ -13247,6 +13255,11 @@ var lodash = createCommonjsModule(function (module, exports) { * // => { 'group1': ['a', 'c'], 'group2': ['b'] } */ var invertBy = createInverter(function(result, value, key) { + if (value != null && + typeof value.toString != 'function') { + value = nativeObjectToString.call(value); + } + if (hasOwnProperty.call(result, value)) { result[value].push(key); } else { @@ -61326,381 +61339,257 @@ var THREE = Object.freeze({ CanvasRenderer: CanvasRenderer }); -var spin = createCommonjsModule(function (module) { -/** - * Copyright (c) 2011-2014 Felix Gnass - * Licensed under the MIT license - * http://spin.js.org/ - * - * Example: - var opts = { - lines: 12 // The number of lines to draw - , length: 7 // The length of each line - , width: 5 // The line thickness - , radius: 10 // The radius of the inner circle - , scale: 1.0 // Scales overall size of the spinner - , corners: 1 // Roundness (0..1) - , color: '#000' // #rgb or #rrggbb - , opacity: 1/4 // Opacity of the lines - , rotate: 0 // Rotation offset - , direction: 1 // 1: clockwise, -1: counterclockwise - , speed: 1 // Rounds per second - , trail: 100 // Afterglow percentage - , fps: 20 // Frames per second when using setTimeout() - , zIndex: 2e9 // Use a high z-index by default - , className: 'spinner' // CSS class to assign to the element - , top: '50%' // center vertically - , left: '50%' // center horizontally - , shadow: false // Whether to render a shadow - , hwaccel: false // Whether to use hardware acceleration (might be buggy) - , position: 'absolute' // Element positioning - } - var target = document.getElementById('foo') - var spinner = new Spinner(opts).spin(target) - */ -(function (root, factory) { - - /* CommonJS */ - if ('object' == 'object' && module.exports) module.exports = factory(); - - /* AMD module */ - else if (typeof undefined == 'function' && undefined.amd) undefined(factory); - - /* Browser global */ - else root.Spinner = factory(); -}(commonjsGlobal, function () { - var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */ - , animations = {} /* Animation rules keyed by their name */ - , useCssAnimations /* Whether to use CSS animations or setTimeout */ - , sheet; /* A stylesheet to hold the @keyframe or VML rules. */ - - /** - * Utility function to create elements. If no tag name is given, - * a DIV is created. Optionally properties can be passed. - */ - function createEl (tag, prop) { - var el = document.createElement(tag || 'div') - , n; - - for (n in prop) el[n] = prop[n]; - return el - } - - /** - * Appends children and returns the parent. - */ - function ins (parent /* child1, child2, ...*/) { - for (var i = 1, n = arguments.length; i < n; i++) { - parent.appendChild(arguments[i]); - } - - return parent - } - - /** - * Creates an opacity keyframe animation rule and returns its name. - * Since most mobile Webkits have timing issues with animation-delay, - * we create separate rules for each line/segment. - */ - function addAnimation (alpha, trail, i, lines) { - var name = ['opacity', trail, ~~(alpha * 100), i, lines].join('-') - , start = 0.01 + i/lines * 100 - , z = Math.max(1 - (1-alpha) / trail * (100-start), alpha) - , prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase() - , pre = prefix && '-' + prefix + '-' || ''; - - if (!animations[name]) { - sheet.insertRule( - '@' + pre + 'keyframes ' + name + '{' + - '0%{opacity:' + z + '}' + - start + '%{opacity:' + alpha + '}' + - (start+0.01) + '%{opacity:1}' + - (start+trail) % 100 + '%{opacity:' + alpha + '}' + - '100%{opacity:' + z + '}' + - '}', sheet.cssRules.length); - - animations[name] = 1; - } - - return name - } - - /** - * Tries various vendor prefixes and returns the first supported property. - */ - function vendor (el, prop) { - var s = el.style - , pp - , i; - - prop = prop.charAt(0).toUpperCase() + prop.slice(1); - if (s[prop] !== undefined) return prop - for (i = 0; i < prefixes.length; i++) { - pp = prefixes[i]+prop; - if (s[pp] !== undefined) return pp - } - } - - /** - * Sets multiple style properties at once. - */ - function css (el, prop) { - for (var n in prop) { - el.style[vendor(el, n) || n] = prop[n]; - } - - return el - } - - /** - * Fills in default values. - */ - function merge (obj) { - for (var i = 1; i < arguments.length; i++) { - var def = arguments[i]; - for (var n in def) { - if (obj[n] === undefined) obj[n] = def[n]; - } +var __assign = (undefined && undefined.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; +var defaults = { + lines: 12, + length: 7, + width: 5, + radius: 10, + scale: 1.0, + corners: 1, + color: '#000', + fadeColor: 'transparent', + opacity: 0.25, + rotate: 0, + direction: 1, + speed: 1, + trail: 100, + fps: 20, + zIndex: 2e9, + className: 'spinner', + top: '50%', + left: '50%', + shadow: 'none', + position: 'absolute', +}; +var Spinner = /** @class */ (function () { + function Spinner(opts) { + if (opts === void 0) { opts = {}; } + this.opts = __assign({}, defaults, opts); } - return obj - } - - /** - * Returns the line color from the given string or array. - */ - function getColor (color, idx) { - return typeof color == 'string' ? color : color[idx % color.length] - } - - // Built-in defaults - - var defaults = { - lines: 12 // The number of lines to draw - , length: 7 // The length of each line - , width: 5 // The line thickness - , radius: 10 // The radius of the inner circle - , scale: 1.0 // Scales overall size of the spinner - , corners: 1 // Roundness (0..1) - , color: '#000' // #rgb or #rrggbb - , opacity: 1/4 // Opacity of the lines - , rotate: 0 // Rotation offset - , direction: 1 // 1: clockwise, -1: counterclockwise - , speed: 1 // Rounds per second - , trail: 100 // Afterglow percentage - , fps: 20 // Frames per second when using setTimeout() - , zIndex: 2e9 // Use a high z-index by default - , className: 'spinner' // CSS class to assign to the element - , top: '50%' // center vertically - , left: '50%' // center horizontally - , shadow: false // Whether to render a shadow - , hwaccel: false // Whether to use hardware acceleration (might be buggy) - , position: 'absolute' // Element positioning - }; - - /** The constructor */ - function Spinner (o) { - this.opts = merge(o || {}, Spinner.defaults, defaults); - } - - // Global defaults that override the built-ins: - Spinner.defaults = {}; - - merge(Spinner.prototype, { /** * Adds the spinner to the given target element. If this instance is already - * spinning, it is automatically removed from its previous target b calling + * spinning, it is automatically removed from its previous target by calling * stop() internally. */ - spin: function (target) { - this.stop(); - - var self = this - , o = self.opts - , el = self.el = createEl(null, {className: o.className}); - - css(el, { - position: o.position - , width: 0 - , zIndex: o.zIndex - , left: o.left - , top: o.top - }); - - if (target) { - target.insertBefore(el, target.firstChild || null); - } - - el.setAttribute('role', 'progressbar'); - self.lines(el, self.opts); - - if (!useCssAnimations) { - // No CSS animation support, use setTimeout() instead - var i = 0 - , start = (o.lines - 1) * (1 - o.direction) / 2 - , alpha - , fps = o.fps - , f = fps / o.speed - , ostep = (1 - o.opacity) / (f * o.trail / 100) - , astep = f / o.lines;(function anim () { - i++; - for (var j = 0; j < o.lines; j++) { - alpha = Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity); - - self.opacity(el, j * o.direction + start, alpha, o); - } - self.timeout = self.el && setTimeout(anim, ~~(1000 / fps)); - })(); - } - return self - } - + Spinner.prototype.spin = function (target) { + var _this = this; + this.stop(); + this.el = document.createElement('div'); + this.el.className = this.opts.className; + this.el.setAttribute('role', 'progressbar'); + css(this.el, { + position: this.opts.position, + width: 0, + zIndex: this.opts.zIndex, + left: this.opts.left, + top: this.opts.top, + transform: "scale(" + this.opts.scale + ")", + }); + if (target) { + target.insertBefore(this.el, target.firstChild || null); + } + var animator; + var getNow; + if (typeof requestAnimationFrame !== 'undefined') { + animator = requestAnimationFrame; + getNow = function () { return performance.now(); }; + } + else { + // fallback for IE 9 + animator = function (callback) { return setTimeout(callback, 1000 / _this.opts.fps); }; + getNow = function () { return Date.now(); }; + } + var lastFrameTime; + var state = 0; // state is rotation percentage (between 0 and 1) + var animate = function () { + var time = getNow(); + if (lastFrameTime === undefined) { + lastFrameTime = time - 1; + } + state += getAdvancePercentage(time - lastFrameTime, _this.opts.speed); + lastFrameTime = time; + if (state > 1) { + state -= Math.floor(state); + } + if (_this.el.childNodes.length === _this.opts.lines) { + for (var line = 0; line < _this.opts.lines; line++) { + var opacity = getLineOpacity(line, state, _this.opts); + _this.el.childNodes[line].childNodes[0].style.opacity = opacity.toString(); + } + } + _this.animateId = _this.el ? animator(animate) : undefined; + }; + drawLines(this.el, this.opts); + animate(); + return this; + }; /** * Stops and removes the Spinner. + * Stopped spinners may be reused by calling spin() again. */ - , stop: function () { - var el = this.el; - if (el) { - clearTimeout(this.timeout); - if (el.parentNode) el.parentNode.removeChild(el); - this.el = undefined; - } - return this - } - - /** - * Internal method that draws the individual lines. Will be overwritten - * in VML fallback mode below. - */ - , lines: function (el, o) { - var i = 0 - , start = (o.lines - 1) * (1 - o.direction) / 2 - , seg; - - function fill (color, shadow) { - return css(createEl(), { - position: 'absolute' - , width: o.scale * (o.length + o.width) + 'px' - , height: o.scale * o.width + 'px' - , background: color - , boxShadow: shadow - , transformOrigin: 'left' - , transform: 'rotate(' + ~~(360/o.lines*i + o.rotate) + 'deg) translate(' + o.scale*o.radius + 'px' + ',0)' - , borderRadius: (o.corners * o.scale * o.width >> 1) + 'px' - }) - } - - for (; i < o.lines; i++) { - seg = css(createEl(), { - position: 'absolute' - , top: 1 + ~(o.scale * o.width / 2) + 'px' - , transform: o.hwaccel ? 'translate3d(0,0,0)' : '' - , opacity: o.opacity - , animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1 / o.speed + 's linear infinite' - }); - - if (o.shadow) ins(seg, css(fill('#000', '0 0 4px #000'), {top: '2px'})); - ins(el, ins(seg, fill(getColor(o.color, i), '0 0 1px rgba(0,0,0,.1)'))); - } - return el + Spinner.prototype.stop = function () { + if (this.el) { + if (typeof requestAnimationFrame !== 'undefined') { + cancelAnimationFrame(this.animateId); + } + else { + clearTimeout(this.animateId); + } + if (this.el.parentNode) { + this.el.parentNode.removeChild(this.el); + } + this.el = undefined; + } + return this; + }; + return Spinner; +}()); +function getAdvancePercentage(msSinceLastFrame, roundsPerSecond) { + return msSinceLastFrame / 1000 * roundsPerSecond; +} +function getLineOpacity(line, state, opts) { + var linePercent = (line + 1) / opts.lines; + var diff = state - (linePercent * opts.direction); + if (diff < 0 || diff > 1) { + diff += opts.direction; + } + // opacity should start at 1, and approach opacity option as diff reaches trail percentage + var trailPercent = opts.trail / 100; + var opacityPercent = 1 - diff / trailPercent; + if (opacityPercent < 0) { + return opts.opacity; + } + var opacityDiff = 1 - opts.opacity; + return opacityPercent * opacityDiff + opts.opacity; +} +/** + * Tries various vendor prefixes and returns the first supported property. + */ +function vendor(el, prop) { + if (el.style[prop] !== undefined) { + return prop; } - - /** - * Internal method that adjusts the opacity of a single line. - * Will be overwritten in VML fallback mode below. - */ - , opacity: function (el, i, val) { - if (i < el.childNodes.length) el.childNodes[i].style.opacity = val; + // needed for transform properties in IE 9 + var prefixed = 'ms' + prop.charAt(0).toUpperCase() + prop.slice(1); + if (el.style[prefixed] !== undefined) { + return prefixed; } - - }); - - - function initVML () { - - /* Utility function to create a VML tag */ - function vml (tag, attr) { - return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr) + return ''; +} +/** + * Sets multiple style properties at once. + */ +function css(el, props) { + for (var prop in props) { + el.style[vendor(el, prop) || prop] = props[prop]; } - - // No CSS transforms but VML support, add a CSS rule for VML elements: - sheet.addRule('.spin-vml', 'behavior:url(#default#VML)'); - - Spinner.prototype.lines = function (el, o) { - var r = o.scale * (o.length + o.width) - , s = o.scale * 2 * r; - - function grp () { - return css( - vml('group', { - coordsize: s + ' ' + s - , coordorigin: -r + ' ' + -r - }) - , { width: s, height: s } - ) - } - - var margin = -(o.width + o.length) * o.scale * 2 + 'px' - , g = css(grp(), {position: 'absolute', top: margin, left: margin}) - , i; - - function seg (i, dx, filter) { - ins( - g - , ins( - css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}) - , ins( - css( - vml('roundrect', {arcsize: o.corners}) - , { width: r - , height: o.scale * o.width - , left: o.scale * o.radius - , top: -o.scale * o.width >> 1 - , filter: filter - } - ) - , vml('fill', {color: getColor(o.color, i), opacity: o.opacity}) - , vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change - ) - ) - ); - } - - if (o.shadow) - for (i = 1; i <= o.lines; i++) { - seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)'); + return el; +} +/** + * Returns the line color from the given string or array. + */ +function getColor(color, idx) { + return typeof color == 'string' ? color : color[idx % color.length]; +} +/** + * Internal method that draws the individual lines. + */ +function drawLines(el, opts) { + var borderRadius = (Math.round(opts.corners * opts.width * 500) / 1000) + 'px'; + var shadow = 'none'; + if (opts.shadow === true) { + shadow = '0 2px 4px #000'; // default shadow + } + else if (typeof opts.shadow === 'string') { + shadow = opts.shadow; + } + var shadows = parseBoxShadow(shadow); + for (var i = 0; i < opts.lines; i++) { + var degrees = ~~(360 / opts.lines * i + opts.rotate); + var backgroundLine = css(document.createElement('div'), { + position: 'absolute', + top: -opts.width / 2 + "px", + width: (opts.length + opts.width) + 'px', + height: opts.width + 'px', + background: getColor(opts.fadeColor, i), + borderRadius: borderRadius, + transformOrigin: 'left', + transform: "rotate(" + degrees + "deg) translateX(" + opts.radius + "px)", + }); + var line = css(document.createElement('div'), { + width: '100%', + height: '100%', + background: getColor(opts.color, i), + borderRadius: borderRadius, + boxShadow: normalizeShadow(shadows, degrees), + opacity: opts.opacity, + }); + backgroundLine.appendChild(line); + el.appendChild(backgroundLine); + } +} +function parseBoxShadow(boxShadow) { + var regex = /^\s*([a-zA-Z]+\s+)?(-?\d+(\.\d+)?)([a-zA-Z]*)\s+(-?\d+(\.\d+)?)([a-zA-Z]*)(.*)$/; + var shadows = []; + for (var _i = 0, _a = boxShadow.split(','); _i < _a.length; _i++) { + var shadow = _a[_i]; + var matches = shadow.match(regex); + if (matches === null) { + continue; // invalid syntax } - - for (i = 1; i <= o.lines; i++) seg(i); - return ins(el, g) - }; - - Spinner.prototype.opacity = function (el, i, val, o) { - var c = el.firstChild; - o = o.shadow && o.lines || 0; - if (c && i + o < c.childNodes.length) { - c = c.childNodes[i + o]; c = c && c.firstChild; c = c && c.firstChild; - if (c) c.opacity = val; - } - }; - } - - if (typeof document !== 'undefined') { - sheet = (function () { - var el = createEl('style', {type : 'text/css'}); - ins(document.getElementsByTagName('head')[0], el); - return el.sheet || el.styleSheet - }()); - - var probe = css(createEl('group'), {behavior: 'url(#default#VML)'}); - - if (!vendor(probe, 'transform') && probe.adj) initVML(); - else useCssAnimations = vendor(probe, 'animation'); - } - - return Spinner - -})); -}); + var x = +matches[2]; + var y = +matches[5]; + var xUnits = matches[4]; + var yUnits = matches[7]; + if (x === 0 && !xUnits) { + xUnits = yUnits; + } + if (y === 0 && !yUnits) { + yUnits = xUnits; + } + if (xUnits !== yUnits) { + continue; // units must match to use as coordinates + } + shadows.push({ + prefix: matches[1] || '', + x: x, + y: y, + xUnits: xUnits, + yUnits: yUnits, + end: matches[8], + }); + } + return shadows; +} +/** + * Modify box-shadow x/y offsets to counteract rotation + */ +function normalizeShadow(shadows, degrees) { + var normalized = []; + for (var _i = 0, shadows_1 = shadows; _i < shadows_1.length; _i++) { + var shadow = shadows_1[_i]; + var xy = convertOffset(shadow.x, shadow.y, degrees); + normalized.push(shadow.prefix + xy[0] + shadow.xUnits + ' ' + xy[1] + shadow.yUnits + shadow.end); + } + return normalized.join(', '); +} +function convertOffset(x, y, degrees) { + var radians = degrees * Math.PI / 180; + var sin = Math.sin(radians); + var cos = Math.cos(radians); + return [ + Math.round((x * cos + y * sin) * 1000) / 1000, + Math.round((-x * sin + y * cos) * 1000) / 1000, + ]; +} /** * This class introduces the simplest event system. @@ -62581,7 +62470,20 @@ var createClass = function () { +var defineProperty = function (obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; +}; @@ -62740,7 +62642,7 @@ var VERSION = 0; * @alias SettingsObject * @namespace */ -var defaults$1 = { +var defaults$2 = { /** * Default options for all available modes. * Use {@link Mode.id} as a dictionary key to access mode options. @@ -63536,7 +63438,7 @@ function Settings() { Settings.prototype = { constructor: Settings, - defaults: defaults$1, + defaults: defaults$2, set: function set(path, value) { lodash.set(this.now, path, value); @@ -63548,7 +63450,7 @@ Settings.prototype = { }, reset: function reset() { - this.now = lodash.cloneDeep(defaults$1); + this.now = lodash.cloneDeep(defaults$2); this.old = null; this._changed = {}; }, @@ -63589,7 +63491,7 @@ Settings.prototype = { }, getDiffs: function getDiffs(versioned) { - var diffs = utils.objectsDiff(this.now, defaults$1); + var diffs = utils.objectsDiff(this.now, defaults$2); if (versioned) { diffs.VERSION = VERSION; } @@ -63597,7 +63499,7 @@ Settings.prototype = { }, setPluginOpts: function setPluginOpts(plugin, opts) { - defaults$1.plugins[plugin] = lodash.cloneDeep(opts); + defaults$2.plugins[plugin] = lodash.cloneDeep(opts); this.now.plugins[plugin] = lodash.cloneDeep(opts); } }; @@ -63723,13 +63625,13 @@ function extractArgs(input, defaultsDict, params) { var args = input.substr(bang + 1).split(cLSep); input = inputVal; if (defaultsDict) { - var defaults$$1 = defaultsDict[input]; - var opts = utils.deriveDeep(defaults$$1, true); + var defaults = defaultsDict[input]; + var opts = utils.deriveDeep(defaults, true); args.forEach(function (arg) { var pair = arg.split(cL2Ass, 2); var key = decodeURIComponent(pair[0]), value = decodeURIComponent(pair[1]); - var adapter = adapters[_typeof(lodash.get(defaults$$1, key))]; + var adapter = adapters[_typeof(lodash.get(defaults, key))]; if (adapter) { lodash.set(opts, key, adapter(value)); } else { @@ -67549,7 +67451,7 @@ Component.prototype.getMaskedSubdivSequences = function (mask) { ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// var cMaxPairsForHashCode = 32; -var cHashTableSize = 16384; +var cHashTableSize = 1024 * 1024; var cNumbersPerPair = 4; var cMaxNeighbours = 14; var cInvalidVal = -1; @@ -67598,7 +67500,7 @@ AtomPairs.prototype.addPair = function (indexA, indexB) { break; } if (code === codeToAdd) { - return; + return false; } } // add this new hash code @@ -67616,6 +67518,7 @@ AtomPairs.prototype.addPair = function (indexA, indexB) { this.intBuffer[j + 1] = ib; this.intBuffer[j + 2] = codeToAdd; this.numPairs++; + return true; }; ////////////////////////////////////////////////////////////////////////////// @@ -67643,23 +67546,6 @@ function _getBondingRadius(atom) { } } -/** - * Returns value, limited in given range (min, max) - * @param {number} val modified value - * @param {number} valMin minimum value in range - * @param {number} valMax maximum value in range - * @returns {number} original value (if it lie inside range) or range bound (left or right) - */ -function _clamp(val, valMin, valMax) { - if (val < valMin) { - return valMin; - } - if (val > valMax) { - return valMax; - } - return val; -} - function _isAtomEligible(atom) { // build for all non-hetatm and for hetatm without bonds return !atom.isHet() || atom._bonds && atom._bonds.length === 0; @@ -67713,80 +67599,60 @@ AutoBond.prototype._addExistingPairs = function () { return 0; }; -AutoBond.prototype._findPairs = function (volMap) { +AutoBond.prototype._findPairs = function () { + var vw = this._complex.getVoxelWorld(); + if (vw === null) { + return; + } + var atoms = this._complex._atoms; var atomsNum = atoms.length; - var vBoxMin = this._vBoxMin; - var xB = this.xB; - var yB = this.yB; - var zB = this.zB; - var invPairDist = this.invPairDist; - var xyTotalBoxes = yB * xB; var isAtomEligible = this.isAtomEligible; + var self = this; - for (var i = 0; i < atomsNum; ++i) { - var atom = atoms[i]; - if (!isAtomEligible(atom)) { - continue; + var rA = void 0; + var isHydrogenA = void 0; + var posA = void 0; + var locationA = void 0; + var atomA = void 0; + + var processAtom = function processAtom(atomB) { + if (isHydrogenA && atomB.isHydrogen()) { + return; } - var rA = atom.element.radiusBonding; - // 'H' == 72 - var isHydrogenA = atom.isHydrogen(); - var locationA = atom.getLocation(); + var locationB = atomB.getLocation(); + if (locationA !== cSpaceCode && locationB !== cSpaceCode && locationA !== locationB) { + return; + } - var posA = atom._position; - var axB = (posA.x - vBoxMin.x) * invPairDist | 0; - var ayB = (posA.y - vBoxMin.y) * invPairDist | 0; - var azB = (posA.z - vBoxMin.z) * invPairDist | 0; + var dist2 = posA.distanceToSquared(atomB._position); + var rB = atomB.element.radiusBonding; + var maxAcceptable = cBondRadInJMOL ? rA + rB + cBondTolerance : cVMDTolerance * (rA + rB); - for (var dz = -1; dz <= 1; ++dz) { - var zInd = azB + dz; - if (zInd < 0 || zInd >= zB) { - continue; - } - for (var dy = -1; dy <= 1; ++dy) { - var yInd = ayB + dy; - if (yInd < 0 || yInd >= yB) { - continue; - } - for (var dx = -1; dx <= 1; ++dx) { - var xInd = axB + dx; - if (xInd < 0 || xInd >= xB) { - continue; - } - var iIndex = zInd * xyTotalBoxes + yInd * xB + xInd; - var neighbours = volMap[iIndex]; - for (var j = 0; j < neighbours.length; ++j) { - var iB = neighbours[j]; - if (iB <= i) { - continue; - } - var atomB = atoms[iB]; - if (isHydrogenA && atomB.isHydrogen()) { - continue; - } + if (dist2 > maxAcceptable * maxAcceptable) { + return; + } - var locationB = atomB.getLocation(); - if (locationA !== cSpaceCode && locationB !== cSpaceCode && locationA !== locationB) { - continue; - } - var dist2 = posA.distanceToSquared(atomB._position); - var rB = atomB.element.radiusBonding; - var maxAcceptable = cBondRadInJMOL ? rA + rB + cBondTolerance : cVMDTolerance * (rA + rB); - if (dist2 > maxAcceptable * maxAcceptable) { - continue; - } + if (dist2 < cEpsilon) { + return; + } - if (dist2 < cEpsilon) { - continue; - } + self._pairCollection.addPair(atomA._index, atomB._index); + }; - this._pairCollection.addPair(i, iB); - } - } - } + for (var i = 0; i < atomsNum; ++i) { + atomA = atoms[i]; + if (!isAtomEligible(atomA)) { + continue; } + + rA = atomA.element.radiusBonding; + isHydrogenA = atomA.isHydrogen(); + posA = atomA._position; + locationA = atomA.getLocation(); + + vw.forEachAtomWithinRadius(posA, 2 * this._maxRad + cBondTolerance, processAtom); } }; @@ -67870,10 +67736,9 @@ AutoBond.prototype._buildInner = function () { this.isAtomEligible = settings.now.draft.waterBondingHack ? _isAtomEligibleWithWaterBondingHack : _isAtomEligible; this._calcBoundingBox(); - var volMap = this._buildGridMap(); this._pairCollection = new AtomPairs(atoms.length * cEstBondsMultiplier); this._addExistingPairs(); - this._findPairs(volMap); + this._findPairs(); this._addPairs(); }; @@ -67889,60 +67754,6 @@ AutoBond.prototype._calcBoundingBox = function () { this._maxRad = maxRad * 1.2; }; -AutoBond.prototype._buildGridMap = function () { - var cMaxBoxes = 125000; - var cRadMultiplier = 1.26; - - var pairDist = this._maxRad * 2; - var newPairDist = pairDist; - var vBoxMin = this._vBoxMin; - var vBoxMax = this._vBoxMax; - var xRange = vBoxMax.x - vBoxMin.x; - var yRange = vBoxMax.y - vBoxMin.y; - var zRange = vBoxMax.z - vBoxMin.z; - var xB, yB, zB, xyTotalBoxes; - var invPairDist; - var totalBoxes; - - do { - pairDist = newPairDist; - invPairDist = 1.0 / pairDist; - xB = (xRange * invPairDist | 0) + 1; - yB = (yRange * invPairDist | 0) + 1; - zB = (zRange * invPairDist | 0) + 1; - xyTotalBoxes = yB * xB; - totalBoxes = xyTotalBoxes * zB; - newPairDist = pairDist * cRadMultiplier; - } while (totalBoxes > cMaxBoxes); - this.xB = xB; - this.yB = yB; - this.zB = zB; - this.invPairDist = invPairDist; - - var voxMap = []; - var i = 0; - for (; i < totalBoxes; ++i) { - voxMap[i] = []; - } - var atoms = this._complex._atoms; - var nAtoms = atoms.length; - var isAtomEligible = this.isAtomEligible; - for (i = 0; i < nAtoms; ++i) { - if (!isAtomEligible(atoms[i])) { - continue; - } - var pos = atoms[i]._position; - var axB = _clamp((pos.x - vBoxMin.x) * invPairDist | 0, 0, xB); - var ayB = _clamp((pos.y - vBoxMin.y) * invPairDist | 0, 0, yB); - var azB = _clamp((pos.z - vBoxMin.z) * invPairDist | 0, 0, zB); - - var iIndex = azB * xyTotalBoxes + ayB * xB + axB; - voxMap[iIndex].push(i); - } - - return voxMap; -}; - AutoBond.prototype.destroy = function () { if (this._pairCollection) { this._pairCollection.destroy(); @@ -68190,6 +68001,1343 @@ AromaticLoopsMarker.prototype.detectCycles = function () { ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// +/** + * Calculate min & max radius of a sphere slice between zMin & zMax + * + * @param {Vector3} center - center of the sphere + * @param {number} radius - sphere radius + * @param {number} zMin - lower bound of the slice + * @param {number} zMax - upper bound of the slice + */ +function _getSphereSliceRadiusRange(center, radius, zMin, zMax) { + var dzMin = zMin - center.z; + var dzMax = zMax - center.z; + var rzMin = Math.sqrt(Math.max(radius * radius - dzMin * dzMin, 0.0)); + var rzMax = Math.sqrt(Math.max(radius * radius - dzMax * dzMax, 0.0)); + + var rMin = Math.min(rzMin, rzMax); + var rMax; + + if (zMin <= center.z && zMax >= center.z) { + // sphere's main diameter is inside slice + rMax = radius; + } else { + rMax = Math.max(rzMin, rzMax); + } + + return [rMin, rMax]; +} + +/** + * Calculate min & max radius of a circle slice between yMin & yMax. + * + * To maintain analogy with _getSphereSliceRadiusRange we call radius what in fact is + * half-width (along X axis) of the slice, i.e. 1D-sphere radius. + * + * @param {Vector3} center - center of the circle (z can be ignored) + * @param {number} radius - circle radius + * @param {number} yMin - lower bound of the slice + * @param {number} yMax - upper bound of the slice + * @returns {Array} - array of two numbers (min & max radius, or half-width) + */ +function _getCircleSliceRadiusRange(center, radius, yMin, yMax) { + var dyMin = yMin - center.y; + var dyMax = yMax - center.y; + var ryMin = Math.sqrt(Math.max(radius * radius - dyMin * dyMin, 0.0)); + var ryMax = Math.sqrt(Math.max(radius * radius - dyMax * dyMax, 0.0)); + + var rMin = Math.min(ryMin, ryMax); + var rMax; + + if (yMin <= center.y && yMax >= center.y) { + // slice's main diameter is inside slice + rMax = radius; + } else { + rMax = Math.max(ryMin, ryMax); + } + + return [rMin, rMax]; +} + +/** + * VoxelWorld constructor + * + * @param {Box3} box - bounding box of the volume to be partitioned + * @param {Vector3} vCellSizeHint - target voxel size (actual voxel size may differ from this) + */ +function VoxelWorld(box, vCellSizeHint) { + var i; + + this._box = box.clone(); + this._count = box.getSize().divide(vCellSizeHint).floor(); + this._last = this._count.clone().subScalar(1); + this._cellSize = box.getSize().divide(this._count); + this._cellInnerR = 0.5 * Math.min(Math.min(this._cellSize.x, this._cellSize.y), this._cellSize.z); + this._cellOuterR = 0.5 * Math.sqrt(this._cellSize.dot(this._cellSize)); + + // array of voxels, each element contains index of first atom in voxel + var numVoxels = this._count.x * this._count.y * this._count.z; + this._voxels = utils.allocateTyped(Int32Array, numVoxels); + for (i = 0; i < numVoxels; ++i) { + this._voxels[i] = -1; + } + + // array of atoms that stores multiple single-linked lists + // two elements for each atom: Atom ref, index of next atom (in this array + this._atoms = []; +} + +/** + * Add all atoms from a complex to voxel world + * + * @param {Complex} complex - complex + */ +VoxelWorld.prototype.addAtoms = function (complex) { + var self = this; + + var idx = this._atoms.length; + + // resize array of atoms + this._atoms.length = this._atoms.length + 2 * complex.getAtomCount(); + + complex.forEachAtom(function (atom) { + // find which voxel contains this atom + var voxelIdx = self._findVoxel(atom._position); + + // push current atom to the head of voxel's atom list + self._atoms[idx] = atom; + self._atoms[idx + 1] = self._voxels[voxelIdx]; + self._voxels[voxelIdx] = idx; + + idx += 2; + }); +}; + +/** + * Get voxel that contains specified 3D point (we use clamp at the edges) + * + * @param {Vector3} point - a point in 3D + * @returns {number} - index of voxel + */ +VoxelWorld.prototype._findVoxel = function () { + var zero = new Vector3(0, 0, 0); + var voxel = new Vector3(); + + return function (point) { + voxel.copy(point).sub(this._box.min).divide(this._cellSize).floor().clamp(zero, this._last); + return voxel.x + this._count.x * (voxel.y + this._count.y * voxel.z); + }; +}(); + +/** + * Call a function for each atom in voxel + * + * @param {number} voxel - index of voxel + * @param {function(Atom)} process - function to call + */ +VoxelWorld.prototype._forEachAtomInVoxel = function (voxel, process) { + for (var i = this._voxels[voxel]; i >= 0; i = this._atoms[i + 1]) { + process(this._atoms[i]); + } +}; + +/** + * Call a function for each voxel that is touched by given sphere. Callback also takes flag + * isInside specifying whether voxel lies inside the sphere entirely. + * + * @param {Vector3} center - center of the sphere + * @param {number} radius - sphere radius + * @param {function(number,bool)} process - function to call that takes voxel index and boolean isInside + */ +VoxelWorld.prototype._forEachVoxelWithinRadius = function () { + var xRange = new Vector2(); + var yRange = new Vector2(); + var zRange = new Vector2(); + + return function (center, radius, process) { + // switch to a faster method unless cell size is much smaller than sphere radius + if (radius / this._cellInnerR < 10) { + this._forEachVoxelWithinRadiusSimple(center, radius, process); + return; + } + + var rRangeXY = void 0, + rRangeX = void 0, + xVal = void 0, + yVal = void 0, + zVal = void 0, + isInsideX = void 0, + isInsideY = void 0, + isInsideZ = void 0; + + zRange.set(center.z - radius, center.z + radius); + zRange.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor().clampScalar(0, this._count.z - 1); + + for (var z = zRange.x; z <= zRange.y; ++z) { + zVal = [this._box.min.z + z * this._cellSize.z, this._box.min.z + (z + 1) * this._cellSize.z]; + + isInsideZ = center.z - radius <= zVal[0] && zVal[1] <= center.z + radius; + + rRangeXY = _getSphereSliceRadiusRange(center, radius, zVal[0], zVal[1]); + + yRange.set(center.y - rRangeXY[1], center.y + rRangeXY[1]); + yRange.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor().clampScalar(0, this._count.y - 1); + + for (var y = yRange.x; y <= yRange.y; ++y) { + yVal = [this._box.min.y + y * this._cellSize.y, this._box.min.y + (y + 1) * this._cellSize.y]; + + isInsideY = center.y - rRangeXY[0] <= yVal[0] && yVal[1] <= center.y + rRangeXY[0]; + + rRangeX = _getCircleSliceRadiusRange(center, rRangeXY[1], yVal[0], yVal[1]); + + xRange.set(center.x - rRangeX[1], center.x + rRangeX[1]); + xRange.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor().clampScalar(0, this._count.x - 1); + + for (var x = xRange.x; x <= xRange.y; ++x) { + xVal = [this._box.min.x + x * this._cellSize.x, this._box.min.x + (x + 1) * this._cellSize.x]; + isInsideX = center.x - rRangeX[0] <= xVal[0] && xVal[1] <= center.x + rRangeX[0]; + + process(x + this._count.x * (y + this._count.y * z), isInsideX && isInsideY && isInsideZ); + } + } + } + }; +}(); + +/** + * Call a function for each voxel that is touched by given sphere. Callback also takes flag + * isInside specifying whether voxel lies inside the sphere entirely. + * This is a version of method that doesn't try to "calculate" what voxels fall inside radius + * but instead just checks all voxels inside sphere's bounding box. This should be faster + * unless cell size is much smaller than sphere radius. + * + * @param {Vector3} center - center of the sphere + * @param {number} radius - sphere radius + * @param {function(number,bool)} process - function to call that takes voxel index and boolean isInside + */ +VoxelWorld.prototype._forEachVoxelWithinRadiusSimple = function () { + var xRange = new Vector2(); + var yRange = new Vector2(); + var zRange = new Vector2(); + var vCenter = new Vector3(); + + return function (center, radius, process) { + var distTouch2 = (radius + this._cellOuterR) * (radius + this._cellOuterR); + var distInside2 = -1.0; + if (radius > this._cellOuterR) { + distInside2 = (radius - this._cellOuterR) * (radius - this._cellOuterR); + } + + // calculate bounding box for the sphere + xRange.set(center.x - radius, center.x + radius); + xRange.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor(); + xRange.x = Math.min(Math.max(xRange.x, 0), this._count.x - 1); + xRange.y = Math.min(Math.max(xRange.y, 0), this._count.x - 1); + + yRange.set(center.y - radius, center.y + radius); + yRange.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor(); + yRange.x = Math.min(Math.max(yRange.x, 0), this._count.y - 1); + yRange.y = Math.min(Math.max(yRange.y, 0), this._count.y - 1); + + zRange.set(center.z - radius, center.z + radius); + zRange.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor(); + zRange.x = Math.min(Math.max(zRange.x, 0), this._count.z - 1); + zRange.y = Math.min(Math.max(zRange.y, 0), this._count.z - 1); + + for (var z = zRange.x; z <= zRange.y; ++z) { + var zVal = [this._box.min.z + z * this._cellSize.z, this._box.min.z + (z + 1) * this._cellSize.z]; + vCenter.z = 0.5 * (zVal[0] + zVal[1]); + + for (var y = yRange.x; y <= yRange.y; ++y) { + var yVal = [this._box.min.y + y * this._cellSize.y, this._box.min.y + (y + 1) * this._cellSize.y]; + vCenter.y = 0.5 * (yVal[0] + yVal[1]); + + for (var x = xRange.x; x <= xRange.y; ++x) { + var xVal = [this._box.min.x + x * this._cellSize.x, this._box.min.x + (x + 1) * this._cellSize.x]; + vCenter.x = 0.5 * (xVal[0] + xVal[1]); + + var d2 = center.distanceToSquared(vCenter); + if (d2 <= distTouch2) { + process(x + this._count.x * (y + this._count.y * z), d2 <= distInside2); + } + } + } + } + }; +}(); + +/** + * Call a function for each atom within given sphere + * + * @param {Vector3} center - center of the sphere + * @param {number} radius - sphere radius + * @param {function(Atom)} process - function to call + */ +VoxelWorld.prototype.forEachAtomWithinRadius = function (center, radius, process) { + var self = this; + var r2 = radius * radius; + + self._forEachVoxelWithinRadius(center, radius, function (voxel, isInside) { + if (isInside) { + self._forEachAtomInVoxel(voxel, process); + } else { + self._forEachAtomInVoxel(voxel, function (atom) { + if (center.distanceToSquared(atom._position) <= r2) { + process(atom); + } + }); + } + }); +}; + +/** + * Call a function for each atom of given complex within given distance from group of atoms defined by mask + * + * @param {Complex} complex - complex + * @param {number} mask - bit mask + * @param {number} dist - distance + * @param {function(Atom)} process - function to call + */ +VoxelWorld.prototype.forEachAtomWithinDistFromMasked = function (complex, mask, dist, process) { + this._forEachAtomWithinDistFromGroup(function (atomProc) { + complex.forEachAtom(function (atom) { + if ((atom._mask & mask) !== 0) { + atomProc(atom); + } + }); + }, dist, process); +}; + +/** + * Call a function for each atom of given complex within given distance from group of atoms defined by selector + * + * @param {Complex} complex - complex + * @param {number} selector - selector + * @param {number} dist - distance + * @param {function(Atom)} process - function to call + */ +VoxelWorld.prototype.forEachAtomWithinDistFromSelected = function (complex, selector, dist, process) { + this._forEachAtomWithinDistFromGroup(function (atomProc) { + complex.forEachAtom(function (atom) { + if (selector.includesAtom(atom)) { + atomProc(atom); + } + }); + }, dist, process); +}; + +/** + * Call a function for each atom of given complex within given distance from group of atoms + * + * @param {function} forEachAtom - enumerator of atoms in the group + * @param {number} dist - distance + * @param {function(Atom)} process - function to call + */ +VoxelWorld.prototype._forEachAtomWithinDistFromGroup = function (forEachAtom, dist, process) { + var self = this; + var r2 = dist * dist; + + var voxels = []; + var atoms = []; + var idx = 0; + + // build "within radius" atom list for each voxel + forEachAtom(function (atom) { + self._forEachVoxelWithinRadius(atom._position, dist, function (voxel, isInside) { + if (isInside) { + // this voxel is inside circle -- no check will be required + voxels[voxel] = -1; + } else if (typeof voxels[voxel] === 'undefined') { + // this voxel isn't covered yet -- start building list of atoms + atoms.push(atom); + atoms.push(-1); + voxels[voxel] = idx; + idx += 2; + } else if (voxels[voxel] !== -1) { + // this voxel has a list of atoms required for distance check -- add atom to the list + atoms.push(atom); + atoms.push(voxels[voxel]); + voxels[voxel] = idx; + idx += 2; + } + }); + }); + + var voxel; + + var processIfWithin = function processIfWithin(atom) { + if (typeof voxels[voxel] === 'undefined') { + return; + } + + idx = voxels[voxel]; + if (idx === -1) { + // this voxel is fully covered + process(atom); + return; + } + + // check distance to each atom within radius from this voxel + for (; idx >= 0; idx = atoms[idx + 1]) { + if (atom._position.distanceToSquared(atoms[idx]._position) < r2) { + process(atom); + break; + } + } + }; + + // for each marked voxel + for (voxel in voxels) { + if (voxels.hasOwnProperty(voxel)) { + self._forEachAtomInVoxel(voxel, processIfWithin); + } + } +}; + +var MINIMAL_DISTANCE = 0.5; +var MIN_HBOND_ENERGY = -9.9; +var MAX_HBOND_ENERGY = -0.5; +var COUPLING_CONSTANT = -27.888; // = -332 * 0.42 * 0.2 +var MAX_COUPLING_DISTANCE = 5.0; // how far is the closest atom of a potential partner residue from CA atom +var MAX_RESIDUES_THRESHOLD = 1000; + +var HBondInfo = function () { + function HBondInfo(complex) { + classCallCheck(this, HBondInfo); + + this._complex = complex; + this._hbonds = []; // array of bond info for each residue + if (this._complex._residues.length > MAX_RESIDUES_THRESHOLD) { + this._buildVW(); // optimized version using voxel grid + } else { + this._build(); // test all pairs of residues + } + } + + createClass(HBondInfo, [{ + key: 'isBond', + value: function isBond(from, to) { + if (this._hbonds[from]) { + var acc = this._hbonds[from].acceptor[0]; + if (acc && acc.residue === to && acc.energy < MAX_HBOND_ENERGY) { + return true; + } + acc = this._hbonds[from].acceptor[1]; + if (acc && acc.residue === to && acc.energy < MAX_HBOND_ENERGY) { + return true; + } + } + return false; + } + }, { + key: '_build', + value: function _build() { + var self = this; + + // TODO Replace quadratic algorithm with something better (use voxel grid?) + for (var i = 0; i < this._complex._residues.length - 1; ++i) { + var ri = this._complex._residues[i]; + if ((ri.getType().flags & ResidueType.Flags.PROTEIN) === 0) { + continue; + } + + // get predecessor in chain + var preri = null; + if (i > 0 && this._complex._residues[i - 1].getType().flags & ResidueType.Flags.PROTEIN && ri._sequence === this._complex._residues[i - 1]._sequence + 1) { + preri = this._complex._residues[i - 1]; + } + + for (var j = i + 1; j < this._complex._residues.length; ++j) { + var rj = this._complex._residues[j]; + if ((rj.getType().flags & ResidueType.Flags.PROTEIN) === 0) { + continue; + } + + // get predecessor in chain + var prerj = null; + if (this._complex._residues[j - 1].getType().flags & ResidueType.Flags.PROTEIN && rj._sequence === this._complex._residues[j - 1]._sequence + 1) { + prerj = this._complex._residues[j - 1]; + } + + self._calcHBondEnergy(preri, ri, rj); + if (j !== i + 1) { + self._calcHBondEnergy(prerj, rj, ri); + } + } + } + } + }, { + key: '_buildVW', + value: function _buildVW() { + var self = this; + var residues = this._complex._residues; + var ri = void 0, + preri = void 0; + + var vw = this._complex.getVoxelWorld(); + if (vw === null) { + return; + } + + var pairs = new AtomPairs(this._complex._residues.length * this._complex._residues.length / 2); + + function processAtom(atom) { + var rj = atom._residue; + + if (rj._index === ri._index) { + return; + } + + if ((rj.getType().flags & ResidueType.Flags.PROTEIN) === 0) { + return; + } + + if (!pairs.addPair(ri._index, rj._index)) { + // we've seen this pair + return; + } + + // get predecessor in chain + var prerj = rj._index > 0 ? residues[rj._index - 1] : null; + if (prerj && ((prerj.getType().flags & ResidueType.Flags.PROTEIN) === 0 || rj._sequence !== prerj._sequence + 1)) { + prerj = null; + } + + self._calcHBondEnergy(preri, ri, rj); + if (rj._index !== ri._index + 1) { + self._calcHBondEnergy(prerj, rj, ri); + } + } + + for (var i = 0; i < residues.length - 1; ++i) { + ri = residues[i]; + if ((ri.getType().flags & ResidueType.Flags.PROTEIN) === 0) { + continue; + } + + // get predecessor in chain + preri = i > 0 ? residues[i - 1] : null; + if (preri && ((preri.getType().flags & ResidueType.Flags.PROTEIN) === 0 || ri._sequence !== preri._sequence + 1)) { + preri = null; + } + + vw.forEachAtomWithinRadius(this._residueGetCAlpha(ri), MAX_COUPLING_DISTANCE, processAtom); + } + } + }, { + key: '_residueGetCAlpha', + value: function _residueGetCAlpha(res) { + for (var i = 0; i < res._atoms.length; ++i) { + var name = res._atoms[i].getName().getString(); + if (name === 'CA' || name === 'C1') { + return res._atoms[i].getPosition(); + } + } + + return null; + } + }, { + key: '_residueGetCO', + value: function _residueGetCO(res) { + var c = null, + o = null; + + res.forEachAtom(function (a) { + if (a.getName().getString() === 'C') { + c = a.getPosition(); + } else if (a.getName().getString() === 'O') { + o = a.getPosition(); + } + }); + + return [c, o]; + } + + // TODO Support hydrogen defined in complex + + }, { + key: '_residueGetNH', + value: function _residueGetNH(prev, res) { + var _residueGetCO2 = this._residueGetCO(prev), + _residueGetCO3 = slicedToArray(_residueGetCO2, 2), + c = _residueGetCO3[0], + o = _residueGetCO3[1]; + + var n = void 0; + res.forEachAtom(function (a) { + if (a.getName().getString() === 'N') { + n = a.getPosition(); + } + }); + + if (c && o && n) { + // calculate hydrogen position + var h = c.clone(); + h.sub(o); + h.multiplyScalar(1.0 / h.length()); + h.add(n); + + return [n, h]; + } + + return [null, null]; + } + }, { + key: '_calcHBondEnergy', + value: function _calcHBondEnergy(predonor, donor, acceptor) { + var result = 0; + + if (predonor === null) { + return result; + } + + if (donor.getType().getName() !== 'PRO') { + var _residueGetNH2 = this._residueGetNH(predonor, donor), + _residueGetNH3 = slicedToArray(_residueGetNH2, 2), + n = _residueGetNH3[0], + h = _residueGetNH3[1]; + + var _residueGetCO4 = this._residueGetCO(acceptor), + _residueGetCO5 = slicedToArray(_residueGetCO4, 2), + c = _residueGetCO5[0], + o = _residueGetCO5[1]; + + if (n === null || h === null || c === null || o === null) { + return result; + } + + var distanceHO = h.distanceTo(o); + var distanceHC = h.distanceTo(c); + var distanceNC = n.distanceTo(c); + var distanceNO = n.distanceTo(o); + + if (distanceHO < MINIMAL_DISTANCE || distanceHC < MINIMAL_DISTANCE || distanceNC < MINIMAL_DISTANCE || distanceNO < MINIMAL_DISTANCE) { + result = MIN_HBOND_ENERGY; + } else { + result = COUPLING_CONSTANT / distanceHO - COUPLING_CONSTANT / distanceHC + COUPLING_CONSTANT / distanceNC - COUPLING_CONSTANT / distanceNO; + } + + // DSSP compatibility mode: + result = Math.round(result * 1000) / 1000; + + if (result < MIN_HBOND_ENERGY) { + result = MIN_HBOND_ENERGY; + } + } + + // update donor + if (typeof this._hbonds[donor._index] === 'undefined') { + this._hbonds[donor._index] = { + donor: [], + acceptor: [] + }; + } + var donorInfo = this._hbonds[donor._index]; + + if (donorInfo.acceptor.length < 2) { + donorInfo.acceptor.push({ + residue: acceptor._index, + energy: result + }); + } + + if (donorInfo.acceptor.length > 1) { + if (result < donorInfo.acceptor[0].energy) { + donorInfo.acceptor[1].residue = donorInfo.acceptor[0].residue; + donorInfo.acceptor[1].energy = donorInfo.acceptor[0].energy; + donorInfo.acceptor[0].residue = acceptor._index; + donorInfo.acceptor[0].energy = result; + } else if (result < donorInfo.acceptor[1].energy) { + donorInfo.acceptor[1].residue = acceptor._index; + donorInfo.acceptor[1].energy = result; + } + } + + // update acceptor + if (typeof this._hbonds[acceptor._index] === 'undefined') { + this._hbonds[acceptor._index] = { + donor: [], + acceptor: [] + }; + } + var accInfo = this._hbonds[acceptor._index]; + + if (accInfo.donor.length < 2) { + accInfo.donor.push({ + residue: donor._index, + energy: result + }); + } + + if (accInfo.donor.length > 1) { + if (result < accInfo.donor[0].energy) { + accInfo.donor[1].residue = accInfo.donor[0].residue; + accInfo.donor[1].energy = accInfo.donor[0].energy; + accInfo.donor[0].residue = donor._index; + accInfo.donor[0].energy = result; + } else if (result < accInfo.donor[1].energy) { + accInfo.donor[1].residue = donor._index; + accInfo.donor[1].energy = result; + } + } + + return result; + } + }]); + return HBondInfo; +}(); + +var BridgeType = Object.freeze({ + NO_BRIDGE: 0, + PARALLEL: 1, + ANTI_PARALLEL: 2 +}); + +var HelixFlag = Object.freeze({ + START: 1, + MIDDLE: 2, + END: 3, + START_AND_END: 4 +}); + +var StructureType = Object.freeze({ + LOOP: ' ', + ALPHA_HELIX: 'H', + BETA_BRIDGE: 'B', + STRAND: 'E', + HELIX_3_10: 'G', + PI_HELIX: 'I', + TURN: 'T', + BEND: 'S' +}); + +var SecondaryStructureMap = function () { + function SecondaryStructureMap(complex) { + classCallCheck(this, SecondaryStructureMap); + + this._complex = complex; + this._build(); + } + + createClass(SecondaryStructureMap, [{ + key: '_build', + value: function _build() { + var self = this; + this._hbonds = new HBondInfo(this._complex); + this._ss = []; // DSSP map by residue + + // auxilliary data + this._sheet = []; + this._betaPartners = []; + this._bend = []; + for (var i = 0; i < this._complex.getResidues().length; ++i) { + this._betaPartners[i] = []; + } + this._helixFlags = []; + this._helixFlags[3] = []; + this._helixFlags[4] = []; + this._helixFlags[5] = []; + + // calculate peptide chain lengths + this._chainLengths = []; + for (var _i = 0; _i < this._complex._chains.length; ++_i) { + var chain = this._complex._chains[_i].getResidues(); + var len = 0; + for (; len < chain.length; ++len) { + if ((chain[len].getType().flags & ResidueType.Flags.PROTEIN) === 0) { + break; + } + } + this._chainLengths[_i] = len; + } + + this._buildBetaSheets(); + + for (var _i2 = 0; _i2 < this._complex._chains.length; ++_i2) { + self._buildAlphaHelices(this._complex._chains[_i2].getResidues(), this._chainLengths[_i2], false); + } + } + }, { + key: '_buildAlphaHelices', + value: function _buildAlphaHelices(inResidues, chainLength, inPreferPiHelices) { + // Helix and Turn + for (var stride = 3; stride <= 5; ++stride) { + if (inResidues.length < stride) { + break; + } + + for (var i = 0; i + stride < chainLength; ++i) { + if (this._hbonds.isBond(inResidues[i + stride]._index, inResidues[i]._index) + /*&& NoChainBreak(res[i], res[i + stride])*/) { + this._helixFlags[stride][inResidues[i + stride]._index] = HelixFlag.END; + for (var j = i + 1; j < i + stride; ++j) { + if (typeof this._helixFlags[stride][inResidues[j]._index] === 'undefined') { + this._helixFlags[stride][inResidues[j]._index] = HelixFlag.MIDDLE; + } + } + + if (this._helixFlags[stride][inResidues[i]._index] === HelixFlag.END) { + this._helixFlags[stride][inResidues[i]._index] = HelixFlag.START_AND_END; + } else { + this._helixFlags[stride][inResidues[i]._index] = HelixFlag.START; + } + } + } + } + + for (var _i3 = 2; _i3 < chainLength - 2; ++_i3) { + var kappa = this._kappa(inResidues[_i3 - 2], inResidues[_i3], inResidues[_i3 + 2]); + this._bend[inResidues[_i3]._index] = kappa !== 360 && kappa > 70; + } + + for (var _i4 = 1; _i4 + 4 < chainLength; ++_i4) { + if (this._isHelixStart(inResidues[_i4]._index, 4) && this._isHelixStart(inResidues[_i4 - 1]._index, 4)) { + for (var _j = _i4; _j <= _i4 + 3; ++_j) { + this._ss[inResidues[_j]._index] = StructureType.ALPHA_HELIX; + } + } + } + + for (var _i5 = 1; _i5 + 3 < chainLength; ++_i5) { + if (this._isHelixStart(inResidues[_i5]._index, 3) && this._isHelixStart(inResidues[_i5 - 1]._index, 3)) { + var empty = true; + for (var _j2 = _i5; empty && _j2 <= _i5 + 2; ++_j2) { + empty = typeof this._ss[inResidues[_j2]._index] === 'undefined' || this._ss[inResidues[_j2]._index] === StructureType.HELIX_3_10; + } + if (empty) { + for (var _j3 = _i5; _j3 <= _i5 + 2; ++_j3) { + this._ss[inResidues[_j3]._index] = StructureType.HELIX_3_10; + } + } + } + } + + for (var _i6 = 1; _i6 + 5 < chainLength; ++_i6) { + if (this._isHelixStart(inResidues[_i6]._index, 5) && this._isHelixStart(inResidues[_i6 - 1]._index, 5)) { + var _empty = true; + for (var _j4 = _i6; _empty && _j4 <= _i6 + 4; ++_j4) { + _empty = typeof this._ss[inResidues[_j4]._index] === 'undefined' || this._ss[inResidues[_j4]._index] === StructureType.PI_HELIX || inPreferPiHelices && this._ss[inResidues[_j4]._index] === StructureType.ALPHA_HELIX; + } + if (_empty) { + for (var _j5 = _i6; _j5 <= _i6 + 4; ++_j5) { + this._ss[inResidues[_j5]._index] = StructureType.PI_HELIX; + } + } + } + } + + for (var _i7 = 1; _i7 + 1 < chainLength; ++_i7) { + if (typeof this._ss[inResidues[_i7]._index] === 'undefined') { + var isTurn = false; + for (var _stride = 3; _stride <= 5 && !isTurn; ++_stride) { + for (var k = 1; k < _stride && !isTurn; ++k) { + isTurn = _i7 >= k && this._isHelixStart(inResidues[_i7 - k]._index, _stride); + } + } + + if (isTurn) { + this._ss[inResidues[_i7]._index] = StructureType.TURN; + } else if (this._bend[inResidues[_i7]._index]) { + this._ss[inResidues[_i7]._index] = StructureType.BEND; + } + } + } + } + }, { + key: '_residueGetCAlpha', + value: function _residueGetCAlpha(res) { + for (var i = 0; i < res._atoms.length; ++i) { + var name = res._atoms[i].getName().getString(); + if (name === 'CA' || name === 'C1') { + return res._atoms[i].getPosition(); + } + } + + return null; + } + }, { + key: '_cosinusAngle', + value: function _cosinusAngle(p1, p2, p3, p4) { + var v12 = p1.clone();v12.sub(p2); + var v34 = p3.clone();v34.sub(p4); + + var result = 0; + + var x = v12.dot(v12) * v34.dot(v34); + if (x > 0) { + result = v12.dot(v34) / Math.sqrt(x); + } + + return result; + } + }, { + key: '_kappa', + value: function _kappa(prevPrev, res, nextNext) { + var curCA = this._residueGetCAlpha(res); + var ppCA = this._residueGetCAlpha(prevPrev); + var nnCA = this._residueGetCAlpha(nextNext); + if (curCA === null || ppCA === null || nnCA === null) { + return 180; + } + + var ckap = this._cosinusAngle(curCA, ppCA, nnCA, curCA); + var skap = Math.sqrt(1 - ckap * ckap); + return Math.atan2(skap, ckap) * 180 / Math.PI; + } + }, { + key: '_isHelixStart', + value: function _isHelixStart(res, stride) { + return this._helixFlags[stride][res] === HelixFlag.START || this._helixFlags[stride][res] === HelixFlag.START_AND_END; + } + }, { + key: '_buildBetaSheets', + value: function _buildBetaSheets() { + // find bridges + // check each chain against each other chain, and against itself + var bridges = []; + for (var a = 0; a < this._complex._chains.length; ++a) { + var lenA = this._chainLengths[a]; + if (lenA <= 4) { + continue; + } + + var chainA = this._complex._chains[a].getResidues(); + + for (var b = a; b < this._complex._chains.length; ++b) { + var lenB = this._chainLengths[b]; + if (lenB <= 4) { + continue; + } + + var chainB = this._complex._chains[b].getResidues(); + + for (var i = 1; i + 1 < lenA; ++i) { + var ri = chainA[i]; + + var j = 1; + if (b === a) { + j = i + 3; // check for self-bridges forward down the chain + } + + for (; j + 1 < lenB; ++j) { + var rj = chainB[j]; + + var type = this._testBridge(chainA, i, chainB, j); + if (type === BridgeType.NO_BRIDGE) { + continue; + } + + // there is a bridge, try to attach it to previously found sequence + var found = false; + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = bridges[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var bridge = _step.value; + + if (type !== bridge.type || ri._index !== bridge.i[bridge.i.length - 1] + 1) { + continue; + } + + if (type === BridgeType.PARALLEL && bridge.j[bridge.j.length - 1] + 1 === rj._index) { + bridge.i.push(ri._index); + bridge.j.push(rj._index); + found = true; + break; + } + + if (type === BridgeType.ANTI_PARALLEL && bridge.j[0] - 1 === rj._index) { + bridge.i.push(ri._index); + bridge.j.unshift(rj._index); + found = true; + break; + } + } + + // this bridge cannot be attached anywhere, start a new sequence + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + if (!found) { + bridges.push({ + type: type, + i: [ri._index], + chainI: ri.getChain()._index, + j: [rj._index], + chainJ: rj.getChain()._index + }); + } + } + } + } + } + + // extend ladders + bridges.sort(function (a, b) { + if (a.chainI < b.chainI || a.chainI === b.chainI && a.i[0] < b.i[0]) { + return -1; + } + return 1; + }); + + for (var _i8 = 0; _i8 < bridges.length; ++_i8) { + for (var _j6 = _i8 + 1; _j6 < bridges.length; ++_j6) { + var ibi = bridges[_i8].i[0]; + var iei = bridges[_i8].i[bridges[_i8].i.length - 1]; + var jbi = bridges[_i8].j[0]; + var jei = bridges[_i8].j[bridges[_i8].j.length - 1]; + var ibj = bridges[_j6].i[0]; + var iej = bridges[_j6].i[bridges[_j6].i.length - 1]; + var jbj = bridges[_j6].j[0]; + var jej = bridges[_j6].j[bridges[_j6].j.length - 1]; + + if (bridges[_i8].type !== bridges[_j6].type || this._hasChainBreak(Math.min(ibi, ibj), Math.max(iei, iej)) || this._hasChainBreak(Math.min(jbi, jbj), Math.max(jei, jej)) || ibj - iei >= 6 || iei >= ibj && ibi <= iej) { + continue; + } + + var bulge = false; + if (bridges[_i8].type === BridgeType.PARALLEL) { + bulge = jbj - jei < 6 && ibj - iei < 3 || jbj - jei < 3; + } else { + bulge = jbi - jej < 6 && ibj - iei < 3 || jbi - jej < 3; + } + + if (bulge) { + bridges[_i8].i = bridges[_i8].i.concat(bridges[_j6].i); + if (bridges[_i8].type === BridgeType.PARALLEL) { + bridges[_i8].j = bridges[_i8].j.concat(bridges[_j6].j); + } else { + bridges[_i8].j = bridges[_j6].j.concat(bridges[_i8].j); + } + bridges.splice(_j6--, 1); + } + } + } + + // Sheet + var ladderset = new Set(); + for (var _i9 = 0; _i9 < bridges.length; ++_i9) { + ladderset.add(bridges[_i9]); + } + + var sheet = 1, + ladder = 0; + while (ladderset.size > 0) { + var _bridge = ladderset.values().next().value; + ladderset.delete(_bridge); + + var sheetset = new Set(); + sheetset.add(_bridge); + + var toMove = void 0; + do { + toMove = new Set(); + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = sheetset.values()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var _a = _step2.value; + var _iteratorNormalCompletion4 = true; + var _didIteratorError4 = false; + var _iteratorError4 = undefined; + + try { + for (var _iterator4 = ladderset.values()[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { + var _b = _step4.value; + + if (this._areBridgesLinked(_a, _b)) { + toMove.add(_b); + } + } + } catch (err) { + _didIteratorError4 = true; + _iteratorError4 = err; + } finally { + try { + if (!_iteratorNormalCompletion4 && _iterator4.return) { + _iterator4.return(); + } + } finally { + if (_didIteratorError4) { + throw _iteratorError4; + } + } + } + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + + var _iteratorNormalCompletion3 = true; + var _didIteratorError3 = false; + var _iteratorError3 = undefined; + + try { + for (var _iterator3 = toMove.values()[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { + _bridge = _step3.value; + + sheetset.add(_bridge); + ladderset.delete(_bridge); + } + } catch (err) { + _didIteratorError3 = true; + _iteratorError3 = err; + } finally { + try { + if (!_iteratorNormalCompletion3 && _iterator3.return) { + _iterator3.return(); + } + } finally { + if (_didIteratorError3) { + throw _iteratorError3; + } + } + } + } while (toMove.size > 0); + + var _iteratorNormalCompletion5 = true; + var _didIteratorError5 = false; + var _iteratorError5 = undefined; + + try { + for (var _iterator5 = sheetset.values()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { + _bridge = _step5.value; + + _bridge.ladder = ladder; + _bridge.sheet = sheet; + _bridge.link = sheetset; + ++ladder; + } + } catch (err) { + _didIteratorError5 = true; + _iteratorError5 = err; + } finally { + try { + if (!_iteratorNormalCompletion5 && _iterator5.return) { + _iterator5.return(); + } + } finally { + if (_didIteratorError5) { + throw _iteratorError5; + } + } + } + + ++sheet; + } + + for (var _i10 = 0; _i10 < bridges.length; ++_i10) { + var _bridge2 = bridges[_i10]; + + // find out if any of the i and j set members already have + // a bridge assigned, if so, we're assigning bridge 2 + + var betai = 0, + betaj = 0; + + for (var l = 0; l < _bridge2.i.length; ++l) { + if (this._betaPartners[_bridge2.i[l]][0]) { + betai = 1; + break; + } + } + + for (var _l = 0; _l < _bridge2.j.length; ++_l) { + if (this._betaPartners[_bridge2.j[_l]][0]) { + betaj = 1; + break; + } + } + + var ss = StructureType.BETA_BRIDGE; + if (_bridge2.i.length > 1) { + ss = StructureType.STRAND; + } + + if (_bridge2.type === BridgeType.PARALLEL) { + var _j7 = 0; + for (var k = 0; k < _bridge2.i.length; ++k) { + this._betaPartners[_bridge2.i[k]][betai] = { + residue: _bridge2.j[_j7++], + ladder: _bridge2.ladder, + parallel: true + }; + } + + _j7 = 0; + for (var _k = 0; _k < _bridge2.j.length; ++_k) { + this._betaPartners[_bridge2.j[_k]][betaj] = { + residue: _bridge2.i[_j7++], + ladder: _bridge2.ladder, + parallel: true + }; + } + } else { + var _j8 = _bridge2.j.length - 1; + for (var _k2 = 0; _k2 < _bridge2.i.length; ++_k2) { + this._betaPartners[_bridge2.i[_k2]][betai] = { + residue: _bridge2.j[_j8--], + ladder: _bridge2.ladder, + parallel: false + }; + } + + _j8 = _bridge2.i.length - 1; + for (var _k3 = 0; _k3 < _bridge2.j.length; ++_k3) { + this._betaPartners[_bridge2.j[_k3]][betaj] = { + residue: _bridge2.i[_j8--], + ladder: _bridge2.ladder, + parallel: false + }; + } + } + + for (var _k4 = _bridge2.i[0]; _k4 <= _bridge2.i[_bridge2.i.length - 1]; ++_k4) { + if (this._ss[_k4] !== StructureType.STRAND) { + this._ss[_k4] = ss; + this._sheet[_k4] = _bridge2.sheet; + } + } + + for (var _k5 = _bridge2.j[0]; _k5 <= _bridge2.j[_bridge2.j.length - 1]; ++_k5) { + if (this._ss[_k5] !== StructureType.STRAND) { + this._ss[_k5] = ss; + this._sheet[_k5] = _bridge2.sheet; + } + } + } + } + }, { + key: '_testBridge', + value: function _testBridge(chainA, from, chainB, to) { + var result = BridgeType.NO_BRIDGE; + + var a = chainA[from - 1]._index; + var b = chainA[from]._index; + var c = chainA[from + 1]._index; + var d = chainB[to - 1]._index; + var e = chainB[to]._index; + var f = chainB[to + 1]._index; + + var isBond = this._hbonds.isBond.bind(this._hbonds); + if (isBond(c, e) && isBond(e, a) || isBond(f, b) && isBond(b, d)) { + result = BridgeType.PARALLEL; + } else if (isBond(c, d) && isBond(f, a) || isBond(e, b) && isBond(b, e)) { + result = BridgeType.ANTI_PARALLEL; + } + return result; + } + + // return true if any of the residues in bridge a is identical to any of the residues in bridge b + // TODO Optimize + + }, { + key: '_areBridgesLinked', + value: function _areBridgesLinked(a, b) { + var ai = new Set(a.i); + var aj = new Set(a.j); + + var _iteratorNormalCompletion6 = true; + var _didIteratorError6 = false; + var _iteratorError6 = undefined; + + try { + for (var _iterator6 = b.i[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) { + var i = _step6.value; + + if (ai.has(i) || aj.has(i)) { + return true; + } + } + } catch (err) { + _didIteratorError6 = true; + _iteratorError6 = err; + } finally { + try { + if (!_iteratorNormalCompletion6 && _iterator6.return) { + _iterator6.return(); + } + } finally { + if (_didIteratorError6) { + throw _iteratorError6; + } + } + } + + var _iteratorNormalCompletion7 = true; + var _didIteratorError7 = false; + var _iteratorError7 = undefined; + + try { + for (var _iterator7 = b.j[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) { + var _i11 = _step7.value; + + if (ai.has(_i11) || aj.has(_i11)) { + return true; + } + } + } catch (err) { + _didIteratorError7 = true; + _iteratorError7 = err; + } finally { + try { + if (!_iteratorNormalCompletion7 && _iterator7.return) { + _iterator7.return(); + } + } finally { + if (_didIteratorError7) { + throw _iteratorError7; + } + } + } + + return false; + } + }, { + key: '_hasChainBreak', + value: function _hasChainBreak(from, to) { + for (var i = from + 1; i <= to; ++i) { + if (this._complex._residues[i]._sequence !== this._complex._residues[i - 1]._sequence + 1) { + return true; + } + } + return false; + } + }]); + return SecondaryStructureMap; +}(); + +SecondaryStructureMap.StructureType = StructureType; + +var VOXEL_SIZE = 5.0; + /** * The entire complex of the molecules under study. * @@ -69203,6 +70351,20 @@ Complex.prototype.getAltLocNames = function () { return this._altlocNames; }; +Complex.prototype.getVoxelWorld = function () { + if (!this.hasOwnProperty('_voxelWorld')) { + try { + this._voxelWorld = new VoxelWorld(this.getDefaultBoundaries().boundingBox, new Vector3(VOXEL_SIZE, VOXEL_SIZE, VOXEL_SIZE)); + this._voxelWorld.addAtoms(this); + } catch (e) { + logger.warn('Unable to create voxel world'); + this._voxelWorld = null; + } + } + + return this._voxelWorld; +}; + // this function joins multiple complexes into one (this) // atom, bond, ... objects are reused -- so input complexes are no longer valid Complex.prototype.joinComplexes = function (complexes) { @@ -69296,6 +70458,68 @@ Complex.prototype.joinComplexes = function (complexes) { this._computeBounds(); }; +/** + * Replace secondary structure with calculated one. + * + * DSSP algorithm implementation is used. + * + * Kabsch W, Sander C. 1983. Dictionary of protein secondary structure: pattern recognition of hydrogen-bonded and + * geometrical features. Biopolymers. 22(12):2577-2637. doi:10.1002/bip.360221211. + */ +Complex.prototype.dssp = function () { + var _helixTypes; + + var ssMap = new SecondaryStructureMap(this); + var StructureType = SecondaryStructureMap.StructureType; + var helixTypes = (_helixTypes = {}, defineProperty(_helixTypes, StructureType.ALPHA_HELIX, 1), defineProperty(_helixTypes, StructureType.HELIX_3_10, 3), defineProperty(_helixTypes, StructureType.PI_HELIX, 5), _helixTypes); + + var helices = []; + var sheets = []; + var curHelix = null; + var curStrand = null; + for (var i = 0, n = this._residues.length; i < n; ++i) { + var ssCode = ssMap._ss[i]; + var residue = this._residues[i]; + residue._secondary = null; + + var helixType = helixTypes[ssCode]; + if (helixType) { + if (curHelix === null) { + curHelix = new Helix(helices.length + 1, '', residue, residue, helixType, '', 0); + helices.push(curHelix); + } + residue._secondary = curHelix; + curHelix._residues.push(residue); + curHelix._end = residue; + curHelix._length++; + } else if (curHelix) { + curHelix = null; + } + + if (ssCode === StructureType.STRAND) { + if (curStrand === null) { + var curSheet = sheets[ssMap._sheet[i]]; + if (curSheet === undefined) { + curSheet = sheets[ssMap._sheet[i]] = new Sheet('', 0); + } + curStrand = new Strand(curSheet, residue, residue, 0, null, null); + curSheet.addStrand(curStrand); + curSheet._width++; + } + residue._secondary = curStrand; + curStrand._residues.push(residue); + curStrand._end = residue; + } else if (curStrand) { + curStrand = null; + } + } + + this._helices = helices; + this._sheets = sheets.filter(function (_sheet) { + return true; + }); // squeeze sheets array +}; + ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// @@ -69607,323 +70831,6 @@ Volume.prototype.getStrideZ = function () { return this._planeElements; }; -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -/** - * Calculate min & max radius of a sphere slice between zMin & zMax - * - * @param {Vector3} center - center of the sphere - * @param {number} radius - sphere radius - * @param {number} zMin - lower bound of the slice - * @param {number} zMax - upper bound of the slice - */ -function _getSphereSliceRadiusRange(center, radius, zMin, zMax) { - var dzMin = zMin - center.z; - var dzMax = zMax - center.z; - var rzMin = Math.sqrt(Math.max(radius * radius - dzMin * dzMin, 0.0)); - var rzMax = Math.sqrt(Math.max(radius * radius - dzMax * dzMax, 0.0)); - - var rMin = Math.min(rzMin, rzMax); - var rMax; - - if (zMin <= center.z && zMax >= center.z) { - // sphere's main diameter is inside slice - rMax = radius; - } else { - rMax = Math.max(rzMin, rzMax); - } - - return [rMin, rMax]; -} - -/** - * Calculate min & max radius of a circle slice between yMin & yMax. - * - * To maintain analogy with _getSphereSliceRadiusRange we call radius what in fact is - * half-width (along X axis) of the slice, i.e. 1D-sphere radius. - * - * @param {Vector3} center - center of the circle (z can be ignored) - * @param {number} radius - circle radius - * @param {number} yMin - lower bound of the slice - * @param {number} yMax - upper bound of the slice - * @returns {Array} - array of two numbers (min & max radius, or half-width) - */ -function _getCircleSliceRadiusRange(center, radius, yMin, yMax) { - var dyMin = yMin - center.y; - var dyMax = yMax - center.y; - var ryMin = Math.sqrt(Math.max(radius * radius - dyMin * dyMin, 0.0)); - var ryMax = Math.sqrt(Math.max(radius * radius - dyMax * dyMax, 0.0)); - - var rMin = Math.min(ryMin, ryMax); - var rMax; - - if (yMin <= center.y && yMax >= center.y) { - // slice's main diameter is inside slice - rMax = radius; - } else { - rMax = Math.max(ryMin, ryMax); - } - - return [rMin, rMax]; -} - -/** - * VoxelWorld constructor - * - * @param {Box3} box - bounding box of the volume to be partitioned - * @param {Vector3} vCellSizeHint - target voxel size (actual voxel size may differ from this) - */ -function VoxelWorld(box, vCellSizeHint) { - var i; - - this._box = box.clone(); - this._count = box.size().divide(vCellSizeHint).floor(); - this._last = this._count.clone().subScalar(1); - this._cellSize = box.size().divide(this._count); - - // array of voxels, each element contains index of first atom in voxel - var numVoxels = this._count.x * this._count.y * this._count.z; - this._voxels = utils.allocateTyped(Int32Array, numVoxels); - for (i = 0; i < numVoxels; ++i) { - this._voxels[i] = -1; - } - - // array of atoms that stores multiple single-linked lists - // two elements for each atom: Atom ref, index of next atom (in this array - this._atoms = []; -} - -/** - * Add all atoms from a complex to voxel world - * - * @param {Complex} complex - complex - */ -VoxelWorld.prototype.addAtoms = function (complex) { - var self = this; - - var idx = this._atoms.length; - - // resize array of atoms - this._atoms.length = this._atoms.length + 2 * complex.getAtomCount(); - - complex.forEachAtom(function (atom) { - // find which voxel contains this atom - var voxelIdx = self._findVoxel(atom._position); - - // push current atom to the head of voxel's atom list - self._atoms[idx] = atom; - self._atoms[idx + 1] = self._voxels[voxelIdx]; - self._voxels[voxelIdx] = idx; - - idx += 2; - }); -}; - -/** - * Get voxel that contains specified 3D point (we use clamp at the edges) - * - * @param {Vector3} point - a point in 3D - * @returns {number} - index of voxel - */ -VoxelWorld.prototype._findVoxel = function () { - var zero = new Vector3(0, 0, 0); - var voxel = new Vector3(); - - return function (point) { - voxel.copy(point).sub(this._box.min).divide(this._cellSize).floor().clamp(zero, this._last); - return voxel.x + this._count.x * (voxel.y + this._count.y * voxel.z); - }; -}(); - -/** - * Call a function for each atom in voxel - * - * @param {number} voxel - index of voxel - * @param {function(Atom)} process - function to call - */ -VoxelWorld.prototype._forEachAtomInVoxel = function (voxel, process) { - for (var i = this._voxels[voxel]; i >= 0; i = this._atoms[i + 1]) { - process(this._atoms[i]); - } -}; - -/** - * Call a function for each voxel that is touched by given sphere. Callback also takes flag - * isInside specifying whether voxel lies inside the sphere entirely. - * - * @param {Vector3} center - center of the sphere - * @param {number} radius - sphere radius - * @param {function(number,bool)} process - function to call that takes voxel index and boolean isInside - */ -VoxelWorld.prototype._forEachVoxelWithinRadius = function (center, radius, process) { - - var rRangeXY, rRangeX, xVal, yVal, zVal, isInsideX, isInsideY, isInsideZ; - var xRange = new Vector2(); - var yRange = new Vector2(); - var zRange = new Vector2(); - - zRange.set(center.z - radius, center.z + radius); - zRange.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor().clampScalar(0, this._count.z - 1); - - for (var z = zRange.x; z <= zRange.y; ++z) { - zVal = [this._box.min.z + z * this._cellSize.z, this._box.min.z + (z + 1) * this._cellSize.z]; - - isInsideZ = center.z - radius <= zVal[0] && zVal[1] <= center.z + radius; - - rRangeXY = _getSphereSliceRadiusRange(center, radius, zVal[0], zVal[1]); - - yRange.set(center.y - rRangeXY[1], center.y + rRangeXY[1]); - yRange.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor().clampScalar(0, this._count.y - 1); - - for (var y = yRange.x; y <= yRange.y; ++y) { - yVal = [this._box.min.y + y * this._cellSize.y, this._box.min.y + (y + 1) * this._cellSize.y]; - - isInsideY = center.y - rRangeXY[0] <= yVal[0] && yVal[1] <= center.y + rRangeXY[0]; - - rRangeX = _getCircleSliceRadiusRange(center, rRangeXY[1], yVal[0], yVal[1]); - - xRange.set(center.x - rRangeX[1], center.x + rRangeX[1]); - xRange.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor().clampScalar(0, this._count.x - 1); - - for (var x = xRange.x; x <= xRange.y; ++x) { - xVal = [this._box.min.x + x * this._cellSize.x, this._box.min.x + (x + 1) * this._cellSize.x]; - isInsideX = center.x - rRangeX[0] <= xVal[0] && xVal[1] <= center.x + rRangeX[0]; - - process(x + this._count.x * (y + this._count.y * z), isInsideX && isInsideY && isInsideZ); - } - } - } -}; - -/** - * Call a function for each atom within given sphere - * - * @param {Vector3} center - center of the sphere - * @param {number} radius - sphere radius - * @param {function(Atom)} process - function to call - */ -VoxelWorld.prototype.forEachAtomWithinRadius = function (center, radius, process) { - var self = this; - var r2 = radius * radius; - - self._forEachVoxelWithinRadius(center, radius, function (voxel, isInside) { - if (isInside) { - self._forEachAtomInVoxel(voxel, process); - } else { - self._forEachAtomInVoxel(voxel, function (atom) { - if (center.distanceToSquared(atom._position) < r2) { - process(atom); - } - }); - } - }); -}; - -/** - * Call a function for each atom of given complex within given distance from group of atoms defined by mask - * - * @param {Complex} complex - complex - * @param {number} mask - bit mask - * @param {number} dist - distance - * @param {function(Atom)} process - function to call - */ -VoxelWorld.prototype.forEachAtomWithinDistFromMasked = function (complex, mask, dist, process) { - this._forEachAtomWithinDistFromGroup(function (atomProc) { - complex.forEachAtom(function (atom) { - if ((atom._mask & mask) !== 0) { - atomProc(atom); - } - }); - }, dist, process); -}; - -/** - * Call a function for each atom of given complex within given distance from group of atoms defined by selector - * - * @param {Complex} complex - complex - * @param {number} selector - selector - * @param {number} dist - distance - * @param {function(Atom)} process - function to call - */ -VoxelWorld.prototype.forEachAtomWithinDistFromSelected = function (complex, selector, dist, process) { - this._forEachAtomWithinDistFromGroup(function (atomProc) { - complex.forEachAtom(function (atom) { - if (selector.includesAtom(atom)) { - atomProc(atom); - } - }); - }, dist, process); -}; - -/** - * Call a function for each atom of given complex within given distance from group of atoms - * - * @param {function} forEachAtom - enumerator of atoms in the group - * @param {number} dist - distance - * @param {function(Atom)} process - function to call - */ -VoxelWorld.prototype._forEachAtomWithinDistFromGroup = function (forEachAtom, dist, process) { - var self = this; - var r2 = dist * dist; - - var voxels = []; - var atoms = []; - var idx = 0; - - // build "within radius" atom list for each voxel - forEachAtom(function (atom) { - self._forEachVoxelWithinRadius(atom._position, dist, function (voxel, isInside) { - if (isInside) { - // this voxel is inside circle -- no check will be required - voxels[voxel] = -1; - } else if (typeof voxels[voxel] === 'undefined') { - // this voxel isn't covered yet -- start building list of atoms - atoms.push(atom); - atoms.push(-1); - voxels[voxel] = idx; - idx += 2; - } else if (voxels[voxel] !== -1) { - // this voxel has a list of atoms required for distance check -- add atom to the list - atoms.push(atom); - atoms.push(voxels[voxel]); - voxels[voxel] = idx; - idx += 2; - } - }); - }); - - var voxel; - - var processIfWithin = function processIfWithin(atom) { - if (typeof voxels[voxel] === 'undefined') { - return; - } - - idx = voxels[voxel]; - if (idx === -1) { - // this voxel is fully covered - process(atom); - return; - } - - // check distance to each atom within radius from this voxel - for (; idx >= 0; idx = atoms[idx + 1]) { - if (atom._position.distanceToSquared(atoms[idx]._position) < r2) { - process(atom); - break; - } - } - }; - - // for each marked voxel - for (voxel in voxels) { - if (voxels.hasOwnProperty(voxel)) { - self._forEachAtomInVoxel(voxel, processIfWithin); - } - } -}; - ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// @@ -78620,8 +79527,7 @@ TextMode.prototype.getTemplateOptions = function () { }; TextMode.prototype.getLabelOpts = function () { - - return _.merge(this.opts, { + return lodash.merge(this.opts, { labels: this.settings.now.labels, colors: true, adjustColor: true, @@ -80277,8 +81183,6 @@ var ComplexVisualEdit = { FragmentEditor: ComplexFragmentEditor }; -var VOXEL_SIZE = 5.0; - var selectors$3 = chem.selectors; function ComplexVisual(name, dataSource) { @@ -81117,16 +82021,9 @@ ComplexVisual.prototype.setUberOptions = function (values) { * @returns {Selector} selector describing result group of atoms */ ComplexVisual.prototype.within = function (selector, radius) { - // build voxel world - if (!this._voxelWorld) { - try { - this._voxelWorld = new chem.VoxelWorld(this._complex.getDefaultBoundaries().boundingBox, new Vector3(VOXEL_SIZE, VOXEL_SIZE, VOXEL_SIZE)); - this._voxelWorld.addAtoms(this._complex); - } catch (e) { - logger.warn('Unable to create voxel world'); - this._voxelWorld = null; - return selectors$3.none(); - } + var vw = this._complex.getVoxelWorld(); + if (vw === null) { + return false; } // mark atoms of the group as selected @@ -81134,9 +82031,11 @@ ComplexVisual.prototype.within = function (selector, radius) { this._complex.markAtoms(selector, selectionMask); // mark all atoms within distance as selected - this._voxelWorld.forEachAtomWithinDistFromMasked(this._complex, selectionMask, Number(radius), function (atom) { - atom._mask |= selectionMask; - }); + if (vw) { + vw.forEachAtomWithinDistFromMasked(this._complex, selectionMask, Number(radius), function (atom) { + atom._mask |= selectionMask; + }); + } // update selection count this._selectionCount = this._complex.countAtomsByMask(selectionMask); @@ -87664,7 +88563,7 @@ var WEBVR = function () { return WEBVR; }(); -/* global "0.7.11":false */ +/* global "0.7.12":false */ ////////////////////////////////////////////////////////////////////////////// @@ -87843,7 +88742,7 @@ Miew.prototype.init = function () { this._initGfx(); this._initListeners(); - this._spinner = new spin({ + this._spinner = new Spinner({ lines: 13, length: 28, width: 14, @@ -90922,6 +91821,31 @@ Miew.prototype.projected = function (fullAtomName, complexName) { }; }; +/** + * Replace secondary structure with calculated one. + * + * DSSP algorithm implementation is used. + * + * Kabsch W, Sander C. 1983. Dictionary of protein secondary structure: pattern recognition of hydrogen-bonded and + * geometrical features. Biopolymers. 22(12):2577-2637. doi:10.1002/bip.360221211. + * + * @param {string=} complexName - complex name + */ +Miew.prototype.dssp = function (complexName) { + var visual = this._getComplexVisual(complexName); + if (!visual) { + return; + } + visual.getComplex().dssp(); + + // rebuild dependent representations (cartoon or ss-colored) + visual._reprList.forEach(function (rep) { + if (rep.mode.id === 'CA' || rep.colorer.id === 'SS') { + rep.needsRebuild = true; + } + }); +}; + var rePdbId = /^(?:(pdb|cif|mmtf|ccp4):\s*)?(\d[a-z\d]{3})$/i; var rePubchem = /^(?:pc|pubchem):\s*([a-z]+)$/i; var reUrlScheme = /^([a-z][a-z\d\-+.]*):/i; @@ -91183,10 +92107,86 @@ function _parseData(data, opts, job) { }); } +Miew.prototype.exportCML = function () { + var self = this; + + function extractRotation(m) { + var xAxis = new Vector3(); + var yAxis = new Vector3(); + var zAxis = new Vector3(); + m.extractBasis(xAxis, yAxis, zAxis); + xAxis.normalize(); + yAxis.normalize(); + zAxis.normalize(); + var retMat = new Matrix4(); + retMat.identity(); + retMat.makeBasis(xAxis, yAxis, zAxis); + return retMat; + } + + function updateCMLData(complex) { + var root = self._gfx.root; + var mat = extractRotation(root.matrixWorld); + var v4 = new Vector4(0, 0, 0, 0); + var vCenter = new Vector4(0, 0, 0, 0); + var xml = null; + var ap = null; + + // update atoms in cml + complex.forEachAtom(function (atom) { + if (atom.xmlNodeRef && atom.xmlNodeRef.xmlNode) { + xml = atom.xmlNodeRef.xmlNode; + ap = atom.getPosition(); + v4.set(ap.x, ap.y, ap.z, 1.0); + v4.applyMatrix4(mat); + xml.setAttribute('x3', v4.x.toString()); + xml.setAttribute('y3', v4.y.toString()); + xml.setAttribute('z3', v4.z.toString()); + xml.removeAttribute('x2'); + xml.removeAttribute('y2'); + } + }); + // update stereo groups in cml + complex.forEachSGroup(function (sGroup) { + if (sGroup.xmlNodeRef && sGroup.xmlNodeRef.xmlNode) { + xml = sGroup.xmlNodeRef.xmlNode; + ap = sGroup.getPosition(); + v4.set(ap.x, ap.y, ap.z, 1.0); + var cp = sGroup.getCentralPoint(); + if (cp === null) { + v4.applyMatrix4(mat); + } else { + vCenter.set(cp.x, cp.y, cp.z, 0.0); + v4.add(vCenter); + v4.applyMatrix4(mat); // pos in global space + vCenter.set(cp.x, cp.y, cp.z, 1.0); + vCenter.applyMatrix4(mat); + v4.sub(vCenter); + } + xml.setAttribute('x', v4.x.toString()); + xml.setAttribute('y', v4.y.toString()); + xml.setAttribute('z', v4.z.toString()); + } + }); + } + + // FIXME save data for all complexes (not only current) + var visual = self._getComplexVisual(); + var complex = visual ? visual.getComplex() : null; + if (complex && complex.originalCML) { + updateCMLData(complex); + + // serialize xml structure to string + var oSerializer = new XMLSerializer(); + return oSerializer.serializeToString(complex.originalCML); + } + + return null; +}; //////////////////////////////////////////////////////////////////////////// // Additional exports -Miew.prototype.VERSION = typeof "0.7.11" !== 'undefined' && "0.7.11" || '0.0.0-dev'; +Miew.prototype.VERSION = typeof "0.7.12" !== 'undefined' && "0.7.12" || '0.0.0-dev'; // Miew.prototype.debugTracer = new utils.DebugTracer(Miew.prototype); lodash.assign(Miew, /** @lends Miew */{ @@ -91303,12 +92303,12 @@ var MiewCLIParser = createCommonjsModule(function (module, exports) { } */ var parser = (function(){ -var o=function(k,v,o,l){for(o=o||{}, l=k.length;l--;o[k[l]]=v);return o},$V0=[1,73],$V1=[1,75],$V2=[1,76],$V3=[1,79],$V4=[1,80],$V5=[1,81],$V6=[1,82],$V7=[1,83],$V8=[1,94],$V9=[1,86],$Va=[1,87],$Vb=[1,88],$Vc=[1,89],$Vd=[1,112],$Ve=[1,90],$Vf=[1,113],$Vg=[1,93],$Vh=[1,64],$Vi=[1,95],$Vj=[1,96],$Vk=[1,98],$Vl=[1,97],$Vm=[1,109],$Vn=[1,110],$Vo=[1,111],$Vp=[1,99],$Vq=[1,100],$Vr=[1,101],$Vs=[1,102],$Vt=[1,103],$Vu=[1,104],$Vv=[1,105],$Vw=[1,106],$Vx=[1,107],$Vy=[1,108],$Vz=[1,114],$VA=[1,115],$VB=[1,116],$VC=[1,118],$VD=[1,117],$VE=[1,70],$VF=[1,72],$VG=[1,69],$VH=[1,71],$VI=[1,77],$VJ=[1,78],$VK=[1,84],$VL=[1,85],$VM=[1,91],$VN=[1,92],$VO=[1,66],$VP=[1,67],$VQ=[1,68],$VR=[1,74],$VS=[1,128],$VT=[1,124],$VU=[1,127],$VV=[1,125],$VW=[1,126],$VX=[1,131],$VY=[1,130],$VZ=[1,147],$V_=[1,155],$V$=[1,162],$V01=[1,163],$V11=[1,200],$V21=[5,6,7,9,12,13,14,16,17,18,19,22,24,25,26,29,32,33,34,36,37,40,42,43,44,51,53,54,55,57,58,59,61,62,63,65,66,67,68,69,70,71,72,73,74,76,77,78,79,81,82,84,85,86,90,91,93,96,97,100,102,103],$V31=[5,6,7,9,12,13,14,16,17,18,19,22,24,25,26,29,32,33,34,36,37,40,42,43,44,51,53,54,55,57,58,59,61,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,81,82,84,85,86,90,91,93,96,97,100,102,103],$V41=[5,6,7,9,12,14,16,17,18,19,22,24,25,26,29,32,33,36,37,40,42,43,44,51,53,54,55,57,58,61,62,63,65,66,67,68,69,70,71,72,73,79,81,82,84,85,86,90,91,100],$V51=[5,90,91],$V61=[5,93],$V71=[1,226],$V81=[5,13,59,74,103],$V91=[75,102]; +var o=function(k,v,o,l){for(o=o||{}, l=k.length;l--;o[k[l]]=v);return o},$V0=[1,74],$V1=[1,76],$V2=[1,77],$V3=[1,80],$V4=[1,81],$V5=[1,82],$V6=[1,83],$V7=[1,84],$V8=[1,95],$V9=[1,87],$Va=[1,88],$Vb=[1,89],$Vc=[1,90],$Vd=[1,113],$Ve=[1,91],$Vf=[1,114],$Vg=[1,94],$Vh=[1,65],$Vi=[1,96],$Vj=[1,97],$Vk=[1,99],$Vl=[1,98],$Vm=[1,110],$Vn=[1,111],$Vo=[1,112],$Vp=[1,100],$Vq=[1,101],$Vr=[1,102],$Vs=[1,103],$Vt=[1,104],$Vu=[1,105],$Vv=[1,106],$Vw=[1,107],$Vx=[1,108],$Vy=[1,109],$Vz=[1,115],$VA=[1,116],$VB=[1,117],$VC=[1,119],$VD=[1,118],$VE=[1,71],$VF=[1,73],$VG=[1,70],$VH=[1,72],$VI=[1,78],$VJ=[1,79],$VK=[1,85],$VL=[1,86],$VM=[1,92],$VN=[1,93],$VO=[1,67],$VP=[1,68],$VQ=[1,69],$VR=[1,75],$VS=[1,129],$VT=[1,125],$VU=[1,128],$VV=[1,126],$VW=[1,127],$VX=[1,132],$VY=[1,131],$VZ=[1,148],$V_=[1,156],$V$=[1,163],$V01=[1,164],$V11=[1,201],$V21=[5,6,7,9,12,13,14,16,17,18,19,22,24,25,26,29,32,33,34,36,37,40,42,44,45,52,54,55,56,58,59,60,62,63,64,66,67,68,69,70,71,72,73,74,75,77,78,79,80,82,83,85,86,87,91,92,94,97,98,101,103,104],$V31=[5,6,7,9,12,13,14,16,17,18,19,22,24,25,26,29,32,33,34,36,37,40,42,44,45,52,54,55,56,58,59,60,62,63,64,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,85,86,87,91,92,94,97,98,101,103,104],$V41=[5,6,7,9,12,14,16,17,18,19,22,24,25,26,29,32,33,36,37,40,42,44,45,52,54,55,56,58,59,62,63,64,66,67,68,69,70,71,72,73,74,80,82,83,85,86,87,91,92,101],$V51=[5,91,92],$V61=[5,94],$V71=[1,227],$V81=[5,13,60,75,104],$V91=[76,103]; var parser = {trace: function trace() { }, yy: {}, -symbols_: {"error":2,"Program":3,"Command":4,"EOF":5,"RESET":6,"BUILD":7,"ALL":8,"HELP":9,"Path":10,"OneArgCommand":11,"GET":12,"STRING":13,"SET":14,"Value":15,"SET_SAVE":16,"SET_RESTORE":17,"SET_RESET":18,"PRESET":19,"AddRepresentation":20,"EditRepresentation":21,"REMOVE":22,"RepresentationReference":23,"HIDE":24,"SHOW":25,"LIST":26,"EXPAND_KEY":27,"SELECTOR_KEY":28,"SELECT":29,"AS":30,"WordAll":31,"SELECTOR":32,"WITHIN":33,"NUMBER":34,"OF":35,"MATERIAL":36,"IDENTIFIER":37,"ModeCMD":38,"ColorCMD":39,"VIEW":40,"BASE_64":41,"UNIT":42,"SCALE":43,"ROTATE":44,"AxesList":45,"TRANSLATE":46,"GetURLBranch":47,"Screenshot":48,"SrvCMD":49,"SrvScenarioCMD":50,"LINE":51,"ArgList":52,"LISTOBJ":53,"REMOVEOBJ":54,"URL":55,"VIEW_KEY":56,"SCREENSHOT":57,"FILE_LIST":58,"FILE_KEY":59,"PresetPath":60,"FILE_REGISTER":61,"FILE_DELETE":62,"PRESET_ADD":63,"Word":64,"PRESET_DELETE":65,"PRESET_UPDATE":66,"PRESET_RENAME":67,"PRESET_OPEN":68,"CREATE_SCENARIO":69,"RESET_SCENARIO":70,"DELETE_SCENARIO":71,"LIST_SCENARIO":72,"ADD_SCENARIO_ITEM":73,"DELAY_KEY":74,"=":75,"DESCRIPTION_KEY":76,"PDB_KEY":77,"PRST_KEY":78,"LOAD":79,"Url":80,"SCRIPT":81,"ADD":82,"Description":83,"REP":84,"MODE":85,"COLOR":86,"Descriptor":87,"RepresentationOwnProperty":88,"RepresentationOwnPropertyOpts":89,"DESC_KEY":90,"DESC_KEY_OPTS":91,"AxesArg":92,"DESC_KEY_AXES":93,"Arg":94,"PathWoDescKey":95,"HEX":96,"BOOL":97,"CommandSetWoDESC_KEY":98,"DescKeys":99,"CLEAR":100,"CommandSet":101,".":102,"/":103,"HexOrNumber":104,"$accept":0,"$end":1}, -terminals_: {2:"error",5:"EOF",6:"RESET",7:"BUILD",8:"ALL",9:"HELP",12:"GET",13:"STRING",14:"SET",16:"SET_SAVE",17:"SET_RESTORE",18:"SET_RESET",19:"PRESET",22:"REMOVE",24:"HIDE",25:"SHOW",26:"LIST",27:"EXPAND_KEY",28:"SELECTOR_KEY",29:"SELECT",30:"AS",32:"SELECTOR",33:"WITHIN",34:"NUMBER",35:"OF",36:"MATERIAL",37:"IDENTIFIER",40:"VIEW",41:"BASE_64",42:"UNIT",43:"SCALE",44:"ROTATE",46:"TRANSLATE",51:"LINE",53:"LISTOBJ",54:"REMOVEOBJ",55:"URL",56:"VIEW_KEY",57:"SCREENSHOT",58:"FILE_LIST",59:"FILE_KEY",61:"FILE_REGISTER",62:"FILE_DELETE",63:"PRESET_ADD",65:"PRESET_DELETE",66:"PRESET_UPDATE",67:"PRESET_RENAME",68:"PRESET_OPEN",69:"CREATE_SCENARIO",70:"RESET_SCENARIO",71:"DELETE_SCENARIO",72:"LIST_SCENARIO",73:"ADD_SCENARIO_ITEM",74:"DELAY_KEY",75:"=",76:"DESCRIPTION_KEY",77:"PDB_KEY",78:"PRST_KEY",79:"LOAD",81:"SCRIPT",82:"ADD",84:"REP",85:"MODE",86:"COLOR",90:"DESC_KEY",91:"DESC_KEY_OPTS",93:"DESC_KEY_AXES",96:"HEX",97:"BOOL",100:"CLEAR",102:".",103:"/"}, -productions_: [0,[3,2],[3,1],[4,1],[4,1],[4,2],[4,1],[4,2],[4,1],[4,2],[4,2],[4,3],[4,3],[4,1],[4,1],[4,1],[4,1],[4,2],[4,1],[4,1],[4,2],[4,2],[4,2],[4,2],[4,1],[4,2],[4,2],[4,2],[4,4],[4,2],[4,6],[4,2],[4,1],[4,1],[4,1],[4,2],[4,2],[4,1],[4,2],[4,2],[4,2],[4,2],[4,1],[4,1],[4,1],[4,1],[4,3],[4,3],[4,4],[4,4],[4,1],[4,2],[47,1],[47,2],[47,2],[47,3],[47,3],[48,1],[48,2],[48,3],[49,1],[49,3],[49,2],[49,4],[49,2],[49,4],[49,2],[49,4],[49,1],[49,2],[49,2],[49,2],[49,3],[49,3],[49,3],[49,2],[49,2],[49,2],[49,2],[49,2],[49,2],[49,2],[49,2],[49,3],[49,3],[49,3],[49,2],[49,2],[49,2],[50,2],[50,2],[50,1],[50,2],[50,2],[50,2],[50,1],[50,2],[50,3],[50,3],[50,3],[50,7],[50,13],[50,13],[50,13],[50,13],[11,2],[11,2],[11,2],[11,2],[20,1],[20,2],[20,2],[20,3],[21,2],[21,3],[38,2],[38,3],[39,2],[39,3],[23,1],[23,1],[83,1],[83,2],[83,3],[83,4],[87,1],[87,1],[87,2],[88,3],[89,3],[45,1],[45,2],[92,2],[52,1],[52,2],[94,3],[15,1],[15,1],[15,1],[15,1],[15,1],[64,1],[64,1],[31,1],[31,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[101,1],[101,1],[95,1],[95,3],[95,3],[10,1],[10,1],[10,3],[10,3],[10,3],[80,1],[60,1],[60,3],[104,1],[104,1]], +symbols_: {"error":2,"Program":3,"Command":4,"EOF":5,"RESET":6,"BUILD":7,"ALL":8,"HELP":9,"Path":10,"OneArgCommand":11,"GET":12,"STRING":13,"SET":14,"Value":15,"SET_SAVE":16,"SET_RESTORE":17,"SET_RESET":18,"PRESET":19,"AddRepresentation":20,"EditRepresentation":21,"REMOVE":22,"RepresentationReference":23,"HIDE":24,"SHOW":25,"LIST":26,"EXPAND_KEY":27,"SELECTOR_KEY":28,"SELECT":29,"AS":30,"WordAll":31,"SELECTOR":32,"WITHIN":33,"NUMBER":34,"OF":35,"MATERIAL":36,"IDENTIFIER":37,"ModeCMD":38,"ColorCMD":39,"VIEW":40,"BASE_64":41,"UNIT":42,"DSSP":43,"SCALE":44,"ROTATE":45,"AxesList":46,"TRANSLATE":47,"GetURLBranch":48,"Screenshot":49,"SrvCMD":50,"SrvScenarioCMD":51,"LINE":52,"ArgList":53,"LISTOBJ":54,"REMOVEOBJ":55,"URL":56,"VIEW_KEY":57,"SCREENSHOT":58,"FILE_LIST":59,"FILE_KEY":60,"PresetPath":61,"FILE_REGISTER":62,"FILE_DELETE":63,"PRESET_ADD":64,"Word":65,"PRESET_DELETE":66,"PRESET_UPDATE":67,"PRESET_RENAME":68,"PRESET_OPEN":69,"CREATE_SCENARIO":70,"RESET_SCENARIO":71,"DELETE_SCENARIO":72,"LIST_SCENARIO":73,"ADD_SCENARIO_ITEM":74,"DELAY_KEY":75,"=":76,"DESCRIPTION_KEY":77,"PDB_KEY":78,"PRST_KEY":79,"LOAD":80,"Url":81,"SCRIPT":82,"ADD":83,"Description":84,"REP":85,"MODE":86,"COLOR":87,"Descriptor":88,"RepresentationOwnProperty":89,"RepresentationOwnPropertyOpts":90,"DESC_KEY":91,"DESC_KEY_OPTS":92,"AxesArg":93,"DESC_KEY_AXES":94,"Arg":95,"PathWoDescKey":96,"HEX":97,"BOOL":98,"CommandSetWoDESC_KEY":99,"DescKeys":100,"CLEAR":101,"CommandSet":102,".":103,"/":104,"HexOrNumber":105,"$accept":0,"$end":1}, +terminals_: {2:"error",5:"EOF",6:"RESET",7:"BUILD",8:"ALL",9:"HELP",12:"GET",13:"STRING",14:"SET",16:"SET_SAVE",17:"SET_RESTORE",18:"SET_RESET",19:"PRESET",22:"REMOVE",24:"HIDE",25:"SHOW",26:"LIST",27:"EXPAND_KEY",28:"SELECTOR_KEY",29:"SELECT",30:"AS",32:"SELECTOR",33:"WITHIN",34:"NUMBER",35:"OF",36:"MATERIAL",37:"IDENTIFIER",40:"VIEW",41:"BASE_64",42:"UNIT",43:"DSSP",44:"SCALE",45:"ROTATE",47:"TRANSLATE",52:"LINE",54:"LISTOBJ",55:"REMOVEOBJ",56:"URL",57:"VIEW_KEY",58:"SCREENSHOT",59:"FILE_LIST",60:"FILE_KEY",62:"FILE_REGISTER",63:"FILE_DELETE",64:"PRESET_ADD",66:"PRESET_DELETE",67:"PRESET_UPDATE",68:"PRESET_RENAME",69:"PRESET_OPEN",70:"CREATE_SCENARIO",71:"RESET_SCENARIO",72:"DELETE_SCENARIO",73:"LIST_SCENARIO",74:"ADD_SCENARIO_ITEM",75:"DELAY_KEY",76:"=",77:"DESCRIPTION_KEY",78:"PDB_KEY",79:"PRST_KEY",80:"LOAD",82:"SCRIPT",83:"ADD",85:"REP",86:"MODE",87:"COLOR",91:"DESC_KEY",92:"DESC_KEY_OPTS",94:"DESC_KEY_AXES",97:"HEX",98:"BOOL",101:"CLEAR",103:".",104:"/"}, +productions_: [0,[3,2],[3,1],[4,1],[4,1],[4,2],[4,1],[4,2],[4,1],[4,2],[4,2],[4,3],[4,3],[4,1],[4,1],[4,1],[4,1],[4,2],[4,1],[4,1],[4,2],[4,2],[4,2],[4,2],[4,1],[4,2],[4,2],[4,2],[4,4],[4,2],[4,6],[4,2],[4,1],[4,1],[4,1],[4,2],[4,2],[4,1],[4,2],[4,1],[4,2],[4,2],[4,2],[4,1],[4,1],[4,1],[4,1],[4,3],[4,3],[4,4],[4,4],[4,1],[4,2],[48,1],[48,2],[48,2],[48,3],[48,3],[49,1],[49,2],[49,3],[50,1],[50,3],[50,2],[50,4],[50,2],[50,4],[50,2],[50,4],[50,1],[50,2],[50,2],[50,2],[50,3],[50,3],[50,3],[50,2],[50,2],[50,2],[50,2],[50,2],[50,2],[50,2],[50,2],[50,3],[50,3],[50,3],[50,2],[50,2],[50,2],[51,2],[51,2],[51,1],[51,2],[51,2],[51,2],[51,1],[51,2],[51,3],[51,3],[51,3],[51,7],[51,13],[51,13],[51,13],[51,13],[11,2],[11,2],[11,2],[11,2],[20,1],[20,2],[20,2],[20,3],[21,2],[21,3],[38,2],[38,3],[39,2],[39,3],[23,1],[23,1],[84,1],[84,2],[84,3],[84,4],[88,1],[88,1],[88,2],[89,3],[90,3],[46,1],[46,2],[93,2],[53,1],[53,2],[95,3],[15,1],[15,1],[15,1],[15,1],[15,1],[65,1],[65,1],[31,1],[31,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[100,1],[100,1],[100,1],[100,1],[100,1],[100,1],[100,1],[102,1],[102,1],[96,1],[96,3],[96,3],[10,1],[10,1],[10,3],[10,3],[10,3],[81,1],[61,1],[61,3],[105,1],[105,1]], performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { /* this == yyval */ @@ -91402,240 +92402,243 @@ case 38: this.$ = yy.miew.changeUnit($$[$0]); break; case 39: -this.$ = yy.miew.scale($$[$0]); +this.$ = yy.miew.dssp(); break; case 40: - for (var i = 0, n = $$[$0].length; i < n; i++) {yy.miew.rotate($$[$0][i]['x'] * Math.PI / 180.0, $$[$0][i]['y'] * Math.PI / 180.0, $$[$0][i]['z'] * Math.PI / 180.0);} +this.$ = yy.miew.scale($$[$0]); break; case 41: + for (var i = 0, n = $$[$0].length; i < n; i++) {yy.miew.rotate($$[$0][i]['x'] * Math.PI / 180.0, $$[$0][i]['y'] * Math.PI / 180.0, $$[$0][i]['z'] * Math.PI / 180.0);} +break; +case 42: for (var i = 0, n = $$[$0].length; i < n; i++) {yy.miew.translate($$[$0][i]['x'] || 0, $$[$0][i]['y'] || 0, $$[$0][i]['z'] || 0);} break; -case 46: case 47: +case 47: case 48: this.$ = yy.miew.addObject({type: 'line', params: [$$[$0-1], $$[$0]]}, true); break; -case 48: case 49: +case 49: case 50: this.$ = yy.miew.addObject({type: 'line', params: [$$[$0-2], $$[$0-1]], opts:$$[$0].toJSO(yy.utils, 'objects', 'line')}, true); break; -case 50: +case 51: this.$ = yy.echo(yy.utils.listObjs(yy.miew)); break; -case 51: +case 52: this.$ = yy.miew.removeObject($$[$0]); break; -case 52: +case 53: this.$ = yy.echo(yy.miew.getURL({view: false, settings: false})); break; -case 53: +case 54: this.$ = yy.echo(yy.miew.getURL({view: false, settings: true})); break; -case 54: +case 55: this.$ = yy.echo(yy.miew.getURL({view: true, settings: false})); break; -case 55: case 56: +case 56: case 57: this.$ = yy.echo(yy.miew.getURL({view: true, settings: true})); break; -case 57: +case 58: this.$ = yy.miew.screenshotSave(); break; -case 58: +case 59: this.$ = yy.miew.screenshotSave('', Number($$[$0])); break; -case 59: +case 60: this.$ = yy.miew.screenshotSave('', Number($$[$0-1]), Number($$[$0])); break; -case 60: +case 61: this.$ = yy.srv.fileList(yy.miew, yy.echo, yy.error); break; -case 61: +case 62: this.$ = yy.srv.fileList(yy.miew, yy.echo, yy.error, "", $$[$0]); break; -case 62: +case 63: this.$ = yy.srv.fileList(yy.miew, yy.echo, yy.error, $$[$0]); break; -case 63: +case 64: this.$ = yy.srv.fileList(yy.miew, yy.echo, yy.error, $$[$0-2], $$[$0]); break; -case 64: case 66: +case 65: case 67: this.$ = yy.srv.coroutineWithFileName(yy.miew, yy.echo, yy.error, $$[$0], yy.srv.fileList, yy.srv, yy.miew, yy.echo, yy.error); break; -case 65: case 67: +case 66: case 68: this.$ = yy.srv.coroutineWithFileName(yy.miew, yy.echo, yy.error, $$[$0-2], yy.srv.fileList, yy.srv, yy.miew, yy.echo, yy.error, $$[$0]); break; -case 68: +case 69: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvTopologyRegister"); break; -case 69: +case 70: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvTopologyDelete", $$[$0], false); break; -case 70: case 71: +case 71: case 72: this.$ = yy.srv.coroutineWithFileName(yy.miew, yy.echo, yy.error, $$[$0], yy.miew.srvTopologyDelete, false); break; -case 72: +case 73: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvTopologyDelete", $$[$0-1], true); break; -case 73: case 74: +case 74: case 75: this.$ = yy.srv.coroutineWithFileName(yy.miew, yy.echo, yy.error, $$[$0-1], yy.miew.srvTopologyDelete, true); break; -case 75: case 76: +case 76: case 77: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvPresetCreate", $$[$0]); break; -case 77: +case 78: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvPresetDelete", $$[$0]); break; -case 78: case 79: +case 79: case 80: this.$ = yy.srv.coroutineWithPresetPath(yy.miew, yy.echo, yy.error, $$[$0], yy.miew.srvPresetDelete); break; -case 80: +case 81: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvPresetUpdate", $$[$0]); break; -case 81: case 82: +case 82: case 83: this.$ = yy.srv.coroutineWithPresetPath(yy.miew, yy.echo, yy.error, $$[$0], yy.miew.srvPresetUpdate); break; -case 83: +case 84: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvPresetRename", $$[$0-1], $$[$0]); break; -case 84: case 85: +case 85: case 86: this.$ = yy.srv.coroutineWithPresetPath(yy.miew, yy.echo, yy.error, $$[$0-1], yy.miew.srvPresetRename, $$[$0]); break; -case 86: +case 87: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvPresetApply", $$[$0]); yy.representations.clear(); break; -case 87: case 88: +case 88: case 89: this.$ = yy.srv.coroutineWithPresetPath(yy.miew, yy.echo, yy.error, $$[$0], yy.miew.srvPresetApply); yy.representations.clear(); break; -case 89: case 90: +case 90: case 91: this.$ = yy.srv.createScenario($$[$0]); break; -case 91: +case 92: this.$ = yy.srv.resetScenario(); break; -case 92: case 93: +case 93: case 94: this.$ = yy.srv.deleteScenario(yy.miew, yy.echo, yy.error, $$[$0]); break; -case 94: +case 95: this.$ = yy.srv.deleteScenario(yy.miew, yy.echo, yy.error, Number($$[$0])); break; -case 95: +case 96: this.$ = yy.srv.listScenario(yy.miew, yy.echo, yy.error); break; -case 96: case 97: case 98: case 99: +case 97: case 98: case 99: case 100: this.$ = yy.srv.listScenario(yy.miew, yy.echo, yy.error, $$[$0]); break; -case 100: +case 101: this.$ =yy.srv.addScenarioItem(yy.miew, yy.echo, yy.error, Number($$[$0-3]), $$[$0]); break; -case 101: +case 102: this.$ =yy.srv.addScenarioItem(yy.miew, yy.echo, yy.error, Number($$[$0-9]), Number($$[$0-6]), Number($$[$0-3]), $$[$0]); break; -case 102: +case 103: this.$ =yy.srv.addScenarioItem(yy.miew, yy.echo, yy.error, $$[$0-9], Number($$[$0-6]), Number($$[$0-3]), $$[$0]); break; -case 103: +case 104: this.$ =yy.srv.addScenarioItem(yy.miew, yy.echo, yy.error, Number($$[$0-9]), $$[$0-6], Number($$[$0-3]), $$[$0]); break; -case 104: +case 105: this.$ =yy.srv.addScenarioItem(yy.miew, yy.echo, yy.error, $$[$0-9], $$[$0-6], Number($$[$0-3]), $$[$0]); break; -case 105: case 106: case 107: +case 106: case 107: case 108: this.$ = yy.utils.load(yy.miew, $$[$0]); yy.representations.clear(); break; -case 108: +case 109: this.$ = yy.notimplemented(); break; -case 109: +case 110: this.$ = yy.echo(yy.representations.add(yy.miew.repAdd())); break; -case 110: +case 111: this.$ = yy.echo(yy.representations.add($$[$0], yy.miew.repAdd())); break; -case 111: +case 112: this.$ = yy.echo(yy.representations.add(yy.miew.repAdd($$[$0]))); break; -case 112: +case 113: this.$ = yy.echo(yy.representations.add($$[$0-1], yy.miew.repAdd($$[$0]))); break; -case 113: +case 114: this.$ = yy.miew.rep($$[$0]); yy.miew.repCurrent($$[$0]); break; -case 114: +case 115: this.$ = yy.miew.rep($$[$0-1], $$[$0]); yy.miew.repCurrent($$[$0-1]); break; -case 115: +case 116: this.$ = yy.miew.rep(yy.miew.repCurrent(), {mode : yy.utils.checkArg($$[$0-1].toLowerCase(), $$[$0].toUpperCase())}); break; -case 116: +case 117: this.$ = yy.miew.rep(yy.miew.repCurrent(), {mode : new Array(yy.utils.checkArg($$[$0-2].toLowerCase(), $$[$0-1].toUpperCase()), $$[$0].toJSO(yy.utils, $$[$0-2], $$[$0-1].toUpperCase()))}); break; -case 117: +case 118: this.$ = yy.miew.rep(yy.miew.repCurrent(), {colorer : yy.utils.checkArg($$[$0-1].toLowerCase(), $$[$0].toUpperCase())}); break; -case 118: +case 119: this.$ = yy.miew.rep(yy.miew.repCurrent(), {colorer : new Array(yy.utils.checkArg($$[$0-2].toLowerCase(), $$[$0-1].toUpperCase()), $$[$0].toJSO(yy.utils, $$[$0-2], $$[$0-1].toUpperCase()))}); break; -case 119: +case 120: this.$ = Number(yy.representations.get($$[$0])); break; -case 120: case 136: +case 121: case 137: this.$ = Number($$[$0]); break; -case 121: +case 122: this.$ = $$[$0]; break; -case 122: +case 123: this.$ = yy._.assign($$[$0-1], $$[$0]); break; -case 123: +case 124: this.$ = yy._.assign($$[$0-2], $$[$0-1], $$[$0]); break; -case 124: +case 125: this.$ = yy._.assign($$[$0-3], $$[$0-2], $$[$0-1], $$[$0]); break; -case 125: case 126: +case 126: case 127: this.$ = yy.CreateObjectPair($$[$0].key, $$[$0].val); break; -case 127: +case 128: this.$ = yy.CreateObjectPair($$[$0-1].key, new Array($$[$0-1].val, $$[$0].toJSO(yy.utils, $$[$0-1].key, $$[$0-1].val))); break; -case 128: case 129: +case 129: case 130: this.$ = Object.create({'key': yy.keyRemap($$[$0-2]), 'val': yy.utils.checkArg($$[$0-2], $$[$0])}); break; -case 130: +case 131: this.$ = [$$[$0]]; break; -case 131: +case 132: this.$ = $$[$0-1].concat($$[$0]); break; -case 132: +case 133: this.$ = yy.CreateObjectPair($$[$0-1].toLowerCase(), Number($$[$0])); break; -case 133: +case 134: this.$ = new yy.ArgList($$[$0]); break; -case 134: +case 135: this.$ = $$[$0-1].append($$[$0]); break; -case 135: +case 136: this.$ = new yy.Arg($$[$0-2], $$[$0]); break; -case 137: +case 138: this.$ = parseInt($$[$0]); break; -case 138: +case 139: this.$ = JSON.parse($$[$0]); break; -case 139: case 140: +case 140: case 141: this.$ = String($$[$0]); break; -case 201: case 202: case 205: case 206: case 207: +case 202: case 203: case 206: case 207: case 208: this.$ = $$[$0-2] + $$[$0-1] + $$[$0]; //cause of could be color word in path; break; -case 210: +case 211: this.$ = $$[$0-2] = $$[$0-2] + $$[$0-1] + $$[$0]; break; } }, -table: [{3:1,4:2,5:[1,3],6:[1,4],7:[1,5],9:[1,6],11:7,12:[1,8],14:[1,9],16:[1,10],17:[1,11],18:[1,12],19:[1,13],20:14,21:15,22:[1,16],24:[1,17],25:[1,18],26:[1,19],29:[1,20],32:[1,21],33:[1,22],36:[1,23],38:24,39:25,40:[1,26],42:[1,27],43:[1,28],44:[1,29],46:[1,30],47:31,48:32,49:33,50:34,51:[1,35],53:[1,36],54:[1,37],55:[1,44],57:[1,45],58:[1,46],61:[1,47],62:[1,48],63:[1,49],65:[1,50],66:[1,51],67:[1,52],68:[1,53],69:[1,54],70:[1,55],71:[1,56],72:[1,57],73:[1,58],79:[1,38],81:[1,39],82:[1,40],84:[1,41],85:[1,42],86:[1,43]},{1:[3]},{5:[1,59]},{1:[2,2]},{5:[2,3]},{5:[2,4],8:[1,60]},{5:[2,6],6:$V0,7:$V1,9:$V2,10:61,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{5:[2,8]},{6:$V0,7:$V1,9:$V2,10:119,12:$V3,13:[1,120],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{6:$V0,7:$V1,9:$V2,10:121,12:$V3,13:[1,122],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{5:[2,13]},{5:[2,14]},{5:[2,15]},{5:[2,16],13:$VS,15:123,34:$VT,37:$VU,96:$VV,97:$VW},{5:[2,18]},{5:[2,19]},{23:129,34:$VX,37:$VY},{23:132,34:$VX,37:$VY},{23:133,34:$VX,37:$VY},{5:[2,24],23:134,27:[1,135],28:[1,136],34:$VX,37:$VY},{13:[1,137]},{13:[1,138]},{34:[1,139]},{37:[1,140]},{5:[2,32]},{5:[2,33]},{5:[2,34],13:[1,141],41:[1,142]},{5:[2,37],34:[1,143]},{34:[1,144]},{45:145,92:146,93:$VZ},{45:148,92:146,93:$VZ},{5:[2,42]},{5:[2,43]},{5:[2,44]},{5:[2,45]},{6:$V0,7:$V1,9:$V2,10:150,12:$V3,13:[1,149],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{5:[2,50]},{34:[1,151]},{13:$V_,37:[1,153],59:[1,154],80:152},{13:$V_,80:156},{5:[2,109],37:[1,157],83:158,87:159,88:160,89:161,90:$V$,91:$V01},{23:164,34:$VX,37:$VY},{37:[1,165]},{37:[1,166]},{5:[2,52],28:[1,167],56:[1,168]},{5:[2,57],34:[1,169]},{5:[2,60],6:$V0,7:$V1,9:$V2,10:174,12:$V3,13:[1,173],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,171],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,59:[1,170],60:172,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{5:[2,68]},{6:$V0,7:$V1,9:$V2,10:174,12:$V3,13:[1,176],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,175],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,60:177,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{6:$V0,7:$V1,9:$V2,12:$V3,13:[1,178],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:179,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,98:65,100:$VR},{6:$V0,7:$V1,9:$V2,10:174,12:$V3,13:[1,181],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,180],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,60:182,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{6:$V0,7:$V1,9:$V2,10:174,12:$V3,13:[1,184],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,183],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,60:185,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{6:$V0,7:$V1,9:$V2,10:174,12:$V3,13:[1,187],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,186],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,60:188,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{6:$V0,7:$V1,9:$V2,10:174,12:$V3,13:[1,190],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,189],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,60:191,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{6:$V0,7:$V1,9:$V2,12:$V3,13:[1,192],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:193,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,98:65,100:$VR},{5:[2,91]},{6:$V0,7:$V1,9:$V2,12:$V3,13:[1,194],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,196],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:195,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,98:65,100:$VR},{5:[2,95],27:[1,197]},{74:[1,198],77:[1,199]},{1:[2,1]},{5:[2,5]},{5:[2,7],102:$V11},o($V21,[2,203]),o($V21,[2,204]),o($V31,[2,141]),o($V31,[2,142]),o($V21,[2,191]),o($V21,[2,192]),o($V21,[2,193]),o($V21,[2,194]),o($V21,[2,195]),o($V21,[2,196]),o($V21,[2,197]),o($V31,[2,145]),o($V31,[2,146]),o($V31,[2,147]),o($V31,[2,148]),o($V31,[2,149]),o($V31,[2,150]),o($V31,[2,151]),o($V31,[2,152]),o($V31,[2,153]),o($V31,[2,154]),o($V31,[2,155]),o($V31,[2,156]),o($V31,[2,157]),o($V31,[2,158]),o($V31,[2,159]),o($V31,[2,160]),o($V31,[2,161]),o($V31,[2,162]),o($V31,[2,163]),o($V31,[2,164]),o($V31,[2,165]),o($V31,[2,166]),o($V31,[2,167]),o($V31,[2,168]),o($V31,[2,169]),o($V31,[2,170]),o($V31,[2,171]),o($V31,[2,172]),o($V31,[2,173]),o($V31,[2,174]),o($V31,[2,175]),o($V31,[2,176]),o($V31,[2,177]),o($V31,[2,178]),o($V31,[2,179]),o($V31,[2,180]),o($V31,[2,181]),o($V31,[2,182]),o($V31,[2,183]),o($V31,[2,184]),o($V31,[2,185]),o($V31,[2,186]),o($V31,[2,187]),o($V31,[2,188]),o($V31,[2,189]),o($V31,[2,190]),{5:[2,9],102:$V11},{5:[2,10]},{13:$VS,15:201,34:$VT,37:$VU,96:$VV,97:$VW,102:$V11},{13:$VS,15:202,34:$VT,37:$VU,96:$VV,97:$VW},{5:[2,17]},o($V41,[2,136]),o($V41,[2,137]),o($V41,[2,138]),o($V41,[2,139]),o($V41,[2,140]),{5:[2,20]},o($V51,[2,119]),o($V51,[2,120]),{5:[2,21]},{5:[2,22]},{5:[2,23]},{5:[2,25]},{5:[2,26]},{5:[2,27],30:[1,203]},{5:[2,29]},{35:[1,204]},{5:[2,31]},{5:[2,35]},{5:[2,36]},{5:[2,38]},{5:[2,39]},{5:[2,40],92:205,93:$VZ},o($V61,[2,130]),{34:[1,206]},{5:[2,41],92:205,93:$VZ},{13:[1,207]},{6:$V0,7:$V1,9:$V2,10:208,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR,102:$V11},{5:[2,51]},{5:[2,105]},{5:[2,106]},{5:[2,107]},{5:[2,208]},{5:[2,108]},{5:[2,110],83:209,87:159,88:160,89:161,90:$V$,91:$V01},{5:[2,111]},{5:[2,121],87:210,88:160,89:161,90:$V$,91:$V01},o($V51,[2,125]),o($V51,[2,126],{98:65,52:211,94:212,95:213,64:214,6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,100:$VR}),{75:[1,215]},{75:[1,216]},{5:[2,113],83:217,87:159,88:160,89:161,90:$V$,91:$V01},{5:[2,115],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,52:218,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:212,95:213,98:65,100:$VR},{5:[2,117],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,52:219,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:212,95:213,98:65,100:$VR},{5:[2,53],56:[1,220]},{5:[2,54],28:[1,221]},{5:[2,58],34:[1,222]},{13:[1,223]},{5:[2,62],59:[1,224]},{5:[2,64],59:[1,225],103:$V71},{5:[2,66],59:[1,227]},o($V81,[2,209],{102:$V11}),{5:[2,69],59:[1,228]},{5:[2,70],59:[1,229]},{5:[2,71],59:[1,230],103:$V71},{5:[2,75]},{5:[2,76]},{5:[2,77]},{5:[2,78]},{5:[2,79],103:$V71},{5:[2,80]},{5:[2,81]},{5:[2,82],103:$V71},{13:[1,231]},{13:[1,232]},{13:[1,233],103:$V71},{5:[2,86]},{5:[2,87]},{5:[2,88],103:$V71},{5:[2,89]},{5:[2,90]},{5:[2,92]},{5:[2,93]},{5:[2,94]},{5:[2,96],6:$V0,7:$V1,9:$V2,12:$V3,13:[1,236],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,234],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:235,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,98:65,100:$VR},{75:[1,237]},{75:[1,238]},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,240],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:239,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:241,100:$VR},{5:[2,11]},{5:[2,12]},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,31:242,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:243,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:244,100:$VR},{13:[1,245]},o($V61,[2,131]),o($V61,[2,132]),{5:[2,46],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,52:246,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:212,95:213,98:65,100:$VR},{5:[2,47],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,52:247,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:212,95:213,98:65,100:$VR,102:$V11},{5:[2,112]},{5:[2,122],87:248,88:160,89:161,90:$V$,91:$V01},o($V51,[2,127],{98:65,95:213,64:214,94:249,6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,100:$VR}),o($V41,[2,133]),{75:[1,250],102:[1,251]},o($V91,[2,200]),{13:$VS,15:252,34:$VT,37:$VU,96:$VV,97:$VW},{13:$VS,15:253,34:$VT,37:$VU,96:$VV,97:$VW},{5:[2,114]},{5:[2,116],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:249,95:213,98:65,100:$VR},{5:[2,118],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:249,95:213,98:65,100:$VR},{5:[2,55]},{5:[2,56]},{5:[2,59]},{5:[2,61]},{13:[1,254]},{13:[1,255]},{6:$V0,7:$V1,9:$V2,10:256,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{13:[1,257]},{5:[2,72]},{5:[2,73]},{5:[2,74]},{5:[2,83]},{5:[2,84]},{5:[2,85]},{5:[2,97]},{5:[2,98]},{5:[2,99]},{34:[1,258]},{34:[1,259],37:[1,260]},o($V21,[2,205]),o($V21,[2,206]),o($V21,[2,207]),{5:[2,28]},{5:[2,143]},{5:[2,144]},{30:[1,261]},{5:[2,48],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:249,95:213,98:65,100:$VR},{5:[2,49],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:249,95:213,98:65,100:$VR},{5:[2,123],87:262,88:160,89:161,90:$V$,91:$V01},o($V41,[2,134]),{13:$VS,15:263,34:$VT,37:$VU,96:$VV,97:$VW},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,265],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:264,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,98:65,100:$VR},o($V51,[2,128]),o($V41,[2,129]),{5:[2,63]},{5:[2,65]},o($V81,[2,210],{102:$V11}),{5:[2,67]},{76:[1,266]},{78:[1,267]},{78:[1,268]},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,31:269,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:243,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:244,100:$VR},{5:[2,124]},o($V41,[2,135]),o($V91,[2,201]),o($V91,[2,202]),{75:[1,270]},{75:[1,271]},{75:[1,272]},{5:[2,30]},{13:[1,273]},{6:$V0,7:$V1,9:$V2,10:174,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,274],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,60:275,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{6:$V0,7:$V1,9:$V2,10:174,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,276],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,60:277,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{5:[2,100]},{74:[1,278]},{74:[1,279],103:$V71},{74:[1,280]},{74:[1,281],103:$V71},{75:[1,282]},{75:[1,283]},{75:[1,284]},{75:[1,285]},{34:[1,286]},{34:[1,287]},{34:[1,288]},{34:[1,289]},{76:[1,290]},{76:[1,291]},{76:[1,292]},{76:[1,293]},{75:[1,294]},{75:[1,295]},{75:[1,296]},{75:[1,297]},{13:[1,298]},{13:[1,299]},{13:[1,300]},{13:[1,301]},{5:[2,101]},{5:[2,103]},{5:[2,102]},{5:[2,104]}], -defaultActions: {3:[2,2],4:[2,3],7:[2,8],10:[2,13],11:[2,14],12:[2,15],14:[2,18],15:[2,19],24:[2,32],25:[2,33],31:[2,42],32:[2,43],33:[2,44],34:[2,45],36:[2,50],47:[2,68],55:[2,91],59:[2,1],60:[2,5],120:[2,10],123:[2,17],129:[2,20],132:[2,21],133:[2,22],134:[2,23],135:[2,25],136:[2,26],138:[2,29],140:[2,31],141:[2,35],142:[2,36],143:[2,38],144:[2,39],151:[2,51],152:[2,105],153:[2,106],154:[2,107],155:[2,208],156:[2,108],158:[2,111],178:[2,75],179:[2,76],180:[2,77],181:[2,78],183:[2,80],184:[2,81],189:[2,86],190:[2,87],192:[2,89],193:[2,90],194:[2,92],195:[2,93],196:[2,94],201:[2,11],202:[2,12],209:[2,112],217:[2,114],220:[2,55],221:[2,56],222:[2,59],223:[2,61],228:[2,72],229:[2,73],230:[2,74],231:[2,83],232:[2,84],233:[2,85],234:[2,97],235:[2,98],236:[2,99],242:[2,28],243:[2,143],244:[2,144],254:[2,63],255:[2,65],257:[2,67],262:[2,124],269:[2,30],273:[2,100],298:[2,101],299:[2,103],300:[2,102],301:[2,104]}, +table: [{3:1,4:2,5:[1,3],6:[1,4],7:[1,5],9:[1,6],11:7,12:[1,8],14:[1,9],16:[1,10],17:[1,11],18:[1,12],19:[1,13],20:14,21:15,22:[1,16],24:[1,17],25:[1,18],26:[1,19],29:[1,20],32:[1,21],33:[1,22],36:[1,23],38:24,39:25,40:[1,26],42:[1,27],43:[1,28],44:[1,29],45:[1,30],47:[1,31],48:32,49:33,50:34,51:35,52:[1,36],54:[1,37],55:[1,38],56:[1,45],58:[1,46],59:[1,47],62:[1,48],63:[1,49],64:[1,50],66:[1,51],67:[1,52],68:[1,53],69:[1,54],70:[1,55],71:[1,56],72:[1,57],73:[1,58],74:[1,59],80:[1,39],82:[1,40],83:[1,41],85:[1,42],86:[1,43],87:[1,44]},{1:[3]},{5:[1,60]},{1:[2,2]},{5:[2,3]},{5:[2,4],8:[1,61]},{5:[2,6],6:$V0,7:$V1,9:$V2,10:62,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{5:[2,8]},{6:$V0,7:$V1,9:$V2,10:120,12:$V3,13:[1,121],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{6:$V0,7:$V1,9:$V2,10:122,12:$V3,13:[1,123],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{5:[2,13]},{5:[2,14]},{5:[2,15]},{5:[2,16],13:$VS,15:124,34:$VT,37:$VU,97:$VV,98:$VW},{5:[2,18]},{5:[2,19]},{23:130,34:$VX,37:$VY},{23:133,34:$VX,37:$VY},{23:134,34:$VX,37:$VY},{5:[2,24],23:135,27:[1,136],28:[1,137],34:$VX,37:$VY},{13:[1,138]},{13:[1,139]},{34:[1,140]},{37:[1,141]},{5:[2,32]},{5:[2,33]},{5:[2,34],13:[1,142],41:[1,143]},{5:[2,37],34:[1,144]},{5:[2,39]},{34:[1,145]},{46:146,93:147,94:$VZ},{46:149,93:147,94:$VZ},{5:[2,43]},{5:[2,44]},{5:[2,45]},{5:[2,46]},{6:$V0,7:$V1,9:$V2,10:151,12:$V3,13:[1,150],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{5:[2,51]},{34:[1,152]},{13:$V_,37:[1,154],60:[1,155],81:153},{13:$V_,81:157},{5:[2,110],37:[1,158],84:159,88:160,89:161,90:162,91:$V$,92:$V01},{23:165,34:$VX,37:$VY},{37:[1,166]},{37:[1,167]},{5:[2,53],28:[1,168],57:[1,169]},{5:[2,58],34:[1,170]},{5:[2,61],6:$V0,7:$V1,9:$V2,10:175,12:$V3,13:[1,174],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,172],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,60:[1,171],61:173,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{5:[2,69]},{6:$V0,7:$V1,9:$V2,10:175,12:$V3,13:[1,177],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,176],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,61:178,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{6:$V0,7:$V1,9:$V2,12:$V3,13:[1,179],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:180,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,99:66,101:$VR},{6:$V0,7:$V1,9:$V2,10:175,12:$V3,13:[1,182],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,181],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,61:183,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{6:$V0,7:$V1,9:$V2,10:175,12:$V3,13:[1,185],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,184],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,61:186,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{6:$V0,7:$V1,9:$V2,10:175,12:$V3,13:[1,188],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,187],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,61:189,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{6:$V0,7:$V1,9:$V2,10:175,12:$V3,13:[1,191],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,190],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,61:192,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{6:$V0,7:$V1,9:$V2,12:$V3,13:[1,193],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:194,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,99:66,101:$VR},{5:[2,92]},{6:$V0,7:$V1,9:$V2,12:$V3,13:[1,195],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,197],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:196,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,99:66,101:$VR},{5:[2,96],27:[1,198]},{75:[1,199],78:[1,200]},{1:[2,1]},{5:[2,5]},{5:[2,7],103:$V11},o($V21,[2,204]),o($V21,[2,205]),o($V31,[2,142]),o($V31,[2,143]),o($V21,[2,192]),o($V21,[2,193]),o($V21,[2,194]),o($V21,[2,195]),o($V21,[2,196]),o($V21,[2,197]),o($V21,[2,198]),o($V31,[2,146]),o($V31,[2,147]),o($V31,[2,148]),o($V31,[2,149]),o($V31,[2,150]),o($V31,[2,151]),o($V31,[2,152]),o($V31,[2,153]),o($V31,[2,154]),o($V31,[2,155]),o($V31,[2,156]),o($V31,[2,157]),o($V31,[2,158]),o($V31,[2,159]),o($V31,[2,160]),o($V31,[2,161]),o($V31,[2,162]),o($V31,[2,163]),o($V31,[2,164]),o($V31,[2,165]),o($V31,[2,166]),o($V31,[2,167]),o($V31,[2,168]),o($V31,[2,169]),o($V31,[2,170]),o($V31,[2,171]),o($V31,[2,172]),o($V31,[2,173]),o($V31,[2,174]),o($V31,[2,175]),o($V31,[2,176]),o($V31,[2,177]),o($V31,[2,178]),o($V31,[2,179]),o($V31,[2,180]),o($V31,[2,181]),o($V31,[2,182]),o($V31,[2,183]),o($V31,[2,184]),o($V31,[2,185]),o($V31,[2,186]),o($V31,[2,187]),o($V31,[2,188]),o($V31,[2,189]),o($V31,[2,190]),o($V31,[2,191]),{5:[2,9],103:$V11},{5:[2,10]},{13:$VS,15:202,34:$VT,37:$VU,97:$VV,98:$VW,103:$V11},{13:$VS,15:203,34:$VT,37:$VU,97:$VV,98:$VW},{5:[2,17]},o($V41,[2,137]),o($V41,[2,138]),o($V41,[2,139]),o($V41,[2,140]),o($V41,[2,141]),{5:[2,20]},o($V51,[2,120]),o($V51,[2,121]),{5:[2,21]},{5:[2,22]},{5:[2,23]},{5:[2,25]},{5:[2,26]},{5:[2,27],30:[1,204]},{5:[2,29]},{35:[1,205]},{5:[2,31]},{5:[2,35]},{5:[2,36]},{5:[2,38]},{5:[2,40]},{5:[2,41],93:206,94:$VZ},o($V61,[2,131]),{34:[1,207]},{5:[2,42],93:206,94:$VZ},{13:[1,208]},{6:$V0,7:$V1,9:$V2,10:209,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR,103:$V11},{5:[2,52]},{5:[2,106]},{5:[2,107]},{5:[2,108]},{5:[2,209]},{5:[2,109]},{5:[2,111],84:210,88:160,89:161,90:162,91:$V$,92:$V01},{5:[2,112]},{5:[2,122],88:211,89:161,90:162,91:$V$,92:$V01},o($V51,[2,126]),o($V51,[2,127],{99:66,53:212,95:213,96:214,65:215,6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,101:$VR}),{76:[1,216]},{76:[1,217]},{5:[2,114],84:218,88:160,89:161,90:162,91:$V$,92:$V01},{5:[2,116],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,53:219,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:213,96:214,99:66,101:$VR},{5:[2,118],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,53:220,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:213,96:214,99:66,101:$VR},{5:[2,54],57:[1,221]},{5:[2,55],28:[1,222]},{5:[2,59],34:[1,223]},{13:[1,224]},{5:[2,63],60:[1,225]},{5:[2,65],60:[1,226],104:$V71},{5:[2,67],60:[1,228]},o($V81,[2,210],{103:$V11}),{5:[2,70],60:[1,229]},{5:[2,71],60:[1,230]},{5:[2,72],60:[1,231],104:$V71},{5:[2,76]},{5:[2,77]},{5:[2,78]},{5:[2,79]},{5:[2,80],104:$V71},{5:[2,81]},{5:[2,82]},{5:[2,83],104:$V71},{13:[1,232]},{13:[1,233]},{13:[1,234],104:$V71},{5:[2,87]},{5:[2,88]},{5:[2,89],104:$V71},{5:[2,90]},{5:[2,91]},{5:[2,93]},{5:[2,94]},{5:[2,95]},{5:[2,97],6:$V0,7:$V1,9:$V2,12:$V3,13:[1,237],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,235],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:236,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,99:66,101:$VR},{76:[1,238]},{76:[1,239]},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,241],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:240,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:242,101:$VR},{5:[2,11]},{5:[2,12]},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,31:243,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:244,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:245,101:$VR},{13:[1,246]},o($V61,[2,132]),o($V61,[2,133]),{5:[2,47],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,53:247,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:213,96:214,99:66,101:$VR},{5:[2,48],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,53:248,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:213,96:214,99:66,101:$VR,103:$V11},{5:[2,113]},{5:[2,123],88:249,89:161,90:162,91:$V$,92:$V01},o($V51,[2,128],{99:66,96:214,65:215,95:250,6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,101:$VR}),o($V41,[2,134]),{76:[1,251],103:[1,252]},o($V91,[2,201]),{13:$VS,15:253,34:$VT,37:$VU,97:$VV,98:$VW},{13:$VS,15:254,34:$VT,37:$VU,97:$VV,98:$VW},{5:[2,115]},{5:[2,117],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:250,96:214,99:66,101:$VR},{5:[2,119],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:250,96:214,99:66,101:$VR},{5:[2,56]},{5:[2,57]},{5:[2,60]},{5:[2,62]},{13:[1,255]},{13:[1,256]},{6:$V0,7:$V1,9:$V2,10:257,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{13:[1,258]},{5:[2,73]},{5:[2,74]},{5:[2,75]},{5:[2,84]},{5:[2,85]},{5:[2,86]},{5:[2,98]},{5:[2,99]},{5:[2,100]},{34:[1,259]},{34:[1,260],37:[1,261]},o($V21,[2,206]),o($V21,[2,207]),o($V21,[2,208]),{5:[2,28]},{5:[2,144]},{5:[2,145]},{30:[1,262]},{5:[2,49],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:250,96:214,99:66,101:$VR},{5:[2,50],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:250,96:214,99:66,101:$VR},{5:[2,124],88:263,89:161,90:162,91:$V$,92:$V01},o($V41,[2,135]),{13:$VS,15:264,34:$VT,37:$VU,97:$VV,98:$VW},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,266],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:265,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,99:66,101:$VR},o($V51,[2,129]),o($V41,[2,130]),{5:[2,64]},{5:[2,66]},o($V81,[2,211],{103:$V11}),{5:[2,68]},{77:[1,267]},{79:[1,268]},{79:[1,269]},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,31:270,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:244,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:245,101:$VR},{5:[2,125]},o($V41,[2,136]),o($V91,[2,202]),o($V91,[2,203]),{76:[1,271]},{76:[1,272]},{76:[1,273]},{5:[2,30]},{13:[1,274]},{6:$V0,7:$V1,9:$V2,10:175,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,275],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,61:276,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{6:$V0,7:$V1,9:$V2,10:175,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,277],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,61:278,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{5:[2,101]},{75:[1,279]},{75:[1,280],104:$V71},{75:[1,281]},{75:[1,282],104:$V71},{76:[1,283]},{76:[1,284]},{76:[1,285]},{76:[1,286]},{34:[1,287]},{34:[1,288]},{34:[1,289]},{34:[1,290]},{77:[1,291]},{77:[1,292]},{77:[1,293]},{77:[1,294]},{76:[1,295]},{76:[1,296]},{76:[1,297]},{76:[1,298]},{13:[1,299]},{13:[1,300]},{13:[1,301]},{13:[1,302]},{5:[2,102]},{5:[2,104]},{5:[2,103]},{5:[2,105]}], +defaultActions: {3:[2,2],4:[2,3],7:[2,8],10:[2,13],11:[2,14],12:[2,15],14:[2,18],15:[2,19],24:[2,32],25:[2,33],28:[2,39],32:[2,43],33:[2,44],34:[2,45],35:[2,46],37:[2,51],48:[2,69],56:[2,92],60:[2,1],61:[2,5],121:[2,10],124:[2,17],130:[2,20],133:[2,21],134:[2,22],135:[2,23],136:[2,25],137:[2,26],139:[2,29],141:[2,31],142:[2,35],143:[2,36],144:[2,38],145:[2,40],152:[2,52],153:[2,106],154:[2,107],155:[2,108],156:[2,209],157:[2,109],159:[2,112],179:[2,76],180:[2,77],181:[2,78],182:[2,79],184:[2,81],185:[2,82],190:[2,87],191:[2,88],193:[2,90],194:[2,91],195:[2,93],196:[2,94],197:[2,95],202:[2,11],203:[2,12],210:[2,113],218:[2,115],221:[2,56],222:[2,57],223:[2,60],224:[2,62],229:[2,73],230:[2,74],231:[2,75],232:[2,84],233:[2,85],234:[2,86],235:[2,98],236:[2,99],237:[2,100],243:[2,28],244:[2,144],245:[2,145],255:[2,64],256:[2,66],258:[2,68],263:[2,125],270:[2,30],274:[2,101],299:[2,102],300:[2,104],301:[2,103],302:[2,105]}, parseError: function parseError(str, hash) { if (hash.recoverable) { this.trace(str); @@ -92117,25 +93120,25 @@ case 3:return 41; break; case 4:return 34; break; -case 5:return 96; +case 5:return 97; break; -case 6:return 97; +case 6:return 98; break; -case 7:return 97; +case 7:return 98; break; case 8:return 8; break; case 9:return 6; break; -case 10:return 100; +case 10:return 101; break; case 11:return 7; break; case 12:return 9; break; -case 13:return 79; +case 13:return 80; break; -case 14:return 81; +case 14:return 82; break; case 15:return 12 break; @@ -92149,9 +93152,9 @@ case 19:return 18 break; case 20:return 19 break; -case 21:return 82 +case 21:return 83 break; -case 22:return 84 +case 22:return 85 break; case 23:return 22 break; @@ -92167,9 +93170,9 @@ case 28:return 33 break; case 29:return 32 break; -case 30:return 85 +case 30:return 86 break; -case 31:return 86 +case 31:return 87 break; case 32:return 36 break; @@ -92177,31 +93180,31 @@ case 33:return 40 break; case 34:return 42 break; -case 35:return 51 +case 35:return 52 break; -case 36:return 53 +case 36:return 54 break; -case 37:return 54 +case 37:return 55 break; -case 38:return 44 +case 38:return 45 break; -case 39:return 46 +case 39:return 47 break; -case 40:return 43 +case 40:return 44 break; -case 41:return 55 +case 41:return 56 break; -case 42:return 57; +case 42:return 58; break; -case 43:return 58 +case 43:return 43 break; -case 44:return 61 +case 44:return 59 break; case 45:return 62 break; case 46:return 63 break; -case 47:return 65 +case 47:return 64 break; case 48:return 66 break; @@ -92215,62 +93218,64 @@ case 52:return 70 break; case 53:return 71 break; -case 54:return 73 +case 54:return 72 break; -case 55:return 72 +case 55:return 74 break; -case 56:return 90 +case 56:return 73 break; -case 57:return 90 +case 57:return 91 break; case 58:return 91 break; -case 59:return 91 +case 59:return 92 break; -case 60:return 93 +case 60:return 92 break; -case 61:return 93 +case 61:return 94 break; -case 62:return 93 +case 62:return 94 break; -case 63:return 30 +case 63:return 94 break; -case 64:return 35 +case 64:return 30 break; -case 65:return 77 +case 65:return 35 break; -case 66:return 74 +case 66:return 78 break; -case 67:return 78 +case 67:return 75 break; -case 68:return 76 +case 68:return 79 break; -case 69:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 13; +case 69:return 77 break; -case 70:return 37; +case 70:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 13; break; -case 71:return 5; +case 71:return 37; break; -case 72:return 102; +case 72:return 5; break; case 73:return 103; break; -case 74:return '\\'; +case 74:return 104; +break; +case 75:return '\\'; break; -case 75:return 27 +case 76:return 27 break; -case 76:return 59 +case 77:return 60 break; -case 77:return 28 +case 78:return 28 break; -case 78:return 56 +case 79:return 57 break; -case 79:return 75 +case 80:return 76 break; } }, -rules: [/^(?:\s+)/i,/^(?:[#].*)/i,/^(?:\/\/.*)/i,/^(?:([_A-Z0-9\/\+]+==))/i,/^(?:-?[0-9]+(\.[0-9]+)?\b)/i,/^(?:0[xX][0-9A-F]+\b)/i,/^(?:false\b)/i,/^(?:true\b)/i,/^(?:all\b)/i,/^(?:reset\b)/i,/^(?:clear\b)/i,/^(?:build\b)/i,/^(?:help\b)/i,/^(?:load\b)/i,/^(?:script\b)/i,/^(?:get\b)/i,/^(?:set\b)/i,/^(?:set_save\b)/i,/^(?:set_restore\b)/i,/^(?:set_reset\b)/i,/^(?:preset\b)/i,/^(?:add\b)/i,/^(?:rep\b)/i,/^(?:remove\b)/i,/^(?:hide\b)/i,/^(?:show\b)/i,/^(?:list\b)/i,/^(?:select\b)/i,/^(?:within\b)/i,/^(?:selector\b)/i,/^(?:mode\b)/i,/^(?:color\b)/i,/^(?:material\b)/i,/^(?:view\b)/i,/^(?:unit\b)/i,/^(?:line\b)/i,/^(?:listobj\b)/i,/^(?:removeobj\b)/i,/^(?:rotate\b)/i,/^(?:translate\b)/i,/^(?:scale\b)/i,/^(?:url\b)/i,/^(?:screenshot\b)/i,/^(?:file_list\b)/i,/^(?:file_register\b)/i,/^(?:file_delete\b)/i,/^(?:preset_add\b)/i,/^(?:preset_delete\b)/i,/^(?:preset_update\b)/i,/^(?:preset_rename\b)/i,/^(?:preset_open\b)/i,/^(?:create_scenario\b)/i,/^(?:reset_scenario\b)/i,/^(?:delete_scenario\b)/i,/^(?:add_scenario_item\b)/i,/^(?:list_scenario\b)/i,/^(?:s\b)/i,/^(?:mt\b)/i,/^(?:m\b)/i,/^(?:c\b)/i,/^(?:x\b)/i,/^(?:y\b)/i,/^(?:z\b)/i,/^(?:as\b)/i,/^(?:of\b)/i,/^(?:pdb\b)/i,/^(?:delay\b)/i,/^(?:prst\b)/i,/^(?:desc\b)/i,/^(?:((?:"([^"]*)"|'([^']*)')))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:\.)/i,/^(?:\/)/i,/^(?:\\)/i,/^(?:-e\b)/i,/^(?:-f\b)/i,/^(?:-s\b)/i,/^(?:-v\b)/i,/^(?:=)/i], -conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79],"inclusive":true}} +rules: [/^(?:\s+)/i,/^(?:[#].*)/i,/^(?:\/\/.*)/i,/^(?:([_A-Z0-9\/\+]+==))/i,/^(?:-?[0-9]+(\.[0-9]+)?\b)/i,/^(?:0[xX][0-9A-F]+\b)/i,/^(?:false\b)/i,/^(?:true\b)/i,/^(?:all\b)/i,/^(?:reset\b)/i,/^(?:clear\b)/i,/^(?:build\b)/i,/^(?:help\b)/i,/^(?:load\b)/i,/^(?:script\b)/i,/^(?:get\b)/i,/^(?:set\b)/i,/^(?:set_save\b)/i,/^(?:set_restore\b)/i,/^(?:set_reset\b)/i,/^(?:preset\b)/i,/^(?:add\b)/i,/^(?:rep\b)/i,/^(?:remove\b)/i,/^(?:hide\b)/i,/^(?:show\b)/i,/^(?:list\b)/i,/^(?:select\b)/i,/^(?:within\b)/i,/^(?:selector\b)/i,/^(?:mode\b)/i,/^(?:color\b)/i,/^(?:material\b)/i,/^(?:view\b)/i,/^(?:unit\b)/i,/^(?:line\b)/i,/^(?:listobj\b)/i,/^(?:removeobj\b)/i,/^(?:rotate\b)/i,/^(?:translate\b)/i,/^(?:scale\b)/i,/^(?:url\b)/i,/^(?:screenshot\b)/i,/^(?:dssp\b)/i,/^(?:file_list\b)/i,/^(?:file_register\b)/i,/^(?:file_delete\b)/i,/^(?:preset_add\b)/i,/^(?:preset_delete\b)/i,/^(?:preset_update\b)/i,/^(?:preset_rename\b)/i,/^(?:preset_open\b)/i,/^(?:create_scenario\b)/i,/^(?:reset_scenario\b)/i,/^(?:delete_scenario\b)/i,/^(?:add_scenario_item\b)/i,/^(?:list_scenario\b)/i,/^(?:s\b)/i,/^(?:mt\b)/i,/^(?:m\b)/i,/^(?:c\b)/i,/^(?:x\b)/i,/^(?:y\b)/i,/^(?:z\b)/i,/^(?:as\b)/i,/^(?:of\b)/i,/^(?:pdb\b)/i,/^(?:delay\b)/i,/^(?:prst\b)/i,/^(?:desc\b)/i,/^(?:((?:"([^"]*)"|'([^']*)')))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:\.)/i,/^(?:\/)/i,/^(?:\\)/i,/^(?:-e\b)/i,/^(?:-f\b)/i,/^(?:-s\b)/i,/^(?:-v\b)/i,/^(?:=)/i], +conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80],"inclusive":true}} }); return lexer; })(); diff --git a/dist/Miew.min.js b/dist/Miew.min.js index 576d7d37..da507fba 100644 --- a/dist/Miew.min.js +++ b/dist/Miew.min.js @@ -1,4 +1,4 @@ -/** Miew - 3D Molecular Viewer v0.7.11 Copyright (c) 2015-2018 EPAM Systems, Inc. */ +/** Miew - 3D Molecular Viewer v0.7.12 Copyright (c) 2015-2018 EPAM Systems, Inc. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Miew=e()}(this,function(){"use strict";var t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function r(t,e){return t(e={exports:{}},e.exports),e.exports}var n=r(function(e,r){ /** * @license @@ -8,42 +8,11 @@ * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ -(function(){var n,i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",s="__lodash_hash_undefined__",l=500,c="__lodash_placeholder__",u=1,h=2,p=4,f=1,d=2,m=1,g=2,v=4,y=8,_=16,x=32,b=64,w=128,S=256,M=512,A=30,E="...",C=800,T=16,P=1,L=2,R=1/0,N=9007199254740991,I=1.7976931348623157e308,O=NaN,D=4294967295,F=D-1,z=D>>>1,k=[["ary",w],["bind",m],["bindKey",g],["curry",y],["curryRight",_],["flip",M],["partial",x],["partialRight",b],["rearg",S]],U="[object Arguments]",B="[object Array]",V="[object AsyncFunction]",j="[object Boolean]",G="[object Date]",W="[object DOMException]",H="[object Error]",X="[object Function]",Y="[object GeneratorFunction]",q="[object Map]",Z="[object Number]",$="[object Null]",K="[object Object]",Q="[object Promise]",J="[object Proxy]",tt="[object RegExp]",et="[object Set]",rt="[object String]",nt="[object Symbol]",it="[object Undefined]",ot="[object WeakMap]",at="[object WeakSet]",st="[object ArrayBuffer]",lt="[object DataView]",ct="[object Float32Array]",ut="[object Float64Array]",ht="[object Int8Array]",pt="[object Int16Array]",ft="[object Int32Array]",dt="[object Uint8Array]",mt="[object Uint8ClampedArray]",gt="[object Uint16Array]",vt="[object Uint32Array]",yt=/\b__p \+= '';/g,_t=/\b(__p \+=) '' \+/g,xt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,bt=/&(?:amp|lt|gt|quot|#39);/g,wt=/[&<>"']/g,St=RegExp(bt.source),Mt=RegExp(wt.source),At=/<%-([\s\S]+?)%>/g,Et=/<%([\s\S]+?)%>/g,Ct=/<%=([\s\S]+?)%>/g,Tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pt=/^\w*$/,Lt=/^\./,Rt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Nt=/[\\^$.*+?()[\]{}|]/g,It=RegExp(Nt.source),Ot=/^\s+|\s+$/g,Dt=/^\s+/,Ft=/\s+$/,zt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,kt=/\{\n\/\* \[wrapped with (.+)\] \*/,Ut=/,? & /,Bt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Vt=/\\(\\)?/g,jt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Gt=/\w*$/,Wt=/^[-+]0x[0-9a-f]+$/i,Ht=/^0b[01]+$/i,Xt=/^\[object .+?Constructor\]$/,Yt=/^0o[0-7]+$/i,qt=/^(?:0|[1-9]\d*)$/,Zt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,$t=/($^)/,Kt=/['\n\r\u2028\u2029\\]/g,Qt="\\ud800-\\udfff",Jt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",te="\\u2700-\\u27bf",ee="a-z\\xdf-\\xf6\\xf8-\\xff",re="A-Z\\xc0-\\xd6\\xd8-\\xde",ne="\\ufe0e\\ufe0f",ie="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",oe="['’]",ae="["+Qt+"]",se="["+ie+"]",le="["+Jt+"]",ce="\\d+",ue="["+te+"]",he="["+ee+"]",pe="[^"+Qt+ie+ce+te+ee+re+"]",fe="\\ud83c[\\udffb-\\udfff]",de="[^"+Qt+"]",me="(?:\\ud83c[\\udde6-\\uddff]){2}",ge="[\\ud800-\\udbff][\\udc00-\\udfff]",ve="["+re+"]",ye="\\u200d",_e="(?:"+he+"|"+pe+")",xe="(?:"+ve+"|"+pe+")",be="(?:['’](?:d|ll|m|re|s|t|ve))?",we="(?:['’](?:D|LL|M|RE|S|T|VE))?",Se="(?:"+le+"|"+fe+")"+"?",Me="["+ne+"]?",Ae=Me+Se+("(?:"+ye+"(?:"+[de,me,ge].join("|")+")"+Me+Se+")*"),Ee="(?:"+[ue,me,ge].join("|")+")"+Ae,Ce="(?:"+[de+le+"?",le,me,ge,ae].join("|")+")",Te=RegExp(oe,"g"),Pe=RegExp(le,"g"),Le=RegExp(fe+"(?="+fe+")|"+Ce+Ae,"g"),Re=RegExp([ve+"?"+he+"+"+be+"(?="+[se,ve,"$"].join("|")+")",xe+"+"+we+"(?="+[se,ve+_e,"$"].join("|")+")",ve+"?"+_e+"+"+be,ve+"+"+we,"\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)","\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)",ce,Ee].join("|"),"g"),Ne=RegExp("["+ye+Qt+Jt+ne+"]"),Ie=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Oe=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],De=-1,Fe={};Fe[ct]=Fe[ut]=Fe[ht]=Fe[pt]=Fe[ft]=Fe[dt]=Fe[mt]=Fe[gt]=Fe[vt]=!0,Fe[U]=Fe[B]=Fe[st]=Fe[j]=Fe[lt]=Fe[G]=Fe[H]=Fe[X]=Fe[q]=Fe[Z]=Fe[K]=Fe[tt]=Fe[et]=Fe[rt]=Fe[ot]=!1;var ze={};ze[U]=ze[B]=ze[st]=ze[lt]=ze[j]=ze[G]=ze[ct]=ze[ut]=ze[ht]=ze[pt]=ze[ft]=ze[q]=ze[Z]=ze[K]=ze[tt]=ze[et]=ze[rt]=ze[nt]=ze[dt]=ze[mt]=ze[gt]=ze[vt]=!0,ze[H]=ze[X]=ze[ot]=!1;var ke={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ue=parseFloat,Be=parseInt,Ve="object"==typeof t&&t&&t.Object===Object&&t,je="object"==typeof self&&self&&self.Object===Object&&self,Ge=Ve||je||Function("return this")(),We=r&&!r.nodeType&&r,He=We&&e&&!e.nodeType&&e,Xe=He&&He.exports===We,Ye=Xe&&Ve.process,qe=function(){try{return Ye&&Ye.binding&&Ye.binding("util")}catch(t){}}(),Ze=qe&&qe.isArrayBuffer,$e=qe&&qe.isDate,Ke=qe&&qe.isMap,Qe=qe&&qe.isRegExp,Je=qe&&qe.isSet,tr=qe&&qe.isTypedArray;function er(t,e){return t.set(e[0],e[1]),t}function rr(t,e){return t.add(e),t}function nr(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function ir(t,e,r,n){for(var i=-1,o=null==t?0:t.length;++i-1}function ur(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function Nr(t,e){for(var r=t.length;r--&&_r(e,t[r],0)>-1;);return r}var Ir=Mr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Or=Mr({"&":"&","<":"<",">":">",'"':""","'":"'"});function Dr(t){return"\\"+ke[t]}function Fr(t){return Ne.test(t)}function zr(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function kr(t,e){return function(r){return t(e(r))}}function Ur(t,e){for(var r=-1,n=t.length,i=0,o=[];++r",""":'"',"'":"'"});var Wr=function t(e){var r,Qt=(e=null==e?Ge:Wr.defaults(Ge.Object(),e,Wr.pick(Ge,Oe))).Array,Jt=e.Date,te=e.Error,ee=e.Function,re=e.Math,ne=e.Object,ie=e.RegExp,oe=e.String,ae=e.TypeError,se=Qt.prototype,le=ee.prototype,ce=ne.prototype,ue=e["__core-js_shared__"],he=le.toString,pe=ce.hasOwnProperty,fe=0,de=(r=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",me=ce.toString,ge=he.call(ne),ve=Ge._,ye=ie("^"+he.call(pe).replace(Nt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),_e=Xe?e.Buffer:n,xe=e.Symbol,be=e.Uint8Array,we=_e?_e.allocUnsafe:n,Se=kr(ne.getPrototypeOf,ne),Me=ne.create,Ae=ce.propertyIsEnumerable,Ee=se.splice,Ce=xe?xe.isConcatSpreadable:n,Le=xe?xe.iterator:n,Ne=xe?xe.toStringTag:n,ke=function(){try{var t=jo(ne,"defineProperty");return t({},"",{}),t}catch(t){}}(),Ve=e.clearTimeout!==Ge.clearTimeout&&e.clearTimeout,je=Jt&&Jt.now!==Ge.Date.now&&Jt.now,We=e.setTimeout!==Ge.setTimeout&&e.setTimeout,He=re.ceil,Ye=re.floor,qe=ne.getOwnPropertySymbols,gr=_e?_e.isBuffer:n,Mr=e.isFinite,Hr=se.join,Xr=kr(ne.keys,ne),Yr=re.max,qr=re.min,Zr=Jt.now,$r=e.parseInt,Kr=re.random,Qr=se.reverse,Jr=jo(e,"DataView"),tn=jo(e,"Map"),en=jo(e,"Promise"),rn=jo(e,"Set"),nn=jo(e,"WeakMap"),on=jo(ne,"create"),an=nn&&new nn,sn={},ln=ma(Jr),cn=ma(tn),un=ma(en),hn=ma(rn),pn=ma(nn),fn=xe?xe.prototype:n,dn=fn?fn.valueOf:n,mn=fn?fn.toString:n;function gn(t){if(Ns(t)&&!bs(t)&&!(t instanceof xn)){if(t instanceof _n)return t;if(pe.call(t,"__wrapped__"))return ga(t)}return new _n(t)}var vn=function(){function t(){}return function(e){if(!Rs(e))return{};if(Me)return Me(e);t.prototype=e;var r=new t;return t.prototype=n,r}}();function yn(){}function _n(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=n}function xn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=D,this.__views__=[]}function bn(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function kn(t,e,r,i,o,a){var s,l=e&u,c=e&h,f=e&p;if(r&&(s=o?r(t,i,o,a):r(t)),s!==n)return s;if(!Rs(t))return t;var d,m,g,v,y,_,x,b,w,S=bs(t);if(S){if(x=t,b=x.length,w=x.constructor(b),b&&"string"==typeof x[0]&&pe.call(x,"index")&&(w.index=x.index,w.input=x.input),s=w,!l)return oo(t,s)}else{var M=Ho(t),A=M==X||M==Y;if(As(t))return Ji(t,l);if(M==K||M==U||A&&!o){if(s=c||A?{}:Yo(t),!l)return c?(g=t,_=t,v=(y=s)&&ao(_,cl(_),y),ao(g,Wo(g),v)):(d=t,m=On(s,t),ao(d,Go(d),m))}else{if(!ze[M])return o?t:{};s=function(t,e,r,n){var i,o,a,s,l,c,h,p=t.constructor;switch(e){case st:return to(t);case j:case G:return new p(+t);case lt:return c=t,h=n?to(c.buffer):c.buffer,new c.constructor(h,c.byteOffset,c.byteLength);case ct:case ut:case ht:case pt:case ft:case dt:case mt:case gt:case vt:return eo(t,n);case q:return l=t,fr(n?r(zr(l),u):zr(l),er,new l.constructor);case Z:case rt:return new p(t);case tt:return(s=new(a=t).constructor(a.source,Gt.exec(a))).lastIndex=a.lastIndex,s;case et:return o=t,fr(n?r(Br(o),u):Br(o),rr,new o.constructor);case nt:return i=t,dn?ne(dn.call(i)):{}}}(t,M,kn,l)}}a||(a=new An);var E=a.get(t);if(E)return E;a.set(t,s);var C=S?n:(f?c?Do:Oo:c?cl:ll)(t);return or(C||t,function(n,i){C&&(n=t[i=n]),Rn(s,i,kn(n,e,r,i,t,a))}),s}function Un(t,e,r){var i=r.length;if(null==t)return!i;for(t=ne(t);i--;){var o=r[i],a=e[o],s=t[o];if(s===n&&!(o in t)||!a(s))return!1}return!0}function Bn(t,e,r){if("function"!=typeof t)throw new ae(a);return aa(function(){t.apply(n,r)},e)}function Vn(t,e,r,n){var o=-1,a=cr,s=!0,l=t.length,c=[],u=e.length;if(!l)return c;r&&(e=hr(e,Tr(r))),n?(a=ur,s=!1):e.length>=i&&(a=Lr,s=!1,e=new Mn(e));t:for(;++o-1},wn.prototype.set=function(t,e){var r=this.__data__,n=Nn(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},Sn.prototype.clear=function(){this.size=0,this.__data__={hash:new bn,map:new(tn||wn),string:new bn}},Sn.prototype.delete=function(t){var e=Bo(this,t).delete(t);return this.size-=e?1:0,e},Sn.prototype.get=function(t){return Bo(this,t).get(t)},Sn.prototype.has=function(t){return Bo(this,t).has(t)},Sn.prototype.set=function(t,e){var r=Bo(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},Mn.prototype.add=Mn.prototype.push=function(t){return this.__data__.set(t,s),this},Mn.prototype.has=function(t){return this.__data__.has(t)},An.prototype.clear=function(){this.__data__=new wn,this.size=0},An.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},An.prototype.get=function(t){return this.__data__.get(t)},An.prototype.has=function(t){return this.__data__.has(t)},An.prototype.set=function(t,e){var r=this.__data__;if(r instanceof wn){var n=r.__data__;if(!tn||n.length0&&r(s)?e>1?Yn(s,e-1,r,n,i):pr(i,s):n||(i[i.length]=s)}return i}var qn=uo(),Zn=uo(!0);function $n(t,e){return t&&qn(t,e,ll)}function Kn(t,e){return t&&Zn(t,e,ll)}function Qn(t,e){return lr(e,function(e){return Ts(t[e])})}function Jn(t,e){for(var r=0,i=(e=Zi(e,t)).length;null!=t&&re}function ni(t,e){return null!=t&&pe.call(t,e)}function ii(t,e){return null!=t&&e in ne(t)}function oi(t,e,r){for(var i=r?ur:cr,o=t[0].length,a=t.length,s=a,l=Qt(a),c=1/0,u=[];s--;){var h=t[s];s&&e&&(h=hr(h,Tr(e))),c=qr(h.length,c),l[s]=!r&&(e||o>=120&&h.length>=120)?new Mn(s&&h):n}h=t[0];var p=-1,f=l[0];t:for(;++p=s)return l;var c=r[n];return l*("desc"==c?-1:1)}}return t.index-e.index}(t,e,r)})}function bi(t,e,r){for(var n=-1,i=e.length,o={};++n-1;)s!==t&&Ee.call(s,l,1),Ee.call(t,l,1);return t}function Si(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==o){var o=i;Zo(i)?Ee.call(t,i,1):Vi(t,i)}}return t}function Mi(t,e){return t+Ye(Kr()*(e-t+1))}function Ai(t,e){var r="";if(!t||e<1||e>N)return r;do{e%2&&(r+=t),(e=Ye(e/2))&&(t+=t)}while(e);return r}function Ei(t,e){return sa(na(t,e,Ol),t+"")}function Ci(t){return Cn(vl(t))}function Ti(t,e){var r=vl(t);return ua(r,zn(e,0,r.length))}function Pi(t,e,r,i){if(!Rs(t))return t;for(var o=-1,a=(e=Zi(e,t)).length,s=a-1,l=t;null!=l&&++oi?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Qt(i);++n>>1,a=t[o];null!==a&&!Us(a)&&(r?a<=e:a=i){var u=e?null:Eo(t);if(u)return Br(u);s=!1,o=Lr,c=new Mn}else c=e?[]:l;t:for(;++n=i?t:Ii(t,e,r)}var Qi=Ve||function(t){return Ge.clearTimeout(t)};function Ji(t,e){if(e)return t.slice();var r=t.length,n=we?we(r):new t.constructor(r);return t.copy(n),n}function to(t){var e=new t.constructor(t.byteLength);return new be(e).set(new be(t)),e}function eo(t,e){var r=e?to(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function ro(t,e){if(t!==e){var r=t!==n,i=null===t,o=t==t,a=Us(t),s=e!==n,l=null===e,c=e==e,u=Us(e);if(!l&&!u&&!a&&t>e||a&&s&&c&&!l&&!u||i&&s&&c||!r&&c||!o)return 1;if(!i&&!a&&!u&&t1?r[o-1]:n,s=o>2?r[2]:n;for(a=t.length>3&&"function"==typeof a?(o--,a):n,s&&$o(r[0],r[1],s)&&(a=o<3?n:a,o=1),e=ne(e);++i-1?o[a?e[s]:s]:n}}function go(t){return Io(function(e){var r=e.length,i=r,o=_n.prototype.thru;for(t&&e.reverse();i--;){var s=e[i];if("function"!=typeof s)throw new ae(a);if(o&&!l&&"wrapper"==zo(s))var l=new _n([],!0)}for(i=l?i:r;++i1&&y.reverse(),h&&cl))return!1;var u=a.get(t);if(u&&a.get(e))return u==e;var h=-1,p=!0,m=r&d?new Mn:n;for(a.set(t,e),a.set(e,t);++h-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(zt,"{\n/* [wrapped with "+e+"] */\n")}(a,(o=a.match(kt),n=o?o[1].split(Ut):[],i=r,or(k,function(t){var e="_."+t[0];i&t[1]&&!cr(n,e)&&n.push(e)}),n.sort())))}function ca(t){var e=0,r=0;return function(){var i=Zr(),o=T-(i-r);if(r=i,o>0){if(++e>=C)return arguments[0]}else e=0;return t.apply(n,arguments)}}function ua(t,e){var r=-1,i=t.length,o=i-1;for(e=e===n?i:e;++r1?t[e-1]:n;return Fa(t,r="function"==typeof r?(t.pop(),r):n)});function Ga(t){var e=gn(t);return e.__chain__=!0,e}function Wa(t,e){return e(t)}var Ha=Io(function(t){var e=t.length,r=e?t[0]:0,i=this.__wrapped__,o=function(e){return Fn(e,t)};return!(e>1||this.__actions__.length)&&i instanceof xn&&Zo(r)?((i=i.slice(r,+r+(e?1:0))).__actions__.push({func:Wa,args:[o],thisArg:n}),new _n(i,this.__chain__).thru(function(t){return e&&!t.length&&t.push(n),t})):this.thru(o)});var Xa=so(function(t,e,r){pe.call(t,r)?++t[r]:Dn(t,r,1)});var Ya=mo(xa),qa=mo(ba);function Za(t,e){return(bs(t)?or:jn)(t,Uo(e,3))}function $a(t,e){return(bs(t)?ar:Gn)(t,Uo(e,3))}var Ka=so(function(t,e,r){pe.call(t,r)?t[r].push(e):Dn(t,r,[e])});var Qa=Ei(function(t,e,r){var n=-1,i="function"==typeof e,o=Ss(t)?Qt(t.length):[];return jn(t,function(t){o[++n]=i?nr(e,t,r):ai(t,e,r)}),o}),Ja=so(function(t,e,r){Dn(t,r,e)});function ts(t,e){return(bs(t)?hr:mi)(t,Uo(e,3))}var es=so(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]});var rs=Ei(function(t,e){if(null==t)return[];var r=e.length;return r>1&&$o(t,e[0],e[1])?e=[]:r>2&&$o(e[0],e[1],e[2])&&(e=[e[0]]),xi(t,Yn(e,1),[])}),ns=je||function(){return Ge.Date.now()};function is(t,e,r){return e=r?n:e,e=t&&null==e?t.length:e,To(t,w,n,n,n,n,e)}function os(t,e){var r;if("function"!=typeof e)throw new ae(a);return t=Hs(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=n),r}}var as=Ei(function(t,e,r){var n=m;if(r.length){var i=Ur(r,ko(as));n|=x}return To(t,n,e,r,i)}),ss=Ei(function(t,e,r){var n=m|g;if(r.length){var i=Ur(r,ko(ss));n|=x}return To(e,n,t,r,i)});function ls(t,e,r){var i,o,s,l,c,u,h=0,p=!1,f=!1,d=!0;if("function"!=typeof t)throw new ae(a);function m(e){var r=i,a=o;return i=o=n,h=e,l=t.apply(a,r)}function g(t){var r=t-u;return u===n||r>=e||r<0||f&&t-h>=s}function v(){var t,r,n=ns();if(g(n))return y(n);c=aa(v,(r=e-((t=n)-u),f?qr(r,s-(t-h)):r))}function y(t){return c=n,d&&i?m(t):(i=o=n,l)}function _(){var t,r=ns(),a=g(r);if(i=arguments,o=this,u=r,a){if(c===n)return h=t=u,c=aa(v,e),p?m(t):l;if(f)return c=aa(v,e),m(u)}return c===n&&(c=aa(v,e)),l}return e=Ys(e)||0,Rs(r)&&(p=!!r.leading,s=(f="maxWait"in r)?Yr(Ys(r.maxWait)||0,e):s,d="trailing"in r?!!r.trailing:d),_.cancel=function(){c!==n&&Qi(c),h=0,i=u=o=c=n},_.flush=function(){return c===n?l:y(ns())},_}var cs=Ei(function(t,e){return Bn(t,1,e)}),us=Ei(function(t,e,r){return Bn(t,Ys(e)||0,r)});function hs(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ae(a);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var a=t.apply(this,n);return r.cache=o.set(i,a)||o,a};return r.cache=new(hs.Cache||Sn),r}function ps(t){if("function"!=typeof t)throw new ae(a);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}hs.Cache=Sn;var fs=$i(function(t,e){var r=(e=1==e.length&&bs(e[0])?hr(e[0],Tr(Uo())):hr(Yn(e,1),Tr(Uo()))).length;return Ei(function(n){for(var i=-1,o=qr(n.length,r);++i=e}),xs=si(function(){return arguments}())?si:function(t){return Ns(t)&&pe.call(t,"callee")&&!Ae.call(t,"callee")},bs=Qt.isArray,ws=Ze?Tr(Ze):function(t){return Ns(t)&&ei(t)==st};function Ss(t){return null!=t&&Ls(t.length)&&!Ts(t)}function Ms(t){return Ns(t)&&Ss(t)}var As=gr||Yl,Es=$e?Tr($e):function(t){return Ns(t)&&ei(t)==G};function Cs(t){if(!Ns(t))return!1;var e=ei(t);return e==H||e==W||"string"==typeof t.message&&"string"==typeof t.name&&!Ds(t)}function Ts(t){if(!Rs(t))return!1;var e=ei(t);return e==X||e==Y||e==V||e==J}function Ps(t){return"number"==typeof t&&t==Hs(t)}function Ls(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=N}function Rs(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ns(t){return null!=t&&"object"==typeof t}var Is=Ke?Tr(Ke):function(t){return Ns(t)&&Ho(t)==q};function Os(t){return"number"==typeof t||Ns(t)&&ei(t)==Z}function Ds(t){if(!Ns(t)||ei(t)!=K)return!1;var e=Se(t);if(null===e)return!0;var r=pe.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&he.call(r)==ge}var Fs=Qe?Tr(Qe):function(t){return Ns(t)&&ei(t)==tt};var zs=Je?Tr(Je):function(t){return Ns(t)&&Ho(t)==et};function ks(t){return"string"==typeof t||!bs(t)&&Ns(t)&&ei(t)==rt}function Us(t){return"symbol"==typeof t||Ns(t)&&ei(t)==nt}var Bs=tr?Tr(tr):function(t){return Ns(t)&&Ls(t.length)&&!!Fe[ei(t)]};var Vs=So(di),js=So(function(t,e){return t<=e});function Gs(t){if(!t)return[];if(Ss(t))return ks(t)?jr(t):oo(t);if(Le&&t[Le])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[Le]());var e=Ho(t);return(e==q?zr:e==et?Br:vl)(t)}function Ws(t){return t?(t=Ys(t))===R||t===-R?(t<0?-1:1)*I:t==t?t:0:0===t?t:0}function Hs(t){var e=Ws(t),r=e%1;return e==e?r?e-r:e:0}function Xs(t){return t?zn(Hs(t),0,D):0}function Ys(t){if("number"==typeof t)return t;if(Us(t))return O;if(Rs(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Rs(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Ot,"");var r=Ht.test(t);return r||Yt.test(t)?Be(t.slice(2),r?2:8):Wt.test(t)?O:+t}function qs(t){return ao(t,cl(t))}function Zs(t){return null==t?"":Ui(t)}var $s=lo(function(t,e){if(ta(e)||Ss(e))ao(e,ll(e),t);else for(var r in e)pe.call(e,r)&&Rn(t,r,e[r])}),Ks=lo(function(t,e){ao(e,cl(e),t)}),Qs=lo(function(t,e,r,n){ao(e,cl(e),t,n)}),Js=lo(function(t,e,r,n){ao(e,ll(e),t,n)}),tl=Io(Fn);var el=Ei(function(t){return t.push(n,Po),nr(Qs,n,t)}),rl=Ei(function(t){return t.push(n,Lo),nr(hl,n,t)});function nl(t,e,r){var i=null==t?n:Jn(t,e);return i===n?r:i}function il(t,e){return null!=t&&Xo(t,e,ii)}var ol=yo(function(t,e,r){t[e]=r},Rl(Ol)),al=yo(function(t,e,r){pe.call(t,e)?t[e].push(r):t[e]=[r]},Uo),sl=Ei(ai);function ll(t){return Ss(t)?En(t):pi(t)}function cl(t){return Ss(t)?En(t,!0):fi(t)}var ul=lo(function(t,e,r){yi(t,e,r)}),hl=lo(function(t,e,r,n){yi(t,e,r,n)}),pl=Io(function(t,e){var r={};if(null==t)return r;var n=!1;e=hr(e,function(e){return e=Zi(e,t),n||(n=e.length>1),e}),ao(t,Do(t),r),n&&(r=kn(r,u|h|p,Ro));for(var i=e.length;i--;)Vi(r,e[i]);return r});var fl=Io(function(t,e){return null==t?{}:bi(r=t,e,function(t,e){return il(r,e)});var r});function dl(t,e){if(null==t)return{};var r=hr(Do(t),function(t){return[t]});return e=Uo(e),bi(t,r,function(t,r){return e(t,r[0])})}var ml=Co(ll),gl=Co(cl);function vl(t){return null==t?[]:Pr(t,ll(t))}var yl=po(function(t,e,r){return e=e.toLowerCase(),t+(r?_l(e):e)});function _l(t){return Cl(Zs(t).toLowerCase())}function xl(t){return(t=Zs(t))&&t.replace(Zt,Ir).replace(Pe,"")}var bl=po(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),wl=po(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),Sl=ho("toLowerCase");var Ml=po(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()});var Al=po(function(t,e,r){return t+(r?" ":"")+Cl(e)});var El=po(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),Cl=ho("toUpperCase");function Tl(t,e,r){return t=Zs(t),(e=r?n:e)===n?(i=t,Ie.test(i)?t.match(Re)||[]:t.match(Bt)||[]):t.match(e)||[];var i}var Pl=Ei(function(t,e){try{return nr(t,n,e)}catch(t){return Cs(t)?t:new te(t)}}),Ll=Io(function(t,e){return or(e,function(e){e=da(e),Dn(t,e,as(t[e],t))}),t});function Rl(t){return function(){return t}}var Nl=go(),Il=go(!0);function Ol(t){return t}function Dl(t){return hi("function"==typeof t?t:kn(t,u))}var Fl=Ei(function(t,e){return function(r){return ai(r,t,e)}}),zl=Ei(function(t,e){return function(r){return ai(t,r,e)}});function kl(t,e,r){var n=ll(e),i=Qn(e,n);null!=r||Rs(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Qn(e,ll(e)));var o=!(Rs(r)&&"chain"in r&&!r.chain),a=Ts(t);return or(i,function(r){var n=e[r];t[r]=n,a&&(t.prototype[r]=function(){var e=this.__chain__;if(o||e){var r=t(this.__wrapped__);return(r.__actions__=oo(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,pr([this.value()],arguments))})}),t}function Ul(){}var Bl=xo(hr),Vl=xo(sr),jl=xo(mr);function Gl(t){return Ko(t)?Sr(da(t)):(e=t,function(t){return Jn(t,e)});var e}var Wl=wo(),Hl=wo(!0);function Xl(){return[]}function Yl(){return!1}var ql=_o(function(t,e){return t+e},0),Zl=Ao("ceil"),$l=_o(function(t,e){return t/e},1),Kl=Ao("floor");var Ql,Jl=_o(function(t,e){return t*e},1),tc=Ao("round"),ec=_o(function(t,e){return t-e},0);return gn.after=function(t,e){if("function"!=typeof e)throw new ae(a);return t=Hs(t),function(){if(--t<1)return e.apply(this,arguments)}},gn.ary=is,gn.assign=$s,gn.assignIn=Ks,gn.assignInWith=Qs,gn.assignWith=Js,gn.at=tl,gn.before=os,gn.bind=as,gn.bindAll=Ll,gn.bindKey=ss,gn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return bs(t)?t:[t]},gn.chain=Ga,gn.chunk=function(t,e,r){e=(r?$o(t,e,r):e===n)?1:Yr(Hs(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var o=0,a=0,s=Qt(He(i/e));oo?0:o+r),(i=i===n||i>o?o:Hs(i))<0&&(i+=o),i=r>i?0:Xs(i);r>>0)?(t=Zs(t))&&("string"==typeof e||null!=e&&!Fs(e))&&!(e=Ui(e))&&Fr(t)?Ki(jr(t),0,r):t.split(e,r):[]},gn.spread=function(t,e){if("function"!=typeof t)throw new ae(a);return e=null==e?0:Yr(Hs(e),0),Ei(function(r){var n=r[e],i=Ki(r,0,e);return n&&pr(i,n),nr(t,this,i)})},gn.tail=function(t){var e=null==t?0:t.length;return e?Ii(t,1,e):[]},gn.take=function(t,e,r){return t&&t.length?Ii(t,0,(e=r||e===n?1:Hs(e))<0?0:e):[]},gn.takeRight=function(t,e,r){var i=null==t?0:t.length;return i?Ii(t,(e=i-(e=r||e===n?1:Hs(e)))<0?0:e,i):[]},gn.takeRightWhile=function(t,e){return t&&t.length?Gi(t,Uo(e,3),!1,!0):[]},gn.takeWhile=function(t,e){return t&&t.length?Gi(t,Uo(e,3)):[]},gn.tap=function(t,e){return e(t),t},gn.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ae(a);return Rs(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),ls(t,e,{leading:n,maxWait:e,trailing:i})},gn.thru=Wa,gn.toArray=Gs,gn.toPairs=ml,gn.toPairsIn=gl,gn.toPath=function(t){return bs(t)?hr(t,da):Us(t)?[t]:oo(fa(Zs(t)))},gn.toPlainObject=qs,gn.transform=function(t,e,r){var n=bs(t),i=n||As(t)||Bs(t);if(e=Uo(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:Rs(t)&&Ts(o)?vn(Se(t)):{}}return(i?or:$n)(t,function(t,n,i){return e(r,t,n,i)}),r},gn.unary=function(t){return is(t,1)},gn.union=Na,gn.unionBy=Ia,gn.unionWith=Oa,gn.uniq=function(t){return t&&t.length?Bi(t):[]},gn.uniqBy=function(t,e){return t&&t.length?Bi(t,Uo(e,2)):[]},gn.uniqWith=function(t,e){return e="function"==typeof e?e:n,t&&t.length?Bi(t,n,e):[]},gn.unset=function(t,e){return null==t||Vi(t,e)},gn.unzip=Da,gn.unzipWith=Fa,gn.update=function(t,e,r){return null==t?t:ji(t,e,qi(r))},gn.updateWith=function(t,e,r,i){return i="function"==typeof i?i:n,null==t?t:ji(t,e,qi(r),i)},gn.values=vl,gn.valuesIn=function(t){return null==t?[]:Pr(t,cl(t))},gn.without=za,gn.words=Tl,gn.wrap=function(t,e){return ds(qi(e),t)},gn.xor=ka,gn.xorBy=Ua,gn.xorWith=Ba,gn.zip=Va,gn.zipObject=function(t,e){return Xi(t||[],e||[],Rn)},gn.zipObjectDeep=function(t,e){return Xi(t||[],e||[],Pi)},gn.zipWith=ja,gn.entries=ml,gn.entriesIn=gl,gn.extend=Ks,gn.extendWith=Qs,kl(gn,gn),gn.add=ql,gn.attempt=Pl,gn.camelCase=yl,gn.capitalize=_l,gn.ceil=Zl,gn.clamp=function(t,e,r){return r===n&&(r=e,e=n),r!==n&&(r=(r=Ys(r))==r?r:0),e!==n&&(e=(e=Ys(e))==e?e:0),zn(Ys(t),e,r)},gn.clone=function(t){return kn(t,p)},gn.cloneDeep=function(t){return kn(t,u|p)},gn.cloneDeepWith=function(t,e){return kn(t,u|p,e="function"==typeof e?e:n)},gn.cloneWith=function(t,e){return kn(t,p,e="function"==typeof e?e:n)},gn.conformsTo=function(t,e){return null==e||Un(t,e,ll(e))},gn.deburr=xl,gn.defaultTo=function(t,e){return null==t||t!=t?e:t},gn.divide=$l,gn.endsWith=function(t,e,r){t=Zs(t),e=Ui(e);var i=t.length,o=r=r===n?i:zn(Hs(r),0,i);return(r-=e.length)>=0&&t.slice(r,o)==e},gn.eq=vs,gn.escape=function(t){return(t=Zs(t))&&Mt.test(t)?t.replace(wt,Or):t},gn.escapeRegExp=function(t){return(t=Zs(t))&&It.test(t)?t.replace(Nt,"\\$&"):t},gn.every=function(t,e,r){var i=bs(t)?sr:Wn;return r&&$o(t,e,r)&&(e=n),i(t,Uo(e,3))},gn.find=Ya,gn.findIndex=xa,gn.findKey=function(t,e){return vr(t,Uo(e,3),$n)},gn.findLast=qa,gn.findLastIndex=ba,gn.findLastKey=function(t,e){return vr(t,Uo(e,3),Kn)},gn.floor=Kl,gn.forEach=Za,gn.forEachRight=$a,gn.forIn=function(t,e){return null==t?t:qn(t,Uo(e,3),cl)},gn.forInRight=function(t,e){return null==t?t:Zn(t,Uo(e,3),cl)},gn.forOwn=function(t,e){return t&&$n(t,Uo(e,3))},gn.forOwnRight=function(t,e){return t&&Kn(t,Uo(e,3))},gn.get=nl,gn.gt=ys,gn.gte=_s,gn.has=function(t,e){return null!=t&&Xo(t,e,ni)},gn.hasIn=il,gn.head=Sa,gn.identity=Ol,gn.includes=function(t,e,r,n){t=Ss(t)?t:vl(t),r=r&&!n?Hs(r):0;var i=t.length;return r<0&&(r=Yr(i+r,0)),ks(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&_r(t,e,r)>-1},gn.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:Hs(r);return i<0&&(i=Yr(n+i,0)),_r(t,e,i)},gn.inRange=function(t,e,r){return e=Ws(e),r===n?(r=e,e=0):r=Ws(r),t=Ys(t),(i=t)>=qr(o=e,a=r)&&i=-N&&t<=N},gn.isSet=zs,gn.isString=ks,gn.isSymbol=Us,gn.isTypedArray=Bs,gn.isUndefined=function(t){return t===n},gn.isWeakMap=function(t){return Ns(t)&&Ho(t)==ot},gn.isWeakSet=function(t){return Ns(t)&&ei(t)==at},gn.join=function(t,e){return null==t?"":Hr.call(t,e)},gn.kebabCase=bl,gn.last=Ca,gn.lastIndexOf=function(t,e,r){var i=null==t?0:t.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=Hs(r))<0?Yr(i+o,0):qr(o,i-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,o):yr(t,br,o,!0)},gn.lowerCase=wl,gn.lowerFirst=Sl,gn.lt=Vs,gn.lte=js,gn.max=function(t){return t&&t.length?Hn(t,Ol,ri):n},gn.maxBy=function(t,e){return t&&t.length?Hn(t,Uo(e,2),ri):n},gn.mean=function(t){return wr(t,Ol)},gn.meanBy=function(t,e){return wr(t,Uo(e,2))},gn.min=function(t){return t&&t.length?Hn(t,Ol,di):n},gn.minBy=function(t,e){return t&&t.length?Hn(t,Uo(e,2),di):n},gn.stubArray=Xl,gn.stubFalse=Yl,gn.stubObject=function(){return{}},gn.stubString=function(){return""},gn.stubTrue=function(){return!0},gn.multiply=Jl,gn.nth=function(t,e){return t&&t.length?_i(t,Hs(e)):n},gn.noConflict=function(){return Ge._===this&&(Ge._=ve),this},gn.noop=Ul,gn.now=ns,gn.pad=function(t,e,r){t=Zs(t);var n=(e=Hs(e))?Vr(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return bo(Ye(i),r)+t+bo(He(i),r)},gn.padEnd=function(t,e,r){t=Zs(t);var n=(e=Hs(e))?Vr(t):0;return e&&ne){var i=t;t=e,e=i}if(r||t%1||e%1){var o=Kr();return qr(t+o*(e-t+Ue("1e-"+((o+"").length-1))),e)}return Mi(t,e)},gn.reduce=function(t,e,r){var n=bs(t)?fr:Ar,i=arguments.length<3;return n(t,Uo(e,4),r,i,jn)},gn.reduceRight=function(t,e,r){var n=bs(t)?dr:Ar,i=arguments.length<3;return n(t,Uo(e,4),r,i,Gn)},gn.repeat=function(t,e,r){return e=(r?$o(t,e,r):e===n)?1:Hs(e),Ai(Zs(t),e)},gn.replace=function(){var t=arguments,e=Zs(t[0]);return t.length<3?e:e.replace(t[1],t[2])},gn.result=function(t,e,r){var i=-1,o=(e=Zi(e,t)).length;for(o||(o=1,t=n);++iN)return[];var r=D,n=qr(t,D);e=Uo(e),t-=D;for(var i=Cr(n,e);++r=a)return t;var l=r-Vr(i);if(l<1)return i;var c=s?Ki(s,0,l).join(""):t.slice(0,l);if(o===n)return c+i;if(s&&(l+=c.length-l),Fs(o)){if(t.slice(l).search(o)){var u,h=c;for(o.global||(o=ie(o.source,Zs(Gt.exec(o))+"g")),o.lastIndex=0;u=o.exec(h);)var p=u.index;c=c.slice(0,p===n?l:p)}}else if(t.indexOf(Ui(o),l)!=l){var f=c.lastIndexOf(o);f>-1&&(c=c.slice(0,f))}return c+i},gn.unescape=function(t){return(t=Zs(t))&&St.test(t)?t.replace(bt,Gr):t},gn.uniqueId=function(t){var e=++fe;return Zs(t)+e},gn.upperCase=El,gn.upperFirst=Cl,gn.each=Za,gn.eachRight=$a,gn.first=Sa,kl(gn,(Ql={},$n(gn,function(t,e){pe.call(gn.prototype,e)||(Ql[e]=t)}),Ql),{chain:!1}),gn.VERSION="4.17.4",or(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){gn[t].placeholder=gn}),or(["drop","take"],function(t,e){xn.prototype[t]=function(r){r=r===n?1:Yr(Hs(r),0);var i=this.__filtered__&&!e?new xn(this):this.clone();return i.__filtered__?i.__takeCount__=qr(r,i.__takeCount__):i.__views__.push({size:qr(r,D),type:t+(i.__dir__<0?"Right":"")}),i},xn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),or(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==P||3==r;xn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Uo(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),or(["head","last"],function(t,e){var r="take"+(e?"Right":"");xn.prototype[t]=function(){return this[r](1).value()[0]}}),or(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");xn.prototype[t]=function(){return this.__filtered__?new xn(this):this[r](1)}}),xn.prototype.compact=function(){return this.filter(Ol)},xn.prototype.find=function(t){return this.filter(t).head()},xn.prototype.findLast=function(t){return this.reverse().find(t)},xn.prototype.invokeMap=Ei(function(t,e){return"function"==typeof t?new xn(this):this.map(function(r){return ai(r,t,e)})}),xn.prototype.reject=function(t){return this.filter(ps(Uo(t)))},xn.prototype.slice=function(t,e){t=Hs(t);var r=this;return r.__filtered__&&(t>0||e<0)?new xn(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==n&&(r=(e=Hs(e))<0?r.dropRight(-e):r.take(e-t)),r)},xn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},xn.prototype.toArray=function(){return this.take(D)},$n(xn.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),o=gn[i?"take"+("last"==e?"Right":""):e],a=i||/^find/.test(e);o&&(gn.prototype[e]=function(){var e=this.__wrapped__,s=i?[1]:arguments,l=e instanceof xn,c=s[0],u=l||bs(e),h=function(t){var e=o.apply(gn,pr([t],s));return i&&p?e[0]:e};u&&r&&"function"==typeof c&&1!=c.length&&(l=u=!1);var p=this.__chain__,f=!!this.__actions__.length,d=a&&!p,m=l&&!f;if(!a&&u){e=m?e:new xn(this);var g=t.apply(e,s);return g.__actions__.push({func:Wa,args:[h],thisArg:n}),new _n(g,p)}return d&&m?t.apply(this,s):(g=this.thru(h),d?i?g.value()[0]:g.value():g)})}),or(["pop","push","shift","sort","splice","unshift"],function(t){var e=se[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);gn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(bs(i)?i:[],t)}return this[r](function(r){return e.apply(bs(r)?r:[],t)})}}),$n(xn.prototype,function(t,e){var r=gn[e];if(r){var n=r.name+"";(sn[n]||(sn[n]=[])).push({name:e,func:r})}}),sn[vo(n,g).name]=[{name:"wrapper",func:n}],xn.prototype.clone=function(){var t=new xn(this.__wrapped__);return t.__actions__=oo(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=oo(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=oo(this.__views__),t},xn.prototype.reverse=function(){if(this.__filtered__){var t=new xn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},xn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=bs(t),n=e<0,i=r?t.length:0,o=function(t,e,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:t,value:t?n:this.__values__[this.__index__++]}},gn.prototype.plant=function(t){for(var e,r=this;r instanceof yn;){var i=ga(r);i.__index__=0,i.__values__=n,e?o.__wrapped__=i:e=i;var o=i;r=r.__wrapped__}return o.__wrapped__=t,e},gn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof xn){var e=t;return this.__actions__.length&&(e=new xn(this)),(e=e.reverse()).__actions__.push({func:Wa,args:[Ra],thisArg:n}),new _n(e,this.__chain__)}return this.thru(Ra)},gn.prototype.toJSON=gn.prototype.valueOf=gn.prototype.value=function(){return Wi(this.__wrapped__,this.__actions__)},gn.prototype.first=gn.prototype.head,Le&&(gn.prototype[Le]=function(){return this}),gn}();"function"==typeof n&&"object"==typeof n.amd&&n.amd?(Ge._=Wr,n(function(){return Wr})):He?((He.exports=Wr)._=Wr,We._=Wr):Ge._=Wr}).call(t)});function i(){}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}),void 0===Math.sign&&(Math.sign=function(t){return t<0?-1:t>0?1:+t}),void 0===Function.prototype.name&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),r=1;r>=4,s[t]=a[19===t?3&o|8:o]);return s.join("")}),clamp:function(t,e,r){return Math.max(e,Math.min(r,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,r,n,i){return n+(t-e)*(i-n)/(r-e)},lerp:function(t,e,r){return(1-r)*t+r*e},smoothstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*(3-2*t)},smootherstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*ye.DEG2RAD},radToDeg:function(t){return t*ye.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}};function _e(t,e){this.x=t||0,this.y=e||0}Object.defineProperties(_e.prototype,{width:{get:function(){return this.x},set:function(t){this.x=t}},height:{get:function(){return this.y},set:function(t){this.y=t}}}),Object.assign(_e.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:(c=new _e,u=new _e,function(t,e){return c.set(t,t),u.set(e,e),this.clamp(c,u)}),clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.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()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y;return e*e+r*r},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var r=Math.cos(e),n=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*r-o*n+t.x,this.y=i*n+o*r+t.y,this}});var xe,be,we,Se,Me,Ae,Ee,Ce,Te,Pe,Le,Re,Ne,Ie,Oe,De,Fe,ze,ke,Ue=0;function Be(t,e,r,n,i,o,a,s,l,c){Object.defineProperty(this,"id",{value:Ue++}),this.uuid=ye.generateUUID(),this.name="",this.image=void 0!==t?t:Be.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:Be.DEFAULT_MAPPING,this.wrapS=void 0!==r?r:vt,this.wrapT=void 0!==n?n:vt,this.magFilter=void 0!==i?i:wt,this.minFilter=void 0!==o?o:Mt,this.anisotropy=void 0!==l?l:1,this.format=void 0!==a?a:Ut,this.type=void 0!==s?s:At,this.offset=new _e(0,0),this.repeat=new _e(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==c?c:ce,this.version=0,this.onUpdate=null}function Ve(t,e,r,n){this.x=t||0,this.y=e||0,this.z=r||0,this.w=void 0!==n?n:1}function je(t,e,r){this.uuid=ye.generateUUID(),this.width=t,this.height=e,this.scissor=new Ve(0,0,t,e),this.scissorTest=!1,this.viewport=new Ve(0,0,t,e),void 0===(r=r||{}).minFilter&&(r.minFilter=wt),this.texture=new Be(void 0,void 0,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.depthBuffer=void 0===r.depthBuffer||r.depthBuffer,this.stencilBuffer=void 0===r.stencilBuffer||r.stencilBuffer,this.depthTexture=void 0!==r.depthTexture?r.depthTexture:null}function Ge(t,e,r){je.call(this,t,e,r),this.activeCubeFace=0,this.activeMipMapLevel=0}function We(t,e,r,n){this._x=t||0,this._y=e||0,this._z=r||0,this._w=void 0!==n?n:1}function He(t,e,r){this.x=t||0,this.y=e||0,this.z=r||0}function Xe(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length}function Ye(t,e,r,n,i,o,a,s,l,c,u,h){Be.call(this,null,o,a,s,l,c,n,i,u,h),this.image={data:t,width:e,height:r},this.magFilter=void 0!==l?l:_t,this.minFilter=void 0!==c?c:_t,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function qe(t,e,r,n,i,o,a,s,l,c){t=void 0!==t?t:[],e=void 0!==e?e:ct,Be.call(this,t,e,r,n,i,o,a,s,l,c),this.flipY=!1}Be.DEFAULT_IMAGE=void 0,Be.DEFAULT_MAPPING=300,Object.defineProperty(Be.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Be.prototype,i.prototype,{constructor:Be,isTexture:!0,clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){if(void 0!==t.textures[this.uuid])return t.textures[this.uuid];var e={metadata:{version:4.5,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 r=this.image;void 0===r.uuid&&(r.uuid=ye.generateUUID()),void 0===t.images[r.uuid]&&(t.images[r.uuid]={uuid:r.uuid,url:function(t){var e;if(t instanceof HTMLCanvasElement)e=t;else{(e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")).width=t.width,e.height=t.height;var r=e.getContext("2d");t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height)}return e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}(r)}),e.image=r.uuid}return t.textures[this.uuid]=e,e},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300===this.mapping){if(t.multiply(this.repeat),t.add(this.offset),t.x<0||t.x>1)switch(this.wrapS){case gt:t.x=t.x-Math.floor(t.x);break;case vt:t.x=t.x<0?0:1;break;case yt:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case gt:t.y=t.y-Math.floor(t.y);break;case vt:t.y=t.y<0?0:1;break;case yt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}this.flipY&&(t.y=1-t.y)}}}),Object.assign(Ve.prototype,{isVector4:!0,set:function(t,e,r,n){return this.x=t,this.y=e,this.z=r,this.w=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*n+o[12]*i,this.y=o[1]*e+o[5]*r+o[9]*n+o[13]*i,this.z=o[2]*e+o[6]*r+o[10]*n+o[14]*i,this.w=o[3]*e+o[7]*r+o[11]*n+o[15]*i,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,r,n,i,o=t.elements,a=o[0],s=o[4],l=o[8],c=o[1],u=o[5],h=o[9],p=o[2],f=o[6],d=o[10];if(Math.abs(s-c)<.01&&Math.abs(l-p)<.01&&Math.abs(h-f)<.01){if(Math.abs(s+c)<.1&&Math.abs(l+p)<.1&&Math.abs(h+f)<.1&&Math.abs(a+u+d-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(a+1)/2,g=(u+1)/2,v=(d+1)/2,y=(s+c)/4,_=(l+p)/4,x=(h+f)/4;return m>g&&m>v?m<.01?(r=0,n=.707106781,i=.707106781):(n=y/(r=Math.sqrt(m)),i=_/r):g>v?g<.01?(r=.707106781,n=0,i=.707106781):(r=y/(n=Math.sqrt(g)),i=x/n):v<.01?(r=.707106781,n=.707106781,i=0):(r=_/(i=Math.sqrt(v)),n=x/i),this.set(r,n,i,e),this}var b=Math.sqrt((f-h)*(f-h)+(l-p)*(l-p)+(c-s)*(c-s));return Math.abs(b)<.001&&(b=1),this.x=(f-h)/b,this.y=(l-p)/b,this.z=(c-s)/b,this.w=Math.acos((a+u+d-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(t,e){return void 0===xe&&(xe=new Ve,be=new Ve),xe.set(t,t,t,t),be.set(e,e,e,e),this.clamp(xe,be)},clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}}),Object.assign(je.prototype,i.prototype,{isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Ge.prototype=Object.create(je.prototype),Ge.prototype.constructor=Ge,Ge.prototype.isWebGLRenderTargetCube=!0,Object.assign(We,{slerp:function(t,e,r,n){return r.copy(t).slerp(e,n)},slerpFlat:function(t,e,r,n,i,o,a){var s=r[n+0],l=r[n+1],c=r[n+2],u=r[n+3],h=i[o+0],p=i[o+1],f=i[o+2],d=i[o+3];if(u!==d||s!==h||l!==p||c!==f){var m=1-a,g=s*h+l*p+c*f+u*d,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var _=Math.sqrt(y),x=Math.atan2(_,g*v);m=Math.sin(m*x)/_,a=Math.sin(a*x)/_}var b=a*v;if(s=s*m+h*b,l=l*m+p*b,c=c*m+f*b,u=u*m+d*b,m===1-a){var w=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=w,l*=w,c*=w,u*=w}}t[e]=s,t[e+1]=l,t[e+2]=c,t[e+3]=u}}),Object.defineProperties(We.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(t){this._w=t,this.onChangeCallback()}}}),Object.assign(We.prototype,{set:function(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._w=n,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=t._x,n=t._y,i=t._z,o=t.order,a=Math.cos,s=Math.sin,l=a(r/2),c=a(n/2),u=a(i/2),h=s(r/2),p=s(n/2),f=s(i/2);return"XYZ"===o?(this._x=h*c*u+l*p*f,this._y=l*p*u-h*c*f,this._z=l*c*f+h*p*u,this._w=l*c*u-h*p*f):"YXZ"===o?(this._x=h*c*u+l*p*f,this._y=l*p*u-h*c*f,this._z=l*c*f-h*p*u,this._w=l*c*u+h*p*f):"ZXY"===o?(this._x=h*c*u-l*p*f,this._y=l*p*u+h*c*f,this._z=l*c*f+h*p*u,this._w=l*c*u-h*p*f):"ZYX"===o?(this._x=h*c*u-l*p*f,this._y=l*p*u+h*c*f,this._z=l*c*f-h*p*u,this._w=l*c*u+h*p*f):"YZX"===o?(this._x=h*c*u+l*p*f,this._y=l*p*u+h*c*f,this._z=l*c*f-h*p*u,this._w=l*c*u-h*p*f):"XZY"===o&&(this._x=h*c*u-l*p*f,this._y=l*p*u-h*c*f,this._z=l*c*f+h*p*u,this._w=l*c*u+h*p*f),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var r=e/2,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,r=t.elements,n=r[0],i=r[4],o=r[8],a=r[1],s=r[5],l=r[9],c=r[2],u=r[6],h=r[10],p=n+s+h;return p>0?(e=.5/Math.sqrt(p+1),this._w=.25/e,this._x=(u-l)*e,this._y=(o-c)*e,this._z=(a-i)*e):n>s&&n>h?(e=2*Math.sqrt(1+n-s-h),this._w=(u-l)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(o+c)/e):s>h?(e=2*Math.sqrt(1+s-n-h),this._w=(o-c)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(l+u)/e):(e=2*Math.sqrt(1+h-n-s),this._w=(a-i)/e,this._x=(o+c)/e,this._y=(l+u)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:(Se=new He,function(t,e){return void 0===Se&&(Se=new He),(we=t.dot(e)+1)<1e-6?(we=0,Math.abs(t.x)>Math.abs(t.z)?Se.set(-t.y,t.x,0):Se.set(0,-t.z,t.y)):Se.crossVectors(t,e),this._x=Se.x,this._y=Se.y,this._z=Se.z,this._w=we,this.normalize()}),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?this.multiplyQuaternions(t,e):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var r=t._x,n=t._y,i=t._z,o=t._w,a=e._x,s=e._y,l=e._z,c=e._w;return this._x=r*c+o*a+n*l-i*s,this._y=n*c+o*s+i*a-r*l,this._z=i*c+o*l+r*s-n*a,this._w=o*c-r*a-n*s-i*l,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var r=this._x,n=this._y,i=this._z,o=this._w,a=o*t._w+r*t._x+n*t._y+i*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=r,this._y=n,this._z=i,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(r+this._x),this._y=.5*(n+this._y),this._z=.5*(i+this._z),this;var l=Math.atan2(s,a),c=Math.sin((1-e)*l)/s,u=Math.sin(e*l)/s;return this._w=o*c+this._w*u,this._x=r*c+this._x*u,this._y=n*c+this._y*u,this._z=i*c+this._z*u,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(He.prototype,{isVector3:!0,set:function(t,e,r){return this.x=t,this.y=e,this.z=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?this.multiplyVectors(t,e):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:(Re=new We,function(t){return!t||t.isEuler,this.applyQuaternion(Re.setFromEuler(t))}),applyAxisAngle:(Le=new We,function(t,e){return this.applyQuaternion(Le.setFromAxisAngle(t,e))}),applyMatrix3:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6]*n,this.y=i[1]*e+i[4]*r+i[7]*n,this.z=i[2]*e+i[5]*r+i[8]*n,this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements,o=1/(i[3]*e+i[7]*r+i[11]*n+i[15]);return this.x=(i[0]*e+i[4]*r+i[8]*n+i[12])*o,this.y=(i[1]*e+i[5]*r+i[9]*n+i[13])*o,this.z=(i[2]*e+i[6]*r+i[10]*n+i[14])*o,this},applyQuaternion:function(t){var e=this.x,r=this.y,n=this.z,i=t.x,o=t.y,a=t.z,s=t.w,l=s*e+o*n-a*r,c=s*r+a*e-i*n,u=s*n+i*r-o*e,h=-i*e-o*r-a*n;return this.x=l*s+h*-i+c*-a-u*-o,this.y=c*s+h*-o+u*-i-l*-a,this.z=u*s+h*-a+l*-o-c*-i,this},project:(Pe=new Xe,function(t){return Pe.multiplyMatrices(t.projectionMatrix,Pe.getInverse(t.matrixWorld)),this.applyMatrix4(Pe)}),unproject:(Te=new Xe,function(t){return Te.multiplyMatrices(t.matrixWorld,Te.getInverse(t.projectionMatrix)),this.applyMatrix4(Te)}),transformDirection:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*r+i[8]*n,this.y=i[1]*e+i[5]*r+i[9]*n,this.z=i[2]*e+i[6]*r+i[10]*n,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:(Ee=new He,Ce=new He,function(t,e){return Ee.set(t,t,t),Ce.set(e,e,e),this.clamp(Ee,Ce)}),clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.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()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},cross:function(t,e){if(void 0!==e)return this.crossVectors(t,e);var r=this.x,n=this.y,i=this.z;return this.x=n*t.z-i*t.y,this.y=i*t.x-r*t.z,this.z=r*t.y-n*t.x,this},crossVectors:function(t,e){var r=t.x,n=t.y,i=t.z,o=e.x,a=e.y,s=e.z;return this.x=n*s-i*a,this.y=i*o-r*s,this.z=r*a-n*o,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:(Ae=new He,function(t){return Ae.copy(this).projectOnVector(t),this.sub(Ae)}),reflect:(Me=new He,function(t){return this.sub(Me.copy(t).multiplyScalar(2*this.dot(t)))}),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(ye.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromCylindrical:function(t){return this.x=t.radius*Math.sin(t.theta),this.y=t.y,this.z=t.radius*Math.cos(t.theta),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}}),Object.assign(Xe.prototype,{isMatrix4:!0,set:function(t,e,r,n,i,o,a,s,l,c,u,h,p,f,d,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=r,g[12]=n,g[1]=i,g[5]=o,g[9]=a,g[13]=s,g[2]=l,g[6]=c,g[10]=u,g[14]=h,g[3]=p,g[7]=f,g[11]=d,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new Xe).fromArray(this.elements)},copy:function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this},copyPosition:function(t){var e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this},extractBasis:function(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this},extractRotation:(ke=new He,function(t){var e=this.elements,r=t.elements,n=1/ke.setFromMatrixColumn(t,0).length(),i=1/ke.setFromMatrixColumn(t,1).length(),o=1/ke.setFromMatrixColumn(t,2).length();return e[0]=r[0]*n,e[1]=r[1]*n,e[2]=r[2]*n,e[4]=r[4]*i,e[5]=r[5]*i,e[6]=r[6]*i,e[8]=r[8]*o,e[9]=r[9]*o,e[10]=r[10]*o,this}),makeRotationFromEuler:function(t){!t||t.isEuler;var e=this.elements,r=t.x,n=t.y,i=t.z,o=Math.cos(r),a=Math.sin(r),s=Math.cos(n),l=Math.sin(n),c=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){var h=o*c,p=o*u,f=a*c,d=a*u;e[0]=s*c,e[4]=-s*u,e[8]=l,e[1]=p+f*l,e[5]=h-d*l,e[9]=-a*s,e[2]=d-h*l,e[6]=f+p*l,e[10]=o*s}else if("YXZ"===t.order){var m=s*c,g=s*u,v=l*c,y=l*u;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*l,e[1]=o*u,e[5]=o*c,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){m=s*c,g=s*u,v=l*c,y=l*u;e[0]=m-y*a,e[4]=-o*u,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*c,e[9]=y-m*a,e[2]=-o*l,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){h=o*c,p=o*u,f=a*c,d=a*u;e[0]=s*c,e[4]=f*l-p,e[8]=h*l+d,e[1]=s*u,e[5]=d*l+h,e[9]=p*l-f,e[2]=-l,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var _=o*s,x=o*l,b=a*s,w=a*l;e[0]=s*c,e[4]=w-_*u,e[8]=b*u+x,e[1]=u,e[5]=o*c,e[9]=-a*c,e[2]=-l*c,e[6]=x*u+b,e[10]=_-w*u}else if("XZY"===t.order){_=o*s,x=o*l,b=a*s,w=a*l;e[0]=s*c,e[4]=-u,e[8]=l*c,e[1]=_*u+w,e[5]=o*c,e[9]=x*u-b,e[2]=b*u-x,e[6]=a*c,e[10]=w*u+_}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,r=t._x,n=t._y,i=t._z,o=t._w,a=r+r,s=n+n,l=i+i,c=r*a,u=r*s,h=r*l,p=n*s,f=n*l,d=i*l,m=o*a,g=o*s,v=o*l;return e[0]=1-(p+d),e[4]=u-v,e[8]=h+g,e[1]=u+v,e[5]=1-(c+d),e[9]=f-m,e[2]=h-g,e[6]=f+m,e[10]=1-(c+p),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:(De=new He,Fe=new He,ze=new He,function(t,e,r){var n=this.elements;return ze.subVectors(t,e),0===ze.lengthSq()&&(ze.z=1),ze.normalize(),De.crossVectors(r,ze),0===De.lengthSq()&&(1===Math.abs(r.z)?ze.x+=1e-4:ze.z+=1e-4,ze.normalize(),De.crossVectors(r,ze)),De.normalize(),Fe.crossVectors(ze,De),n[0]=De.x,n[4]=Fe.x,n[8]=ze.x,n[1]=De.y,n[5]=Fe.y,n[9]=ze.y,n[2]=De.z,n[6]=Fe.z,n[10]=ze.z,this}),multiply:function(t,e){return void 0!==e?this.multiplyMatrices(t,e):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var r=t.elements,n=e.elements,i=this.elements,o=r[0],a=r[4],s=r[8],l=r[12],c=r[1],u=r[5],h=r[9],p=r[13],f=r[2],d=r[6],m=r[10],g=r[14],v=r[3],y=r[7],_=r[11],x=r[15],b=n[0],w=n[4],S=n[8],M=n[12],A=n[1],E=n[5],C=n[9],T=n[13],P=n[2],L=n[6],R=n[10],N=n[14],I=n[3],O=n[7],D=n[11],F=n[15];return i[0]=o*b+a*A+s*P+l*I,i[4]=o*w+a*E+s*L+l*O,i[8]=o*S+a*C+s*R+l*D,i[12]=o*M+a*T+s*N+l*F,i[1]=c*b+u*A+h*P+p*I,i[5]=c*w+u*E+h*L+p*O,i[9]=c*S+u*C+h*R+p*D,i[13]=c*M+u*T+h*N+p*F,i[2]=f*b+d*A+m*P+g*I,i[6]=f*w+d*E+m*L+g*O,i[10]=f*S+d*C+m*R+g*D,i[14]=f*M+d*T+m*N+g*F,i[3]=v*b+y*A+_*P+x*I,i[7]=v*w+y*E+_*L+x*O,i[11]=v*S+y*C+_*R+x*D,i[15]=v*M+y*T+_*N+x*F,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute:(Oe=new He,function(t){for(var e=0,r=t.count;e0)return t;var i=e*r,o=Qe[i];if(void 0===o&&(o=new Float32Array(i),Qe[i]=o),0!==e){n.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=r,t[a].toArray(o,s)}return o}function nr(t,e){var r=Je[e];void 0===r&&(r=new Int32Array(e),Je[e]=r);for(var n=0;n!==e;++n)r[n]=t.allocTextureUnit();return r}function ir(t,e){t.uniform1f(this.addr,e)}function or(t,e){t.uniform1i(this.addr,e)}function ar(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function sr(t,e){void 0!==e.x?t.uniform3f(this.addr,e.x,e.y,e.z):void 0!==e.r?t.uniform3f(this.addr,e.r,e.g,e.b):t.uniform3fv(this.addr,e)}function lr(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function cr(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function ur(t,e){void 0===e.elements?t.uniformMatrix3fv(this.addr,!1,e):(er.set(e.elements),t.uniformMatrix3fv(this.addr,!1,er))}function hr(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(tr.set(e.elements),t.uniformMatrix4fv(this.addr,!1,tr))}function pr(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTexture2D(e||Ze,n)}function fr(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTextureCube(e||$e,n)}function dr(t,e){t.uniform2iv(this.addr,e)}function mr(t,e){t.uniform3iv(this.addr,e)}function gr(t,e){t.uniform4iv(this.addr,e)}function vr(t,e){t.uniform1fv(this.addr,e)}function yr(t,e){t.uniform1iv(this.addr,e)}function _r(t,e){t.uniform2fv(this.addr,rr(e,this.size,2))}function xr(t,e){t.uniform3fv(this.addr,rr(e,this.size,3))}function br(t,e){t.uniform4fv(this.addr,rr(e,this.size,4))}function wr(t,e){t.uniformMatrix2fv(this.addr,!1,rr(e,this.size,4))}function Sr(t,e){t.uniformMatrix3fv(this.addr,!1,rr(e,this.size,9))}function Mr(t,e){t.uniformMatrix4fv(this.addr,!1,rr(e,this.size,16))}function Ar(t,e,r){var n=e.length,i=nr(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTexture2D(e[o]||Ze,i[o])}function Er(t,e,r){var n=e.length,i=nr(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTextureCube(e[o]||$e,i[o])}function Cr(t,e,r){this.id=t,this.addr=r,this.setValue=function(t){switch(t){case 5126:return ir;case 35664:return ar;case 35665:return sr;case 35666:return lr;case 35674:return cr;case 35675:return ur;case 35676:return hr;case 35678:case 36198:return pr;case 35680:return fr;case 5124:case 35670:return or;case 35667:case 35671:return dr;case 35668:case 35672:return mr;case 35669:case 35673:return gr}}(e.type)}function Tr(t,e,r){this.id=t,this.addr=r,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return vr;case 35664:return _r;case 35665:return xr;case 35666:return br;case 35674:return wr;case 35675:return Sr;case 35676:return Mr;case 35678:return Ar;case 35680:return Er;case 5124:case 35670:return yr;case 35667:case 35671:return dr;case 35668:case 35672:return mr;case 35669:case 35673:return gr}}(e.type)}function Pr(t){this.id=t,Ke.call(this)}Pr.prototype.setValue=function(t,e){for(var r=this.seq,n=0,i=r.length;n!==i;++n){var o=r[n];o.setValue(t,e[o.id])}};var Lr=/([\w\d_]+)(\])?(\[|\.)?/g;function Rr(t,e){t.seq.push(e),t.map[e.id]=e}function Nr(t,e,r){var n=t.name,i=n.length;for(Lr.lastIndex=0;;){var o=Lr.exec(n),a=Lr.lastIndex,s=o[1],l="]"===o[2],c=o[3];if(l&&(s|=0),void 0===c||"["===c&&a+2===i){Rr(r,void 0===c?new Cr(s,t,e):new Tr(s,t,e));break}var u=r.map[s];void 0===u&&Rr(r,u=new Pr(s)),r=u}}function Ir(t,e,r){Ke.call(this),this.renderer=r;for(var n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),i=0;i>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,r){return this.r=t,this.g=e,this.b=r,this},setHSL:function(){function t(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+6*(e-t)*(2/3-r):t}return function(e,r,n){if(e=ye.euclideanModulo(e,1),r=ye.clamp(r,0,1),n=ye.clamp(n,0,1),0===r)this.r=this.g=this.b=n;else{var i=n<=.5?n*(1+r):n+r-n*r,o=2*n-i;this.r=t(o,i,e+1/3),this.g=t(o,i,e),this.b=t(o,i,e-1/3)}return this}}(),setStyle:function(t){function e(t){void 0!==t&&parseFloat(t)}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var n,i=r[1],o=r[2];switch(i){case"rgb":case"rgba":if(n=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,e(n[5]),this;if(n=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,e(n[5]),this;break;case"hsl":case"hsla":if(n=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(n[1])/360,s=parseInt(n[2],10)/100,l=parseInt(n[3],10)/100;return e(n[5]),this.setHSL(a,s,l)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(t)){var c,u=(c=r[1]).length;if(3===u)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===u)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}t&&t.length>0&&(void 0!==(c=Or[t])&&this.setHex(c));return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var r=e>0?1/e:1;return this.r=Math.pow(t.r,r),this.g=Math.pow(t.g,r),this.b=Math.pow(t.b,r),this},convertGammaToLinear:function(){var t=this.r,e=this.g,r=this.b;return this.r=t*t,this.g=e*e,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){var e,r,n=t||{h:0,s:0,l:0},i=this.r,o=this.g,a=this.b,s=Math.max(i,o,a),l=Math.min(i,o,a),c=(l+s)/2;if(l===s)e=0,r=0;else{var u=s-l;switch(r=c<=.5?u/(s+l):u/(2-s-l),s){case i:e=(o-a)/u+(o 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\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}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.86267 + (0.49788 + 0.01436 * y ) * y;\n\tfloat b = 3.45068 + (4.18814 + y) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = (x > 0.0) ? v : 0.5 * inversesqrt( 1.0 - x * x ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tvec3 result = vec3( LTC_ClippedSphereFormFactor( vectorFormFactor ) );\n\treturn result;\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 = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\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 PI_HALF 1.5707963267949\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}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\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:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\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 += normalize( objectNormal ) * ( 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\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn 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\treturn 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\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn 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\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn 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\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn 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, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = 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 envMapIntensity;\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_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\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\tvarying float fogDepth;\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\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",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\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\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\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\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 ( angleCos > spotLight.coneCos ) {\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_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltcMat;\tuniform sampler2D ltcMag;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\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\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = 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 = 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\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = 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 = 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 = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, 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 = 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\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\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}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tfloat norm = texture2D( ltcMag, uv ).a;\n\t\tvec4 t = texture2D( ltcMat, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( 1, 0, t.y ),\n\t\t\tvec3( 0, t.z, 0 ),\n\t\t\tvec3( t.w, 0, t.x )\n\t\t);\n\t\treflectedLight.directSpecular += lightColor * material.specularColor * norm * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1 ), rectCoords );\n\t}\n#endif\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_Direct_RectArea\t\tRE_Direct_RectArea_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 ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 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 ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, 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\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.b;\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_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 );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\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 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\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\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 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\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( 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:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\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\tfloat shadow = 1.0;\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\tshadow = (\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\tshadow = (\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\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\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, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\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 ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 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 boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\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\ttransformed = ( bindMatrixInverse * skinned ).xyz;\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\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn 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\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn 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( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\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#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\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}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\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#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\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\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 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 \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\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 \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 = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\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 \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\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 \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\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \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 \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\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 \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\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\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 \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\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\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 \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\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \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\t#include \n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\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#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#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\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 \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\t#include \n}\n",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, 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"},Vr={basic:{uniforms:Ur.merge([kr.common,kr.specularmap,kr.envmap,kr.aomap,kr.lightmap,kr.fog]),vertexShader:Br.meshbasic_vert,fragmentShader:Br.meshbasic_frag},lambert:{uniforms:Ur.merge([kr.common,kr.specularmap,kr.envmap,kr.aomap,kr.lightmap,kr.emissivemap,kr.fog,kr.lights,{emissive:{value:new Dr(0)}}]),vertexShader:Br.meshlambert_vert,fragmentShader:Br.meshlambert_frag},phong:{uniforms:Ur.merge([kr.common,kr.specularmap,kr.envmap,kr.aomap,kr.lightmap,kr.emissivemap,kr.bumpmap,kr.normalmap,kr.displacementmap,kr.gradientmap,kr.fog,kr.lights,{emissive:{value:new Dr(0)},specular:{value:new Dr(1118481)},shininess:{value:30}}]),vertexShader:Br.meshphong_vert,fragmentShader:Br.meshphong_frag},standard:{uniforms:Ur.merge([kr.common,kr.envmap,kr.aomap,kr.lightmap,kr.emissivemap,kr.bumpmap,kr.normalmap,kr.displacementmap,kr.roughnessmap,kr.metalnessmap,kr.fog,kr.lights,{emissive:{value:new Dr(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Br.meshphysical_vert,fragmentShader:Br.meshphysical_frag},points:{uniforms:Ur.merge([kr.points,kr.fog]),vertexShader:Br.points_vert,fragmentShader:Br.points_frag},dashed:{uniforms:Ur.merge([kr.common,kr.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Br.linedashed_vert,fragmentShader:Br.linedashed_frag},depth:{uniforms:Ur.merge([kr.common,kr.displacementmap]),vertexShader:Br.depth_vert,fragmentShader:Br.depth_frag},normal:{uniforms:Ur.merge([kr.common,kr.bumpmap,kr.normalmap,kr.displacementmap,{opacity:{value:1}}]),vertexShader:Br.normal_vert,fragmentShader:Br.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Br.cube_vert,fragmentShader:Br.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Br.equirect_vert,fragmentShader:Br.equirect_frag},distanceRGBA:{uniforms:Ur.merge([kr.common,kr.displacementmap,{referencePosition:{value:new He},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Br.distanceRGBA_vert,fragmentShader:Br.distanceRGBA_frag},shadow:{uniforms:Ur.merge([kr.lights,{color:{value:new Dr(0)},opacity:{value:1}}]),vertexShader:Br.shadow_vert,fragmentShader:Br.shadow_frag}};function jr(t,e){this.min=void 0!==t?t:new _e(1/0,1/0),this.max=void 0!==e?e:new _e(-1/0,-1/0)}function Gr(t,e,r,n,i){var o,a,s,l,c,u,h,p;function f(){var t,n,f,d,m,g=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),v=new Uint16Array([0,1,2,0,2,3]);o=e.createBuffer(),a=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,o),e.bufferData(e.ARRAY_BUFFER,g,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.bufferData(e.ELEMENT_ARRAY_BUFFER,v,e.STATIC_DRAW),h=e.createTexture(),p=e.createTexture(),r.bindTexture(e.TEXTURE_2D,h),e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),r.bindTexture(e.TEXTURE_2D,p),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,16,16,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),s={vertexShader:["uniform lowp int renderType;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform float rotation;","uniform sampler2D occlusionMap;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","varying float vVisibility;","void main() {","vUV = uv;","vec2 pos = position;","if ( renderType == 2 ) {","vec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );","vVisibility = visibility.r / 9.0;","vVisibility *= 1.0 - visibility.g / 9.0;","vVisibility *= visibility.b / 9.0;","vVisibility *= 1.0 - visibility.a / 9.0;","pos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;","pos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;","}","gl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["uniform lowp int renderType;","uniform sampler2D map;","uniform float opacity;","uniform vec3 color;","varying vec2 vUV;","varying float vVisibility;","void main() {","if ( renderType == 0 ) {","gl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );","} else if ( renderType == 1 ) {","gl_FragColor = texture2D( map, vUV );","} else {","vec4 texture = texture2D( map, vUV );","texture.a *= opacity * vVisibility;","gl_FragColor = texture;","gl_FragColor.rgb *= color;","}","}"].join("\n")},t=s,n=e.createProgram(),f=e.createShader(e.FRAGMENT_SHADER),d=e.createShader(e.VERTEX_SHADER),m="precision "+i.precision+" float;\n",e.shaderSource(f,m+t.fragmentShader),e.shaderSource(d,m+t.vertexShader),e.compileShader(f),e.compileShader(d),e.attachShader(n,f),e.attachShader(n,d),e.linkProgram(n),l=n,c={vertex:e.getAttribLocation(l,"position"),uv:e.getAttribLocation(l,"uv")},u={renderType:e.getUniformLocation(l,"renderType"),map:e.getUniformLocation(l,"map"),occlusionMap:e.getUniformLocation(l,"occlusionMap"),opacity:e.getUniformLocation(l,"opacity"),color:e.getUniformLocation(l,"color"),scale:e.getUniformLocation(l,"scale"),rotation:e.getUniformLocation(l,"rotation"),screenPosition:e.getUniformLocation(l,"screenPosition")}}this.render=function(t,i,s,d){if(0!==t.length){var m=new He,g=d.w/d.z,v=.5*d.z,y=.5*d.w,_=16/d.w,x=new _e(_*g,_),b=new He(1,1,0),w=new _e(1,1),S=new jr;S.min.set(d.x,d.y),S.max.set(d.x+(d.z-16),d.y+(d.w-16)),void 0===l&&f(),r.useProgram(l),r.initAttributes(),r.enableAttribute(c.vertex),r.enableAttribute(c.uv),r.disableUnusedAttributes(),e.uniform1i(u.occlusionMap,0),e.uniform1i(u.map,1),e.bindBuffer(e.ARRAY_BUFFER,o),e.vertexAttribPointer(c.vertex,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(c.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),r.disable(e.CULL_FACE),r.buffers.depth.setMask(!1);for(var M=0,A=t.length;M.001&&P.scale>.001&&(b.x=P.x,b.y=P.y,b.z=P.z,_=P.size*P.scale/d.w,x.x=_*g,x.y=_,e.uniform3f(u.screenPosition,b.x,b.y,b.z),e.uniform2f(u.scale,x.x,x.y),e.uniform1f(u.rotation,P.rotation),e.uniform1f(u.opacity,P.opacity),e.uniform3f(u.color,P.color.r,P.color.g,P.color.b),r.setBlending(P.blending,P.blendEquation,P.blendSrc,P.blendDst),n.setTexture2D(P.texture,1),e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}}}r.enable(e.CULL_FACE),r.enable(e.DEPTH_TEST),r.buffers.depth.setMask(!0),r.reset()}}}function Wr(t,e,r,n,i,o,a,s,l){Be.call(this,t,e,r,n,i,o,a,s,l),this.needsUpdate=!0}function Hr(t,e,r,n,i){var o,a,s,l,c,u,h=new He,p=new We,f=new He;function d(){var t,r,n,h=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),p=new Uint16Array([0,1,2,0,2,3]);o=e.createBuffer(),a=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,o),e.bufferData(e.ARRAY_BUFFER,h,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.bufferData(e.ELEMENT_ARRAY_BUFFER,p,e.STATIC_DRAW),t=e.createProgram(),r=e.createShader(e.VERTEX_SHADER),n=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(r,["precision "+i.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),e.shaderSource(n,["precision "+i.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),e.compileShader(r),e.compileShader(n),e.attachShader(t,r),e.attachShader(t,n),e.linkProgram(t),s=t,l={position:e.getAttribLocation(s,"position"),uv:e.getAttribLocation(s,"uv")},c={uvOffset:e.getUniformLocation(s,"uvOffset"),uvScale:e.getUniformLocation(s,"uvScale"),rotation:e.getUniformLocation(s,"rotation"),scale:e.getUniformLocation(s,"scale"),color:e.getUniformLocation(s,"color"),map:e.getUniformLocation(s,"map"),opacity:e.getUniformLocation(s,"opacity"),modelViewMatrix:e.getUniformLocation(s,"modelViewMatrix"),projectionMatrix:e.getUniformLocation(s,"projectionMatrix"),fogType:e.getUniformLocation(s,"fogType"),fogDensity:e.getUniformLocation(s,"fogDensity"),fogNear:e.getUniformLocation(s,"fogNear"),fogFar:e.getUniformLocation(s,"fogFar"),fogColor:e.getUniformLocation(s,"fogColor"),alphaTest:e.getUniformLocation(s,"alphaTest")};var f=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");f.width=8,f.height=8;var d=f.getContext("2d");d.fillStyle="white",d.fillRect(0,0,8,8),u=new Wr(f)}function m(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}this.render=function(i,g,v){if(0!==i.length){void 0===s&&d(),r.useProgram(s),r.initAttributes(),r.enableAttribute(l.position),r.enableAttribute(l.uv),r.disableUnusedAttributes(),r.disable(e.CULL_FACE),r.enable(e.BLEND),e.bindBuffer(e.ARRAY_BUFFER,o),e.vertexAttribPointer(l.position,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(l.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.uniformMatrix4fv(c.projectionMatrix,!1,v.projectionMatrix.elements),r.activeTexture(e.TEXTURE0),e.uniform1i(c.map,0);var y=0,_=0,x=g.fog;x?(e.uniform3f(c.fogColor,x.color.r,x.color.g,x.color.b),x.isFog?(e.uniform1f(c.fogNear,x.near),e.uniform1f(c.fogFar,x.far),e.uniform1i(c.fogType,1),y=1,_=1):x.isFogExp2&&(e.uniform1f(c.fogDensity,x.density),e.uniform1i(c.fogType,2),y=2,_=2)):(e.uniform1i(c.fogType,0),y=0,_=0);for(var b=0,w=i.length;bthis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return(e||new _e).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return(e||new _e).copy(t).clamp(this.min,this.max)},distanceToPoint:(Fr=new _e,function(t){return Fr.copy(t).clamp(this.min,this.max).sub(t).length()}),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Wr.prototype=Object.create(Be.prototype),Wr.prototype.constructor=Wr;var Xr,Yr,qr,Zr,$r,Kr,Qr,Jr,tn,en,rn,nn,on,an,sn,ln,cn,un,hn,pn=0;function fn(){Object.defineProperty(this,"id",{value:pn++}),this.uuid=ye.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=E,this.side=y,this.flatShading=!1,this.vertexColors=w,this.opacity=1,this.transparent=!1,this.blendSrc=B,this.blendDst=V,this.blendEquation=R,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=$,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this.userData={},this.needsUpdate=!0}function dn(t){fn.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,void 0!==t&&(t.attributes,this.setValues(t))}function mn(t){fn.call(this),this.type="MeshDepthMaterial",this.depthPacking=ge,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(t)}function gn(t){fn.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new He,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.lights=!1,this.setValues(t)}function vn(t,e){this.min=void 0!==t?t:new He(1/0,1/0,1/0),this.max=void 0!==e?e:new He(-1/0,-1/0,-1/0)}function yn(t,e){this.center=void 0!==t?t:new He,this.radius=void 0!==e?e:0}function _n(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length}function xn(t,e){this.normal=void 0!==t?t:new He(1,0,0),this.constant=void 0!==e?e:0}function bn(t,e,r,n,i,o){this.planes=[void 0!==t?t:new xn,void 0!==e?e:new xn,void 0!==r?r:new xn,void 0!==n?n:new xn,void 0!==i?i:new xn,void 0!==o?o:new xn]}function wn(t,e,r){for(var n=new bn,i=new Xe,o=new _e,a=new _e(r,r),s=new He,l=new He,c=1,u=2,h=1+(c|u),p=new Array(h),f=new Array(h),d={},m=[new He(1,0,0),new He(-1,0,0),new He(0,0,1),new He(0,0,-1),new He(0,1,0),new He(0,-1,0)],v=[new He(0,1,0),new He(0,1,0),new He(0,1,0),new He(0,1,0),new He(0,0,1),new He(0,0,-1)],_=[new Ve,new Ve,new Ve,new Ve,new Ve,new Ve],w=0;w!==h;++w){var S=0!=(w&c),M=0!=(w&u),A=new mn({depthPacking:ve,morphTargets:S,skinning:M});p[w]=A;var E=new gn({morphTargets:S,skinning:M});f[w]=E}var C=this;function T(e,r,n,i,o,a){var s=e.geometry,l=null,h=p,m=e.customDepthMaterial;if(n&&(h=f,m=e.customDistanceMaterial),m)l=m;else{var g=!1;r.morphTargets&&(s&&s.isBufferGeometry?g=s.morphAttributes&&s.morphAttributes.position&&s.morphAttributes.position.length>0:s&&s.isGeometry&&(g=s.morphTargets&&s.morphTargets.length>0)),e.isSkinnedMesh&&r.skinning;var v=e.isSkinnedMesh&&r.skinning,_=0;g&&(_|=c),v&&(_|=u),l=h[_]}if(t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var w=l.uuid,S=r.uuid,M=d[w];void 0===M&&(M={},d[w]=M);var A=M[S];void 0===A&&(A=l.clone(),M[S]=A),l=A}l.visible=r.visible,l.wireframe=r.wireframe;var E=r.side;return C.renderSingleSided&&E==b&&(E=y),C.renderReverseSided&&(E===y?E=x:E===x&&(E=y)),l.side=E,l.clipShadows=r.clipShadows,l.clippingPlanes=r.clippingPlanes,l.clipIntersection=r.clipIntersection,l.wireframeLinewidth=r.wireframeLinewidth,l.linewidth=r.linewidth,n&&l.isMeshDistanceMaterial&&(l.referencePosition.copy(i),l.nearDistance=o,l.farDistance=a),l}function P(r,i,o,a){if(!1!==r.visible){if(r.layers.test(i.layers)&&(r.isMesh||r.isLine||r.isPoints)&&r.castShadow&&(!r.frustumCulled||n.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,r.matrixWorld);var s=e.update(r),c=r.material;if(Array.isArray(c))for(var u=s.groups,h=0,p=u.length;h0&&(r.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(r.morphTargets=!0),!0===this.skinning&&(r.skinning=!0),!1===this.visible&&(r.visible=!1),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),e){var i=n(t.textures),o=n(t.images);i.length>0&&(r.textures=i),o.length>0&&(r.images=o)}return r},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.overdraw=t.overdraw,this.visible=t.visible,this.userData=JSON.parse(JSON.stringify(t.userData)),this.clipShadows=t.clipShadows,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,r=null;if(null!==e){var n=e.length;r=new Array(n);for(var i=0;i!==n;++i)r[i]=e[i].clone()}return this.clippingPlanes=r,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),dn.prototype=Object.create(fn.prototype),dn.prototype.constructor=dn,dn.prototype.isShaderMaterial=!0,dn.prototype.copy=function(t){return fn.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Ur.clone(t.uniforms),this.defines=t.defines,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this},dn.prototype.toJSON=function(t){var e=fn.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},mn.prototype=Object.create(fn.prototype),mn.prototype.constructor=mn,mn.prototype.isMeshDepthMaterial=!0,mn.prototype.copy=function(t){return fn.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},gn.prototype=Object.create(fn.prototype),gn.prototype.constructor=gn,gn.prototype.isMeshDistanceMaterial=!0,gn.prototype.copy=function(t){return fn.prototype.copy.call(this,t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this},Object.assign(vn.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,r=1/0,n=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,l=t.length;si&&(i=c),u>o&&(o=u),h>a&&(a=h)}return this.min.set(e,r,n),this.max.set(i,o,a),this},setFromBufferAttribute:function(t){for(var e=1/0,r=1/0,n=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,l=t.count;si&&(i=c),u>o&&(o=u),h>a&&(a=h)}return this.min.set(e,r,n),this.max.set(i,o,a),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,r=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return(e||new He).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:(Zr=new He,function(t){return this.clampPoint(t.center,Zr),Zr.distanceToSquared(t.center)<=t.radius*t.radius}),intersectsPlane:function(t){var e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=t.constant&&r>=t.constant},clampPoint:function(t,e){return(e||new He).copy(t).clamp(this.min,this.max)},distanceToPoint:(qr=new He,function(t){return qr.copy(t).clamp(this.min,this.max).sub(t).length()}),getBoundingSphere:(Yr=new He,function(t){var e=t||new yn;return this.getCenter(e.center),e.radius=.5*this.getSize(Yr).length(),e}),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:(Xr=[new He,new He,new He,new He,new He,new He,new He,new He],function(t){return this.isEmpty()?this:(Xr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Xr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Xr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Xr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Xr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Xr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Xr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Xr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Xr),this)}),translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Object.assign(yn.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:(Qr=new vn,function(t,e){var r=this.center;void 0!==e?r.copy(e):Qr.setFromPoints(t).getCenter(r);for(var n=0,i=0,o=t.length;ithis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n},getBoundingBox:function(t){var e=t||new vn;return e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}}),Object.assign(_n.prototype,{isMatrix3:!0,set:function(t,e,r,n,i,o,a,s,l){var c=this.elements;return c[0]=t,c[1]=n,c[2]=a,c[3]=e,c[4]=i,c[5]=s,c[6]=r,c[7]=o,c[8]=l,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToBufferAttribute:(Jr=new He,function(t){for(var e=0,r=t.count;e1?void 0:r.copy(n).multiplyScalar(o).add(t.start)}),intersectsLine:function(t){var e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&r>0||r<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return(t||new He).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:(tn=new He,en=new _n,function(t,e){var r=e||en.getNormalMatrix(t),n=this.coplanarPoint(tn).applyMatrix4(t),i=this.normal.applyMatrix3(r).normalize();return this.constant=-n.dot(i),this}),translate:function(t){return this.constant-=t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}}),Object.assign(bn.prototype,{set:function(t,e,r,n,i,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(r),a[3].copy(n),a[4].copy(i),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,r=0;r<6;r++)e[r].copy(t.planes[r]);return this},setFromMatrix:function(t){var e=this.planes,r=t.elements,n=r[0],i=r[1],o=r[2],a=r[3],s=r[4],l=r[5],c=r[6],u=r[7],h=r[8],p=r[9],f=r[10],d=r[11],m=r[12],g=r[13],v=r[14],y=r[15];return e[0].setComponents(a-n,u-s,d-h,y-m).normalize(),e[1].setComponents(a+n,u+s,d+h,y+m).normalize(),e[2].setComponents(a+i,u+l,d+p,y+g).normalize(),e[3].setComponents(a-i,u-l,d-p,y-g).normalize(),e[4].setComponents(a-o,u-c,d-f,y-v).normalize(),e[5].setComponents(a+o,u+c,d+f,y+v).normalize(),this},intersectsObject:(cn=new yn,function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),cn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(cn)}),intersectsSprite:(ln=new yn,function(t){return ln.center.set(0,0,0),ln.radius=.7071067811865476,ln.applyMatrix4(t.matrixWorld),this.intersectsSphere(ln)}),intersectsSphere:function(t){for(var e=this.planes,r=t.center,n=-t.radius,i=0;i<6;i++){if(e[i].distanceToPoint(r)0?t.min.x:t.max.x,sn.x=n.normal.x>0?t.max.x:t.min.x,an.y=n.normal.y>0?t.min.y:t.max.y,sn.y=n.normal.y>0?t.max.y:t.min.y,an.z=n.normal.z>0?t.min.z:t.max.z,sn.z=n.normal.z>0?t.max.z:t.min.z;var i=n.distanceToPoint(an),o=n.distanceToPoint(sn);if(i<0&&o<0)return!1}return!0}),containsPoint:function(t){for(var e=this.planes,r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0}}),Mn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],Mn.DefaultOrder="XYZ",Object.defineProperties(Mn.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},order:{get:function(){return this._order},set:function(t){this._order=t,this.onChangeCallback()}}}),Object.assign(Mn.prototype,{isEuler:!0,set:function(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._order=n||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},setFromRotationMatrix:function(t,e,r){var n=ye.clamp,i=t.elements,o=i[0],a=i[4],s=i[8],l=i[1],c=i[5],u=i[9],h=i[2],p=i[6],f=i[10];return"XYZ"===(e=e||this._order)?(this._y=Math.asin(n(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(p,c),this._z=0)):"YXZ"===e?(this._x=Math.asin(-n(u,-1,1)),Math.abs(u)<.99999?(this._y=Math.atan2(s,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,o),this._z=0)):"ZXY"===e?(this._x=Math.asin(n(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,o))):"ZYX"===e?(this._y=Math.asin(-n(h,-1,1)),Math.abs(h)<.99999?(this._x=Math.atan2(p,f),this._z=Math.atan2(l,o)):(this._x=0,this._z=Math.atan2(-a,c))):"YZX"===e?(this._z=Math.asin(n(l,-1,1)),Math.abs(l)<.99999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,o)):(this._x=0,this._y=Math.atan2(s,f))):"XZY"===e&&(this._z=Math.asin(-n(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(p,c),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-u,f),this._y=0)),this._order=e,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:(hn=new Xe,function(t,e,r){return hn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(hn,e,r)}),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:(un=new We,function(t){return un.setFromEuler(this),this.setFromQuaternion(un,t)}),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new He(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(An.prototype,{set:function(t){this.mask=1<1){for(var e=0;e1){for(var e=0;e0){n.children=[];for(a=0;a0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),h.length>0&&(r.images=h)}return r.object=n,r;function p(t){var e=[];for(var r in t){var n=t[r];delete n.metadata,e.push(n)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var r=0;re&&(e=t[r]);return e}function Zi(){Object.defineProperty(this,"id",{value:Di()}),this.uuid=ye.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}}function $i(t,e,r,n,i,o){Fi.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:o},this.fromBufferGeometry(new Ki(t,e,r,n,i,o)),this.mergeVertices()}function Ki(t,e,r,n,i,o){Zi.call(this),this.type="BoxBufferGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:o};var a=this;n=Math.floor(n)||1,i=Math.floor(i)||1;var s=[],l=[],c=[],u=[],h=0,p=0;function f(t,e,r,n,i,o,f,d,m,g,v){var y,_,x=o/m,b=f/g,w=o/2,S=f/2,M=d/2,A=m+1,E=g+1,C=0,T=0,P=new He;for(_=0;_0?1:-1,c.push(P.x,P.y,P.z),u.push(y/m),u.push(1-_/g),C+=1}}for(_=0;_1&&r.sort(oo),n.length>1&&n.sort(ao)}}},t[n]=i),i},dispose:function(){t={}}}}function lo(t,e){return Math.abs(e[1])-Math.abs(t[1])}function co(){var t=new function(){var t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];var r;switch(e.type){case"DirectionalLight":r={direction:new He,color:new Dr,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new _e};break;case"SpotLight":r={position:new He,direction:new He,color:new Dr,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new _e};break;case"PointLight":r={position:new He,color:new Dr,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new _e,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":r={direction:new He,skyColor:new Dr,groundColor:new Dr};break;case"RectAreaLight":r={color:new Dr,position:new He,halfWidth:new He,halfHeight:new He}}return t[e.id]=r,r}}},e={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},r=new He,n=new Xe,i=new Xe;return{setup:function(o,a,s){for(var l=0,c=0,u=0,h=0,p=0,f=0,d=0,m=0,g=s.matrixWorldInverse,v=0,y=o.length;v0)for(p=0;p0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,r;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,r,n,i;for(r=0,n=this.faces.length;r0&&(t+=e[r].distanceTo(e[r-1])),this.lineDistances[r]=t},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new vn),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new yn),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,r){if(t&&t.isGeometry){var n,i=this.vertices.length,o=this.vertices,a=t.vertices,s=this.faces,l=t.faces,c=this.faceVertexUvs[0],u=t.faceVertexUvs[0],h=this.colors,p=t.colors;void 0===r&&(r=0),void 0!==e&&(n=(new _n).getNormalMatrix(e));for(var f=0,d=a.length;f=0;r--){var d=p[r];for(this.faces.splice(d,1),a=0,s=this.faceVertexUvs.length;a0,g=f.vertexNormals.length>0,v=1!==f.color.r||1!==f.color.g||1!==f.color.b,y=f.vertexColors.length>0,_=0;if(_=S(_=S(_=S(_=S(_=S(_=S(_=S(_=S(_,0,0),1,!0),2,!1),3,d),4,m),5,g),6,v),7,y),a.push(_),a.push(f.a,f.b,f.c),a.push(f.materialIndex),d){var x=this.faceVertexUvs[0][i];a.push(E(x[0]),E(x[1]),E(x[2]))}if(m&&a.push(M(f.normal)),g){var b=f.vertexNormals;a.push(M(b[0]),M(b[1]),M(b[2]))}if(v&&a.push(A(f.color)),y){var w=f.vertexColors;a.push(A(w[0]),A(w[1]),A(w[2]))}}function S(t,e,r){return r?t|1<0&&(t.data.colors=c),h.length>0&&(t.data.uvs=[h]),t.data.faces=a,t},clone:function(){return(new Fi).copy(this)},copy:function(t){var e,r,n,i,o,a;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var s=t.vertices;for(e=0,r=s.length;e0,a=i[1]&&i[1].length>0,s=t.morphTargets,l=s.length;if(l>0){e=[];for(var c=0;c0){u=[];for(c=0;c65535?Wi:ji)(t,1):this.index=t},addAttribute:function(t,e){if(e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute){if("index"!==t)return this.attributes[t]=e,this;this.setIndex(e)}else this.addAttribute(t,new zi(arguments[1],arguments[2]))},getAttribute:function(t){return this.attributes[t]},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,r){this.groups.push({start:t,count:e,materialIndex:void 0!==r?r:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToBufferAttribute(e),e.needsUpdate=!0);var r=this.attributes.normal;void 0!==r&&((new _n).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:(ci=new Xe,function(t){return ci.makeRotationX(t),this.applyMatrix(ci),this}),rotateY:(li=new Xe,function(t){return li.makeRotationY(t),this.applyMatrix(li),this}),rotateZ:(si=new Xe,function(t){return si.makeRotationZ(t),this.applyMatrix(si),this}),translate:(ai=new Xe,function(t,e,r){return ai.makeTranslation(t,e,r),this.applyMatrix(ai),this}),scale:(oi=new Xe,function(t,e,r){return oi.makeScale(t,e,r),this.applyMatrix(oi),this}),lookAt:(ii=new Wn,function(t){ii.lookAt(t),ii.updateMatrix(),this.applyMatrix(ii.matrix)}),center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var r=new Hi(3*e.vertices.length,3),n=new Hi(3*e.colors.length,3);if(this.addAttribute("position",r.copyVector3sArray(e.vertices)),this.addAttribute("color",n.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new Hi(e.lineDistances.length,1);this.addAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},updateFromObject:function(t){var e,r=t.geometry;if(t.isMesh){var n=r.__directGeometry;if(!0===r.elementsNeedUpdate&&(n=void 0,r.elementsNeedUpdate=!1),void 0===n)return this.fromGeometry(r);n.verticesNeedUpdate=r.verticesNeedUpdate,n.normalsNeedUpdate=r.normalsNeedUpdate,n.colorsNeedUpdate=r.colorsNeedUpdate,n.uvsNeedUpdate=r.uvsNeedUpdate,n.groupsNeedUpdate=r.groupsNeedUpdate,r.verticesNeedUpdate=!1,r.normalsNeedUpdate=!1,r.colorsNeedUpdate=!1,r.uvsNeedUpdate=!1,r.groupsNeedUpdate=!1,r=n}return!0===r.verticesNeedUpdate&&(void 0!==(e=this.attributes.position)&&(e.copyVector3sArray(r.vertices),e.needsUpdate=!0),r.verticesNeedUpdate=!1),!0===r.normalsNeedUpdate&&(void 0!==(e=this.attributes.normal)&&(e.copyVector3sArray(r.normals),e.needsUpdate=!0),r.normalsNeedUpdate=!1),!0===r.colorsNeedUpdate&&(void 0!==(e=this.attributes.color)&&(e.copyColorsArray(r.colors),e.needsUpdate=!0),r.colorsNeedUpdate=!1),r.uvsNeedUpdate&&(void 0!==(e=this.attributes.uv)&&(e.copyVector2sArray(r.uvs),e.needsUpdate=!0),r.uvsNeedUpdate=!1),r.lineDistancesNeedUpdate&&(void 0!==(e=this.attributes.lineDistance)&&(e.copyArray(r.lineDistances),e.needsUpdate=!0),r.lineDistancesNeedUpdate=!1),r.groupsNeedUpdate&&(r.computeGroups(t.geometry),this.groups=r.groups,r.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new Yi).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new zi(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){var r=new Float32Array(3*t.normals.length);this.addAttribute("normal",new zi(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new zi(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new zi(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new zi(o,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var a=new(qi(t.indices)>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new zi(a,1).copyIndicesArray(t.indices))}this.groups=t.groups;for(var s in t.morphTargets){for(var l=[],c=t.morphTargets[s],u=0,h=c.length;u0){var d=new Hi(4*t.skinIndices.length,4);this.addAttribute("skinIndex",d.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var m=new Hi(4*t.skinWeights.length,4);this.addAttribute("skinWeight",m.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new vn);var t=this.attributes.position;void 0!==t?this.boundingBox.setFromBufferAttribute(t):this.boundingBox.makeEmpty(),isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z)},computeBoundingSphere:(ri=new vn,ni=new He,function(){null===this.boundingSphere&&(this.boundingSphere=new yn);var t=this.attributes.position;if(t){var e=this.boundingSphere.center;ri.setFromBufferAttribute(t),ri.getCenter(e);for(var r=0,n=0,i=t.count;n0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var l=this.boundingSphere;return null!==l&&(t.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),t},clone:function(){return(new Zi).copy(this)},copy:function(t){var e,r,n;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var i=t.index;null!==i&&this.setIndex(i.clone());var o=t.attributes;for(e in o){var a=o[e];this.addAttribute(e,a.clone())}var s=t.morphAttributes;for(e in s){var l=[],c=s[e];for(r=0,n=c.length;r0)if(o=c*u-h,s=l*f,(i=c*h-u)>=0)if(o>=-s)if(o<=s){var d=1/f;a=(i*=d)*(i+c*(o*=d)+2*u)+o*(c*i+o+2*h)+p}else o=l,a=-(i=Math.max(0,-(c*o+u)))*i+o*(o+2*h)+p;else o=-l,a=-(i=Math.max(0,-(c*o+u)))*i+o*(o+2*h)+p;else o<=-s?a=-(i=Math.max(0,-(-c*l+u)))*i+(o=i>0?-l:Math.min(Math.max(-l,-h),l))*(o+2*h)+p:o<=s?(i=0,a=(o=Math.min(Math.max(-l,-h),l))*(o+2*h)+p):a=-(i=Math.max(0,-(c*l+u)))*i+(o=i>0?l:Math.min(Math.max(-l,-h),l))*(o+2*h)+p;else o=c>0?-l:l,a=-(i=Math.max(0,-(c*o+u)))*i+o*(o+2*h)+p;return r&&r.copy(this.direction).multiplyScalar(i).add(this.origin),n&&n.copy(vi).multiplyScalar(o).add(gi),a}),intersectSphere:(mi=new He,function(t,e){mi.subVectors(t.center,this.origin);var r=mi.dot(this.direction),n=mi.dot(mi)-r*r,i=t.radius*t.radius;if(n>i)return null;var o=Math.sqrt(i-n),a=r-o,s=r+o;return a<0&&s<0?null:a<0?this.at(s,e):this.at(a,e)}),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null},intersectPlane:function(t,e){var r=this.distanceToPlane(t);return null===r?null:this.at(r,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var r,n,i,o,a,s,l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(r=(t.min.x-h.x)*l,n=(t.max.x-h.x)*l):(r=(t.max.x-h.x)*l,n=(t.min.x-h.x)*l),c>=0?(i=(t.min.y-h.y)*c,o=(t.max.y-h.y)*c):(i=(t.max.y-h.y)*c,o=(t.min.y-h.y)*c),r>o||i>n?null:((i>r||r!=r)&&(r=i),(o=0?(a=(t.min.z-h.z)*u,s=(t.max.z-h.z)*u):(a=(t.max.z-h.z)*u,s=(t.min.z-h.z)*u),r>s||a>n?null:((a>r||r!=r)&&(r=a),(s=0?r:n,e)))},intersectsBox:(di=new He,function(t){return null!==this.intersectBox(t,di)}),intersectTriangle:(ui=new He,hi=new He,pi=new He,fi=new He,function(t,e,r,n,i){hi.subVectors(e,t),pi.subVectors(r,t),fi.crossVectors(hi,pi);var o,a=this.direction.dot(fi);if(a>0){if(n)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}ui.subVectors(this.origin,t);var s=o*this.direction.dot(pi.crossVectors(ui,pi));if(s<0)return null;var l=o*this.direction.dot(hi.cross(ui));if(l<0)return null;if(s+l>a)return null;var c=-o*ui.dot(fi);return c<0?null:this.at(c/a,i)}),applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}}),Object.assign(ro.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return(t||new He).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return(t||new He).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){var r=e||new He;return this.delta(r).multiplyScalar(t).add(this.start)},closestPointToPointParameter:(bi=new He,wi=new He,function(t,e){bi.subVectors(t,this.start),wi.subVectors(this.end,this.start);var r=wi.dot(wi),n=wi.dot(bi)/r;return e&&(n=ye.clamp(n,0,1)),n}),closestPointToPoint:function(t,e,r){var n=this.closestPointToPointParameter(t,e),i=r||new He;return this.delta(i).multiplyScalar(n).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),Object.assign(no,{normal:(Ci=new He,function(t,e,r,n){var i=n||new He;i.subVectors(r,e),Ci.subVectors(t,e),i.cross(Ci);var o=i.lengthSq();return o>0?i.multiplyScalar(1/Math.sqrt(o)):i.set(0,0,0)}),barycoordFromPoint:(Mi=new He,Ai=new He,Ei=new He,function(t,e,r,n,i){Mi.subVectors(n,e),Ai.subVectors(r,e),Ei.subVectors(t,e);var o=Mi.dot(Mi),a=Mi.dot(Ai),s=Mi.dot(Ei),l=Ai.dot(Ai),c=Ai.dot(Ei),u=o*l-a*a,h=i||new He;if(0===u)return h.set(-2,-1,-1);var p=1/u,f=(l*s-a*c)*p,d=(o*c-a*s)*p;return h.set(1-f-d,d,f)}),containsPoint:(Si=new He,function(t,e,r,n){var i=no.barycoordFromPoint(t,e,r,n,Si);return i.x>=0&&i.y>=0&&i.x+i.y<=1})}),Object.assign(no.prototype,{set:function(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this},setFromPointsAndIndices:function(t,e,r,n){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[n]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},area:(Ni=new He,Ii=new He,function(){return Ni.subVectors(this.c,this.b),Ii.subVectors(this.a,this.b),.5*Ni.cross(Ii).length()}),midpoint:function(t){return(t||new He).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return no.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new xn).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return no.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return no.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:(Ti=new xn,Pi=[new ro,new ro,new ro],Li=new He,Ri=new He,function(t,e){var r=e||new He,n=1/0;if(Ti.setFromCoplanarPoints(this.a,this.b,this.c),Ti.projectPoint(t,Li),!0===this.containsPoint(Li))r.copy(Li);else{Pi[0].set(this.a,this.b),Pi[1].set(this.b,this.c),Pi[2].set(this.c,this.a);for(var i=0;i0){var a=i[o[0]];if(void 0!==a)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=a.length;t0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=s.length;tr.far?null:{distance:l,point:d.clone(),object:t}}function v(t,e,r,a,s,l,p,d){n.fromBufferAttribute(a,l),i.fromBufferAttribute(a,p),o.fromBufferAttribute(a,d);var v=g(t,t.material,e,r,n,i,o,f);return v&&(s&&(c.fromBufferAttribute(s,l),u.fromBufferAttribute(s,p),h.fromBufferAttribute(s,d),v.uv=m(f,n,i,o,c,u,h)),v.face=new qn(l,p,d,no.normal(n,i,o)),v.faceIndex=l),v}return function(p,d){var y,_=this.geometry,x=this.material,b=this.matrixWorld;if(void 0!==x&&(null===_.boundingSphere&&_.computeBoundingSphere(),r.copy(_.boundingSphere),r.applyMatrix4(b),!1!==p.ray.intersectsSphere(r)&&(t.getInverse(b),e.copy(p.ray).applyMatrix4(t),null===_.boundingBox||!1!==e.intersectsBox(_.boundingBox))))if(_.isBufferGeometry){var w,S,M,A,E,C=_.index,T=_.attributes.position,P=_.attributes.uv;if(null!==C)for(A=0,E=C.count;A0&&(I=z);for(var k=0,U=F.length;k/gm,function(t,e){var r=Br[e];if(void 0===r)throw new Error("Can not resolve #include <"+e+">");return Ro(r)})}function No(t){return t.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(t,e,r,n){for(var i="",o=parseInt(e);o0?t.gammaFactor:1,A=(d=n.extensions,m=o,y=e,[(d=d||{}).derivatives||m.envMapCubeUV||m.bumpMap||m.normalMap||m.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(d.fragDepth||m.logarithmicDepthBuffer)&&y.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",d.drawBuffers&&y.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(d.shaderTextureLOD||m.envMap)&&y.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Po).join("\n")),E=function(t){var e=[];for(var r in t){var n=t[r];!1!==n&&e.push("#define "+r+" "+n)}return e.join("\n")}(s),C=a.createProgram();n.isRawShaderMaterial?(_=[E,"\n"].filter(Po).join("\n"),x=[A,E,"\n"].filter(Po).join("\n")):(_=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,E,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+M,"#define MAX_BONES "+o.maxBones,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+p:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.displacementMap&&o.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.flatShading?"#define FLAT_SHADED":"",o.skinning?"#define USE_SKINNING":"",o.useVertexTexture?"#define BONE_TEXTURE":"",o.morphTargets?"#define USE_MORPHTARGETS":"",o.morphNormals&&!1===o.flatShading?"#define USE_MORPHNORMALS":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+u:"",o.sizeAttenuation?"#define USE_SIZEATTENUATION":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Po).join("\n"),x=[A,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,E,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+M,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+h:"",o.envMap?"#define "+p:"",o.envMap?"#define "+f:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.gradientMap?"#define USE_GRADIENTMAP":"",o.flatShading?"#define FLAT_SHADED":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(o.numClippingPlanes-o.numClipIntersection),o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+u:"",o.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",o.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",o.envMap&&e.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",o.toneMapping!==it?"#define TONE_MAPPING":"",o.toneMapping!==it?Br.tonemapping_pars_fragment:"",o.toneMapping!==it?function(t,e){var r;switch(e){case ot:r="Linear";break;case at:r="Reinhard";break;case st:r="Uncharted2";break;case lt:r="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+e)}return"vec3 "+t+"( vec3 color ) { return "+r+"ToneMapping( color ); }"}("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.envMapEncoding||o.emissiveMapEncoding?Br.encodings_pars_fragment:"",o.mapEncoding?To("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?To("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?To("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?(b="linearToOutputTexel",w=o.outputEncoding,S=Co(w),"vec4 "+b+"( vec4 value ) { return LinearTo"+S[0]+S[1]+"; }"):"",o.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Po).join("\n")),l=Lo(l=Ro(l),o),c=Lo(c=Ro(c),o),n.isShaderMaterial||(l=No(l),c=No(c));var T=_+l,P=x+c,L=uo(a,a.VERTEX_SHADER,T),R=uo(a,a.FRAGMENT_SHADER,P);a.attachShader(C,L),a.attachShader(C,R),void 0!==n.index0AttributeName?a.bindAttribLocation(C,0,n.index0AttributeName):!0===o.morphTargets&&a.bindAttribLocation(C,0,"position"),a.linkProgram(C);var N,I,O=a.getProgramInfoLog(C),D=a.getShaderInfoLog(L),F=a.getShaderInfoLog(R),z=!0,k=!0;return!1===a.getProgramParameter(C,a.LINK_STATUS)?z=!1:""!==O||""!==D&&""!==F||(k=!1),k&&(this.diagnostics={runnable:z,material:n,programLog:O,vertexShader:{log:D,prefix:_},fragmentShader:{log:F,prefix:x}}),a.deleteShader(L),a.deleteShader(R),this.getUniforms=function(){return void 0===N&&(N=new Ir(a,C,t)),N},this.getAttributes=function(){return void 0===I&&(I=function(t,e,r){for(var n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),o=0;o0,maxBones:p,useVertexTexture:r.floatVertexTextures,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:n.directional.length,numPointLights:n.point.length,numSpotLights:n.spot.length,numRectAreaLights:n.rectArea.length,numHemiLights:n.hemi.length,numClippingPlanes:l,numClipIntersection:c,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&u.receiveShadow&&o.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===b,flipSided:e.side===x,depthPacking:void 0!==e.depthPacking&&e.depthPacking}},this.getProgramCode=function(e,r){var n=[];if(r.shaderID?n.push(r.shaderID):(n.push(e.fragmentShader),n.push(e.vertexShader)),void 0!==e.defines)for(var i in e.defines)n.push(i),n.push(e.defines[i]);for(var a=0;ae||t.height>e){var r=e/Math.max(t.width,t.height),n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return n.width=Math.floor(t.width*r),n.height=Math.floor(t.height*r),n.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,n.width,n.height),n}return t}function c(t){return ye.isPowerOfTwo(t.width)&&ye.isPowerOfTwo(t.height)}function u(t,e){return t.generateMipmaps&&e&&t.minFilter!==_t&&t.minFilter!==wt}function h(e){return e===_t||e===xt||e===bt?t.NEAREST:t.LINEAR}function p(e){var r=e.target;r.removeEventListener("dispose",p),function(e){var r=n.get(e);if(e.image&&r.__image__webglTextureCube)t.deleteTexture(r.__image__webglTextureCube);else{if(void 0===r.__webglInit)return;t.deleteTexture(r.__webglTexture)}n.remove(e)}(r),a.textures--}function f(e){var r=e.target;r.removeEventListener("dispose",f),function(e){var r=n.get(e),i=n.get(e.texture);if(!e)return;void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLRenderTargetCube)for(var o=0;o<6;o++)t.deleteFramebuffer(r.__webglFramebuffer[o]),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[o]);else t.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer);n.remove(e.texture),n.remove(e)}(r),a.textures--}function d(e,h){var f=n.get(e);if(e.version>0&&f.__version!==e.version){var d=e.image;if(void 0===d);else if(!1!==d.complete)return void function(e,n,h){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",p),e.__webglTexture=t.createTexture(),a.textures++);r.activeTexture(t.TEXTURE0+h),r.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,n.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,n.unpackAlignment);var f=l(n.image,i.maxTextureSize);d=n,(d.wrapS!==vt||d.wrapT!==vt||d.minFilter!==_t&&d.minFilter!==wt)&&!1===c(f)&&(f=function(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=ye.nearestPowerOfTwo(t.width),e.height=ye.nearestPowerOfTwo(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),e}return t}(f));var d;var g=c(f),v=o.convert(n.format),y=o.convert(n.type);m(t.TEXTURE_2D,n,g);var _,x=n.mipmaps;if(n.isDepthTexture){var b=t.DEPTH_COMPONENT;if(n.type===Rt){if(!s)throw new Error("Float Depth Texture only supported in WebGL2.0");b=t.DEPTH_COMPONENT32F}else s&&(b=t.DEPTH_COMPONENT16);n.format===Gt&&b===t.DEPTH_COMPONENT&&n.type!==Tt&&n.type!==Lt&&(n.type=Tt,y=o.convert(n.type)),n.format===Wt&&(b=t.DEPTH_STENCIL,n.type!==Ft&&(n.type=Ft,y=o.convert(n.type))),r.texImage2D(t.TEXTURE_2D,0,b,f.width,f.height,0,v,y,null)}else if(n.isDataTexture)if(x.length>0&&g){for(var w=0,S=x.length;w-1&&r.compressedTexImage2D(t.TEXTURE_2D,w,v,_.width,_.height,0,_.data):r.texImage2D(t.TEXTURE_2D,w,v,_.width,_.height,0,v,y,_.data);else if(x.length>0&&g){for(var w=0,S=x.length;w1||n.get(a).__currentAnisotropy)&&(t.texParameterf(r,l.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),n.get(a).__currentAnisotropy=a.anisotropy)}}function g(e,i,a,s){var l=o.convert(i.texture.format),c=o.convert(i.texture.type);r.texImage2D(s,0,l,i.width,i.height,0,l,c,null),t.bindFramebuffer(t.FRAMEBUFFER,e),t.framebufferTexture2D(t.FRAMEBUFFER,a,s,n.get(i.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function v(e,r){t.bindRenderbuffer(t.RENDERBUFFER,e),r.depthBuffer&&!r.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,r.width,r.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)):r.depthBuffer&&r.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,r.width,r.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)):t.renderbufferStorage(t.RENDERBUFFER,t.RGBA4,r.width,r.height),t.bindRenderbuffer(t.RENDERBUFFER,null)}function y(e){var r=n.get(e),i=!0===e.isWebGLRenderTargetCube;if(e.depthTexture){if(i)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),d(r.depthTexture,0);var i=n.get(r.depthTexture).__webglTexture;if(r.depthTexture.format===Gt)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,i,0);else{if(r.depthTexture.format!==Wt)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,i,0)}}(r.__webglFramebuffer,e)}else if(i){r.__webglDepthbuffer=[];for(var o=0;o<6;o++)t.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[o]),r.__webglDepthbuffer[o]=t.createRenderbuffer(),v(r.__webglDepthbuffer[o],e)}else t.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=t.createRenderbuffer(),v(r.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}this.setTexture2D=d,this.setTextureCube=function(e,s){var h=n.get(e);if(6===e.image.length)if(e.version>0&&h.__version!==e.version){h.__image__webglTextureCube||(e.addEventListener("dispose",p),h.__image__webglTextureCube=t.createTexture(),a.textures++),r.activeTexture(t.TEXTURE0+s),r.bindTexture(t.TEXTURE_CUBE_MAP,h.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var f=e&&e.isCompressedTexture,d=e.image[0]&&e.image[0].isDataTexture,g=[],v=0;v<6;v++)g[v]=f||d?d?e.image[v].image:e.image[v]:l(e.image[v],i.maxCubemapSize);var y=c(g[0]),_=o.convert(e.format),x=o.convert(e.type);for(m(t.TEXTURE_CUBE_MAP,e,y),v=0;v<6;v++)if(f)for(var b,w=g[v].mipmaps,S=0,M=w.length;S-1&&r.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,S,_,b.width,b.height,0,b.data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,S,_,b.width,b.height,0,_,x,b.data);else d?r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,_,g[v].width,g[v].height,0,_,x,g[v].data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,_,_,x,g[v]);u(e,y)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),h.__version=e.version,e.onUpdate&&e.onUpdate(e)}else r.activeTexture(t.TEXTURE0+s),r.bindTexture(t.TEXTURE_CUBE_MAP,h.__image__webglTextureCube)},this.setTextureCubeDynamic=function(e,i){r.activeTexture(t.TEXTURE0+i),r.bindTexture(t.TEXTURE_CUBE_MAP,n.get(e).__webglTexture)},this.setupRenderTarget=function(e){var i=n.get(e),o=n.get(e.texture);e.addEventListener("dispose",f),o.__webglTexture=t.createTexture(),a.textures++;var s=!0===e.isWebGLRenderTargetCube,l=c(e);if(s){i.__webglFramebuffer=[];for(var h=0;h<6;h++)i.__webglFramebuffer[h]=t.createFramebuffer()}else i.__webglFramebuffer=t.createFramebuffer();if(s){for(r.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),m(t.TEXTURE_CUBE_MAP,e.texture,l),h=0;h<6;h++)g(i.__webglFramebuffer[h],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+h);u(e.texture,l)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),r.bindTexture(t.TEXTURE_CUBE_MAP,null)}else r.bindTexture(t.TEXTURE_2D,o.__webglTexture),m(t.TEXTURE_2D,e.texture,l),g(i.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),u(e.texture,l)&&t.generateMipmap(t.TEXTURE_2D),r.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&y(e)},this.updateRenderTargetMipmap=function(e){var i=e.texture;if(u(i,c(e))){var o=e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=n.get(i).__webglTexture;r.bindTexture(o,a),t.generateMipmap(o),r.bindTexture(o,null)}}}function Fo(t){Yn.call(this),this.cameras=t||[]}function zo(t,e){return{convert:function(r){var n;if(r===gt)return t.REPEAT;if(r===vt)return t.CLAMP_TO_EDGE;if(r===yt)return t.MIRRORED_REPEAT;if(r===_t)return t.NEAREST;if(r===xt)return t.NEAREST_MIPMAP_NEAREST;if(r===bt)return t.NEAREST_MIPMAP_LINEAR;if(r===wt)return t.LINEAR;if(r===St)return t.LINEAR_MIPMAP_NEAREST;if(r===Mt)return t.LINEAR_MIPMAP_LINEAR;if(r===At)return t.UNSIGNED_BYTE;if(r===It)return t.UNSIGNED_SHORT_4_4_4_4;if(r===Ot)return t.UNSIGNED_SHORT_5_5_5_1;if(r===Dt)return t.UNSIGNED_SHORT_5_6_5;if(r===Et)return t.BYTE;if(r===Ct)return t.SHORT;if(r===Tt)return t.UNSIGNED_SHORT;if(r===Pt)return t.INT;if(r===Lt)return t.UNSIGNED_INT;if(r===Rt)return t.FLOAT;if(r===Nt&&null!==(n=e.get("OES_texture_half_float")))return n.HALF_FLOAT_OES;if(r===zt)return t.ALPHA;if(r===kt)return t.RGB;if(r===Ut)return t.RGBA;if(r===Bt)return t.LUMINANCE;if(r===Vt)return t.LUMINANCE_ALPHA;if(r===Gt)return t.DEPTH_COMPONENT;if(r===Wt)return t.DEPTH_STENCIL;if(r===R)return t.FUNC_ADD;if(r===N)return t.FUNC_SUBTRACT;if(r===I)return t.FUNC_REVERSE_SUBTRACT;if(r===F)return t.ZERO;if(r===z)return t.ONE;if(r===k)return t.SRC_COLOR;if(r===U)return t.ONE_MINUS_SRC_COLOR;if(r===B)return t.SRC_ALPHA;if(r===V)return t.ONE_MINUS_SRC_ALPHA;if(r===j)return t.DST_ALPHA;if(r===G)return t.ONE_MINUS_DST_ALPHA;if(r===W)return t.DST_COLOR;if(r===H)return t.ONE_MINUS_DST_COLOR;if(r===X)return t.SRC_ALPHA_SATURATE;if((r===Ht||r===Xt||r===Yt||r===qt)&&null!==(n=e.get("WEBGL_compressed_texture_s3tc"))){if(r===Ht)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===Xt)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===Yt)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===qt)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((r===Zt||r===$t||r===Kt||r===Qt)&&null!==(n=e.get("WEBGL_compressed_texture_pvrtc"))){if(r===Zt)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===$t)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===Kt)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Qt)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(r===Jt&&null!==(n=e.get("WEBGL_compressed_texture_etc1")))return n.COMPRESSED_RGB_ETC1_WEBGL;if((r===O||r===D)&&null!==(n=e.get("EXT_blend_minmax"))){if(r===O)return n.MIN_EXT;if(r===D)return n.MAX_EXT}return r===Ft&&null!==(n=e.get("WEBGL_depth_texture"))?n.UNSIGNED_INT_24_8_WEBGL:0}}}function ko(t){var e=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),r=void 0!==t.context?t.context:null,n=void 0!==t.alpha&&t.alpha,i=void 0===t.depth||t.depth,o=void 0===t.stencil||t.stencil,a=void 0!==t.antialias&&t.antialias,s=void 0===t.premultipliedAlpha||t.premultipliedAlpha,l=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,c=[],u=[],h=null,g=[],v=[];this.domElement=e,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=ot,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var y,_,S,M,R,N,I,O,D,F,z,k,U,B,V,j,G,W,H,X=this,et=!1,rt=null,nt=null,it=-1,at="",st=null,lt=null,ct=new Ve,ut=new Ve,ht=null,pt=0,ft=e.width,dt=e.height,mt=1,gt=new Ve(0,0,ft,dt),vt=new Ve(0,0,ft,dt),yt=!1,_t=new bn,xt=new function(){var t=this,e=null,r=0,n=!1,i=!1,o=new xn,a=new _n,s={value:null,needsUpdate:!1};function l(){s.value!==e&&(s.value=e,s.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function c(e,r,n,i){var l=null!==e?e.length:0,c=null;if(0!==l){if(c=s.value,!0!==i||null===c){var u=n+4*l,h=r.matrixWorldInverse;a.getNormalMatrix(h),(null===c||c.length0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var o=void 0!==r.precision?r.precision:"highp",a=i(o);a!==o&&(o=a);var s=!0===r.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),l=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),c=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_TEXTURE_SIZE),h=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),p=t.getParameter(t.MAX_VERTEX_ATTRIBS),f=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),d=t.getParameter(t.MAX_VARYING_VECTORS),m=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),g=c>0,v=!!e.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==n)return n;var r=e.get("EXT_texture_filter_anisotropic");return n=null!==r?t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:s,maxTextures:l,maxVertexTextures:c,maxTextureSize:u,maxCubemapSize:h,maxAttributes:p,maxVertexUniforms:f,maxVaryings:d,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v}}(y,_,t),(M=new function(t,e,r){var n=new function(){var e=!1,r=new Ve,n=null,i=new Ve(0,0,0,0);return{setMask:function(r){n===r||e||(t.colorMask(r,r,r,r),n=r)},setLocked:function(t){e=t},setClear:function(e,n,o,a,s){!0===s&&(e*=a,n*=a,o*=a),r.set(e,n,o,a),!1===i.equals(r)&&(t.clearColor(e,n,o,a),i.copy(r))},reset:function(){e=!1,n=null,i.set(-1,0,0,0)}}},i=new function(){var e=!1,r=null,n=null,i=null;return{setTest:function(e){e?X(t.DEPTH_TEST):et(t.DEPTH_TEST)},setMask:function(n){r===n||e||(t.depthMask(n),r=n)},setFunc:function(e){if(n!==e){if(e)switch(e){case Y:t.depthFunc(t.NEVER);break;case q:t.depthFunc(t.ALWAYS);break;case Z:t.depthFunc(t.LESS);break;case $:t.depthFunc(t.LEQUAL);break;case K:t.depthFunc(t.EQUAL);break;case Q:t.depthFunc(t.GEQUAL);break;case J:t.depthFunc(t.GREATER);break;case tt:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}else t.depthFunc(t.LEQUAL);n=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,r=null,n=null,i=null}}},o=new function(){var e=!1,r=null,n=null,i=null,o=null,a=null,s=null,l=null,c=null;return{setTest:function(e){e?X(t.STENCIL_TEST):et(t.STENCIL_TEST)},setMask:function(n){r===n||e||(t.stencilMask(n),r=n)},setFunc:function(e,r,a){n===e&&i===r&&o===a||(t.stencilFunc(e,r,a),n=e,i=r,o=a)},setOp:function(e,r,n){a===e&&s===r&&l===n||(t.stencilOp(e,r,n),a=e,s=r,l=n)},setLocked:function(t){e=t},setClear:function(e){c!==e&&(t.clearStencil(e),c=e)},reset:function(){e=!1,r=null,n=null,i=null,o=null,a=null,s=null,l=null,c=null}}},a=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=new Uint8Array(a),l=new Uint8Array(a),c=new Uint8Array(a),u={},h=null,m=null,g=null,v=null,y=null,_=null,w=null,S=null,M=null,R=!1,N=null,I=null,O=null,D=null,F=null,z=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),k=parseFloat(/^WebGL\ ([0-9])/.exec(t.getParameter(t.VERSION))[1]),U=parseFloat(k)>=1,B=null,V={},j=new Ve,G=new Ve;function W(e,r,n){var i=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var a=0;a65535?Wi:ji)(a,1),e.update(n,t.ELEMENT_ARRAY_BUFFER),i[r.id]=n,n}}}(y,I,Et),D=new function(t,e){var r={};return{update:function(n){var i=e.frame,o=n.geometry,a=t.get(n,o);return r[a.id]!==i&&(o.isGeometry&&a.updateFromObject(n),t.update(a),r[a.id]=i),a},clear:function(){r={}}}}(O,Ct),B=new function(t){var e={},r=new Float32Array(8);return{update:function(n,i,o,a){var s=n.morphTargetInfluences,l=s.length,c=e[i.id];if(void 0===c){c=[];for(var u=0;u=0){var c=i[s];if(void 0!==c){var u=c.normalized,h=c.itemSize,p=I.get(c);if(void 0===p)continue;var f=p.buffer,d=p.type,m=p.bytesPerElement;if(c.isInterleavedBufferAttribute){var g=c.data,v=g.stride,x=c.offset;g&&g.isInstancedInterleavedBuffer?(M.enableAttributeAndDivisor(l,g.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=g.meshPerAttribute*g.count)):M.enableAttribute(l),y.bindBuffer(y.ARRAY_BUFFER,f),y.vertexAttribPointer(l,h,d,u,v*m,(n*v+x)*m)}else c.isInstancedBufferAttribute?(M.enableAttributeAndDivisor(l,c.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=c.meshPerAttribute*c.count)):M.enableAttribute(l),y.bindBuffer(y.ARRAY_BUFFER,f),y.vertexAttribPointer(l,h,d,u,0,n*h*m)}else if(void 0!==a){var b=a[s];if(void 0!==b)switch(b.length){case 2:y.vertexAttrib2fv(l,b);break;case 3:y.vertexAttrib3fv(l,b);break;case 4:y.vertexAttrib4fv(l,b);break;default:y.vertexAttrib1fv(l,b)}}}}M.disableUnusedAttributes()}(n,a,r),null!==u&&y.bindBuffer(y.ELEMENT_ARRAY_BUFFER,c.buffer));var d=0;null!==u?d=u.count:void 0!==h&&(d=h.count);var m=r.drawRange.start*p,g=r.drawRange.count*p,v=null!==o?o.start*p:0,x=null!==o?o.count*p:1/0,b=Math.max(m,v),w=Math.min(d,m+g,v+x)-1,S=Math.max(0,w-b+1);if(0!==S){if(i.isMesh)if(!0===n.wireframe)M.setLineWidth(n.wireframeLinewidth*Tt()),f.setMode(y.LINES);else switch(i.drawMode){case ae:f.setMode(y.TRIANGLES);break;case se:f.setMode(y.TRIANGLE_STRIP);break;case le:f.setMode(y.TRIANGLE_FAN)}else if(i.isLine){var A=n.linewidth;void 0===A&&(A=1),M.setLineWidth(A*Tt()),i.isLineSegments?f.setMode(y.LINES):i.isLineLoop?f.setMode(y.LINE_LOOP):f.setMode(y.LINE_STRIP)}else i.isPoints&&f.setMode(y.POINTS);r&&r.isInstancedBufferGeometry?r.maxInstancedCount>0&&f.renderInstances(r,b,S):f.render(b,S)}},this.compile=function(t,e){c.length=0,u.length=0,t.traverse(function(t){t.isLight&&(c.push(t),t.castShadow&&u.push(t))}),F.setup(c,u,e),t.traverse(function(e){if(e.material)if(Array.isArray(e.material))for(var r=0;r=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(h=0;h=0&&t.numSupportedMorphNormals++}var p=n.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=xt.numPlanes,n.numIntersection=xt.numIntersection,p.clippingPlanes=xt.uniform),n.fog=e,n.lightsHash=F.state.hash,t.lights&&(p.ambientLightColor.value=F.state.ambient,p.directionalLights.value=F.state.directional,p.spotLights.value=F.state.spot,p.rectAreaLights.value=F.state.rectArea,p.pointLights.value=F.state.point,p.hemisphereLights.value=F.state.hemi,p.directionalShadowMap.value=F.state.directionalShadowMap,p.directionalShadowMatrix.value=F.state.directionalShadowMatrix,p.spotShadowMap.value=F.state.spotShadowMap,p.spotShadowMatrix.value=F.state.spotShadowMatrix,p.pointShadowMap.value=F.state.pointShadowMap,p.pointShadowMatrix.value=F.state.pointShadowMatrix);var f=n.program.getUniforms(),d=Ir.seqWithValue(f.seq,p);n.uniformsList=d}function Zt(t,e,r,n){pt=0;var i=R.get(r);if(bt&&(wt||t!==st)){var o=t===st&&r.id===it;xt.setState(r.clippingPlanes,r.clipIntersection,r.clipShadows,t,i,o)}!1===r.needsUpdate&&(void 0===i.program?r.needsUpdate=!0:r.fog&&i.fog!==e?r.needsUpdate=!0:r.lights&&i.lightsHash!==F.state.hash?r.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===xt.numPlanes&&i.numIntersection===xt.numIntersection||(r.needsUpdate=!0)),r.needsUpdate&&(qt(r,e,n),r.needsUpdate=!1);var a,s,l,c,u,h,p,f,d,m,g,v,_,x,b,w,A=!1,E=!1,C=!1,T=i.program,P=T.getUniforms(),L=i.shader.uniforms;if(M.useProgram(T.program)&&(A=!0,E=!0,C=!0),r.id!==it&&(it=r.id,E=!0),A||t!==st){if(P.setValue(y,"projectionMatrix",t.projectionMatrix),S.logarithmicDepthBuffer&&P.setValue(y,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),st!==(lt||t)&&(st=lt||t,E=!0,C=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var N=P.map.cameraPosition;void 0!==N&&N.setValue(y,Mt.setFromMatrixPosition(t.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&P.setValue(y,"viewMatrix",t.matrixWorldInverse)}if(r.skinning){P.setOptional(y,n,"bindMatrix"),P.setOptional(y,n,"bindMatrixInverse");var I=n.skeleton;if(I){var O=I.bones;if(S.floatVertexTextures){if(void 0===I.boneTexture){var D=Math.sqrt(4*O.length);D=ye.nextPowerOfTwo(Math.ceil(D)),D=Math.max(D,4);var z=new Float32Array(D*D*4);z.set(I.boneMatrices);var k=new Ye(z,D,D,Ut,Rt);I.boneMatrices=z,I.boneTexture=k,I.boneTextureSize=D}P.setValue(y,"boneTexture",I.boneTexture),P.setValue(y,"boneTextureSize",I.boneTextureSize)}else P.setOptional(y,I,"boneMatrices")}}return(E||r.forceUniformsUpdate)&&(P.setValue(y,"toneMappingExposure",X.toneMappingExposure),P.setValue(y,"toneMappingWhitePoint",X.toneMappingWhitePoint),r.lights&&(w=C,(b=L).ambientLightColor.needsUpdate=w,b.directionalLights.needsUpdate=w,b.pointLights.needsUpdate=w,b.spotLights.needsUpdate=w,b.rectAreaLights.needsUpdate=w,b.hemisphereLights.needsUpdate=w),e&&r.fog&&(x=e,(_=L).fogColor.value=x.color,x.isFog?(_.fogNear.value=x.near,_.fogFar.value=x.far):x.isFogExp2&&(_.fogDensity.value=x.density)),r.isMeshBasicMaterial?$t(L,r):r.isMeshLambertMaterial?($t(L,r),g=L,(v=r).emissiveMap&&(g.emissiveMap.value=v.emissiveMap)):r.isMeshPhongMaterial?($t(L,r),r.isMeshToonMaterial?(Kt(d=L,m=r),m.gradientMap&&(d.gradientMap.value=m.gradientMap)):Kt(L,r)):r.isMeshStandardMaterial?($t(L,r),r.isMeshPhysicalMaterial?(f=r,(p=L).clearCoat.value=f.clearCoat,p.clearCoatRoughness.value=f.clearCoatRoughness,Qt(p,f)):Qt(L,r)):r.isMeshDepthMaterial?($t(L,r),u=L,(h=r).displacementMap&&(u.displacementMap.value=h.displacementMap,u.displacementScale.value=h.displacementScale,u.displacementBias.value=h.displacementBias)):r.isMeshDistanceMaterial?($t(L,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(L,r)):r.isMeshNormalMaterial?($t(L,r),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale);e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale));e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(L,r)):r.isLineBasicMaterial?(c=r,(l=L).diffuse.value=c.color,l.opacity.value=c.opacity,r.isLineDashedMaterial&&(s=r,(a=L).dashSize.value=s.dashSize,a.totalSize.value=s.dashSize+s.gapSize,a.scale.value=s.scale)):r.isPointsMaterial?function(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*mt,t.scale.value=.5*dt,t.map.value=e.map,null!==e.map){var r=e.map.offset,n=e.map.repeat;t.offsetRepeat.value.set(r.x,r.y,n.x,n.y)}}(L,r):r.isShadowMaterial&&(L.color.value=r.color,L.opacity.value=r.opacity),void 0!==L.ltcMat&&(L.ltcMat.value=kr.LTC_MAT_TEXTURE),void 0!==L.ltcMag&&(L.ltcMag.value=kr.LTC_MAG_TEXTURE),Ir.upload(y,i.uniformsList,L,X)),P.setValue(y,"modelViewMatrix",n.modelViewMatrix),P.setValue(y,"normalMatrix",n.normalMatrix),P.setValue(y,"modelMatrix",n.matrixWorld),T}function $t(t,e){var r;if(t.opacity.value=e.opacity,e.color&&(t.diffuse.value=e.color),e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.specularMap&&(t.specularMap.value=e.specularMap),e.envMap&&(t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap&&e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity),e.map?r=e.map:e.specularMap?r=e.specularMap:e.displacementMap?r=e.displacementMap:e.normalMap?r=e.normalMap:e.bumpMap?r=e.bumpMap:e.roughnessMap?r=e.roughnessMap:e.metalnessMap?r=e.metalnessMap:e.alphaMap?r=e.alphaMap:e.emissiveMap&&(r=e.emissiveMap),void 0!==r){r.isWebGLRenderTarget&&(r=r.texture);var n=r.offset,i=r.repeat;t.offsetRepeat.value.set(n.x,n.y,i.x,i.y)}}function Kt(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function Qt(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}this.animate=function(t){Wt=t,Gt||((It.getDevice()||window).requestAnimationFrame(Ht),Gt=!0)},this.render=function(t,e,r,n){if(e&&e.isCamera&&!et){at="",it=-1,st=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),It.enabled&&(e=It.getCamera(e)),St.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),_t.setFromMatrix(St),c.length=0,u.length=0,g.length=0,v.length=0,wt=this.localClippingEnabled,bt=xt.init(this.clippingPlanes,wt,e),(h=k.get(t,e)).init(),function t(e,r,n){if(!e.visible)return;var i=e.layers.test(r.layers);if(i)if(e.isLight)c.push(e),e.castShadow&&u.push(e);else if(e.isSprite)e.frustumCulled&&!_t.intersectsSprite(e)||g.push(e);else if(e.isLensFlare)v.push(e);else if(e.isImmediateRenderObject)n&&Mt.setFromMatrixPosition(e.matrixWorld).applyMatrix4(St),h.push(e,null,e.material,Mt.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.update(),!e.frustumCulled||_t.intersectsObject(e))){n&&Mt.setFromMatrixPosition(e.matrixWorld).applyMatrix4(St);var o=D.update(e),a=e.material;if(Array.isArray(a))for(var s=o.groups,l=0,p=s.length;l=0&&e<=t.width-n&&r>=0&&r<=t.height-i&&y.readPixels(e,r,n,i,H.convert(c),H.convert(u),o)}finally{s&&y.bindFramebuffer(y.FRAMEBUFFER,nt)}}}}}function Uo(t,e){this.name="",this.color=new Dr(t),this.density=void 0!==e?e:25e-5}function Bo(t,e,r){this.name="",this.color=new Dr(t),this.near=void 0!==e?e:1,this.far=void 0!==r?r:1e3}function Vo(){Wn.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function jo(t,e,r,n,i){Wn.call(this),this.lensFlares=[],this.positionScreen=new He,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,r,n,i)}function Go(t){fn.call(this),this.type="SpriteMaterial",this.color=new Dr(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function Wo(t){Wn.call(this),this.type="Sprite",this.material=void 0!==t?t:new Go}function Ho(){Wn.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Xo(t,e){if(t=t||[],this.bones=t.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{this.boneInverses=[];for(var r=0,n=this.bones.length;r=t.HAVE_CURRENT_DATA&&(c.needsUpdate=!0)}()}function na(t,e,r,n,i,o,a,s,l,c,u,h){Be.call(this,null,o,a,s,l,c,n,i,u,h),this.image={width:e,height:r},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function ia(t,e,r,n,i,o,a,s,l,c){if((c=void 0!==c?c:Gt)!==Gt&&c!==Wt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&c===Gt&&(r=Tt),void 0===r&&c===Wt&&(r=Ft),Be.call(this,null,n,i,o,a,s,c,r,l),this.image={width:t,height:e},this.magFilter=void 0!==a?a:_t,this.minFilter=void 0!==s?s:_t,this.flipY=!1,this.generateMipmaps=!1}function oa(t){Zi.call(this),this.type="WireframeGeometry";var e,r,n,i,o,a,s,l,c,u,h=[],p=[0,0],f={},d=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(e=0,n=m.length;e=0?(h=t(g-1e-5,m,h),p.subVectors(u,h)):(h=t(g+1e-5,m,h),p.subVectors(h,u)),m-1e-5>=0?(h=t(g,m-1e-5,h),f.subVectors(u,h)):(h=t(g,m+1e-5,h),f.subVectors(h,u)),c.crossVectors(p,f).normalize(),s.push(c.x,c.y,c.z),l.push(g,m)}}for(n=0;n.9&&a<.1&&(e<.2&&(o[t+0]+=1),r<.2&&(o[t+2]+=1),n<.2&&(o[t+4]+=1))}}()}(),this.addAttribute("position",new Hi(i,3)),this.addAttribute("normal",new Hi(i.slice(),3)),this.addAttribute("uv",new Hi(o,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}function ua(t,e){Fi.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new ha(t,e)),this.mergeVertices()}function ha(t,e){ca.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],t,e),this.type="TetrahedronBufferGeometry",this.parameters={radius:t,detail:e}}function pa(t,e){Fi.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new fa(t,e)),this.mergeVertices()}function fa(t,e){ca.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],t,e),this.type="OctahedronBufferGeometry",this.parameters={radius:t,detail:e}}function da(t,e){Fi.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new ma(t,e)),this.mergeVertices()}function ma(t,e){var r=(1+Math.sqrt(5))/2,n=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1];ca.call(this,n,[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],t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function ga(t,e){Fi.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new va(t,e)),this.mergeVertices()}function va(t,e){var r=(1+Math.sqrt(5))/2,n=1/r,i=[-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,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n];ca.call(this,i,[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],t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function ya(t,e,r,n,i,o){Fi.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:r,radialSegments:n,closed:i};var a=new _a(t,e,r,n,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function _a(t,e,r,n,i){Zi.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:r,radialSegments:n,closed:i},e=e||64,r=r||1,n=n||8,i=i||!1;var o=t.computeFrenetFrames(e,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;var a,s,l=new He,c=new He,u=new _e,h=[],p=[],f=[],d=[];function m(i){var a=t.getPointAt(i/e),u=o.normals[i],f=o.binormals[i];for(s=0;s<=n;s++){var d=s/n*Math.PI*2,m=Math.sin(d),g=-Math.cos(d);c.x=g*u.x+m*f.x,c.y=g*u.y+m*f.y,c.z=g*u.z+m*f.z,c.normalize(),p.push(c.x,c.y,c.z),l.x=a.x+r*c.x,l.y=a.y+r*c.y,l.z=a.z+r*c.z,h.push(l.x,l.y,l.z)}}!function(){for(a=0;ar)){var n=t.ray.origin.distanceTo(ho);nt.far||e.push({distance:n,point:ho.clone(),face:null,object:this})}}),clone:function(){return new this.constructor(this.material).copy(this)}}),Ho.prototype=Object.assign(Object.create(Wn.prototype),{constructor:Ho,copy:function(t){Wn.prototype.copy.call(this,t,!1);for(var e=t.levels,r=0,n=e.length;r1){mo.setFromMatrixPosition(t.matrixWorld),go.setFromMatrixPosition(this.matrixWorld);var r=mo.distanceTo(go);e[0].object.visible=!0;for(var n=1,i=e.length;n=e[n].distance;n++)e[n-1].object.visible=!1,e[n].object.visible=!0;for(;nn||(c.applyMatrix4(this.matrixWorld),(x=t.ray.origin.distanceTo(c))t.far||e.push({distance:x,point:l.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this}))}else for(d=0,m=p.length/3-1;dn||(c.applyMatrix4(this.matrixWorld),(x=t.ray.origin.distanceTo(c))t.far||e.push({distance:x,point:l.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this}))}else if(i.isGeometry){var y=i.vertices,_=y.length;for(d=0;d<_-1;d+=u){var x;bo.distanceSqToSegment(y[d],y[d+1],c,l)>n||(c.applyMatrix4(this.matrixWorld),(x=t.ray.origin.distanceTo(c))t.far||e.push({distance:x,point:l.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this}))}}}}),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Ko.prototype=Object.assign(Object.create($o.prototype),{constructor:Ko,isLineSegments:!0}),Qo.prototype=Object.assign(Object.create($o.prototype),{constructor:Qo,isLineLoop:!0}),Jo.prototype=Object.create(fn.prototype),Jo.prototype.constructor=Jo,Jo.prototype.isPointsMaterial=!0,Jo.prototype.copy=function(t){return fn.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},ta.prototype=Object.assign(Object.create(Wn.prototype),{constructor:ta,isPoints:!0,raycast:(So=new Xe,Mo=new eo,Ao=new yn,function(t,e){var r=this,n=this.geometry,i=this.matrixWorld,o=t.params.Points.threshold;if(null===n.boundingSphere&&n.computeBoundingSphere(),Ao.copy(n.boundingSphere),Ao.applyMatrix4(i),Ao.radius+=o,!1!==t.ray.intersectsSphere(Ao)){So.getInverse(i),Mo.copy(t.ray).applyMatrix4(So);var a=o/((this.scale.x+this.scale.y+this.scale.z)/3),s=a*a,l=new He;if(n.isBufferGeometry){var c=n.index,u=n.attributes.position.array;if(null!==c)for(var h=c.array,p=0,f=h.length;pt.far)return;e.push({distance:c,distanceToRay:Math.sqrt(a),point:l.clone(),index:o,face:null,object:r})}}}),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),ea.prototype=Object.assign(Object.create(Wn.prototype),{constructor:ea}),ra.prototype=Object.create(Be.prototype),ra.prototype.constructor=ra,na.prototype=Object.create(Be.prototype),na.prototype.constructor=na,na.prototype.isCompressedTexture=!0,ia.prototype=Object.create(Be.prototype),ia.prototype.constructor=ia,ia.prototype.isDepthTexture=!0,oa.prototype=Object.create(Zi.prototype),oa.prototype.constructor=oa,aa.prototype=Object.create(Fi.prototype),aa.prototype.constructor=aa,sa.prototype=Object.create(Zi.prototype),sa.prototype.constructor=sa,la.prototype=Object.create(Fi.prototype),la.prototype.constructor=la,ca.prototype=Object.create(Zi.prototype),ca.prototype.constructor=ca,ua.prototype=Object.create(Fi.prototype),ua.prototype.constructor=ua,ha.prototype=Object.create(ca.prototype),ha.prototype.constructor=ha,pa.prototype=Object.create(Fi.prototype),pa.prototype.constructor=pa,fa.prototype=Object.create(ca.prototype),fa.prototype.constructor=fa,da.prototype=Object.create(Fi.prototype),da.prototype.constructor=da,ma.prototype=Object.create(ca.prototype),ma.prototype.constructor=ma,ga.prototype=Object.create(Fi.prototype),ga.prototype.constructor=ga,va.prototype=Object.create(ca.prototype),va.prototype.constructor=va,ya.prototype=Object.create(Fi.prototype),ya.prototype.constructor=ya,_a.prototype=Object.create(Zi.prototype),_a.prototype.constructor=_a,xa.prototype=Object.create(Fi.prototype),xa.prototype.constructor=xa,ba.prototype=Object.create(Zi.prototype),ba.prototype.constructor=ba,wa.prototype=Object.create(Fi.prototype),wa.prototype.constructor=wa,Sa.prototype=Object.create(Zi.prototype),Sa.prototype.constructor=Sa;var Ma={area:function(t){for(var e=t.length,r=0,n=e-1,i=0;i=-Number.EPSILON&&w>=-Number.EPSILON&&b>=-Number.EPSILON))return!1;return!0}return function(e,r){var n=e.length;if(n<3)return null;var i,o,a,s=[],l=[],c=[];if(Ma.area(e)>0)for(o=0;o2;){if(h--<=0)return r?c:s;if(u<=(i=o)&&(i=0),u<=(o=i+1)&&(o=0),u<=(a=o+1)&&(a=0),t(e,i,o,a,u,l)){var p,f,d,m,g;for(p=l[i],f=l[o],d=l[a],s.push([e[p],e[f],e[d]]),c.push([l[i],l[o],l[a]]),m=o,g=o+1;g2&&t[e-1].equals(t[0])&&t.pop()}function n(t,e,r){return t.x!==e.x?t.xNumber.EPSILON){var d;if(p>0){if(f<0||f>p)return[];if((d=c*u-l*h)<0||d>p)return[]}else{if(f>0||f0||dS?[]:y===S?o?[]:[g]:_<=S?[g,v]:[g,b])}function o(t,e,r,n){var i=e.x-t.x,o=e.y-t.y,a=r.x-t.x,s=r.y-t.y,l=n.x-t.x,c=n.y-t.y,u=i*s-o*a,h=i*c-o*l;if(Math.abs(u)>Number.EPSILON){var p=l*s-c*a;return u>0?h>=0&&p>=0:h>=0||p>=0}return h>0}r(t),e.forEach(r);for(var a,s,l,c,u,h,p={},f=t.concat(),d=0,m=e.length;di&&(s=0);var l=o(n[t],n[a],n[s],r[e]);if(!l)return!1;var c=r.length-1,u=e-1;u<0&&(u=c);var h=e+1;return h>c&&(h=0),!!(l=o(r[e],r[u],r[h],n[t]))}function s(t,e){var r,o;for(r=0;r0)return!0;return!1}var l=[];function c(t,r){var n,o,a,s;for(n=0;n0)return!0;return!1}for(var u,h,p,f,d,m,g,v,y,_,x=[],b=0,w=e.length;b0&&!(--M<0);)for(h=S;h=0)break;x[m]=!0}if(u>=0)break}return n}(t,e),v=Ma.triangulate(g,!1);for(a=0,s=v.length;a0)&&d.push(b,w,M),(l!==r-1||c0&&v(!0),e>0&&v(!1)),this.setIndex(c),this.addAttribute("position",new Hi(u,3)),this.addAttribute("normal",new Hi(h,3)),this.addAttribute("uv",new Hi(p,2))}function Ba(t,e,r,n,i,o,a){ka.call(this,0,t,e,r,n,i,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:o,thetaLength:a}}function Va(t,e,r,n,i,o,a){Ua.call(this,0,t,e,r,n,i,o,a),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:o,thetaLength:a}}function ja(t,e,r,n){Fi.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},this.fromBufferGeometry(new Ga(t,e,r,n)),this.mergeVertices()}function Ga(t,e,r,n){Zi.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},t=t||50,e=void 0!==e?Math.max(3,e):8,r=void 0!==r?r:0,n=void 0!==n?n:2*Math.PI;var i,o,a=[],s=[],l=[],c=[],u=new He,h=new _e;for(s.push(0,0,0),l.push(0,0,1),c.push(.5,.5),o=0,i=3;o<=e;o++,i+=3){var p=r+o/e*n;u.x=t*Math.cos(p),u.y=t*Math.sin(p),s.push(u.x,u.y,u.z),l.push(0,0,1),h.x=(s[i]/t+1)/2,h.y=(s[i+1]/t+1)/2,c.push(h.x,h.y)}for(i=1;i<=e;i++)a.push(i,i+1,0);this.setIndex(a),this.addAttribute("position",new Hi(s,3)),this.addAttribute("normal",new Hi(l,3)),this.addAttribute("uv",new Hi(c,2))}Aa.prototype=Object.create(Fi.prototype),Aa.prototype.constructor=Aa,Ea.prototype=Object.create(Zi.prototype),Ea.prototype.constructor=Ea,Ea.prototype.getArrays=function(){var t=this.getAttribute("position"),e=t?Array.prototype.slice.call(t.array):[],r=this.getAttribute("uv"),n=r?Array.prototype.slice.call(r.array):[],i=this.index;return{position:e,uv:n,index:i?Array.prototype.slice.call(i.array):[]}},Ea.prototype.addShapeList=function(t,e){var r=t.length;e.arrays=this.getArrays();for(var n=0;nNumber.EPSILON){var p=Math.sqrt(u),f=Math.sqrt(l*l+c*c),d=e.x-s/p,m=e.y+a/p,g=((r.x-c/f-d)*c-(r.y+l/f-m)*l)/(a*c-s*l),v=(n=d+a*g-t.x)*n+(i=m+s*g-t.y)*i;if(v<=2)return new _e(n,i);o=Math.sqrt(v/2)}else{var y=!1;a>Number.EPSILON?l>Number.EPSILON&&(y=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(c)&&(y=!0),y?(n=-s,i=a,o=Math.sqrt(u)):(n=a,i=s,o=Math.sqrt(u/2))}return new _e(n/o,i/o)}for(var V=[],j=0,G=L.length,W=G-1,H=j+1;j=0;N--){for(O=N/y,D=g*Math.cos(O*Math.PI/2),I=v*Math.sin(O*Math.PI/2),j=0,G=L.length;j=0;){r=j,(n=j-1)<0&&(n=t.length-1);var i=0,o=b+2*y;for(i=0;i0||0===t.search(/^data\:image\/jpeg/);o.format=r?kt:Ut,o.needsUpdate=!0,void 0!==e&&e(o)},r,n),o},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),us.prototype=Object.assign(Object.create(Wn.prototype),{constructor:us,isLight:!0,copy:function(t){return Wn.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=Wn.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),hs.prototype=Object.assign(Object.create(us.prototype),{constructor:hs,isHemisphereLight:!0,copy:function(t){return us.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(ps.prototype,{copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t={};return 0!==this.bias&&(t.bias=this.bias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),fs.prototype=Object.assign(Object.create(ps.prototype),{constructor:fs,isSpotLightShadow:!0,update:function(t){var e=this.camera,r=2*ye.RAD2DEG*t.angle,n=this.mapSize.width/this.mapSize.height,i=t.distance||e.far;r===e.fov&&n===e.aspect&&i===e.far||(e.fov=r,e.aspect=n,e.far=i,e.updateProjectionMatrix())}}),ds.prototype=Object.assign(Object.create(us.prototype),{constructor:ds,isSpotLight:!0,copy:function(t){return us.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),ms.prototype=Object.assign(Object.create(us.prototype),{constructor:ms,isPointLight:!0,copy:function(t){return us.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),gs.prototype=Object.assign(Object.create(ps.prototype),{constructor:gs}),vs.prototype=Object.assign(Object.create(us.prototype),{constructor:vs,isDirectionalLight:!0,copy:function(t){return us.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),ys.prototype=Object.assign(Object.create(us.prototype),{constructor:ys,isAmbientLight:!0}),_s.prototype=Object.assign(Object.create(us.prototype),{constructor:_s,isRectAreaLight:!0,copy:function(t){return us.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){var e=us.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});var xs,bs={arraySlice:function(t,e,r){return bs.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==r?r:t.length)):t.slice(e,r)},convertArray:function(t,e,r){return!t||!r&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){for(var e=t.length,r=new Array(e),n=0;n!==e;++n)r[n]=n;return r.sort(function(e,r){return t[e]-t[r]}),r},sortedArray:function(t,e,r){for(var n=t.length,i=new t.constructor(n),o=0,a=0;a!==n;++o)for(var s=r[o]*e,l=0;l!==e;++l)i[a++]=t[s+l];return i},flattenJSON:function(t,e,r,n){for(var i=1,o=t[0];void 0!==o&&void 0===o[n];)o=t[i++];if(void 0!==o){var a=o[n];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[n])&&(e.push(o.time),r.push.apply(r,a)),o=t[i++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[n])&&(e.push(o.time),a.toArray(r,r.length)),o=t[i++]}while(void 0!==o);else do{void 0!==(a=o[n])&&(e.push(o.time),r.push(a)),o=t[i++]}while(void 0!==o)}}};function ws(t,e,r,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(r),this.sampleValues=e,this.valueSize=r}function Ss(t,e,r,n){ws.call(this,t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Ms(t,e,r,n){ws.call(this,t,e,r,n)}function As(t,e,r,n){ws.call(this,t,e,r,n)}function Es(t,e,r,n){if(void 0===t)throw new Error("track name is undefined");if(void 0===e||0===e.length)throw new Error("no keyframes in track named "+t);this.name=t,this.times=bs.convertArray(e,this.TimeBufferType),this.values=bs.convertArray(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation),this.validate(),this.optimize()}function Cs(t,e,r,n){Es.call(this,t,e,r,n)}function Ts(t,e,r,n){ws.call(this,t,e,r,n)}function Ps(t,e,r,n){Es.call(this,t,e,r,n)}function Ls(t,e,r,n){Es.call(this,t,e,r,n)}function Rs(t,e,r,n){Es.call(this,t,e,r,n)}function Ns(t,e,r){Es.call(this,t,e,r)}function Is(t,e,r,n){Es.call(this,t,e,r,n)}function Os(t,e,r,n){Es.apply(this,arguments)}function Ds(t,e,r){this.name=t,this.tracks=r,this.duration=void 0!==e?e:-1,this.uuid=ye.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function Fs(t){this.manager=void 0!==t?t:ns,this.textures={}}function zs(t){this.manager=void 0!==t?t:ns}Object.assign(ws.prototype,{evaluate:function(t){var e=this.parameterPositions,r=this._cachedIndex,n=e[r],i=e[r-1];t:{e:{var o;r:{n:if(!(t=i)break t;var s=e[1];t=(i=e[--r-1]))break e}o=r,r=0}for(;r>>1;te;)--o;if(++o,0!==i||o!==n){i>=o&&(i=(o=Math.max(o,1))-1);var a=this.getValueSize();this.times=bs.arraySlice(r,i,o),this.values=bs.arraySlice(this.values,i*a,o*a)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(t=!1);var r=this.times,n=this.values,i=r.length;0===i&&(t=!1);for(var o=null,a=0;a!==i;a++){var s=r[a];if("number"==typeof s&&isNaN(s)){t=!1;break}if(null!==o&&o>s){t=!1;break}o=s}if(void 0!==n&&bs.isTypedArray(n)){a=0;for(var l=n.length;a!==l;++a){var c=n[a];if(isNaN(c)){t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,r=this.getValueSize(),n=2302===this.getInterpolation(),i=1,o=t.length-1,a=1;a0){t[i]=t[o];for(d=o*r,m=i*r,p=0;p!==r;++p)e[m+p]=e[d+p];++i}return i!==t.length&&(this.times=bs.arraySlice(t,0,i),this.values=bs.arraySlice(e,0,i*r)),this}},Cs.prototype=Object.assign(Object.create(xs),{constructor:Cs,ValueTypeName:"vector"}),Ts.prototype=Object.assign(Object.create(ws.prototype),{constructor:Ts,interpolate_:function(t,e,r,n){for(var i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,l=(r-e)/(n-e),c=s+a;s!==c;s+=4)We.slerpFlat(i,0,o,s-a,o,s,l);return i}}),Ps.prototype=Object.assign(Object.create(xs),{constructor:Ps,ValueTypeName:"quaternion",DefaultInterpolation:re,InterpolantFactoryMethodLinear:function(t){return new Ts(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),Ls.prototype=Object.assign(Object.create(xs),{constructor:Ls,ValueTypeName:"number"}),Rs.prototype=Object.assign(Object.create(xs),{constructor:Rs,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:ee,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Ns.prototype=Object.assign(Object.create(xs),{constructor:Ns,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:ee,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Is.prototype=Object.assign(Object.create(xs),{constructor:Is,ValueTypeName:"color"}),Os.prototype=xs,xs.constructor=Os,Object.assign(Os,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=Os._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var r=[],n=[];bs.flattenJSON(t.keys,r,n,"value"),t.times=r,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)},toJSON:function(t){var e,r=t.constructor;if(void 0!==r.toJSON)e=r.toJSON(t);else{e={name:t.name,times:bs.convertArray(t.times,Array),values:bs.convertArray(t.values,Array)};var n=t.getInterpolation();n!==t.DefaultInterpolation&&(e.interpolation=n)}return e.type=t.ValueTypeName,e},_getTrackTypeForValueTypeName:function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ls;case"vector":case"vector2":case"vector3":case"vector4":return Cs;case"color":return Is;case"quaternion":return Ps;case"bool":case"boolean":return Ns;case"string":return Rs}throw new Error("Unsupported typeName: "+t)}}),Object.assign(Ds,{parse:function(t){for(var e=[],r=t.tracks,n=1/(t.fps||1),i=0,o=r.length;i!==o;++i)e.push(Os.parse(r[i]).scale(n));return new Ds(t.name,t.duration,e)},toJSON:function(t){for(var e=[],r=t.tracks,n={name:t.name,duration:t.duration,tracks:e},i=0,o=r.length;i!==o;++i)e.push(Os.toJSON(r[i]));return n},CreateFromMorphTargetSequence:function(t,e,r,n){for(var i=e.length,o=[],a=0;a1){var c=n[h=l[1]];c||(n[h]=c=[]),c.push(s)}}var u=[];for(var h in n)u.push(Ds.CreateFromMorphTargetSequence(h,n[h],e,r));return u},parseAnimation:function(t,e){if(!t)return null;for(var r=function(t,e,r,n,i){if(0!==r.length){var o=[],a=[];bs.flattenJSON(r,o,a,n),0!==o.length&&i.push(new t(e,o,a))}},n=[],i=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],l=0;l1?t.skinWeights[n+1]:0,s=r>2?t.skinWeights[n+2]:0,l=r>3?t.skinWeights[n+3]:0;e.skinWeights.push(new Ve(o,a,s,l))}if(t.skinIndices)for(n=0,i=t.skinIndices.length;n1?t.skinIndices[n+1]:0,h=r>2?t.skinIndices[n+2]:0,p=r>3?t.skinIndices[n+3]:0;e.skinIndices.push(new Ve(c,u,h,p))}e.bones=t.bones,e.bones&&e.bones.length>0&&(e.skinWeights.length!==e.skinIndices.length||(e.skinIndices.length,e.vertices.length))}(t,r),function(t,e){var r=t.scale;if(void 0!==t.morphTargets)for(var n=0,i=t.morphTargets.length;n0){var u=e.faces,h=t.morphColors[0].colors;for(n=0,i=u.length;n0&&(e.animations=r)}(t,r),r.computeFaceNormals(),r.computeBoundingSphere(),void 0===t.materials||0===t.materials.length?{geometry:r}:{geometry:r,materials:Ws.prototype.initMaterials(t.materials,e,this.crossOrigin)}}}()}),Object.assign(Xs.prototype,{load:function(t,e,r,n){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var i=this;new is(i.manager).load(t,function(t){var r=null;try{r=JSON.parse(t)}catch(t){return void(void 0!==n&&n(t))}var o=r.metadata;void 0!==o&&void 0!==o.type&&"geometry"!==o.type.toLowerCase()&&i.parse(r,e)},r,n)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var r=this.parseGeometries(t.geometries),n=this.parseImages(t.images,function(){void 0!==e&&e(a)}),i=this.parseTextures(t.textures,n),o=this.parseMaterials(t.materials,i),a=this.parseObject(t.object,r,o);return t.animations&&(a.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(a),a},parseGeometries:function(t){var e={};if(void 0!==t)for(var r=new Hs,n=new zs,i=0,o=t.length;i0){var o=new ss(new rs(e));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=t.length;a0?new qo(a,s):new io(a,s);break;case"LOD":n=new Ho;break;case"Line":n=new $o(i(t.geometry),o(t.material),t.mode);break;case"LineLoop":n=new Qo(i(t.geometry),o(t.material));break;case"LineSegments":n=new Ko(i(t.geometry),o(t.material));break;case"PointCloud":case"Points":n=new ta(i(t.geometry),o(t.material));break;case"Sprite":n=new Wo(o(t.material));break;case"Group":n=new ea;break;default:n=new Wn}if(n.uuid=t.uuid,void 0!==t.name&&(n.name=t.name),void 0!==t.matrix?(js.fromArray(t.matrix),js.decompose(n.position,n.quaternion,n.scale)):(void 0!==t.position&&n.position.fromArray(t.position),void 0!==t.rotation&&n.rotation.fromArray(t.rotation),void 0!==t.quaternion&&n.quaternion.fromArray(t.quaternion),void 0!==t.scale&&n.scale.fromArray(t.scale)),void 0!==t.castShadow&&(n.castShadow=t.castShadow),void 0!==t.receiveShadow&&(n.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(n.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(n.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&n.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(n.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.children)for(var l=t.children,c=0;c0)){l=i;break}l=i-1}if(n[i=l]===r)return i/(o-1);var c=n[i];return(i+(r-c)/(n[i+1]-c))/(o-1)},getTangent:function(t){var e=t-1e-4,r=t+1e-4;e<0&&(e=0),r>1&&(r=1);var n=this.getPoint(e);return this.getPoint(r).clone().sub(n).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var r,n,i,o=new He,a=[],s=[],l=[],c=new He,u=new Xe;for(r=0;r<=t;r++)n=r/t,a[r]=this.getTangentAt(n),a[r].normalize();s[0]=new He,l[0]=new He;var h=Number.MAX_VALUE,p=Math.abs(a[0].x),f=Math.abs(a[0].y),d=Math.abs(a[0].z);for(p<=h&&(h=p,o.set(1,0,0)),f<=h&&(h=f,o.set(0,1,0)),d<=h&&o.set(0,0,1),c.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],c),l[0].crossVectors(a[0],s[0]),r=1;r<=t;r++)s[r]=s[r-1].clone(),l[r]=l[r-1].clone(),c.crossVectors(a[r-1],a[r]),c.length()>Number.EPSILON&&(c.normalize(),i=Math.acos(ye.clamp(a[r-1].dot(a[r]),-1,1)),s[r].applyMatrix4(u.makeRotationAxis(c,i))),l[r].crossVectors(a[r],s[r]);if(!0===e)for(i=Math.acos(ye.clamp(s[0].dot(s[t]),-1,1)),i/=t,a[0].dot(c.crossVectors(s[0],s[t]))>0&&(i=-i),r=1;r<=t;r++)s[r].applyMatrix4(u.makeRotationAxis(a[r],i*r)),l[r].crossVectors(a[r],s[r]);return{tangents:a,normals:s,binormals:l}}}),tl.prototype=Object.create(Js.prototype),tl.prototype.constructor=tl,tl.prototype.isLineCurve=!0,tl.prototype.getPoint=function(t){if(1===t)return this.v2.clone();var e=this.v2.clone().sub(this.v1);return e.multiplyScalar(t).add(this.v1),e},tl.prototype.getPointAt=function(t){return this.getPoint(t)},tl.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},el.prototype=Object.assign(Object.create(Js.prototype),{constructor:el,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new tl(e,t))},getPoint:function(t){for(var e=t*this.getLength(),r=this.getCurveLengths(),n=0;n=e){var i=r[n]-e,o=this.curves[n],a=o.getLength(),s=0===a?0:1-i/a;return o.getPointAt(s)}n++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,r=0,n=this.curves.length;r1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r},createPointsGeometry:function(t){var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){for(var e=new Fi,r=0,n=t.length;re;)r-=e;re.length-2?e.length-1:n+1],l=e[n>e.length-3?e.length-1:n+2];return new _e($s(i,o.x,a.x,s.x,l.x),$s(i,o.y,a.y,s.y,l.y))},il.prototype=Object.create(Js.prototype),il.prototype.constructor=il,il.prototype.getPoint=function(t){var e=this.v0,r=this.v1,n=this.v2,i=this.v3;return new _e(Qs(t,e.x,r.x,n.x,i.x),Qs(t,e.y,r.y,n.y,i.y))},ol.prototype=Object.create(Js.prototype),ol.prototype.constructor=ol,ol.prototype.getPoint=function(t){var e=this.v0,r=this.v1,n=this.v2;return new _e(Ks(t,e.x,r.x,n.x),Ks(t,e.y,r.y,n.y))};var al,sl=Object.assign(Object.create(el.prototype),{fromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,r=t.length;e0){var c=l.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(l);var u=l.getPoint(1);this.currentPoint.copy(u)}});function ll(t){el.call(this),this.currentPoint=new _e,t&&this.fromPoints(t)}function cl(){ll.apply(this,arguments),this.holes=[]}function ul(){this.subPaths=[],this.currentPath=null}function hl(t){this.data=t}function pl(t){this.manager=void 0!==t?t:ns}ll.prototype=sl,sl.constructor=ll,cl.prototype=Object.assign(Object.create(sl),{constructor:cl,getPointsHoles:function(t){for(var e=[],r=0,n=this.holes.length;rNumber.EPSILON){if(c<0&&(a=e[o],l=-l,s=e[i],c=-c),t.ys.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var u=c*(t.x-a.x)-l*(t.y-a.y);if(0===u)return!0;if(u<0)continue;n=!n}}else{if(t.y!==a.y)continue;if(s.x<=t.x&&t.x<=a.x||a.x<=t.x&&t.x<=s.x)return!0}}return n}var i=Ma.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return r(o);var a,s,l,c=[];if(1===o.length)return s=o[0],(l=new cl).curves=s.curves,c.push(l),c;var u=!i(o[0].getPoints());u=t?!u:u;var h,p,f=[],d=[],m=[],g=0;d[g]=void 0,m[g]=[];for(var v=0,y=o.length;v1){for(var _=!1,x=[],b=0,w=d.length;b0&&(_||(m=f))}v=0;for(var T=d.length;v0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var o=0;o!==i;++o)t[e+o]=t[r+o]},_slerp:function(t,e,r,n){We.slerpFlat(t,e,t,e,t,r,n)},_lerp:function(t,e,r,n,i){for(var o=1-n,a=0;a!==i;++a){var s=e+a;t[s]=t[s]*o+t[r+a]*n}}}),Object.assign(sc.prototype,{getValue:function(t,e){this.bind();var r=this._targetGroup.nCachedObjects_,n=this._bindings[r];void 0!==n&&n.getValue(t,e)},setValue:function(t,e){for(var r=this._bindings,n=this._targetGroup.nCachedObjects_,i=r.length;n!==i;++n)r[n].setValue(t,e)},bind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()},unbind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}}),Object.assign(lc,{Composite:sc,create:function(t,e,r){return t&&t.isAnimationObjectGroup?new lc.Composite(t,e,r):new lc(t,e,r)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(/[^\w-]/g,"")},parseTrackName:(Tl=new RegExp("^"+/((?:[\w-]+[\/:])*)/.source+/([\w-\.]+)?/.source+/(?:\.([\w-]+)(?:\[(.+)\])?)?/.source+/\.([\w-]+)(?:\[(.+)\])?/.source+"$"),Pl=["material","materials","bones"],function(t){var e=Tl.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);var r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=r.nodeName&&r.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){var i=r.nodeName.substring(n+1);-1!==Pl.indexOf(i)&&(r.nodeName=r.nodeName.substring(0,n),r.objectName=i)}if(null===r.propertyName||0===r.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}),findNode:function(t,e){if(!e||""===e||"root"===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){var r=function(t){for(var r=0;r=r){var h=r++,p=e[h];n[p.uuid]=u,e[u]=p,n[c]=h,e[h]=l;for(var f=0,d=o;f!==d;++f){var m=i[f],g=m[h],v=m[u];m[u]=g,m[h]=v}}}this.nCachedObjects_=r},uncache:function(t){for(var e=this._objects,r=e.length,n=this.nCachedObjects_,i=this._indicesByUUID,o=this._bindings,a=o.length,s=0,l=arguments.length;s!==l;++s){var c=arguments[s].uuid,u=i[c];if(void 0!==u)if(delete i[c],u0)for(var l=this._interpolants,c=this._propertyBindings,u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].accumulate(n,s)}else this._updateWeight(t)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var r=this._weightInterpolant;if(null!==r){var n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var r=this._timeScaleInterpolant;if(null!==r)e*=r.evaluate(t)[0],t>r.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var r=this._clip.duration,n=this.loop,i=this._loopCount;if(2200===n){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=r)e=r;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{var o=2202===n;if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),e>=r||e<0){var a=Math.floor(e/r);e-=r*a,i+=Math.abs(a);var s=this.repetitions-i;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?r:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(0===s){var l=t<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&i))return this.time=e,r-e}return this.time=e,e},_setEndings:function(t,e,r){var n=this._interpolantSettings;r?(n.endingStart=ie,n.endingEnd=ie):(n.endingStart=t?this.zeroSlopeAtStart?ie:ne:oe,n.endingEnd=e?this.zeroSlopeAtEnd?ie:ne:oe)},_scheduleFading:function(t,e,r){var n=this._mixer,i=n.time,o=this._weightInterpolant;null===o&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=i,s[0]=e,a[1]=i+t,s[1]=r,this}}),Object.assign(hc.prototype,i.prototype,{_bindAction:function(t,e){var r=t._localRoot||this._root,n=t._clip.tracks,i=n.length,o=t._propertyBindings,a=t._interpolants,s=r.uuid,l=this._bindingsByRootAndName,c=l[s];void 0===c&&(c={},l[s]=c);for(var u=0;u!==i;++u){var h=n[u],p=h.name,f=c[p];if(void 0!==f)o[u]=f;else{if(void 0!==(f=o[u])){null===f._cacheIndex&&(++f.referenceCount,this._addInactiveBinding(f,s,p));continue}var d=e&&e._propertyBindings[u].binding.parsedPath;++(f=new ac(lc.create(r,p,d),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(f,s,p),o[u]=f}a[u].resultBuffer=f.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,r=t._clip.uuid,n=this._actionsByClip[r];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,r,e)}for(var i=t._propertyBindings,o=0,a=i.length;o!==a;++o){var s=i[o];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,r=0,n=e.length;r!==n;++r){var i=e[r];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e.99999?this.quaternion.set(0,0,0,1):t.y<-.99999?this.quaternion.set(1,0,0,0):(Kl.set(t.z,0,-t.x).normalize(),$l=Math.acos(t.y),this.quaternion.setFromAxisAngle(Kl,$l))}),Uc.prototype.setLength=function(t,e,r){void 0===e&&(e=.2*t),void 0===r&&(r=.2*e),this.line.scale.set(1,Math.max(0,t-e),1),this.line.updateMatrix(),this.cone.scale.set(r,e,r),this.cone.position.y=t,this.cone.updateMatrix()},Uc.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},Bc.prototype=Object.create(Ko.prototype),Bc.prototype.constructor=Bc;var jc=new He,Gc=new Vc,Wc=new Vc,Hc=new Vc;function Xc(t){Js.call(this),t.length,this.points=t||[],this.closed=!1}function Yc(t,e,r,n){Js.call(this),this.v0=t,this.v1=e,this.v2=r,this.v3=n}function qc(t,e,r){Js.call(this),this.v0=t,this.v1=e,this.v2=r}function Zc(t,e){Js.call(this),this.v1=t,this.v2=e}function $c(t,e,r,n,i,o){rl.call(this,t,e,r,r,n,i,o)}Xc.prototype=Object.create(Js.prototype),Xc.prototype.constructor=Xc,Xc.prototype.getPoint=function(t){var e,r,n,i,o=this.points,a=o.length,s=(a-(this.closed?0:1))*t,l=Math.floor(s),c=s-l;if(this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/o.length)+1)*o.length:0===c&&l===a-1&&(l=a-2,c=1),this.closed||l>0?e=o[(l-1)%a]:(jc.subVectors(o[0],o[1]).add(o[0]),e=jc),r=o[l%a],n=o[(l+1)%a],this.closed||l+2>1)+"px"})}for(;_',e)}e.addRule(".spin-vml","behavior:url(#default#VML)"),p.prototype.lines=function(e,r){var n=r.scale*(r.length+r.width),i=2*r.scale*n;function a(){return s(t("group",{coordsize:i+" "+i,coordorigin:-n+" "+-n}),{width:i,height:i})}var l,u=-(r.width+r.length)*r.scale*2+"px",h=s(a(),{position:"absolute",top:u,left:u});function p(e,i,l){o(h,o(s(a(),{rotation:360/r.lines*e+"deg",left:~~i}),o(s(t("roundrect",{arcsize:r.corners}),{width:n,height:r.scale*r.width,left:r.scale*r.radius,top:-r.scale*r.width>>1,filter:l}),t("fill",{color:c(r.color,e),opacity:r.opacity}),t("stroke",{opacity:0}))))}if(r.shadow)for(l=1;l<=r.lines;l++)p(l,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(l=1;l<=r.lines;l++)p(l);return o(e,h)},p.prototype.opacity=function(t,e,r,n){var i=t.firstChild;n=n.shadow&&n.lines||0,i&&e+n=3&&"base64"===e[r-2]?new Blob([yu(e[r-1])]):null}pu.now=(uu="undefined"!=typeof window&&window.performance)&&uu.now?uu.now.bind(uu):Date.now,pu.prototype={constructor:pu,start:function(){this.startTime=pu.now(),this.oldTime=this.startTime,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1},getElapsedTime:function(){return this.update(),this.elapsedTime},update:function(){var t=0;if(this.running){var e=pu.now();t=.001*(e-this.oldTime),this.oldTime=e,this.elapsedTime+=t}return t}},mu.spaces=" ",gu.prototype=Object.create(Error.prototype);var bu=/^[a-zA-Z0-9_]*$/,wu=['"',"",'"'];function Su(t,e){t.includes(e)||t.push(e)}function Mu(t,e){var r=t.indexOf(e);-1!==r&&t.splice(r,1)}function Au(t,e,r){e.forEach(function(e){e=e.toLowerCase();var n=t[e]=t[e]||[];n.includes(r)||n.push(r)})}function Eu(t,e,r){e.forEach(function(e){e=e.toLowerCase();var n=t[e];if(n){var i=n.indexOf(r);-1!==i&&n.splice(i,1),0===n.length&&delete t[e]}})}var Cu={Timer:pu,encodeQueryComponent:function(t,e){return encodeURIComponent(t).replace(e,function(t){return String.fromCharCode(parseInt(t.substr(1),16))}).replace(/%20/g,"+")},decodeQueryComponent:fu,getUrlParameters:du,getUrlParametersAsDict:function(t){for(var e={},r=du(t),n=0;n0&&(o=Object.create(o))}return o},hexColor:function(t){return"#"+("0000000"+t.toString(16)).substr(-6)},DebugTracer:mu,OutOfMemoryError:gu,allocateTyped:function(t,e){var r=null;try{r=new t(e)}catch(t){throw t instanceof RangeError?new gu(t.message):t}return r},bytesFromBase64:yu,bytesToBase64:vu,arrayFromBase64:function(t,e){return Array.prototype.slice.call(new e(yu(t)))},arrayToBase64:function(t,e){return vu(new e(t).buffer)},compareOptionsWithDefaults:function(t,e){var r=[];if(e&&t){for(var n=Object.keys(t),i=0;i0)return"!"+r.join()}return""},objectsDiff:function t(e,r){var i={};return n.forIn(e,function(e,o){if(e instanceof Object){var a=t(e,r[o]);n.isEmpty(a)||(i[o]=a)}else r&&void 0!==r[o]&&r[o]===e||(i[o]=e)}),i},forInRecursive:function(t,e){!function t(r,i){n.forIn(r,function(r,n){var o=i+(i.length>0?".":"");r instanceof Object?t(r,o+n):void 0!==r&&e(r,o+n)})}(t,"")},enquoteString:function(t){return n.isString(t)?'"'+t.replace(/"/g,'\\"')+'"':t},shotOpen:function(t){"undefined"!=typeof window&&window.open().document.write('')},shotDownload:function(t,e){if(t&&"data:"===t.substr(0,5))if(e||(e=["screenshot-",+new Date,".png"].join("")),"undefined"!=typeof window&&window.navigator&&window.navigator.msSaveBlob)window.navigator.msSaveBlob(xu(t),e);else if("undefined"!=typeof document){var r=document.createElement("a");r.download=e,r.innerHTML="download",r.href=window.URL.createObjectURL(xu(t)),document.body.appendChild(r),r.click(),document.body.removeChild(r)}},copySubArrays:function(t,e,r,n){for(var i=0,o=r.length;ithis._prevTime+1e3&&(this._text.textContent=this.fps.toPrecision(2),this._prevTime=t),t},update:function(){this._startTime=this.end()},show:function(t){void 0===t&&(t=!0),this.domElement.style.display=t?"block":"none"}};var Ru="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Nu=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},Iu=function(){function t(t,e){for(var r=0;r=t.reps.length&&(t.reps[ju]=Cu.deriveDeep(n,!0)),void 0!==r&&(t.reps[ju][e]=r)}function rh(t,e,r){if(t){var i=t.indexOf(Xu),o=(c=t.substr(0,i>=0?i:void 0),u=r,(h=c.indexOf(","))>=0?(u.push(c.substr(h+1).split(",")),c.substr(0,h)):c);if(i>=0){var a=t.substr(i+1).split(qu);if(t=o,e){var s=e[t],l=Cu.deriveDeep(s,!0);a.forEach(function(e){var r=e.split(Yu,2),i=decodeURIComponent(r[0]),o=decodeURIComponent(r[1]),a=Wu[Ru(n.get(s,i))];a?n.set(l,i,a(o)):hu.warn('Unknown argument "'+i+'" for option "'+t+'"')}),Object.keys(l).length>0&&(t=[t,l])}}else t=o}var c,u,h;return t}var nh={l:"load",load:String,t:"type",type:String,v:"view",view:String,u:"unit",unit:Number,menu:Gu,o:"object",object:function(t,e){var r=[],n=rh(t,Vu.defaults.objects,r);Array.isArray(n)||(n=[n]),function(t,e,r){void 0===t._objects&&(t._objects=[]);var n={type:r[0],params:e};void 0!==r[1]&&(n.opts=r[1]),t._objects[t._objects.length]=n}(e,r[0],n)},p:"preset",preset:function(t,e){e.preset=t,e.reps=null,th(e)},r:"rep",rep:function(t,e){th(e),(ju=(ju=Number(t))<=e.reps.length?ju<0?0:ju:e.reps.length)===e.reps.length&&(e.reps[ju]=ju>0?Cu.deriveDeep(e.reps[ju-1],!0):Cu.deriveDeep(Vu.defaults.presets.default[0],!0))},s:"select",select:function(t,e){eh(e,"selector",t)},m:"mode",mode:function(t,e){eh(e,"mode",rh(t,Vu.defaults.modes))},c:"color",color:function(t,e){eh(e,"colorer",rh(t,Vu.defaults.colorers))},mt:"material",material:function(t,e){eh(e,"material",rh(t,Vu.defaults.materials))},dup:function(t,e){th(e);var r=e.reps,n=r[ju];++ju>=r.length&&(r[ju]=Cu.deriveDeep(n,!0))},ar:"autoResolution",background:"theme"};function ih(t){ju=0;for(var e={},r=0,i=t.length;r0&&(e+=","+t.params.join(",")),t.opts&&(e+=Xu+oh(t.opts)),e}}function lh(t){var e=[],r=0;return Cu.forInRecursive(t,function(t,n){e[r++]=n+"="+Cu.enquoteString(t)}),e.join(" ")}function ch(t){return n.isArray(t)?t[0]+(t.length<2?"":" "+lh(t[1])):t}function uh(t){if(t&&t.type){var e=t.type;return n.isArray(t.params)&&t.params.length>0&&(e+=" "+t.params.map(Cu.enquoteString).join(" ")),t.opts&&(e+=" "+lh(t.opts)),e}}function hh(t,e){var r=[],i=0;function o(t,e){null!==e&&void 0!==e&&(r[i++]=t+e)}return n.isEmpty(t)?null:(o("",e),o("s=",Cu.enquoteString(t.selector)),o("m=",ch(t.mode)),o("c=",ch(t.colorer)),o("mt=",ch(t.material)),r.join(" "))}var ph={fromURL:function(t){return ih(Cu.getUrlParameters(t))},fromAttr:function(t){return ih(Cu.getUrlParameters("?"+(t||"")))},adapters:Wu,toURL:function(t){var e=[],r=0;function i(t,n){null!==n&&void 0!==n&&(e[r++]=Ku(t)+Hu+Ku(n))}i("l",t.load),i("u",t.unit),i("p",t.preset),function(t){if(t)for(var e=0,r=t.length;e0&&(o+="?"+e.join("&")),o},toScript:function(t){var e=[],r=0;function n(t,n){null!==n&&void 0!==n&&(e[r++]=t+" "+n)}return n("set","autobuild false"),n("load",t.load),n("unit",t.unit),n("preset",t.preset),function(t){if(t)for(var e=0,r=t.length;e0?t.getString():this.element.name.trim()},mh.prototype.forEachBond=function(t){for(var e=this._bonds,r=0,n=e.length;r=0)return this._hydrogenCount;var t=this.element,e=t.hydrogenValency;if(1===e.length&&0===e[0])return 0;switch(t.number){case 1:return this.getHydrogenCountHydrogen();case 3:case 11:case 19:case 37:case 55:case 87:case 4:case 12:case 20:case 38:case 56:case 88:case 13:case 31:case 49:case 41:case 82:case 83:return this.getHydrogenCountMetal();case 6:case 14:case 32:case 51:return this.getHydrogenCountGroup14();case 50:return this.getHydrogenCountTin();case 7:case 8:case 9:case 15:case 16:case 17:case 33:case 34:case 35:case 53:case 85:return this.getHydrogenCountNonMetal();case 5:return this.getHydrogenCountBoron();default:return 0}},mh.prototype.getAtomBondsCount=function(){for(var t,e=this.getBonds(),r=0,n=0;n=t){r=e[n];break}return r},mh.prototype.getCharge=function(){return this._charge},mh.prototype.getLocation=function(){return this._location},mh.prototype.getFullName=function(){var t="";return null!==this._residue&&(null!==this._residue._chain&&(t+=this._residue._chain.getName()+"."),t+=this._residue._sequence+"."),t+=this._name.getString()};var gh={UNKNOWN:0,COVALENT:1,AROMATIC:2};function vh(t){return t._position}function yh(t,e,r,n,i){if(this._left=t,this._right=e,this._fixed=i,this._index=-1,t>e)throw new Error("In a bond atom indices must be in increasing order");this._order=r,this._type=n}function _h(t,e,r){this._name=t,this._fullName=e,this.letterCode=r,this.flags=0}function xh(t,e){for(var r=0,n=e.length;r0?++n:++i}function s(t){"C"===t.element.name&&a(t)}for(var l=[[this.forEachLevelOne,s],[this.forEachLevelOne,a],[this.forEachLevelTwo,s],[this.forEachLevelTwo,a]],c=0;cn)return e.multiplyScalar(-1);if(ir._bonds.length&&(n=r,i=e);for(var o=n,a=0,s=i._bonds,l=0,c=s.length;la&&u!==n&&(o=u,a=u._bonds.length)}var h=t(i),p=t(n).clone().sub(h),f=t(o).clone().sub(h);return f.crossVectors(p,f),f.lengthSq()<1e-4&&f.set(0,1,0),p.normalize(),f.normalize(),p.crossVectors(f,p),p.lengthSq()<1e-4&&p.set(0,1,0),p.normalize(),this._fixDir(h,p,t)},_h.prototype.getName=function(){return this._name},_h.StandardTypes={ALA:new _h("ALA","Alanine","A"),ARG:new _h("ARG","Arginine","R"),ASN:new _h("ASN","Asparagine","N"),ASP:new _h("ASP","Aspartic Acid","D"),CYS:new _h("CYS","Cysteine","C"),GLN:new _h("GLN","Glutamine","Q"),GLU:new _h("GLU","Glutamic Acid","E"),GLY:new _h("GLY","Glycine","G"),HIS:new _h("HIS","Histidine","H"),ILE:new _h("ILE","Isoleucine","I"),LEU:new _h("LEU","Leucine","L"),LYS:new _h("LYS","Lysine","K"),MET:new _h("MET","Methionine","M"),PHE:new _h("PHE","Phenylalanine","F"),PRO:new _h("PRO","Proline","P"),PYL:new _h("PYL","Pyrrolysine","O"),SEC:new _h("SEC","Selenocysteine","U"),SER:new _h("SER","Serine","S"),THR:new _h("THR","Threonine","T"),TRP:new _h("TRP","Tryptophan","W"),TYR:new _h("TYR","Tyrosine","Y"),VAL:new _h("VAL","Valine","V"),A:new _h("A","Adenine","A"),C:new _h("C","Cytosine","C"),G:new _h("G","Guanine","G"),I:new _h("I","Inosine","I"),T:new _h("T","Thymine","T"),U:new _h("U","Uracil","U"),DA:new _h("DA","Adenine","A"),DC:new _h("DC","Cytosine","C"),DG:new _h("DG","Guanine","G"),DI:new _h("DI","Inosine","I"),DT:new _h("DT","Thymine","T"),DU:new _h("DU","Uracil","U"),"+A":new _h("+A","Adenine","A"),"+C":new _h("+C","Cytosine","C"),"+G":new _h("+G","Guanine","G"),"+I":new _h("+I","Inosine","I"),"+T":new _h("+T","Thymine","T"),"+U":new _h("+U","Uracil","U"),WAT:new _h("WAT","Water",""),H2O:new _h("H2O","Water",""),HOH:new _h("HOH","Water",""),DOD:new _h("DOD","Water",""),UNK:new _h("UNK","Unknown",""),UNL:new _h("UNL","Unknown Ligand","")},_h.Flags={PROTEIN:1,BASIC:2,ACIDIC:4,POLAR:8,NONPOLAR:16,AROMATIC:32,NUCLEIC:256,PURINE:512,PYRIMIDINE:1024,DNA:2048,RNA:4096,WATER:65536};var bh=_h.Flags;xh(bh.WATER,["WAT","H2O","HOH","DOD"]),xh(bh.PROTEIN,["ALA","ARG","ASN","ASP","CYS","GLY","GLU","GLN","HIS","ILE","LEU","LYS","MET","PHE","PRO","PYL","SEC","SER","THR","TRP","TYR","VAL"]),xh(bh.BASIC,["ARG","HIS","LYS"]),xh(bh.ACIDIC,["ASP","GLU"]),xh(bh.POLAR,["ASN","CYS","GLN","SER","THR","TYR"]),xh(bh.NONPOLAR,["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL","GLY"]),xh(bh.AROMATIC,["PHE","TRP","TYR"]),xh(bh.NUCLEIC,["A","G","I","DA","DG","DI","+A","+G","+I","C","T","U","DC","DT","DU","+C","+T","+U"]),xh(bh.PURINE,["A","G","I","DA","DG","DI","+A","+G","+I"]),xh(bh.PYRIMIDINE,["C","T","U","DC","DT","DU","+C","+T","+U"]),xh(bh.DNA,["DA","DG","DI","DC","DT","DU"]),xh(bh.RNA,["A","G","I","C","T","U"]);!function(t,e){for(var r=Object.keys(e),n=0,i=r.length;nMath.PI/2&&o.negate(),o},Ch.prototype._innerFinalize=function(t,e,r,n,i){var o=null===e,a=i(this._leadAtom),s=new He(a.x,a.y,a.z);if(0==(this._type.flags&_h.Flags.NUCLEIC)){if(o)n._midPoint=i(this._firstAtom).clone();else{var l=e._controlPoint;n._midPoint=l.clone().lerp(s,.5),n._wingVector=this.calcWing(l,s,i(t._wingAtom),e._wingVector)}n._controlPoint=s}else this._detectLeadWing(n,r,i)},Ch.prototype._finalize2=function(t,e){this._innerFinalize(t,t,e,this,function(t){return t._position})},Ch.prototype.isConnected=function(t){if(this._chain!==t._chain)return!1;if(this===t)return!0;var e=!1;return this.forEachAtom(function(r){for(var n=r._bonds,i=0,o=n.length;i1){var a=t[1]._wingVector;t[0]._wingVector=new He(a.x,a.y,a.z)}else t.length>0&&(t[0]._wingVector=new He(1,0,0))},Th.prototype.updateToFrame=function(t){var e=this._residues,r=null,n=null,i=t._residues,o=e.length;function a(e){return t.getAtomPos(e._index)}for(var s=0;s1?i[e[1]._index]._wingVector:new He(1,0,0)},Th.prototype.addResidue=function(t,e,r){var n=this._complex.getResidueType(t);null===n&&(n=this._complex.addResidueType(t));var i=new Ch(this,n,e,r);return this._complex.addResidue(i),this._residues.push(i),n.flags&(_h.Flags.NUCLEIC|_h.Flags.PROTEIN)&&(this.maxSequencee&&(this.minSequence=e)),i},Th.prototype.getResidueCount=function(){return this._residues.length},Th.prototype.forEachResidue=function(t){for(var e=this._residues,r=0,n=e.length;r1?i=n>1?this._repeat.toString()+"("+i+")":this._repeat.toString()+i:n>1&&(i="("+i+")"),o>1&&(i+="^"+o.toString()+"+"),1===o&&(i+="^+"),o<-1&&(i+="^"+Math.abs(o).toString()+"-"),-1===o&&(i+="^-")):this._repeat>1&&(i=this._repeat.toString()+i),i};var Ih={},Oh=Object.freeze({default:Ih}); +(function(){var n,i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",s="__lodash_hash_undefined__",l=500,c="__lodash_placeholder__",u=1,h=2,p=4,d=1,f=2,m=1,g=2,v=4,y=8,_=16,x=32,b=64,w=128,S=256,M=512,A=30,E="...",C=800,T=16,P=1,L=2,R=1/0,N=9007199254740991,I=1.7976931348623157e308,O=NaN,D=4294967295,z=D-1,F=D>>>1,k=[["ary",w],["bind",m],["bindKey",g],["curry",y],["curryRight",_],["flip",M],["partial",x],["partialRight",b],["rearg",S]],B="[object Arguments]",U="[object Array]",V="[object AsyncFunction]",j="[object Boolean]",G="[object Date]",H="[object DOMException]",W="[object Error]",X="[object Function]",Y="[object GeneratorFunction]",q="[object Map]",Z="[object Number]",$="[object Null]",K="[object Object]",Q="[object Promise]",J="[object Proxy]",tt="[object RegExp]",et="[object Set]",rt="[object String]",nt="[object Symbol]",it="[object Undefined]",ot="[object WeakMap]",at="[object WeakSet]",st="[object ArrayBuffer]",lt="[object DataView]",ct="[object Float32Array]",ut="[object Float64Array]",ht="[object Int8Array]",pt="[object Int16Array]",dt="[object Int32Array]",ft="[object Uint8Array]",mt="[object Uint8ClampedArray]",gt="[object Uint16Array]",vt="[object Uint32Array]",yt=/\b__p \+= '';/g,_t=/\b(__p \+=) '' \+/g,xt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,bt=/&(?:amp|lt|gt|quot|#39);/g,wt=/[&<>"']/g,St=RegExp(bt.source),Mt=RegExp(wt.source),At=/<%-([\s\S]+?)%>/g,Et=/<%([\s\S]+?)%>/g,Ct=/<%=([\s\S]+?)%>/g,Tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pt=/^\w*$/,Lt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Rt=/[\\^$.*+?()[\]{}|]/g,Nt=RegExp(Rt.source),It=/^\s+|\s+$/g,Ot=/^\s+/,Dt=/\s+$/,zt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ft=/\{\n\/\* \[wrapped with (.+)\] \*/,kt=/,? & /,Bt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ut=/\\(\\)?/g,Vt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,jt=/\w*$/,Gt=/^[-+]0x[0-9a-f]+$/i,Ht=/^0b[01]+$/i,Wt=/^\[object .+?Constructor\]$/,Xt=/^0o[0-7]+$/i,Yt=/^(?:0|[1-9]\d*)$/,qt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Zt=/($^)/,$t=/['\n\r\u2028\u2029\\]/g,Kt="\\ud800-\\udfff",Qt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Jt="\\u2700-\\u27bf",te="a-z\\xdf-\\xf6\\xf8-\\xff",ee="A-Z\\xc0-\\xd6\\xd8-\\xde",re="\\ufe0e\\ufe0f",ne="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",ie="['’]",oe="["+Kt+"]",ae="["+ne+"]",se="["+Qt+"]",le="\\d+",ce="["+Jt+"]",ue="["+te+"]",he="[^"+Kt+ne+le+Jt+te+ee+"]",pe="\\ud83c[\\udffb-\\udfff]",de="[^"+Kt+"]",fe="(?:\\ud83c[\\udde6-\\uddff]){2}",me="[\\ud800-\\udbff][\\udc00-\\udfff]",ge="["+ee+"]",ve="\\u200d",ye="(?:"+ue+"|"+he+")",_e="(?:"+ge+"|"+he+")",xe="(?:['’](?:d|ll|m|re|s|t|ve))?",be="(?:['’](?:D|LL|M|RE|S|T|VE))?",we="(?:"+se+"|"+pe+")"+"?",Se="["+re+"]?",Me=Se+we+("(?:"+ve+"(?:"+[de,fe,me].join("|")+")"+Se+we+")*"),Ae="(?:"+[ce,fe,me].join("|")+")"+Me,Ee="(?:"+[de+se+"?",se,fe,me,oe].join("|")+")",Ce=RegExp(ie,"g"),Te=RegExp(se,"g"),Pe=RegExp(pe+"(?="+pe+")|"+Ee+Me,"g"),Le=RegExp([ge+"?"+ue+"+"+xe+"(?="+[ae,ge,"$"].join("|")+")",_e+"+"+be+"(?="+[ae,ge+ye,"$"].join("|")+")",ge+"?"+ye+"+"+xe,ge+"+"+be,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",le,Ae].join("|"),"g"),Re=RegExp("["+ve+Kt+Qt+re+"]"),Ne=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ie=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Oe=-1,De={};De[ct]=De[ut]=De[ht]=De[pt]=De[dt]=De[ft]=De[mt]=De[gt]=De[vt]=!0,De[B]=De[U]=De[st]=De[j]=De[lt]=De[G]=De[W]=De[X]=De[q]=De[Z]=De[K]=De[tt]=De[et]=De[rt]=De[ot]=!1;var ze={};ze[B]=ze[U]=ze[st]=ze[lt]=ze[j]=ze[G]=ze[ct]=ze[ut]=ze[ht]=ze[pt]=ze[dt]=ze[q]=ze[Z]=ze[K]=ze[tt]=ze[et]=ze[rt]=ze[nt]=ze[ft]=ze[mt]=ze[gt]=ze[vt]=!0,ze[W]=ze[X]=ze[ot]=!1;var Fe={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ke=parseFloat,Be=parseInt,Ue="object"==typeof t&&t&&t.Object===Object&&t,Ve="object"==typeof self&&self&&self.Object===Object&&self,je=Ue||Ve||Function("return this")(),Ge=r&&!r.nodeType&&r,He=Ge&&e&&!e.nodeType&&e,We=He&&He.exports===Ge,Xe=We&&Ue.process,Ye=function(){try{return Xe&&Xe.binding&&Xe.binding("util")}catch(t){}}(),qe=Ye&&Ye.isArrayBuffer,Ze=Ye&&Ye.isDate,$e=Ye&&Ye.isMap,Ke=Ye&&Ye.isRegExp,Qe=Ye&&Ye.isSet,Je=Ye&&Ye.isTypedArray;function tr(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function er(t,e,r,n){for(var i=-1,o=null==t?0:t.length;++i-1}function sr(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function Pr(t,e){for(var r=t.length;r--&&gr(e,t[r],0)>-1;);return r}var Lr=br({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Rr=br({"&":"&","<":"<",">":">",'"':""","'":"'"});function Nr(t){return"\\"+Fe[t]}function Ir(t){return Re.test(t)}function Or(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function Dr(t,e){return function(r){return t(e(r))}}function zr(t,e){for(var r=-1,n=t.length,i=0,o=[];++r",""":'"',"'":"'"});var jr=function t(e){var r,Kt=(e=null==e?je:jr.defaults(je.Object(),e,jr.pick(je,Ie))).Array,Qt=e.Date,Jt=e.Error,te=e.Function,ee=e.Math,re=e.Object,ne=e.RegExp,ie=e.String,oe=e.TypeError,ae=Kt.prototype,se=te.prototype,le=re.prototype,ce=e["__core-js_shared__"],ue=se.toString,he=le.hasOwnProperty,pe=0,de=(r=/[^.]+$/.exec(ce&&ce.keys&&ce.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",fe=le.toString,me=ue.call(re),ge=je._,ve=ne("^"+ue.call(he).replace(Rt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ye=We?e.Buffer:n,_e=e.Symbol,xe=e.Uint8Array,be=ye?ye.allocUnsafe:n,we=Dr(re.getPrototypeOf,re),Se=re.create,Me=le.propertyIsEnumerable,Ae=ae.splice,Ee=_e?_e.isConcatSpreadable:n,Pe=_e?_e.iterator:n,Re=_e?_e.toStringTag:n,Fe=function(){try{var t=Uo(re,"defineProperty");return t({},"",{}),t}catch(t){}}(),Ue=e.clearTimeout!==je.clearTimeout&&e.clearTimeout,Ve=Qt&&Qt.now!==je.Date.now&&Qt.now,Ge=e.setTimeout!==je.setTimeout&&e.setTimeout,He=ee.ceil,Xe=ee.floor,Ye=re.getOwnPropertySymbols,dr=ye?ye.isBuffer:n,br=e.isFinite,Gr=ae.join,Hr=Dr(re.keys,re),Wr=ee.max,Xr=ee.min,Yr=Qt.now,qr=e.parseInt,Zr=ee.random,$r=ae.reverse,Kr=Uo(e,"DataView"),Qr=Uo(e,"Map"),Jr=Uo(e,"Promise"),tn=Uo(e,"Set"),en=Uo(e,"WeakMap"),rn=Uo(re,"create"),nn=en&&new en,on={},an=da(Kr),sn=da(Qr),ln=da(Jr),cn=da(tn),un=da(en),hn=_e?_e.prototype:n,pn=hn?hn.valueOf:n,dn=hn?hn.toString:n;function fn(t){if(Ls(t)&&!_s(t)&&!(t instanceof yn)){if(t instanceof vn)return t;if(he.call(t,"__wrapped__"))return fa(t)}return new vn(t)}var mn=function(){function t(){}return function(e){if(!Ps(e))return{};if(Se)return Se(e);t.prototype=e;var r=new t;return t.prototype=n,r}}();function gn(){}function vn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=n}function yn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=D,this.__views__=[]}function _n(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function zn(t,e,r,i,o,a){var s,l=e&u,c=e&h,d=e&p;if(r&&(s=o?r(t,i,o,a):r(t)),s!==n)return s;if(!Ps(t))return t;var f,m,g,v,y,_,x,b,w,S=_s(t);if(S){if(b=(x=t).length,w=new x.constructor(b),b&&"string"==typeof x[0]&&he.call(x,"index")&&(w.index=x.index,w.input=x.input),s=w,!l)return no(t,s)}else{var M=Go(t),A=M==X||M==Y;if(Ss(t))return Ki(t,l);if(M==K||M==B||A&&!o){if(s=c||A?{}:Wo(t),!l)return c?(g=t,_=t,v=(y=s)&&io(_,sl(_),y),io(g,jo(g),v)):(f=t,m=Nn(s,t),io(f,Vo(f),m))}else{if(!ze[M])return o?t:{};s=function(t,e,r){var n,i,o,a,s,l=t.constructor;switch(e){case st:return Qi(t);case j:case G:return new l(+t);case lt:return a=t,s=r?Qi(a.buffer):a.buffer,new a.constructor(s,a.byteOffset,a.byteLength);case ct:case ut:case ht:case pt:case dt:case ft:case mt:case gt:case vt:return Ji(t,r);case q:return new l;case Z:case rt:return new l(t);case tt:return(o=new(i=t).constructor(i.source,jt.exec(i))).lastIndex=i.lastIndex,o;case et:return new l;case nt:return n=t,pn?re(pn.call(n)):{}}}(t,M,l)}}a||(a=new Sn);var E=a.get(t);if(E)return E;if(a.set(t,s),Ds(t))return t.forEach(function(n){s.add(zn(n,e,r,n,t,a))}),s;if(Rs(t))return t.forEach(function(n,i){s.set(i,zn(n,e,r,i,t,a))}),s;var C=S?n:(d?c?Io:No:c?sl:al)(t);return rr(C||t,function(n,i){C&&(n=t[i=n]),Pn(s,i,zn(n,e,r,i,t,a))}),s}function Fn(t,e,r){var i=r.length;if(null==t)return!i;for(t=re(t);i--;){var o=r[i],a=e[o],s=t[o];if(s===n&&!(o in t)||!a(s))return!1}return!0}function kn(t,e,r){if("function"!=typeof t)throw new oe(a);return ia(function(){t.apply(n,r)},e)}function Bn(t,e,r,n){var o=-1,a=ar,s=!0,l=t.length,c=[],u=e.length;if(!l)return c;r&&(e=lr(e,Ar(r))),n?(a=sr,s=!1):e.length>=i&&(a=Cr,s=!1,e=new wn(e));t:for(;++o-1},xn.prototype.set=function(t,e){var r=this.__data__,n=Ln(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},bn.prototype.clear=function(){this.size=0,this.__data__={hash:new _n,map:new(Qr||xn),string:new _n}},bn.prototype.delete=function(t){var e=ko(this,t).delete(t);return this.size-=e?1:0,e},bn.prototype.get=function(t){return ko(this,t).get(t)},bn.prototype.has=function(t){return ko(this,t).has(t)},bn.prototype.set=function(t,e){var r=ko(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},wn.prototype.add=wn.prototype.push=function(t){return this.__data__.set(t,s),this},wn.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.clear=function(){this.__data__=new xn,this.size=0},Sn.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Sn.prototype.get=function(t){return this.__data__.get(t)},Sn.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.set=function(t,e){var r=this.__data__;if(r instanceof xn){var n=r.__data__;if(!Qr||n.length0&&r(s)?e>1?Wn(s,e-1,r,n,i):cr(i,s):n||(i[i.length]=s)}return i}var Xn=lo(),Yn=lo(!0);function qn(t,e){return t&&Xn(t,e,al)}function Zn(t,e){return t&&Yn(t,e,al)}function $n(t,e){return or(e,function(e){return Es(t[e])})}function Kn(t,e){for(var r=0,i=(e=Yi(e,t)).length;null!=t&&re}function ei(t,e){return null!=t&&he.call(t,e)}function ri(t,e){return null!=t&&e in re(t)}function ni(t,e,r){for(var i=r?sr:ar,o=t[0].length,a=t.length,s=a,l=Kt(a),c=1/0,u=[];s--;){var h=t[s];s&&e&&(h=lr(h,Ar(e))),c=Xr(h.length,c),l[s]=!r&&(e||o>=120&&h.length>=120)?new wn(s&&h):n}h=t[0];var p=-1,d=l[0];t:for(;++p=s)return l;var c=r[n];return l*("desc"==c?-1:1)}}return t.index-e.index}(t,e,r)})}function _i(t,e,r){for(var n=-1,i=e.length,o={};++n-1;)s!==t&&Ae.call(s,l,1),Ae.call(t,l,1);return t}function bi(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==o){var o=i;Yo(i)?Ae.call(t,i,1):Bi(t,i)}}return t}function wi(t,e){return t+Xe(Zr()*(e-t+1))}function Si(t,e){var r="";if(!t||e<1||e>N)return r;do{e%2&&(r+=t),(e=Xe(e/2))&&(t+=t)}while(e);return r}function Mi(t,e){return oa(ea(t,e,Nl),t+"")}function Ai(t){return An(ml(t))}function Ei(t,e){var r=ml(t);return la(r,Dn(e,0,r.length))}function Ci(t,e,r,i){if(!Ps(t))return t;for(var o=-1,a=(e=Yi(e,t)).length,s=a-1,l=t;null!=l&&++oi?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Kt(i);++n>>1,a=t[o];null!==a&&!Fs(a)&&(r?a<=e:a=i){var u=e?null:Mo(t);if(u)return kr(u);s=!1,o=Cr,c=new wn}else c=e?[]:l;t:for(;++n=i?t:Ri(t,e,r)}var $i=Ue||function(t){return je.clearTimeout(t)};function Ki(t,e){if(e)return t.slice();var r=t.length,n=be?be(r):new t.constructor(r);return t.copy(n),n}function Qi(t){var e=new t.constructor(t.byteLength);return new xe(e).set(new xe(t)),e}function Ji(t,e){var r=e?Qi(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function to(t,e){if(t!==e){var r=t!==n,i=null===t,o=t==t,a=Fs(t),s=e!==n,l=null===e,c=e==e,u=Fs(e);if(!l&&!u&&!a&&t>e||a&&s&&c&&!l&&!u||i&&s&&c||!r&&c||!o)return 1;if(!i&&!a&&!u&&t1?r[o-1]:n,s=o>2?r[2]:n;for(a=t.length>3&&"function"==typeof a?(o--,a):n,s&&qo(r[0],r[1],s)&&(a=o<3?n:a,o=1),e=re(e);++i-1?o[a?e[s]:s]:n}}function fo(t){return Ro(function(e){var r=e.length,i=r,o=vn.prototype.thru;for(t&&e.reverse();i--;){var s=e[i];if("function"!=typeof s)throw new oe(a);if(o&&!l&&"wrapper"==Do(s))var l=new vn([],!0)}for(i=l?i:r;++i1&&y.reverse(),h&&cl))return!1;var u=a.get(t);if(u&&a.get(e))return u==e;var h=-1,p=!0,m=r&f?new wn:n;for(a.set(t,e),a.set(e,t);++h-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(zt,"{\n/* [wrapped with "+e+"] */\n")}(a,(o=a.match(Ft),n=o?o[1].split(kt):[],i=r,rr(k,function(t){var e="_."+t[0];i&t[1]&&!ar(n,e)&&n.push(e)}),n.sort())))}function sa(t){var e=0,r=0;return function(){var i=Yr(),o=T-(i-r);if(r=i,o>0){if(++e>=C)return arguments[0]}else e=0;return t.apply(n,arguments)}}function la(t,e){var r=-1,i=t.length,o=i-1;for(e=e===n?i:e;++r1?t[e-1]:n;return Oa(t,r="function"==typeof r?(t.pop(),r):n)});function Va(t){var e=fn(t);return e.__chain__=!0,e}function ja(t,e){return e(t)}var Ga=Ro(function(t){var e=t.length,r=e?t[0]:0,i=this.__wrapped__,o=function(e){return On(e,t)};return!(e>1||this.__actions__.length)&&i instanceof yn&&Yo(r)?((i=i.slice(r,+r+(e?1:0))).__actions__.push({func:ja,args:[o],thisArg:n}),new vn(i,this.__chain__).thru(function(t){return e&&!t.length&&t.push(n),t})):this.thru(o)});var Ha=oo(function(t,e,r){he.call(t,r)?++t[r]:In(t,r,1)});var Wa=po(ya),Xa=po(_a);function Ya(t,e){return(_s(t)?rr:Un)(t,Fo(e,3))}function qa(t,e){return(_s(t)?nr:Vn)(t,Fo(e,3))}var Za=oo(function(t,e,r){he.call(t,r)?t[r].push(e):In(t,r,[e])});var $a=Mi(function(t,e,r){var n=-1,i="function"==typeof e,o=bs(t)?Kt(t.length):[];return Un(t,function(t){o[++n]=i?tr(e,t,r):ii(t,e,r)}),o}),Ka=oo(function(t,e,r){In(t,r,e)});function Qa(t,e){return(_s(t)?lr:di)(t,Fo(e,3))}var Ja=oo(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]});var ts=Mi(function(t,e){if(null==t)return[];var r=e.length;return r>1&&qo(t,e[0],e[1])?e=[]:r>2&&qo(e[0],e[1],e[2])&&(e=[e[0]]),yi(t,Wn(e,1),[])}),es=Ve||function(){return je.Date.now()};function rs(t,e,r){return e=r?n:e,e=t&&null==e?t.length:e,Eo(t,w,n,n,n,n,e)}function ns(t,e){var r;if("function"!=typeof e)throw new oe(a);return t=Gs(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=n),r}}var is=Mi(function(t,e,r){var n=m;if(r.length){var i=zr(r,zo(is));n|=x}return Eo(t,n,e,r,i)}),os=Mi(function(t,e,r){var n=m|g;if(r.length){var i=zr(r,zo(os));n|=x}return Eo(e,n,t,r,i)});function as(t,e,r){var i,o,s,l,c,u,h=0,p=!1,d=!1,f=!0;if("function"!=typeof t)throw new oe(a);function m(e){var r=i,a=o;return i=o=n,h=e,l=t.apply(a,r)}function g(t){var r=t-u;return u===n||r>=e||r<0||d&&t-h>=s}function v(){var t,r,n=es();if(g(n))return y(n);c=ia(v,(r=e-((t=n)-u),d?Xr(r,s-(t-h)):r))}function y(t){return c=n,f&&i?m(t):(i=o=n,l)}function _(){var t,r=es(),a=g(r);if(i=arguments,o=this,u=r,a){if(c===n)return h=t=u,c=ia(v,e),p?m(t):l;if(d)return c=ia(v,e),m(u)}return c===n&&(c=ia(v,e)),l}return e=Ws(e)||0,Ps(r)&&(p=!!r.leading,s=(d="maxWait"in r)?Wr(Ws(r.maxWait)||0,e):s,f="trailing"in r?!!r.trailing:f),_.cancel=function(){c!==n&&$i(c),h=0,i=u=o=c=n},_.flush=function(){return c===n?l:y(es())},_}var ss=Mi(function(t,e){return kn(t,1,e)}),ls=Mi(function(t,e,r){return kn(t,Ws(e)||0,r)});function cs(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new oe(a);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var a=t.apply(this,n);return r.cache=o.set(i,a)||o,a};return r.cache=new(cs.Cache||bn),r}function us(t){if("function"!=typeof t)throw new oe(a);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}cs.Cache=bn;var hs=qi(function(t,e){var r=(e=1==e.length&&_s(e[0])?lr(e[0],Ar(Fo())):lr(Wn(e,1),Ar(Fo()))).length;return Mi(function(n){for(var i=-1,o=Xr(n.length,r);++i=e}),ys=oi(function(){return arguments}())?oi:function(t){return Ls(t)&&he.call(t,"callee")&&!Me.call(t,"callee")},_s=Kt.isArray,xs=qe?Ar(qe):function(t){return Ls(t)&&Jn(t)==st};function bs(t){return null!=t&&Ts(t.length)&&!Es(t)}function ws(t){return Ls(t)&&bs(t)}var Ss=dr||Wl,Ms=Ze?Ar(Ze):function(t){return Ls(t)&&Jn(t)==G};function As(t){if(!Ls(t))return!1;var e=Jn(t);return e==W||e==H||"string"==typeof t.message&&"string"==typeof t.name&&!Is(t)}function Es(t){if(!Ps(t))return!1;var e=Jn(t);return e==X||e==Y||e==V||e==J}function Cs(t){return"number"==typeof t&&t==Gs(t)}function Ts(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=N}function Ps(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ls(t){return null!=t&&"object"==typeof t}var Rs=$e?Ar($e):function(t){return Ls(t)&&Go(t)==q};function Ns(t){return"number"==typeof t||Ls(t)&&Jn(t)==Z}function Is(t){if(!Ls(t)||Jn(t)!=K)return!1;var e=we(t);if(null===e)return!0;var r=he.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ue.call(r)==me}var Os=Ke?Ar(Ke):function(t){return Ls(t)&&Jn(t)==tt};var Ds=Qe?Ar(Qe):function(t){return Ls(t)&&Go(t)==et};function zs(t){return"string"==typeof t||!_s(t)&&Ls(t)&&Jn(t)==rt}function Fs(t){return"symbol"==typeof t||Ls(t)&&Jn(t)==nt}var ks=Je?Ar(Je):function(t){return Ls(t)&&Ts(t.length)&&!!De[Jn(t)]};var Bs=bo(pi),Us=bo(function(t,e){return t<=e});function Vs(t){if(!t)return[];if(bs(t))return zs(t)?Ur(t):no(t);if(Pe&&t[Pe])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[Pe]());var e=Go(t);return(e==q?Or:e==et?kr:ml)(t)}function js(t){return t?(t=Ws(t))===R||t===-R?(t<0?-1:1)*I:t==t?t:0:0===t?t:0}function Gs(t){var e=js(t),r=e%1;return e==e?r?e-r:e:0}function Hs(t){return t?Dn(Gs(t),0,D):0}function Ws(t){if("number"==typeof t)return t;if(Fs(t))return O;if(Ps(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ps(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(It,"");var r=Ht.test(t);return r||Xt.test(t)?Be(t.slice(2),r?2:8):Gt.test(t)?O:+t}function Xs(t){return io(t,sl(t))}function Ys(t){return null==t?"":Fi(t)}var qs=ao(function(t,e){if(Qo(e)||bs(e))io(e,al(e),t);else for(var r in e)he.call(e,r)&&Pn(t,r,e[r])}),Zs=ao(function(t,e){io(e,sl(e),t)}),$s=ao(function(t,e,r,n){io(e,sl(e),t,n)}),Ks=ao(function(t,e,r,n){io(e,al(e),t,n)}),Qs=Ro(On);var Js=Mi(function(t,e){t=re(t);var r=-1,i=e.length,o=i>2?e[2]:n;for(o&&qo(e[0],e[1],o)&&(i=1);++r1),e}),io(t,Io(t),r),n&&(r=zn(r,u|h|p,Po));for(var i=e.length;i--;)Bi(r,e[i]);return r});var hl=Ro(function(t,e){return null==t?{}:_i(r=t,e,function(t,e){return rl(r,e)});var r});function pl(t,e){if(null==t)return{};var r=lr(Io(t),function(t){return[t]});return e=Fo(e),_i(t,r,function(t,r){return e(t,r[0])})}var dl=Ao(al),fl=Ao(sl);function ml(t){return null==t?[]:Er(t,al(t))}var gl=uo(function(t,e,r){return e=e.toLowerCase(),t+(r?vl(e):e)});function vl(t){return Al(Ys(t).toLowerCase())}function yl(t){return(t=Ys(t))&&t.replace(qt,Lr).replace(Te,"")}var _l=uo(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),xl=uo(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),bl=co("toLowerCase");var wl=uo(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()});var Sl=uo(function(t,e,r){return t+(r?" ":"")+Al(e)});var Ml=uo(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),Al=co("toUpperCase");function El(t,e,r){return t=Ys(t),(e=r?n:e)===n?(i=t,Ne.test(i)?t.match(Le)||[]:t.match(Bt)||[]):t.match(e)||[];var i}var Cl=Mi(function(t,e){try{return tr(t,n,e)}catch(t){return As(t)?t:new Jt(t)}}),Tl=Ro(function(t,e){return rr(e,function(e){e=pa(e),In(t,e,is(t[e],t))}),t});function Pl(t){return function(){return t}}var Ll=fo(),Rl=fo(!0);function Nl(t){return t}function Il(t){return ci("function"==typeof t?t:zn(t,u))}var Ol=Mi(function(t,e){return function(r){return ii(r,t,e)}}),Dl=Mi(function(t,e){return function(r){return ii(t,r,e)}});function zl(t,e,r){var n=al(e),i=$n(e,n);null!=r||Ps(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=$n(e,al(e)));var o=!(Ps(r)&&"chain"in r&&!r.chain),a=Es(t);return rr(i,function(r){var n=e[r];t[r]=n,a&&(t.prototype[r]=function(){var e=this.__chain__;if(o||e){var r=t(this.__wrapped__);return(r.__actions__=no(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,cr([this.value()],arguments))})}),t}function Fl(){}var kl=yo(lr),Bl=yo(ir),Ul=yo(pr);function Vl(t){return Zo(t)?xr(pa(t)):(e=t,function(t){return Kn(t,e)});var e}var jl=xo(),Gl=xo(!0);function Hl(){return[]}function Wl(){return!1}var Xl=vo(function(t,e){return t+e},0),Yl=So("ceil"),ql=vo(function(t,e){return t/e},1),Zl=So("floor");var $l,Kl=vo(function(t,e){return t*e},1),Ql=So("round"),Jl=vo(function(t,e){return t-e},0);return fn.after=function(t,e){if("function"!=typeof e)throw new oe(a);return t=Gs(t),function(){if(--t<1)return e.apply(this,arguments)}},fn.ary=rs,fn.assign=qs,fn.assignIn=Zs,fn.assignInWith=$s,fn.assignWith=Ks,fn.at=Qs,fn.before=ns,fn.bind=is,fn.bindAll=Tl,fn.bindKey=os,fn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return _s(t)?t:[t]},fn.chain=Va,fn.chunk=function(t,e,r){e=(r?qo(t,e,r):e===n)?1:Wr(Gs(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var o=0,a=0,s=Kt(He(i/e));oo?0:o+r),(i=i===n||i>o?o:Gs(i))<0&&(i+=o),i=r>i?0:Hs(i);r>>0)?(t=Ys(t))&&("string"==typeof e||null!=e&&!Os(e))&&!(e=Fi(e))&&Ir(t)?Zi(Ur(t),0,r):t.split(e,r):[]},fn.spread=function(t,e){if("function"!=typeof t)throw new oe(a);return e=null==e?0:Wr(Gs(e),0),Mi(function(r){var n=r[e],i=Zi(r,0,e);return n&&cr(i,n),tr(t,this,i)})},fn.tail=function(t){var e=null==t?0:t.length;return e?Ri(t,1,e):[]},fn.take=function(t,e,r){return t&&t.length?Ri(t,0,(e=r||e===n?1:Gs(e))<0?0:e):[]},fn.takeRight=function(t,e,r){var i=null==t?0:t.length;return i?Ri(t,(e=i-(e=r||e===n?1:Gs(e)))<0?0:e,i):[]},fn.takeRightWhile=function(t,e){return t&&t.length?Vi(t,Fo(e,3),!1,!0):[]},fn.takeWhile=function(t,e){return t&&t.length?Vi(t,Fo(e,3)):[]},fn.tap=function(t,e){return e(t),t},fn.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new oe(a);return Ps(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),as(t,e,{leading:n,maxWait:e,trailing:i})},fn.thru=ja,fn.toArray=Vs,fn.toPairs=dl,fn.toPairsIn=fl,fn.toPath=function(t){return _s(t)?lr(t,pa):Fs(t)?[t]:no(ha(Ys(t)))},fn.toPlainObject=Xs,fn.transform=function(t,e,r){var n=_s(t),i=n||Ss(t)||ks(t);if(e=Fo(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:Ps(t)&&Es(o)?mn(we(t)):{}}return(i?rr:qn)(t,function(t,n,i){return e(r,t,n,i)}),r},fn.unary=function(t){return rs(t,1)},fn.union=La,fn.unionBy=Ra,fn.unionWith=Na,fn.uniq=function(t){return t&&t.length?ki(t):[]},fn.uniqBy=function(t,e){return t&&t.length?ki(t,Fo(e,2)):[]},fn.uniqWith=function(t,e){return e="function"==typeof e?e:n,t&&t.length?ki(t,n,e):[]},fn.unset=function(t,e){return null==t||Bi(t,e)},fn.unzip=Ia,fn.unzipWith=Oa,fn.update=function(t,e,r){return null==t?t:Ui(t,e,Xi(r))},fn.updateWith=function(t,e,r,i){return i="function"==typeof i?i:n,null==t?t:Ui(t,e,Xi(r),i)},fn.values=ml,fn.valuesIn=function(t){return null==t?[]:Er(t,sl(t))},fn.without=Da,fn.words=El,fn.wrap=function(t,e){return ps(Xi(e),t)},fn.xor=za,fn.xorBy=Fa,fn.xorWith=ka,fn.zip=Ba,fn.zipObject=function(t,e){return Hi(t||[],e||[],Pn)},fn.zipObjectDeep=function(t,e){return Hi(t||[],e||[],Ci)},fn.zipWith=Ua,fn.entries=dl,fn.entriesIn=fl,fn.extend=Zs,fn.extendWith=$s,zl(fn,fn),fn.add=Xl,fn.attempt=Cl,fn.camelCase=gl,fn.capitalize=vl,fn.ceil=Yl,fn.clamp=function(t,e,r){return r===n&&(r=e,e=n),r!==n&&(r=(r=Ws(r))==r?r:0),e!==n&&(e=(e=Ws(e))==e?e:0),Dn(Ws(t),e,r)},fn.clone=function(t){return zn(t,p)},fn.cloneDeep=function(t){return zn(t,u|p)},fn.cloneDeepWith=function(t,e){return zn(t,u|p,e="function"==typeof e?e:n)},fn.cloneWith=function(t,e){return zn(t,p,e="function"==typeof e?e:n)},fn.conformsTo=function(t,e){return null==e||Fn(t,e,al(e))},fn.deburr=yl,fn.defaultTo=function(t,e){return null==t||t!=t?e:t},fn.divide=ql,fn.endsWith=function(t,e,r){t=Ys(t),e=Fi(e);var i=t.length,o=r=r===n?i:Dn(Gs(r),0,i);return(r-=e.length)>=0&&t.slice(r,o)==e},fn.eq=ms,fn.escape=function(t){return(t=Ys(t))&&Mt.test(t)?t.replace(wt,Rr):t},fn.escapeRegExp=function(t){return(t=Ys(t))&&Nt.test(t)?t.replace(Rt,"\\$&"):t},fn.every=function(t,e,r){var i=_s(t)?ir:jn;return r&&qo(t,e,r)&&(e=n),i(t,Fo(e,3))},fn.find=Wa,fn.findIndex=ya,fn.findKey=function(t,e){return fr(t,Fo(e,3),qn)},fn.findLast=Xa,fn.findLastIndex=_a,fn.findLastKey=function(t,e){return fr(t,Fo(e,3),Zn)},fn.floor=Zl,fn.forEach=Ya,fn.forEachRight=qa,fn.forIn=function(t,e){return null==t?t:Xn(t,Fo(e,3),sl)},fn.forInRight=function(t,e){return null==t?t:Yn(t,Fo(e,3),sl)},fn.forOwn=function(t,e){return t&&qn(t,Fo(e,3))},fn.forOwnRight=function(t,e){return t&&Zn(t,Fo(e,3))},fn.get=el,fn.gt=gs,fn.gte=vs,fn.has=function(t,e){return null!=t&&Ho(t,e,ei)},fn.hasIn=rl,fn.head=ba,fn.identity=Nl,fn.includes=function(t,e,r,n){t=bs(t)?t:ml(t),r=r&&!n?Gs(r):0;var i=t.length;return r<0&&(r=Wr(i+r,0)),zs(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&gr(t,e,r)>-1},fn.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:Gs(r);return i<0&&(i=Wr(n+i,0)),gr(t,e,i)},fn.inRange=function(t,e,r){return e=js(e),r===n?(r=e,e=0):r=js(r),t=Ws(t),(i=t)>=Xr(o=e,a=r)&&i=-N&&t<=N},fn.isSet=Ds,fn.isString=zs,fn.isSymbol=Fs,fn.isTypedArray=ks,fn.isUndefined=function(t){return t===n},fn.isWeakMap=function(t){return Ls(t)&&Go(t)==ot},fn.isWeakSet=function(t){return Ls(t)&&Jn(t)==at},fn.join=function(t,e){return null==t?"":Gr.call(t,e)},fn.kebabCase=_l,fn.last=Aa,fn.lastIndexOf=function(t,e,r){var i=null==t?0:t.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=Gs(r))<0?Wr(i+o,0):Xr(o,i-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,o):mr(t,yr,o,!0)},fn.lowerCase=xl,fn.lowerFirst=bl,fn.lt=Bs,fn.lte=Us,fn.max=function(t){return t&&t.length?Gn(t,Nl,ti):n},fn.maxBy=function(t,e){return t&&t.length?Gn(t,Fo(e,2),ti):n},fn.mean=function(t){return _r(t,Nl)},fn.meanBy=function(t,e){return _r(t,Fo(e,2))},fn.min=function(t){return t&&t.length?Gn(t,Nl,pi):n},fn.minBy=function(t,e){return t&&t.length?Gn(t,Fo(e,2),pi):n},fn.stubArray=Hl,fn.stubFalse=Wl,fn.stubObject=function(){return{}},fn.stubString=function(){return""},fn.stubTrue=function(){return!0},fn.multiply=Kl,fn.nth=function(t,e){return t&&t.length?vi(t,Gs(e)):n},fn.noConflict=function(){return je._===this&&(je._=ge),this},fn.noop=Fl,fn.now=es,fn.pad=function(t,e,r){t=Ys(t);var n=(e=Gs(e))?Br(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return _o(Xe(i),r)+t+_o(He(i),r)},fn.padEnd=function(t,e,r){t=Ys(t);var n=(e=Gs(e))?Br(t):0;return e&&ne){var i=t;t=e,e=i}if(r||t%1||e%1){var o=Zr();return Xr(t+o*(e-t+ke("1e-"+((o+"").length-1))),e)}return wi(t,e)},fn.reduce=function(t,e,r){var n=_s(t)?ur:wr,i=arguments.length<3;return n(t,Fo(e,4),r,i,Un)},fn.reduceRight=function(t,e,r){var n=_s(t)?hr:wr,i=arguments.length<3;return n(t,Fo(e,4),r,i,Vn)},fn.repeat=function(t,e,r){return e=(r?qo(t,e,r):e===n)?1:Gs(e),Si(Ys(t),e)},fn.replace=function(){var t=arguments,e=Ys(t[0]);return t.length<3?e:e.replace(t[1],t[2])},fn.result=function(t,e,r){var i=-1,o=(e=Yi(e,t)).length;for(o||(o=1,t=n);++iN)return[];var r=D,n=Xr(t,D);e=Fo(e),t-=D;for(var i=Mr(n,e);++r=a)return t;var l=r-Br(i);if(l<1)return i;var c=s?Zi(s,0,l).join(""):t.slice(0,l);if(o===n)return c+i;if(s&&(l+=c.length-l),Os(o)){if(t.slice(l).search(o)){var u,h=c;for(o.global||(o=ne(o.source,Ys(jt.exec(o))+"g")),o.lastIndex=0;u=o.exec(h);)var p=u.index;c=c.slice(0,p===n?l:p)}}else if(t.indexOf(Fi(o),l)!=l){var d=c.lastIndexOf(o);d>-1&&(c=c.slice(0,d))}return c+i},fn.unescape=function(t){return(t=Ys(t))&&St.test(t)?t.replace(bt,Vr):t},fn.uniqueId=function(t){var e=++pe;return Ys(t)+e},fn.upperCase=Ml,fn.upperFirst=Al,fn.each=Ya,fn.eachRight=qa,fn.first=ba,zl(fn,($l={},qn(fn,function(t,e){he.call(fn.prototype,e)||($l[e]=t)}),$l),{chain:!1}),fn.VERSION="4.17.5",rr(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){fn[t].placeholder=fn}),rr(["drop","take"],function(t,e){yn.prototype[t]=function(r){r=r===n?1:Wr(Gs(r),0);var i=this.__filtered__&&!e?new yn(this):this.clone();return i.__filtered__?i.__takeCount__=Xr(r,i.__takeCount__):i.__views__.push({size:Xr(r,D),type:t+(i.__dir__<0?"Right":"")}),i},yn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),rr(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==P||3==r;yn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Fo(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),rr(["head","last"],function(t,e){var r="take"+(e?"Right":"");yn.prototype[t]=function(){return this[r](1).value()[0]}}),rr(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");yn.prototype[t]=function(){return this.__filtered__?new yn(this):this[r](1)}}),yn.prototype.compact=function(){return this.filter(Nl)},yn.prototype.find=function(t){return this.filter(t).head()},yn.prototype.findLast=function(t){return this.reverse().find(t)},yn.prototype.invokeMap=Mi(function(t,e){return"function"==typeof t?new yn(this):this.map(function(r){return ii(r,t,e)})}),yn.prototype.reject=function(t){return this.filter(us(Fo(t)))},yn.prototype.slice=function(t,e){t=Gs(t);var r=this;return r.__filtered__&&(t>0||e<0)?new yn(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==n&&(r=(e=Gs(e))<0?r.dropRight(-e):r.take(e-t)),r)},yn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},yn.prototype.toArray=function(){return this.take(D)},qn(yn.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),o=fn[i?"take"+("last"==e?"Right":""):e],a=i||/^find/.test(e);o&&(fn.prototype[e]=function(){var e=this.__wrapped__,s=i?[1]:arguments,l=e instanceof yn,c=s[0],u=l||_s(e),h=function(t){var e=o.apply(fn,cr([t],s));return i&&p?e[0]:e};u&&r&&"function"==typeof c&&1!=c.length&&(l=u=!1);var p=this.__chain__,d=!!this.__actions__.length,f=a&&!p,m=l&&!d;if(!a&&u){e=m?e:new yn(this);var g=t.apply(e,s);return g.__actions__.push({func:ja,args:[h],thisArg:n}),new vn(g,p)}return f&&m?t.apply(this,s):(g=this.thru(h),f?i?g.value()[0]:g.value():g)})}),rr(["pop","push","shift","sort","splice","unshift"],function(t){var e=ae[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);fn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(_s(i)?i:[],t)}return this[r](function(r){return e.apply(_s(r)?r:[],t)})}}),qn(yn.prototype,function(t,e){var r=fn[e];if(r){var n=r.name+"";(on[n]||(on[n]=[])).push({name:e,func:r})}}),on[mo(n,g).name]=[{name:"wrapper",func:n}],yn.prototype.clone=function(){var t=new yn(this.__wrapped__);return t.__actions__=no(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=no(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=no(this.__views__),t},yn.prototype.reverse=function(){if(this.__filtered__){var t=new yn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},yn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=_s(t),n=e<0,i=r?t.length:0,o=function(t,e,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:t,value:t?n:this.__values__[this.__index__++]}},fn.prototype.plant=function(t){for(var e,r=this;r instanceof gn;){var i=fa(r);i.__index__=0,i.__values__=n,e?o.__wrapped__=i:e=i;var o=i;r=r.__wrapped__}return o.__wrapped__=t,e},fn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof yn){var e=t;return this.__actions__.length&&(e=new yn(this)),(e=e.reverse()).__actions__.push({func:ja,args:[Pa],thisArg:n}),new vn(e,this.__chain__)}return this.thru(Pa)},fn.prototype.toJSON=fn.prototype.valueOf=fn.prototype.value=function(){return ji(this.__wrapped__,this.__actions__)},fn.prototype.first=fn.prototype.head,Pe&&(fn.prototype[Pe]=function(){return this}),fn}();"function"==typeof n&&"object"==typeof n.amd&&n.amd?(je._=jr,n(function(){return jr})):He?((He.exports=jr)._=jr,Ge._=jr):je._=jr}).call(t)});function i(){}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}),void 0===Math.sign&&(Math.sign=function(t){return t<0?-1:t>0?1:+t}),void 0===Function.prototype.name&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),r=1;r>=4,s[t]=a[19===t?3&o|8:o]);return s.join("")}),clamp:function(t,e,r){return Math.max(e,Math.min(r,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,r,n,i){return n+(t-e)*(i-n)/(r-e)},lerp:function(t,e,r){return(1-r)*t+r*e},smoothstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*(3-2*t)},smootherstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*ve.DEG2RAD},radToDeg:function(t){return t*ve.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}};function ye(t,e){this.x=t||0,this.y=e||0}Object.defineProperties(ye.prototype,{width:{get:function(){return this.x},set:function(t){this.x=t}},height:{get:function(){return this.y},set:function(t){this.y=t}}}),Object.assign(ye.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:(c=new ye,u=new ye,function(t,e){return c.set(t,t),u.set(e,e),this.clamp(c,u)}),clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.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()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y;return e*e+r*r},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var r=Math.cos(e),n=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*r-o*n+t.x,this.y=i*n+o*r+t.y,this}});var _e,xe,be,we,Se,Me,Ae,Ee,Ce,Te,Pe,Le,Re,Ne,Ie,Oe,De,ze,Fe,ke=0;function Be(t,e,r,n,i,o,a,s,l,c){Object.defineProperty(this,"id",{value:ke++}),this.uuid=ve.generateUUID(),this.name="",this.image=void 0!==t?t:Be.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:Be.DEFAULT_MAPPING,this.wrapS=void 0!==r?r:gt,this.wrapT=void 0!==n?n:gt,this.magFilter=void 0!==i?i:bt,this.minFilter=void 0!==o?o:St,this.anisotropy=void 0!==l?l:1,this.format=void 0!==a?a:kt,this.type=void 0!==s?s:Mt,this.offset=new ye(0,0),this.repeat=new ye(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==c?c:le,this.version=0,this.onUpdate=null}function Ue(t,e,r,n){this.x=t||0,this.y=e||0,this.z=r||0,this.w=void 0!==n?n:1}function Ve(t,e,r){this.uuid=ve.generateUUID(),this.width=t,this.height=e,this.scissor=new Ue(0,0,t,e),this.scissorTest=!1,this.viewport=new Ue(0,0,t,e),void 0===(r=r||{}).minFilter&&(r.minFilter=bt),this.texture=new Be(void 0,void 0,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.depthBuffer=void 0===r.depthBuffer||r.depthBuffer,this.stencilBuffer=void 0===r.stencilBuffer||r.stencilBuffer,this.depthTexture=void 0!==r.depthTexture?r.depthTexture:null}function je(t,e,r){Ve.call(this,t,e,r),this.activeCubeFace=0,this.activeMipMapLevel=0}function Ge(t,e,r,n){this._x=t||0,this._y=e||0,this._z=r||0,this._w=void 0!==n?n:1}function He(t,e,r){this.x=t||0,this.y=e||0,this.z=r||0}function We(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length}function Xe(t,e,r,n,i,o,a,s,l,c,u,h){Be.call(this,null,o,a,s,l,c,n,i,u,h),this.image={data:t,width:e,height:r},this.magFilter=void 0!==l?l:yt,this.minFilter=void 0!==c?c:yt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function Ye(t,e,r,n,i,o,a,s,l,c){t=void 0!==t?t:[],e=void 0!==e?e:lt,Be.call(this,t,e,r,n,i,o,a,s,l,c),this.flipY=!1}Be.DEFAULT_IMAGE=void 0,Be.DEFAULT_MAPPING=300,Object.defineProperty(Be.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Be.prototype,i.prototype,{constructor:Be,isTexture:!0,clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){if(void 0!==t.textures[this.uuid])return t.textures[this.uuid];var e={metadata:{version:4.5,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 r=this.image;void 0===r.uuid&&(r.uuid=ve.generateUUID()),void 0===t.images[r.uuid]&&(t.images[r.uuid]={uuid:r.uuid,url:function(t){var e;if(t instanceof HTMLCanvasElement)e=t;else{(e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")).width=t.width,e.height=t.height;var r=e.getContext("2d");t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height)}return e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}(r)}),e.image=r.uuid}return t.textures[this.uuid]=e,e},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300===this.mapping){if(t.multiply(this.repeat),t.add(this.offset),t.x<0||t.x>1)switch(this.wrapS){case mt:t.x=t.x-Math.floor(t.x);break;case gt:t.x=t.x<0?0:1;break;case vt:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case mt:t.y=t.y-Math.floor(t.y);break;case gt:t.y=t.y<0?0:1;break;case vt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}this.flipY&&(t.y=1-t.y)}}}),Object.assign(Ue.prototype,{isVector4:!0,set:function(t,e,r,n){return this.x=t,this.y=e,this.z=r,this.w=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*n+o[12]*i,this.y=o[1]*e+o[5]*r+o[9]*n+o[13]*i,this.z=o[2]*e+o[6]*r+o[10]*n+o[14]*i,this.w=o[3]*e+o[7]*r+o[11]*n+o[15]*i,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,r,n,i,o=t.elements,a=o[0],s=o[4],l=o[8],c=o[1],u=o[5],h=o[9],p=o[2],d=o[6],f=o[10];if(Math.abs(s-c)<.01&&Math.abs(l-p)<.01&&Math.abs(h-d)<.01){if(Math.abs(s+c)<.1&&Math.abs(l+p)<.1&&Math.abs(h+d)<.1&&Math.abs(a+u+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(a+1)/2,g=(u+1)/2,v=(f+1)/2,y=(s+c)/4,_=(l+p)/4,x=(h+d)/4;return m>g&&m>v?m<.01?(r=0,n=.707106781,i=.707106781):(n=y/(r=Math.sqrt(m)),i=_/r):g>v?g<.01?(r=.707106781,n=0,i=.707106781):(r=y/(n=Math.sqrt(g)),i=x/n):v<.01?(r=.707106781,n=.707106781,i=0):(r=_/(i=Math.sqrt(v)),n=x/i),this.set(r,n,i,e),this}var b=Math.sqrt((d-h)*(d-h)+(l-p)*(l-p)+(c-s)*(c-s));return Math.abs(b)<.001&&(b=1),this.x=(d-h)/b,this.y=(l-p)/b,this.z=(c-s)/b,this.w=Math.acos((a+u+f-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(t,e){return void 0===_e&&(_e=new Ue,xe=new Ue),_e.set(t,t,t,t),xe.set(e,e,e,e),this.clamp(_e,xe)},clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}}),Object.assign(Ve.prototype,i.prototype,{isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),je.prototype=Object.create(Ve.prototype),je.prototype.constructor=je,je.prototype.isWebGLRenderTargetCube=!0,Object.assign(Ge,{slerp:function(t,e,r,n){return r.copy(t).slerp(e,n)},slerpFlat:function(t,e,r,n,i,o,a){var s=r[n+0],l=r[n+1],c=r[n+2],u=r[n+3],h=i[o+0],p=i[o+1],d=i[o+2],f=i[o+3];if(u!==f||s!==h||l!==p||c!==d){var m=1-a,g=s*h+l*p+c*d+u*f,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var _=Math.sqrt(y),x=Math.atan2(_,g*v);m=Math.sin(m*x)/_,a=Math.sin(a*x)/_}var b=a*v;if(s=s*m+h*b,l=l*m+p*b,c=c*m+d*b,u=u*m+f*b,m===1-a){var w=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=w,l*=w,c*=w,u*=w}}t[e]=s,t[e+1]=l,t[e+2]=c,t[e+3]=u}}),Object.defineProperties(Ge.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(t){this._w=t,this.onChangeCallback()}}}),Object.assign(Ge.prototype,{set:function(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._w=n,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=t._x,n=t._y,i=t._z,o=t.order,a=Math.cos,s=Math.sin,l=a(r/2),c=a(n/2),u=a(i/2),h=s(r/2),p=s(n/2),d=s(i/2);return"XYZ"===o?(this._x=h*c*u+l*p*d,this._y=l*p*u-h*c*d,this._z=l*c*d+h*p*u,this._w=l*c*u-h*p*d):"YXZ"===o?(this._x=h*c*u+l*p*d,this._y=l*p*u-h*c*d,this._z=l*c*d-h*p*u,this._w=l*c*u+h*p*d):"ZXY"===o?(this._x=h*c*u-l*p*d,this._y=l*p*u+h*c*d,this._z=l*c*d+h*p*u,this._w=l*c*u-h*p*d):"ZYX"===o?(this._x=h*c*u-l*p*d,this._y=l*p*u+h*c*d,this._z=l*c*d-h*p*u,this._w=l*c*u+h*p*d):"YZX"===o?(this._x=h*c*u+l*p*d,this._y=l*p*u+h*c*d,this._z=l*c*d-h*p*u,this._w=l*c*u-h*p*d):"XZY"===o&&(this._x=h*c*u-l*p*d,this._y=l*p*u-h*c*d,this._z=l*c*d+h*p*u,this._w=l*c*u+h*p*d),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var r=e/2,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,r=t.elements,n=r[0],i=r[4],o=r[8],a=r[1],s=r[5],l=r[9],c=r[2],u=r[6],h=r[10],p=n+s+h;return p>0?(e=.5/Math.sqrt(p+1),this._w=.25/e,this._x=(u-l)*e,this._y=(o-c)*e,this._z=(a-i)*e):n>s&&n>h?(e=2*Math.sqrt(1+n-s-h),this._w=(u-l)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(o+c)/e):s>h?(e=2*Math.sqrt(1+s-n-h),this._w=(o-c)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(l+u)/e):(e=2*Math.sqrt(1+h-n-s),this._w=(a-i)/e,this._x=(o+c)/e,this._y=(l+u)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:(we=new He,function(t,e){return void 0===we&&(we=new He),(be=t.dot(e)+1)<1e-6?(be=0,Math.abs(t.x)>Math.abs(t.z)?we.set(-t.y,t.x,0):we.set(0,-t.z,t.y)):we.crossVectors(t,e),this._x=we.x,this._y=we.y,this._z=we.z,this._w=be,this.normalize()}),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?this.multiplyQuaternions(t,e):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var r=t._x,n=t._y,i=t._z,o=t._w,a=e._x,s=e._y,l=e._z,c=e._w;return this._x=r*c+o*a+n*l-i*s,this._y=n*c+o*s+i*a-r*l,this._z=i*c+o*l+r*s-n*a,this._w=o*c-r*a-n*s-i*l,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var r=this._x,n=this._y,i=this._z,o=this._w,a=o*t._w+r*t._x+n*t._y+i*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=r,this._y=n,this._z=i,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(r+this._x),this._y=.5*(n+this._y),this._z=.5*(i+this._z),this;var l=Math.atan2(s,a),c=Math.sin((1-e)*l)/s,u=Math.sin(e*l)/s;return this._w=o*c+this._w*u,this._x=r*c+this._x*u,this._y=n*c+this._y*u,this._z=i*c+this._z*u,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(He.prototype,{isVector3:!0,set:function(t,e,r){return this.x=t,this.y=e,this.z=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?this.multiplyVectors(t,e):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:(Le=new Ge,function(t){return!t||t.isEuler,this.applyQuaternion(Le.setFromEuler(t))}),applyAxisAngle:(Pe=new Ge,function(t,e){return this.applyQuaternion(Pe.setFromAxisAngle(t,e))}),applyMatrix3:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6]*n,this.y=i[1]*e+i[4]*r+i[7]*n,this.z=i[2]*e+i[5]*r+i[8]*n,this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements,o=1/(i[3]*e+i[7]*r+i[11]*n+i[15]);return this.x=(i[0]*e+i[4]*r+i[8]*n+i[12])*o,this.y=(i[1]*e+i[5]*r+i[9]*n+i[13])*o,this.z=(i[2]*e+i[6]*r+i[10]*n+i[14])*o,this},applyQuaternion:function(t){var e=this.x,r=this.y,n=this.z,i=t.x,o=t.y,a=t.z,s=t.w,l=s*e+o*n-a*r,c=s*r+a*e-i*n,u=s*n+i*r-o*e,h=-i*e-o*r-a*n;return this.x=l*s+h*-i+c*-a-u*-o,this.y=c*s+h*-o+u*-i-l*-a,this.z=u*s+h*-a+l*-o-c*-i,this},project:(Te=new We,function(t){return Te.multiplyMatrices(t.projectionMatrix,Te.getInverse(t.matrixWorld)),this.applyMatrix4(Te)}),unproject:(Ce=new We,function(t){return Ce.multiplyMatrices(t.matrixWorld,Ce.getInverse(t.projectionMatrix)),this.applyMatrix4(Ce)}),transformDirection:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*r+i[8]*n,this.y=i[1]*e+i[5]*r+i[9]*n,this.z=i[2]*e+i[6]*r+i[10]*n,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:(Ae=new He,Ee=new He,function(t,e){return Ae.set(t,t,t),Ee.set(e,e,e),this.clamp(Ae,Ee)}),clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.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()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},cross:function(t,e){if(void 0!==e)return this.crossVectors(t,e);var r=this.x,n=this.y,i=this.z;return this.x=n*t.z-i*t.y,this.y=i*t.x-r*t.z,this.z=r*t.y-n*t.x,this},crossVectors:function(t,e){var r=t.x,n=t.y,i=t.z,o=e.x,a=e.y,s=e.z;return this.x=n*s-i*a,this.y=i*o-r*s,this.z=r*a-n*o,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:(Me=new He,function(t){return Me.copy(this).projectOnVector(t),this.sub(Me)}),reflect:(Se=new He,function(t){return this.sub(Se.copy(t).multiplyScalar(2*this.dot(t)))}),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(ve.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromCylindrical:function(t){return this.x=t.radius*Math.sin(t.theta),this.y=t.y,this.z=t.radius*Math.cos(t.theta),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}}),Object.assign(We.prototype,{isMatrix4:!0,set:function(t,e,r,n,i,o,a,s,l,c,u,h,p,d,f,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=r,g[12]=n,g[1]=i,g[5]=o,g[9]=a,g[13]=s,g[2]=l,g[6]=c,g[10]=u,g[14]=h,g[3]=p,g[7]=d,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new We).fromArray(this.elements)},copy:function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this},copyPosition:function(t){var e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this},extractBasis:function(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this},extractRotation:(Fe=new He,function(t){var e=this.elements,r=t.elements,n=1/Fe.setFromMatrixColumn(t,0).length(),i=1/Fe.setFromMatrixColumn(t,1).length(),o=1/Fe.setFromMatrixColumn(t,2).length();return e[0]=r[0]*n,e[1]=r[1]*n,e[2]=r[2]*n,e[4]=r[4]*i,e[5]=r[5]*i,e[6]=r[6]*i,e[8]=r[8]*o,e[9]=r[9]*o,e[10]=r[10]*o,this}),makeRotationFromEuler:function(t){!t||t.isEuler;var e=this.elements,r=t.x,n=t.y,i=t.z,o=Math.cos(r),a=Math.sin(r),s=Math.cos(n),l=Math.sin(n),c=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){var h=o*c,p=o*u,d=a*c,f=a*u;e[0]=s*c,e[4]=-s*u,e[8]=l,e[1]=p+d*l,e[5]=h-f*l,e[9]=-a*s,e[2]=f-h*l,e[6]=d+p*l,e[10]=o*s}else if("YXZ"===t.order){var m=s*c,g=s*u,v=l*c,y=l*u;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*l,e[1]=o*u,e[5]=o*c,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){m=s*c,g=s*u,v=l*c,y=l*u;e[0]=m-y*a,e[4]=-o*u,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*c,e[9]=y-m*a,e[2]=-o*l,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){h=o*c,p=o*u,d=a*c,f=a*u;e[0]=s*c,e[4]=d*l-p,e[8]=h*l+f,e[1]=s*u,e[5]=f*l+h,e[9]=p*l-d,e[2]=-l,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var _=o*s,x=o*l,b=a*s,w=a*l;e[0]=s*c,e[4]=w-_*u,e[8]=b*u+x,e[1]=u,e[5]=o*c,e[9]=-a*c,e[2]=-l*c,e[6]=x*u+b,e[10]=_-w*u}else if("XZY"===t.order){_=o*s,x=o*l,b=a*s,w=a*l;e[0]=s*c,e[4]=-u,e[8]=l*c,e[1]=_*u+w,e[5]=o*c,e[9]=x*u-b,e[2]=b*u-x,e[6]=a*c,e[10]=w*u+_}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,r=t._x,n=t._y,i=t._z,o=t._w,a=r+r,s=n+n,l=i+i,c=r*a,u=r*s,h=r*l,p=n*s,d=n*l,f=i*l,m=o*a,g=o*s,v=o*l;return e[0]=1-(p+f),e[4]=u-v,e[8]=h+g,e[1]=u+v,e[5]=1-(c+f),e[9]=d-m,e[2]=h-g,e[6]=d+m,e[10]=1-(c+p),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:(Oe=new He,De=new He,ze=new He,function(t,e,r){var n=this.elements;return ze.subVectors(t,e),0===ze.lengthSq()&&(ze.z=1),ze.normalize(),Oe.crossVectors(r,ze),0===Oe.lengthSq()&&(1===Math.abs(r.z)?ze.x+=1e-4:ze.z+=1e-4,ze.normalize(),Oe.crossVectors(r,ze)),Oe.normalize(),De.crossVectors(ze,Oe),n[0]=Oe.x,n[4]=De.x,n[8]=ze.x,n[1]=Oe.y,n[5]=De.y,n[9]=ze.y,n[2]=Oe.z,n[6]=De.z,n[10]=ze.z,this}),multiply:function(t,e){return void 0!==e?this.multiplyMatrices(t,e):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var r=t.elements,n=e.elements,i=this.elements,o=r[0],a=r[4],s=r[8],l=r[12],c=r[1],u=r[5],h=r[9],p=r[13],d=r[2],f=r[6],m=r[10],g=r[14],v=r[3],y=r[7],_=r[11],x=r[15],b=n[0],w=n[4],S=n[8],M=n[12],A=n[1],E=n[5],C=n[9],T=n[13],P=n[2],L=n[6],R=n[10],N=n[14],I=n[3],O=n[7],D=n[11],z=n[15];return i[0]=o*b+a*A+s*P+l*I,i[4]=o*w+a*E+s*L+l*O,i[8]=o*S+a*C+s*R+l*D,i[12]=o*M+a*T+s*N+l*z,i[1]=c*b+u*A+h*P+p*I,i[5]=c*w+u*E+h*L+p*O,i[9]=c*S+u*C+h*R+p*D,i[13]=c*M+u*T+h*N+p*z,i[2]=d*b+f*A+m*P+g*I,i[6]=d*w+f*E+m*L+g*O,i[10]=d*S+f*C+m*R+g*D,i[14]=d*M+f*T+m*N+g*z,i[3]=v*b+y*A+_*P+x*I,i[7]=v*w+y*E+_*L+x*O,i[11]=v*S+y*C+_*R+x*D,i[15]=v*M+y*T+_*N+x*z,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute:(Ie=new He,function(t){for(var e=0,r=t.count;e0)return t;var i=e*r,o=Ke[i];if(void 0===o&&(o=new Float32Array(i),Ke[i]=o),0!==e){n.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=r,t[a].toArray(o,s)}return o}function rr(t,e){var r=Qe[e];void 0===r&&(r=new Int32Array(e),Qe[e]=r);for(var n=0;n!==e;++n)r[n]=t.allocTextureUnit();return r}function nr(t,e){t.uniform1f(this.addr,e)}function ir(t,e){t.uniform1i(this.addr,e)}function or(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function ar(t,e){void 0!==e.x?t.uniform3f(this.addr,e.x,e.y,e.z):void 0!==e.r?t.uniform3f(this.addr,e.r,e.g,e.b):t.uniform3fv(this.addr,e)}function sr(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function lr(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function cr(t,e){void 0===e.elements?t.uniformMatrix3fv(this.addr,!1,e):(tr.set(e.elements),t.uniformMatrix3fv(this.addr,!1,tr))}function ur(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(Je.set(e.elements),t.uniformMatrix4fv(this.addr,!1,Je))}function hr(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTexture2D(e||qe,n)}function pr(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTextureCube(e||Ze,n)}function dr(t,e){t.uniform2iv(this.addr,e)}function fr(t,e){t.uniform3iv(this.addr,e)}function mr(t,e){t.uniform4iv(this.addr,e)}function gr(t,e){t.uniform1fv(this.addr,e)}function vr(t,e){t.uniform1iv(this.addr,e)}function yr(t,e){t.uniform2fv(this.addr,er(e,this.size,2))}function _r(t,e){t.uniform3fv(this.addr,er(e,this.size,3))}function xr(t,e){t.uniform4fv(this.addr,er(e,this.size,4))}function br(t,e){t.uniformMatrix2fv(this.addr,!1,er(e,this.size,4))}function wr(t,e){t.uniformMatrix3fv(this.addr,!1,er(e,this.size,9))}function Sr(t,e){t.uniformMatrix4fv(this.addr,!1,er(e,this.size,16))}function Mr(t,e,r){var n=e.length,i=rr(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTexture2D(e[o]||qe,i[o])}function Ar(t,e,r){var n=e.length,i=rr(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTextureCube(e[o]||Ze,i[o])}function Er(t,e,r){this.id=t,this.addr=r,this.setValue=function(t){switch(t){case 5126:return nr;case 35664:return or;case 35665:return ar;case 35666:return sr;case 35674:return lr;case 35675:return cr;case 35676:return ur;case 35678:case 36198:return hr;case 35680:return pr;case 5124:case 35670:return ir;case 35667:case 35671:return dr;case 35668:case 35672:return fr;case 35669:case 35673:return mr}}(e.type)}function Cr(t,e,r){this.id=t,this.addr=r,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return gr;case 35664:return yr;case 35665:return _r;case 35666:return xr;case 35674:return br;case 35675:return wr;case 35676:return Sr;case 35678:return Mr;case 35680:return Ar;case 5124:case 35670:return vr;case 35667:case 35671:return dr;case 35668:case 35672:return fr;case 35669:case 35673:return mr}}(e.type)}function Tr(t){this.id=t,$e.call(this)}Tr.prototype.setValue=function(t,e){for(var r=this.seq,n=0,i=r.length;n!==i;++n){var o=r[n];o.setValue(t,e[o.id])}};var Pr=/([\w\d_]+)(\])?(\[|\.)?/g;function Lr(t,e){t.seq.push(e),t.map[e.id]=e}function Rr(t,e,r){var n=t.name,i=n.length;for(Pr.lastIndex=0;;){var o=Pr.exec(n),a=Pr.lastIndex,s=o[1],l="]"===o[2],c=o[3];if(l&&(s|=0),void 0===c||"["===c&&a+2===i){Lr(r,void 0===c?new Er(s,t,e):new Cr(s,t,e));break}var u=r.map[s];void 0===u&&Lr(r,u=new Tr(s)),r=u}}function Nr(t,e,r){$e.call(this),this.renderer=r;for(var n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),i=0;i>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,r){return this.r=t,this.g=e,this.b=r,this},setHSL:function(){function t(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+6*(e-t)*(2/3-r):t}return function(e,r,n){if(e=ve.euclideanModulo(e,1),r=ve.clamp(r,0,1),n=ve.clamp(n,0,1),0===r)this.r=this.g=this.b=n;else{var i=n<=.5?n*(1+r):n+r-n*r,o=2*n-i;this.r=t(o,i,e+1/3),this.g=t(o,i,e),this.b=t(o,i,e-1/3)}return this}}(),setStyle:function(t){function e(t){void 0!==t&&parseFloat(t)}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var n,i=r[1],o=r[2];switch(i){case"rgb":case"rgba":if(n=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,e(n[5]),this;if(n=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,e(n[5]),this;break;case"hsl":case"hsla":if(n=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(n[1])/360,s=parseInt(n[2],10)/100,l=parseInt(n[3],10)/100;return e(n[5]),this.setHSL(a,s,l)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(t)){var c,u=(c=r[1]).length;if(3===u)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===u)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}t&&t.length>0&&(void 0!==(c=Ir[t])&&this.setHex(c));return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var r=e>0?1/e:1;return this.r=Math.pow(t.r,r),this.g=Math.pow(t.g,r),this.b=Math.pow(t.b,r),this},convertGammaToLinear:function(){var t=this.r,e=this.g,r=this.b;return this.r=t*t,this.g=e*e,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){var e,r,n=t||{h:0,s:0,l:0},i=this.r,o=this.g,a=this.b,s=Math.max(i,o,a),l=Math.min(i,o,a),c=(l+s)/2;if(l===s)e=0,r=0;else{var u=s-l;switch(r=c<=.5?u/(s+l):u/(2-s-l),s){case i:e=(o-a)/u+(o 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\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}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.86267 + (0.49788 + 0.01436 * y ) * y;\n\tfloat b = 3.45068 + (4.18814 + y) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = (x > 0.0) ? v : 0.5 * inversesqrt( 1.0 - x * x ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tvec3 result = vec3( LTC_ClippedSphereFormFactor( vectorFormFactor ) );\n\treturn result;\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 = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\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 PI_HALF 1.5707963267949\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}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\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:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\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 += normalize( objectNormal ) * ( 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\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn 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\treturn 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\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn 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\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn 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\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn 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, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = 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 envMapIntensity;\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_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\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\tvarying float fogDepth;\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\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",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\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\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\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\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 ( angleCos > spotLight.coneCos ) {\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_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltcMat;\tuniform sampler2D ltcMag;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\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\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = 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 = 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\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = 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 = 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 = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, 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 = 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\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\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}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tfloat norm = texture2D( ltcMag, uv ).a;\n\t\tvec4 t = texture2D( ltcMat, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( 1, 0, t.y ),\n\t\t\tvec3( 0, t.z, 0 ),\n\t\t\tvec3( t.w, 0, t.x )\n\t\t);\n\t\treflectedLight.directSpecular += lightColor * material.specularColor * norm * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1 ), rectCoords );\n\t}\n#endif\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_Direct_RectArea\t\tRE_Direct_RectArea_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 ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 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 ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, 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\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.b;\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_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 );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\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 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\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\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 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\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( 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:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\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\tfloat shadow = 1.0;\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\tshadow = (\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\tshadow = (\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\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\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, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\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 ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 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 boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\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\ttransformed = ( bindMatrixInverse * skinned ).xyz;\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\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn 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\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn 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( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\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#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\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}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\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#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\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\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 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 \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\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 \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 = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\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 \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\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 \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\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \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 \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\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 \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\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\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 \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\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\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 \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\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \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\t#include \n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\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#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#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\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 \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\t#include \n}\n",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, 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"},Ur={basic:{uniforms:kr.merge([Fr.common,Fr.specularmap,Fr.envmap,Fr.aomap,Fr.lightmap,Fr.fog]),vertexShader:Br.meshbasic_vert,fragmentShader:Br.meshbasic_frag},lambert:{uniforms:kr.merge([Fr.common,Fr.specularmap,Fr.envmap,Fr.aomap,Fr.lightmap,Fr.emissivemap,Fr.fog,Fr.lights,{emissive:{value:new Or(0)}}]),vertexShader:Br.meshlambert_vert,fragmentShader:Br.meshlambert_frag},phong:{uniforms:kr.merge([Fr.common,Fr.specularmap,Fr.envmap,Fr.aomap,Fr.lightmap,Fr.emissivemap,Fr.bumpmap,Fr.normalmap,Fr.displacementmap,Fr.gradientmap,Fr.fog,Fr.lights,{emissive:{value:new Or(0)},specular:{value:new Or(1118481)},shininess:{value:30}}]),vertexShader:Br.meshphong_vert,fragmentShader:Br.meshphong_frag},standard:{uniforms:kr.merge([Fr.common,Fr.envmap,Fr.aomap,Fr.lightmap,Fr.emissivemap,Fr.bumpmap,Fr.normalmap,Fr.displacementmap,Fr.roughnessmap,Fr.metalnessmap,Fr.fog,Fr.lights,{emissive:{value:new Or(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Br.meshphysical_vert,fragmentShader:Br.meshphysical_frag},points:{uniforms:kr.merge([Fr.points,Fr.fog]),vertexShader:Br.points_vert,fragmentShader:Br.points_frag},dashed:{uniforms:kr.merge([Fr.common,Fr.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Br.linedashed_vert,fragmentShader:Br.linedashed_frag},depth:{uniforms:kr.merge([Fr.common,Fr.displacementmap]),vertexShader:Br.depth_vert,fragmentShader:Br.depth_frag},normal:{uniforms:kr.merge([Fr.common,Fr.bumpmap,Fr.normalmap,Fr.displacementmap,{opacity:{value:1}}]),vertexShader:Br.normal_vert,fragmentShader:Br.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Br.cube_vert,fragmentShader:Br.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Br.equirect_vert,fragmentShader:Br.equirect_frag},distanceRGBA:{uniforms:kr.merge([Fr.common,Fr.displacementmap,{referencePosition:{value:new He},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Br.distanceRGBA_vert,fragmentShader:Br.distanceRGBA_frag},shadow:{uniforms:kr.merge([Fr.lights,{color:{value:new Or(0)},opacity:{value:1}}]),vertexShader:Br.shadow_vert,fragmentShader:Br.shadow_frag}};function Vr(t,e){this.min=void 0!==t?t:new ye(1/0,1/0),this.max=void 0!==e?e:new ye(-1/0,-1/0)}function jr(t,e,r,n,i){var o,a,s,l,c,u,h,p;function d(){var t,n,d,f,m,g=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),v=new Uint16Array([0,1,2,0,2,3]);o=e.createBuffer(),a=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,o),e.bufferData(e.ARRAY_BUFFER,g,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.bufferData(e.ELEMENT_ARRAY_BUFFER,v,e.STATIC_DRAW),h=e.createTexture(),p=e.createTexture(),r.bindTexture(e.TEXTURE_2D,h),e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),r.bindTexture(e.TEXTURE_2D,p),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,16,16,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),s={vertexShader:["uniform lowp int renderType;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform float rotation;","uniform sampler2D occlusionMap;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","varying float vVisibility;","void main() {","vUV = uv;","vec2 pos = position;","if ( renderType == 2 ) {","vec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );","vVisibility = visibility.r / 9.0;","vVisibility *= 1.0 - visibility.g / 9.0;","vVisibility *= visibility.b / 9.0;","vVisibility *= 1.0 - visibility.a / 9.0;","pos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;","pos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;","}","gl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["uniform lowp int renderType;","uniform sampler2D map;","uniform float opacity;","uniform vec3 color;","varying vec2 vUV;","varying float vVisibility;","void main() {","if ( renderType == 0 ) {","gl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );","} else if ( renderType == 1 ) {","gl_FragColor = texture2D( map, vUV );","} else {","vec4 texture = texture2D( map, vUV );","texture.a *= opacity * vVisibility;","gl_FragColor = texture;","gl_FragColor.rgb *= color;","}","}"].join("\n")},t=s,n=e.createProgram(),d=e.createShader(e.FRAGMENT_SHADER),f=e.createShader(e.VERTEX_SHADER),m="precision "+i.precision+" float;\n",e.shaderSource(d,m+t.fragmentShader),e.shaderSource(f,m+t.vertexShader),e.compileShader(d),e.compileShader(f),e.attachShader(n,d),e.attachShader(n,f),e.linkProgram(n),l=n,c={vertex:e.getAttribLocation(l,"position"),uv:e.getAttribLocation(l,"uv")},u={renderType:e.getUniformLocation(l,"renderType"),map:e.getUniformLocation(l,"map"),occlusionMap:e.getUniformLocation(l,"occlusionMap"),opacity:e.getUniformLocation(l,"opacity"),color:e.getUniformLocation(l,"color"),scale:e.getUniformLocation(l,"scale"),rotation:e.getUniformLocation(l,"rotation"),screenPosition:e.getUniformLocation(l,"screenPosition")}}this.render=function(t,i,s,f){if(0!==t.length){var m=new He,g=f.w/f.z,v=.5*f.z,y=.5*f.w,_=16/f.w,x=new ye(_*g,_),b=new He(1,1,0),w=new ye(1,1),S=new Vr;S.min.set(f.x,f.y),S.max.set(f.x+(f.z-16),f.y+(f.w-16)),void 0===l&&d(),r.useProgram(l),r.initAttributes(),r.enableAttribute(c.vertex),r.enableAttribute(c.uv),r.disableUnusedAttributes(),e.uniform1i(u.occlusionMap,0),e.uniform1i(u.map,1),e.bindBuffer(e.ARRAY_BUFFER,o),e.vertexAttribPointer(c.vertex,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(c.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),r.disable(e.CULL_FACE),r.buffers.depth.setMask(!1);for(var M=0,A=t.length;M.001&&P.scale>.001&&(b.x=P.x,b.y=P.y,b.z=P.z,_=P.size*P.scale/f.w,x.x=_*g,x.y=_,e.uniform3f(u.screenPosition,b.x,b.y,b.z),e.uniform2f(u.scale,x.x,x.y),e.uniform1f(u.rotation,P.rotation),e.uniform1f(u.opacity,P.opacity),e.uniform3f(u.color,P.color.r,P.color.g,P.color.b),r.setBlending(P.blending,P.blendEquation,P.blendSrc,P.blendDst),n.setTexture2D(P.texture,1),e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}}}r.enable(e.CULL_FACE),r.enable(e.DEPTH_TEST),r.buffers.depth.setMask(!0),r.reset()}}}function Gr(t,e,r,n,i,o,a,s,l){Be.call(this,t,e,r,n,i,o,a,s,l),this.needsUpdate=!0}function Hr(t,e,r,n,i){var o,a,s,l,c,u,h=new He,p=new Ge,d=new He;function f(){var t,r,n,h=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),p=new Uint16Array([0,1,2,0,2,3]);o=e.createBuffer(),a=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,o),e.bufferData(e.ARRAY_BUFFER,h,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.bufferData(e.ELEMENT_ARRAY_BUFFER,p,e.STATIC_DRAW),t=e.createProgram(),r=e.createShader(e.VERTEX_SHADER),n=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(r,["precision "+i.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),e.shaderSource(n,["precision "+i.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),e.compileShader(r),e.compileShader(n),e.attachShader(t,r),e.attachShader(t,n),e.linkProgram(t),s=t,l={position:e.getAttribLocation(s,"position"),uv:e.getAttribLocation(s,"uv")},c={uvOffset:e.getUniformLocation(s,"uvOffset"),uvScale:e.getUniformLocation(s,"uvScale"),rotation:e.getUniformLocation(s,"rotation"),scale:e.getUniformLocation(s,"scale"),color:e.getUniformLocation(s,"color"),map:e.getUniformLocation(s,"map"),opacity:e.getUniformLocation(s,"opacity"),modelViewMatrix:e.getUniformLocation(s,"modelViewMatrix"),projectionMatrix:e.getUniformLocation(s,"projectionMatrix"),fogType:e.getUniformLocation(s,"fogType"),fogDensity:e.getUniformLocation(s,"fogDensity"),fogNear:e.getUniformLocation(s,"fogNear"),fogFar:e.getUniformLocation(s,"fogFar"),fogColor:e.getUniformLocation(s,"fogColor"),alphaTest:e.getUniformLocation(s,"alphaTest")};var d=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");d.width=8,d.height=8;var f=d.getContext("2d");f.fillStyle="white",f.fillRect(0,0,8,8),u=new Gr(d)}function m(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}this.render=function(i,g,v){if(0!==i.length){void 0===s&&f(),r.useProgram(s),r.initAttributes(),r.enableAttribute(l.position),r.enableAttribute(l.uv),r.disableUnusedAttributes(),r.disable(e.CULL_FACE),r.enable(e.BLEND),e.bindBuffer(e.ARRAY_BUFFER,o),e.vertexAttribPointer(l.position,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(l.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.uniformMatrix4fv(c.projectionMatrix,!1,v.projectionMatrix.elements),r.activeTexture(e.TEXTURE0),e.uniform1i(c.map,0);var y=0,_=0,x=g.fog;x?(e.uniform3f(c.fogColor,x.color.r,x.color.g,x.color.b),x.isFog?(e.uniform1f(c.fogNear,x.near),e.uniform1f(c.fogFar,x.far),e.uniform1i(c.fogType,1),y=1,_=1):x.isFogExp2&&(e.uniform1f(c.fogDensity,x.density),e.uniform1i(c.fogType,2),y=2,_=2)):(e.uniform1i(c.fogType,0),y=0,_=0);for(var b=0,w=i.length;bthis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return(e||new ye).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return(e||new ye).copy(t).clamp(this.min,this.max)},distanceToPoint:(Dr=new ye,function(t){return Dr.copy(t).clamp(this.min,this.max).sub(t).length()}),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Gr.prototype=Object.create(Be.prototype),Gr.prototype.constructor=Gr;var Wr,Xr,Yr,qr,Zr,$r,Kr,Qr,Jr,tn,en,rn,nn,on,an,sn,ln,cn,un,hn=0;function pn(){Object.defineProperty(this,"id",{value:hn++}),this.uuid=ve.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=A,this.side=y,this.flatShading=!1,this.vertexColors=b,this.opacity=1,this.transparent=!1,this.blendSrc=B,this.blendDst=U,this.blendEquation=L,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Z,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this.userData={},this.needsUpdate=!0}function dn(t){pn.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,void 0!==t&&(t.attributes,this.setValues(t))}function fn(t){pn.call(this),this.type="MeshDepthMaterial",this.depthPacking=me,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(t)}function mn(t){pn.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new He,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.lights=!1,this.setValues(t)}function gn(t,e){this.min=void 0!==t?t:new He(1/0,1/0,1/0),this.max=void 0!==e?e:new He(-1/0,-1/0,-1/0)}function vn(t,e){this.center=void 0!==t?t:new He,this.radius=void 0!==e?e:0}function yn(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length}function _n(t,e){this.normal=void 0!==t?t:new He(1,0,0),this.constant=void 0!==e?e:0}function xn(t,e,r,n,i,o){this.planes=[void 0!==t?t:new _n,void 0!==e?e:new _n,void 0!==r?r:new _n,void 0!==n?n:new _n,void 0!==i?i:new _n,void 0!==o?o:new _n]}function bn(t,e,r){for(var n=new xn,i=new We,o=new ye,a=new ye(r,r),s=new He,l=new He,c=1,u=2,h=1+(c|u),p=new Array(h),d=new Array(h),f={},m=[new He(1,0,0),new He(-1,0,0),new He(0,0,1),new He(0,0,-1),new He(0,1,0),new He(0,-1,0)],v=[new He(0,1,0),new He(0,1,0),new He(0,1,0),new He(0,1,0),new He(0,0,1),new He(0,0,-1)],b=[new Ue,new Ue,new Ue,new Ue,new Ue,new Ue],w=0;w!==h;++w){var S=0!=(w&c),M=0!=(w&u),A=new fn({depthPacking:ge,morphTargets:S,skinning:M});p[w]=A;var E=new mn({morphTargets:S,skinning:M});d[w]=E}var C=this;function T(e,r,n,i,o,a){var s=e.geometry,l=null,h=p,m=e.customDepthMaterial;if(n&&(h=d,m=e.customDistanceMaterial),m)l=m;else{var g=!1;r.morphTargets&&(s&&s.isBufferGeometry?g=s.morphAttributes&&s.morphAttributes.position&&s.morphAttributes.position.length>0:s&&s.isGeometry&&(g=s.morphTargets&&s.morphTargets.length>0)),e.isSkinnedMesh&&r.skinning;var v=e.isSkinnedMesh&&r.skinning,b=0;g&&(b|=c),v&&(b|=u),l=h[b]}if(t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var w=l.uuid,S=r.uuid,M=f[w];void 0===M&&(M={},f[w]=M);var A=M[S];void 0===A&&(A=l.clone(),M[S]=A),l=A}l.visible=r.visible,l.wireframe=r.wireframe;var E=r.side;return C.renderSingleSided&&E==x&&(E=y),C.renderReverseSided&&(E===y?E=_:E===_&&(E=y)),l.side=E,l.clipShadows=r.clipShadows,l.clippingPlanes=r.clippingPlanes,l.clipIntersection=r.clipIntersection,l.wireframeLinewidth=r.wireframeLinewidth,l.linewidth=r.linewidth,n&&l.isMeshDistanceMaterial&&(l.referencePosition.copy(i),l.nearDistance=o,l.farDistance=a),l}function P(r,i,o,a){if(!1!==r.visible){if(r.layers.test(i.layers)&&(r.isMesh||r.isLine||r.isPoints)&&r.castShadow&&(!r.frustumCulled||n.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,r.matrixWorld);var s=e.update(r),c=r.material;if(Array.isArray(c))for(var u=s.groups,h=0,p=u.length;h0&&(r.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(r.morphTargets=!0),!0===this.skinning&&(r.skinning=!0),!1===this.visible&&(r.visible=!1),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),e){var i=n(t.textures),o=n(t.images);i.length>0&&(r.textures=i),o.length>0&&(r.images=o)}return r},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.overdraw=t.overdraw,this.visible=t.visible,this.userData=JSON.parse(JSON.stringify(t.userData)),this.clipShadows=t.clipShadows,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,r=null;if(null!==e){var n=e.length;r=new Array(n);for(var i=0;i!==n;++i)r[i]=e[i].clone()}return this.clippingPlanes=r,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),dn.prototype=Object.create(pn.prototype),dn.prototype.constructor=dn,dn.prototype.isShaderMaterial=!0,dn.prototype.copy=function(t){return pn.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=kr.clone(t.uniforms),this.defines=t.defines,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this},dn.prototype.toJSON=function(t){var e=pn.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},fn.prototype=Object.create(pn.prototype),fn.prototype.constructor=fn,fn.prototype.isMeshDepthMaterial=!0,fn.prototype.copy=function(t){return pn.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},mn.prototype=Object.create(pn.prototype),mn.prototype.constructor=mn,mn.prototype.isMeshDistanceMaterial=!0,mn.prototype.copy=function(t){return pn.prototype.copy.call(this,t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this},Object.assign(gn.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,r=1/0,n=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,l=t.length;si&&(i=c),u>o&&(o=u),h>a&&(a=h)}return this.min.set(e,r,n),this.max.set(i,o,a),this},setFromBufferAttribute:function(t){for(var e=1/0,r=1/0,n=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,l=t.count;si&&(i=c),u>o&&(o=u),h>a&&(a=h)}return this.min.set(e,r,n),this.max.set(i,o,a),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,r=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return(e||new He).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:(qr=new He,function(t){return this.clampPoint(t.center,qr),qr.distanceToSquared(t.center)<=t.radius*t.radius}),intersectsPlane:function(t){var e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=t.constant&&r>=t.constant},clampPoint:function(t,e){return(e||new He).copy(t).clamp(this.min,this.max)},distanceToPoint:(Yr=new He,function(t){return Yr.copy(t).clamp(this.min,this.max).sub(t).length()}),getBoundingSphere:(Xr=new He,function(t){var e=t||new vn;return this.getCenter(e.center),e.radius=.5*this.getSize(Xr).length(),e}),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:(Wr=[new He,new He,new He,new He,new He,new He,new He,new He],function(t){return this.isEmpty()?this:(Wr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Wr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Wr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Wr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Wr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Wr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Wr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Wr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Wr),this)}),translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Object.assign(vn.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:(Kr=new gn,function(t,e){var r=this.center;void 0!==e?r.copy(e):Kr.setFromPoints(t).getCenter(r);for(var n=0,i=0,o=t.length;ithis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n},getBoundingBox:function(t){var e=t||new gn;return e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}}),Object.assign(yn.prototype,{isMatrix3:!0,set:function(t,e,r,n,i,o,a,s,l){var c=this.elements;return c[0]=t,c[1]=n,c[2]=a,c[3]=e,c[4]=i,c[5]=s,c[6]=r,c[7]=o,c[8]=l,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToBufferAttribute:(Qr=new He,function(t){for(var e=0,r=t.count;e1?void 0:r.copy(n).multiplyScalar(o).add(t.start)}),intersectsLine:function(t){var e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&r>0||r<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return(t||new He).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:(Jr=new He,tn=new yn,function(t,e){var r=e||tn.getNormalMatrix(t),n=this.coplanarPoint(Jr).applyMatrix4(t),i=this.normal.applyMatrix3(r).normalize();return this.constant=-n.dot(i),this}),translate:function(t){return this.constant-=t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}}),Object.assign(xn.prototype,{set:function(t,e,r,n,i,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(r),a[3].copy(n),a[4].copy(i),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,r=0;r<6;r++)e[r].copy(t.planes[r]);return this},setFromMatrix:function(t){var e=this.planes,r=t.elements,n=r[0],i=r[1],o=r[2],a=r[3],s=r[4],l=r[5],c=r[6],u=r[7],h=r[8],p=r[9],d=r[10],f=r[11],m=r[12],g=r[13],v=r[14],y=r[15];return e[0].setComponents(a-n,u-s,f-h,y-m).normalize(),e[1].setComponents(a+n,u+s,f+h,y+m).normalize(),e[2].setComponents(a+i,u+l,f+p,y+g).normalize(),e[3].setComponents(a-i,u-l,f-p,y-g).normalize(),e[4].setComponents(a-o,u-c,f-d,y-v).normalize(),e[5].setComponents(a+o,u+c,f+d,y+v).normalize(),this},intersectsObject:(ln=new vn,function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),ln.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(ln)}),intersectsSprite:(sn=new vn,function(t){return sn.center.set(0,0,0),sn.radius=.7071067811865476,sn.applyMatrix4(t.matrixWorld),this.intersectsSphere(sn)}),intersectsSphere:function(t){for(var e=this.planes,r=t.center,n=-t.radius,i=0;i<6;i++){if(e[i].distanceToPoint(r)0?t.min.x:t.max.x,an.x=n.normal.x>0?t.max.x:t.min.x,on.y=n.normal.y>0?t.min.y:t.max.y,an.y=n.normal.y>0?t.max.y:t.min.y,on.z=n.normal.z>0?t.min.z:t.max.z,an.z=n.normal.z>0?t.max.z:t.min.z;var i=n.distanceToPoint(on),o=n.distanceToPoint(an);if(i<0&&o<0)return!1}return!0}),containsPoint:function(t){for(var e=this.planes,r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0}}),Sn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],Sn.DefaultOrder="XYZ",Object.defineProperties(Sn.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},order:{get:function(){return this._order},set:function(t){this._order=t,this.onChangeCallback()}}}),Object.assign(Sn.prototype,{isEuler:!0,set:function(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._order=n||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},setFromRotationMatrix:function(t,e,r){var n=ve.clamp,i=t.elements,o=i[0],a=i[4],s=i[8],l=i[1],c=i[5],u=i[9],h=i[2],p=i[6],d=i[10];return"XYZ"===(e=e||this._order)?(this._y=Math.asin(n(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(p,c),this._z=0)):"YXZ"===e?(this._x=Math.asin(-n(u,-1,1)),Math.abs(u)<.99999?(this._y=Math.atan2(s,d),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,o),this._z=0)):"ZXY"===e?(this._x=Math.asin(n(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,o))):"ZYX"===e?(this._y=Math.asin(-n(h,-1,1)),Math.abs(h)<.99999?(this._x=Math.atan2(p,d),this._z=Math.atan2(l,o)):(this._x=0,this._z=Math.atan2(-a,c))):"YZX"===e?(this._z=Math.asin(n(l,-1,1)),Math.abs(l)<.99999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,o)):(this._x=0,this._y=Math.atan2(s,d))):"XZY"===e&&(this._z=Math.asin(-n(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(p,c),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-u,d),this._y=0)),this._order=e,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:(un=new We,function(t,e,r){return un.makeRotationFromQuaternion(t),this.setFromRotationMatrix(un,e,r)}),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:(cn=new Ge,function(t){return cn.setFromEuler(this),this.setFromQuaternion(cn,t)}),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new He(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(Mn.prototype,{set:function(t){this.mask=1<1){for(var e=0;e1){for(var e=0;e0){n.children=[];for(a=0;a0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),h.length>0&&(r.images=h)}return r.object=n,r;function p(t){var e=[];for(var r in t){var n=t[r];delete n.metadata,e.push(n)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var r=0;re&&(e=t[r]);return e}function qi(){Object.defineProperty(this,"id",{value:Oi()}),this.uuid=ve.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}}function Zi(t,e,r,n,i,o){Di.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:o},this.fromBufferGeometry(new $i(t,e,r,n,i,o)),this.mergeVertices()}function $i(t,e,r,n,i,o){qi.call(this),this.type="BoxBufferGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:o};var a=this;n=Math.floor(n)||1,i=Math.floor(i)||1;var s=[],l=[],c=[],u=[],h=0,p=0;function d(t,e,r,n,i,o,d,f,m,g,v){var y,_,x=o/m,b=d/g,w=o/2,S=d/2,M=f/2,A=m+1,E=g+1,C=0,T=0,P=new He;for(_=0;_0?1:-1,c.push(P.x,P.y,P.z),u.push(y/m),u.push(1-_/g),C+=1}}for(_=0;_1&&r.sort(io),n.length>1&&n.sort(oo)}}},t[n]=i),i},dispose:function(){t={}}}}function so(t,e){return Math.abs(e[1])-Math.abs(t[1])}function lo(){var t=new function(){var t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];var r;switch(e.type){case"DirectionalLight":r={direction:new He,color:new Or,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new ye};break;case"SpotLight":r={position:new He,direction:new He,color:new Or,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new ye};break;case"PointLight":r={position:new He,color:new Or,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new ye,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":r={direction:new He,skyColor:new Or,groundColor:new Or};break;case"RectAreaLight":r={color:new Or,position:new He,halfWidth:new He,halfHeight:new He}}return t[e.id]=r,r}}},e={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},r=new He,n=new We,i=new We;return{setup:function(o,a,s){for(var l=0,c=0,u=0,h=0,p=0,d=0,f=0,m=0,g=s.matrixWorldInverse,v=0,y=o.length;v0)for(p=0;p0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,r;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,r,n,i;for(r=0,n=this.faces.length;r0&&(t+=e[r].distanceTo(e[r-1])),this.lineDistances[r]=t},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new gn),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new vn),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,r){if(t&&t.isGeometry){var n,i=this.vertices.length,o=this.vertices,a=t.vertices,s=this.faces,l=t.faces,c=this.faceVertexUvs[0],u=t.faceVertexUvs[0],h=this.colors,p=t.colors;void 0===r&&(r=0),void 0!==e&&(n=(new yn).getNormalMatrix(e));for(var d=0,f=a.length;d=0;r--){var f=p[r];for(this.faces.splice(f,1),a=0,s=this.faceVertexUvs.length;a0,g=d.vertexNormals.length>0,v=1!==d.color.r||1!==d.color.g||1!==d.color.b,y=d.vertexColors.length>0,_=0;if(_=S(_=S(_=S(_=S(_=S(_=S(_=S(_=S(_,0,0),1,!0),2,!1),3,f),4,m),5,g),6,v),7,y),a.push(_),a.push(d.a,d.b,d.c),a.push(d.materialIndex),f){var x=this.faceVertexUvs[0][i];a.push(E(x[0]),E(x[1]),E(x[2]))}if(m&&a.push(M(d.normal)),g){var b=d.vertexNormals;a.push(M(b[0]),M(b[1]),M(b[2]))}if(v&&a.push(A(d.color)),y){var w=d.vertexColors;a.push(A(w[0]),A(w[1]),A(w[2]))}}function S(t,e,r){return r?t|1<0&&(t.data.colors=c),h.length>0&&(t.data.uvs=[h]),t.data.faces=a,t},clone:function(){return(new Di).copy(this)},copy:function(t){var e,r,n,i,o,a;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var s=t.vertices;for(e=0,r=s.length;e0,a=i[1]&&i[1].length>0,s=t.morphTargets,l=s.length;if(l>0){e=[];for(var c=0;c0){u=[];for(c=0;c65535?Gi:Vi)(t,1):this.index=t},addAttribute:function(t,e){if(e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute){if("index"!==t)return this.attributes[t]=e,this;this.setIndex(e)}else this.addAttribute(t,new zi(arguments[1],arguments[2]))},getAttribute:function(t){return this.attributes[t]},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,r){this.groups.push({start:t,count:e,materialIndex:void 0!==r?r:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToBufferAttribute(e),e.needsUpdate=!0);var r=this.attributes.normal;void 0!==r&&((new yn).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:(li=new We,function(t){return li.makeRotationX(t),this.applyMatrix(li),this}),rotateY:(si=new We,function(t){return si.makeRotationY(t),this.applyMatrix(si),this}),rotateZ:(ai=new We,function(t){return ai.makeRotationZ(t),this.applyMatrix(ai),this}),translate:(oi=new We,function(t,e,r){return oi.makeTranslation(t,e,r),this.applyMatrix(oi),this}),scale:(ii=new We,function(t,e,r){return ii.makeScale(t,e,r),this.applyMatrix(ii),this}),lookAt:(ni=new Gn,function(t){ni.lookAt(t),ni.updateMatrix(),this.applyMatrix(ni.matrix)}),center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var r=new Hi(3*e.vertices.length,3),n=new Hi(3*e.colors.length,3);if(this.addAttribute("position",r.copyVector3sArray(e.vertices)),this.addAttribute("color",n.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new Hi(e.lineDistances.length,1);this.addAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},updateFromObject:function(t){var e,r=t.geometry;if(t.isMesh){var n=r.__directGeometry;if(!0===r.elementsNeedUpdate&&(n=void 0,r.elementsNeedUpdate=!1),void 0===n)return this.fromGeometry(r);n.verticesNeedUpdate=r.verticesNeedUpdate,n.normalsNeedUpdate=r.normalsNeedUpdate,n.colorsNeedUpdate=r.colorsNeedUpdate,n.uvsNeedUpdate=r.uvsNeedUpdate,n.groupsNeedUpdate=r.groupsNeedUpdate,r.verticesNeedUpdate=!1,r.normalsNeedUpdate=!1,r.colorsNeedUpdate=!1,r.uvsNeedUpdate=!1,r.groupsNeedUpdate=!1,r=n}return!0===r.verticesNeedUpdate&&(void 0!==(e=this.attributes.position)&&(e.copyVector3sArray(r.vertices),e.needsUpdate=!0),r.verticesNeedUpdate=!1),!0===r.normalsNeedUpdate&&(void 0!==(e=this.attributes.normal)&&(e.copyVector3sArray(r.normals),e.needsUpdate=!0),r.normalsNeedUpdate=!1),!0===r.colorsNeedUpdate&&(void 0!==(e=this.attributes.color)&&(e.copyColorsArray(r.colors),e.needsUpdate=!0),r.colorsNeedUpdate=!1),r.uvsNeedUpdate&&(void 0!==(e=this.attributes.uv)&&(e.copyVector2sArray(r.uvs),e.needsUpdate=!0),r.uvsNeedUpdate=!1),r.lineDistancesNeedUpdate&&(void 0!==(e=this.attributes.lineDistance)&&(e.copyArray(r.lineDistances),e.needsUpdate=!0),r.lineDistancesNeedUpdate=!1),r.groupsNeedUpdate&&(r.computeGroups(t.geometry),this.groups=r.groups,r.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new Xi).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new zi(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){var r=new Float32Array(3*t.normals.length);this.addAttribute("normal",new zi(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new zi(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new zi(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new zi(o,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var a=new(Yi(t.indices)>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new zi(a,1).copyIndicesArray(t.indices))}for(var s in this.groups=t.groups,t.morphTargets){for(var l=[],c=t.morphTargets[s],u=0,h=c.length;u0){var f=new Hi(4*t.skinIndices.length,4);this.addAttribute("skinIndex",f.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var m=new Hi(4*t.skinWeights.length,4);this.addAttribute("skinWeight",m.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new gn);var t=this.attributes.position;void 0!==t?this.boundingBox.setFromBufferAttribute(t):this.boundingBox.makeEmpty(),isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z)},computeBoundingSphere:(ei=new gn,ri=new He,function(){null===this.boundingSphere&&(this.boundingSphere=new vn);var t=this.attributes.position;if(t){var e=this.boundingSphere.center;ei.setFromBufferAttribute(t),ei.getCenter(e);for(var r=0,n=0,i=t.count;n0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var l=this.boundingSphere;return null!==l&&(t.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),t},clone:function(){return(new qi).copy(this)},copy:function(t){var e,r,n;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var i=t.index;null!==i&&this.setIndex(i.clone());var o=t.attributes;for(e in o){var a=o[e];this.addAttribute(e,a.clone())}var s=t.morphAttributes;for(e in s){var l=[],c=s[e];for(r=0,n=c.length;r0)if(o=c*u-h,s=l*d,(i=c*h-u)>=0)if(o>=-s)if(o<=s){var f=1/d;a=(i*=f)*(i+c*(o*=f)+2*u)+o*(c*i+o+2*h)+p}else o=l,a=-(i=Math.max(0,-(c*o+u)))*i+o*(o+2*h)+p;else o=-l,a=-(i=Math.max(0,-(c*o+u)))*i+o*(o+2*h)+p;else o<=-s?a=-(i=Math.max(0,-(-c*l+u)))*i+(o=i>0?-l:Math.min(Math.max(-l,-h),l))*(o+2*h)+p:o<=s?(i=0,a=(o=Math.min(Math.max(-l,-h),l))*(o+2*h)+p):a=-(i=Math.max(0,-(c*l+u)))*i+(o=i>0?l:Math.min(Math.max(-l,-h),l))*(o+2*h)+p;else o=c>0?-l:l,a=-(i=Math.max(0,-(c*o+u)))*i+o*(o+2*h)+p;return r&&r.copy(this.direction).multiplyScalar(i).add(this.origin),n&&n.copy(gi).multiplyScalar(o).add(mi),a}),intersectSphere:(fi=new He,function(t,e){fi.subVectors(t.center,this.origin);var r=fi.dot(this.direction),n=fi.dot(fi)-r*r,i=t.radius*t.radius;if(n>i)return null;var o=Math.sqrt(i-n),a=r-o,s=r+o;return a<0&&s<0?null:a<0?this.at(s,e):this.at(a,e)}),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null},intersectPlane:function(t,e){var r=this.distanceToPlane(t);return null===r?null:this.at(r,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var r,n,i,o,a,s,l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(r=(t.min.x-h.x)*l,n=(t.max.x-h.x)*l):(r=(t.max.x-h.x)*l,n=(t.min.x-h.x)*l),c>=0?(i=(t.min.y-h.y)*c,o=(t.max.y-h.y)*c):(i=(t.max.y-h.y)*c,o=(t.min.y-h.y)*c),r>o||i>n?null:((i>r||r!=r)&&(r=i),(o=0?(a=(t.min.z-h.z)*u,s=(t.max.z-h.z)*u):(a=(t.max.z-h.z)*u,s=(t.min.z-h.z)*u),r>s||a>n?null:((a>r||r!=r)&&(r=a),(s=0?r:n,e)))},intersectsBox:(di=new He,function(t){return null!==this.intersectBox(t,di)}),intersectTriangle:(ci=new He,ui=new He,hi=new He,pi=new He,function(t,e,r,n,i){ui.subVectors(e,t),hi.subVectors(r,t),pi.crossVectors(ui,hi);var o,a=this.direction.dot(pi);if(a>0){if(n)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}ci.subVectors(this.origin,t);var s=o*this.direction.dot(hi.crossVectors(ci,hi));if(s<0)return null;var l=o*this.direction.dot(ui.cross(ci));if(l<0)return null;if(s+l>a)return null;var c=-o*ci.dot(pi);return c<0?null:this.at(c/a,i)}),applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}}),Object.assign(eo.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return(t||new He).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return(t||new He).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){var r=e||new He;return this.delta(r).multiplyScalar(t).add(this.start)},closestPointToPointParameter:(xi=new He,bi=new He,function(t,e){xi.subVectors(t,this.start),bi.subVectors(this.end,this.start);var r=bi.dot(bi),n=bi.dot(xi)/r;return e&&(n=ve.clamp(n,0,1)),n}),closestPointToPoint:function(t,e,r){var n=this.closestPointToPointParameter(t,e),i=r||new He;return this.delta(i).multiplyScalar(n).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),Object.assign(ro,{normal:(Ei=new He,function(t,e,r,n){var i=n||new He;i.subVectors(r,e),Ei.subVectors(t,e),i.cross(Ei);var o=i.lengthSq();return o>0?i.multiplyScalar(1/Math.sqrt(o)):i.set(0,0,0)}),barycoordFromPoint:(Si=new He,Mi=new He,Ai=new He,function(t,e,r,n,i){Si.subVectors(n,e),Mi.subVectors(r,e),Ai.subVectors(t,e);var o=Si.dot(Si),a=Si.dot(Mi),s=Si.dot(Ai),l=Mi.dot(Mi),c=Mi.dot(Ai),u=o*l-a*a,h=i||new He;if(0===u)return h.set(-2,-1,-1);var p=1/u,d=(l*s-a*c)*p,f=(o*c-a*s)*p;return h.set(1-d-f,f,d)}),containsPoint:(wi=new He,function(t,e,r,n){var i=ro.barycoordFromPoint(t,e,r,n,wi);return i.x>=0&&i.y>=0&&i.x+i.y<=1})}),Object.assign(ro.prototype,{set:function(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this},setFromPointsAndIndices:function(t,e,r,n){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[n]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},area:(Ri=new He,Ni=new He,function(){return Ri.subVectors(this.c,this.b),Ni.subVectors(this.a,this.b),.5*Ri.cross(Ni).length()}),midpoint:function(t){return(t||new He).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return ro.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new _n).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return ro.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return ro.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:(Ci=new _n,Ti=[new eo,new eo,new eo],Pi=new He,Li=new He,function(t,e){var r=e||new He,n=1/0;if(Ci.setFromCoplanarPoints(this.a,this.b,this.c),Ci.projectPoint(t,Pi),!0===this.containsPoint(Pi))r.copy(Pi);else{Ti[0].set(this.a,this.b),Ti[1].set(this.b,this.c),Ti[2].set(this.c,this.a);for(var i=0;i0){var a=i[o[0]];if(void 0!==a)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=a.length;t0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=s.length;tr.far?null:{distance:l,point:f.clone(),object:t}}function v(t,e,r,a,s,l,p,f){n.fromBufferAttribute(a,l),i.fromBufferAttribute(a,p),o.fromBufferAttribute(a,f);var v=g(t,t.material,e,r,n,i,o,d);return v&&(s&&(c.fromBufferAttribute(s,l),u.fromBufferAttribute(s,p),h.fromBufferAttribute(s,f),v.uv=m(d,n,i,o,c,u,h)),v.face=new Yn(l,p,f,ro.normal(n,i,o)),v.faceIndex=l),v}return function(p,f){var y,_=this.geometry,x=this.material,b=this.matrixWorld;if(void 0!==x&&(null===_.boundingSphere&&_.computeBoundingSphere(),r.copy(_.boundingSphere),r.applyMatrix4(b),!1!==p.ray.intersectsSphere(r)&&(t.getInverse(b),e.copy(p.ray).applyMatrix4(t),null===_.boundingBox||!1!==e.intersectsBox(_.boundingBox))))if(_.isBufferGeometry){var w,S,M,A,E,C=_.index,T=_.attributes.position,P=_.attributes.uv;if(null!==C)for(A=0,E=C.count;A0&&(I=F);for(var k=0,B=z.length;k/gm,function(t,e){var r=Br[e];if(void 0===r)throw new Error("Can not resolve #include <"+e+">");return Lo(r)})}function Ro(t){return t.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(t,e,r,n){for(var i="",o=parseInt(e);o0?t.gammaFactor:1,A=(f=n.extensions,m=o,y=e,[(f=f||{}).derivatives||m.envMapCubeUV||m.bumpMap||m.normalMap||m.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(f.fragDepth||m.logarithmicDepthBuffer)&&y.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",f.drawBuffers&&y.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(f.shaderTextureLOD||m.envMap)&&y.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(To).join("\n")),E=function(t){var e=[];for(var r in t){var n=t[r];!1!==n&&e.push("#define "+r+" "+n)}return e.join("\n")}(s),C=a.createProgram();n.isRawShaderMaterial?(_=[E,"\n"].filter(To).join("\n"),x=[A,E,"\n"].filter(To).join("\n")):(_=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,E,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+M,"#define MAX_BONES "+o.maxBones,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+p:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.displacementMap&&o.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.flatShading?"#define FLAT_SHADED":"",o.skinning?"#define USE_SKINNING":"",o.useVertexTexture?"#define BONE_TEXTURE":"",o.morphTargets?"#define USE_MORPHTARGETS":"",o.morphNormals&&!1===o.flatShading?"#define USE_MORPHNORMALS":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+u:"",o.sizeAttenuation?"#define USE_SIZEATTENUATION":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(To).join("\n"),x=[A,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,E,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+M,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+h:"",o.envMap?"#define "+p:"",o.envMap?"#define "+d:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.gradientMap?"#define USE_GRADIENTMAP":"",o.flatShading?"#define FLAT_SHADED":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(o.numClippingPlanes-o.numClipIntersection),o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+u:"",o.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",o.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",o.envMap&&e.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",o.toneMapping!==nt?"#define TONE_MAPPING":"",o.toneMapping!==nt?Br.tonemapping_pars_fragment:"",o.toneMapping!==nt?function(t,e){var r;switch(e){case it:r="Linear";break;case ot:r="Reinhard";break;case at:r="Uncharted2";break;case st:r="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+e)}return"vec3 "+t+"( vec3 color ) { return "+r+"ToneMapping( color ); }"}("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.envMapEncoding||o.emissiveMapEncoding?Br.encodings_pars_fragment:"",o.mapEncoding?Co("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?Co("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?Co("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?(b="linearToOutputTexel",w=o.outputEncoding,S=Eo(w),"vec4 "+b+"( vec4 value ) { return LinearTo"+S[0]+S[1]+"; }"):"",o.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(To).join("\n")),l=Po(l=Lo(l),o),c=Po(c=Lo(c),o),n.isShaderMaterial||(l=Ro(l),c=Ro(c));var T=_+l,P=x+c,L=co(a,a.VERTEX_SHADER,T),R=co(a,a.FRAGMENT_SHADER,P);a.attachShader(C,L),a.attachShader(C,R),void 0!==n.index0AttributeName?a.bindAttribLocation(C,0,n.index0AttributeName):!0===o.morphTargets&&a.bindAttribLocation(C,0,"position"),a.linkProgram(C);var N,I,O=a.getProgramInfoLog(C),D=a.getShaderInfoLog(L),z=a.getShaderInfoLog(R),F=!0,k=!0;return!1===a.getProgramParameter(C,a.LINK_STATUS)?F=!1:""!==O||""!==D&&""!==z||(k=!1),k&&(this.diagnostics={runnable:F,material:n,programLog:O,vertexShader:{log:D,prefix:_},fragmentShader:{log:z,prefix:x}}),a.deleteShader(L),a.deleteShader(R),this.getUniforms=function(){return void 0===N&&(N=new Nr(a,C,t)),N},this.getAttributes=function(){return void 0===I&&(I=function(t,e,r){for(var n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),o=0;o0,maxBones:p,useVertexTexture:r.floatVertexTextures,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:n.directional.length,numPointLights:n.point.length,numSpotLights:n.spot.length,numRectAreaLights:n.rectArea.length,numHemiLights:n.hemi.length,numClippingPlanes:l,numClipIntersection:c,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&u.receiveShadow&&o.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===x,flipSided:e.side===_,depthPacking:void 0!==e.depthPacking&&e.depthPacking}},this.getProgramCode=function(e,r){var n=[];if(r.shaderID?n.push(r.shaderID):(n.push(e.fragmentShader),n.push(e.vertexShader)),void 0!==e.defines)for(var i in e.defines)n.push(i),n.push(e.defines[i]);for(var a=0;ae||t.height>e){var r=e/Math.max(t.width,t.height),n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return n.width=Math.floor(t.width*r),n.height=Math.floor(t.height*r),n.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,n.width,n.height),n}return t}function c(t){return ve.isPowerOfTwo(t.width)&&ve.isPowerOfTwo(t.height)}function u(t,e){return t.generateMipmaps&&e&&t.minFilter!==yt&&t.minFilter!==bt}function h(e){return e===yt||e===_t||e===xt?t.NEAREST:t.LINEAR}function p(e){var r=e.target;r.removeEventListener("dispose",p),function(e){var r=n.get(e);if(e.image&&r.__image__webglTextureCube)t.deleteTexture(r.__image__webglTextureCube);else{if(void 0===r.__webglInit)return;t.deleteTexture(r.__webglTexture)}n.remove(e)}(r),a.textures--}function d(e){var r=e.target;r.removeEventListener("dispose",d),function(e){var r=n.get(e),i=n.get(e.texture);if(!e)return;void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLRenderTargetCube)for(var o=0;o<6;o++)t.deleteFramebuffer(r.__webglFramebuffer[o]),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[o]);else t.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer);n.remove(e.texture),n.remove(e)}(r),a.textures--}function f(e,h){var d=n.get(e);if(e.version>0&&d.__version!==e.version){var f=e.image;if(void 0===f);else if(!1!==f.complete)return void function(e,n,h){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",p),e.__webglTexture=t.createTexture(),a.textures++);r.activeTexture(t.TEXTURE0+h),r.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,n.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,n.unpackAlignment);var d=l(n.image,i.maxTextureSize);f=n,(f.wrapS!==gt||f.wrapT!==gt||f.minFilter!==yt&&f.minFilter!==bt)&&!1===c(d)&&(d=function(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=ve.nearestPowerOfTwo(t.width),e.height=ve.nearestPowerOfTwo(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),e}return t}(d));var f;var g=c(d),v=o.convert(n.format),y=o.convert(n.type);m(t.TEXTURE_2D,n,g);var _,x=n.mipmaps;if(n.isDepthTexture){var b=t.DEPTH_COMPONENT;if(n.type===Lt){if(!s)throw new Error("Float Depth Texture only supported in WebGL2.0");b=t.DEPTH_COMPONENT32F}else s&&(b=t.DEPTH_COMPONENT16);n.format===jt&&b===t.DEPTH_COMPONENT&&n.type!==Ct&&n.type!==Pt&&(n.type=Ct,y=o.convert(n.type)),n.format===Gt&&(b=t.DEPTH_STENCIL,n.type!==Dt&&(n.type=Dt,y=o.convert(n.type))),r.texImage2D(t.TEXTURE_2D,0,b,d.width,d.height,0,v,y,null)}else if(n.isDataTexture)if(x.length>0&&g){for(var w=0,S=x.length;w-1&&r.compressedTexImage2D(t.TEXTURE_2D,w,v,_.width,_.height,0,_.data):r.texImage2D(t.TEXTURE_2D,w,v,_.width,_.height,0,v,y,_.data);else if(x.length>0&&g){for(var w=0,S=x.length;w1||n.get(a).__currentAnisotropy)&&(t.texParameterf(r,l.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),n.get(a).__currentAnisotropy=a.anisotropy)}}function g(e,i,a,s){var l=o.convert(i.texture.format),c=o.convert(i.texture.type);r.texImage2D(s,0,l,i.width,i.height,0,l,c,null),t.bindFramebuffer(t.FRAMEBUFFER,e),t.framebufferTexture2D(t.FRAMEBUFFER,a,s,n.get(i.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function v(e,r){t.bindRenderbuffer(t.RENDERBUFFER,e),r.depthBuffer&&!r.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,r.width,r.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)):r.depthBuffer&&r.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,r.width,r.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)):t.renderbufferStorage(t.RENDERBUFFER,t.RGBA4,r.width,r.height),t.bindRenderbuffer(t.RENDERBUFFER,null)}function y(e){var r=n.get(e),i=!0===e.isWebGLRenderTargetCube;if(e.depthTexture){if(i)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),f(r.depthTexture,0);var i=n.get(r.depthTexture).__webglTexture;if(r.depthTexture.format===jt)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,i,0);else{if(r.depthTexture.format!==Gt)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,i,0)}}(r.__webglFramebuffer,e)}else if(i){r.__webglDepthbuffer=[];for(var o=0;o<6;o++)t.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[o]),r.__webglDepthbuffer[o]=t.createRenderbuffer(),v(r.__webglDepthbuffer[o],e)}else t.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=t.createRenderbuffer(),v(r.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}this.setTexture2D=f,this.setTextureCube=function(e,s){var h=n.get(e);if(6===e.image.length)if(e.version>0&&h.__version!==e.version){h.__image__webglTextureCube||(e.addEventListener("dispose",p),h.__image__webglTextureCube=t.createTexture(),a.textures++),r.activeTexture(t.TEXTURE0+s),r.bindTexture(t.TEXTURE_CUBE_MAP,h.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var d=e&&e.isCompressedTexture,f=e.image[0]&&e.image[0].isDataTexture,g=[],v=0;v<6;v++)g[v]=d||f?f?e.image[v].image:e.image[v]:l(e.image[v],i.maxCubemapSize);var y=c(g[0]),_=o.convert(e.format),x=o.convert(e.type);for(m(t.TEXTURE_CUBE_MAP,e,y),v=0;v<6;v++)if(d)for(var b,w=g[v].mipmaps,S=0,M=w.length;S-1&&r.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,S,_,b.width,b.height,0,b.data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,S,_,b.width,b.height,0,_,x,b.data);else f?r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,_,g[v].width,g[v].height,0,_,x,g[v].data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,_,_,x,g[v]);u(e,y)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),h.__version=e.version,e.onUpdate&&e.onUpdate(e)}else r.activeTexture(t.TEXTURE0+s),r.bindTexture(t.TEXTURE_CUBE_MAP,h.__image__webglTextureCube)},this.setTextureCubeDynamic=function(e,i){r.activeTexture(t.TEXTURE0+i),r.bindTexture(t.TEXTURE_CUBE_MAP,n.get(e).__webglTexture)},this.setupRenderTarget=function(e){var i=n.get(e),o=n.get(e.texture);e.addEventListener("dispose",d),o.__webglTexture=t.createTexture(),a.textures++;var s=!0===e.isWebGLRenderTargetCube,l=c(e);if(s){i.__webglFramebuffer=[];for(var h=0;h<6;h++)i.__webglFramebuffer[h]=t.createFramebuffer()}else i.__webglFramebuffer=t.createFramebuffer();if(s){for(r.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),m(t.TEXTURE_CUBE_MAP,e.texture,l),h=0;h<6;h++)g(i.__webglFramebuffer[h],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+h);u(e.texture,l)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),r.bindTexture(t.TEXTURE_CUBE_MAP,null)}else r.bindTexture(t.TEXTURE_2D,o.__webglTexture),m(t.TEXTURE_2D,e.texture,l),g(i.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),u(e.texture,l)&&t.generateMipmap(t.TEXTURE_2D),r.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&y(e)},this.updateRenderTargetMipmap=function(e){var i=e.texture;if(u(i,c(e))){var o=e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=n.get(i).__webglTexture;r.bindTexture(o,a),t.generateMipmap(o),r.bindTexture(o,null)}}}function Do(t){Xn.call(this),this.cameras=t||[]}function zo(t,e){return{convert:function(r){var n;if(r===mt)return t.REPEAT;if(r===gt)return t.CLAMP_TO_EDGE;if(r===vt)return t.MIRRORED_REPEAT;if(r===yt)return t.NEAREST;if(r===_t)return t.NEAREST_MIPMAP_NEAREST;if(r===xt)return t.NEAREST_MIPMAP_LINEAR;if(r===bt)return t.LINEAR;if(r===wt)return t.LINEAR_MIPMAP_NEAREST;if(r===St)return t.LINEAR_MIPMAP_LINEAR;if(r===Mt)return t.UNSIGNED_BYTE;if(r===Nt)return t.UNSIGNED_SHORT_4_4_4_4;if(r===It)return t.UNSIGNED_SHORT_5_5_5_1;if(r===Ot)return t.UNSIGNED_SHORT_5_6_5;if(r===At)return t.BYTE;if(r===Et)return t.SHORT;if(r===Ct)return t.UNSIGNED_SHORT;if(r===Tt)return t.INT;if(r===Pt)return t.UNSIGNED_INT;if(r===Lt)return t.FLOAT;if(r===Rt&&null!==(n=e.get("OES_texture_half_float")))return n.HALF_FLOAT_OES;if(r===zt)return t.ALPHA;if(r===Ft)return t.RGB;if(r===kt)return t.RGBA;if(r===Bt)return t.LUMINANCE;if(r===Ut)return t.LUMINANCE_ALPHA;if(r===jt)return t.DEPTH_COMPONENT;if(r===Gt)return t.DEPTH_STENCIL;if(r===L)return t.FUNC_ADD;if(r===R)return t.FUNC_SUBTRACT;if(r===N)return t.FUNC_REVERSE_SUBTRACT;if(r===D)return t.ZERO;if(r===z)return t.ONE;if(r===F)return t.SRC_COLOR;if(r===k)return t.ONE_MINUS_SRC_COLOR;if(r===B)return t.SRC_ALPHA;if(r===U)return t.ONE_MINUS_SRC_ALPHA;if(r===V)return t.DST_ALPHA;if(r===j)return t.ONE_MINUS_DST_ALPHA;if(r===G)return t.DST_COLOR;if(r===H)return t.ONE_MINUS_DST_COLOR;if(r===W)return t.SRC_ALPHA_SATURATE;if((r===Ht||r===Wt||r===Xt||r===Yt)&&null!==(n=e.get("WEBGL_compressed_texture_s3tc"))){if(r===Ht)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===Wt)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===Xt)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===Yt)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((r===qt||r===Zt||r===$t||r===Kt)&&null!==(n=e.get("WEBGL_compressed_texture_pvrtc"))){if(r===qt)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===Zt)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===$t)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Kt)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(r===Qt&&null!==(n=e.get("WEBGL_compressed_texture_etc1")))return n.COMPRESSED_RGB_ETC1_WEBGL;if((r===I||r===O)&&null!==(n=e.get("EXT_blend_minmax"))){if(r===I)return n.MIN_EXT;if(r===O)return n.MAX_EXT}return r===Dt&&null!==(n=e.get("WEBGL_depth_texture"))?n.UNSIGNED_INT_24_8_WEBGL:0}}}function Fo(t){var e=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),r=void 0!==t.context?t.context:null,n=void 0!==t.alpha&&t.alpha,i=void 0===t.depth||t.depth,o=void 0===t.stencil||t.stencil,a=void 0!==t.antialias&&t.antialias,s=void 0===t.premultipliedAlpha||t.premultipliedAlpha,l=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,c=[],u=[],h=null,g=[],v=[];this.domElement=e,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=it,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var y,w,S,L,R,N,I,O,D,z,F,k,B,U,V,j,G,H,W,tt=this,et=!1,rt=null,nt=null,ot=-1,at="",st=null,lt=null,ct=new Ue,ut=new Ue,ht=null,pt=0,dt=e.width,ft=e.height,mt=1,gt=new Ue(0,0,dt,ft),vt=new Ue(0,0,dt,ft),yt=!1,_t=new xn,xt=new function(){var t=this,e=null,r=0,n=!1,i=!1,o=new _n,a=new yn,s={value:null,needsUpdate:!1};function l(){s.value!==e&&(s.value=e,s.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function c(e,r,n,i){var l=null!==e?e.length:0,c=null;if(0!==l){if(c=s.value,!0!==i||null===c){var u=n+4*l,h=r.matrixWorldInverse;a.getNormalMatrix(h),(null===c||c.length0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var o=void 0!==r.precision?r.precision:"highp",a=i(o);a!==o&&(o=a);var s=!0===r.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),l=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),c=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_TEXTURE_SIZE),h=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),p=t.getParameter(t.MAX_VERTEX_ATTRIBS),d=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),f=t.getParameter(t.MAX_VARYING_VECTORS),m=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),g=c>0,v=!!e.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==n)return n;var r=e.get("EXT_texture_filter_anisotropic");return n=null!==r?t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:s,maxTextures:l,maxVertexTextures:c,maxTextureSize:u,maxCubemapSize:h,maxAttributes:p,maxVertexUniforms:d,maxVaryings:f,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v}}(y,w,t),(L=new function(t,e,r){var n=new function(){var e=!1,r=new Ue,n=null,i=new Ue(0,0,0,0);return{setMask:function(r){n===r||e||(t.colorMask(r,r,r,r),n=r)},setLocked:function(t){e=t},setClear:function(e,n,o,a,s){!0===s&&(e*=a,n*=a,o*=a),r.set(e,n,o,a),!1===i.equals(r)&&(t.clearColor(e,n,o,a),i.copy(r))},reset:function(){e=!1,n=null,i.set(-1,0,0,0)}}},i=new function(){var e=!1,r=null,n=null,i=null;return{setTest:function(e){e?tt(t.DEPTH_TEST):et(t.DEPTH_TEST)},setMask:function(n){r===n||e||(t.depthMask(n),r=n)},setFunc:function(e){if(n!==e){if(e)switch(e){case X:t.depthFunc(t.NEVER);break;case Y:t.depthFunc(t.ALWAYS);break;case q:t.depthFunc(t.LESS);break;case Z:t.depthFunc(t.LEQUAL);break;case $:t.depthFunc(t.EQUAL);break;case K:t.depthFunc(t.GEQUAL);break;case Q:t.depthFunc(t.GREATER);break;case J:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}else t.depthFunc(t.LEQUAL);n=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,r=null,n=null,i=null}}},o=new function(){var e=!1,r=null,n=null,i=null,o=null,a=null,s=null,l=null,c=null;return{setTest:function(e){e?tt(t.STENCIL_TEST):et(t.STENCIL_TEST)},setMask:function(n){r===n||e||(t.stencilMask(n),r=n)},setFunc:function(e,r,a){n===e&&i===r&&o===a||(t.stencilFunc(e,r,a),n=e,i=r,o=a)},setOp:function(e,r,n){a===e&&s===r&&l===n||(t.stencilOp(e,r,n),a=e,s=r,l=n)},setLocked:function(t){e=t},setClear:function(e){c!==e&&(t.clearStencil(e),c=e)},reset:function(){e=!1,r=null,n=null,i=null,o=null,a=null,s=null,l=null,c=null}}},a=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=new Uint8Array(a),l=new Uint8Array(a),c=new Uint8Array(a),u={},h=null,m=null,g=null,v=null,y=null,b=null,w=null,S=null,L=null,R=!1,N=null,I=null,O=null,D=null,z=null,F=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),k=parseFloat(/^WebGL\ ([0-9])/.exec(t.getParameter(t.VERSION))[1]),B=parseFloat(k)>=1,U=null,V={},j=new Ue,G=new Ue;function H(e,r,n){var i=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var a=0;a65535?Gi:Vi)(a,1),e.update(n,t.ELEMENT_ARRAY_BUFFER),i[r.id]=n,n}}}(y,I,Et),D=new function(t,e){var r={};return{update:function(n){var i=e.frame,o=n.geometry,a=t.get(n,o);return r[a.id]!==i&&(o.isGeometry&&a.updateFromObject(n),t.update(a),r[a.id]=i),a},clear:function(){r={}}}}(O,Ct),U=new function(t){var e={},r=new Float32Array(8);return{update:function(n,i,o,a){var s=n.morphTargetInfluences,l=s.length,c=e[i.id];if(void 0===c){c=[];for(var u=0;u=0){var c=i[s];if(void 0!==c){var u=c.normalized,h=c.itemSize,p=I.get(c);if(void 0===p)continue;var d=p.buffer,f=p.type,m=p.bytesPerElement;if(c.isInterleavedBufferAttribute){var g=c.data,v=g.stride,_=c.offset;g&&g.isInstancedInterleavedBuffer?(L.enableAttributeAndDivisor(l,g.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=g.meshPerAttribute*g.count)):L.enableAttribute(l),y.bindBuffer(y.ARRAY_BUFFER,d),y.vertexAttribPointer(l,h,f,u,v*m,(n*v+_)*m)}else c.isInstancedBufferAttribute?(L.enableAttributeAndDivisor(l,c.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=c.meshPerAttribute*c.count)):L.enableAttribute(l),y.bindBuffer(y.ARRAY_BUFFER,d),y.vertexAttribPointer(l,h,f,u,0,n*h*m)}else if(void 0!==a){var x=a[s];if(void 0!==x)switch(x.length){case 2:y.vertexAttrib2fv(l,x);break;case 3:y.vertexAttrib3fv(l,x);break;case 4:y.vertexAttrib4fv(l,x);break;default:y.vertexAttrib1fv(l,x)}}}}L.disableUnusedAttributes()}(n,a,r),null!==u&&y.bindBuffer(y.ELEMENT_ARRAY_BUFFER,c.buffer));var f=0;null!==u?f=u.count:void 0!==h&&(f=h.count);var m=r.drawRange.start*p,g=r.drawRange.count*p,v=null!==o?o.start*p:0,_=null!==o?o.count*p:1/0,x=Math.max(m,v),b=Math.min(f,m+g,v+_)-1,S=Math.max(0,b-x+1);if(0!==S){if(i.isMesh)if(!0===n.wireframe)L.setLineWidth(n.wireframeLinewidth*Tt()),d.setMode(y.LINES);else switch(i.drawMode){case oe:d.setMode(y.TRIANGLES);break;case ae:d.setMode(y.TRIANGLE_STRIP);break;case se:d.setMode(y.TRIANGLE_FAN)}else if(i.isLine){var M=n.linewidth;void 0===M&&(M=1),L.setLineWidth(M*Tt()),i.isLineSegments?d.setMode(y.LINES):i.isLineLoop?d.setMode(y.LINE_LOOP):d.setMode(y.LINE_STRIP)}else i.isPoints&&d.setMode(y.POINTS);r&&r.isInstancedBufferGeometry?r.maxInstancedCount>0&&d.renderInstances(r,x,S):d.render(x,S)}},this.compile=function(t,e){c.length=0,u.length=0,t.traverse(function(t){t.isLight&&(c.push(t),t.castShadow&&u.push(t))}),z.setup(c,u,e),t.traverse(function(e){if(e.material)if(Array.isArray(e.material))for(var r=0;r=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(h=0;h=0&&t.numSupportedMorphNormals++}var p=n.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=xt.numPlanes,n.numIntersection=xt.numIntersection,p.clippingPlanes=xt.uniform),n.fog=e,n.lightsHash=z.state.hash,t.lights&&(p.ambientLightColor.value=z.state.ambient,p.directionalLights.value=z.state.directional,p.spotLights.value=z.state.spot,p.rectAreaLights.value=z.state.rectArea,p.pointLights.value=z.state.point,p.hemisphereLights.value=z.state.hemi,p.directionalShadowMap.value=z.state.directionalShadowMap,p.directionalShadowMatrix.value=z.state.directionalShadowMatrix,p.spotShadowMap.value=z.state.spotShadowMap,p.spotShadowMatrix.value=z.state.spotShadowMatrix,p.pointShadowMap.value=z.state.pointShadowMap,p.pointShadowMatrix.value=z.state.pointShadowMatrix);var d=n.program.getUniforms(),f=Nr.seqWithValue(d.seq,p);n.uniformsList=f}function Zt(t,e,r,n){pt=0;var i=R.get(r);if(bt&&(wt||t!==st)){var o=t===st&&r.id===ot;xt.setState(r.clippingPlanes,r.clipIntersection,r.clipShadows,t,i,o)}!1===r.needsUpdate&&(void 0===i.program?r.needsUpdate=!0:r.fog&&i.fog!==e?r.needsUpdate=!0:r.lights&&i.lightsHash!==z.state.hash?r.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===xt.numPlanes&&i.numIntersection===xt.numIntersection||(r.needsUpdate=!0)),r.needsUpdate&&(qt(r,e,n),r.needsUpdate=!1);var a,s,l,c,u,h,p,d,f,m,g,v,_,x,b,w,M=!1,A=!1,E=!1,C=i.program,T=C.getUniforms(),P=i.shader.uniforms;if(L.useProgram(C.program)&&(M=!0,A=!0,E=!0),r.id!==ot&&(ot=r.id,A=!0),M||t!==st){if(T.setValue(y,"projectionMatrix",t.projectionMatrix),S.logarithmicDepthBuffer&&T.setValue(y,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),st!==(lt||t)&&(st=lt||t,A=!0,E=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var N=T.map.cameraPosition;void 0!==N&&N.setValue(y,At.setFromMatrixPosition(t.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&T.setValue(y,"viewMatrix",t.matrixWorldInverse)}if(r.skinning){T.setOptional(y,n,"bindMatrix"),T.setOptional(y,n,"bindMatrixInverse");var I=n.skeleton;if(I){var O=I.bones;if(S.floatVertexTextures){if(void 0===I.boneTexture){var D=Math.sqrt(4*O.length);D=ve.nextPowerOfTwo(Math.ceil(D)),D=Math.max(D,4);var F=new Float32Array(D*D*4);F.set(I.boneMatrices);var k=new Xe(F,D,D,kt,Lt);I.boneMatrices=F,I.boneTexture=k,I.boneTextureSize=D}T.setValue(y,"boneTexture",I.boneTexture),T.setValue(y,"boneTextureSize",I.boneTextureSize)}else T.setOptional(y,I,"boneMatrices")}}return(A||r.forceUniformsUpdate)&&(T.setValue(y,"toneMappingExposure",tt.toneMappingExposure),T.setValue(y,"toneMappingWhitePoint",tt.toneMappingWhitePoint),r.lights&&(w=E,(b=P).ambientLightColor.needsUpdate=w,b.directionalLights.needsUpdate=w,b.pointLights.needsUpdate=w,b.spotLights.needsUpdate=w,b.rectAreaLights.needsUpdate=w,b.hemisphereLights.needsUpdate=w),e&&r.fog&&(x=e,(_=P).fogColor.value=x.color,x.isFog?(_.fogNear.value=x.near,_.fogFar.value=x.far):x.isFogExp2&&(_.fogDensity.value=x.density)),r.isMeshBasicMaterial?$t(P,r):r.isMeshLambertMaterial?($t(P,r),g=P,(v=r).emissiveMap&&(g.emissiveMap.value=v.emissiveMap)):r.isMeshPhongMaterial?($t(P,r),r.isMeshToonMaterial?(Kt(f=P,m=r),m.gradientMap&&(f.gradientMap.value=m.gradientMap)):Kt(P,r)):r.isMeshStandardMaterial?($t(P,r),r.isMeshPhysicalMaterial?(d=r,(p=P).clearCoat.value=d.clearCoat,p.clearCoatRoughness.value=d.clearCoatRoughness,Qt(p,d)):Qt(P,r)):r.isMeshDepthMaterial?($t(P,r),u=P,(h=r).displacementMap&&(u.displacementMap.value=h.displacementMap,u.displacementScale.value=h.displacementScale,u.displacementBias.value=h.displacementBias)):r.isMeshDistanceMaterial?($t(P,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(P,r)):r.isMeshNormalMaterial?($t(P,r),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale);e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale));e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(P,r)):r.isLineBasicMaterial?(c=r,(l=P).diffuse.value=c.color,l.opacity.value=c.opacity,r.isLineDashedMaterial&&(s=r,(a=P).dashSize.value=s.dashSize,a.totalSize.value=s.dashSize+s.gapSize,a.scale.value=s.scale)):r.isPointsMaterial?function(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*mt,t.scale.value=.5*ft,t.map.value=e.map,null!==e.map){var r=e.map.offset,n=e.map.repeat;t.offsetRepeat.value.set(r.x,r.y,n.x,n.y)}}(P,r):r.isShadowMaterial&&(P.color.value=r.color,P.opacity.value=r.opacity),void 0!==P.ltcMat&&(P.ltcMat.value=Fr.LTC_MAT_TEXTURE),void 0!==P.ltcMag&&(P.ltcMag.value=Fr.LTC_MAG_TEXTURE),Nr.upload(y,i.uniformsList,P,tt)),T.setValue(y,"modelViewMatrix",n.modelViewMatrix),T.setValue(y,"normalMatrix",n.normalMatrix),T.setValue(y,"modelMatrix",n.matrixWorld),C}function $t(t,e){var r;if(t.opacity.value=e.opacity,e.color&&(t.diffuse.value=e.color),e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.specularMap&&(t.specularMap.value=e.specularMap),e.envMap&&(t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap&&e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity),e.map?r=e.map:e.specularMap?r=e.specularMap:e.displacementMap?r=e.displacementMap:e.normalMap?r=e.normalMap:e.bumpMap?r=e.bumpMap:e.roughnessMap?r=e.roughnessMap:e.metalnessMap?r=e.metalnessMap:e.alphaMap?r=e.alphaMap:e.emissiveMap&&(r=e.emissiveMap),void 0!==r){r.isWebGLRenderTarget&&(r=r.texture);var n=r.offset,i=r.repeat;t.offsetRepeat.value.set(n.x,n.y,i.x,i.y)}}function Kt(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function Qt(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}this.animate=function(t){Ht=t,Gt||((It.getDevice()||window).requestAnimationFrame(Wt),Gt=!0)},this.render=function(t,e,r,n){if(e&&e.isCamera&&!et){at="",ot=-1,st=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),It.enabled&&(e=It.getCamera(e)),St.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),_t.setFromMatrix(St),c.length=0,u.length=0,g.length=0,v.length=0,wt=this.localClippingEnabled,bt=xt.init(this.clippingPlanes,wt,e),(h=k.get(t,e)).init(),function t(e,r,n){if(!e.visible)return;var i=e.layers.test(r.layers);if(i)if(e.isLight)c.push(e),e.castShadow&&u.push(e);else if(e.isSprite)e.frustumCulled&&!_t.intersectsSprite(e)||g.push(e);else if(e.isLensFlare)v.push(e);else if(e.isImmediateRenderObject)n&&At.setFromMatrixPosition(e.matrixWorld).applyMatrix4(St),h.push(e,null,e.material,At.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.update(),!e.frustumCulled||_t.intersectsObject(e))){n&&At.setFromMatrixPosition(e.matrixWorld).applyMatrix4(St);var o=D.update(e),a=e.material;if(Array.isArray(a))for(var s=o.groups,l=0,p=s.length;l=0&&e<=t.width-n&&r>=0&&r<=t.height-i&&y.readPixels(e,r,n,i,W.convert(c),W.convert(u),o)}finally{s&&y.bindFramebuffer(y.FRAMEBUFFER,nt)}}}}}function ko(t,e){this.name="",this.color=new Or(t),this.density=void 0!==e?e:25e-5}function Bo(t,e,r){this.name="",this.color=new Or(t),this.near=void 0!==e?e:1,this.far=void 0!==r?r:1e3}function Uo(){Gn.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function Vo(t,e,r,n,i){Gn.call(this),this.lensFlares=[],this.positionScreen=new He,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,r,n,i)}function jo(t){pn.call(this),this.type="SpriteMaterial",this.color=new Or(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function Go(t){Gn.call(this),this.type="Sprite",this.material=void 0!==t?t:new jo}function Ho(){Gn.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Wo(t,e){if(t=t||[],this.bones=t.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{this.boneInverses=[];for(var r=0,n=this.bones.length;r=t.HAVE_CURRENT_DATA&&(c.needsUpdate=!0)}()}function ra(t,e,r,n,i,o,a,s,l,c,u,h){Be.call(this,null,o,a,s,l,c,n,i,u,h),this.image={width:e,height:r},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function na(t,e,r,n,i,o,a,s,l,c){if((c=void 0!==c?c:jt)!==jt&&c!==Gt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&c===jt&&(r=Ct),void 0===r&&c===Gt&&(r=Dt),Be.call(this,null,n,i,o,a,s,c,r,l),this.image={width:t,height:e},this.magFilter=void 0!==a?a:yt,this.minFilter=void 0!==s?s:yt,this.flipY=!1,this.generateMipmaps=!1}function ia(t){qi.call(this),this.type="WireframeGeometry";var e,r,n,i,o,a,s,l,c,u,h=[],p=[0,0],d={},f=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(e=0,n=m.length;e=0?(h=t(g-1e-5,m,h),p.subVectors(u,h)):(h=t(g+1e-5,m,h),p.subVectors(h,u)),m-1e-5>=0?(h=t(g,m-1e-5,h),d.subVectors(u,h)):(h=t(g,m+1e-5,h),d.subVectors(h,u)),c.crossVectors(p,d).normalize(),s.push(c.x,c.y,c.z),l.push(g,m)}}for(n=0;n.9&&a<.1&&(e<.2&&(o[t+0]+=1),r<.2&&(o[t+2]+=1),n<.2&&(o[t+4]+=1))}}()}(),this.addAttribute("position",new Hi(i,3)),this.addAttribute("normal",new Hi(i.slice(),3)),this.addAttribute("uv",new Hi(o,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}function ca(t,e){Di.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new ua(t,e)),this.mergeVertices()}function ua(t,e){la.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],t,e),this.type="TetrahedronBufferGeometry",this.parameters={radius:t,detail:e}}function ha(t,e){Di.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new pa(t,e)),this.mergeVertices()}function pa(t,e){la.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],t,e),this.type="OctahedronBufferGeometry",this.parameters={radius:t,detail:e}}function da(t,e){Di.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new fa(t,e)),this.mergeVertices()}function fa(t,e){var r=(1+Math.sqrt(5))/2,n=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1];la.call(this,n,[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],t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function ma(t,e){Di.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new ga(t,e)),this.mergeVertices()}function ga(t,e){var r=(1+Math.sqrt(5))/2,n=1/r,i=[-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,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n];la.call(this,i,[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],t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function va(t,e,r,n,i,o){Di.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:r,radialSegments:n,closed:i};var a=new ya(t,e,r,n,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function ya(t,e,r,n,i){qi.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:r,radialSegments:n,closed:i},e=e||64,r=r||1,n=n||8,i=i||!1;var o=t.computeFrenetFrames(e,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;var a,s,l=new He,c=new He,u=new ye,h=[],p=[],d=[],f=[];function m(i){var a=t.getPointAt(i/e),u=o.normals[i],d=o.binormals[i];for(s=0;s<=n;s++){var f=s/n*Math.PI*2,m=Math.sin(f),g=-Math.cos(f);c.x=g*u.x+m*d.x,c.y=g*u.y+m*d.y,c.z=g*u.z+m*d.z,c.normalize(),p.push(c.x,c.y,c.z),l.x=a.x+r*c.x,l.y=a.y+r*c.y,l.z=a.z+r*c.z,h.push(l.x,l.y,l.z)}}!function(){for(a=0;ar)){var n=t.ray.origin.distanceTo(uo);nt.far||e.push({distance:n,point:uo.clone(),face:null,object:this})}}),clone:function(){return new this.constructor(this.material).copy(this)}}),Ho.prototype=Object.assign(Object.create(Gn.prototype),{constructor:Ho,copy:function(t){Gn.prototype.copy.call(this,t,!1);for(var e=t.levels,r=0,n=e.length;r1){fo.setFromMatrixPosition(t.matrixWorld),mo.setFromMatrixPosition(this.matrixWorld);var r=fo.distanceTo(mo);e[0].object.visible=!0;for(var n=1,i=e.length;n=e[n].distance;n++)e[n-1].object.visible=!1,e[n].object.visible=!0;for(;nn||(c.applyMatrix4(this.matrixWorld),(x=t.ray.origin.distanceTo(c))t.far||e.push({distance:x,point:l.clone().applyMatrix4(this.matrixWorld),index:f,face:null,faceIndex:null,object:this}))}else for(f=0,m=p.length/3-1;fn||(c.applyMatrix4(this.matrixWorld),(x=t.ray.origin.distanceTo(c))t.far||e.push({distance:x,point:l.clone().applyMatrix4(this.matrixWorld),index:f,face:null,faceIndex:null,object:this}))}else if(i.isGeometry){var y=i.vertices,_=y.length;for(f=0;f<_-1;f+=u){var x;xo.distanceSqToSegment(y[f],y[f+1],c,l)>n||(c.applyMatrix4(this.matrixWorld),(x=t.ray.origin.distanceTo(c))t.far||e.push({distance:x,point:l.clone().applyMatrix4(this.matrixWorld),index:f,face:null,faceIndex:null,object:this}))}}}}),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),$o.prototype=Object.assign(Object.create(Zo.prototype),{constructor:$o,isLineSegments:!0}),Ko.prototype=Object.assign(Object.create(Zo.prototype),{constructor:Ko,isLineLoop:!0}),Qo.prototype=Object.create(pn.prototype),Qo.prototype.constructor=Qo,Qo.prototype.isPointsMaterial=!0,Qo.prototype.copy=function(t){return pn.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},Jo.prototype=Object.assign(Object.create(Gn.prototype),{constructor:Jo,isPoints:!0,raycast:(wo=new We,So=new to,Mo=new vn,function(t,e){var r=this,n=this.geometry,i=this.matrixWorld,o=t.params.Points.threshold;if(null===n.boundingSphere&&n.computeBoundingSphere(),Mo.copy(n.boundingSphere),Mo.applyMatrix4(i),Mo.radius+=o,!1!==t.ray.intersectsSphere(Mo)){wo.getInverse(i),So.copy(t.ray).applyMatrix4(wo);var a=o/((this.scale.x+this.scale.y+this.scale.z)/3),s=a*a,l=new He;if(n.isBufferGeometry){var c=n.index,u=n.attributes.position.array;if(null!==c)for(var h=c.array,p=0,d=h.length;pt.far)return;e.push({distance:c,distanceToRay:Math.sqrt(a),point:l.clone(),index:o,face:null,object:r})}}}),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),ta.prototype=Object.assign(Object.create(Gn.prototype),{constructor:ta}),ea.prototype=Object.create(Be.prototype),ea.prototype.constructor=ea,ra.prototype=Object.create(Be.prototype),ra.prototype.constructor=ra,ra.prototype.isCompressedTexture=!0,na.prototype=Object.create(Be.prototype),na.prototype.constructor=na,na.prototype.isDepthTexture=!0,ia.prototype=Object.create(qi.prototype),ia.prototype.constructor=ia,oa.prototype=Object.create(Di.prototype),oa.prototype.constructor=oa,aa.prototype=Object.create(qi.prototype),aa.prototype.constructor=aa,sa.prototype=Object.create(Di.prototype),sa.prototype.constructor=sa,la.prototype=Object.create(qi.prototype),la.prototype.constructor=la,ca.prototype=Object.create(Di.prototype),ca.prototype.constructor=ca,ua.prototype=Object.create(la.prototype),ua.prototype.constructor=ua,ha.prototype=Object.create(Di.prototype),ha.prototype.constructor=ha,pa.prototype=Object.create(la.prototype),pa.prototype.constructor=pa,da.prototype=Object.create(Di.prototype),da.prototype.constructor=da,fa.prototype=Object.create(la.prototype),fa.prototype.constructor=fa,ma.prototype=Object.create(Di.prototype),ma.prototype.constructor=ma,ga.prototype=Object.create(la.prototype),ga.prototype.constructor=ga,va.prototype=Object.create(Di.prototype),va.prototype.constructor=va,ya.prototype=Object.create(qi.prototype),ya.prototype.constructor=ya,_a.prototype=Object.create(Di.prototype),_a.prototype.constructor=_a,xa.prototype=Object.create(qi.prototype),xa.prototype.constructor=xa,ba.prototype=Object.create(Di.prototype),ba.prototype.constructor=ba,wa.prototype=Object.create(qi.prototype),wa.prototype.constructor=wa;var Sa={area:function(t){for(var e=t.length,r=0,n=e-1,i=0;i=-Number.EPSILON&&w>=-Number.EPSILON&&b>=-Number.EPSILON))return!1;return!0}return function(e,r){var n=e.length;if(n<3)return null;var i,o,a,s=[],l=[],c=[];if(Sa.area(e)>0)for(o=0;o2;){if(h--<=0)return r?c:s;if(u<=(i=o)&&(i=0),u<=(o=i+1)&&(o=0),u<=(a=o+1)&&(a=0),t(e,i,o,a,u,l)){var p,d,f,m,g;for(p=l[i],d=l[o],f=l[a],s.push([e[p],e[d],e[f]]),c.push([l[i],l[o],l[a]]),m=o,g=o+1;g2&&t[e-1].equals(t[0])&&t.pop()}function n(t,e,r){return t.x!==e.x?t.xNumber.EPSILON){var f;if(p>0){if(d<0||d>p)return[];if((f=c*u-l*h)<0||f>p)return[]}else{if(d>0||d0||fS?[]:y===S?o?[]:[g]:_<=S?[g,v]:[g,b])}function o(t,e,r,n){var i=e.x-t.x,o=e.y-t.y,a=r.x-t.x,s=r.y-t.y,l=n.x-t.x,c=n.y-t.y,u=i*s-o*a,h=i*c-o*l;if(Math.abs(u)>Number.EPSILON){var p=l*s-c*a;return u>0?h>=0&&p>=0:h>=0||p>=0}return h>0}r(t),e.forEach(r);for(var a,s,l,c,u,h,p={},d=t.concat(),f=0,m=e.length;fi&&(s=0);var l=o(n[t],n[a],n[s],r[e]);if(!l)return!1;var c=r.length-1,u=e-1;u<0&&(u=c);var h=e+1;return h>c&&(h=0),!!(l=o(r[e],r[u],r[h],n[t]))}function s(t,e){var r,o;for(r=0;r0)return!0;return!1}var l=[];function c(t,r){var n,o,a,s;for(n=0;n0)return!0;return!1}for(var u,h,p,d,f,m,g,v,y,_,x=[],b=0,w=e.length;b0&&!(--M<0);)for(h=S;h=0)break;x[m]=!0}if(u>=0)break}return n}(t,e),v=Sa.triangulate(g,!1);for(a=0,s=v.length;a0)&&f.push(b,w,M),(l!==r-1||c0&&v(!0),e>0&&v(!1)),this.setIndex(c),this.addAttribute("position",new Hi(u,3)),this.addAttribute("normal",new Hi(h,3)),this.addAttribute("uv",new Hi(p,2))}function Ba(t,e,r,n,i,o,a){Fa.call(this,0,t,e,r,n,i,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:o,thetaLength:a}}function Ua(t,e,r,n,i,o,a){ka.call(this,0,t,e,r,n,i,o,a),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:o,thetaLength:a}}function Va(t,e,r,n){Di.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},this.fromBufferGeometry(new ja(t,e,r,n)),this.mergeVertices()}function ja(t,e,r,n){qi.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},t=t||50,e=void 0!==e?Math.max(3,e):8,r=void 0!==r?r:0,n=void 0!==n?n:2*Math.PI;var i,o,a=[],s=[],l=[],c=[],u=new He,h=new ye;for(s.push(0,0,0),l.push(0,0,1),c.push(.5,.5),o=0,i=3;o<=e;o++,i+=3){var p=r+o/e*n;u.x=t*Math.cos(p),u.y=t*Math.sin(p),s.push(u.x,u.y,u.z),l.push(0,0,1),h.x=(s[i]/t+1)/2,h.y=(s[i+1]/t+1)/2,c.push(h.x,h.y)}for(i=1;i<=e;i++)a.push(i,i+1,0);this.setIndex(a),this.addAttribute("position",new Hi(s,3)),this.addAttribute("normal",new Hi(l,3)),this.addAttribute("uv",new Hi(c,2))}Ma.prototype=Object.create(Di.prototype),Ma.prototype.constructor=Ma,Aa.prototype=Object.create(qi.prototype),Aa.prototype.constructor=Aa,Aa.prototype.getArrays=function(){var t=this.getAttribute("position"),e=t?Array.prototype.slice.call(t.array):[],r=this.getAttribute("uv"),n=r?Array.prototype.slice.call(r.array):[],i=this.index;return{position:e,uv:n,index:i?Array.prototype.slice.call(i.array):[]}},Aa.prototype.addShapeList=function(t,e){var r=t.length;e.arrays=this.getArrays();for(var n=0;nNumber.EPSILON){var p=Math.sqrt(u),d=Math.sqrt(l*l+c*c),f=e.x-s/p,m=e.y+a/p,g=((r.x-c/d-f)*c-(r.y+l/d-m)*l)/(a*c-s*l),v=(n=f+a*g-t.x)*n+(i=m+s*g-t.y)*i;if(v<=2)return new ye(n,i);o=Math.sqrt(v/2)}else{var y=!1;a>Number.EPSILON?l>Number.EPSILON&&(y=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(c)&&(y=!0),y?(n=-s,i=a,o=Math.sqrt(u)):(n=a,i=s,o=Math.sqrt(u/2))}return new ye(n/o,i/o)}for(var V=[],j=0,G=L.length,H=G-1,W=j+1;j=0;N--){for(O=N/y,D=g*Math.cos(O*Math.PI/2),I=v*Math.sin(O*Math.PI/2),j=0,G=L.length;j=0;){r=j,(n=j-1)<0&&(n=t.length-1);var i=0,o=b+2*y;for(i=0;i0||0===t.search(/^data\:image\/jpeg/);o.format=r?Ft:kt,o.needsUpdate=!0,void 0!==e&&e(o)},r,n),o},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),cs.prototype=Object.assign(Object.create(Gn.prototype),{constructor:cs,isLight:!0,copy:function(t){return Gn.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=Gn.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),us.prototype=Object.assign(Object.create(cs.prototype),{constructor:us,isHemisphereLight:!0,copy:function(t){return cs.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(hs.prototype,{copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t={};return 0!==this.bias&&(t.bias=this.bias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),ps.prototype=Object.assign(Object.create(hs.prototype),{constructor:ps,isSpotLightShadow:!0,update:function(t){var e=this.camera,r=2*ve.RAD2DEG*t.angle,n=this.mapSize.width/this.mapSize.height,i=t.distance||e.far;r===e.fov&&n===e.aspect&&i===e.far||(e.fov=r,e.aspect=n,e.far=i,e.updateProjectionMatrix())}}),ds.prototype=Object.assign(Object.create(cs.prototype),{constructor:ds,isSpotLight:!0,copy:function(t){return cs.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),fs.prototype=Object.assign(Object.create(cs.prototype),{constructor:fs,isPointLight:!0,copy:function(t){return cs.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),ms.prototype=Object.assign(Object.create(hs.prototype),{constructor:ms}),gs.prototype=Object.assign(Object.create(cs.prototype),{constructor:gs,isDirectionalLight:!0,copy:function(t){return cs.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),vs.prototype=Object.assign(Object.create(cs.prototype),{constructor:vs,isAmbientLight:!0}),ys.prototype=Object.assign(Object.create(cs.prototype),{constructor:ys,isRectAreaLight:!0,copy:function(t){return cs.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){var e=cs.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});var _s,xs={arraySlice:function(t,e,r){return xs.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==r?r:t.length)):t.slice(e,r)},convertArray:function(t,e,r){return!t||!r&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){for(var e=t.length,r=new Array(e),n=0;n!==e;++n)r[n]=n;return r.sort(function(e,r){return t[e]-t[r]}),r},sortedArray:function(t,e,r){for(var n=t.length,i=new t.constructor(n),o=0,a=0;a!==n;++o)for(var s=r[o]*e,l=0;l!==e;++l)i[a++]=t[s+l];return i},flattenJSON:function(t,e,r,n){for(var i=1,o=t[0];void 0!==o&&void 0===o[n];)o=t[i++];if(void 0!==o){var a=o[n];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[n])&&(e.push(o.time),r.push.apply(r,a)),o=t[i++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[n])&&(e.push(o.time),a.toArray(r,r.length)),o=t[i++]}while(void 0!==o);else do{void 0!==(a=o[n])&&(e.push(o.time),r.push(a)),o=t[i++]}while(void 0!==o)}}};function bs(t,e,r,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(r),this.sampleValues=e,this.valueSize=r}function ws(t,e,r,n){bs.call(this,t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Ss(t,e,r,n){bs.call(this,t,e,r,n)}function Ms(t,e,r,n){bs.call(this,t,e,r,n)}function As(t,e,r,n){if(void 0===t)throw new Error("track name is undefined");if(void 0===e||0===e.length)throw new Error("no keyframes in track named "+t);this.name=t,this.times=xs.convertArray(e,this.TimeBufferType),this.values=xs.convertArray(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation),this.validate(),this.optimize()}function Es(t,e,r,n){As.call(this,t,e,r,n)}function Cs(t,e,r,n){bs.call(this,t,e,r,n)}function Ts(t,e,r,n){As.call(this,t,e,r,n)}function Ps(t,e,r,n){As.call(this,t,e,r,n)}function Ls(t,e,r,n){As.call(this,t,e,r,n)}function Rs(t,e,r){As.call(this,t,e,r)}function Ns(t,e,r,n){As.call(this,t,e,r,n)}function Is(t,e,r,n){As.apply(this,arguments)}function Os(t,e,r){this.name=t,this.tracks=r,this.duration=void 0!==e?e:-1,this.uuid=ve.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function Ds(t){this.manager=void 0!==t?t:rs,this.textures={}}function zs(t){this.manager=void 0!==t?t:rs}Object.assign(bs.prototype,{evaluate:function(t){var e=this.parameterPositions,r=this._cachedIndex,n=e[r],i=e[r-1];t:{e:{var o;r:{n:if(!(t=i)break t;var s=e[1];t=(i=e[--r-1]))break e}o=r,r=0}for(;r>>1;te;)--o;if(++o,0!==i||o!==n){i>=o&&(i=(o=Math.max(o,1))-1);var a=this.getValueSize();this.times=xs.arraySlice(r,i,o),this.values=xs.arraySlice(this.values,i*a,o*a)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(t=!1);var r=this.times,n=this.values,i=r.length;0===i&&(t=!1);for(var o=null,a=0;a!==i;a++){var s=r[a];if("number"==typeof s&&isNaN(s)){t=!1;break}if(null!==o&&o>s){t=!1;break}o=s}if(void 0!==n&&xs.isTypedArray(n)){a=0;for(var l=n.length;a!==l;++a){var c=n[a];if(isNaN(c)){t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,r=this.getValueSize(),n=2302===this.getInterpolation(),i=1,o=t.length-1,a=1;a0){t[i]=t[o];for(f=o*r,m=i*r,p=0;p!==r;++p)e[m+p]=e[f+p];++i}return i!==t.length&&(this.times=xs.arraySlice(t,0,i),this.values=xs.arraySlice(e,0,i*r)),this}},Es.prototype=Object.assign(Object.create(_s),{constructor:Es,ValueTypeName:"vector"}),Cs.prototype=Object.assign(Object.create(bs.prototype),{constructor:Cs,interpolate_:function(t,e,r,n){for(var i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,l=(r-e)/(n-e),c=s+a;s!==c;s+=4)Ge.slerpFlat(i,0,o,s-a,o,s,l);return i}}),Ts.prototype=Object.assign(Object.create(_s),{constructor:Ts,ValueTypeName:"quaternion",DefaultInterpolation:ee,InterpolantFactoryMethodLinear:function(t){return new Cs(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),Ps.prototype=Object.assign(Object.create(_s),{constructor:Ps,ValueTypeName:"number"}),Ls.prototype=Object.assign(Object.create(_s),{constructor:Ls,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:te,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Rs.prototype=Object.assign(Object.create(_s),{constructor:Rs,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:te,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Ns.prototype=Object.assign(Object.create(_s),{constructor:Ns,ValueTypeName:"color"}),Is.prototype=_s,_s.constructor=Is,Object.assign(Is,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=Is._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var r=[],n=[];xs.flattenJSON(t.keys,r,n,"value"),t.times=r,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)},toJSON:function(t){var e,r=t.constructor;if(void 0!==r.toJSON)e=r.toJSON(t);else{e={name:t.name,times:xs.convertArray(t.times,Array),values:xs.convertArray(t.values,Array)};var n=t.getInterpolation();n!==t.DefaultInterpolation&&(e.interpolation=n)}return e.type=t.ValueTypeName,e},_getTrackTypeForValueTypeName:function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ps;case"vector":case"vector2":case"vector3":case"vector4":return Es;case"color":return Ns;case"quaternion":return Ts;case"bool":case"boolean":return Rs;case"string":return Ls}throw new Error("Unsupported typeName: "+t)}}),Object.assign(Os,{parse:function(t){for(var e=[],r=t.tracks,n=1/(t.fps||1),i=0,o=r.length;i!==o;++i)e.push(Is.parse(r[i]).scale(n));return new Os(t.name,t.duration,e)},toJSON:function(t){for(var e=[],r=t.tracks,n={name:t.name,duration:t.duration,tracks:e},i=0,o=r.length;i!==o;++i)e.push(Is.toJSON(r[i]));return n},CreateFromMorphTargetSequence:function(t,e,r,n){for(var i=e.length,o=[],a=0;a1){var c=n[h=l[1]];c||(n[h]=c=[]),c.push(s)}}var u=[];for(var h in n)u.push(Os.CreateFromMorphTargetSequence(h,n[h],e,r));return u},parseAnimation:function(t,e){if(!t)return null;for(var r=function(t,e,r,n,i){if(0!==r.length){var o=[],a=[];xs.flattenJSON(r,o,a,n),0!==o.length&&i.push(new t(e,o,a))}},n=[],i=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],l=0;l1?t.skinWeights[n+1]:0,s=r>2?t.skinWeights[n+2]:0,l=r>3?t.skinWeights[n+3]:0;e.skinWeights.push(new Ue(o,a,s,l))}if(t.skinIndices)for(n=0,i=t.skinIndices.length;n1?t.skinIndices[n+1]:0,h=r>2?t.skinIndices[n+2]:0,p=r>3?t.skinIndices[n+3]:0;e.skinIndices.push(new Ue(c,u,h,p))}e.bones=t.bones,e.bones&&e.bones.length>0&&(e.skinWeights.length!==e.skinIndices.length||(e.skinIndices.length,e.vertices.length))}(t,r),function(t,e){var r=t.scale;if(void 0!==t.morphTargets)for(var n=0,i=t.morphTargets.length;n0){var u=e.faces,h=t.morphColors[0].colors;for(n=0,i=u.length;n0&&(e.animations=r)}(t,r),r.computeFaceNormals(),r.computeBoundingSphere(),void 0===t.materials||0===t.materials.length?{geometry:r}:{geometry:r,materials:Gs.prototype.initMaterials(t.materials,e,this.crossOrigin)}}}()}),Object.assign(Ws.prototype,{load:function(t,e,r,n){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var i=this;new ns(i.manager).load(t,function(t){var r=null;try{r=JSON.parse(t)}catch(t){return void(void 0!==n&&n(t))}var o=r.metadata;void 0!==o&&void 0!==o.type&&"geometry"!==o.type.toLowerCase()&&i.parse(r,e)},r,n)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var r=this.parseGeometries(t.geometries),n=this.parseImages(t.images,function(){void 0!==e&&e(a)}),i=this.parseTextures(t.textures,n),o=this.parseMaterials(t.materials,i),a=this.parseObject(t.object,r,o);return t.animations&&(a.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(a),a},parseGeometries:function(t){var e={};if(void 0!==t)for(var r=new Hs,n=new zs,i=0,o=t.length;i0){var o=new as(new es(e));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=t.length;a0?new Yo(a,s):new no(a,s);break;case"LOD":n=new Ho;break;case"Line":n=new Zo(i(t.geometry),o(t.material),t.mode);break;case"LineLoop":n=new Ko(i(t.geometry),o(t.material));break;case"LineSegments":n=new $o(i(t.geometry),o(t.material));break;case"PointCloud":case"Points":n=new Jo(i(t.geometry),o(t.material));break;case"Sprite":n=new Go(o(t.material));break;case"Group":n=new ta;break;default:n=new Gn}if(n.uuid=t.uuid,void 0!==t.name&&(n.name=t.name),void 0!==t.matrix?(Vs.fromArray(t.matrix),Vs.decompose(n.position,n.quaternion,n.scale)):(void 0!==t.position&&n.position.fromArray(t.position),void 0!==t.rotation&&n.rotation.fromArray(t.rotation),void 0!==t.quaternion&&n.quaternion.fromArray(t.quaternion),void 0!==t.scale&&n.scale.fromArray(t.scale)),void 0!==t.castShadow&&(n.castShadow=t.castShadow),void 0!==t.receiveShadow&&(n.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(n.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(n.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&n.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(n.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.children)for(var l=t.children,c=0;c0)){l=i;break}l=i-1}if(n[i=l]===r)return i/(o-1);var c=n[i];return(i+(r-c)/(n[i+1]-c))/(o-1)},getTangent:function(t){var e=t-1e-4,r=t+1e-4;e<0&&(e=0),r>1&&(r=1);var n=this.getPoint(e);return this.getPoint(r).clone().sub(n).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var r,n,i,o=new He,a=[],s=[],l=[],c=new He,u=new We;for(r=0;r<=t;r++)n=r/t,a[r]=this.getTangentAt(n),a[r].normalize();s[0]=new He,l[0]=new He;var h=Number.MAX_VALUE,p=Math.abs(a[0].x),d=Math.abs(a[0].y),f=Math.abs(a[0].z);for(p<=h&&(h=p,o.set(1,0,0)),d<=h&&(h=d,o.set(0,1,0)),f<=h&&o.set(0,0,1),c.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],c),l[0].crossVectors(a[0],s[0]),r=1;r<=t;r++)s[r]=s[r-1].clone(),l[r]=l[r-1].clone(),c.crossVectors(a[r-1],a[r]),c.length()>Number.EPSILON&&(c.normalize(),i=Math.acos(ve.clamp(a[r-1].dot(a[r]),-1,1)),s[r].applyMatrix4(u.makeRotationAxis(c,i))),l[r].crossVectors(a[r],s[r]);if(!0===e)for(i=Math.acos(ve.clamp(s[0].dot(s[t]),-1,1)),i/=t,a[0].dot(c.crossVectors(s[0],s[t]))>0&&(i=-i),r=1;r<=t;r++)s[r].applyMatrix4(u.makeRotationAxis(a[r],i*r)),l[r].crossVectors(a[r],s[r]);return{tangents:a,normals:s,binormals:l}}}),Js.prototype=Object.create(Qs.prototype),Js.prototype.constructor=Js,Js.prototype.isLineCurve=!0,Js.prototype.getPoint=function(t){if(1===t)return this.v2.clone();var e=this.v2.clone().sub(this.v1);return e.multiplyScalar(t).add(this.v1),e},Js.prototype.getPointAt=function(t){return this.getPoint(t)},Js.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},tl.prototype=Object.assign(Object.create(Qs.prototype),{constructor:tl,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Js(e,t))},getPoint:function(t){for(var e=t*this.getLength(),r=this.getCurveLengths(),n=0;n=e){var i=r[n]-e,o=this.curves[n],a=o.getLength(),s=0===a?0:1-i/a;return o.getPointAt(s)}n++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,r=0,n=this.curves.length;r1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r},createPointsGeometry:function(t){var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){for(var e=new Di,r=0,n=t.length;re;)r-=e;re.length-2?e.length-1:n+1],l=e[n>e.length-3?e.length-1:n+2];return new ye(Zs(i,o.x,a.x,s.x,l.x),Zs(i,o.y,a.y,s.y,l.y))},nl.prototype=Object.create(Qs.prototype),nl.prototype.constructor=nl,nl.prototype.getPoint=function(t){var e=this.v0,r=this.v1,n=this.v2,i=this.v3;return new ye(Ks(t,e.x,r.x,n.x,i.x),Ks(t,e.y,r.y,n.y,i.y))},il.prototype=Object.create(Qs.prototype),il.prototype.constructor=il,il.prototype.getPoint=function(t){var e=this.v0,r=this.v1,n=this.v2;return new ye($s(t,e.x,r.x,n.x),$s(t,e.y,r.y,n.y))};var ol,al=Object.assign(Object.create(tl.prototype),{fromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,r=t.length;e0){var c=l.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(l);var u=l.getPoint(1);this.currentPoint.copy(u)}});function sl(t){tl.call(this),this.currentPoint=new ye,t&&this.fromPoints(t)}function ll(){sl.apply(this,arguments),this.holes=[]}function cl(){this.subPaths=[],this.currentPath=null}function ul(t){this.data=t}function hl(t){this.manager=void 0!==t?t:rs}sl.prototype=al,al.constructor=sl,ll.prototype=Object.assign(Object.create(al),{constructor:ll,getPointsHoles:function(t){for(var e=[],r=0,n=this.holes.length;rNumber.EPSILON){if(c<0&&(a=e[o],l=-l,s=e[i],c=-c),t.ys.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var u=c*(t.x-a.x)-l*(t.y-a.y);if(0===u)return!0;if(u<0)continue;n=!n}}else{if(t.y!==a.y)continue;if(s.x<=t.x&&t.x<=a.x||a.x<=t.x&&t.x<=s.x)return!0}}return n}var i=Sa.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return r(o);var a,s,l,c=[];if(1===o.length)return s=o[0],(l=new ll).curves=s.curves,c.push(l),c;var u=!i(o[0].getPoints());u=t?!u:u;var h,p,d=[],f=[],m=[],g=0;f[g]=void 0,m[g]=[];for(var v=0,y=o.length;v1){for(var _=!1,x=[],b=0,w=f.length;b0&&(_||(m=d))}v=0;for(var T=f.length;v0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var o=0;o!==i;++o)t[e+o]=t[r+o]},_slerp:function(t,e,r,n){Ge.slerpFlat(t,e,t,e,t,r,n)},_lerp:function(t,e,r,n,i){for(var o=1-n,a=0;a!==i;++a){var s=e+a;t[s]=t[s]*o+t[r+a]*n}}}),Object.assign(ac.prototype,{getValue:function(t,e){this.bind();var r=this._targetGroup.nCachedObjects_,n=this._bindings[r];void 0!==n&&n.getValue(t,e)},setValue:function(t,e){for(var r=this._bindings,n=this._targetGroup.nCachedObjects_,i=r.length;n!==i;++n)r[n].setValue(t,e)},bind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()},unbind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}}),Object.assign(sc,{Composite:ac,create:function(t,e,r){return t&&t.isAnimationObjectGroup?new sc.Composite(t,e,r):new sc(t,e,r)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(/[^\w-]/g,"")},parseTrackName:(Cl=new RegExp("^"+/((?:[\w-]+[\/:])*)/.source+/([\w-\.]+)?/.source+/(?:\.([\w-]+)(?:\[(.+)\])?)?/.source+/\.([\w-]+)(?:\[(.+)\])?/.source+"$"),Tl=["material","materials","bones"],function(t){var e=Cl.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);var r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=r.nodeName&&r.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){var i=r.nodeName.substring(n+1);-1!==Tl.indexOf(i)&&(r.nodeName=r.nodeName.substring(0,n),r.objectName=i)}if(null===r.propertyName||0===r.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}),findNode:function(t,e){if(!e||""===e||"root"===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){var r=function(t){for(var r=0;r=r){var h=r++,p=e[h];n[p.uuid]=u,e[u]=p,n[c]=h,e[h]=l;for(var d=0,f=o;d!==f;++d){var m=i[d],g=m[h],v=m[u];m[u]=g,m[h]=v}}}this.nCachedObjects_=r},uncache:function(t){for(var e=this._objects,r=e.length,n=this.nCachedObjects_,i=this._indicesByUUID,o=this._bindings,a=o.length,s=0,l=arguments.length;s!==l;++s){var c=arguments[s].uuid,u=i[c];if(void 0!==u)if(delete i[c],u0)for(var l=this._interpolants,c=this._propertyBindings,u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].accumulate(n,s)}else this._updateWeight(t)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var r=this._weightInterpolant;if(null!==r){var n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var r=this._timeScaleInterpolant;if(null!==r)e*=r.evaluate(t)[0],t>r.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var r=this._clip.duration,n=this.loop,i=this._loopCount;if(2200===n){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=r)e=r;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{var o=2202===n;if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),e>=r||e<0){var a=Math.floor(e/r);e-=r*a,i+=Math.abs(a);var s=this.repetitions-i;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?r:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(0===s){var l=t<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&i))return this.time=e,r-e}return this.time=e,e},_setEndings:function(t,e,r){var n=this._interpolantSettings;r?(n.endingStart=ne,n.endingEnd=ne):(n.endingStart=t?this.zeroSlopeAtStart?ne:re:ie,n.endingEnd=e?this.zeroSlopeAtEnd?ne:re:ie)},_scheduleFading:function(t,e,r){var n=this._mixer,i=n.time,o=this._weightInterpolant;null===o&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=i,s[0]=e,a[1]=i+t,s[1]=r,this}}),Object.assign(uc.prototype,i.prototype,{_bindAction:function(t,e){var r=t._localRoot||this._root,n=t._clip.tracks,i=n.length,o=t._propertyBindings,a=t._interpolants,s=r.uuid,l=this._bindingsByRootAndName,c=l[s];void 0===c&&(c={},l[s]=c);for(var u=0;u!==i;++u){var h=n[u],p=h.name,d=c[p];if(void 0!==d)o[u]=d;else{if(void 0!==(d=o[u])){null===d._cacheIndex&&(++d.referenceCount,this._addInactiveBinding(d,s,p));continue}var f=e&&e._propertyBindings[u].binding.parsedPath;++(d=new oc(sc.create(r,p,f),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(d,s,p),o[u]=d}a[u].resultBuffer=d.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,r=t._clip.uuid,n=this._actionsByClip[r];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,r,e)}for(var i=t._propertyBindings,o=0,a=i.length;o!==a;++o){var s=i[o];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,r=0,n=e.length;r!==n;++r){var i=e[r];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e.99999?this.quaternion.set(0,0,0,1):t.y<-.99999?this.quaternion.set(1,0,0,0):($l.set(t.z,0,-t.x).normalize(),Zl=Math.acos(t.y),this.quaternion.setFromAxisAngle($l,Zl))}),kc.prototype.setLength=function(t,e,r){void 0===e&&(e=.2*t),void 0===r&&(r=.2*e),this.line.scale.set(1,Math.max(0,t-e),1),this.line.updateMatrix(),this.cone.scale.set(r,e,r),this.cone.position.y=t,this.cone.updateMatrix()},kc.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},Bc.prototype=Object.create($o.prototype),Bc.prototype.constructor=Bc;var Vc=new He,jc=new Uc,Gc=new Uc,Hc=new Uc;function Wc(t){Qs.call(this),t.length,this.points=t||[],this.closed=!1}function Xc(t,e,r,n){Qs.call(this),this.v0=t,this.v1=e,this.v2=r,this.v3=n}function Yc(t,e,r){Qs.call(this),this.v0=t,this.v1=e,this.v2=r}function qc(t,e){Qs.call(this),this.v1=t,this.v2=e}function Zc(t,e,r,n,i,o){el.call(this,t,e,r,r,n,i,o)}Wc.prototype=Object.create(Qs.prototype),Wc.prototype.constructor=Wc,Wc.prototype.getPoint=function(t){var e,r,n,i,o=this.points,a=o.length,s=(a-(this.closed?0:1))*t,l=Math.floor(s),c=s-l;if(this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/o.length)+1)*o.length:0===c&&l===a-1&&(l=a-2,c=1),this.closed||l>0?e=o[(l-1)%a]:(Vc.subVectors(o[0],o[1]).add(o[0]),e=Vc),r=o[l%a],n=o[(l+1)%a],this.closed||l+21&&(o-=Math.floor(o)),i.el.childNodes.length===i.opts.lines)for(var c=0;c1)&&(n+=r.direction);var i=1-n/(r.trail/100);return i<0?r.opacity:i*(1-r.opacity)+r.opacity}function lu(t,e){if(void 0!==t.style[e])return e;var r="ms"+e.charAt(0).toUpperCase()+e.slice(1);return void 0!==t.style[r]?r:""}function cu(t,e){for(var r in e)t.style[lu(t,r)||r]=e[r];return t}function uu(t,e){return"string"==typeof t?t:t[e%t.length]}function hu(t,e){for(var r,n,i,o,a,s=[],l=0,c=t;l=3&&"base64"===e[r-2]?new Blob([Mu(e[r-1])]):null}yu.now=(gu="undefined"!=typeof window&&window.performance)&&gu.now?gu.now.bind(gu):Date.now,yu.prototype={constructor:yu,start:function(){this.startTime=yu.now(),this.oldTime=this.startTime,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1},getElapsedTime:function(){return this.update(),this.elapsedTime},update:function(){var t=0;if(this.running){var e=yu.now();t=.001*(e-this.oldTime),this.oldTime=e,this.elapsedTime+=t}return t}},bu.spaces=" ",wu.prototype=Object.create(Error.prototype);var Cu=/^[a-zA-Z0-9_]*$/,Tu=['"',"",'"'];function Pu(t,e){t.includes(e)||t.push(e)}function Lu(t,e){var r=t.indexOf(e);-1!==r&&t.splice(r,1)}function Ru(t,e,r){e.forEach(function(e){e=e.toLowerCase();var n=t[e]=t[e]||[];n.includes(r)||n.push(r)})}function Nu(t,e,r){e.forEach(function(e){e=e.toLowerCase();var n=t[e];if(n){var i=n.indexOf(r);-1!==i&&n.splice(i,1),0===n.length&&delete t[e]}})}var Iu={Timer:yu,encodeQueryComponent:function(t,e){return encodeURIComponent(t).replace(e,function(t){return String.fromCharCode(parseInt(t.substr(1),16))}).replace(/%20/g,"+")},decodeQueryComponent:_u,getUrlParameters:xu,getUrlParametersAsDict:function(t){for(var e={},r=xu(t),n=0;n0&&(o=Object.create(o))}return o},hexColor:function(t){return"#"+("0000000"+t.toString(16)).substr(-6)},DebugTracer:bu,OutOfMemoryError:wu,allocateTyped:function(t,e){var r=null;try{r=new t(e)}catch(t){throw t instanceof RangeError?new wu(t.message):t}return r},bytesFromBase64:Mu,bytesToBase64:Su,arrayFromBase64:function(t,e){return Array.prototype.slice.call(new e(Mu(t)))},arrayToBase64:function(t,e){return Su(new e(t).buffer)},compareOptionsWithDefaults:function(t,e){var r=[];if(e&&t){for(var n=Object.keys(t),i=0;i0)return"!"+r.join()}return""},objectsDiff:function t(e,r){var i={};return n.forIn(e,function(e,o){if(e instanceof Object){var a=t(e,r[o]);n.isEmpty(a)||(i[o]=a)}else r&&void 0!==r[o]&&r[o]===e||(i[o]=e)}),i},forInRecursive:function(t,e){!function t(r,i){n.forIn(r,function(r,n){var o=i+(i.length>0?".":"");r instanceof Object?t(r,o+n):void 0!==r&&e(r,o+n)})}(t,"")},enquoteString:function(t){return n.isString(t)?'"'+t.replace(/"/g,'\\"')+'"':t},shotOpen:function(t){"undefined"!=typeof window&&window.open().document.write('')},shotDownload:function(t,e){if(t&&"data:"===t.substr(0,5))if(e||(e=["screenshot-",+new Date,".png"].join("")),"undefined"!=typeof window&&window.navigator&&window.navigator.msSaveBlob)window.navigator.msSaveBlob(Eu(t),e);else if("undefined"!=typeof document){var r=document.createElement("a");r.download=e,r.innerHTML="download",r.href=window.URL.createObjectURL(Eu(t)),document.body.appendChild(r),r.click(),document.body.removeChild(r)}},copySubArrays:function(t,e,r,n){for(var i=0,o=r.length;ithis._prevTime+1e3&&(this._text.textContent=this.fps.toPrecision(2),this._prevTime=t),t},update:function(){this._startTime=this.end()},show:function(t){void 0===t&&(t=!0),this.domElement.style.display=t?"block":"none"}};var Fu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ku=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},Bu=function(){function t(t,e){for(var r=0;r=t.reps.length&&(t.reps[Zu]=Iu.deriveDeep(n,!0)),void 0!==r&&(t.reps[Zu][e]=r)}function ch(t,e,r){if(t){var i=t.indexOf(Ju),o=(c=t.substr(0,i>=0?i:void 0),u=r,(h=c.indexOf(","))>=0?(u.push(c.substr(h+1).split(",")),c.substr(0,h)):c);if(i>=0){var a=t.substr(i+1).split(eh);if(t=o,e){var s=e[t],l=Iu.deriveDeep(s,!0);a.forEach(function(e){var r=e.split(th,2),i=decodeURIComponent(r[0]),o=decodeURIComponent(r[1]),a=Ku[Fu(n.get(s,i))];a?n.set(l,i,a(o)):vu.warn('Unknown argument "'+i+'" for option "'+t+'"')}),Object.keys(l).length>0&&(t=[t,l])}}else t=o}var c,u,h;return t}var uh={l:"load",load:String,t:"type",type:String,v:"view",view:String,u:"unit",unit:Number,menu:$u,o:"object",object:function(t,e){var r=[],n=ch(t,qu.defaults.objects,r);Array.isArray(n)||(n=[n]),function(t,e,r){void 0===t._objects&&(t._objects=[]);var n={type:r[0],params:e};void 0!==r[1]&&(n.opts=r[1]),t._objects[t._objects.length]=n}(e,r[0],n)},p:"preset",preset:function(t,e){e.preset=t,e.reps=null,sh(e)},r:"rep",rep:function(t,e){sh(e),(Zu=(Zu=Number(t))<=e.reps.length?Zu<0?0:Zu:e.reps.length)===e.reps.length&&(e.reps[Zu]=Zu>0?Iu.deriveDeep(e.reps[Zu-1],!0):Iu.deriveDeep(qu.defaults.presets.default[0],!0))},s:"select",select:function(t,e){lh(e,"selector",t)},m:"mode",mode:function(t,e){lh(e,"mode",ch(t,qu.defaults.modes))},c:"color",color:function(t,e){lh(e,"colorer",ch(t,qu.defaults.colorers))},mt:"material",material:function(t,e){lh(e,"material",ch(t,qu.defaults.materials))},dup:function(t,e){sh(e);var r=e.reps,n=r[Zu];++Zu>=r.length&&(r[Zu]=Iu.deriveDeep(n,!0))},ar:"autoResolution",background:"theme"};function hh(t){Zu=0;for(var e={},r=0,i=t.length;r0&&(e+=","+t.params.join(",")),t.opts&&(e+=Ju+ph(t.opts)),e}}function mh(t){var e=[],r=0;return Iu.forInRecursive(t,function(t,n){e[r++]=n+"="+Iu.enquoteString(t)}),e.join(" ")}function gh(t){return n.isArray(t)?t[0]+(t.length<2?"":" "+mh(t[1])):t}function vh(t){if(t&&t.type){var e=t.type;return n.isArray(t.params)&&t.params.length>0&&(e+=" "+t.params.map(Iu.enquoteString).join(" ")),t.opts&&(e+=" "+mh(t.opts)),e}}function yh(t,e){var r=[],i=0;function o(t,e){null!==e&&void 0!==e&&(r[i++]=t+e)}return n.isEmpty(t)?null:(o("",e),o("s=",Iu.enquoteString(t.selector)),o("m=",gh(t.mode)),o("c=",gh(t.colorer)),o("mt=",gh(t.material)),r.join(" "))}var _h={fromURL:function(t){return hh(Iu.getUrlParameters(t))},fromAttr:function(t){return hh(Iu.getUrlParameters("?"+(t||"")))},adapters:Ku,toURL:function(t){var e=[],r=0;function i(t,n){null!==n&&void 0!==n&&(e[r++]=ih(t)+Qu+ih(n))}i("l",t.load),i("u",t.unit),i("p",t.preset),function(t){if(t)for(var e=0,r=t.length;e0&&(o+="?"+e.join("&")),o},toScript:function(t){var e=[],r=0;function n(t,n){null!==n&&void 0!==n&&(e[r++]=t+" "+n)}return n("set","autobuild false"),n("load",t.load),n("unit",t.unit),n("preset",t.preset),function(t){if(t)for(var e=0,r=t.length;e0?t.getString():this.element.name.trim()},wh.prototype.forEachBond=function(t){for(var e=this._bonds,r=0,n=e.length;r=0)return this._hydrogenCount;var t=this.element,e=t.hydrogenValency;if(1===e.length&&0===e[0])return 0;switch(t.number){case 1:return this.getHydrogenCountHydrogen();case 3:case 11:case 19:case 37:case 55:case 87:case 4:case 12:case 20:case 38:case 56:case 88:case 13:case 31:case 49:case 41:case 82:case 83:return this.getHydrogenCountMetal();case 6:case 14:case 32:case 51:return this.getHydrogenCountGroup14();case 50:return this.getHydrogenCountTin();case 7:case 8:case 9:case 15:case 16:case 17:case 33:case 34:case 35:case 53:case 85:return this.getHydrogenCountNonMetal();case 5:return this.getHydrogenCountBoron();default:return 0}},wh.prototype.getAtomBondsCount=function(){for(var t,e=this.getBonds(),r=0,n=0;n=t){r=e[n];break}return r},wh.prototype.getCharge=function(){return this._charge},wh.prototype.getLocation=function(){return this._location},wh.prototype.getFullName=function(){var t="";return null!==this._residue&&(null!==this._residue._chain&&(t+=this._residue._chain.getName()+"."),t+=this._residue._sequence+"."),t+=this._name.getString()};var Sh={UNKNOWN:0,COVALENT:1,AROMATIC:2};function Mh(t){return t._position}function Ah(t,e,r,n,i){if(this._left=t,this._right=e,this._fixed=i,this._index=-1,t>e)throw new Error("In a bond atom indices must be in increasing order");this._order=r,this._type=n}function Eh(t,e,r){this._name=t,this._fullName=e,this.letterCode=r,this.flags=0}function Ch(t,e){for(var r=0,n=e.length;r0?++n:++i}function s(t){"C"===t.element.name&&a(t)}for(var l=[[this.forEachLevelOne,s],[this.forEachLevelOne,a],[this.forEachLevelTwo,s],[this.forEachLevelTwo,a]],c=0;cn)return e.multiplyScalar(-1);if(ir._bonds.length&&(n=r,i=e);for(var o=n,a=0,s=i._bonds,l=0,c=s.length;la&&u!==n&&(o=u,a=u._bonds.length)}var h=t(i),p=t(n).clone().sub(h),d=t(o).clone().sub(h);return d.crossVectors(p,d),d.lengthSq()<1e-4&&d.set(0,1,0),p.normalize(),d.normalize(),p.crossVectors(d,p),p.lengthSq()<1e-4&&p.set(0,1,0),p.normalize(),this._fixDir(h,p,t)},Eh.prototype.getName=function(){return this._name},Eh.StandardTypes={ALA:new Eh("ALA","Alanine","A"),ARG:new Eh("ARG","Arginine","R"),ASN:new Eh("ASN","Asparagine","N"),ASP:new Eh("ASP","Aspartic Acid","D"),CYS:new Eh("CYS","Cysteine","C"),GLN:new Eh("GLN","Glutamine","Q"),GLU:new Eh("GLU","Glutamic Acid","E"),GLY:new Eh("GLY","Glycine","G"),HIS:new Eh("HIS","Histidine","H"),ILE:new Eh("ILE","Isoleucine","I"),LEU:new Eh("LEU","Leucine","L"),LYS:new Eh("LYS","Lysine","K"),MET:new Eh("MET","Methionine","M"),PHE:new Eh("PHE","Phenylalanine","F"),PRO:new Eh("PRO","Proline","P"),PYL:new Eh("PYL","Pyrrolysine","O"),SEC:new Eh("SEC","Selenocysteine","U"),SER:new Eh("SER","Serine","S"),THR:new Eh("THR","Threonine","T"),TRP:new Eh("TRP","Tryptophan","W"),TYR:new Eh("TYR","Tyrosine","Y"),VAL:new Eh("VAL","Valine","V"),A:new Eh("A","Adenine","A"),C:new Eh("C","Cytosine","C"),G:new Eh("G","Guanine","G"),I:new Eh("I","Inosine","I"),T:new Eh("T","Thymine","T"),U:new Eh("U","Uracil","U"),DA:new Eh("DA","Adenine","A"),DC:new Eh("DC","Cytosine","C"),DG:new Eh("DG","Guanine","G"),DI:new Eh("DI","Inosine","I"),DT:new Eh("DT","Thymine","T"),DU:new Eh("DU","Uracil","U"),"+A":new Eh("+A","Adenine","A"),"+C":new Eh("+C","Cytosine","C"),"+G":new Eh("+G","Guanine","G"),"+I":new Eh("+I","Inosine","I"),"+T":new Eh("+T","Thymine","T"),"+U":new Eh("+U","Uracil","U"),WAT:new Eh("WAT","Water",""),H2O:new Eh("H2O","Water",""),HOH:new Eh("HOH","Water",""),DOD:new Eh("DOD","Water",""),UNK:new Eh("UNK","Unknown",""),UNL:new Eh("UNL","Unknown Ligand","")},Eh.Flags={PROTEIN:1,BASIC:2,ACIDIC:4,POLAR:8,NONPOLAR:16,AROMATIC:32,NUCLEIC:256,PURINE:512,PYRIMIDINE:1024,DNA:2048,RNA:4096,WATER:65536};var Th=Eh.Flags;Ch(Th.WATER,["WAT","H2O","HOH","DOD"]),Ch(Th.PROTEIN,["ALA","ARG","ASN","ASP","CYS","GLY","GLU","GLN","HIS","ILE","LEU","LYS","MET","PHE","PRO","PYL","SEC","SER","THR","TRP","TYR","VAL"]),Ch(Th.BASIC,["ARG","HIS","LYS"]),Ch(Th.ACIDIC,["ASP","GLU"]),Ch(Th.POLAR,["ASN","CYS","GLN","SER","THR","TYR"]),Ch(Th.NONPOLAR,["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL","GLY"]),Ch(Th.AROMATIC,["PHE","TRP","TYR"]),Ch(Th.NUCLEIC,["A","G","I","DA","DG","DI","+A","+G","+I","C","T","U","DC","DT","DU","+C","+T","+U"]),Ch(Th.PURINE,["A","G","I","DA","DG","DI","+A","+G","+I"]),Ch(Th.PYRIMIDINE,["C","T","U","DC","DT","DU","+C","+T","+U"]),Ch(Th.DNA,["DA","DG","DI","DC","DT","DU"]),Ch(Th.RNA,["A","G","I","C","T","U"]);!function(t,e){for(var r=Object.keys(e),n=0,i=r.length;nMath.PI/2&&o.negate(),o},Oh.prototype._innerFinalize=function(t,e,r,n,i){var o=null===e,a=i(this._leadAtom),s=new He(a.x,a.y,a.z);if(0==(this._type.flags&Eh.Flags.NUCLEIC)){if(o)n._midPoint=i(this._firstAtom).clone();else{var l=e._controlPoint;n._midPoint=l.clone().lerp(s,.5),n._wingVector=this.calcWing(l,s,i(t._wingAtom),e._wingVector)}n._controlPoint=s}else this._detectLeadWing(n,r,i)},Oh.prototype._finalize2=function(t,e){this._innerFinalize(t,t,e,this,function(t){return t._position})},Oh.prototype.isConnected=function(t){if(this._chain!==t._chain)return!1;if(this===t)return!0;var e=!1;return this.forEachAtom(function(r){for(var n=r._bonds,i=0,o=n.length;i1){var a=t[1]._wingVector;t[0]._wingVector=new He(a.x,a.y,a.z)}else t.length>0&&(t[0]._wingVector=new He(1,0,0))},Dh.prototype.updateToFrame=function(t){var e=this._residues,r=null,n=null,i=t._residues,o=e.length;function a(e){return t.getAtomPos(e._index)}for(var s=0;s1?i[e[1]._index]._wingVector:new He(1,0,0)},Dh.prototype.addResidue=function(t,e,r){var n=this._complex.getResidueType(t);null===n&&(n=this._complex.addResidueType(t));var i=new Oh(this,n,e,r);return this._complex.addResidue(i),this._residues.push(i),n.flags&(Eh.Flags.NUCLEIC|Eh.Flags.PROTEIN)&&(this.maxSequencee&&(this.minSequence=e)),i},Dh.prototype.getResidueCount=function(){return this._residues.length},Dh.prototype.forEachResidue=function(t){for(var e=this._residues,r=0,n=e.length;r1?i=n>1?this._repeat.toString()+"("+i+")":this._repeat.toString()+i:n>1&&(i="("+i+")"),o>1&&(i+="^"+o.toString()+"+"),1===o&&(i+="^+"),o<-1&&(i+="^"+Math.abs(o).toString()+"-"),-1===o&&(i+="^-")):this._repeat>1&&(i=this._repeat.toString()+i),i};var Uh={},Vh=Object.freeze({default:Uh}); // Copyright Joyent, Inc. and other Node contributors. // The above copyright notice and this permission notice shall be included // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -function Dh(t,e){for(var r=0,n=t.length-1;n>=0;n--){var i=t[n];"."===i?t.splice(n,1):".."===i?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}var Fh=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,zh=function(t){return Fh.exec(t).slice(1)};function kh(){for(var t="",e=!1,r=arguments.length-1;r>=-1&&!e;r--){var n=r>=0?arguments[r]:"/";if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(t=n+"/"+t,e="/"===n.charAt(0))}return t=Dh(Yh(t.split("/"),function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function Uh(t){var e=Bh(t),r="/"===qh(t,-1);return(t=Dh(Yh(t.split("/"),function(t){return!!t}),!e).join("/"))||e||(t="."),t&&r&&(t+="/"),(e?"/":"")+t}function Bh(t){return"/"===t.charAt(0)}function Vh(){return Uh(Yh(Array.prototype.slice.call(arguments,0),function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function jh(t,e){function r(t){for(var e=0;e=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=kh(t).substr(1),e=kh(e).substr(1);for(var n=r(t.split("/")),i=r(e.split("/")),o=Math.min(n.length,i.length),a=o,s=0;s2&&A.push("'"+this.terminals_[w]+"'");T=p.showPosition?"Parse error on line "+(l+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[v]||v)+"'":"Parse error on line "+(l+1)+": Unexpected "+(v==u?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(T,{text:p.match,token:this.terminals_[v]||v,line:p.yylineno,loc:m,expected:A})}if(x[0]instanceof Array&&x.length>1)throw new Error("Parse Error: multiple actions possible at state: "+_+", token: "+v);switch(x[0]){case 1:r.push(v),i.push(p.yytext),o.push(p.yylloc),r.push(x[1]),v=null,y?(v=y,y=null):(c=p.yyleng,s=p.yytext,l=p.yylineno,m=p.yylloc);break;case 2:if(S=this.productions_[x[1]][1],C.$=i[i.length-S],C._$={first_line:o[o.length-(S||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(S||1)].first_column,last_column:o[o.length-1].last_column},g&&(C._$.range=[o[o.length-(S||1)].range[0],o[o.length-1].range[1]]),void 0!==(b=this.performAction.apply(C,[s,c,l,f.yy,x[1],i,o].concat(h))))return b;S&&(r=r.slice(0,-1*S*2),i=i.slice(0,-1*S),o=o.slice(0,-1*S)),r.push(this.productions_[x[1]][0]),i.push(C.$),o.push(C._$),M=a[r[r.length-2]][r[r.length-1]],r.push(M);break;case 3:return!0}}return!0}},g={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],r=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;var t,e,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;oe[0].length)){if(e=r,n=o,this.options.backtrack_lexer){if(!1!==(t=this.test_match(r,i[o])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[n]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,r,n){switch(r){case 0:break;case 1:return 20;case 2:return 7;case 3:return 8;case 4:return 9;case 5:return 12;case 6:return 16;case 7:return 14;case 8:return 10;case 9:return 11;case 10:return 19;case 11:return 21;case 12:return"<=";case 13:return">=";case 14:return"<";case 15:return">";case 16:return e.yytext=e.yytext.substr(1,e.yyleng-2),24;case 17:return 13;case 18:return 23;case 19:return 5;case 20:return"INVALID"}},rules:[/^(?:\s+)/i,/^(?:(-?(?:[1-9][0-9]+|[0-9]))\b)/i,/^(?:OR\b)/i,/^(?:AND\b)/i,/^(?:NOT\b)/i,/^(?:((ALL|NONE|HETATM|PROTEIN|BASIC|ACIDIC|CHARGED|POLAR|NONPOLAR|AROMATIC|NUCLEIC|PURINE|PYRIMIDINE|WATER|POLARH|NONPOLARH))\b)/i,/^(?:((NAME|ELEM|TYPE|RESIDUE|ICODE|CHAIN|ALTLOC))\b)/i,/^(?:((SERIAL|SEQUENCE|RESIDX))\b)/i,/^(?:\()/i,/^(?:\))/i,/^(?:,)/i,/^(?::)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:((?:"([^"]*)"|'([^']*)')))/i,/^(?:(@[_A-Z0-9]+))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],inclusive:!0}}};function v(){this.yy={}}return m.lexer=g,v.prototype=m,m.Parser=v,new v}();void 0!==e&&(r.parser=n,r.Parser=n.Parser,r.parse=function(){return n.parse.apply(n,arguments)},r.main=function(t){t[1]||process.exit(1);var e=$h.readFileSync(Kh.normalize(t[1]),"utf8");return r.parser.parse(e)},e.main===t&&r.main(process.argv.slice(1)))}),Jh=Qh.parser,tp=(Qh.Parser,Qh.parse,Qh.main,{});function ep(t,e){var r=t.toLowerCase();e.prototype.keyword=r,e.prototype.name=t;var n=function(){for(var t=arguments.length,r=Array(t),n=0;n=0&&e.splice(r,1),this}},{key:"toString",value:function(){return this._values.join(",")}},{key:"toJSON",value:function(){for(var t=this._values,e=[],r=0,n=t.length;rthis.priority?"("+this.rhs+")":this.rhs;return this.keyword+" "+t}},{key:"toJSON",value:function(){return[this.name,this.rhs.toJSON()]}}]),e}();dp.prototype.priority=1;var mp=function(t){function e(t,r){Nu(this,e);var n=Du(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.lhs=t||hp,n.rhs=r||hp,n}return Ou(e,sp),Iu(e,[{key:"toString",value:function(){var t=this.lhs.priority&&this.lhs.priority>this.priority?"("+this.lhs+")":this.lhs,e=this.rhs.priority&&this.rhs.priority>this.priority?"("+this.rhs+")":this.rhs;return t+" "+this.keyword+" "+e}},{key:"toJSON",value:function(){return[this.name,this.lhs.toJSON(),this.rhs.toJSON()]}}]),e}();mp.prototype.priority=1e3,fp("Not",1,function(t){function e(){return Nu(this,e),Du(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Ou(e,dp),Iu(e,[{key:"includesAtom",value:function(t){return!this.rhs.includesAtom(t)}}]),e}()),fp("And",2,function(t){function e(){return Nu(this,e),Du(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Ou(e,mp),Iu(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)&&this.rhs.includesAtom(t)}}]),e}()),fp("Or",3,function(t){function e(){return Nu(this,e),Du(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Ou(e,mp),Iu(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)||this.rhs.includesAtom(t)}}]),e}());var gp=Object.create(tp);function vp(t){this._complex=t,this._selector=gp.keyword("All")(),this._boundaries={boundingBox:new vn,boundingSphere:new yn}}function yp(t){vp.call(this,t),this.chains=[],this.matrices=[]}function _p(){if(this.constructor===_p)throw new Error("Can not instantiate abstract class!")}function xp(t){this._complex=t,this._index=-1,this._residueIndices=[],this._cycles=[],this._subDivs=[],this._residueCount=0}gp.Selector=sp,gp.RangeListSelector=cp,gp.ValueListSelector=up,gp.Range=rp,gp.RangeList=ip,gp.ValueList=ap,gp.PrefixOperator=dp,gp.InfixOperator=mp,gp.Context=Object.create({}),gp.GetSelector=function(t){if(!gp.Context.hasOwnProperty(t))throw{message:"selector "+t+" is not registered"};return gp.Context[t]||hp},gp.ClearContext=function(){Object.keys(gp.Context).forEach(function(t){delete gp.Context[t]})},gp.keyword=function(t){return tp[t.toLowerCase()]||tp.none},gp.parse=function(t){var e={};try{e.selector=Jh.parse(t)}catch(t){e.selector=hp,e.error=t.message}return e},Jh.yy=gp,Jh.yy.parseError=Jh.parseError,vp.prototype.constructor=vp,vp.prototype.computeBoundaries=function(){var t,e=this._complex._atoms,r=e.length,n=this._selector,i=this._boundaries.boundingBox;if(i.makeEmpty(),1===r){i.expandByPoint(e[0]._position);var o=i.getCenter(),a=2*e[0].element.radius;i.setFromCenterAndSize(o,new He(a,a,a))}else for(t=0;t0?this._selector=gp.keyword("Chain")(this.chains):this._selector=gp.keyword("None")()},_p.prototype.id="__",xp.prototype.getResidues=function(){return this._complex._residues},xp.prototype.getResidueCount=function(){return this._residueCount},xp.prototype.forEachResidue=function(t){for(var e=this._complex._residues,r=this._residueIndices,n=0,i=r.length;ne?t:e,i=r+(n<<14),o=(r+89237*n&wp-1)*bp,a=0;a=bp)throw new Error("addPair: increase cMaxPairsForHashCode");if(this.hashBuffer[o+a]=i,this.numPairs>=this.numMaxPairs)throw new Error("addPair: increase num pairs");o=this.numPairs*Sp,this.intBuffer[o]=r,this.intBuffer[o+1]=n,this.intBuffer[o+2]=i,this.numPairs++};function Ep(t){var e=t.element;if(e)return e.radiusBonding;throw new Error("_getBondingRadius: Logic error.")}function Cp(t,e,r){return tr?r:t}function Tp(t){return!t.isHet()||t._bonds&&0===t._bonds.length}function Pp(t){return"HOH"!==t._residue._type._name&&!t.isHet()}function Lp(t){this._complex=t,this._maxRad=1.8;var e=this._complex.getDefaultBoundaries().boundingBox;this._vBoxMin=e.min.clone(),this._vBoxMax=e.max.clone(),this._pairCollection=null}Lp.prototype._addExistingPairs=function(){for(var t=this._complex.getAtoms(),e=t.length,r=0,n=this._pairCollection;r=a))for(var b=-1;b<=1;++b){var w=v+b;if(!(w<0||w>=o))for(var S=-1;S<=1;++S){var M=g+S;if(!(M<0||M>=i))for(var A=t[x*l+w*i+M],E=0;EN*N||L<.001||this._pairCollection.addPair(u,C)}}}}}}}}},Lp.prototype._addPairs=function(){for(var t=this._complex._atoms,e=0,r=0;e125e3);this.xB=t,this.yB=e,this.zB=r,this.invPairDist=i;for(var f=[],d=0;d.1)&&Rp.dot(Np)>=0});function Up(t,e){for(var r=0;r3}function Xp(t){return!0}function Yp(t){this._complex=t;for(var e=new Array(t._bonds.length),r=new Array(t._bonds.length),n=0,i=e.length;n>1;t;)e<<=1,t>>=1;return e}function Kp(t,e){var r;this._box=t.clone(),this._count=t.size().divide(e).floor(),this._last=this._count.clone().subScalar(1),this._cellSize=t.size().divide(this._count);var n=this._count.x*this._count.y*this._count.z;for(this._voxels=Cu.allocateTyped(Int32Array,n),r=0;ri[l]?++l:++s}return!1},Yp.prototype._tryBond=function(t,e,r){var n=[],i=this._bondsData,o=Bp(t,e),a=e._position.clone().sub(o._position),s=this._currStart,l=this,c=this._bondMarks,u=this._checkBond;c[t._index]=!0,u=void 0===u?Gp:u,e.forEachBond(function(o){if(u(o)&&o!==t&&!c[o._index]&&!l._haveSameCycle(i,t,o)){var h,p,f,d=Bp(o,e),m=d._position.clone().sub(e._position),g=d===s?-2:1-(p=m,f=(h=a).dot(p)/Math.sqrt(h.lengthSq()*p.lengthSq()),ye.clamp(f,-1,1)),v=m.cross(a);if(kp(v,r)){for(var y=0;ys?1:0},qp.prototype._atomNameCompareCWithH=function(t,e){return this._atomNameCompare(t,e,2)},qp.prototype._atomNameCompareCWithoutH=function(t,e){return this._atomNameCompare(t,e,254)},qp.prototype._buildFormulaSimple=function(t,e){var r=t.atoms,n=null,i={},o="",a=this,s=dh.ByName.H.name,l=0;r.forEach(function(t){var e=t.getHydrogenCount();n=t.element,i[n.name]?i[n.name]+=1:i[n.name]=1,e>0&&(i[s]?i[s]+=e:i[s]=e),l+=t.getCharge()});var c=Object.keys(i);return i.C?c.sort(this._atomNameCompareCWithH.bind(this)):c.sort(function(t,e){return a._atomNameCompare(t,e,"H".charCodeAt(0))}),c.forEach(function(t){var e=t.substr(0,1).toUpperCase()+t.substr(1).toLowerCase();i[t]>1?o+=e+i[t].toString():o+=e}),null===e?(0!==l&&(c.length>1&&(o="("+o+")"),l>1&&(o+="^{"+l.toString()+"+}"),1===l&&(o+="^+"),l<-1&&(o+="^{"+Math.abs(l).toString()+"-}"),-1===l&&(o+="^-")),t.repeatCount>1&&(o=t.repeatCount.toString(10)+o)):e(c.length,l),o},qp.prototype._buildPartFormula=function(t){return t.owner instanceof qp||t.owner instanceof xp?this._buildFormulaSimple(t,null):t.owner instanceof Nh?t.owner.buildChemicalFormula(this,t):""},qp.prototype._partCompareFunc=function(t,e){return this._partCompareFuncInt(t,e,!0)},qp.prototype._getCumulativeCharge=function(t){for(var e=t.length,r=0,n=0;n0&&(r[i]?r[i]+=n:r[i]=n)}});var o=Object.keys(r);return o.sort(n._atomNameCompareCWithoutH.bind(n)),{seq:o,data:r}}for(var a,s=[r,!1],l=0;ldh.ByName.MT.number)return"}\\text{Could not create chemical formula for this structure.}{"}return""},qp.prototype.buildChemicalFormula=function(){var t=[],e=null,r=null,n={},i=null,o=this,a=this._checkFormulaBuildable();if(""!==a)return a;this.forEachAtom(function(t){n[t.getSerial()]&&hu.warn("Broken complex. Formula can be invalid..."),n[t.getSerial()]={atom:t,taken:null}}),this.forEachSGroup(function(o){0===o._charge&&1===o._repeat||(r=(e={owner:o,atoms:[],repeatCount:1}).atoms,o._atoms.forEach(function(t){null===(i=n[t.getSerial()]).taken&&(r.push(t),i.taken=o)}),e.atoms.length>0&&t.push(e),e=null)}),this.forEachComponent(function(o){r=(e={owner:o,atoms:[],repeatCount:1}).atoms,o.forEachResidue(function(t){t._atoms.forEach(function(t){null===(i=n[t.getSerial()]).taken&&(r.push(t),i.taken=o)})}),e.atoms.length>0&&t.push(e),e=null}),Object.keys(n).forEach(function(t){null===t.taken&&(null===e&&(e={owner:o,atoms:[],repeatCount:1}),e.atoms.push(t.atom),t.taken=o)}),null!==e&&e.atoms.length>0&&t.push(e),t.sort(function(t,e){return o._partCompareFunc(t,e)});for(var s=t.length-1,l=t.length-2;s>=0&&l>=0;){var c=t[s],u=t[l];c.owner instanceof qp||c.owner instanceof xp?u.owner instanceof qp||u.owner instanceof xp?(0===this._partCompareFuncInt(u,c,!1)&&(u.repeatCount+=c.repeatCount,t.splice(s,1)),l--,s--):l--:--s===l&&l--}return t.forEach(function(t){var e=o._buildPartFormula(t);e.length>0&&(a.length>0&&(a+="*"),a+=e)}),a},qp.prototype.getUnifiedSerial=function(t,e,r){return e+65536*r+16777216*t},qp.prototype.splitUnifiedSerial=function(t){var e=Math.floor(t/16777216),r=t-16777216*e,n=Math.floor(r/65536);return{chain:e,serial:r-65536*n,iCode:n}},qp.prototype._fillCmpEdit=function(){var t=this,e=this._components;function r(){var r=new xp(t);return r._index=e.length,e[r._index]=r,r}this.forEachChain(function(t){var e=t._residues,n=e.length;if(!(n<1))for(var i=r(),o=e[0]._index,a=0;a=0&&t=0;e--){var i=n[e];null===i._left||null===i._right?n.splice(e,1):(i._left._bonds.push(i),i._right._bonds.push(i))}var o=this._residues;for(e=0,r=o.length;e1?t.x/(this._dimX-1):0,e.y=this._dimY>1?t.y/(this._dimY-1):0,e.z=this._dimZ>1?t.z/(this._dimZ-1):0,e},Zp.prototype.computeGradient=function(){if(1!==this._dimVec)return null;var t=new Zp(Float32Array,[this._dimX,this._dimY,this._dimZ],this._box,3),e=this.getCellSize(),r=new He(-.5/e.x,-.5/e.y,-.5/e.z);function n(t,e,r){return Math.min(r,Math.max(e,t))}var i=this._dimX,o=this._dimY,a=this._dimZ,s=this._data;function l(t,e,r){return s[r*i*o+e*i+t]}for(var c=0;c=0;r=this._atoms[r+1])e(this._atoms[r])},Kp.prototype._forEachVoxelWithinRadius=function(t,e,r){var n,i,o,a,s,l,c,u,h,p,f,d,m,g,v,y,_,x,b,w,S,M,A,E,C=new _e,T=new _e,P=new _e;P.set(t.z-e,t.z+e),P.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor().clampScalar(0,this._count.z-1);for(var L=P.x;L<=P.y;++L){s=[this._box.min.z+L*this._cellSize.z,this._box.min.z+(L+1)*this._cellSize.z],u=t.z-e<=s[0]&&s[1]<=t.z+e,_=t,x=e,b=s[0],w=s[1],void 0,void 0,void 0,void 0,S=b-_.z,M=w-_.z,A=Math.sqrt(Math.max(x*x-S*S,0)),E=Math.sqrt(Math.max(x*x-M*M,0)),n=[Math.min(A,E),b<=_.z&&w>=_.z?x:Math.max(A,E)],T.set(t.y-n[1],t.y+n[1]),T.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor().clampScalar(0,this._count.y-1);for(var R=T.x;R<=T.y;++R){a=[this._box.min.y+R*this._cellSize.y,this._box.min.y+(R+1)*this._cellSize.y],c=t.y-n[0]<=a[0]&&a[1]<=t.y+n[0],h=t,p=n[1],f=a[0],d=a[1],void 0,void 0,void 0,void 0,m=f-h.y,g=d-h.y,v=Math.sqrt(Math.max(p*p-m*m,0)),y=Math.sqrt(Math.max(p*p-g*g,0)),i=[Math.min(v,y),f<=h.y&&d>=h.y?p:Math.max(v,y)],C.set(t.x-i[1],t.x+i[1]),C.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor().clampScalar(0,this._count.x-1);for(var N=C.x;N<=C.y;++N)o=[this._box.min.x+N*this._cellSize.x,this._box.min.x+(N+1)*this._cellSize.x],l=t.x-i[0]<=o[0]&&o[1]<=t.x+i[0],r(N+this._count.x*(R+this._count.y*L),l&&c&&u)}}},Kp.prototype.forEachAtomWithinRadius=function(t,e,r){var n=this,i=e*e;n._forEachVoxelWithinRadius(t,e,function(e,o){o?n._forEachAtomInVoxel(e,r):n._forEachAtomInVoxel(e,function(e){t.distanceToSquared(e._position)=0;l=s[l+1])if(t._position.distanceToSquared(s[l]._position)=1?this.fov=t:this.fov=ye.radToDeg(2*Math.atan(Math.tan(.5*ye.degToRad(t))/this.aspect))},Yn.prototype.setDistanceToFit=function(t,e){this.position.z=t/Math.sin(.5*ye.degToRad(e))},zi.prototype.copyAtList=function(t,e){for(var r=this.itemSize,n=0,i=e.length;n1e-5;)e=n,n=t/((i=1+r*n)*i);return 1/i}for(var i=new Ji(2,2,t,e),o=i.getAttribute("position"),a=0;a65535,l=o*e,c=this._index=Cu.allocateTyped(s?Uint32Array:Uint16Array,l);this._positions=Cu.allocateTyped(Float32Array,3*a),this._normals=Cu.allocateTyped(Float32Array,3*a),this._colors=Cu.allocateTyped(Float32Array,3*a);var u=this._alpha=Cu.allocateTyped(Float32Array,a);n.fill(u,1);for(var h=0;h0,l=!1===o&&e>0,c=(i+1)*n+s*(n+1)+l*(n+1),u=(2*i+s+l)*n,h=r/2,p=new zi(Cu.allocateTyped(Float32Array,3*c),3),f=new zi(Cu.allocateTyped(Float32Array,3*c),3),d=new ji(Cu.allocateTyped(Uint16Array,u*Df),1),m=new zi(Cu.allocateTyped(Float32Array,2*c),2),g=0,v=0,y=-(e-t)/r,_=0;_<=i;_++){if(_!==i)for(var x=0;x65535;this._index=Cu.allocateTyped(r?Uint32Array:Uint16Array,6*t),this._positions=Cu.allocateTyped(Float32Array,4*e),this._colors=Cu.allocateTyped(Float32Array,3*e),this._directions=Cu.allocateTyped(Float32Array,3*e);var i=this._alpha=Cu.allocateTyped(Float32Array,e);n.fill(i,1);for(var o=this._index,a=0,s=0,l=0;l117440512)throw new Error("Too large cube dimension: lead to memory huge uasge");return this.pointsValuesLinear=Cu.allocateTyped(Float32Array,32*e),this.hasIntersection=Cu.allocateTyped(Int32Array,e),this.bitsInside=Cu.allocateTyped(Int32Array,e),0},xd.prototype.destroy=function(){this.bitsInside=null,this.hasIntersection=null,this.pointsValuesLinear=null},xd.prototype.striIndicesMarchCube=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];var bd=[0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0];function wd(){this._arrSize=8,this.p=new Array(this._arrSize),this.g=new Array(this._arrSize),this.val=new Array(this._arrSize);for(var t=0;t0&&(f=h/p),f=f>1?1:f,i.lerpVectors(a,s,f),o.lerpVectors(l,c,f)},Md.prototype._polygonize=function(){for(var t=xd.prototype.striIndicesMarchCube,e=[0,1,2,3,4,5,6,7,0,1,2,3],r=[1,2,3,0,5,6,7,4,4,5,6,7],n=new Array(12),i=new Array(12),o=0;o<12;++o)n[o]=new He,i[o]=new He;return function(a,s,l){var c=a.cubeIndex;for(o=0;o<12;++o)bd[c]&1<s?s:c+e,h=-1,p=c;pV&&(j=G,V=A[G]);if(j<0||!n.includesAtom(M[j])){P[i]=-1;continue}}P[i]=L++;var W=D=0&&nt>=0&&it>=0&&(this._indices[3*et]=rt,this._indices[3*et+1]=nt,this._indices[3*et+2]=it,++et)}this._position=new Float32Array(this._position.buffer.slice(0,3*L*4)),this._normals=new Float32Array(this._normals.buffer.slice(0,3*L*4)),this._colors=new Float32Array(this._colors.buffer.slice(0,3*L*4)),this._indices=new Uint32Array(this._indices.buffer.slice(0,3*et*4))}},Md.prototype.toMesh=function(){var t=new Zi;return t.setIndex(new zi(this._indices,1)),t.addAttribute("position",new zi(this._position,3)),t.addAttribute("normal",new zi(this._normals,3)),t.addAttribute("color",new zi(this._colors,3)),t.computeBoundingSphere(),t},Ad.prototype=Object.create(_d.prototype),Ad.prototype.constructor=Ad,Ad.prototype._build=function(){var t=this._opts;this.numVoxels=[128,128,128],this.xAxis=new He(1,0,0),this.yAxis=new He(0,1,0),this.zAxis=new He(0,0,1),this.origin=new He(0,0,0),this._visibilitySelector=t.visibilitySelector,this._calcSurface(t)},Ad.prototype._findMinMax=function(t){for(var e=t.length/4,r=[t[0],t[1],t[2],t[3]],n=[t[0],t[1],t[2],t[3]],i=1;i4&&(e.gridSpacing*=i[3]);var a=e.radScale*o[3]*1.7,s=a;s=.65*Math.sqrt(4/3*Math.PI*s*s*s),a=Math.max(a,s);for(var l=0;l<3;++l)i[l]-=a,o[l]+=a;for(l=0;l<3;++l)r[l]=Math.ceil((o[l]-i[l])/e.gridSpacing);return this.xAxis.x=(r[0]-1)*e.gridSpacing,this.yAxis.y=(r[1]-1)*e.gridSpacing,this.zAxis.z=(r[2]-1)*e.gridSpacing,this.origin.x=i[0],this.origin.y=i[1],this.origin.z=i[2],{bbox:n,dim:r}},Ad.prototype._makeSurface=function(t,e){var r=new Md;r.compute(t.volMap,this.origin,e.isoValue,1),r.vertexFusion(9,9),r._numTriangles>0&&(r.setColorVolTex(t.volTexMap,t.atomMap,t.atomWeightMap,this._visibilitySelector),this.setIndex(new zi(r._indices,1)),this.addAttribute("position",new zi(r._position,3)),this.addAttribute("normal",new zi(r._normals,3)),this.addAttribute("color",new zi(r._colors,3)))},Ad.prototype._calcSurface=function(t){var e={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};if(0!==e.posRad.length){var r=this._findNumVoxels(e.posRad,t),n=new vn(this.origin,new He(this.xAxis.x,this.yAxis.y,this.zAxis.z).add(this.origin)),i=this._computeSurface(e,n,r,t);this._makeSurface(i,t)}};var Ed=Jp.Volume;function Cd(t,e){Ad.call(this,t,e)}function Td(t,e,r,n){var i,o,a,s,l,c,u,h,p,f,d,m,g,v,y,_,x,b=4,w=t.posRad,S=t.colors,M=t.atoms,A=w.length/b,E=e.bbox,C=E.minPosRad,T=E.maxPosRad,P=-1,L=null,R=null,N=null,I=new He(0,0,0),O=new He(0,0,0),D=new He(0,0,0);function F(){a=r.probeRadius,s=r.scaleFactor,l=r.probePositions,N=r.visibilitySelector,i=Cu.allocateTyped(Float32Array,A),o=0;for(var t=0;to&&(o=n),i[t]=n*n}!function(){s=r.scaleFactor,c=e.dim,x=Math.min(5,2+Math.floor(a*s));var t=c[0]*c[1]*c[2];u=function(t,e,r){for(var n=Cu.allocateTyped(t,e),i=0;iP&&(P=N)}this.neighbourListLength=27*P+1,this.withinRadii=function(e,r,n,i,l){var c=0,u=h(e,o),d=h(r,a),m=h(n,s),g=Math.max(0,u-1),x=Math.max(0,d-1),w=Math.max(0,m-1),S=Math.min(v-1,u+1),T=Math.min(y-1,d+1),P=Math.min(_-1,m+1);for(p=g;p<=S;++p){var L=p*b;for(M=x;M<=T;++M)for(var R=M*_,N=w;N<=P;++N)for(var I=A[f=L+R+N],O=I+E[f],D=I;D=0;){if(o!==n&&o!==i&&U(o,t,e,r))return P=o,o;o=_[++a]}return P=-1,-1}function U(t,e,r,n){var o=b*t,a=i[t],s=w[o]-e,l=w[o+1]-r,c=w[o+2]-n;return s*s+l*l+c*c0&&ML[$]&&(L[$]=J,R[$]=M[t]),u[$]<0&&(u[$]=-u[$]);var et=Math.sqrt(Q),rt=a/et,nt=K*rt,it=X*rt,ot=G*rt;if(-1===k(nt+=r,it+=n,ot+=o,t,-1)){var at=a-et;at=0;)t0){r=1/r;var n=3*t;h[n]*=r,h[n+1]*=r,h[n+2]*=r}}}()}this.build=function(){V(),this.volTexMap=h,this.weightsMap=L,this.atomMap=R,this.volMap=u}}Cd.prototype=Object.create(Ad.prototype),Cd.prototype.constructor=Cd,Cd.prototype._computeSurface=function(t,e,r,n){this._shiftByOrigin(t.posRad);var i={volMap:new Ed(Float32Array,this.numVoxels,e),volTexMap:new Ed(Float32Array,this.numVoxels,e,3)};return null!=this._visibilitySelector&&(i.atomMap=[],i.atomWeightMap=new Ed(Float32Array,this.numVoxels,e)),this.gaussdensity(i,t,null,n),i},Cd.prototype.gaussdensity=function(t,e,r,n){var i,o=e.posRad.length/4,a=e.posRad,s=e.colors,l=this.numVoxels,c=n.radScale,u=n.gaussLim,h=n.gridSpacing,p=1/n.isoValue,f=1/h,d=l[0]-1,m=l[1]-1,g=l[2]-1,v=t.volMap,y=t.volTexMap,_=v.getData(),x=v.getStrideX(),b=y.getData(),w=y.getStrideX();null!=this._visibilitySelector&&(i=t.atomWeightMap.getData());for(var S=t.atomMap,M=0;M=L))for(var G=v.getDirectIdx(N,V,U),W=y.getDirectIdx(N,V,U),H=N*h-a[A],X=N;X<=I;++X,H+=h,G+=x,W+=w){var Y=-(H*H+j)*T,q=Math.exp(Y)*C;null!=this._visibilitySelector&&q>i[G]&&(i[G]=q,S[G]=e.atoms[M]),_[G]+=q,q*=p;var Z=3*M;b[W]+=q*s[Z],b[W+1]+=q*s[Z+1],b[W+2]+=q*s[Z+2]}}}},Cd.prototype._shiftByOrigin=function(t){for(var e=this.origin.x,r=this.origin.y,n=this.origin.z,i=t.length/4,o=0;oc?e:c,u+=e;var h=Math.floor(s/c);h<2&&(h=2),u/=r,this._numCells=h,this._aveRad=u,this._maxRad=c;var p=h,f=h*h,d=h*h*h,m=this._xScale=1/(this._vBoxMax.x-this._vBoxMin.x),g=this._yScale=1/(this._vBoxMax.y-this._vBoxMin.y),v=this._zScale=1/(this._vBoxMax.z-this._vBoxMin.z),y=0,_=m*h,x=g*h,b=v*h;for(l=0;l=0?C:0,T=T>=0?T:0,P=P>=0?P:0,L=L=0;s=this._atomsList[2*s+1]){e(a[this._atomsList[2*s]])}},Nd.prototype.getClosestAtom=function(t){var e=null,r=Number.MAX_VALUE;return this.forEachRelatedAtom(t,function(n){var i=t.distanceToSquared(n.coord);im)){var v=t.radius+i._probeRadius;(p=n-v*v)<0&&(p=-p),f=Math.exp(g*p),c+=e*f,u+=r*f,h+=d*f,o++}},y=0;y0&&(p=1/Math.sqrt(n),c*=p,u*=p,h*=p),r[y].x=c,r[y].y=u,r[y].z=h;return 0},Nd.prototype.buildColors=function(t,e,r,n){for(var i=this,o=0,a=0,s=0,l=0,c=0,u=n*n,h=[],p=[],f=0,d=function(t){var e=o-t.coord.x,r=a-t.coord.y,n=s-t.coord.z,d=e*e+r*r+n*n;if(!(d>u)){var m=t.radius+i._probeRadius;(l=d-m*m)<0&&(l=-l),c=1/(.8+l),h.push([t.colorX,t.colorY,t.colorZ]),p.push(c),f+=c}},m=0;m=0&&!(this.voxelsRefs[2*o+1]<0);)o=this.voxelsRefs[2*o+1];this.voxelsRefs[2*o+1]=r}}for(var x=0,b=0;b=0;)E+=(a=this.atoms[o]).coord.x,C+=a.coord.y,T+=a.coord.z,P++,o=this.voxelsRefs[2*o+1];for(E*=1/P,C*=1/P,T*=1/P,r=0;r<8;r++)p[r]=0;var L=0;for(o=this.voxels[i];o>=0;){var R=(a=this.atoms[o]).coord.x-E,N=a.coord.y-C,I=a.coord.z-T,O=Math.sqrt(R*R+N*N+I*I)+a.radius;O>L&&(L=O),h=e.getIndex(t,this.atoms[o]),p[h&=7]++,o=this.voxelsRefs[2*o+1]}var D=0;for(r=1;r<8;r++)p[r]>p[D]&&(D=r);var F=new Dr(e.getAtomColor(t,this.atoms[D]));if(0===this.colorMode&&(l=this.atomColors[D].x,c=this.atomColors[D].y,u=this.atomColors[D].z),1===this.colorMode){var z=this.complex.monomerTypeArray[h].color;l=z.r,c=z.g,u=z.b}1!==this.colorMode&&0!==this.colorMode&&(l=this.atomColors[D].x,c=this.atomColors[D].y,u=this.atomColors[D].z),F.set(E,C,T),s[x]=new Rd(F,L),s[x].colorX=l,s[x].colorY=c,s[x].colorZ=u,x++}return this.voxelsRefs=null,this.voxels=null,s},Od.prototype.destroy=function(){this._vertices=null,this._normals=null,this._indices=null};var Dd=Jp.Element;function Fd(t,e){_d.call(this,t,e)}function zd(t,e){su.call(this),this._opts=e,this.items=[],this.needsUpdate=!1;var r=-50,n=-50;switch(e.horizontalAlign){case"left":r=0;break;case"right":r=-100}switch(e.verticalAlign){case"top":n=-100;break;case"bottom":n=0}var i=new He(e.dx||0,e.dy||0,e.dz||0);this.userData={translation:"translate("+r+"%, "+n+"%)",offset:i}}Fd.prototype=Object.create(_d.prototype),Fd.prototype.constructor=Fd,Fd.prototype._build=function(){this._innerBuild();var t=this.getGeo();this.destroy(),this._fromGeo(t)},Fd.prototype._fromGeo=function(t){var e=null,r=Cu.allocateTyped(Float32Array,3*t._numVertices),n=Cu.allocateTyped(Float32Array,3*t._numVertices);null!==t._colors&&(e=Cu.allocateTyped(Float32Array,3*t._numVertices));var i,o=Cu.allocateTyped(Uint32Array,3*t._numTriangles),a=0;for(i=0;ii?l:i,s.x-lr.x&&(r.x=s.x+l),s.y+l>r.y&&(r.y=s.y+l),s.z+l>r.z&&(r.z=s.z+l)}e.x-=i,e.y-=i,e.z-=i,r.x+=i,r.y+=i,r.z+=i},Fd.prototype.getCornerCoord=function(t,e,r,n,i,o,a){var s=1/(o-1),l=r*s,c=n*s,u=i*s;a.x=t.x*(1-l)+e.x*l,a.y=t.y*(1-c)+e.y*c,a.z=t.z*(1-u)+e.z*u},Fd.prototype.buildEdgePoint=function(t,e,r,n,i,o){if(r[t]^r[e]){var a=(0-n.pointsValuesLinear[i+24+t])/(n.pointsValuesLinear[i+24+e]-n.pointsValuesLinear[i+24+t]),s=n.pointsValuesLinear[i+3*t+0],l=n.pointsValuesLinear[i+3*t+1],c=n.pointsValuesLinear[i+3*t+2],u=n.pointsValuesLinear[i+3*e+0],h=n.pointsValuesLinear[i+3*e+1],p=n.pointsValuesLinear[i+3*e+2];o.x=s*(1-a)+u*a,o.y=l*(1-a)+h*a,o.z=c*(1-a)+p*a}},Fd.prototype.isTriangleVisible=function(t,e,r){var n=this.voxelWorld.getClosestAtom(t),i=this.voxelWorld.getClosestAtom(e),o=this.voxelWorld.getClosestAtom(r);return null!==n&&null!==i&&null!==o&&null!==n.srcAtom&&null!==i.srcAtom&&null!==o.srcAtom&&(this.visibilitySelector.includesAtom(n.srcAtom)&&this.visibilitySelector.includesAtom(i.srcAtom)&&this.visibilitySelector.includesAtom(o.srcAtom))},Fd.prototype.addTriangle=function(t,e,r){if(this.visibilitySelector&&!this.isTriangleVisible(t,e,r))return!0;var n=this.geoOut;if(n._numTriangles>=this.maxNumTriangles)return!1;var i=this.addVertexToGeo(n,t),o=this.addVertexToGeo(n,e),a=this.addVertexToGeo(n,r);if((i|o|a)<0)return!1;var s=3*n._numTriangles;return n._indices[s+0]=i,n._indices[s+1]=o,n._indices[s+2]=a,n._numTriangles++,!0},Fd.prototype.buildGeoFromCorners=function(t,e,r,n,i,o){var a,s,l=t-1,c=t,u=t*t,h=new Array(12);for(a=0;a<12;a++)h[a]=new He;var p=[];for(a=0;a<8;a++)p[a]=1;for(var f=new He,d=0,m=0,g=0;ge.length/2||2*Object.keys(Dd.ByAtomicNumber).length!==e.length)throw new Error("atomT.length should be equal Element.ByAtomicNumber.length * 2");return e[2*t]},Fd.prototype.calculateGridCorners=function(t,e,r,n,i,o){for(var a=e*e,s=a*e,l=new He,c=new He,u=0;u=0;r=this.hashEntries[2*r+1]){var c=this.hashEntries[2*r+0];if(i.copy(t._vertices[c]),i.x-=e.x,i.y-=e.y,i.z-=e.z,i.x*i.x+i.y*i.y+i.z*i.z<1e-6)return c}if(t._numVertices>=this.maxNumVertices)return-1;var u=t._numVertices;if(t._vertices[u].copy(e),null!==this.vBoxMin&&null!==this.vBoxMax){if((r=this.getNewHashEntry())<0)return-1;var h=this.hashLines[l+1];this.hashLines[l+1]=r,this.hashEntries[2*r+0]=u,this.hashEntries[2*r+1]=h,this.hashLines[l+0]++}return t._numVertices++,u},Fd.prototype.modifyExcludedFromGeo=function(t,e,r,n,i,o){var a,s,l;for(var c=t*t,u=(t-1)/(n.x-r.x),h=(t-1)/(n.y-r.y),p=(t-1)/(n.z-r.z),f=2*e*(2*e),d=1/(t-1),m=0;m=0?y:0,_=_>=0?_:0,x=x>=0?x:0,b=b<=t-1?b:t-1,w=w<=t-1?w:t-1,S=S<=t-1?S:t-1;for(var M=_;M<=w;M++)for(var A=M*c,E=x;E<=S;E++)for(var C=E*t,T=y;T<=b;T++){a=A+C+T;var P=T*d,L=r.x*(1-P)+n.x*P;P=M*d;var R=r.y*(1-P)+n.y*P;P=E*d;var N=r.z*(1-P)+n.z*P,I=L-g.x,O=R-g.y,D=N-g.z,F=I*I+O*O+D*D;F0?(o[a]<0&&(o[a]=l),l>o[a]&&(o[a]=l)):l>o[a]&&(o[a]=l))}}return 0},Fd.prototype._innerBuild=function(){var t,e={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};this.complex=this._opts.parent,this.atoms=e.atoms,this.meshResolution=this._opts.gridSpacing,this.atomRadiusScale=this._opts.radScale,this.colorMode=this._opts.colorMode,this.probeRadius=this._opts.probeRadius,this.useVertexColors=!0,this.excludeProbe=this._opts.excludeProbe,this.visibilitySelector=this._opts.visibilitySelector,this.clusterizationType=this._opts.clusterizationType,this.geoOut=null,this.hashLines=null,this.hashEntries=null,this.numHashEtriesAllocated=0,this.numHashEntryIndex=0,this.maxNumVertices=0,this.maxNumTriangles=0;var r=new Array(this.atoms.length);this.convertToAtomsColored(e,r);var n=this.vBoxMin=new He,i=this.vBoxMax=new He;this.getBoundingBox(r,n,i);var o=this.marCubeResoultion=4*this.meshResolution,a=o,s=a*a*a,l=Cu.allocateTyped(Float32Array,s),c=this.meshResolution,u=4,h=this.atoms.length;h>=100&&(u=Math.floor(Math.pow(2*h,1/3))),c>u&&(c=u);var p=this.probeRadius*this.atomRadiusScale,f=null,d=null;this.clusterizationType>0?(f=new Id(this.complex,this.atoms,r,n,i,c,this.colorMode),d=1===this.clusterizationType?f.buildKMeans():f.buildSimple(),n.x-=3.5,n.y-=3.5,n.z-=3.5,i.x+=3.5,i.y+=3.5,i.z+=3.5,this.calculateGridCorners(l,a,n,i,d,p)):this.calculateGridCorners(l,a,n,i,r,p);var m=o-1,g=new xd;if((t=g.create(m))<0)return t;var v=new He;v.x=(i.x-n.x)/m,v.y=(i.y-n.y)/m,v.z=(i.z-n.z)/m;var y=this.getNumIntersectedCells(a,m,l,g),_=Math.floor(1.2*y),x=Math.floor(1.2*y*2);if(this.geoOut=new Od(_,x,this.useVertexColors),(t=this.createVertexHash(_,x))<0)return t;var b=p;if(this.excludeProbe&&(b=.01),this.voxelWorld=null,this.clusterizationType>0?this.voxelWorld=new Nd(d.length,d,n,i,b):this.voxelWorld=new Nd(r.length,r,n,i,b),this.voxelWorld.createVoxels(),t=this.buildGeoFromCorners(o,n,i,l,v,g),this.excludeProbe){if(this.modifyExcludedFromGeo(a,p,n,i,this.geoOut,l),this.geoOut._vertices=null,this.geoOut._colors=null,this.geoOut._indices=null,this.geoOut._normals=null,this.geoOut._numVertices=0,this.geoOut._numTriangles=0,this.geoOut=null,y=this.getNumIntersectedCells(a,m,l,g),_=Math.floor(1.2*y),x=Math.floor(1.2*y*2),this.geoOut=new Od(_,x,this.useVertexColors),(t=this.createVertexHash(_,x))<0)return t;t=this.buildGeoFromCorners(a,n,i,l,v,g)}if(null!==this.voxelWorld){this.voxelWorld.buildNormals(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._normals);var w=6.5;this.excludeProbe&&(w-=1.5),this.useVertexColors&&this.voxelWorld.buildColors(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._colors,w)}return this.voxelWorld.destroyVoxels(),this.voxelWorld=null,null!==f&&f.destroy(),g.destroy(),t},zd.prototype=Object.create(su.prototype),zd.prototype.constructor=zd,zd.prototype.setItem=function(t,e,r){var n=this._opts,i=n.labels,o=this.items[t]||function(t,e){var r=document.createElement("div");if(r.className=e,"string"==typeof t){var n=document.createElement("span");n.style.fontSize="150%";for(var i=t.split("\n"),o=0,a=i.length;o=0;--e)this.remove(t[e]);var r=this.geometry.items,i=this.geometry.userData,o=r.length;for(e=0;e0?n:[new Xe];for(var o=this._createMeshes(t),a=0,s=o.length;a>16&255,r=t>>8&255,n=255&t;return.2126*e+.7152*r+.0722*n>127?(e=3*e/10,r=3*r/10,n=3*n/10):(e=255-3*(255-e)/10,r=255-3*(255-r)/10,n=255-3*(255-n)/10),e<<16|r<<8|n},inverse:function(t){return 255-(t>>16&255)<<16|255-(t>>8&255)<<8|255-(255&t)}};function cm(t,e){var r;if(lm.hasOwnProperty(e))r=Cu.hexColor(lm[e](t));else{var n=parseInt(e,16);r=!Number.isNaN(n)&&e.toLowerCase().startsWith("0x")?Cu.hexColor(n):"#000000"}return r}var um={serial:function(t){return t.getSerial()},name:function(t){return t.getVisualName()},elem:function(t){return t.element.name},residue:function(t){return t._residue.getType().getName()},sequence:function(t){return t._residue.getSequence()},chain:function(t){return t._residue.getChain().getName()},hetatm:function(t){return t.isHet()},water:function(t){return"HOH"===t._residue.getType().getName()||"WAT"===t._residue.getType().getName()}},hm=function(t,e){return e.replace(/\{\{(\s*\w+\s*)\}\}/g,function(e){var r=e.replace(/\s+/g,"");return r=r.substring(2,r.length-2).toLowerCase(),um.hasOwnProperty(r)?um[r](t):"null"})};function pm(t,e,r,n,i,o,a){this._geoArgs=this._makeGeoArgs(e,n,r,o),nm.call(this,t,e,r,n,i,o,a)}function fm(t,e,r,n){var i=Math.sin(t);return e.clone().multiplyScalar(Math.sin((1-n)*t)/i).addScaledVector(r,Math.sin(n*t)/i)}function dm(t,e,r,n,i,o,a){nm.call(this,t,e,r,n,i,o,a)}pm.prototype=Object.create(nm.prototype),pm.prototype.constructor=pm,pm.prototype._makeGeoArgs=function(t,e,r,n){var i=e.getLabelOpts();return[t.chunks.length,i]},pm.prototype._build=function(){for(var t=this._mode.getLabelOpts(),e=this._selection.chunks,r=this._selection.atoms,n=this._selection.parent,i=this._colorer,o=this._geo,a=0,s=e.length;a=0;n--){var i=t[n];"."===i?t.splice(n,1):".."===i?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}var Gh=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,Hh=function(t){return Gh.exec(t).slice(1)};function Wh(){for(var t="",e=!1,r=arguments.length-1;r>=-1&&!e;r--){var n=r>=0?arguments[r]:"/";if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(t=n+"/"+t,e="/"===n.charAt(0))}return t=jh(tp(t.split("/"),function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function Xh(t){var e=Yh(t),r="/"===ep(t,-1);return(t=jh(tp(t.split("/"),function(t){return!!t}),!e).join("/"))||e||(t="."),t&&r&&(t+="/"),(e?"/":"")+t}function Yh(t){return"/"===t.charAt(0)}function qh(){return Xh(tp(Array.prototype.slice.call(arguments,0),function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function Zh(t,e){function r(t){for(var e=0;e=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=Wh(t).substr(1),e=Wh(e).substr(1);for(var n=r(t.split("/")),i=r(e.split("/")),o=Math.min(n.length,i.length),a=o,s=0;s2&&A.push("'"+this.terminals_[w]+"'");T=p.showPosition?"Parse error on line "+(l+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[v]||v)+"'":"Parse error on line "+(l+1)+": Unexpected "+(v==u?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(T,{text:p.match,token:this.terminals_[v]||v,line:p.yylineno,loc:m,expected:A})}if(x[0]instanceof Array&&x.length>1)throw new Error("Parse Error: multiple actions possible at state: "+_+", token: "+v);switch(x[0]){case 1:r.push(v),i.push(p.yytext),o.push(p.yylloc),r.push(x[1]),v=null,y?(v=y,y=null):(c=p.yyleng,s=p.yytext,l=p.yylineno,m=p.yylloc);break;case 2:if(S=this.productions_[x[1]][1],C.$=i[i.length-S],C._$={first_line:o[o.length-(S||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(S||1)].first_column,last_column:o[o.length-1].last_column},g&&(C._$.range=[o[o.length-(S||1)].range[0],o[o.length-1].range[1]]),void 0!==(b=this.performAction.apply(C,[s,c,l,d.yy,x[1],i,o].concat(h))))return b;S&&(r=r.slice(0,-1*S*2),i=i.slice(0,-1*S),o=o.slice(0,-1*S)),r.push(this.productions_[x[1]][0]),i.push(C.$),o.push(C._$),M=a[r[r.length-2]][r[r.length-1]],r.push(M);break;case 3:return!0}}return!0}},g={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],r=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;var t,e,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;oe[0].length)){if(e=r,n=o,this.options.backtrack_lexer){if(!1!==(t=this.test_match(r,i[o])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[n]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,r,n){switch(r){case 0:break;case 1:return 20;case 2:return 7;case 3:return 8;case 4:return 9;case 5:return 12;case 6:return 16;case 7:return 14;case 8:return 10;case 9:return 11;case 10:return 19;case 11:return 21;case 12:return"<=";case 13:return">=";case 14:return"<";case 15:return">";case 16:return e.yytext=e.yytext.substr(1,e.yyleng-2),24;case 17:return 13;case 18:return 23;case 19:return 5;case 20:return"INVALID"}},rules:[/^(?:\s+)/i,/^(?:(-?(?:[1-9][0-9]+|[0-9]))\b)/i,/^(?:OR\b)/i,/^(?:AND\b)/i,/^(?:NOT\b)/i,/^(?:((ALL|NONE|HETATM|PROTEIN|BASIC|ACIDIC|CHARGED|POLAR|NONPOLAR|AROMATIC|NUCLEIC|PURINE|PYRIMIDINE|WATER|POLARH|NONPOLARH))\b)/i,/^(?:((NAME|ELEM|TYPE|RESIDUE|ICODE|CHAIN|ALTLOC))\b)/i,/^(?:((SERIAL|SEQUENCE|RESIDX))\b)/i,/^(?:\()/i,/^(?:\))/i,/^(?:,)/i,/^(?::)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:((?:"([^"]*)"|'([^']*)')))/i,/^(?:(@[_A-Z0-9]+))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],inclusive:!0}}};function v(){this.yy={}}return m.lexer=g,v.prototype=m,m.Parser=v,new v}();void 0!==e&&(r.parser=n,r.Parser=n.Parser,r.parse=function(){return n.parse.apply(n,arguments)},r.main=function(t){t[1]||process.exit(1);var e=np.readFileSync(ip.normalize(t[1]),"utf8");return r.parser.parse(e)},e.main===t&&r.main(process.argv.slice(1)))}),ap=op.parser,sp=(op.Parser,op.parse,op.main,{});function lp(t,e){var r=t.toLowerCase();e.prototype.keyword=r,e.prototype.name=t;var n=function(){for(var t=arguments.length,r=Array(t),n=0;n=0&&e.splice(r,1),this}},{key:"toString",value:function(){return this._values.join(",")}},{key:"toJSON",value:function(){for(var t=this._values,e=[],r=0,n=t.length;rthis.priority?"("+this.rhs+")":this.rhs;return this.keyword+" "+t}},{key:"toJSON",value:function(){return[this.name,this.rhs.toJSON()]}}]),e}();bp.prototype.priority=1;var wp=function(t){function e(t,r){ku(this,e);var n=ju(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.lhs=t||yp,n.rhs=r||yp,n}return Vu(e,fp),Bu(e,[{key:"toString",value:function(){var t=this.lhs.priority&&this.lhs.priority>this.priority?"("+this.lhs+")":this.lhs,e=this.rhs.priority&&this.rhs.priority>this.priority?"("+this.rhs+")":this.rhs;return t+" "+this.keyword+" "+e}},{key:"toJSON",value:function(){return[this.name,this.lhs.toJSON(),this.rhs.toJSON()]}}]),e}();wp.prototype.priority=1e3,xp("Not",1,function(t){function e(){return ku(this,e),ju(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Vu(e,bp),Bu(e,[{key:"includesAtom",value:function(t){return!this.rhs.includesAtom(t)}}]),e}()),xp("And",2,function(t){function e(){return ku(this,e),ju(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Vu(e,wp),Bu(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)&&this.rhs.includesAtom(t)}}]),e}()),xp("Or",3,function(t){function e(){return ku(this,e),ju(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Vu(e,wp),Bu(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)||this.rhs.includesAtom(t)}}]),e}());var Sp=Object.create(sp);function Mp(t){this._complex=t,this._selector=Sp.keyword("All")(),this._boundaries={boundingBox:new gn,boundingSphere:new vn}}function Ap(t){Mp.call(this,t),this.chains=[],this.matrices=[]}function Ep(){if(this.constructor===Ep)throw new Error("Can not instantiate abstract class!")}function Cp(t){this._complex=t,this._index=-1,this._residueIndices=[],this._cycles=[],this._subDivs=[],this._residueCount=0}Sp.Selector=fp,Sp.RangeListSelector=gp,Sp.ValueListSelector=vp,Sp.Range=cp,Sp.RangeList=hp,Sp.ValueList=dp,Sp.PrefixOperator=bp,Sp.InfixOperator=wp,Sp.Context=Object.create({}),Sp.GetSelector=function(t){if(!Sp.Context.hasOwnProperty(t))throw{message:"selector "+t+" is not registered"};return Sp.Context[t]||yp},Sp.ClearContext=function(){Object.keys(Sp.Context).forEach(function(t){delete Sp.Context[t]})},Sp.keyword=function(t){return sp[t.toLowerCase()]||sp.none},Sp.parse=function(t){var e={};try{e.selector=ap.parse(t)}catch(t){e.selector=yp,e.error=t.message}return e},ap.yy=Sp,ap.yy.parseError=ap.parseError,Mp.prototype.constructor=Mp,Mp.prototype.computeBoundaries=function(){var t,e=this._complex._atoms,r=e.length,n=this._selector,i=this._boundaries.boundingBox;if(i.makeEmpty(),1===r){i.expandByPoint(e[0]._position);var o=i.getCenter(),a=2*e[0].element.radius;i.setFromCenterAndSize(o,new He(a,a,a))}else for(t=0;t0?this._selector=Sp.keyword("Chain")(this.chains):this._selector=Sp.keyword("None")()},Ep.prototype.id="__",Cp.prototype.getResidues=function(){return this._complex._residues},Cp.prototype.getResidueCount=function(){return this._residueCount},Cp.prototype.forEachResidue=function(t){for(var e=this._complex._residues,r=this._residueIndices,n=0,i=r.length;ne?t:e,i=r+(n<<14),o=(r+89237*n&Pp-1)*Tp,a=0;a=Tp)throw new Error("addPair: increase cMaxPairsForHashCode");if(this.hashBuffer[o+a]=i,this.numPairs>=this.numMaxPairs)throw new Error("addPair: increase num pairs");return o=this.numPairs*Lp,this.intBuffer[o]=r,this.intBuffer[o+1]=n,this.intBuffer[o+2]=i,this.numPairs++,!0};function Ip(t){var e=t.element;if(e)return e.radiusBonding;throw new Error("_getBondingRadius: Logic error.")}function Op(t){return!t.isHet()||t._bonds&&0===t._bonds.length}function Dp(t){return"HOH"!==t._residue._type._name&&!t.isHet()}function zp(t){this._complex=t,this._maxRad=1.8;var e=this._complex.getDefaultBoundaries().boundingBox;this._vBoxMin=e.min.clone(),this._vBoxMax=e.max.clone(),this._pairCollection=null}zp.prototype._addExistingPairs=function(){for(var t=this._complex.getAtoms(),e=t.length,r=0,n=this._pairCollection;ru*u||r<.001||i._pairCollection.addPair(c._index,t._index)}}},h=0;h.1)&&Fp.dot(kp)>=0});function Qp(t,e){for(var r=0;r3}function od(t){return!0}function ad(t){this._complex=t;for(var e=new Array(t._bonds.length),r=new Array(t._bonds.length),n=0,i=e.length;ni[l]?++l:++s}return!1},ad.prototype._tryBond=function(t,e,r){var n=[],i=this._bondsData,o=Jp(t,e),a=e._position.clone().sub(o._position),s=this._currStart,l=this,c=this._bondMarks,u=this._checkBond;c[t._index]=!0,u=void 0===u?rd:u,e.forEachBond(function(o){if(u(o)&&o!==t&&!c[o._index]&&!l._haveSameCycle(i,t,o)){var h,p,d,f=Jp(o,e),m=f._position.clone().sub(e._position),g=f===s?-2:1-(p=m,d=(h=a).dot(p)/Math.sqrt(h.lengthSq()*p.lengthSq()),ve.clamp(d,-1,1)),v=m.cross(a);if(Kp(v,r)){for(var y=0;y=0;r=this._atoms[r+1])e(this._atoms[r])},sd.prototype._forEachVoxelWithinRadius=(jp=new ye,Gp=new ye,Hp=new ye,function(t,e,r){if(e/this._cellInnerR<10)this._forEachVoxelWithinRadiusSimple(t,e,r);else{var n,i,o,a,s,l,c,u,h,p,d,f,m,g,v,y,_=void 0,x=void 0,b=void 0,w=void 0,S=void 0,M=void 0,A=void 0,E=void 0;Hp.set(t.z-e,t.z+e),Hp.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor().clampScalar(0,this._count.z-1);for(var C=Hp.x;C<=Hp.y;++C){S=[this._box.min.z+C*this._cellSize.z,this._box.min.z+(C+1)*this._cellSize.z],E=t.z-e<=S[0]&&S[1]<=t.z+e,h=t,p=e,d=S[0],f=S[1],m=d-h.z,g=f-h.z,v=Math.sqrt(Math.max(p*p-m*m,0)),y=Math.sqrt(Math.max(p*p-g*g,0)),_=[Math.min(v,y),d<=h.z&&f>=h.z?p:Math.max(v,y)],Gp.set(t.y-_[1],t.y+_[1]),Gp.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor().clampScalar(0,this._count.y-1);for(var T=Gp.x;T<=Gp.y;++T){w=[this._box.min.y+T*this._cellSize.y,this._box.min.y+(T+1)*this._cellSize.y],A=t.y-_[0]<=w[0]&&w[1]<=t.y+_[0],n=t,i=_[1],o=w[0],a=w[1],s=o-n.y,l=a-n.y,c=Math.sqrt(Math.max(i*i-s*s,0)),u=Math.sqrt(Math.max(i*i-l*l,0)),x=[Math.min(c,u),o<=n.y&&a>=n.y?i:Math.max(c,u)],jp.set(t.x-x[1],t.x+x[1]),jp.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor().clampScalar(0,this._count.x-1);for(var P=jp.x;P<=jp.y;++P)b=[this._box.min.x+P*this._cellSize.x,this._box.min.x+(P+1)*this._cellSize.x],M=t.x-x[0]<=b[0]&&b[1]<=t.x+x[0],r(P+this._count.x*(T+this._count.y*C),M&&A&&E)}}}}),sd.prototype._forEachVoxelWithinRadiusSimple=(Wp=new ye,Xp=new ye,Yp=new ye,qp=new He,function(t,e,r){var n=(e+this._cellOuterR)*(e+this._cellOuterR),i=-1;e>this._cellOuterR&&(i=(e-this._cellOuterR)*(e-this._cellOuterR)),Wp.set(t.x-e,t.x+e),Wp.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor(),Wp.x=Math.min(Math.max(Wp.x,0),this._count.x-1),Wp.y=Math.min(Math.max(Wp.y,0),this._count.x-1),Xp.set(t.y-e,t.y+e),Xp.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor(),Xp.x=Math.min(Math.max(Xp.x,0),this._count.y-1),Xp.y=Math.min(Math.max(Xp.y,0),this._count.y-1),Yp.set(t.z-e,t.z+e),Yp.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor(),Yp.x=Math.min(Math.max(Yp.x,0),this._count.z-1),Yp.y=Math.min(Math.max(Yp.y,0),this._count.z-1);for(var o=Yp.x;o<=Yp.y;++o){var a=[this._box.min.z+o*this._cellSize.z,this._box.min.z+(o+1)*this._cellSize.z];qp.z=.5*(a[0]+a[1]);for(var s=Xp.x;s<=Xp.y;++s){var l=[this._box.min.y+s*this._cellSize.y,this._box.min.y+(s+1)*this._cellSize.y];qp.y=.5*(l[0]+l[1]);for(var c=Wp.x;c<=Wp.y;++c){var u=[this._box.min.x+c*this._cellSize.x,this._box.min.x+(c+1)*this._cellSize.x];qp.x=.5*(u[0]+u[1]);var h=t.distanceToSquared(qp);h<=n&&r(c+this._count.x*(s+this._count.y*o),h<=i)}}}}),sd.prototype.forEachAtomWithinRadius=function(t,e,r){var n=this,i=e*e;n._forEachVoxelWithinRadius(t,e,function(e,o){o?n._forEachAtomInVoxel(e,r):n._forEachAtomInVoxel(e,function(e){t.distanceToSquared(e._position)<=i&&r(e)})})},sd.prototype.forEachAtomWithinDistFromMasked=function(t,e,r,n){this._forEachAtomWithinDistFromGroup(function(r){t.forEachAtom(function(t){0!=(t._mask&e)&&r(t)})},r,n)},sd.prototype.forEachAtomWithinDistFromSelected=function(t,e,r,n){this._forEachAtomWithinDistFromGroup(function(r){t.forEachAtom(function(t){e.includesAtom(t)&&r(t)})},r,n)},sd.prototype._forEachAtomWithinDistFromGroup=function(t,e,r){var n,i=this,o=e*e,a=[],s=[],l=0;t(function(t){i._forEachVoxelWithinRadius(t._position,e,function(e,r){r?a[e]=-1:void 0===a[e]?(s.push(t),s.push(-1),a[e]=l,l+=2):-1!==a[e]&&(s.push(t),s.push(a[e]),a[e]=l,l+=2)})});var c=function(t){if(void 0!==a[n])if(-1!==(l=a[n])){for(;l>=0;l=s[l+1])if(t._position.distanceToSquared(s[l]._position)cd?this._buildVW():this._build()}return Bu(t,[{key:"isBond",value:function(t,e){if(this._hbonds[t]){var r=this._hbonds[t].acceptor[0];if(r&&r.residue===e&&r.energy<-.5)return!0;if((r=this._hbonds[t].acceptor[1])&&r.residue===e&&r.energy<-.5)return!0}return!1}},{key:"_build",value:function(){for(var t=0;t0&&this._complex._residues[t-1].getType().flags&Eh.Flags.PROTEIN&&e._sequence===this._complex._residues[t-1]._sequence+1&&(r=this._complex._residues[t-1]);for(var n=t+1;n0?e[a-1]:null)||0!=(n.getType().flags&Eh.Flags.PROTEIN)&&r._sequence===n._sequence+1||(n=null),i.forEachAtomWithinRadius(this._residueGetCAlpha(r),5,s));function s(i){var a=i._residue;if(a._index!==r._index&&0!=(a.getType().flags&Eh.Flags.PROTEIN)&&o.addPair(r._index,a._index)){var s=a._index>0?e[a._index-1]:null;!s||0!=(s.getType().flags&Eh.Flags.PROTEIN)&&a._sequence===s._sequence+1||(s=null),t._calcHBondEnergy(n,r,a),a._index!==r._index+1&&t._calcHBondEnergy(s,a,r)}}}},{key:"_residueGetCAlpha",value:function(t){for(var e=0;e1&&(n1&&(n70}for(var l=1;l+4=b&&this._isHelixStart(t[y-b]._index,x);_?this._ss[t[y]._index]=dd.TURN:this._bend[t[y]._index]&&(this._ss[t[y]._index]=dd.BEND)}}},{key:"_residueGetCAlpha",value:function(t){for(var e=0;e0&&(a=i.dot(o)/Math.sqrt(s)),a}},{key:"_kappa",value:function(t,e,r){var n=this._residueGetCAlpha(e),i=this._residueGetCAlpha(t),o=this._residueGetCAlpha(r);if(null===n||null===i||null===o)return 180;var a=this._cosinusAngle(n,i,o,n),s=Math.sqrt(1-a*a);return 180*Math.atan2(s,a)/Math.PI}},{key:"_isHelixStart",value:function(t,e){return this._helixFlags[e][t]===pd.START||this._helixFlags[e][t]===pd.START_AND_END}},{key:"_buildBetaSheets",value:function(){for(var t=[],e=0;e=6||w>=A&&b<=E)){(t[_].type===hd.PARALLEL?C-M<6&&A-w<3||C-M<3:S-T<6&&A-w<3||S-T<3)&&(t[_].i=t[_].i.concat(t[x].i),t[_].type===hd.PARALLEL?t[_].j=t[_].j.concat(t[x].j):t[_].j=t[x].j.concat(t[_].j),t.splice(x--,1))}}for(var P=new Set,L=0;L0;){var I=P.values().next().value;P.delete(I);var O=new Set;O.add(I);var D=void 0;do{D=new Set;var z=!0,F=!1,k=void 0;try{for(var B,U=O.values()[Symbol.iterator]();!(z=(B=U.next()).done);z=!0){var V=B.value,j=!0,G=!1,H=void 0;try{for(var W,X=P.values()[Symbol.iterator]();!(j=(W=X.next()).done);j=!0){var Y=W.value;this._areBridgesLinked(V,Y)&&D.add(Y)}}catch(t){G=!0,H=t}finally{try{!j&&X.return&&X.return()}finally{if(G)throw H}}}}catch(t){F=!0,k=t}finally{try{!z&&U.return&&U.return()}finally{if(F)throw k}}var q=!0,Z=!1,$=void 0;try{for(var K,Q=D.values()[Symbol.iterator]();!(q=(K=Q.next()).done);q=!0)I=K.value,O.add(I),P.delete(I)}catch(t){Z=!0,$=t}finally{try{!q&&Q.return&&Q.return()}finally{if(Z)throw $}}}while(D.size>0);var J=!0,tt=!1,et=void 0;try{for(var rt,nt=O.values()[Symbol.iterator]();!(J=(rt=nt.next()).done);J=!0)(I=rt.value).ladder=N,I.sheet=R,I.link=O,++N}catch(t){tt=!0,et=t}finally{try{!J&&nt.return&&nt.return()}finally{if(tt)throw et}}++R}for(var it=0;it1&&(ut=dd.STRAND),ot.type===hd.PARALLEL){for(var ht=0,pt=0;pt>1;t;)e<<=1,t>>=1;return e}function yd(t,e,r){this._complex=t,this._name=e||"",this._residues=[],this._mask=1,this._index=r||-1}Iu.deriveClass(md,Ep,{id:"Complex"}),md.prototype.name="",md.prototype.addAtom=function(t){var e=this._atoms.length;return this._atoms.push(t),e},md.prototype.addSheet=function(t){var e=this._sheets.length;return this._sheets.push(t),e},md.prototype.addHelix=function(t){var e=this._helices.length;return this._helices.push(t),e},md.prototype.getAtoms=function(){return this._atoms},md.prototype.getBonds=function(){return this._bonds},md.prototype.getAtomCount=function(){return this._atoms.length},md.prototype.addResidue=function(t){var e=this._residues.length;return this._residues.push(t),e},md.prototype.updateToFrame=function(t){this.forEachChain(function(e){e.updateToFrame(t)})},md.prototype.addResidueType=function(t){return this._residueTypes[t]=new Eh(t,"Unknown","")},md.prototype.getResidueCount=function(){return this._residues.length},md.prototype.getResidues=function(){return this._residues},md.prototype.getSGroupCount=function(){return this._sgroups.length},md.prototype.getSGroups=function(){return this._sgroups},md.prototype.getAtomByFullname=function(t){var e=t.split(".");if(3!==e.length)return null;var r=e[0],n=parseInt(e[1],10);if(Number.isNaN(n))return null;var i=e[2].toUpperCase(),o=null;return this.forEachChain(function(t){o||0===t._name.localeCompare(r)&&t.forEachResidue(function(t){o||t._sequence===n&&t.forEachAtom(function(t){o||0===i.localeCompare(t._name.getString())&&(o=t)})})}),o},md.prototype.addChain=function(t){var e=new Dh(this,t);return this._chains.push(e),e},md.prototype.getChain=function(t){for(var e=0,r=this._chains.length;es?1:0},md.prototype._atomNameCompareCWithH=function(t,e){return this._atomNameCompare(t,e,2)},md.prototype._atomNameCompareCWithoutH=function(t,e){return this._atomNameCompare(t,e,254)},md.prototype._buildFormulaSimple=function(t,e){var r=t.atoms,n=null,i={},o="",a=this,s=bh.ByName.H.name,l=0;r.forEach(function(t){var e=t.getHydrogenCount();n=t.element,i[n.name]?i[n.name]+=1:i[n.name]=1,e>0&&(i[s]?i[s]+=e:i[s]=e),l+=t.getCharge()});var c=Object.keys(i);return i.C?c.sort(this._atomNameCompareCWithH.bind(this)):c.sort(function(t,e){return a._atomNameCompare(t,e,"H".charCodeAt(0))}),c.forEach(function(t){var e=t.substr(0,1).toUpperCase()+t.substr(1).toLowerCase();i[t]>1?o+=e+i[t].toString():o+=e}),null===e?(0!==l&&(c.length>1&&(o="("+o+")"),l>1&&(o+="^{"+l.toString()+"+}"),1===l&&(o+="^+"),l<-1&&(o+="^{"+Math.abs(l).toString()+"-}"),-1===l&&(o+="^-")),t.repeatCount>1&&(o=t.repeatCount.toString(10)+o)):e(c.length,l),o},md.prototype._buildPartFormula=function(t){return t.owner instanceof md||t.owner instanceof Cp?this._buildFormulaSimple(t,null):t.owner instanceof Bh?t.owner.buildChemicalFormula(this,t):""},md.prototype._partCompareFunc=function(t,e){return this._partCompareFuncInt(t,e,!0)},md.prototype._getCumulativeCharge=function(t){for(var e=t.length,r=0,n=0;n0&&(r[i]?r[i]+=n:r[i]=n)}});var o=Object.keys(r);return o.sort(n._atomNameCompareCWithoutH.bind(n)),{seq:o,data:r}}for(var a,s=[r,!1],l=0;lbh.ByName.MT.number)return"}\\text{Could not create chemical formula for this structure.}{"}return""},md.prototype.buildChemicalFormula=function(){var t=[],e=null,r=null,n={},i=null,o=this,a=this._checkFormulaBuildable();if(""!==a)return a;this.forEachAtom(function(t){n[t.getSerial()]&&vu.warn("Broken complex. Formula can be invalid..."),n[t.getSerial()]={atom:t,taken:null}}),this.forEachSGroup(function(o){0===o._charge&&1===o._repeat||(r=(e={owner:o,atoms:[],repeatCount:1}).atoms,o._atoms.forEach(function(t){null===(i=n[t.getSerial()]).taken&&(r.push(t),i.taken=o)}),e.atoms.length>0&&t.push(e),e=null)}),this.forEachComponent(function(o){r=(e={owner:o,atoms:[],repeatCount:1}).atoms,o.forEachResidue(function(t){t._atoms.forEach(function(t){null===(i=n[t.getSerial()]).taken&&(r.push(t),i.taken=o)})}),e.atoms.length>0&&t.push(e),e=null}),Object.keys(n).forEach(function(t){null===t.taken&&(null===e&&(e={owner:o,atoms:[],repeatCount:1}),e.atoms.push(t.atom),t.taken=o)}),null!==e&&e.atoms.length>0&&t.push(e),t.sort(function(t,e){return o._partCompareFunc(t,e)});for(var s=t.length-1,l=t.length-2;s>=0&&l>=0;){var c=t[s],u=t[l];c.owner instanceof md||c.owner instanceof Cp?u.owner instanceof md||u.owner instanceof Cp?(0===this._partCompareFuncInt(u,c,!1)&&(u.repeatCount+=c.repeatCount,t.splice(s,1)),l--,s--):l--:--s===l&&l--}return t.forEach(function(t){var e=o._buildPartFormula(t);e.length>0&&(a.length>0&&(a+="*"),a+=e)}),a},md.prototype.getUnifiedSerial=function(t,e,r){return e+65536*r+16777216*t},md.prototype.splitUnifiedSerial=function(t){var e=Math.floor(t/16777216),r=t-16777216*e,n=Math.floor(r/65536);return{chain:e,serial:r-65536*n,iCode:n}},md.prototype._fillCmpEdit=function(){var t=this,e=this._components;function r(){var r=new Cp(t);return r._index=e.length,e[r._index]=r,r}this.forEachChain(function(t){var e=t._residues,n=e.length;if(!(n<1))for(var i=r(),o=e[0]._index,a=0;a=0&&t=0;e--){var i=n[e];null===i._left||null===i._right?n.splice(e,1):(i._left._bonds.push(i),i._right._bonds.push(i))}var o=this._residues;for(e=0,r=o.length;e1?t.x/(this._dimX-1):0,e.y=this._dimY>1?t.y/(this._dimY-1):0,e.z=this._dimZ>1?t.z/(this._dimZ-1):0,e},gd.prototype.computeGradient=function(){if(1!==this._dimVec)return null;var t=new gd(Float32Array,[this._dimX,this._dimY,this._dimZ],this._box,3),e=this.getCellSize(),r=new He(-.5/e.x,-.5/e.y,-.5/e.z);function n(t,e,r){return Math.min(r,Math.max(e,t))}var i=this._dimX,o=this._dimY,a=this._dimZ,s=this._data;function l(t,e,r){return s[r*i*o+e*i+t]}for(var c=0;c=1?this.fov=t:this.fov=ve.radToDeg(2*Math.atan(Math.tan(.5*ve.degToRad(t))/this.aspect))},Xn.prototype.setDistanceToFit=function(t,e){this.position.z=t/Math.sin(.5*ve.degToRad(e))},zi.prototype.copyAtList=function(t,e){for(var r=this.itemSize,n=0,i=e.length;n1e-5;)e=n,n=t/((i=1+r*n)*i);return 1/i}for(var i=new Qi(2,2,t,e),o=i.getAttribute("position"),a=0;a65535,l=o*e,c=this._index=Iu.allocateTyped(s?Uint32Array:Uint16Array,l);this._positions=Iu.allocateTyped(Float32Array,3*a),this._normals=Iu.allocateTyped(Float32Array,3*a),this._colors=Iu.allocateTyped(Float32Array,3*a);var u=this._alpha=Iu.allocateTyped(Float32Array,a);n.fill(u,1);for(var h=0;h0,l=!1===o&&e>0,c=(i+1)*n+s*(n+1)+l*(n+1),u=(2*i+s+l)*n,h=r/2,p=new zi(Iu.allocateTyped(Float32Array,3*c),3),d=new zi(Iu.allocateTyped(Float32Array,3*c),3),f=new Vi(Iu.allocateTyped(Uint16Array,u*tf),1),m=new zi(Iu.allocateTyped(Float32Array,2*c),2),g=0,v=0,y=-(e-t)/r,_=0;_<=i;_++){if(_!==i)for(var x=0;x65535;this._index=Iu.allocateTyped(r?Uint32Array:Uint16Array,6*t),this._positions=Iu.allocateTyped(Float32Array,4*e),this._colors=Iu.allocateTyped(Float32Array,3*e),this._directions=Iu.allocateTyped(Float32Array,3*e);var i=this._alpha=Iu.allocateTyped(Float32Array,e);n.fill(i,1);for(var o=this._index,a=0,s=0,l=0;l117440512)throw new Error("Too large cube dimension: lead to memory huge uasge");return this.pointsValuesLinear=Iu.allocateTyped(Float32Array,32*e),this.hasIntersection=Iu.allocateTyped(Int32Array,e),this.bitsInside=Iu.allocateTyped(Int32Array,e),0},Uf.prototype.destroy=function(){this.bitsInside=null,this.hasIntersection=null,this.pointsValuesLinear=null},Uf.prototype.striIndicesMarchCube=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];var Vf=[0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0];function jf(){this._arrSize=8,this.p=new Array(this._arrSize),this.g=new Array(this._arrSize),this.val=new Array(this._arrSize);for(var t=0;t0&&(d=h/p),d=d>1?1:d,i.lerpVectors(a,s,d),o.lerpVectors(l,c,d)},Hf.prototype._polygonize=function(){for(var t=Uf.prototype.striIndicesMarchCube,e=[0,1,2,3,4,5,6,7,0,1,2,3],r=[1,2,3,0,5,6,7,4,4,5,6,7],n=new Array(12),i=new Array(12),o=0;o<12;++o)n[o]=new He,i[o]=new He;return function(a,s,l){var c=a.cubeIndex;for(o=0;o<12;++o)Vf[c]&1<s?s:c+e,h=-1,p=c;pV&&(j=G,V=A[G]);if(j<0||!n.includesAtom(M[j])){P[i]=-1;continue}}P[i]=L++;var H=D=0&&nt>=0&&it>=0&&(this._indices[3*et]=rt,this._indices[3*et+1]=nt,this._indices[3*et+2]=it,++et)}this._position=new Float32Array(this._position.buffer.slice(0,3*L*4)),this._normals=new Float32Array(this._normals.buffer.slice(0,3*L*4)),this._colors=new Float32Array(this._colors.buffer.slice(0,3*L*4)),this._indices=new Uint32Array(this._indices.buffer.slice(0,3*et*4))}},Hf.prototype.toMesh=function(){var t=new qi;return t.setIndex(new zi(this._indices,1)),t.addAttribute("position",new zi(this._position,3)),t.addAttribute("normal",new zi(this._normals,3)),t.addAttribute("color",new zi(this._colors,3)),t.computeBoundingSphere(),t},Wf.prototype=Object.create(Bf.prototype),Wf.prototype.constructor=Wf,Wf.prototype._build=function(){var t=this._opts;this.numVoxels=[128,128,128],this.xAxis=new He(1,0,0),this.yAxis=new He(0,1,0),this.zAxis=new He(0,0,1),this.origin=new He(0,0,0),this._visibilitySelector=t.visibilitySelector,this._calcSurface(t)},Wf.prototype._findMinMax=function(t){for(var e=t.length/4,r=[t[0],t[1],t[2],t[3]],n=[t[0],t[1],t[2],t[3]],i=1;i4&&(e.gridSpacing*=i[3]);var a=e.radScale*o[3]*1.7,s=a;s=.65*Math.sqrt(4/3*Math.PI*s*s*s),a=Math.max(a,s);for(var l=0;l<3;++l)i[l]-=a,o[l]+=a;for(l=0;l<3;++l)r[l]=Math.ceil((o[l]-i[l])/e.gridSpacing);return this.xAxis.x=(r[0]-1)*e.gridSpacing,this.yAxis.y=(r[1]-1)*e.gridSpacing,this.zAxis.z=(r[2]-1)*e.gridSpacing,this.origin.x=i[0],this.origin.y=i[1],this.origin.z=i[2],{bbox:n,dim:r}},Wf.prototype._makeSurface=function(t,e){var r=new Hf;r.compute(t.volMap,this.origin,e.isoValue,1),r.vertexFusion(9,9),r._numTriangles>0&&(r.setColorVolTex(t.volTexMap,t.atomMap,t.atomWeightMap,this._visibilitySelector),this.setIndex(new zi(r._indices,1)),this.addAttribute("position",new zi(r._position,3)),this.addAttribute("normal",new zi(r._normals,3)),this.addAttribute("color",new zi(r._colors,3)))},Wf.prototype._calcSurface=function(t){var e={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};if(0!==e.posRad.length){var r=this._findNumVoxels(e.posRad,t),n=new gn(this.origin,new He(this.xAxis.x,this.yAxis.y,this.zAxis.z).add(this.origin)),i=this._computeSurface(e,n,r,t);this._makeSurface(i,t)}};var Xf=_d.Volume;function Yf(t,e){Wf.call(this,t,e)}function qf(t,e,r,n){var i,o,a,s,l,c,u,h,p,d,f,m,g,v,y,_,x,b=4,w=t.posRad,S=t.colors,M=t.atoms,A=w.length/b,E=e.bbox,C=E.minPosRad,T=E.maxPosRad,P=-1,L=null,R=null,N=null,I=new He(0,0,0),O=new He(0,0,0),D=new He(0,0,0);function z(){a=r.probeRadius,s=r.scaleFactor,l=r.probePositions,N=r.visibilitySelector,i=Iu.allocateTyped(Float32Array,A),o=0;for(var t=0;to&&(o=n),i[t]=n*n}!function(){s=r.scaleFactor,c=e.dim,x=Math.min(5,2+Math.floor(a*s));var t=c[0]*c[1]*c[2];u=function(t,e,r){for(var n=Iu.allocateTyped(t,e),i=0;iP&&(P=N)}this.neighbourListLength=27*P+1,this.withinRadii=function(e,r,n,i,l){var c=0,u=h(e,o),f=h(r,a),m=h(n,s),g=Math.max(0,u-1),x=Math.max(0,f-1),w=Math.max(0,m-1),S=Math.min(v-1,u+1),T=Math.min(y-1,f+1),P=Math.min(_-1,m+1);for(p=g;p<=S;++p){var L=p*b;for(M=x;M<=T;++M)for(var R=M*_,N=w;N<=P;++N)for(var I=A[d=L+R+N],O=I+E[d],D=I;D=0;){if(o!==n&&o!==i&&B(o,t,e,r))return P=o,o;o=_[++a]}return P=-1,-1}function B(t,e,r,n){var o=b*t,a=i[t],s=w[o]-e,l=w[o+1]-r,c=w[o+2]-n;return s*s+l*l+c*c0&&ML[$]&&(L[$]=J,R[$]=M[t]),u[$]<0&&(u[$]=-u[$]);var et=Math.sqrt(Q),rt=a/et,nt=K*rt,it=X*rt,ot=G*rt;if(-1===k(nt+=r,it+=n,ot+=o,t,-1)){var at=a-et;at=0;)t0){r=1/r;var n=3*t;h[n]*=r,h[n+1]*=r,h[n+2]*=r}}}()}this.build=function(){V(),this.volTexMap=h,this.weightsMap=L,this.atomMap=R,this.volMap=u}}Yf.prototype=Object.create(Wf.prototype),Yf.prototype.constructor=Yf,Yf.prototype._computeSurface=function(t,e,r,n){this._shiftByOrigin(t.posRad);var i={volMap:new Xf(Float32Array,this.numVoxels,e),volTexMap:new Xf(Float32Array,this.numVoxels,e,3)};return null!=this._visibilitySelector&&(i.atomMap=[],i.atomWeightMap=new Xf(Float32Array,this.numVoxels,e)),this.gaussdensity(i,t,null,n),i},Yf.prototype.gaussdensity=function(t,e,r,n){var i,o=e.posRad.length/4,a=e.posRad,s=e.colors,l=this.numVoxels,c=n.radScale,u=n.gaussLim,h=n.gridSpacing,p=1/n.isoValue,d=1/h,f=l[0]-1,m=l[1]-1,g=l[2]-1,v=t.volMap,y=t.volTexMap,_=v.getData(),x=v.getStrideX(),b=y.getData(),w=y.getStrideX();null!=this._visibilitySelector&&(i=t.atomWeightMap.getData());for(var S=t.atomMap,M=0;M=L))for(var G=v.getDirectIdx(N,V,B),H=y.getDirectIdx(N,V,B),W=N*h-a[A],X=N;X<=I;++X,W+=h,G+=x,H+=w){var Y=-(W*W+j)*T,q=Math.exp(Y)*C;null!=this._visibilitySelector&&q>i[G]&&(i[G]=q,S[G]=e.atoms[M]),_[G]+=q,q*=p;var Z=3*M;b[H]+=q*s[Z],b[H+1]+=q*s[Z+1],b[H+2]+=q*s[Z+2]}}}},Yf.prototype._shiftByOrigin=function(t){for(var e=this.origin.x,r=this.origin.y,n=this.origin.z,i=t.length/4,o=0;oc?e:c,u+=e;var h=Math.floor(s/c);h<2&&(h=2),u/=r,this._numCells=h,this._aveRad=u,this._maxRad=c;var p=h,d=h*h,f=h*h*h,m=this._xScale=1/(this._vBoxMax.x-this._vBoxMin.x),g=this._yScale=1/(this._vBoxMax.y-this._vBoxMin.y),v=this._zScale=1/(this._vBoxMax.z-this._vBoxMin.z),y=0,_=m*h,x=g*h,b=v*h;for(l=0;l=0?C:0,T=T>=0?T:0,P=P>=0?P:0,L=L=0;s=this._atomsList[2*s+1]){e(a[this._atomsList[2*s]])}},Qf.prototype.getClosestAtom=function(t){var e=null,r=Number.MAX_VALUE;return this.forEachRelatedAtom(t,function(n){var i=t.distanceToSquared(n.coord);im)){var v=t.radius+i._probeRadius;(p=n-v*v)<0&&(p=-p),d=Math.exp(g*p),c+=e*d,u+=r*d,h+=f*d,o++}},y=0;y0&&(p=1/Math.sqrt(n),c*=p,u*=p,h*=p),r[y].x=c,r[y].y=u,r[y].z=h;return 0},Qf.prototype.buildColors=function(t,e,r,n){for(var i=this,o=0,a=0,s=0,l=0,c=0,u=n*n,h=[],p=[],d=0,f=function(t){var e=o-t.coord.x,r=a-t.coord.y,n=s-t.coord.z,f=e*e+r*r+n*n;if(!(f>u)){var m=t.radius+i._probeRadius;(l=f-m*m)<0&&(l=-l),c=1/(.8+l),h.push([t.colorX,t.colorY,t.colorZ]),p.push(c),d+=c}},m=0;m=0&&!(this.voxelsRefs[2*o+1]<0);)o=this.voxelsRefs[2*o+1];this.voxelsRefs[2*o+1]=r}}for(var x=0,b=0;b=0;)E+=(a=this.atoms[o]).coord.x,C+=a.coord.y,T+=a.coord.z,P++,o=this.voxelsRefs[2*o+1];for(E*=1/P,C*=1/P,T*=1/P,r=0;r<8;r++)p[r]=0;var L=0;for(o=this.voxels[i];o>=0;){var R=(a=this.atoms[o]).coord.x-E,N=a.coord.y-C,I=a.coord.z-T,O=Math.sqrt(R*R+N*N+I*I)+a.radius;O>L&&(L=O),h=e.getIndex(t,this.atoms[o]),p[h&=7]++,o=this.voxelsRefs[2*o+1]}var D=0;for(r=1;r<8;r++)p[r]>p[D]&&(D=r);var z=new Or(e.getAtomColor(t,this.atoms[D]));if(0===this.colorMode&&(l=this.atomColors[D].x,c=this.atomColors[D].y,u=this.atomColors[D].z),1===this.colorMode){var F=this.complex.monomerTypeArray[h].color;l=F.r,c=F.g,u=F.b}1!==this.colorMode&&0!==this.colorMode&&(l=this.atomColors[D].x,c=this.atomColors[D].y,u=this.atomColors[D].z),z.set(E,C,T),s[x]=new Kf(z,L),s[x].colorX=l,s[x].colorY=c,s[x].colorZ=u,x++}return this.voxelsRefs=null,this.voxels=null,s},tm.prototype.destroy=function(){this._vertices=null,this._normals=null,this._indices=null};var em=_d.Element;function rm(t,e){Bf.call(this,t,e)}function nm(t,e){du.call(this),this._opts=e,this.items=[],this.needsUpdate=!1;var r=-50,n=-50;switch(e.horizontalAlign){case"left":r=0;break;case"right":r=-100}switch(e.verticalAlign){case"top":n=-100;break;case"bottom":n=0}var i=new He(e.dx||0,e.dy||0,e.dz||0);this.userData={translation:"translate("+r+"%, "+n+"%)",offset:i}}rm.prototype=Object.create(Bf.prototype),rm.prototype.constructor=rm,rm.prototype._build=function(){this._innerBuild();var t=this.getGeo();this.destroy(),this._fromGeo(t)},rm.prototype._fromGeo=function(t){var e=null,r=Iu.allocateTyped(Float32Array,3*t._numVertices),n=Iu.allocateTyped(Float32Array,3*t._numVertices);null!==t._colors&&(e=Iu.allocateTyped(Float32Array,3*t._numVertices));var i,o=Iu.allocateTyped(Uint32Array,3*t._numTriangles),a=0;for(i=0;ii?l:i,s.x-lr.x&&(r.x=s.x+l),s.y+l>r.y&&(r.y=s.y+l),s.z+l>r.z&&(r.z=s.z+l)}e.x-=i,e.y-=i,e.z-=i,r.x+=i,r.y+=i,r.z+=i},rm.prototype.getCornerCoord=function(t,e,r,n,i,o,a){var s=1/(o-1),l=r*s,c=n*s,u=i*s;a.x=t.x*(1-l)+e.x*l,a.y=t.y*(1-c)+e.y*c,a.z=t.z*(1-u)+e.z*u},rm.prototype.buildEdgePoint=function(t,e,r,n,i,o){if(r[t]^r[e]){var a=(0-n.pointsValuesLinear[i+24+t])/(n.pointsValuesLinear[i+24+e]-n.pointsValuesLinear[i+24+t]),s=n.pointsValuesLinear[i+3*t+0],l=n.pointsValuesLinear[i+3*t+1],c=n.pointsValuesLinear[i+3*t+2],u=n.pointsValuesLinear[i+3*e+0],h=n.pointsValuesLinear[i+3*e+1],p=n.pointsValuesLinear[i+3*e+2];o.x=s*(1-a)+u*a,o.y=l*(1-a)+h*a,o.z=c*(1-a)+p*a}},rm.prototype.isTriangleVisible=function(t,e,r){var n=this.voxelWorld.getClosestAtom(t),i=this.voxelWorld.getClosestAtom(e),o=this.voxelWorld.getClosestAtom(r);return null!==n&&null!==i&&null!==o&&null!==n.srcAtom&&null!==i.srcAtom&&null!==o.srcAtom&&(this.visibilitySelector.includesAtom(n.srcAtom)&&this.visibilitySelector.includesAtom(i.srcAtom)&&this.visibilitySelector.includesAtom(o.srcAtom))},rm.prototype.addTriangle=function(t,e,r){if(this.visibilitySelector&&!this.isTriangleVisible(t,e,r))return!0;var n=this.geoOut;if(n._numTriangles>=this.maxNumTriangles)return!1;var i=this.addVertexToGeo(n,t),o=this.addVertexToGeo(n,e),a=this.addVertexToGeo(n,r);if((i|o|a)<0)return!1;var s=3*n._numTriangles;return n._indices[s+0]=i,n._indices[s+1]=o,n._indices[s+2]=a,n._numTriangles++,!0},rm.prototype.buildGeoFromCorners=function(t,e,r,n,i,o){var a,s,l=t-1,c=t,u=t*t,h=new Array(12);for(a=0;a<12;a++)h[a]=new He;var p=[];for(a=0;a<8;a++)p[a]=1;for(var d=new He,f=0,m=0,g=0;ge.length/2||2*Object.keys(em.ByAtomicNumber).length!==e.length)throw new Error("atomT.length should be equal Element.ByAtomicNumber.length * 2");return e[2*t]},rm.prototype.calculateGridCorners=function(t,e,r,n,i,o){for(var a=e*e,s=a*e,l=new He,c=new He,u=0;u=0;r=this.hashEntries[2*r+1]){var c=this.hashEntries[2*r+0];if(i.copy(t._vertices[c]),i.x-=e.x,i.y-=e.y,i.z-=e.z,i.x*i.x+i.y*i.y+i.z*i.z<1e-6)return c}if(t._numVertices>=this.maxNumVertices)return-1;var u=t._numVertices;if(t._vertices[u].copy(e),null!==this.vBoxMin&&null!==this.vBoxMax){if((r=this.getNewHashEntry())<0)return-1;var h=this.hashLines[l+1];this.hashLines[l+1]=r,this.hashEntries[2*r+0]=u,this.hashEntries[2*r+1]=h,this.hashLines[l+0]++}return t._numVertices++,u},rm.prototype.modifyExcludedFromGeo=function(t,e,r,n,i,o){var a,s,l;for(var c=t*t,u=(t-1)/(n.x-r.x),h=(t-1)/(n.y-r.y),p=(t-1)/(n.z-r.z),d=2*e*(2*e),f=1/(t-1),m=0;m=0?y:0,_=_>=0?_:0,x=x>=0?x:0,b=b<=t-1?b:t-1,w=w<=t-1?w:t-1,S=S<=t-1?S:t-1;for(var M=_;M<=w;M++)for(var A=M*c,E=x;E<=S;E++)for(var C=E*t,T=y;T<=b;T++){a=A+C+T;var P=T*f,L=r.x*(1-P)+n.x*P;P=M*f;var R=r.y*(1-P)+n.y*P;P=E*f;var N=r.z*(1-P)+n.z*P,I=L-g.x,O=R-g.y,D=N-g.z,z=I*I+O*O+D*D;z0?(o[a]<0&&(o[a]=l),l>o[a]&&(o[a]=l)):l>o[a]&&(o[a]=l))}}return 0},rm.prototype._innerBuild=function(){var t,e={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};this.complex=this._opts.parent,this.atoms=e.atoms,this.meshResolution=this._opts.gridSpacing,this.atomRadiusScale=this._opts.radScale,this.colorMode=this._opts.colorMode,this.probeRadius=this._opts.probeRadius,this.useVertexColors=!0,this.excludeProbe=this._opts.excludeProbe,this.visibilitySelector=this._opts.visibilitySelector,this.clusterizationType=this._opts.clusterizationType,this.geoOut=null,this.hashLines=null,this.hashEntries=null,this.numHashEtriesAllocated=0,this.numHashEntryIndex=0,this.maxNumVertices=0,this.maxNumTriangles=0;var r=new Array(this.atoms.length);this.convertToAtomsColored(e,r);var n=this.vBoxMin=new He,i=this.vBoxMax=new He;this.getBoundingBox(r,n,i);var o=this.marCubeResoultion=4*this.meshResolution,a=o,s=a*a*a,l=Iu.allocateTyped(Float32Array,s),c=this.meshResolution,u=4,h=this.atoms.length;h>=100&&(u=Math.floor(Math.pow(2*h,1/3))),c>u&&(c=u);var p=this.probeRadius*this.atomRadiusScale,d=null,f=null;this.clusterizationType>0?(d=new Jf(this.complex,this.atoms,r,n,i,c,this.colorMode),f=1===this.clusterizationType?d.buildKMeans():d.buildSimple(),n.x-=3.5,n.y-=3.5,n.z-=3.5,i.x+=3.5,i.y+=3.5,i.z+=3.5,this.calculateGridCorners(l,a,n,i,f,p)):this.calculateGridCorners(l,a,n,i,r,p);var m=o-1,g=new Uf;if((t=g.create(m))<0)return t;var v=new He;v.x=(i.x-n.x)/m,v.y=(i.y-n.y)/m,v.z=(i.z-n.z)/m;var y=this.getNumIntersectedCells(a,m,l,g),_=Math.floor(1.2*y),x=Math.floor(1.2*y*2);if(this.geoOut=new tm(_,x,this.useVertexColors),(t=this.createVertexHash(_,x))<0)return t;var b=p;if(this.excludeProbe&&(b=.01),this.voxelWorld=null,this.clusterizationType>0?this.voxelWorld=new Qf(f.length,f,n,i,b):this.voxelWorld=new Qf(r.length,r,n,i,b),this.voxelWorld.createVoxels(),t=this.buildGeoFromCorners(o,n,i,l,v,g),this.excludeProbe){if(this.modifyExcludedFromGeo(a,p,n,i,this.geoOut,l),this.geoOut._vertices=null,this.geoOut._colors=null,this.geoOut._indices=null,this.geoOut._normals=null,this.geoOut._numVertices=0,this.geoOut._numTriangles=0,this.geoOut=null,y=this.getNumIntersectedCells(a,m,l,g),_=Math.floor(1.2*y),x=Math.floor(1.2*y*2),this.geoOut=new tm(_,x,this.useVertexColors),(t=this.createVertexHash(_,x))<0)return t;t=this.buildGeoFromCorners(a,n,i,l,v,g)}if(null!==this.voxelWorld){this.voxelWorld.buildNormals(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._normals);var w=6.5;this.excludeProbe&&(w-=1.5),this.useVertexColors&&this.voxelWorld.buildColors(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._colors,w)}return this.voxelWorld.destroyVoxels(),this.voxelWorld=null,null!==d&&d.destroy(),g.destroy(),t},nm.prototype=Object.create(du.prototype),nm.prototype.constructor=nm,nm.prototype.setItem=function(t,e,r){var n=this._opts,i=n.labels,o=this.items[t]||function(t,e){var r=document.createElement("div");if(r.className=e,"string"==typeof t){var n=document.createElement("span");n.style.fontSize="150%";for(var i=t.split("\n"),o=0,a=i.length;o=0;--e)this.remove(t[e]);var r=this.geometry.items,i=this.geometry.userData,o=r.length;for(e=0;e0?n:[new We];for(var o=this._createMeshes(t),a=0,s=o.length;a>16&255,r=t>>8&255,n=255&t;return.2126*e+.7152*r+.0722*n>127?(e=3*e/10,r=3*r/10,n=3*n/10):(e=255-3*(255-e)/10,r=255-3*(255-r)/10,n=255-3*(255-n)/10),e<<16|r<<8|n},inverse:function(t){return 255-(t>>16&255)<<16|255-(t>>8&255)<<8|255-(255&t)}};function Pm(t,e){var r;if(Tm.hasOwnProperty(e))r=Iu.hexColor(Tm[e](t));else{var n=parseInt(e,16);r=!Number.isNaN(n)&&e.toLowerCase().startsWith("0x")?Iu.hexColor(n):"#000000"}return r}var Lm={serial:function(t){return t.getSerial()},name:function(t){return t.getVisualName()},elem:function(t){return t.element.name},residue:function(t){return t._residue.getType().getName()},sequence:function(t){return t._residue.getSequence()},chain:function(t){return t._residue.getChain().getName()},hetatm:function(t){return t.isHet()},water:function(t){return"HOH"===t._residue.getType().getName()||"WAT"===t._residue.getType().getName()}},Rm=function(t,e){return e.replace(/\{\{(\s*\w+\s*)\}\}/g,function(e){var r=e.replace(/\s+/g,"");return r=r.substring(2,r.length-2).toLowerCase(),Lm.hasOwnProperty(r)?Lm[r](t):"null"})};function Nm(t,e,r,n,i,o,a){this._geoArgs=this._makeGeoArgs(e,n,r,o),Sm.call(this,t,e,r,n,i,o,a)}function Im(t,e,r,n){var i=Math.sin(t);return e.clone().multiplyScalar(Math.sin((1-n)*t)/i).addScaledVector(r,Math.sin(n*t)/i)}function Om(t,e,r,n,i,o,a){Sm.call(this,t,e,r,n,i,o,a)}Nm.prototype=Object.create(Sm.prototype),Nm.prototype.constructor=Nm,Nm.prototype._makeGeoArgs=function(t,e,r,n){var i=e.getLabelOpts();return[t.chunks.length,i]},Nm.prototype._build=function(){for(var t=this._mode.getLabelOpts(),e=this._selection.chunks,r=this._selection.atoms,n=this._selection.parent,i=this._colorer,o=this._geo,a=0,s=e.length;ae-1&&(t=r-t),t},t=function(){function t(t,e){if(this.array=t.slice(0),this.length=this.array.length,!(this.clipHelper={clamp:this.clipHelperClamp,zero:this.clipHelperZero,periodic:this.clipHelperPeriodic,mirror:this.clipHelperMirror}[e.clip]))throw"Invalid clip: "+e.clip}return t.prototype.getClippedInput=function(t){return 0<=t&&t=o;i<=o?r++:r--)n+=this.kernel(t-r)*this.getClippedInput(r);return n},r}(),f=function(t,e){var r,n,i,o;for(o=[],n=0,i=t.length;na;0<=a?c++:c--)e.push(new h(f(t,c),r));return e}(),function(t){var e,r,n,i;for(i=[],r=0,n=m.length;ri&&t[e-1]._isValid?e-1:e}function s(e){return e1&&0!==E&&(c.lerpVectors(y,_,.15/w),u.lerpVectors(y,_,1-.15/w)),E*=.15,c.addScaledVector(S,E),u.addScaledVector(S,E),o.setItem(h,c,u),o.setColor(h++,i.getAtomColor(g,r),i.getAtomColor(v,r))}}o.finalize(),this._chunksIdc=p},Om.prototype.updateToFrame=function(t){for(var e=this._selection.chunks,r=this._selection.bonds,n=this._mode,i=this._colorer,o=this._geo,a=n.drawMultiorderBonds(),s=n.showAromaticLoops(),l=new He,c=new He,u=new He,h=0,p=t.needsColorUpdate(i),f=0,d=e.length;f1&&0!==E&&(c.lerpVectors(y,_,.15/w),u.lerpVectors(y,_,1-.15/w)),E*=.15,c.addScaledVector(S,E),u.addScaledVector(S,E),o.setItem(h,c,u),p&&o.setColor(h,t.getAtomColor(i,g),t.getAtomColor(i,v)),h++}}o.finalize()};var Dm=im,Fm=om,zm=am,km=pm,Um=gm,Bm=vm,Vm=xm,jm=bm,Gm=Lm,Wm=Rm,Hm=Im,Xm=Om;function Ym(t,e,r,n,i,o,a,s){var l=this;ef.call(l),this._complex=r;var c=r.getAtoms(),u=r.getTransforms();r.forEachComponent(function(h){var p=[],f=0;if(h.forEachAtom(function(t){l._checkAtom(t,a)&&(p[f++]=t._index)}),0!==f){var d=new t(e,{atoms:c,chunks:p,parent:r},n,i,u,o,s);d._component=h,l.add(d)}})}function qm(t,e,r,n,i,o,a,s){this._mode=i,Ym.call(this,t,e,r,n,i,o,a,s)}function Zm(t,e,r,n,i,o,a,s){var l=this;ef.call(l),this._complex=r;var c=r.getResidues(),u=r.getTransforms();r.forEachComponent(function(h){var p=0,f=[];if(h.forEachResidue(function(t){l._checkResidue(t,a)&&(f[p++]=t._index)}),0!==p){var d=new t(e,{residues:c,chunks:f,parent:r},n,i,u,o,s);d._component=h,l.add(d)}})}function $m(t,e,r,n,i,o,a,s){Zm.call(this,t,e,r,n,i,o,a,s)}function Km(t,e,r,n,i,o,a,s){var l=this;ef.call(l),this._complex=r;var c=r.getResidues(),u=r.getTransforms();r.forEachComponent(function(h){for(var p=h.getMaskedSubdivSequences(a),f=0,d=[],m=0,g=p.length;m0&&(d[m++]=t)});var g=new t(e,{cycles:d,atoms:c,chunks:p,parent:r},n,i,u,o,s);g._component=h,l.add(g)})}function tg(t,e,r){var n=document.createElement("div");if(n.className="label label-sgroup",n.style.color=e,"string"==typeof r){var i=document.createElement("span");i.style.fontSize="150%";var o=document.createElement("span"),a=document.createTextNode(r);o.appendChild(a),i.appendChild(o),n.appendChild(i)}else n.appendChild(r);var s=new tf(n);s.position.copy(t),s.userData={translation:"translate(-50%, -50%)",color:e};var l=s.getElement();return l.style.visibility="visible",l.style.textAlign="center",l.style.verticalAlign="middle",s}function eg(t,e,r,n,i,o,a,s){ef.call(this);for(var l=new ef,c=0;c0&&l.add(p)}return l},pg.prototype=Object.create(hg.prototype),pg.prototype.constructor=pg,pg.prototype.update=function(){var t=this._staticGroups;"no"===this.settings.now.labels?this.depGroups=this.depGroups.slice(0,t):(this.depGroups[t]="TextLabelsGeo",this.depGroups[t+1]="SGroupsLabels")},pg.prototype.buildGeometry=function(t,e,r,n){return this.update(),hg.prototype.buildGeometry.call(this,t,e,r,n)},Cu.deriveClass(dg,pg,{id:"LN",name:"Lines",shortName:"Lines",depGroups:["ALoopsLines","BondsLines","OrphanedAtomsCrosses"]}),dg.prototype.drawMultiorderBonds=function(){return this.opts.multibond},dg.prototype.calcAtomRadius=function(){return this.opts.atom},dg.prototype.getAromaticOffset=function(){return this.opts.offsarom},dg.prototype.getAromaticArcChunks=function(){return this.opts.chunkarom},dg.prototype.showAromaticLoops=function(){return this.opts.showarom},dg.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!0,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},Cu.deriveClass(mg,pg,{id:"LC",name:"Licorice",shortName:"Licorice",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),mg.prototype.calcAtomRadius=function(t){return this.opts.bond},mg.prototype.calcStickRadius=function(){return this.opts.bond},mg.prototype.calcSpaceFraction=function(){return this.opts.space},mg.prototype.getAromRadius=function(){return this.opts.aromrad},mg.prototype.showAromaticLoops=function(){return this.opts.showarom},mg.prototype.drawMultiorderBonds=function(){return this.opts.multibond},mg.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},Cu.deriveClass(gg,pg,{id:"BS",name:"Balls and Sticks",shortName:"Balls",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),gg.prototype.calcAtomRadius=function(t){return t.element.radius*this.opts.atom},gg.prototype.calcStickRadius=function(){return this.opts.bond},gg.prototype.getAromRadius=function(){return this.opts.aromrad},gg.prototype.showAromaticLoops=function(){return this.opts.showarom},gg.prototype.calcSpaceFraction=function(){return this.opts.space},gg.prototype.drawMultiorderBonds=function(){return this.opts.multibond},gg.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},Cu.deriveClass(vg,hg,{id:"VW",name:"Van der Waals",shortName:"VDW",depGroups:["AtomsSpheres"]}),vg.prototype.calcAtomRadius=function(t){return t.element.radius},Cu.deriveClass(yg,hg,{id:"TR",name:"Trace",shortName:"Trace",depGroups:["TraceChains"]}),yg.prototype.calcStickRadius=function(){return this.opts.radius},Cu.deriveClass(_g,hg,{id:"TU",name:"Tube",shortName:"Tube",depGroups:["CartoonChains"]}),_g.prototype.getResidueRadius=function(t){return this.TUBE_RADIUS},_g.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},_g.prototype.getTension=function(){return this.opts.tension},_g.prototype.buildGeometry=function(t,e,r,n){var i=this.opts.radius;return this.TUBE_RADIUS=new _e(i,i),hg.prototype.buildGeometry.call(this,t,e,r,n)},Cu.deriveClass(xg,hg,{id:"CA",name:"Cartoon",shortName:"Cartoon",depGroups:["CartoonChains","NucleicSpheres","NucleicCylinders"]}),xg.prototype.getResidueStartRadius=function(t){var e=t.getSecondary();if(!e||!e.type)return this.TUBE_RADIUS;var r=this.secCache[e.type];return r?e._end===t?r.start:r.center:this.TUBE_RADIUS},xg.prototype.getResidueEndRadius=function(t){var e=t.getSecondary();if(null===e||!e.type)return this.TUBE_RADIUS;var r=this.secCache[e.type];return r?e._end===t?this.ARROW_END:r.center:this.TUBE_RADIUS},xg.prototype.getResidueRadius=function(t,e){var r=this.getResidueStartRadius(t);if(0===e)return r;var n=this.getResidueEndRadius(t);return 2===e?n:r.clone().lerp(n,e/2)},xg.prototype.calcStickRadius=function(t){return this.opts.radius},xg.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},xg.prototype.getTension=function(){return this.opts.tension},xg.prototype.buildGeometry=function(t,e,r,n){var i=this.opts.radius,o=this.opts.depth;this.TUBE_RADIUS=new _e(i,i),this.ARROW_END=new _e(o,i);var a={},s=this.opts.ss;for(var l in s)a[l]={center:new _e(o,s[l].width),start:new _e(o,s[l].arrow)};return this.secCache=a,hg.prototype.buildGeometry.call(this,t,e,r,n)};var bg=Jp.selectors;function wg(){return{wireframe:this.opts.wireframe,zClip:this.opts.zClip}}function Sg(t){hg.call(this,t),this.depGroups=this.depGroups.slice(0);for(var e=this.surfaceNames,r=this.depGroups,n=0,i=e.length;n=256?e-256:e))%this.chainColors.length,this.chainColors[e]},getSecondaryColor:function(t,e){var r=this.secondaryColors[t];return r instanceof Object&&(r=r[e]),void 0===r?this.defaultSecondaryColor:r},getSequentialColor:function(t){var e=this.colors,r=e.length;return t<0?e[t%r+r]:e[t%r]},getGradientColor:function(t,e){var r,n,i,o,a=this.gradients[e];if(a){var s=a.length,l=t*(s-1),c=Math.floor(l),u=Ig(c+1,0,s-1);return c=Ig(c,0,s-1),r=a[c],n=a[u],(o=1-(i=l-c))*(r>>16&255)+i*(n>>16&255)<<16|o*(r>>8&255)+i*(n>>8&255)<<8|o*(255&r)+i*(255&n)}return this.defaultNamedColor},getNamedColor:function(t,e){var r=this.namedColors[t];return void 0!==r||e?r:this.defaultNamedColor}};for(var Dg=Og.prototype.namedColorsArray,Fg=Og.prototype.namedColors,zg=0,kg=Dg.length;zg=0?this.opts.carbon:this.palette.getElementColor(r)},$g.prototype.getResidueColor=function(t,e){return this.palette.defaultResidueColor},Cu.deriveClass(Kg,Zg,{id:"RT",name:"Residue Type",shortName:"Residue"}),Kg.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Kg.prototype.getResidueColor=function(t,e){return this.palette.getResidueColor(t._type._name)},Cu.deriveClass(Qg,Zg,{id:"SQ",aliases:["RI"],name:"Sequence",shortName:"Sequence"}),Qg.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Qg.prototype.getResidueColor=function(t,e){var r=t._chain;if(r.minSequence===Number.POSITIVE_INFINITY&&r.maxSequence===Number.NEGATIVE_INFINITY)return this.palette.defaultNamedColor;var n=r.minSequence,i=r.maxSequence>n?r.maxSequence:n+1;return this.palette.getGradientColor((t._sequence-n)/(i-n),this.opts.gradient)},Cu.deriveClass(Jg,Zg,{id:"CH",name:"Chain",shortName:"Chain"}),Jg.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Jg.prototype.getResidueColor=function(t,e){return this.palette.getChainColor(t.getChain()._name)},Cu.deriveClass(tv,Zg,{id:"SS",name:"Secondary Structure",shortName:"Structure"}),tv.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},tv.prototype.getResidueColor=function(t,e){if(t._type.flags&_h.Flags.DNA)return this.palette.getSecondaryColor("dna");if(t._type.flags&_h.Flags.RNA)return this.palette.getSecondaryColor("rna");var r=t.getSecondary();return r?this.palette.getSecondaryColor(r.type,r._type):this.palette.getSecondaryColor("")},Cu.deriveClass(ev,Zg,{id:"UN",name:"Uniform",shortName:"Uniform"}),ev.prototype.getAtomColor=function(t,e){return this.opts.color},ev.prototype.getResidueColor=function(t,e){return this.opts.color},Cu.deriveClass(rv,Zg,{id:"CO",name:"Conditional",shortName:"Conditional"}),rv.prototype.getAtomColor=function(t,e){return this._subsetCached.includesAtom(t)?this.opts.color:this.opts.baseColor},rv.prototype.getResidueColor=function(t,e){for(var r=this._subsetCached,n=!0,i=t._atoms,o=0,a=i.length;or.max?1:0:(t._temperature-r.min)/(r.max-r.min),this.palette.getGradientColor(n,r.gradient)):this.palette.defaultElementColor},iv.prototype.getResidueColor=function(t,e){var r=this.opts;if(!r)return this.palette.defaultResidueColor;var n=-1;if(t.forEachAtom(function(t){t._temperature&&t._role===Jp.Element.Constants.Lead&&(n=t._temperature)}),n>0){var i=0;return i=r.min===r.max?n>r.max?1:0:(n-r.min)/(r.max-r.min),this.palette.getGradientColor(i,r.gradient)}return this.palette.defaultResidueColor},Cu.deriveClass(ov,Zg,{id:"OC",name:"Occupancy",shortName:"Occupancy"}),ov.prototype.getAtomColor=function(t,e){var r=this.opts;if(t._occupancy&&r){var n=1-t._occupancy;return this.palette.getGradientColor(n,r.gradient)}return this.palette.defaultElementColor},ov.prototype.getResidueColor=function(t,e){var r=this.opts;if(!r)return this.palette.defaultResidueColor;var n=-1;if(t.forEachAtom(function(t){t._occupancy&&t._role===Jp.Element.Constants.Lead&&(n=t._occupancy)}),n>0){var i=1-n;return this.palette.getGradientColor(i,r.gradient)}return this.palette.defaultResidueColor},Cu.deriveClass(av,Zg,{id:"HY",name:"Hydrophobicity",shortName:"Hydrophobicity"}),av.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},av.prototype.getResidueColor=function(t,e){var r=this.palette.defaultResidueColor;if(t._type.hydrophobicity){r=this.palette.getGradientColor((t._type.hydrophobicity- -4.5)/9,this.opts.gradient)}return r},Cu.deriveClass(sv,Zg,{id:"MO",name:"Molecule",shortName:"Molecule"}),sv.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},sv.prototype.getResidueColor=function(t,e){var r=t._molecule,n=e.getMoleculeCount();return n>1?this.palette.getGradientColor((r._index-1)/(n-1),this.opts.gradient):this.palette.getGradientColor(0,this.opts.gradient)};var lv=[],cv={};!function(t){for(var e=0,r=t.length;e0){(e=new ea).matrixAutoUpdate=!1,e.matrix=this.geo.matrix;for(var n=0;n2)return hu.error("Can only edit fragments with one or two bound atoms."),!1;this._fragmentBoundAtoms=r;var n=1<0?this._reprList[0]:null,this._selectionBit=t.length,this._reprUsedBits|=1<=0&&tthis._reprList.length)return hu.error("Rep "+t+" does not exist!"),null;t===this._reprList.length&&(this.repAdd(e),e=void 0,hu.warn("Rep "+t+" does not exist! New representation was created."));var r=this._reprList[t],i={selector:r.selectorString,mode:r.mode.identify(),colorer:r.colorer.identify(),material:r.materialPreset.id};if(e){var o=!1;if(e.selector){var a=wv.parse(e.selector).selector,s=String(a);i.selector!==s&&(r.selectorString=i.selector=s,r.selector=a,r.markAtoms(this._complex),o=!0,hu.debug("rep["+t+"].selector changed to"+s))}if(e.mode){var l=e.mode;n.isEqual(i.mode,l)||(i.mode=l,r.setMode(Ng.create(e.mode)),o=!0,hu.debug("rep["+t+"].mode changed to "+l),!r.mode.isSurface||"ultra"!==Vu.now.resolution&&"high"!==Vu.now.resolution||(hu.report('Surface resolution was changed to "medium" to avoid hang-ups.'),Vu.now.resolution="medium"))}if(e.colorer){var c=e.colorer;n.isEqual(i.colorer,c)||(i.colorer=c,r.colorer=uv.create(e.colorer),o=!0,hu.debug("rep["+t+"].colorer changed to "+c))}if(e.material){var u=e.material;n.isEqual(i.material,u)||(i.material=u,r.setMaterialPreset(gv.get(e.material)),o=!0,hu.debug("rep["+t+"].material changed to"+u))}o&&(r.needsRebuild=!0)}return i},Sv.prototype.repGet=function(t){return(void 0===t||t instanceof Object)&&(t=this.repCurrent()),t<0||t>=this._reprList.length?null:this._reprList[t]},Sv.prototype._getFreeReprIdx=function(){for(var t=this._reprUsedBits,e=0;e<=Sv.NUM_REPRESENTATION_BITS;++e,t>>=1)if(0==(1&t))return e;return-1},Sv.prototype.repAdd=function(t){if(this._reprList.length>=Sv.NUM_REPRESENTATION_BITS)return-1;var e=this._getFreeReprIdx();if(e<0)return-1;var r=this.buildSelectorFromMask(1<=e||e<=1)){var r=this._reprList[t];r.unmarkAtoms(this._complex),this._reprUsedBits&=~(1<=this._reprList.length)||this._reprList[t].show(!e)},Sv.prototype.select=function(t,e){e?this._selectionCount+=this._complex.markAtomsAdditionally(t,1<0&&(a=wv.chain(r),o=o?wv.or(o,a):a),Object.keys(e).length>0)for(var s in e)e.hasOwnProperty(s)&&(a=wv.and(wv.chain(s),wv.residx(i(e[s]))),o=o?wv.or(o,a):a);t.length>0&&(a=wv.serial(i(t)),o=o?wv.or(o,a):a),o||(o=wv.none())}return o},Sv.prototype.buildSelectorFromMask=function(t){var e=this._complex,r=[],n={},i=[];return e.forEachChain(function(e){e._mask&t&&r.push(e._name)}),e.forEachResidue(function(e){if(e._mask&t&&!(e._chain._mask&t)){var r=e._chain._name;r in n?n[r].push(e._index):n[r]=[e._index]}}),e.forEachAtom(function(e){e._mask&t&&!(e._residue._mask&t)&&i.push(e._serial)}),this._buildSelectorFromSortedLists(i,n,r)},Sv.prototype.getSelectedComponent=function(){var t=1<=0):n<8+y.indices.length&&(this.cullFlag[n]=!0);var w=this.geometry.getAttribute("position"),S=0;for(n=0;n=3&&(u+=3*(r.indices.length-2));var h=0,p=new Uint16Array(u);for(e=0;ee&&(n._prof.end(),n._prof.start(),++i),l>r||i===t?a(Math.max(i,0)):requestAnimationFrame(s)})})},Fv.prototype.mean=function(){return this._prof?this._prof.rawMean():0},Fv.prototype.min=function(){return this._prof?this._prof.min():0};var zv=function(){function t(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];Nu(this,t),this._list=[],this._byType={},r.forEach(function(t){return e.register(t)})}return Iu(t,[{key:"register",value:function(t){Su(this._list,t),Au(this._byType,t.types,t)}},{key:"unregister",value:function(t){Mu(this._list,t),Eu(this._byType,t.types,t)}},{key:"find",value:function(t){var e=[];if(t.type)e=this._byType[t.type.toLowerCase()]||[];else if(t.source)return this._list.filter(function(e){return e.canProbablyLoad&&e.canProbablyLoad(t.source)});return[].concat(zu(e))}},{key:"all",get:function(){return[].concat(zu(this._list))}},{key:"types",get:function(){return Object.keys(this._byType)}}]),t}(),kv=function(t){function e(t,r){Nu(this,e);var n=Du(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n._source=t,n._options=r||{},n._abort=!1,n._agent=null,n}return Ou(e,su),Iu(e,[{key:"load",value:function(t){return t?this._loadOLD(t):this._abort?Promise.reject(new Error("Loading aborted")):this.loadAsync()}},{key:"loadAsync",value:function(){return Promise.reject(new Error("Loading from this source is not implemented"))}},{key:"_loadOLD",value:function(t){return t.progress&&this.addEventListener("progress",function(e){e.lengthComputable&&e.total>0?t.progress(e.loaded/e.total):t.progress()}),this.load().then(function(e){t.ready(e)}).catch(function(e){t.error(e)})}},{key:"abort",value:function(){this._abort=!0,this._agent&&this._agent.abort()}}],[{key:"extractName",value:function(t){}}]),e}();yf(kv.prototype);var Uv=function(t){function e(t,r){Nu(this,e);var n=Du(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r));return r=n._options,n._binary=!0===r.binary,n}return Ou(e,kv),Iu(e,[{key:"loadAsync",value:function(){var t=this;return new Promise(function(e,r){var n=t._source,i=t._agent=new FileReader;i.addEventListener("load",function(){e(i.result)}),i.addEventListener("error",function(){r(i.error)}),i.addEventListener("abort",function(){r(new Error("Loading aborted"))}),i.addEventListener("progress",function(e){t.dispatchEvent(e)}),t._binary?i.readAsArrayBuffer(n):i.readAsText(n)})}}],[{key:"canLoad",value:function(t,e){var r=e.sourceType;return t instanceof File&&(!r||"file"===r)}},{key:"canProbablyLoad",value:function(t){return File&&t instanceof File||Blob&&t instanceof Blob}},{key:"extractName",value:function(t){return t&&t.name}}]),e}();Uv.types=["file","blob"];var Bv=/^(https?|ftp):\/\//i,Vv=function(t){function e(t,r){Nu(this,e);var n=Du(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r));return r=n._options,n._binary=!0===r.binary,n}return Ou(e,kv),Iu(e,[{key:"loadAsync",value:function(){var t=this;return new Promise(function(e,r){var n=t._source,i=t._agent=new XMLHttpRequest;i.addEventListener("load",function(){200===i.status?e(i.response):r(new Error("HTTP "+i.status+" while fetching "+n))}),i.addEventListener("error",function(){r(new Error("HTTP request failed"))}),i.addEventListener("abort",function(){r(new Error("Loading aborted"))}),i.addEventListener("progress",function(e){t.dispatchEvent(e)}),i.open("GET",n),t._binary?i.responseType="arraybuffer":i.responseType="text",i.send()})}}],[{key:"canLoad",value:function(t,e){var r=e.sourceType;return"string"==typeof t&&(!r||"url"===r)}},{key:"canProbablyLoad",value:function(t){return n.isString(t)&&Bv.test(t)}},{key:"extractName",value:function(t){if(t){var e=(t.indexOf("?")+1||t.lastIndexOf("#")+1||t.length+1)-1;return t.slice(t.lastIndexOf("/",e)+1,e)}}}]),e}();Vv.types=["url"];var jv=function(t){function e(t,r){return Nu(this,e),Du(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r))}return Ou(e,kv),Iu(e,[{key:"loadAsync",value:function(){return Promise.resolve(this._source)}}],[{key:"canLoad",value:function(t,e){return void 0!==t&&void 0!==e&&"immediate"===e.sourceType}},{key:"canProbablyLoad",value:function(t){return!1}}]),e}();jv.types=["immediate"];var Gv=new zv([Uv,Vv,jv]),Wv=function(){function t(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];Nu(this,t),this._list=[],this._byFormat={},this._byExt={},r.forEach(function(t){return e.register(t)})}return Iu(t,[{key:"register",value:function(t){Su(this._list,t),Au(this._byFormat,t.formats,t),Au(this._byExt,t.extensions,t)}},{key:"unregister",value:function(t){Mu(this._list,t),Eu(this._byFormat,t.formats,t),Eu(this._byExt,t.extensions,t)}},{key:"find",value:function(t){var e=[];return t.format?e=this._byFormat[t.format.toLowerCase()]||[]:t.ext&&(e=this._byExt[t.ext.toLowerCase()]||[]),0===e.length&&!t.format&&t.data?this._list.filter(function(e){return e.canProbablyParse&&e.canProbablyParse(t.data)}):[].concat(zu(e))}},{key:"all",get:function(){return[].concat(zu(this._list))}},{key:"formats",get:function(){return Object.keys(this._byFormat)}},{key:"extensions",get:function(){return Object.keys(this._byExt)}}]),t}(),Hv=function(){function t(e,r){Nu(this,t),this._data=e,this._options=r||{},this._abort=!1}return Iu(t,[{key:"parseSync",value:function(){throw new Error("Parsing this type of data is not implemented")}},{key:"parse",value:function(t){var e=this;return t?this._parseOLD(t):new Promise(function(t,r){setTimeout(function(){try{return e._abort?r(new Error("Parsing aborted")):t(e.parseSync())}catch(t){return r(t)}})})}},{key:"_parseOLD",value:function(t){return this.parse().then(function(e){t.ready(e)}).catch(function(e){t.error(e)})}},{key:"abort",value:function(){this._abort=!0}}],[{key:"checkDataTypeOptions",value:function(t,e,r){var n=t.fileType,i=t.fileName;return r=(r||"."+e).toLowerCase(),Boolean(n&&n.toLowerCase()===e.toLowerCase()||!n&&i&&i.toLowerCase().endsWith(r))}}]),t}();function Xv(){this.matrices=[],this._matrix=null,this._matrixIndex=-1}yf(Hv.prototype),Xv.prototype.id=290,Xv.prototype.parse=function(t){var e=this._matrix;if(" SMTRY"===t.readString(12,18)){var r=t.readCharCode(19)-49,n=t.readString(20,80).trim().split(/\s+/),i=parseInt(n[0],10);null!==this._matrix&&i===this._matrixIndex||(this._matrixIndex=i,this._matrix=e=new Xe,this.matrices[this.matrices.length]=e);var o=e.elements;o[r]=parseFloat(n[1]),o[r+4]=parseFloat(n[2]),o[r+8]=parseFloat(n[3]),o[r+12]=parseFloat(n[4])}};var Yv=Jp.Assembly;function qv(t){this._complex=t,this.assemblies=[],this._assembly=null,this._matrix=null,this._matrixIndex=-1}qv.prototype.id=350,qv.prototype.parse=function(t){var e=this._assembly,r=this._matrix;if(e&&" BIOMT"===t.readString(12,18)){var n=t.readCharCode(19)-49,i=t.readString(20,80).trim().split(/\s+/),o=parseInt(i[0],10);null!==this._matrix&&o===this._matrixIndex||(this._matrixIndex=o,this._matrix=r=new Xe,e.addMatrix(r));var a=r.elements;a[n]=parseFloat(i[1]),a[n+4]=parseFloat(i[2]),a[n+8]=parseFloat(i[3]),a[n+12]=parseFloat(i[4])}else if(e&&"CHAINS:"===t.readString(35,41))for(var s=t.readString(42,80).split(","),l=0,c=s.length;l0&&e.addChain(u)}else"BIOMOLECULE:"===t.readString(12,23)&&(this._matrix=null,this._matrixIndex=-1,this._assembly=e=new Yv(this._complex),this.assemblies.push(e))};var Zv=function(){function t(e){Nu(this,t),this._data=e,this._start=0,this._nextCR=-1,this._nextLF=-1,this._next=-1,this._end=e.length,this.next()}return Iu(t,[{key:"readLine",value:function(){return this._data.slice(this._start,this._next)}},{key:"readChar",value:function(t){return(t=this._start+t-1)=this._end}},{key:"next",value:function(){var t=this._next+1;this._start=tthis._nextCR&&(this._nextCR=(this._data.indexOf("\r",this._start)+1||this._end+1)-1),this._start>this._nextLF&&(this._nextLF=(this._data.indexOf("\n",this._start)+1||this._end+1)-1),this._next=this._nextCR+1e&&a.addBond(e,r,0,ey.BondType.UNKNOWN,!0),n&&n>e&&a.addBond(e,n,0,ey.BondType.UNKNOWN,!0),i&&i>e&&a.addBond(e,i,0,ey.BondType.UNKNOWN,!0),o&&o>e&&a.addBond(e,o,0,ey.BondType.UNKNOWN,!0)},ny.prototype._parseCOMPND=function(t){var e=t.readString(11,80),r=e.indexOf(":");if(this._compndCurrToken=r>0?e.substring(0,r).trim():this._compndCurrToken,"MOL_ID"===this._compndCurrToken)this._molecule={_index:"",_chains:[]},this._molecule._index=parseInt(e.substring(r+1,e.indexOf(";")),10),this._molecules.push(this._molecule);else if("MOLECULE"===this._compndCurrToken&&null!=this._molecule)this._molecule._name=e.substring(r+1,e.indexOf(";")).trim();else if("CHAIN"===this._compndCurrToken&&null!=this._molecule){var n=e.substring(r+1,80).trim(),i=n[n.length-1];";"!==i&&","!==i||(n=n.slice(0,-1));var o=(n=n.replace(/\s+/g,"")).split(",");this._molecule._chains=this._molecule._chains.concat(o)}};var oy={290:Xv,350:qv};ny.prototype._parseREMARK=function(t){var e=t.readInt(8,10),r=this._remarks[e];if(n.isUndefined(r)){var i=oy[e];n.isFunction(i)&&(this._remarks[e]=r=new i(this._complex))}n.isUndefined(r)||r.parse(t)},ny.prototype._parseHELIX=function(t){this._parseSTRUCTURE(t,[20,22,32,34],function(t){this._complex.addHelix(t)}.bind(this))},ny.prototype._parseSHEET=function(t){this._parseSTRUCTURE(t,[22,23,33,34],function(t){this._complex.addSheet(t)}.bind(this))},ny.prototype._parseSTRUCTURE=function(t,e,r){var n=t.readInt(8,10),i=t.readString(12,14).trim(),o=t.readString(41,70).trim(),a=t.readInt(72,76),s=t.readInt(39,40),l=t.readInt(15,16),c=t.readInt(42,45),u=t.readInt(57,60),h=t.readString(e[0],e[2]+1).charCodeAt(0),p=t.readString(e[2],e[2]+1).charCodeAt(0),f=t.readInt(e[1],e[1]+3),d=t.readString(e[1]+4,e[1]+4),m=0;d.length>0&&(m=d.charCodeAt(0));var g,v=t.readInt(e[3],e[3]+3),y=0;(d=t.readString(e[3]+4,e[3]+4)).length>0&&(y=d.charCodeAt(0));var _=this._sheet;if(83===t.readCharCode(1)){null!==_&&_.getName()!==i&&(_=null,this._sheet=null),null===_?(this._sheet=g=new Jv(i,l),r(g)):g=_;var x=new ty(g,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,v,y),s,c,u);g.addStrand(x)}else r(g=new Qv(n,i,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,v,y),s,o,a))},ny.prototype._parseHEADER=function(t){var e=this._complex.metadata;e.classification=t.readString(11,50).trim(),e.date=t.readString(51,59).trim();var r=t.readString(63,66).trim();e.id=r,r&&(this._complex.name=r)},ny.prototype._parseTITLE=function(t){var e=this._complex.metadata;e.title=e.title||[];var r=t.readInt(9,10)||1;e.title[r-1]=t.readString(11,80).trim()};var ay={HEADER:ny.prototype._parseHEADER,"TITLE ":ny.prototype._parseTITLE,"ATOM ":ny.prototype._parseATOM,HETATM:ny.prototype._parseATOM,ENDMDL:ny.prototype._parseENDMDL,CONECT:ny.prototype._parseCONECT,COMPND:ny.prototype._parseCOMPND,REMARK:ny.prototype._parseREMARK,"HELIX ":ny.prototype._parseHELIX,"SHEET ":ny.prototype._parseSHEET,"ATOM 1":ny.prototype._parseATOM,"ATOM 2":ny.prototype._parseATOM,"ATOM 3":ny.prototype._parseATOM,"ATOM 4":ny.prototype._parseATOM,"ATOM 5":ny.prototype._parseATOM,"ATOM 6":ny.prototype._parseATOM,"ATOM 7":ny.prototype._parseATOM,"ATOM 8":ny.prototype._parseATOM,"ATOM 9":ny.prototype._parseATOM};ny.prototype.parseSync=function(){for(var t=new Zv(this._data),e=this._complex=new $v;!t.end();){var r=t.readString(1,6),i=ay[r];n.isFunction(i)&&i.call(this,t),t.next()}if(this._finalize(),this._serialAtomMap=null,this._sheet=null,this._residue=null,this._chain=null,this._complex=null,0===e.getAtomCount())throw new Error("The data does not contain valid atoms");return e},ny.formats=["pdb"],ny.extensions=[".pdb",".ent"];var sy=Jp.Complex,ly=Jp.Element,cy=Jp.AtomName,uy=Jp.SGroup,hy=Jp.Bond,py={A:0,S:1,D:2,T:3};function fy(t,e){Hv.call(this,t,e),this._complex=null,this._sheet=null,this._residue=null,this._serialAtomMap=null,this._modelId=1,this._lastMolId=-1,this._readOnlyOneMolecule=!1,this._options.fileType="cml"}fy.prototype=Object.create(Hv.prototype),fy.prototype.constructor=fy,fy.canParse=function(t,e){if(!t)return!1;var r=new RegExp("^\\s*?\\<\\?xml"),n=new RegExp("^\\s*?\\]*\?>\s*<(?:cml|molecule)\b/i;fy.canProbablyParse=function(t){return n.isString(t)&&dy.test(t)},fy.prototype._rebuidBondIndexes=function(t,e){for(var r=t.length,n=0;n1&&a.splice(1,a.length-1),a.forEach(function(t){var e=function(t){var e,n=[];if(t.molecule&&t.molecule.atomArray&&t.molecule.atomArray.atom)Array.isArray(t.molecule.atomArray.atom)?n=t.molecule.atomArray.atom:n.push(t.molecule.atomArray.atom);else if(!t.molecule){var o={atomLabels:null,labelsCount:1};return o}t.molecule.molecule&&i._extractSGroups(t.molecule.molecule,n);for(var a=n.length,s=0;s1)c[u].order=p;else{var f=py[h];void 0!==f&&(c[u].order=f,"A"===h&&(c[u].type=hy.BondType.AROMATIC))}}a=n.length;for(var d=0;d0&&o.push(e)}),o},fy.prototype._packLabel=function(t,e){return(e<<16)+t},fy.prototype._unpackLabel=function(t){return{molId:t>>>16,compId:65535&t}},fy.prototype._breadWidthSearch=function(t,e){var r,n=new Array(t.length);for(r=0;r0;){o++;var s=-1;for(r=0;r0;){var l=i.shift();if(l)for(var c=0;c=0){var i=[Math.min(t,e),Math.max(t,e)];this._complex.addBond(i[0],i[1],r,n,!0)}},fy.prototype._fixBondsArray=function(){for(var t=this._serialAtomMap={},e=this._complex,r=e._atoms,n=0,i=r.length;n1){var n=new sy;return n.joinComplexes(t),n.originalCML=t[0].originalCML,n}return 1===t.length?t[0]:new sy},fy.formats=["cml"],fy.extensions=[".cml"];var my=r(function(t,e){(function(t){function e(t,e,r){for(var n=(t.byteLength,0),i=r.length;i>n;n++){var o=r.charCodeAt(n);if(128>o)t.setUint8(e++,o>>>0&127|0);else if(2048>o)t.setUint8(e++,o>>>6&31|192),t.setUint8(e++,o>>>0&63|128);else if(65536>o)t.setUint8(e++,o>>>12&15|224),t.setUint8(e++,o>>>6&63|128),t.setUint8(e++,o>>>0&63|128);else{if(!(1114112>o))throw new Error("bad codepoint "+o);t.setUint8(e++,o>>>18&7|240),t.setUint8(e++,o>>>12&63|128),t.setUint8(e++,o>>>6&63|128),t.setUint8(e++,o>>>0&63|128)}}}function r(t){for(var e=0,r=0,n=t.length;n>r;r++){var i=t.charCodeAt(r);if(128>i)e+=1;else if(2048>i)e+=2;else if(65536>i)e+=3;else{if(!(1114112>i))throw new Error("bad codepoint "+i);e+=4}}return e}function n(t){var n=new ArrayBuffer(function t(e){var n=typeof e;if("string"===n){if(32>(i=r(e)))return 1+i;if(256>i)return 2+i;if(65536>i)return 3+i;if(4294967296>i)return 5+i}if(e instanceof Uint8Array){if(256>(i=e.byteLength))return 2+i;if(65536>i)return 3+i;if(4294967296>i)return 5+i}if("number"===n){if(Math.floor(e)!==e)return 9;if(e>=0){if(128>e)return 1;if(256>e)return 2;if(65536>e)return 3;if(4294967296>e)return 5;throw new Error("Number too big 0x"+e.toString(16))}if(e>=-32)return 1;if(e>=-128)return 2;if(e>=-32768)return 3;if(e>=-2147483648)return 5;throw new Error("Number too small -0x"+e.toString(16).substr(1))}if("boolean"===n||null===e)return 1;if("object"===n){var i,o=0;if(Array.isArray(e)){i=e.length;for(var a=0;i>a;a++)o+=t(e[a])}else{var s=Object.keys(e);for(i=s.length,a=0;i>a;a++){var l=s[a];o+=t(l)+t(e[l])}}if(16>i)return 1+o;if(65536>i)return 3+o;if(4294967296>i)return 5+o;throw new Error("Array or object too long 0x"+i.toString(16))}throw new Error("Unknown type "+n)}(t));return function t(n,i,o){var a=typeof n;if("string"===a){if(32>(s=r(n)))return i.setUint8(o,160|s),e(i,o+1,n),1+s;if(256>s)return i.setUint8(o,217),i.setUint8(o+1,s),e(i,o+2,n),2+s;if(65536>s)return i.setUint8(o,218),i.setUint16(o+1,s),e(i,o+3,n),3+s;if(4294967296>s)return i.setUint8(o,219),i.setUint32(o+1,s),e(i,o+5,n),5+s}if(n instanceof Uint8Array){var s=n.byteLength,l=new Uint8Array(i.buffer);if(256>s)return i.setUint8(o,196),i.setUint8(o+1,s),l.set(n,o+2),2+s;if(65536>s)return i.setUint8(o,197),i.setUint16(o+1,s),l.set(n,o+3),3+s;if(4294967296>s)return i.setUint8(o,198),i.setUint32(o+1,s),l.set(n,o+5),5+s}if("number"===a){if(!isFinite(n))throw new Error("Number not finite: "+n);if(Math.floor(n)!==n)return i.setUint8(o,203),i.setFloat64(o+1,n),9;if(n>=0){if(128>n)return i.setUint8(o,n),1;if(256>n)return i.setUint8(o,204),i.setUint8(o+1,n),2;if(65536>n)return i.setUint8(o,205),i.setUint16(o+1,n),3;if(4294967296>n)return i.setUint8(o,206),i.setUint32(o+1,n),5;throw new Error("Number too big 0x"+n.toString(16))}if(n>=-32)return i.setInt8(o,n),1;if(n>=-128)return i.setUint8(o,208),i.setInt8(o+1,n),2;if(n>=-32768)return i.setUint8(o,209),i.setInt16(o+1,n),3;if(n>=-2147483648)return i.setUint8(o,210),i.setInt32(o+1,n),5;throw new Error("Number too small -0x"+(-n).toString(16).substr(1))}if(null===n)return i.setUint8(o,192),1;if("boolean"===a)return i.setUint8(o,n?195:194),1;if("object"===a){var c=0,u=Array.isArray(n);if(u)s=n.length;else{var h=Object.keys(n);s=h.length}if(16>s?(i.setUint8(o,s|(u?144:128)),c=1):65536>s?(i.setUint8(o,u?220:222),i.setUint16(o+1,s),c=3):4294967296>s&&(i.setUint8(o,u?221:223),i.setUint32(o+1,s),c=5),u)for(var p=0;s>p;p++)c+=t(n[p],i,o+c);else for(p=0;s>p;p++){var f=h[p];c+=t(f,i,o+c),c+=t(n[f],i,o+c)}return c}throw new Error("Unknown type "+a)}(t,new DataView(n),0),new Uint8Array(n)}function i(t,e,r){return e?new t(e.buffer,e.byteOffset,e.byteLength/(r||1)):void 0}function o(t){return i(DataView,t)}function a(t){return i(Uint8Array,t)}function s(t){return i(Int8Array,t)}function l(t){return i(Int32Array,t,4)}function c(t,e){var r=t.length/2;e||(e=new Int16Array(r));for(var n=0,i=0;r>n;++n,i+=2)e[n]=t[i]<<8^t[i+1]<<0;return e}function u(t,e){var r=t.length/4;e||(e=new Int32Array(r));for(var n=0,i=0;r>n;++n,i+=4)e[n]=t[i]<<24^t[i+1]<<16^t[i+2]<<8^t[i+3]<<0;return e}function h(t,e){var r=t.length;e||(e=new Uint8Array(4*r));for(var n=o(e),i=0;r>i;++i)n.setInt32(4*i,t[i]);return a(e)}function p(t,e,r){var n=t.length,i=1/e;r||(r=new Float32Array(n));for(var o=0;n>o;++o)r[o]=t[o]*i;return r}function f(t,e,r){var n=t.length;r||(r=new Int32Array(n));for(var i=0;n>i;++i)r[i]=Math.round(t[i]*e);return r}function d(t,e){var r,n;if(!e){var i=0;for(r=0,n=t.length;n>r;r+=2)i+=t[r+1];e=new t.constructor(i)}var o=0;for(r=0,n=t.length;n>r;r+=2)for(var a=t[r],s=t[r+1],l=0;s>l;++l)e[o]=a,++o;return e}function m(t){if(0===t.length)return new Int32Array;var e,r,n=2;for(e=1,r=t.length;r>e;++e)t[e-1]!==t[e]&&(n+=2);var i=new Int32Array(n),o=0,a=1;for(e=1,r=t.length;r>e;++e)t[e-1]!==t[e]?(i[o]=t[e-1],i[o+1]=a,a=1,o+=2):++a;return i[o]=t[t.length-1],i[o+1]=a,i}function g(t,e){var r=t.length;e||(e=new t.constructor(r)),r&&(e[0]=t[0]);for(var n=1;r>n;++n)e[n]=t[n]+e[n-1];return e}function v(t,e){var r=t.length;e||(e=new t.constructor(r)),e[0]=t[0];for(var n=1;r>n;++n)e[n]=t[n]-t[n-1];return e}function y(t,e){var r,n,i=t instanceof Int8Array?127:32767,o=-i-1,a=t.length;if(!e){var s=0;for(r=0;a>r;++r)t[r]o&&++s;e=new Int32Array(s)}for(r=0,n=0;a>r;){for(var l=0;t[r]===i||t[r]===o;)l+=t[r],++r;l+=t[r],++r,e[n]=l,++n}return e}function _(t,e,r){return p(y(t,l(r)),e,r)}function x(t,e,r){var n,o,a,s=y(t,l(r));return n=s,o=e,a=i(Float32Array,s,4),p(g(n,l(a)),o,a)}function b(t,e,r){return function(t,e){var r,n=e?127:32767,i=-n-1,o=t.length,a=0;for(r=0;o>r;++r)0===(c=t[r])?++a:a+=c===n||c===i?2:c>0?Math.ceil(c/n):Math.ceil(c/i);var s=e?new Int8Array(a):new Int16Array(a),l=0;for(r=0;o>r;++r){var c;if((c=t[r])>=0)for(;c>=n;)s[l]=n,++l,c-=n;else for(;i>=c;)s[l]=i,++l,c-=i;s[l]=c,++l}return s}(v(f(t,e),n),r);var n}function w(t,e,r,n){var i=new ArrayBuffer(12+n.byteLength),o=new Uint8Array(i),a=new DataView(i);return a.setInt32(0,t),a.setInt32(4,e),r&&o.set(r,8),o.set(n,12),o}function S(t){return w(2,t.length,void 0,a(t))}function M(t){return w(4,t.length,void 0,h(t))}function A(t,e){return w(5,t.length/e,h([e]),a(t))}function E(t){return w(6,t.length,void 0,h(m(t)))}function C(t){return w(8,t.length,void 0,h(m(v(t))))}function T(t,e){return w(9,t.length,h([e]),h(m(f(t,e))))}function P(t,e){return w(10,t.length,h([e]),function(t,e){var r=t.length;e||(e=new Uint8Array(2*r));for(var n=o(e),i=0;r>i;++i)n.setInt16(2*i,t[i]);return a(e)}(b(t,e)))}function L(t){var e={};return z.forEach(function(r){void 0!==t[r]&&(e[r]=t[r])}),t.bondAtomList&&(e.bondAtomList=M(t.bondAtomList)),t.bondOrderList&&(e.bondOrderList=S(t.bondOrderList)),e.xCoordList=P(t.xCoordList,1e3),e.yCoordList=P(t.yCoordList,1e3),e.zCoordList=P(t.zCoordList,1e3),t.bFactorList&&(e.bFactorList=P(t.bFactorList,100)),t.atomIdList&&(e.atomIdList=C(t.atomIdList)),t.altLocList&&(e.altLocList=E(t.altLocList)),t.occupancyList&&(e.occupancyList=T(t.occupancyList,100)),e.groupIdList=C(t.groupIdList),e.groupTypeList=M(t.groupTypeList),t.secStructList&&(e.secStructList=S(t.secStructList)),t.insCodeList&&(e.insCodeList=E(t.insCodeList)),t.sequenceIndexList&&(e.sequenceIndexList=C(t.sequenceIndexList)),e.chainIdList=A(t.chainIdList,4),t.chainNameList&&(e.chainNameList=A(t.chainNameList,4)),e}function R(t){function e(t){for(var e={},r=0;t>r;r++){e[o()]=o()}return e}function r(e){var r=t.subarray(a,a+e);return a+=e,r}function n(e){var r=t.subarray(a,a+e);a+=e;if(e>65535){for(var n=[],i=0;ir;r++)e[r]=o();return e}function o(){var o,l,c=t[a];if(0==(128&c))return a++,c;if(128==(240&c))return l=15&c,a++,e(l);if(144==(240&c))return l=15&c,a++,i(l);if(160==(224&c))return l=31&c,a++,n(l);if(224==(224&c))return o=s.getInt8(a),a++,o;switch(c){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return l=s.getUint8(a+1),a+=2,r(l);case 197:return l=s.getUint16(a+1),a+=3,r(l);case 198:return l=s.getUint32(a+1),a+=5,r(l);case 202:return o=s.getFloat32(a+1),a+=5,o;case 203:return o=s.getFloat64(a+1),a+=9,o;case 204:return o=t[a+1],a+=2,o;case 205:return o=s.getUint16(a+1),a+=3,o;case 206:return o=s.getUint32(a+1),a+=5,o;case 208:return o=s.getInt8(a+1),a+=2,o;case 209:return o=s.getInt16(a+1),a+=3,o;case 210:return o=s.getInt32(a+1),a+=5,o;case 217:return l=s.getUint8(a+1),a+=2,n(l);case 218:return l=s.getUint16(a+1),a+=3,n(l);case 219:return l=s.getUint32(a+1),a+=5,n(l);case 220:return l=s.getUint16(a+1),a+=3,i(l);case 221:return l=s.getUint32(a+1),a+=5,i(l);case 222:return l=s.getUint16(a+1),a+=3,e(l);case 223:return l=s.getUint32(a+1),a+=5,e(l)}throw new Error("Unknown type 0x"+c.toString(16))}var a=0,s=new DataView(t.buffer);return o()}function N(t,e,r,n){switch(t){case 1:return function(t,e){var r=t.length;e||(e=new Float32Array(r/4));for(var n=o(e),i=o(t),a=0,s=0,l=r/4;l>a;++a,s+=4)n.setFloat32(s,i.getFloat32(s),!0);return e}(e);case 2:return s(e);case 3:return c(e);case 4:return u(e);case 5:return a(e);case 6:return d(u(e),new Uint8Array(r));case 7:return d(u(e));case 8:return g(d(u(e)),m);case 9:return i=u(e),h=u(n)[0],p(d(i,l(f)),h,f);case 10:return x(c(e),u(n)[0]);case 11:return p(c(e),u(n)[0]);case 12:return _(c(e),u(n)[0]);case 13:return _(s(e),u(n)[0]);case 14:return y(c(e));case 15:return y(s(e))}var i,h,f,m}function I(t,e){var r=(e=e||{}).ignoreFields,n={};return k.forEach(function(e){var i,a,s,l,c,u=!!r&&-1!==r.indexOf(e),h=t[e];u||void 0===h||(h instanceof Uint8Array?n[e]=N.apply(null,(a=o(i=h),s=a.getInt32(0),l=a.getInt32(4),c=i.subarray(8,12),[s,i=i.subarray(12),l,c])):n[e]=h)}),n}function O(t){return String.fromCharCode.apply(null,t).replace(/\0/g,"")}function D(t,e){return t instanceof ArrayBuffer&&(t=new Uint8Array(t)),I(t instanceof Uint8Array?R(t):t,e)}function F(t,e,r,n){var i=new XMLHttpRequest;i.addEventListener("load",function(){try{var t=D(i.response);r(t)}catch(t){n(t)}},!0),i.addEventListener("error",n,!0),i.responseType="arraybuffer",i.open("GET",e+t.toUpperCase()),i.send()}var z=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],k=z.concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]),U="//mmtf.rcsb.org/v1.0/",B=U+"full/",V=U+"reduced/";t.encode=function(t){return n(L(t))},t.decode=D,t.traverse=function(t,e,r){var n,i,o,a,s,l,c=(r=r||{}).firstModelOnly,u=e.onModel,h=e.onChain,p=e.onGroup,f=e.onAtom,d=e.onBond,m=0,g=0,v=0,y=0,_=0,x=-1,b=t.chainNameList,w=t.secStructList,S=t.insCodeList,M=t.sequenceIndexList,A=t.atomIdList,E=t.bFactorList,C=t.altLocList,T=t.occupancyList,P=t.bondAtomList,L=t.bondOrderList;for(n=0,i=t.chainsPerModel.length;i>n&&!(c&&m>0);++n){var R=t.chainsPerModel[m];for(u&&u({chainCount:R,modelIndex:m}),o=0;R>o;++o){var N=t.groupsPerChain[g];if(h){var I=O(t.chainIdList.subarray(4*g,4*g+4)),D=null;b&&(D=O(b.subarray(4*g,4*g+4))),h({groupCount:N,chainIndex:g,modelIndex:m,chainId:I,chainName:D})}for(a=0;N>a;++a){var F=t.groupList[t.groupTypeList[v]],z=F.atomNameList.length;if(p){var k=null;w&&(k=w[v]);var U=null;t.insCodeList&&(U=String.fromCharCode(S[v]));var B=null;M&&(B=M[v]),p({atomCount:z,groupIndex:v,chainIndex:g,modelIndex:m,groupId:t.groupIdList[v],groupType:t.groupTypeList[v],groupName:F.groupName,singleLetterCode:F.singleLetterCode,chemCompType:F.chemCompType,secStruct:k,insCode:U,sequenceIndex:B})}for(s=0;z>s;++s){if(f){var V=null;A&&(V=A[y]);var j=null;E&&(j=E[y]);var G=null;C&&(G=String.fromCharCode(C[y]));var W=null;T&&(W=T[y]),f({atomIndex:y,groupIndex:v,chainIndex:g,modelIndex:m,atomId:V,element:F.elementList[s],atomName:F.atomNameList[s],formalCharge:F.formalChargeList[s],xCoord:t.xCoordList[y],yCoord:t.yCoordList[y],zCoord:t.zCoordList[y],bFactor:j,altLoc:G,occupancy:W})}y+=1}if(d){var H=F.bondAtomList;for(s=0,l=F.bondOrderList.length;l>s;++s)d({atomIndex1:y-z+H[2*s],atomIndex2:y-z+H[2*s+1],bondOrder:F.bondOrderList[s]})}v+=1}g+=1}if(_=x+1,x=y-1,d&&P)for(s=0,l=P.length;l>s;s+=2){var X=P[s],Y=P[s+1];(X>=_&&x>=X||Y>=_&&x>=Y)&&d({atomIndex1:X,atomIndex2:Y,bondOrder:L?L[s/2]:null})}m+=1}},t.fetch=function(t,e,r){F(t,B,e,r)},t.fetchReduced=function(t,e,r){F(t,V,e,r)},t.version="v1.1.0dev",t.fetchUrl=B,t.fetchReducedUrl=V,t.encodeMsgpack=n,t.encodeMmtf=L,t.decodeMsgpack=R,t.decodeMmtf=I})(e)}),gy=Jp.Complex,vy=Jp.Chain,yy=Jp.Atom,_y=Jp.AtomName,xy=Jp.Element,by=Jp.Helix,wy=Jp.Sheet,Sy=Jp.Strand,My=Jp.Bond,Ay=Jp.Assembly,Ey=Jp.Molecule;function Cy(t){this._original=Array.from(t),this._original.sort(),this._sum=0;for(var e=0;e=this._complex._atoms.length)){var r=Math.min(t.atomIndex1,t.atomIndex2);this._complex.addBond(this._complex._atoms[r],this._complex._atoms[e],t.bondOrder,My.BondType.UNKNOWN,!0)}},Ty.prototype._updateSecStructure=function(t,e,r){if(!n.isUndefined(r)&&r.secStruct===this._ssType)return e._secondary=this._ssStruct,void((this._ssStruct instanceof by||this._ssStruct instanceof Sy)&&this._ssStruct._residues.push(e));if(-1!==this._ssType&&(this._ssStruct instanceof by||this._ssStruct instanceof Sy)&&(this._ssStruct._end=this._ssStruct._residues[this._ssStruct._residues.length-1]),!n.isUndefined(r)){this._ssType=r.secStruct,this._ssStart=e;var i=null;switch(this._ssType){case-1:break;case 0:case 2:case 4:i=new by(0,"",e,null,[3,-1,1,-1,5][this._ssType],"",0),t._helices.push(i);break;case 3:var o=new wy("",0);t._sheets.push(o),i=new Sy(o,e,null,0);break;default:i={type:"mmtf"+this._ssType}}this._ssStruct=i,e._secondary=i}},Ty.prototype._updateMolecules=function(t){var e=t.entityList;if(e)for(var r=t.chainsPerModel[0],n=0;n=r)){var c=this._complex._chains[l];a=a.concat(c._residues.slice())}}var u=new Ey(this._complex,i.description,n+1);u._residues=a,this._complex._molecules[n]=u}},Ty.prototype._traverse=function(t){var e=this,r={onModel:function(t){e._onModel(t)},onChain:function(t){e._onChain(t)},onGroup:function(t){e._onGroup(t)},onAtom:function(t){e._onAtom(t)},onBond:function(t){e._onBond(t)}};this._ssType=-1,this._ssStruct=null,this._ssStart=null,my.traverse(t,r),this._updateSecStructure(this._complex),this._updateMolecules(t)},Ty.prototype._linkAtomsToResidues=function(){for(var t=0;t=e))for(var a=this._complex._chains[o],s=0;s0&&u.addChain(r[m])}u.matrices=h,t.structures.push(u)}}}},Uy._parseToObject=function(t){var e,r,i,o,a=0,s=0,l=t.length,c=NaN,u=!0,h=1,p=1,f=0,d="unexpected character",m={},g={},v=[],y=0,_="",x=[],b=0;function w(t){return 32===t||10===t||13===t||9===t}function S(t,e,r){for(var n=e.length,i=-1;r=l||w(t.charCodeAt(a+1)))){if(u&&59===c){s=a;var r=0;do{if(-1===(s=S(10,t,s+1)))return d="unterminated text block found",null;++r}while(s+1=l);return e=t.substring(a+1,s).replace(/\r/g,""),a=s+2,h+=r,p=1,u=!1,e}if(39===c||34===c){s=a;do{if(-1===(s=S(c,t,s+1)))return d="unterminated quoted string found",null}while(s+10){for(var A=0;A-e.near?"hidden":"visible",s=1e4*(e.far- -this._vector.z)/(e.far-e.near),l=t.getElement();if(void 0===r.fog)l.style.color=i(t.userData.color),"transparent"!==t.userData.background&&(l.style.background=i(t.userData.background));else{var c=ye.smoothstep(-this._vector.z,r.fog.near,r.fog.far);l.style.color=n(t.userData.color,r.fog.color,c),"transparent"!==t.userData.background&&(l.style.background=n(t.userData.background,r.fog.color,c))}this._vector.applyMatrix4(this._projectionMatrix);var u=(t.userData!=={}?t.userData.translation:"translate(-50%, -50%) ")+"translate("+(this._vector.x*this._widthHalf+this._widthHalf)+"px,"+(-this._vector.y*this._heightHalf+this._heightHalf)+"px)";l.style.visibility=a,l.style.WebkitTransform=u,l.style.MozTransform=u,l.style.oTransform=u,l.style.transform=u,l.style.zIndex=Number(s).toFixed(0),l.parentNode!==this._domElement&&this._domElement.appendChild(l)}for(var h=0,p=t.children.length;h0&&(this._altObj.setObjects(a.objects),this._altObj.pivot=a.pivot,"axis"in a?this._altObj.axis=a.axis.clone():this._altObj.axis.set(0,0,1),this._altObj.translate(new _e(o*n,o*i)),this.dispatchEvent({type:"change",action:"translate"}))}else o*=10*(Vu.now.inversePanning?-1:1),this.camera.translateX(o*n),this.camera.translateY(o*i),this.dispatchEvent({type:"change",action:"pan"})}}this._lastUpdateTime=t},Jy.prototype.reset=function(){this._state=Ky.NONE,this.object.quaternion.copy(new We(0,0,0,1))},Jy.prototype.mousedown=function(t){if(!1!==this.enabled&&this._state===Ky.NONE){if(t.preventDefault(),t.stopPropagation(),this._state===Ky.NONE)if(0===t.button){this._affectedObj.stop();var e=!1;if(t.altKey){var r=this.getAltObj();(e=r.objects.length>0)&&(this._altObj.setObjects(r.objects),this._altObj.pivot=r.pivot,"axis"in r?this._altObj.axis=r.axis.clone():this._altObj.axis.set(0,0,1))}this._affectedObj=e?this._altObj:this._mainObj,this._state=e&&t.ctrlKey&&this._isTranslationAllowed?Ky.TRANSLATE:Ky.ROTATE}else 2===t.button&&(this._state=Ky.TRANSLATE_PIVOT);this._state===Ky.ROTATE&&(this._mouseCurPos.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos)),this._state!==Ky.TRANSLATE&&this._state!==Ky.TRANSLATE_PIVOT||(this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos))}},Jy.prototype.mousemove=function(t){if(!1!==this.enabled&&this._state!==Ky.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case Ky.ROTATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this.rotateByMouse(t.altKey&&!this._isAltObjFreeRotationAllowed||t.shiftKey),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case Ky.TRANSLATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translate();break;case Ky.TRANSLATE_PIVOT:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translatePivotByMouse()}},Jy.prototype.mousewheel=function(t){if(!1!==this.enabled&&Vu.now.zooming&&this._state===Ky.NONE&&!t.shiftKey){t.preventDefault();var e=0;t.wheelDelta?e=t.wheelDelta/40:t.detail&&(e=-t.detail/3);var r=1+.05*e;this.scale(r),this.dispatchEvent({type:"change",action:"zoom",factor:r})}},Jy.prototype.mouseup=function(t){!1!==this.enabled&&this._state!==Ky.NONE&&(t.preventDefault(),t.stopPropagation(),this._state=Ky.NONE,this._clock.getElapsedTime()-this._lastMouseMoveTime>.1&&this._affectedObj.stop())},Jy.prototype.touchstartend=function(t){if(!1!==this.enabled)switch(t.preventDefault(),t.stopPropagation(),t.touches.length){case 1:this._state=Ky.ROTATE,this._mouseCurPos.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY)),this._mousePrevPos.copy(this._mouseCurPos);break;case 2:this._mainObj.stop(),this._altObj.stop(),this._state=Ky.SCALE_PAN;var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY;this._touchDistanceCur=this._touchDistanceStart=Math.sqrt(e*e+r*r),this._scaleStart=this.object.scale.x,this._originalPinchCenter=new _e(.5*(t.touches[0].pageX+t.touches[1].pageX),.5*(t.touches[0].pageY+t.touches[1].pageY)),this._originalCameraPos.copy(this.camera.position);break;default:this._state=Ky.NONE}},Jy.prototype.touchmove=function(t){if(!1!==this.enabled&&this._state!==Ky.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case Ky.ROTATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY)),this.rotateByMouse(!1),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case Ky.SCALE_PAN:if(Vu.now.zooming){var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY;this._touchDistanceCur=Math.sqrt(e*e+r*r);var n=this.object.scale.x,i=this._scaleStart*this._touchDistanceCur/this._touchDistanceStart;this.setScale(i),this.dispatchEvent({type:"change",action:"zoom",factor:0===n?1:i/n})}if(Vu.now.panning){var o=new _e(.5*(t.touches[0].pageX+t.touches[1].pageX),.5*(t.touches[0].pageY+t.touches[1].pageY));o.sub(this._originalPinchCenter),this.camera.position.x=this._originalCameraPos.x-.1*o.x,this.camera.position.y=this._originalCameraPos.y+.1*o.y,this.dispatchEvent({type:"change",action:"pan"})}}},Jy.prototype.keydownup=function(t){if(!1!==this.enabled&&!1!==this.hotkeysEnabled)switch(t.keyCode){case 37:case 38:case 39:case 40:this._pressedKeys[t.keyCode]="keydown"===t.type,t.preventDefault(),t.stopPropagation()}},Jy.prototype.getKeyBindObject=function(){return window.top},Jy.prototype.dispose=function(){for(var t=0;t0){var o=e[0],a=new He;if(Vu.now.draft.clipPlane&&this.hasOwnProperty("clipPlaneValue")){var s;for(s=0;s=n_?t-i_:t}function c_(t,e,r){this._complex=t,this._secondary=null,this.isLoading=!1,this._framesRange={start:0,end:-1},this.frameIsReady=!1,this._buffer=null,this._frameRequest=null,this._callbacks=r,"function"==typeof e?(this._framesRequestLength=1,this._downloadDataFn=e):this.parseBinaryData(e,!0),this.reset(),this.setFrame(0)}function u_(t,e){if(this.constructor===u_)throw new Error("Can not instantiate abstract class!");this.params=t,this.opts=n.merge(Cu.deriveDeep(Vu.now.objects[this.type],!0),e),this.needsRebuild=!1}function h_(t,e){if(u_.call(this,t,e),t.length<2)throw new Error("Wrong number of argumets on line object creation!");this._id1=t[0],this._id2=t[1]}c_.prototype._prepareBuffer=function(t,e){if(void 0!==t&&null!==t||(t=0),void 0!==e&&null!==e||(e=t+this._framesRequestLength),void 0!==this._framesCount&&(e=Math.min(this._framesCount-1,e)),this._downloadDataFn){var r=this;this._buffer||(this._buffer={}),this._buffer.state="downloading",this.isLoading=!0,r._callbacks&&"function"==typeof r._callbacks.onLoadStatusChanged&&r._callbacks.onLoadStatusChanged(),this._downloadDataFn({start:t,end:e+1},function(n){if(r.isLoading=!1,r._callbacks&&"function"==typeof r._callbacks.onLoadStatusChanged&&r._callbacks.onLoadStatusChanged(),r._buffer={data:n,state:"ready",start:t,end:e},null!==r._frameRequest){var i=r._frameRequest;r._frameRequest=null,r.setFrame(i)}},function(){r.isLoading=!1,r._callbacks&&"function"==typeof r._callbacks.onError&&r._callbacks.onError("Streaming failed")})}},c_.prototype._parseBuffer=function(){if(this._buffer&&"ready"===this._buffer.state){this._framesRange={start:this._buffer.start,end:this._buffer.end},this.parseBinaryData(this._buffer.data,!1);var t=(this._buffer.end+1)%this._framesCount;if(t>=this._framesCount&&(t=0),this._buffer={state:"none"},this._prepareBuffer(t,t+this._framesRequestLength),null!==this._frameRequest){var e=this._frameRequest;this._frameRequest=null,this.setFrame(e)}}},c_.prototype.parseBinaryData=function(t){var e=new DataView(t),r=0,n=e.getUint32(r,!0);r+=4;var i=e.getUint32(r,!0);this._framesCount=i,this._framesRange.end=this._framesRange.end>0?Math.min(this._framesRange.end,i-1):i-1,r+=4,this._atomsCount=n;this._framesRequestLength=Math.ceil(1048576/(8*n));var o=this._framesRange.end-this._framesRange.start+1;if(n!==this._complex._atoms.length||t.byteLength!==12+o*n*8)throw new Error;for(var a=this._complex,s=e.getUint32(r,!0),l=0;s>1e3&&l>>28,y=l_((268435200&g)>>>8>>0),_=l_(((255&g)<<12|(4293918720&m)>>>20)>>0),x=l_((1048575&m)>>0);p[d]=0,v>0&&v<4?p[d]=1:4===v&&(p[d]=2),u[h++]=y/100,u[h++]=_/100,u[h++]=x/100}c.push(s_(p,a))}this._secondaryData=c,this._data=u},c_.prototype.nextFrame=function(){this.setFrame((this._currFrame+1)%this._framesCount)},c_.prototype.needsColorUpdate=function(t){return t instanceof tv},c_.prototype.getAtomColor=function(t,e){return t.getResidueColor(this._residues[e._residue._index],this._complex)},c_.prototype.getResidueColor=function(t,e){return t.getResidueColor(this._residues[e._index],this._complex)},c_.prototype._updateSecondary=function(){var t,e=this._residues,r=e.length;for(t=0;t=this._framesRange.start&&t<=this._framesRange.end)this._currFrame=t,this._cachedResidues=!1,this._updateSecondary(),this.frameIsReady=!0;else if(this._frameRequest=t,this._buffer){switch(this._buffer.state){case"none":this._prepareBuffer(t);break;case"ready":this._parseBuffer()}}else this._prepareBuffer(t)},c_.prototype.disableEvents=function(){this._callbacks=null},c_.prototype.getAtomPos=(r_=new He,function(t){var e=this._data,r=3*(this._atomsCount*(this._currFrame-this._framesRange.start)+t);return r_.set(e[r],e[r+1],e[r+2]),r_}),c_.prototype.getResidues=function(){return this._cachedResidues?this._residues:(this._complex.updateToFrame(this),this._residues)},u_.prototype.type="__",u_.prototype.identify=function(){var t={type:this.type,params:this.params},e=Cu.objectsDiff(this.opts,Vu.now.modes[this.id]);return n.isEmpty(e)||(t.opts=e),t},u_.prototype.toString=function(){return"o="+this.type+","+this.params.join(",")+Cu.compareOptionsWithDefaults(this.opts,Vu.defaults.objects[this.type])},u_.prototype.getGeometry=function(){return this._mesh},u_.prototype.destroy=function(){this._mesh&&mf.destroyObject(this._mesh)},Cu.deriveClass(h_,u_,{type:"line"}),h_.prototype.constructor=h_,h_.prototype._getAtomFromName=function(t,e){var r=t.getAtomByFullname(e);if(!r)throw new Error(e+" - Wrong atom format it must be '#CHAIN_NAME.#NUMBER.#ATOM_NAME' (e.g. 'A.38.CO1')");return r},h_.prototype.build=function(t){var e=new Fi;this._atom1=this._getAtomFromName(t,this._id1),this._atom2=this._getAtomFromName(t,this._id2),e.vertices[0]=this._atom1._position.clone(),e.vertices[1]=this._atom2._position.clone(),e.dynamic=!0,e.computeLineDistances(),e.computeBoundingBox(),this._line=new Zd.Line(e,new lf({lights:!1,overrideColor:!0,dashedLine:!0})),this._line.material.setUberOptions({fixedColor:new Dr(this.opts.color),dashedLineSize:this.opts.dashSize,dashedLinePeriod:this.opts.dashSize+this.opts.gapSize}),this._line.material.updateUniforms(),this._line.raycast=function(t,e){},this._mesh=this._line;var r=t.getTransforms();r.length>0&&(this._mesh=new ea,this._mesh.add(this._line),mf.applyTransformsToMeshes(this._mesh,r))},h_.prototype.updateToFrame=function(t){if(this._atom1&&this._atom2&&this._line){var e=this._line.geometry;e.vertices[0].copy(t.getAtomPos(this._atom1._index)),e.vertices[1].copy(t.getAtomPos(this._atom2._index)),e.computeLineDistances(),e.computeBoundingSphere(),e.verticesNeedUpdate=!0}};var p_="varying vec2 vUv;\r\n\r\nvoid main() {\r\n vUv = uv;\r\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\r\n}\r\n",f_="uniform sampler2D srcTex;\r\nuniform vec2 srcTexSize;\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n\r\n vec2 pixelSize = vec2(1, 1) / srcTexSize;\r\n\r\n vec4 c00 = texture2D(srcTex, vUv + vec2(-pixelSize.x,-pixelSize.y));\r\n vec4 c01 = texture2D(srcTex, vUv + vec2(0,-pixelSize.y));\r\n vec4 c02 = texture2D(srcTex, vUv + vec2(pixelSize.x,-pixelSize.y));\r\n vec4 c10 = texture2D(srcTex, vUv + vec2(-pixelSize.x,0));\r\n vec4 c12 = texture2D(srcTex, vUv + vec2(pixelSize.x,0));\r\n vec4 c20 = texture2D(srcTex, vUv + vec2(-pixelSize.x,pixelSize.y));\r\n vec4 c21 = texture2D(srcTex, vUv + vec2(0,pixelSize.y));\r\n vec4 c22 = texture2D(srcTex, vUv + vec2(pixelSize.x,pixelSize.y));\r\n\r\n vec4 horizEdge = - c00 - 2.0 * c01 - c02 + c20 + 2.0 * c21 + c22;\r\n vec4 vertEdge = - c00 - 2.0 * c10 - c20 + c02 + 2.0 * c12 + c22;\r\n\r\n vec4 grad = sqrt(horizEdge * horizEdge + vertEdge * vertEdge);\r\n\r\n gl_FragColor = grad;\r\n}\r\n",d_=Ur.merge([{srcTex:{type:"t",value:null},srcTexSize:{type:"v2",value:new _e(512,512)},opacity:{type:"f",value:1}}]);function m_(t){return new dn({uniforms:function(t){var e=Ur.clone(d_);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:p_,fragmentShader:f_,transparent:!0,depthTest:!1,depthWrite:!1})}var g_="// edge end finding algorithm parameters\r\n#define FXAA_QUALITY_PS 8\r\n#define FXAA_QUALITY_P0 1.0\r\n#define FXAA_QUALITY_P1 1.5\r\n#define FXAA_QUALITY_P2 2.0\r\n#define FXAA_QUALITY_P3 2.0\r\n#define FXAA_QUALITY_P4 2.0\r\n#define FXAA_QUALITY_P5 2.0\r\n#define FXAA_QUALITY_P6 4.0\r\n#define FXAA_QUALITY_P7 12.0\r\n// constants\r\nfloat fxaaQualityEdgeThreshold = 0.125;\r\nfloat fxaaQualityEdgeThresholdMin = 0.0625;\r\nfloat fxaaQualitySubpix = 0.7; //0.65;\r\n// global params\r\nuniform sampler2D srcTex;\r\nuniform vec2 srcTexelSize;\r\n// from vs\r\nvarying vec2 vUv;\r\n//=====================================================================//\r\n// calc luminance from rgb\r\n//'float FxaaLuma(vec3 rgb) {return rgb.y * (0.587/0.299) + rgb.x; } // Lotte's idea about game luminance\r\nfloat FxaaLuma(vec3 rgb) {return dot(rgb, vec3(0.299, 0.587, 0.114)); } // real luminance calculation\r\n // for non-real scene rendering\r\n// texture sampling by pixel position(coords) and offset(in pixels)\r\nvec3 FxaaTex(sampler2D tex, vec2 pos, vec2 off, vec2 res ) {return texture2D( tex, pos + off * res ).xyz;}\r\nvec3 FxaaTexTop(sampler2D tex, vec2 pos) {return texture2D( tex, pos).xyz;}\r\n//=====================================================================//\r\nvoid main() {\r\n// renaming\r\n vec2 posM = vUv;\r\n// get luminance for neighbours\r\n float lumaS = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, 1.0 ), srcTexelSize));\r\n float lumaE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 0.0 ), srcTexelSize));\r\n float lumaN = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, -1.0 ), srcTexelSize));\r\n float lumaW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 0.0 ), srcTexelSize));\r\n float lumaM = FxaaLuma(FxaaTexTop(srcTex, posM));\r\n// find max and min luminance\r\n float rangeMax = max(max(lumaN, lumaW), max(lumaE, max(lumaS, lumaM)));\r\n float rangeMin = min(min(lumaN, lumaW), min(lumaE, min(lumaS, lumaM)));\r\n// calc maximum non-edge range\r\n float rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\r\n float range = rangeMax - rangeMin;\r\n float rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\r\n// exit when luma contrast is small (is not edge)\r\n if(range < rangeMaxClamped){\r\n gl_FragColor = vec4(FxaaTexTop(srcTex, posM).xyz, 1.0);\r\n return;\r\n }\r\n float subpixRcpRange = 1.0/range;\r\n// calc other neighbours luminance\r\n float lumaNE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, -1.0 ), srcTexelSize));\r\n float lumaSW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 1.0 ), srcTexelSize));\r\n float lumaSE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 1.0 ), srcTexelSize));\r\n float lumaNW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, -1.0 ), srcTexelSize));\r\n/*--------------span calculation and subpix amount calulation-----------------*/\r\n float lumaNS = lumaN + lumaS;\r\n float lumaWE = lumaW + lumaE;\r\n float subpixNSWE = lumaNS + lumaWE;\r\n float edgeHorz1 = (-2.0 * lumaM) + lumaNS;\r\n float edgeVert1 = (-2.0 * lumaM) + lumaWE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNESE = lumaNE + lumaSE;\r\n float lumaNWNE = lumaNW + lumaNE;\r\n float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\r\n float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNWSW = lumaNW + lumaSW;\r\n float lumaSWSE = lumaSW + lumaSE;\r\n float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\r\n float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\r\n float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\r\n float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\r\n float edgeHorz = abs(edgeHorz3) + edgeHorz4;\r\n float edgeVert = abs(edgeVert3) + edgeVert4;\r\n/*--------------------subpix amount calulation------------------------------*/\r\n float subpixNWSWNESE = lumaNWSW + lumaNESE;\r\n float lengthSign = srcTexelSize.x;\r\n bool horzSpan = edgeHorz >= edgeVert;\r\n // debug code edge span visualization\r\n/*' if (horzSpan)\r\n gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\r\n else\r\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\r\n return;*/\r\n float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\r\n/*--------------------------------------------------------------------------*/\r\n if(!horzSpan) lumaN = lumaW;\r\n if(!horzSpan) lumaS = lumaE;\r\n if(horzSpan) lengthSign = srcTexelSize.y;\r\n float subpixB = (subpixA * (1.0/12.0)) - lumaM;\r\n/*--------------------------------------------------------------------------*/\r\n float gradientN = lumaN - lumaM;\r\n float gradientS = lumaS - lumaM;\r\n float lumaNN = lumaN + lumaM;\r\n float lumaSS = lumaS + lumaM;\r\n bool pairN = abs(gradientN) >= abs(gradientS);\r\n float gradient = max(abs(gradientN), abs(gradientS));\r\n if(pairN) lengthSign = -lengthSign;\r\n float subpixC = clamp(abs(subpixB) * subpixRcpRange, 0.0, 1.0);\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posB;\r\n posB = posM;\r\n vec2 offNP;\r\n offNP.x = (!horzSpan) ? 0.0 : srcTexelSize.x;\r\n offNP.y = ( horzSpan) ? 0.0 : srcTexelSize.y;\r\n if(!horzSpan) posB.x += lengthSign * 0.5;\r\n if( horzSpan) posB.y += lengthSign * 0.5;\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posN;\r\n posN = posB - offNP * FXAA_QUALITY_P0;\r\n vec2 posP;\r\n posP = posB + offNP * FXAA_QUALITY_P0;\r\n float subpixD = ((-2.0)*subpixC) + 3.0;\r\n float lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN));\r\n float subpixE = subpixC * subpixC;\r\n float lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP));\r\n/*--------------------------------------------------------------------------*/\r\n if(!pairN) lumaNN = lumaSS;\r\n float gradientScaled = gradient * 1.0/4.0;\r\n float lumaMM = lumaM - lumaNN * 0.5;\r\n float subpixF = subpixD * subpixE;\r\n bool lumaMLTZero = lumaMM < 0.0;\r\n/*---------------------looped edge-end search-------------------------------*/\r\n lumaEndN -= lumaNN * 0.5;\r\n lumaEndP -= lumaNN * 0.5;\r\n bool doneN = abs(lumaEndN) >= gradientScaled;\r\n bool doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P1;\r\n bool doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P1;\r\n/*--------------------------------------------------------------------------*/\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P2;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P2;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 3)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P3;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P3;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 4)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P4;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P4;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 5)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P5;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P5;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 6)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P6;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P6;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 7)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P7;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P7;\r\n/*--------------------------------------------------------------------------*/\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n/*----------------calculate subpix offset due to edge ends-------------------*/\r\n float dstN = posM.x - posN.x;\r\n float dstP = posP.x - posM.x;\r\n if(!horzSpan) dstN = posM.y - posN.y;\r\n if(!horzSpan) dstP = posP.y - posM.y;\r\n/*--------------------------------------------------------------------------*/\r\n bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\r\n float spanLength = (dstP + dstN);\r\n bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\r\n float spanLengthRcp = 1.0/spanLength;\r\n/*--------------------------------------------------------------------------*/\r\n bool directionN = dstN < dstP;\r\n float dst = min(dstN, dstP);\r\n bool goodSpan = directionN ? goodSpanN : goodSpanP;\r\n float subpixG = subpixF * subpixF;\r\n float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\r\n float subpixH = subpixG * fxaaQualitySubpix;\r\n/*-----------------calc texture offest using subpix-------------------------*/\r\n float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\r\n float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\r\n if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\r\n if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\r\n gl_FragColor = vec4(FxaaTexTop(srcTex, posM).xyz, 1.0);\r\n return;\r\n}\r\n",v_=Ur.merge([{srcTex:{type:"t",value:null},srcTexelSize:{type:"v2",value:new _e(1/512,1/512)}}]);function y_(t){return new dn({uniforms:function(t){var e=Ur.clone(v_);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:p_,fragmentShader:g_,transparent:!0,depthTest:!1,depthWrite:!1})}var __="#define MAX_SAMPLES_COUNT 32\r\n\r\nuniform vec3 samplesKernel[MAX_SAMPLES_COUNT];\r\nuniform sampler2D noiseTexture;\r\nuniform vec2 noiseTexelSize;\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\nuniform vec2 camNearFar;\r\nuniform mat4 projMatrix;\r\n\r\nuniform float aspectRatio;\r\nuniform float tanHalfFOV;\r\n\r\nuniform float kernelRadius;\r\nuniform float depthThreshold;\r\nuniform float factor;\r\n\r\nuniform vec2 fogNearFar;\r\nvarying vec2 vUv;\r\n\r\nfloat CalcViewZ(vec2 screenPos)\r\n{\r\n float depth = texture2D(depthTexture, screenPos).x;\r\n // [0, 1]->[-1, 1]\r\n float clipedZ = 2.0 * depth - 1.0;\r\n // see THREE.js camera.makeFrustum for projection details\r\n return (- projMatrix[3][2] / (clipedZ + projMatrix[2][2]));\r\n}\r\n\r\nvec3 ViewPosFromDepth(vec2 screenPos)\r\n{\r\n vec3 viewPos;\r\n viewPos.z = CalcViewZ(screenPos);\r\n //[0, 1]->[-1, 1]\r\n vec2 projPos = 2.0 * screenPos - 1.0;\r\n vec2 viewRay = vec2(projPos.x * aspectRatio * tanHalfFOV, projPos.y * tanHalfFOV); // TODO mode to vs\r\n // reconstruct viewposition in right-handed sc with z from viewer\r\n viewPos.xy = vec2(viewRay.x * viewPos.z, viewRay.y * viewPos.z);\r\n return viewPos;\r\n}\r\n\r\nvec3 GetDerivative( vec3 p0, vec3 p1, vec3 p2 )\r\n{\r\n vec3 v1 = p1 - p0;\r\n vec3 v2 = p0 - p2;\r\n return ( dot( v1, v1 ) < dot( v2, v2 ) ) ? v1 : v2;\r\n}\r\n\r\nvec3 RestoreNormalFromDepth(vec2 texcoords, vec3 p) {\r\n\r\n vec2 offset1 = vec2(srcTexelSize.x, 0.0);\r\n vec2 offset2 = vec2(0.0, srcTexelSize.y);\r\n\r\n vec3 p1 = ViewPosFromDepth(texcoords + offset1);\r\n vec3 p2 = ViewPosFromDepth(texcoords + offset2);\r\n vec3 p3 = ViewPosFromDepth(texcoords - offset1);\r\n vec3 p4 = ViewPosFromDepth(texcoords - offset2);\r\n\r\n vec3 dx = GetDerivative(p, p3, p1);\r\n vec3 dy = GetDerivative(p, p4, p2);\r\n vec3 normal = cross(dx, dy);\r\n return normalize(normal);\r\n}\r\n\r\nvoid main() {\r\n vec3 viewPos = ViewPosFromDepth(vUv);\r\n // remap coordinates to prevent noise exture rescale\r\n vec2 vUvNoise = vUv / srcTexelSize * noiseTexelSize;\r\n // restore normal from depth buffer\r\n vec3 normal = RestoreNormalFromDepth(vUv, viewPos); \r\n // get random vector for sampling sphere rotation\r\n vec3 randN = texture2D(noiseTexture, vUvNoise).rgb * 2.0 - 1.0;\r\n randN = normalize(randN);\r\n // build TBN (randomly rotated around normal)\r\n vec3 tangent = normalize(randN - normal * dot(randN, normal));\r\n vec3 bitangent = cross(tangent, normal);\r\n mat3 TBN = mat3(tangent, bitangent, normal);\r\n // calc AO value\r\n float AO = 0.0;\r\n for (int i = 0 ; i < MAX_SAMPLES_COUNT ; i++) {\r\n // rotate sampling kernel around normal\r\n vec3 reflectedSample = TBN * samplesKernel[i];\r\n // get sample\r\n vec3 samplePos = viewPos + reflectedSample * kernelRadius;\r\n // project sample to screen to get sample's screen pos\r\n vec4 offset = vec4(samplePos, 1.0);\r\n offset = projMatrix * offset;\r\n offset.xy /= offset.w;\r\n offset.xy = (-offset.xy + vec2(1.0)) * 0.5;\r\n // get view z for sample projected to the objct surface\r\n float sampleDepth = CalcViewZ(offset.xy);\r\n // calc occlusion made by object surface at the sample\r\n AO += step(samplePos.z, sampleDepth);\r\n }\r\n // add fog to the AO value\r\n AO *= 1.0 - smoothstep(fogNearFar.x, fogNearFar.y, - viewPos.z);\r\n // calc result AO-map color\r\n AO = 1.0 - max(0.0, AO / 32.0 * factor); // TODO use MAX_SAMPLES_COUNT\r\n vec3 color = texture2D(diffuseTexture, vUv).rgb;\r\n // check if the fragment doesn't belong to background\r\n if (abs(- viewPos.z - camNearFar.y) < 0.1) { // FIXME remove temporal fix for background darkening\r\n gl_FragColor = vec4(1.0);\r\n return;\r\n }\r\n // write value to AO-map\r\n gl_FragColor = vec4(AO, AO, AO, 1.0);\r\n}",x_="#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 res = vec4(0.0);\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n vec2 samplePos = vec2(x + samplesOffsets[i] * srcTexelSize.x, y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res += texture2D(aoMap, vec2(x + samplesOffsets[i] * srcTexelSize.x, y )) * weight;\r\n weightSum += weight;\r\n }\r\n gl_FragColor = res / weightSum;\r\n}\r\n",b_="#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 res = vec4(0.0);\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n vec2 samplePos = vec2(x, y + samplesOffsets[i] * srcTexelSize.y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res += texture2D(aoMap, vec2(x, y + samplesOffsets[i] * srcTexelSize.y)) * weight;\r\n weightSum += weight;\r\n }\r\n res /= weightSum;\r\n vec3 color = texture2D(diffuseTexture, vec2(x, y)).rgb;\r\n gl_FragColor = vec4(color * res.rgb, 1.0);\r\n}",w_=Ur.merge([{noiseTexture:{type:"t",value:null},noiseTexelSize:{type:"v2",value:new _e(1/512,1/512)},diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new _e(1/512,1/512)},camNearFar:{type:"v2",value:new _e(1,10)},projMatrix:{type:"mat4",value:new Xe},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0},samplesKernel:{type:"v3v",value:null},kernelRadius:{type:"f",value:1},depthThreshold:{type:"f",value:1},factor:{type:"f",value:1},fogNearFar:{type:"v2",value:new _e(100,100)}}]),S_=Ur.merge([{diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new _e(1/512,1/512)},aoMap:{type:"t",value:null},samplesOffsets:{type:"fv1",value:null},camNearFar:{type:"v2",value:new _e(1,10)},projMatrix:{type:"mat4",value:new Xe},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0}}]);function M_(t,e){var r=Ur.clone(e);for(var n in t)r.hasOwnProperty(n)&&(r[n].value=t[n]);return r}var A_={AOMaterial:function(t){return new dn({uniforms:M_(t,w_),vertexShader:p_,fragmentShader:__,transparent:!1,depthTest:!1,depthWrite:!1})},HorBilateralBlurMaterial:function(t){return new dn({uniforms:M_(t,S_),vertexShader:p_,fragmentShader:x_,transparent:!1,depthTest:!1,depthWrite:!1})},VertBilateralBlurMaterial:function(t){return new dn({uniforms:M_(t,S_),vertexShader:p_,fragmentShader:b_,transparent:!1,depthTest:!1,depthWrite:!1})}},E_="uniform sampler2D srcL;\r\nuniform sampler2D srcR;\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n vec4 l = texture2D(srcL, vUv);\r\n vec4 r = texture2D(srcR, vUv);\r\n gl_FragColor = vec4(l.r, r.g, r.b, 1.0);\r\n}\r\n",C_=Ur.merge([{srcL:{type:"t",value:null},srcR:{type:"t",value:null}}]);function T_(t){return new dn({uniforms:function(t){var e=Ur.clone(C_);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:p_,fragmentShader:E_,transparent:!1,depthTest:!1,depthWrite:!1})}function P_(){this.position=new He(0,0,0),this.scale=1,this.orientation=new We(0,0,0,1)}P_.prototype.set=function(t,e,r){this.position=t,this.scale=e,this.orientation=r};function L_(){}L_.prototype.setup=function(t,e){this._startTime=void 0,this._endTime=void 0,this._srcView=t,this._dstView=e,this._isMoving=!1},L_.prototype.isMoving=function(){return this._isMoving},L_.prototype.wasStarted=function(){return void 0!==this._startTime&&void 0!==this._endTime},L_.prototype.start=function(){this._startTime=Date.now();var t=Vu.now.interpolateViews?1500:0;this._endTime=this._startTime+t,this._isMoving=!0},L_.prototype.getCurrentView=function(){if(void 0===this._srcView||void 0===this._dstView||!this._isMoving||!this.wasStarted())return{success:!1};var t=this.createView(),e=Date.now();if(e>this._endTime)return t=this._dstView,this._reset(),{success:!0,view:t};var r=(e-this._startTime)/(this._endTime-this._startTime);return t.position.copy(this._srcView.position),t.position.lerp(this._dstView.position,r),t.scale=(1-r)*this._srcView.scale+r*this._dstView.scale,t.orientation.copy(this._srcView.orientation),t.orientation.slerp(this._dstView.orientation,r),{success:!0,view:t}},L_.prototype._reset=function(){this._startTime=this._endTime=0,this._isMoving=!1},L_.prototype.createView=function(){return new P_};var R_=new L_,N_=Vu.now.fbxprec,I_='; FBX 6.1.0 project file\n; Copyright (C) 1997-2007 Autodesk Inc. and/or its licensors.\n; All rights reserved.\n; ----------------------------------------------------\n\n FBXHeaderExtension: {\n FBXHeaderVersion: 1003\n FBXVersion: 6100\n CreationTimeStamp: {\n Version: 1000\n Year: 2015\n Month: 12\n Day: 7\n Hour: 17\n Minute: 34\n Second: 53\n Millisecond: 369\n }\n Creator: "FBX SDK/FBX Plugins build 20080212"\n OtherFlags: {\n FlagPLE: 0\n }\n}\nreationTime: "2015-12-07 17:34:53:369"\nreator: "FBX SDK/FBX Plugins build 20080212"\n\n; Document Description\n;------------------------------------------------------------------\n\n Document: {\n Name: ""\n}\n\n; Document References\n;------------------------------------------------------------------\n\n References: {\n}\n\n; Object definitions\n;------------------------------------------------------------------\n\n Definitions: {\n Version: 100\n Count: 3\n ObjectType: "Model" {\n Count: 1\n }\n ObjectType: "SceneInfo" {\n Count: 1\n }\n ObjectType: "GlobalSettings" {\n Count: 1\n }\n}\n\n; Object properties\n;------------------------------------------------------------------\n\n Objects: {\n Model: "Model::Sphere01", "Mesh" {\n Version: 232\n Properties60: {\n Property: "QuaternionInterpolate", "bool", "",0\n Property: "RotationOffset", "Vector3D", "",0,0,0\n Property: "RotationPivot", "Vector3D", "",0,0,0\n Property: "ScalingOffset", "Vector3D", "",0,0,0\n Property: "ScalingPivot", "Vector3D", "",0,0,0\n Property: "TranslationActive", "bool", "",0\n Property: "TranslationMin", "Vector3D", "",0,0,0\n Property: "TranslationMax", "Vector3D", "",0,0,0\n Property: "TranslationMinX", "bool", "",0\n Property: "TranslationMinY", "bool", "",0\n Property: "TranslationMinZ", "bool", "",0\n Property: "TranslationMaxX", "bool", "",0\n Property: "TranslationMaxY", "bool", "",0\n Property: "TranslationMaxZ", "bool", "",0\n Property: "RotationOrder", "enum", "",0\n Property: "RotationSpaceForLimitOnly", "bool", "",0\n Property: "RotationStiffnessX", "double", "",0\n Property: "RotationStiffnessY", "double", "",0\n Property: "RotationStiffnessZ", "double", "",0\n Property: "AxisLen", "double", "",10\n Property: "PreRotation", "Vector3D", "",0,0,0\n Property: "PostRotation", "Vector3D", "",0,0,0\n Property: "RotationActive", "bool", "",0\n Property: "RotationMin", "Vector3D", "",0,0,0\n Property: "RotationMax", "Vector3D", "",0,0,0\n Property: "RotationMinX", "bool", "",0\n Property: "RotationMinY", "bool", "",0\n Property: "RotationMinZ", "bool", "",0\n Property: "RotationMaxX", "bool", "",0\n Property: "RotationMaxY", "bool", "",0\n Property: "RotationMaxZ", "bool", "",0\n Property: "InheritType", "enum", "",1\n Property: "ScalingActive", "bool", "",0\n Property: "ScalingMin", "Vector3D", "",1,1,1\n Property: "ScalingMax", "Vector3D", "",1,1,1\n Property: "ScalingMinX", "bool", "",0\n Property: "ScalingMinY", "bool", "",0\n Property: "ScalingMinZ", "bool", "",0\n Property: "ScalingMaxX", "bool", "",0\n Property: "ScalingMaxY", "bool", "",0\n Property: "ScalingMaxZ", "bool", "",0\n Property: "GeometricTranslation", "Vector3D", "",0,0,0\n Property: "GeometricRotation", "Vector3D", "",0,0,0\n Property: "GeometricScaling", "Vector3D", "",1,1,1\n Property: "MinDampRangeX", "double", "",0\n Property: "MinDampRangeY", "double", "",0\n Property: "MinDampRangeZ", "double", "",0\n Property: "MaxDampRangeX", "double", "",0\n Property: "MaxDampRangeY", "double", "",0\n Property: "MaxDampRangeZ", "double", "",0\n Property: "MinDampStrengthX", "double", "",0\n Property: "MinDampStrengthY", "double", "",0\n Property: "MinDampStrengthZ", "double", "",0\n Property: "MaxDampStrengthX", "double", "",0\n Property: "MaxDampStrengthY", "double", "",0\n Property: "MaxDampStrengthZ", "double", "",0\n Property: "PreferedAngleX", "double", "",0\n Property: "PreferedAngleY", "double", "",0\n Property: "PreferedAngleZ", "double", "",0\n Property: "LookAtProperty", "object", ""\n Property: "UpVectorProperty", "object", ""\n Property: "Show", "bool", "",1\n Property: "NegativePercentShapeSupport", "bool", "",1\n Property: "DefaultAttributeIndex", "int", "",0\n Property: "Lcl Translation", "Lcl Translation", "A+",-0.169204741716385,-0.507614195346832,0\n Property: "Lcl Rotation", "Lcl Rotation", "A+",0,0,0\n Property: "Lcl Scaling", "Lcl Scaling", "A+",1,1,1\n Property: "Visibility", "Visibility", "A+",1\n Property: "BBoxMin", "Vector3D", "N",0,0,0\n Property: "BBoxMax", "Vector3D", "N",0,0,0\n }\n MultiLayer: 0\n MultiTake: 1\n Shading: T\n Culling: "CullingOff"\n',O_='NodeAttributeName: "Geometry::Sphere01"\n}\nceneInfo: "SceneInfo::GlobalInfo", "UserData" {\n Type: "UserData"\n Version: 100\n MetaData: {\n Version: 100\n Title: ""\n Subject: ""\n Author: ""\n Keywords: ""\n Revision: ""\n Comment: ""\n }\n Properties60: {\n Property: "DocumentUrl", "KString", "", "D:\\depot\\MolViewer\\Assets\\models\\test1.FBX"\n Property: "SrcDocumentUrl", "KString", "", "D:\\depot\\MolViewer\\Assets\\models\\test1.FBX"\n Property: "Original", "Compound", ""\n Property: "Original|ApplicationVendor", "KString", "", "Autodesk"\n Property: "Original|ApplicationName", "KString", "", "3ds Max"\n Property: "Original|ApplicationVersion", "KString", "", "2009.0"\n Property: "Original|DateTime_GMT", "DateTime", "", "07/12/2015 14:34:53.369"\n Property: "Original|FileName", "KString", "", "D:\\depot\\MolViewer\\Assets\\models\\test1.FBX"\n Property: "LastSaved", "Compound", ""\n Property: "LastSaved|ApplicationVendor", "KString", "", "Autodesk"\n Property: "LastSaved|ApplicationName", "KString", "", "3ds Max"\n Property: "LastSaved|ApplicationVersion", "KString", "", "2009.0"\n Property: "LastSaved|DateTime_GMT", "DateTime", "", "07/12/2015 14:34:53.369"\n }\n}\nlobalSettings: {\n Version: 1000\n Properties60: {\n Property: "UpAxis", "int", "",2\n Property: "UpAxisSign", "int", "",1\n Property: "FrontAxis", "int", "",1\n Property: "FrontAxisSign", "int", "",-1\n Property: "CoordAxis", "int", "",0\n Property: "CoordAxisSign", "int", "",1\n Property: "UnitScaleFactor", "double", "",2.54\n }\n}\n}\n\n; Object relations\n;------------------------------------------------------------------\n\n Relations: {\n Model: "Model::Sphere01", "Mesh" {\n }\n SceneInfo: "SceneInfo::GlobalInfo", "UserData" {\n }\n}\n\n; Object connections\n;------------------------------------------------------------------\n\n Connections: {\n Connect: "OO", "Model::Sphere01", "Model::Scene"\n}\n\n;Object data\n;------------------------------------------------------------------\n\n ObjectData: {\n}\n;Takes and animation section\n;----------------------------------------------------\n\n Takes: {\n Current: "Take 001"\n}\n;Version 5 settings\n;------------------------------------------------------------------\n\n Version5: {\n AmbientRenderSettings: {\n Version: 101\n AmbientLightColor: 0.533333003520966,0.533333003520966,0.533333003520966,1\n }\n FogOptions: {\n FlogEnable: 0\n FogMode: 0\n FogDensity: 0.002\n FogStart: 0.3\n FogEnd: 1000\n FogColor: 1,1,1,1\n }\n Settings: {\n FrameRate: "30"\n TimeFormat: 1\n SnapOnFrames: 0\n ReferenceTimeIndex: -1\n TimeLineStartTime: 0\n TimeLineStopTime: 153953860000\n }\n RendererSetting: {\n DefaultCamera: ""\n DefaultViewingMode: 0\n }\n}\n\n';function D_(t){var e;switch(t.code){case FileError.QUOTA_EXCEEDED_ERR:e="QUOTA_EXCEEDED_ERR";break;case FileError.NOT_FOUND_ERR:e="NOT_FOUND_ERR";break;case FileError.SECURITY_ERR:e="SECURITY_ERR";break;case FileError.INVALID_MODIFICATION_ERR:e="INVALID_MODIFICATION_ERR";break;case FileError.INVALID_STATE_ERR:e="INVALID_STATE_ERR";break;default:e="Unknown Error"}throw new Error(e)}var F_=null;function z_(){}function k_(t){for(var e=[],r=0,n=t.length;r0?t.write(o):i()},t.truncate(0))},D_)},D_))};function G_(t,e){this.context=t,this._opts=n.merge({path:"/"},e)}yf(G_.prototype),G_.prototype.removeCookie=function(t){var e=this._toCount(t),r=this._getSimpleCookie(e);if(r){this._removeSimpleCookie(e),r=parseInt(r,10);for(var n=0;n0?e(t[0],i):r(i)}),i}var o=document.createElement("a");return o.href="https://webvr.info",o.innerHTML="WEBVR NOT SUPPORTED",o.style.left="calc(50% - 90px)",o.style.width="180px",o.style.textDecoration="none",n(o),o}}]),t}(),sx=Jp.selectors,lx=Jp.Atom,cx=Jp.Residue,ux=Jp.Chain,hx=Jp.Molecule,px=0,fx=1,dx=2,mx=Cu.createElement;function gx(t){var e=t.lastIndexOf(".");return e>=0&&(t=t.substr(0,e)),t}function vx(t,e,r){void 0!==r?t.debug(e+"... "+Math.floor(100*r)+"%"):t.debug(e+"...")}function yx(t){su.call(this),this._opts=n.merge({settingsCookie:"settings",cookiePath:"/"},t),this._gfx=null,this._container=t&&t.container||document.getElementById("miew-container")||n.head(document.getElementsByClassName("miew-container"))||document.body,this._containerRoot=this._container,this._running=!1,this._halting=!1,this._building=!1,this._needRender=!0,this._hotKeysEnabled=!0,this.settings=Vu;var e=hu;e.console=!1,e.level="info",this.logger=e,this._cookies=new G_(this),this._loadSettings(),t&&t.settings&&this.settings.override(t.settings),this._spinner=null,this._loading=[],this._animInterval=null,this._visuals={},this._curVisualName=null,this._objects=[],this._sourceWindow=null,this._srvTopoSource=null,this._srvAnimSource=null,this.reset(),this._repr&&e.debug("Selected "+this._repr.mode.name+" mode with "+this._repr.colorer.name+" colorer.");var r=this;yx.registeredPlugins.forEach(function(t){t.call(r)})}function _x(t,e){for(var r=t;r.firstChild;)r.removeChild(r.firstChild);r.appendChild(e)}yx.prototype=Object.create(su.prototype),yx.prototype.constructor=yx,yx.prototype.getMaxRepresentationCount=function(){return Sv.NUM_REPRESENTATION_BITS},yx.prototype.init=function(){var t=this._container,e=Cu.createElement("div",{class:"miew-canvas"});_x(t,e),this._container=e;var r=document.createDocumentFragment();if(r.appendChild(this._msgMode=mx("div",{class:"mode-message overlay"},mx("p",{},"COMPONENT EDIT MODE"))),r.appendChild(this._msgAtomInfo=mx("div",{class:"atom-info overlay"},mx("p",{},""))),t.appendChild(r),null!==this._gfx)return!0;var n=this;this._showMessage("Viewer is being initialized...");try{this._initGfx(),this._initListeners(),this._spinner=new ou({lines:13,length:28,width:14,radius:42,color:"#fff",zIndex:700}),window.top.addEventListener("keydown",function(t){n._onKeyDown(t)}),window.top.addEventListener("keyup",function(t){n._onKeyUp(t)}),this._objectControls=new Jy(this._gfx.root,this._gfx.pivot,this._gfx.camera,this._gfx.renderer.domElement,function(){return n._getAltObj()}),this._objectControls.addEventListener("change",function(t){switch(t.action){case"rotate":n.dispatchEvent({type:"rotate",angle:t.angle});break;case"zoom":n.dispatchEvent({type:"zoom",factor:t.factor})}n.dispatchEvent({type:"transform"}),n._needRender=!0});var i=this._gfx;this._picker=new t_(i.root,i.camera,i.renderer.domElement),this._picker.addEventListener("newpick",function(t){n._onPick(t)}),this._picker.addEventListener("dblclick",function(t){n._onDblClick(t)}),this._onThemeChanged()}catch(t){if("TypeError"!==t.name||"Cannot read property 'getExtension' of null"!==t.message)throw this._showMessage("Viewer initialization failed."),t;return this._showMessage("Could not create WebGL context."),!1}var o=this._opts&&this._opts.load;if(o){var a=this._opts&&this._opts.type;this.load(o,{fileType:a,keepRepsInfo:!0})}return!0},yx.prototype.term=function(){this._showMessage("Viewer has been terminated."),this._loading.forEach(function(t){t.cancel()}),this._loading.length=0,this.halt(),this._gfx=null},yx.prototype._showMessage=function(t){var e=document.createElement("div");e.setAttribute("class","miew-message"),e.appendChild(document.createElement("p")).appendChild(document.createTextNode(t)),_x(this._container,e)},yx.prototype._showCanvas=function(){_x(this._container,this._gfx.renderer.domElement)},yx.prototype._initGfx=function(){var t={width:this._container.clientWidth,height:this._container.clientHeight},e={preserveDrawingBuffer:!0};Vu.now.antialias&&(e.antialias=!0),t.renderer2d=new $y,t.renderer=new ko(e),of.init(t.renderer),t.renderer.getContext().getExtension("EXT_frag_depth")||(Vu.now.zSprites=!1),t.renderer.getContext().getExtension("WEBGL_depth_texture")||(Vu.now.ao=!1),t.renderer.autoClear=!1,t.renderer.setPixelRatio(window.devicePixelRatio),t.renderer.setSize(t.width,t.height),t.renderer.setClearColor(Vu.now.themes[Vu.now.theme]),t.renderer.clearColor(),t.renderer2d.setSize(t.width,t.height),t.camera=new Yn(Vu.now.camFov,t.width/t.height,Vu.now.camNear,Vu.now.camFar),t.camera.setMinimalFov(Vu.now.camFov),t.camera.position.z=Vu.now.camDistance,t.camera.updateProjectionMatrix(),t.camera.layers.set(mf.LAYERS.DEFAULT),t.camera.layers.enable(mf.LAYERS.VOLUME),t.camera.layers.enable(mf.LAYERS.VOLUME_BFPLANE),t.stereoCam=new tc,t.scene=new Vo,t.scene.fog=new Bo(Vu.now.themes[Vu.now.theme],Vu.now.camNear,Vu.now.camFar),t.root=new mf.RCGroup,t.scene.add(t.root),t.pivot=new mf.RCGroup,t.root.add(t.pivot),t.selectionScene=new Vo,t.selectionRoot=new ea,t.selectionRoot.matrixAutoUpdate=!1,t.selectionScene.add(t.selectionRoot),t.selectionPivot=new ea,t.selectionPivot.matrixAutoUpdate=!1,t.selectionRoot.add(t.selectionPivot);var r=new vs(16777215,.45);r.position.set(0,.414,1),r.layers.enable(mf.LAYERS.TRANSPARENT),t.scene.add(r);var n=new ys(6710886);n.layers.enable(mf.LAYERS.TRANSPARENT),t.scene.add(n),t.axes=new e_(t.root,t.camera),t.offscreenBuf=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:_t,format:Ut,depthBuffer:!0}),t.renderer.getContext().getExtension("WEBGL_depth_texture")&&(t.offscreenBuf.depthTexture=new ia,t.offscreenBuf.depthTexture.type=Tt),t.offscreenBuf2=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,depthBuffer:!1}),t.offscreenBuf3=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,depthBuffer:!1}),t.offscreenBuf4=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,depthBuffer:!1}),t.volBFTex=t.offscreenBuf3,t.volFFTex=t.offscreenBuf4,t.volWFFTex=t.offscreenBuf,t.renderer.getContext().getExtension("OES_texture_float")?(t.offscreenBuf5=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,type:Rt,depthBuffer:!1}),t.offscreenBuf6=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,type:Rt,depthBuffer:!1}),t.offscreenBuf7=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,type:Rt,depthBuffer:!0}),t.volBFTex=t.offscreenBuf5,t.volFFTex=t.offscreenBuf6,t.volWFFTex=t.offscreenBuf7):this.logger.warn("Device doesn't support OES_texture_float extension"),t.stereoBufL=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,depthBuffer:!1}),t.stereoBufR=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,depthBuffer:!1}),this._toggleWebVR("WEBVR"===Vu.now.stereo,t),this._gfx=t,this._showCanvas(),this._container.appendChild(t.renderer2d.getElement());var i=new Lu;i.domElement.style.position="absolute",i.domElement.style.right="0",i.domElement.style.bottom="0",this._container.appendChild(i.domElement),this._fps=i,this._fps.show(Vu.now.fps)},yx.prototype._initListeners=function(){var t=this;window.addEventListener("resize",function(){t._onResize()})},yx.prototype._makeUniqueVisualName=function(t){if(!t)return Math.random().toString();for(var e=t,r=1;this._visuals.hasOwnProperty(e);)e=t+" ("+r.toString()+")",r++;return e},yx.prototype._addVisual=function(t){if(!t)return null;var e=this._makeUniqueVisualName(t.name);return t.name=e,this._visuals[e]=t,this._gfx.pivot.add(t),t.getSelectionGeo&&this._gfx.selectionPivot.add(t.getSelectionGeo()),e},yx.prototype._removeVisual=function(t){var e="",r=null;t instanceof vf?(e=t.name,r=t):"string"==typeof t&&(e=t,r=this._visuals[e]),r&&this._visuals.hasOwnProperty(e)&&this._visuals[e]===r&&(e===this._curVisualName&&(this._curVisualName=void 0),delete this._visuals[e],r.release(),this._needRender=!0)},yx.prototype._forEachVisual=function(t){for(var e in this._visuals)this._visuals.hasOwnProperty(e)&&t(this._visuals[e])},yx.prototype._releaseAllVisuals=function(){if(this._gfx&&this._gfx.pivot){for(var t in this._visuals)this._visuals.hasOwnProperty(t)&&this._visuals[t].release();this._visuals={}}},yx.prototype._forEachComplexVisual=function(t){if(this._gfx&&this._gfx.pivot)for(var e in this._visuals)this._visuals.hasOwnProperty(e)&&this._visuals[e]instanceof Sv&&t(this._visuals[e])},yx.prototype._getComplexVisual=function(t){t=t||this._curVisualName;var e=null,r=null;return this._forEachComplexVisual(function(n){e=n,n.name===t&&(r=n)}),r||e},yx.prototype._getVolumeVisual=function(){var t=null;return this._forEachVisual(function(e){e instanceof Ov&&(t=e)}),t},yx.prototype._getVisualForComplex=function(t){if(!t)return null;var e=null;return this._forEachComplexVisual(function(r){r.getComplex()===t&&(e=r)}),e},yx.prototype.getVisuals=function(){return Object.keys(this._visuals)},yx.prototype.getCurrentVisual=function(){return this._curVisualName},yx.prototype.setCurrentVisual=function(t){this._visuals[t]&&(this._curVisualName=t)},yx.prototype.run=function(){var t=this;if(!this._running){if(this._running=!0,this._halting)return void(this._halting=!1);this._objectControls.enable(!0),(this._getWebVRDevice()||window).requestAnimationFrame(function(){return t._onTick()})}},yx.prototype.halt=function(){this._running&&(this._discardComponentEdit(),this._discardFragmentEdit(),this._objectControls.enable(!1),this._halting=!0)},yx.prototype.enableHotKeys=function(t){this._hotKeysEnabled=t,this._objectControls.enableHotkeys(t)},yx.prototype._onResize=function(){this._needRender=!0;var t=this._gfx;t.width=this._container.clientWidth,t.height=this._container.clientHeight,t.camera.aspect=t.width/t.height,t.camera.setMinimalFov(Vu.now.camFov),t.camera.updateProjectionMatrix(),t.renderer.setSize(t.width,t.height),t.renderer2d.setSize(t.width,t.height),this.dispatchEvent({type:"resize"})},yx.prototype._resizeOffscreenBuffers=function(t,e,r){var n=this._gfx,i="NONE"===(r=r||"NONE")||"ANAGLYPH"===r,o=i?1:.5;n.offscreenBuf.setSize(o*t,e),n.offscreenBuf2.setSize(o*t,e),n.offscreenBuf3.setSize(o*t,e),n.offscreenBuf5&&n.offscreenBuf5.setSize(o*t,e),n.offscreenBuf6&&n.offscreenBuf6.setSize(o*t,e),n.offscreenBuf7&&n.offscreenBuf7.setSize(o*t,e),i&&(n.stereoBufL.setSize(t,e),n.stereoBufR.setSize(t,e))},yx.prototype._onTick=function(){var t=this;if(this._halting)return this._running=!1,void(this._halting=!1);this._fps.update();var e=this._getWebVRDevice();(e||window).requestAnimationFrame(function(){return t._onTick()}),this._onUpdate(),this._needRender&&(this._onRender(),this._needRender=!Vu.now.suspendRender||"WEBVR"===Vu.now.stereo||!!e)},yx.prototype._toggleWebVR=(W_=new Yn,H_=!1,X_=null,function(t,e){var r=e?e.renderer:null;if(!r)throw new Error("No renderer is available to toggle WebVR");if(!e.camera)throw new Error("No camera is available to toggle WebVR");t?(W_.copy(e.camera),H_=!0,r.vr.enabled=!0,X_?X_.style.display="block":(X_=ax.createButton(r),document.body.appendChild(X_))):(r.vr.enabled=!1,X_&&(X_.style.display="none"),H_&&(e.camera.copy(W_),this._onResize())),this._needRender=!0}),yx.prototype._getWebVRDevice=function(){var t=this._gfx.renderer.vr;return t&&t.enabled?t.getDevice():null},yx.prototype._getBSphereRadius=function(){var t=0;return this._forEachVisual(function(e){t=Math.max(t,e.getBoundaries().boundingSphere.radius)}),t*this._objectControls.getScale()},yx.prototype._updateFog=function(){var t,e,r,n=this._gfx;Vu.now.fog?(void 0!==n.scene.fog&&null!==n.scene.fog||(n.scene.fog=new Bo(Vu.now.themes[Vu.now.theme]),this._setUberMaterialValues({fog:Vu.now.fog})),t=n.scene.fog,e=n.camera.position.z,r=this._getBSphereRadius(),t.near=e-r*Vu.now.fogNearFactor,t.far=e+r*Vu.now.fogFarFactor):n.scene.fog&&(n.scene.fog=void 0,this._setUberMaterialValues({fog:Vu.now.fog}))},yx.prototype._onUpdate=function(){void 0!==this.isScriptingCommandAvailable&&this.isScriptingCommandAvailable()&&!this._building&&this.callNextCmd(),this._objectControls.update(),this._forEachComplexVisual(function(t){t.getComplex().update()}),Vu.now.autobuild&&!this._loading.length&&!this._building&&this._needRebuild()&&this.rebuild(),this._loading.length||this._building||this._needRebuild()||this._updateView(),this._updateFog()},yx.prototype._onRender=function(){var t=this._gfx;t.scene.updateMatrixWorld(),t.camera.updateMatrixWorld(),this._clipPlaneUpdateValue(this._getBSphereRadius()),this._fogFarUpdateValue(),t.renderer.clearTarget(null),this._renderFrame(Vu.now.stereo)},yx.prototype._renderFrame=(Y_=new T_,function(t){var e=this._gfx,r=e.renderer;"NONE"!==t&&(e.stereoCam.aspect="ANAGLYPH"===t?1:.5,e.camera.focus=e.camera.position.z,e.stereoCam.update(e.camera));var n=r.getSize();switch(this._resizeOffscreenBuffers(n.width*window.devicePixelRatio,n.height*window.devicePixelRatio,t),t){case"WEBVR":case"NONE":this._renderScene(e.camera,!1);break;case"SIMPLE":case"DISTORTED":r.setScissorTest(!0),r.setScissor(0,0,n.width/2,n.height),r.setViewport(0,0,n.width/2,n.height),this._renderScene(this._gfx.stereoCam.cameraL,"DISTORTED"===t),r.setScissor(n.width/2,0,n.width/2,n.height),r.setViewport(n.width/2,0,n.width/2,n.height),this._renderScene(this._gfx.stereoCam.cameraR,"DISTORTED"===t),r.setScissorTest(!1);break;case"ANAGLYPH":this._renderScene(this._gfx.stereoCam.cameraL,!1,e.stereoBufL),this._renderScene(this._gfx.stereoCam.cameraR,!1,e.stereoBufR),Y_.uniforms.srcL.value=e.stereoBufL,Y_.uniforms.srcR.value=e.stereoBufR,e.renderer.renderScreenQuad(Y_)}e.renderer2d.render(e.scene,e.camera),Vu.now.axes&&e.axes&&!e.renderer.vr.enabled&&e.axes.render(r)}),yx.prototype._onThemeChanged=(q_=/\s*theme-\w+\b/g,function(){var t=Vu.now.theme,e=this._containerRoot;e.className=e.className.replace(q_,"")+" theme-"+t;var r=this._gfx;if(r){var n=Vu.now.themes[t];r.scene.fog&&r.scene.fog.color.set(n),r.renderer.setClearColor(n)}}),yx.prototype._setUberMaterialValues=function(t){this._gfx.root.traverse(function(e){(e instanceof io||e instanceof Ko||e instanceof $o)&&e.material instanceof lf&&(e.material.setValues(t),e.material.needsUpdate=!0)})},yx.prototype._renderScene=function(t,e,r){e=e||!1,r=r||null;var n=this._gfx;if(n.renderer.setClearColor(Vu.now.themes[Vu.now.theme],1),n.renderer.clearTarget(r),n.renderer.vr.enabled)n.renderer.render(n.scene,t);else{n.renderer.clearTarget(n.offscreenBuf),"prepass"===Vu.now.transparency?this._renderWithPrepassTransparency(t,n.offscreenBuf):"standard"===Vu.now.transparency&&n.renderer.render(n.scene,t,n.offscreenBuf);var i=null!==this._getComplexVisual(),o=this._getVolumeVisual(),a=i&&Vu.now.fxaa,s=null!==o&&null!=o.getMesh().material,l=s||a||e?n.offscreenBuf2:r,c=n.offscreenBuf;i&&Vu.now.ao?this._performAO(c,n.offscreenBuf.depthTexture,l,n.offscreenBuf3,n.offscreenBuf2):n.renderer.renderScreenQuadFromTex(c.texture,1,l),this._renderSelection(t,c,l),s&&(n.renderer.renderScreenQuadFromTex(l.texture,1,n.offscreenBuf),l=n.offscreenBuf,this._renderVolume(o,t,l,n.volBFTex,n.volFFTex,n.volWFFTex),a||e||n.renderer.renderScreenQuadFromTex(l.texture,1,r)),c=l,a&&(l=e?n.offscreenBuf3:r,this._performFXAA(c,l),c=l),e&&(l=r,this._performDistortion(c,l,!0))}},yx.prototype._performDistortion=(Z_=new Vo,$_=new Xn(-1,1,1,-1,-500,1e3),K_=new dn({uniforms:{srcTex:{type:"t",value:null},aberration:{type:"fv3",value:new He(1)}},vertexShader:"varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }",fragmentShader:"varying vec2 vUv; uniform sampler2D srcTex; uniform vec3 aberration;void main() {vec2 uv = vUv * 2.0 - 1.0;gl_FragColor.r = texture2D(srcTex, 0.5 * (uv * aberration[0] + 1.0)).r;gl_FragColor.g = texture2D(srcTex, 0.5 * (uv * aberration[1] + 1.0)).g;gl_FragColor.b = texture2D(srcTex, 0.5 * (uv * aberration[2] + 1.0)).b;gl_FragColor.a = 1.0;}",transparent:!1,depthTest:!1,depthWrite:!1}),Q_=mf.buildDistorionMesh(10,10,Vu.now.debug.stereoBarrel),Z_.add(new Zd.Mesh(Q_,K_)),function(t,e,r){this._gfx.renderer.clearTarget(e),r?(K_.uniforms.srcTex.value=t.texture,K_.uniforms.aberration.value.set(.995,1,1.01),this._gfx.renderer.render(Z_,$_,e)):this._gfx.renderer.renderScreenQuadFromTexWithDistortion(t,Vu.now.debug.stereoBarrel,e)}),yx.prototype._renderSelection=(J_=new m_,function(t,e,r){var n=this._gfx;n.renderer.setClearColor("black",0),n.renderer.clearTarget(e,!0,!1,!1),n.selectionPivot.children.length>0?(n.selectionRoot.matrix=n.root.matrix,n.selectionPivot.matrix=n.pivot.matrix,n.renderer.render(n.selectionScene,t,e)):n.renderer.renderDummyQuad(e),n.renderer.renderScreenQuadFromTex(e.texture,.6,r),J_.uniforms.srcTex.value=e.texture,J_.uniforms.srcTexSize.value.set(e.width,e.height),n.renderer.renderScreenQuad(J_,r)}),yx.prototype._checkVolumeRenderingSupport=function(t){if(!t)return!1;var e=this._gfx,r=e.renderer.getRenderTarget();e.renderer.setRenderTarget(t);var n=e.renderer.getContext(),i=n.checkFramebufferStatus(n.FRAMEBUFFER);return e.renderer.setRenderTarget(r),i===n.FRAMEBUFFER_COMPLETE||(this.logger.warn("Device doesn't support electron density rendering"),!1)},yx.prototype._renderVolume=(ex=new Nv.BackFacePosMaterial,rx=new Nv.FrontFacePosMaterial,nx=(new Xe).makeTranslation(.5,.5,.5),ix=new Xe,function(t,e,r,n,i,o){var a=this._gfx;if(void 0===tx&&(tx=this._checkVolumeRenderingSupport(n)),tx){var s=t.getMesh();s.rebuild(e),a.renderer.setClearColor("black",0),a.renderer.clearTarget(n),a.renderer.clearTarget(i),a.renderer.clearTarget(o),e.layers.set(mf.LAYERS.VOLUME_BFPLANE),a.renderer.render(a.scene,e,n),e.layers.set(mf.LAYERS.VOLUME),a.scene.overrideMaterial=ex,a.renderer.render(a.scene,e,n),e.layers.set(mf.LAYERS.VOLUME),a.scene.overrideMaterial=rx,a.renderer.render(a.scene,e,i),a.scene.overrideMaterial=null,e.layers.set(mf.LAYERS.DEFAULT),ix.getInverse(s.matrixWorld),lf.prototype.uberOptions.world2colorMatrix.multiplyMatrices(nx,ix),this._setUberMaterialValues({colorFromPos:!0}),a.renderer.render(a.scene,e,o),this._setUberMaterialValues({colorFromPos:!1});var l=s.material;l.uniforms._BFRight.value=n.texture,l.uniforms._FFRight.value=i.texture,l.uniforms._WFFRight.value=o.texture,e.layers.set(mf.LAYERS.VOLUME),a.renderer.render(a.scene,e,r),e.layers.set(mf.LAYERS.DEFAULT)}}),yx.prototype._renderWithPrepassTransparency=function(t,e){var r=this._gfx;t.layers.set(mf.LAYERS.DEFAULT),r.renderer.render(r.scene,t,e),t.layers.set(mf.LAYERS.PREPASS_TRANSPARENT),r.renderer.context.colorMask(!1,!1,!1,!1),r.renderer.render(r.scene,t,e),r.renderer.context.colorMask(!0,!0,!0,!0),t.layers.set(mf.LAYERS.TRANSPARENT),r.renderer.render(r.scene,t,e),t.layers.set(mf.LAYERS.DEFAULT)},yx.prototype._performFXAA=(ox=new y_,function(t,e){if(void 0!==t&&void 0!==e){var r=this._gfx;r.renderer.setClearColor(Vu.now.themes[Vu.now.theme],1),r.renderer.clearTarget(e),ox.uniforms.srcTex.value=t.texture,ox.uniforms.srcTexelSize.value.set(1/t.width,1/t.height),ox.transparent=!0,r.renderer.renderScreenQuad(ox,e)}}),yx.prototype._performAO=function(){var t=new A_.AOMaterial,e=new A_.HorBilateralBlurMaterial,r=new A_.VertBilateralBlurMaterial,n=new Ye(new Uint8Array([0,0,0,66,0,0,77,0,0,155,62,0,0,247,0,33,0,0,0,0,0,235,0,0,0,0,0,176,44,0,232,46,0,0,29,0,0,0,0,78,197,0,93,0,0,0,0,0]),4,4,kt,At,300,gt,gt,_t,_t,1);n.needsUpdate=!0;var i=[new He(.295184,.077723,.068429),new He(-.271976,-.365221,.838363),new He(.547713,.467576,.488515),new He(.662808,-.031733,.584758),new He(-.025717,.218955,.657094),new He(-.310153,-.365223,.370701),new He(-.101407,-.006313,.747665),new He(-.769138,.360399,.086847),new He(-.271988,-.27514,.905353),new He(.09674,-.566901,.700151),new He(.562872,-.735136,.094647),new He(.379877,.359278,.190061),new He(.519064,-.023055,.405068),new He(-.301036,.114696,.088885),new He(-.282922,.598305,.487214),new He(-.181859,.25167,.679702),new He(-.191463,-.635818,.512919),new He(-.293655,.427423,.078921),new He(-.267983,.680534,.13288),new He(.139611,.319637,.477439),new He(-.352086,.31104,.653913),new He(.321032,.805279,.487345),new He(.073516,.820734,.414183),new He(-.155324,.589983,.41146),new He(.335976,.170782,.527627),new He(.46346,-.355658,.167689),new He(.222654,.59655,.769406),new He(.922138,-.04207,.147555),new He(-.72705,-.329192,.369826),new He(-.090731,.53382,.463767),new He(-.323457,-.876559,.238524),new He(-.663277,-.372384,.342856)],o=[-2,-1,0,1,2];return function(a,s,l,c,u){if(void 0!==a&&void 0!==s&&void 0!==l&&void 0!==c&&void 0!==u){var h=this._gfx;t.uniforms.diffuseTexture.value=a.texture,t.uniforms.depthTexture.value=s,t.uniforms.srcTexelSize.value.set(1/a.width,1/a.height),t.uniforms.camNearFar.value.set(h.camera.near,h.camera.far),t.uniforms.projMatrix.value=h.camera.projectionMatrix,t.uniforms.aspectRatio.value=h.camera.aspect,t.uniforms.tanHalfFOV.value=Math.tan(.5*ye.DEG2RAD*h.camera.fov),t.uniforms.samplesKernel.value=i;var p=new He,f=new We,d=new He;h.root.matrix.decompose(p,f,d),t.uniforms.kernelRadius.value=Vu.now.debug.ssaoKernelRadius*d.x,t.uniforms.depthThreshold.value=2*this._getBSphereRadius(),t.uniforms.factor.value=Vu.now.debug.ssaoFactor,t.uniforms.noiseTexture.value=n,t.uniforms.noiseTexelSize.value.set(.25,.25);var m=h.scene.fog;m&&t.uniforms.fogNearFar.value.set(m.near,m.far),t.transparent=!1,h.renderer.renderScreenQuad(t,u),e.uniforms.aoMap.value=u.texture,e.uniforms.srcTexelSize.value.set(1/u.width,1/u.height),e.uniforms.depthTexture.value=s,e.uniforms.samplesOffsets.value=o,h.renderer.renderScreenQuad(e,c),r.uniforms.aoMap.value=c.texture,r.uniforms.diffuseTexture.value=a.texture,r.uniforms.srcTexelSize.value.set(1/c.width,1/c.height),r.uniforms.depthTexture.value=s,r.uniforms.samplesOffsets.value=o,h.renderer.renderScreenQuad(r,l)}}}(),yx.prototype.reset=function(){this._picker&&this._picker.reset(),this._lastPick=null,this._releaseAllVisuals(),this._setEditMode(px),this._resetObjects(),this._gfx&&(mf.clearTree(this._gfx.pivot),this._gfx.renderer2d.reset()),this.setNeedRender()},yx.prototype._resetScene=function(){this._objectControls.reset(),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this.resetReps(),this.resetPivot(),this.rebuildAll()},yx.prototype.resetView=function(){this._picker&&this._picker.reset(),this._setEditMode(px),this._resetScene(),this._forEachComplexVisual(function(t){t.updateSelectionMask({}),t.rebuildSelectionGeometry()})},yx.prototype.load=function(t,e){var r=this;e=n.merge({},e,{context:this}),this.settings.now.use.multiFile||(this._loading.length&&(this._loading.forEach(function(t){t.cancel()}),this._loading.length=0),e.animation||this.reset(!0)),this.dispatchEvent({type:"load",options:e,source:t});var i=new ku;this._loading.push(i),i.addEventListener("notification",function(t){r.dispatchEvent(t.slaveEvent)}),this._spinner.spin(this._container);var o,a,s,l=function(t){var e=r._loading.indexOf(i);return-1!==e&&r._loading.splice(e,1),r._spinner.stop(),r._refreshTitle(),t};return(o=t,a=e,s=i,new Promise(function(t){if(s.shouldCancel())throw new Error("Operation cancelled");o=function(t,e){if(!n.isString(t))return t;var r=bx.exec(t);if(r){var i=Fu(r,3),o=i[1],a=void 0===o?"pdb":o,s=i[2];switch(a=a.toLowerCase(),s=s.toUpperCase(),a){case"pdb":t="http://files.rcsb.org/download/"+s+".pdb";break;case"cif":t="http://files.rcsb.org/download/"+s+".cif";break;case"mmtf":t="http://mmtf.rcsb.org/v1.0/full/"+s;break;case"ccp4":t="https://www.ebi.ac.uk/pdbe/coordinates/files/"+s.toLowerCase()+".ccp4";break;default:throw new Error("Unexpected data format shortcut")}return e.fileType=a,e.fileName=s+"."+a,e.sourceType="url",t}var l=wx.exec(t);if(l){var c=l[1].toLowerCase();return t="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/"+c+"/JSON?record_type=3d",e.fileType="pubchem",e.fileName=c+".json",e.sourceType="url",t}return"url"!==e.sourceType&&void 0!==e.sourceType||(e.sourceType="url",Sx.test(t)||(t=Cu.resolveURL(t))),t}(o,a);var e=n.head(qy.loaders.find({type:a.sourceType,source:o}));if(!e)throw new Error("Could not find suitable loader for this source");var r=a.fileName||e.extractName(o);if(r){var i=Cu.splitFileName(r),l=Fu(i,2),c=l[0],u=l[1];n.defaults(a,{name:c,fileExt:u,fileName:r})}!function(t){var e=t.binary;if(void 0!==t.fileType){var r=n.head(qy.parsers.find({format:t.fileType}));if(!r)throw new Error("Could not find suitable parser for this format");e=r.binary||!1}if(void 0===e&&void 0!==t.fileExt){var i=n.head(qy.parsers.find({ext:t.fileExt}));i&&(e=i.binary||!1)}void 0!==t.fileExt&&".man"===t.fileExt.toLowerCase()&&(t.binary=!0,t.animation=!0),void 0!==e&&void 0!==t.binary&&t.binary!==e&&t.context.logger.warn("Overriding incorrect binary mode"),t.binary=e||!1}(a);var h=n.get(a,"preset.expression");if(!n.isUndefined(h)&&(h=JSON.parse(h))&&h.settings)for(var p=["singleUnit","draft.waterBondingHack"],f=0,d=p.length;f0?vx(v.logger,"Fetching",t.loaded/t.total):vx(v.logger,"Fetching")});var y=v.load().then(function(t){return a.context.logger.info("Fetching finished"),s.notify({type:"fetchingFinished",data:t}),t}).catch(function(t){throw a.context.logger.debug(t.message),t.stack&&a.context.logger.debug(t.stack),a.context.logger.error("Fetching failed"),s.notify({type:"fetchingFinished",error:t}),t});t(y)})).then(function(t){return r=t,n=e,o=i,new Promise(function(t,e){if(o.shouldCancel())throw new Error("Operation cancelled");if(o.notify({type:"convert"}),n.mdFile){for(var i=new Array(r.length),a=0;a0?"Bio molecule "+n:"Asymmetric unit")+")"}if(!r)throw new Error("There is no complex to change!");return r.getComplex().setCurrentStructure(t)&&this._resetScene(),""},yx.prototype.rebuild=function(){if(this._building)this.logger.warn("Miew.rebuild(): already building!");else{this._building=!0,this.dispatchEvent({type:"rebuild"}),this._rebuildObjects(),this._gfx.renderer2d.reset();var t=[];this._forEachComplexVisual(function(e){e.needsRebuild()&&t.push(e.rebuild().then(function(){return new Promise(function(t){e.rebuildSelectionGeometry(),t()})}))});var e=this;this._spinner.spin(this._container),Promise.all(t).then(function(){e._spinner.stop(),e._needRender=!0,e._refreshTitle(),e._building=!1})}},yx.prototype.rebuildAll=function(){this._forEachComplexVisual(function(t){t.setNeedsRebuild()})},yx.prototype._refreshTitle=function(t){var e;t=void 0===t?"":t;var r=this._getComplexVisual();if(r){e=r.getComplex().name;var n=r.repGet(r.repCurrent());e+=n?" – "+n.mode.name+" Mode":""}else e=Object.keys(this._visuals).length>0?"Unknown":"No Data";e+=t,this.dispatchEvent({type:"titleChanged",data:e})},yx.prototype.setNeedRender=function(){this._needRender=!0},yx.prototype._extractRepresentation=function(){var t=this,e=[];this._forEachComplexVisual(function(r){if(0!==r.getSelectionCount()){var n=r.buildSelectorFromMask(1<0&&(this.logger.report("New representation from selection for complexes: "+e.join(", ")),this.dispatchEvent({type:"repAdd"}))},yx.prototype._setReps=function(t){t=t||this._opts&&this._opts.reps||[],this._forEachComplexVisual(function(e){return e.resetReps(t)})},yx.prototype.applyPreset=function(t){for(var e=Vu.now.presets,r=[t||Vu.defaults.preset,Vu.defaults.preset,Object.keys(e)[0]],n=null,i=0;!n&&i0&&t.push(e)}),1===t.length){var e=t[0].beginFragmentEdit();e&&(this._editors=[e],this.logger.info("FRAGMENT EDIT MODE -- ON (single bond)"),this._setEditMode(dx),this._objectControls.allowTranslation(!1),this._objectControls.allowAltObjFreeRotation(e.isFreeRotationAllowed()),this._needRender=!0)}}},yx.prototype._applyFragmentEdit=function(){if(this._editMode===dx){this._objectControls.stop();for(var t=0;t0){if(t){t=null;break}t=r}}if(t)return t}return{objects:[],pivot:new He(0,0,0)}},yx.prototype.resetPivot=function(){var t=new vn;this._forEachVisual(function(e){t.union(e.getBoundaries().boundingBox)}),t.getCenter(this._gfx.pivot.position),this._gfx.pivot.position.negate(),this.dispatchEvent({type:"transform"})},yx.prototype.setPivotResidue=function(t){var e=this._getVisualForComplex(t.getChain().getComplex());if(e){var r=this._gfx.pivot.position;if(t._controlPoint)r.copy(t._controlPoint);else{for(var n=0,i=0,o=0,a=t._atoms.length,s=0;s=5&&(e._gfxScore=1e3/r.mean()),t>0&&(e._gfxScore=.5*t),e._spinner.stop(),n()})):n()})},yx.prototype.screenshot=function(t,e){var r,n,i,o=this._gfx;if(e=e||t||o.height,(t=t||o.width)===o.width&&e===o.height)r=o.renderer.domElement.toDataURL("image/png");else{var a=o.camera.aspect,s=o.camera.fov,l=(i=o.camera.fov,Math.tan(ye.degToRad(.5*i)))*Math.min(o.width,o.height)/o.height,c=t/e;o.camera.aspect=c,o.camera.fov=(n=l/Math.min(c,1),2*ye.radToDeg(Math.atan(n))),o.camera.updateProjectionMatrix(),o.renderer.setSize(t,e),this._renderFrame("NONE"),r=o.renderer.domElement.toDataURL("image/png"),o.camera.aspect=a,o.camera.fov=s,o.camera.updateProjectionMatrix(),o.renderer.setSize(o.width,o.height),this._needRender=!0}return r},yx.prototype.screenshotSave=function(t,e,r){var n=this.screenshot(e,r);Cu.shotDownload(n,t)},yx.prototype._tweakResolution=function(){var t=[["poor",100],["low",500],["medium",1e3],["high",5e3],["ultra",Number.MAX_VALUE]],e=0;if(this._forEachComplexVisual(function(t){e+=t.getComplex().getAtomCount()}),e>0)for(var r=1e6*this._gfxScore/e,n=0;ni?(a=!1,r.preset="empty"):Vu.now.preset!==Vu.defaults.preset&&(r.preset=Vu.now.preset);for(var s=[],l=!0,c=0,u=i;c0&&(e._objects=s),t.view&&(e.view=this.view()),t.settings){var u=this.settings.getDiffs(!1);n.isEmpty(u)||(e.settings=u)}return e},yx.prototype.get=function(t,e){return Vu.get(t,e)},yx.prototype._clipPlaneUpdateValue=function(t){var e=Math.max(this._gfx.camera.position.z-t*Vu.now.draft.clipPlaneFactor,Vu.now.camNear),r={clipPlaneValue:e};this._forEachComplexVisual(function(t){t.setUberOptions(r)});for(var n=0,i=this._objects.length;n2&&A.push("'"+this.terminals_[w]+"'");T=p.showPosition?"Parse error on line "+(l+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[v]||v)+"'":"Parse error on line "+(l+1)+": Unexpected "+(v==u?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(T,{text:p.match,token:this.terminals_[v]||v,line:p.yylineno,loc:m,expected:A})}if(x[0]instanceof Array&&x.length>1)throw new Error("Parse Error: multiple actions possible at state: "+_+", token: "+v);switch(x[0]){case 1:r.push(v),i.push(p.yytext),o.push(p.yylloc),r.push(x[1]),v=null,y?(v=y,y=null):(c=p.yyleng,s=p.yytext,l=p.yylineno,m=p.yylloc);break;case 2:if(S=this.productions_[x[1]][1],C.$=i[i.length-S],C._$={first_line:o[o.length-(S||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(S||1)].first_column,last_column:o[o.length-1].last_column},g&&(C._$.range=[o[o.length-(S||1)].range[0],o[o.length-1].range[1]]),void 0!==(b=this.performAction.apply(C,[s,c,l,f.yy,x[1],i,o].concat(h))))return b;S&&(r=r.slice(0,-1*S*2),i=i.slice(0,-1*S),o=o.slice(0,-1*S)),r.push(this.productions_[x[1]][0]),i.push(C.$),o.push(C._$),M=a[r[r.length-2]][r[r.length-1]],r.push(M);break;case 3:return!0}}return!0}},wt={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],r=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;var t,e,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;oe[0].length)){if(e=r,n=o,this.options.backtrack_lexer){if(!1!==(t=this.test_match(r,i[o])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[n]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,r,n){switch(r){case 0:break;case 1:case 2:return"";case 3:return 41;case 4:return 34;case 5:return 96;case 6:case 7:return 97;case 8:return 8;case 9:return 6;case 10:return 100;case 11:return 7;case 12:return 9;case 13:return 79;case 14:return 81;case 15:return 12;case 16:return 14;case 17:return 16;case 18:return 17;case 19:return 18;case 20:return 19;case 21:return 82;case 22:return 84;case 23:return 22;case 24:return 24;case 25:return 25;case 26:return 26;case 27:return 29;case 28:return 33;case 29:return 32;case 30:return 85;case 31:return 86;case 32:return 36;case 33:return 40;case 34:return 42;case 35:return 51;case 36:return 53;case 37:return 54;case 38:return 44;case 39:return 46;case 40:return 43;case 41:return 55;case 42:return 57;case 43:return 58;case 44:return 61;case 45:return 62;case 46:return 63;case 47:return 65;case 48:return 66;case 49:return 67;case 50:return 68;case 51:return 69;case 52:return 70;case 53:return 71;case 54:return 73;case 55:return 72;case 56:case 57:return 90;case 58:case 59:return 91;case 60:case 61:case 62:return 93;case 63:return 30;case 64:return 35;case 65:return 77;case 66:return 74;case 67:return 78;case 68:return 76;case 69:return e.yytext=e.yytext.substr(1,e.yyleng-2),13;case 70:return 37;case 71:return 5;case 72:return 102;case 73:return 103;case 74:return"\\";case 75:return 27;case 76:return 59;case 77:return 28;case 78:return 56;case 79:return 75}},rules:[/^(?:\s+)/i,/^(?:[#].*)/i,/^(?:\/\/.*)/i,/^(?:([_A-Z0-9\/\+]+==))/i,/^(?:-?[0-9]+(\.[0-9]+)?\b)/i,/^(?:0[xX][0-9A-F]+\b)/i,/^(?:false\b)/i,/^(?:true\b)/i,/^(?:all\b)/i,/^(?:reset\b)/i,/^(?:clear\b)/i,/^(?:build\b)/i,/^(?:help\b)/i,/^(?:load\b)/i,/^(?:script\b)/i,/^(?:get\b)/i,/^(?:set\b)/i,/^(?:set_save\b)/i,/^(?:set_restore\b)/i,/^(?:set_reset\b)/i,/^(?:preset\b)/i,/^(?:add\b)/i,/^(?:rep\b)/i,/^(?:remove\b)/i,/^(?:hide\b)/i,/^(?:show\b)/i,/^(?:list\b)/i,/^(?:select\b)/i,/^(?:within\b)/i,/^(?:selector\b)/i,/^(?:mode\b)/i,/^(?:color\b)/i,/^(?:material\b)/i,/^(?:view\b)/i,/^(?:unit\b)/i,/^(?:line\b)/i,/^(?:listobj\b)/i,/^(?:removeobj\b)/i,/^(?:rotate\b)/i,/^(?:translate\b)/i,/^(?:scale\b)/i,/^(?:url\b)/i,/^(?:screenshot\b)/i,/^(?:file_list\b)/i,/^(?:file_register\b)/i,/^(?:file_delete\b)/i,/^(?:preset_add\b)/i,/^(?:preset_delete\b)/i,/^(?:preset_update\b)/i,/^(?:preset_rename\b)/i,/^(?:preset_open\b)/i,/^(?:create_scenario\b)/i,/^(?:reset_scenario\b)/i,/^(?:delete_scenario\b)/i,/^(?:add_scenario_item\b)/i,/^(?:list_scenario\b)/i,/^(?:s\b)/i,/^(?:mt\b)/i,/^(?:m\b)/i,/^(?:c\b)/i,/^(?:x\b)/i,/^(?:y\b)/i,/^(?:z\b)/i,/^(?:as\b)/i,/^(?:of\b)/i,/^(?:pdb\b)/i,/^(?:delay\b)/i,/^(?:prst\b)/i,/^(?:desc\b)/i,/^(?:((?:"([^"]*)"|'([^']*)')))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:\.)/i,/^(?:\/)/i,/^(?:\\)/i,/^(?:-e\b)/i,/^(?:-f\b)/i,/^(?:-s\b)/i,/^(?:-v\b)/i,/^(?:=)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79],inclusive:!0}}};function St(){this.yy={}}return bt.lexer=wt,St.prototype=bt,bt.Parser=St,new St}();void 0!==e&&(r.parser=n,r.Parser=n.Parser,r.parse=function(){return n.parse.apply(n,arguments)},r.main=function(t){t[1]||process.exit(1);var e=$h.readFileSync(Kh.normalize(t[1]),"utf8");return r.parser.parse(e)},e.main===t&&r.main(process.argv.slice(1)))}),Ax=Mx.parser,Ex=(Mx.Parser,Mx.parse,Mx.main,{$help:["Rendering mode shortcut"," BS - balls and sticks mode"," LN - lines mode"," LC - licorice mode"," VW - van der waals mode"," TR - trace mode"," TU - tube mode"," CA - cartoon mode"," SA - isosurface mode"," QS - quick surface mode"," SE - solvent excluded mode"," TX - text mode"],BS:{$help:[" Balls and sticks"," aromrad = #aromatic radius"," atom = #atom radius"," bond = #bond radius"," multibond = #use multibond"," showarom = #show aromatic"," space = #space value\n"]},CA:{$help:[" Cartoon"," arrow = #arrow size"," depth = #depth of surface"," heightSegmentsRatio = "," radius = #tube radius"," tension = #"," width = #secondary width\n"]},LN:{$help:[" Lines"," atom = #atom radius"," chunkarom = "," multibond = #use multibond"," showarom = #show aromatic"," offsarom = \n"]},LC:{$help:[" Licorice"," aromrad = #aromatic radius"," bond = #bond radius"," multibond = #use multibond"," showarom = #show aromatic"," space = #space value\n"]},VW:{$help:[" Van der Waals"," nothing\n"]},TR:{$help:[" Trace"," radius = #tube radius\n"]},TU:{$help:[" Tube"," heightSegmentsRatio = "," radius = #tube radius"," tension = \n"]},SA:{$help:[" Surface"," zClip = #clip z plane\n"]},QS:{$help:[" Quick surface"," isoValue = "," scale = "," wireframe = "," zClip = #clip z plane\n"]},SE:{$help:[" Solvent excluded surface"," zClip = #clip z plane\n"]},TX:{$help:[" Text mode",' template = string that can include "{{ id }}"'," it will be replaced by value, id can be one of next:"," serial, name, type, sequence, residue, chain, hetatm, water\n",' horizontalAlign = {"left", "right", "center"}',' verticalAlign = {"top", "bottom", "middle"}'," dx = #offset along x"," dy = #offset along y"," dz = #offset along z"," fg = #text color modificator"," could be keyword, named color or hex"," fg = #back color modificator"," could be keyword, named color or hex"," showBg = #if set show background"," plate under text"]}}),Cx={$help:["Coloring mode shortcut"," EL - color by element"," CH - color by chain"," SQ - color by sequence"," RT - color by residue type"," SS - color by secondary structure"," UN - uniform"],UN:{$help:["Parameters of coloring modes customization"," Uniform"," color = #RGB->HEX->dec\n"],color:{$help:Object.keys(qg.get(Vu.now.palette).namedColors).sort().join("\n")}}},Tx={$help:["Material shortcut"," DF - diffuse"," TR - transparent"," SF - soft plastic"," PL - glossy plastic"," ME - metal"," GL - glass"]},Px={$help:["Short (packed) representation description as a set of variables"," s="," selector property"," m=[!:[,...]]"," render mode property"," c=[!:[,...]]"," color mode property"," mt="," material property"],s:{$help:"Selection expression string as it is in menu->representations->selection"},m:Ex,c:Cx,mt:Tx},Lx={$help:["Parameters of rendering modes customization: modes","Parameters of colorer customization: colorers","Autobuild: autobuild = (|)"],modes:Ex,colorers:Cx},Rx={$help:["help (| )","You can get detailed information about command options",' using "help cmd.opt.opt.[...]"\n'," you can use one line comments"," everything started from (#|//) will be skipped"," Example: >build //some comment\n","List of available commands:"],reset:{$help:["Reload current object, delete all representations"," Nothing will work until load new object"]},load:{$help:["load (||-f [<*.NC FILE URL STRING>])"," Load new pdb object from selected source"],PDBID:{$help:"pdb id in remote molecule database"},URL:{$help:"url to source file"},f:{$help:["open file system dialog to fetch local file","optionally you can determine trajectory file","via URL for *.top model"]}},clear:{$help:"No args. Clear terminal"},add:{$help:["add [] []"," Add new item to representation set with"," default or params"],REP_NAME:{$help:"Identifier string [_,a-z,A-Z,0-9] can not start from digit"},DESCRIPTION:Px},rep:{$help:["rep [|] []"," set current representation by name or index"," edit current representation by "],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"},DESCRIPTION:Px},remove:{$help:["remove (|)","Remove representation by name or index"],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"}},selector:{$help:["selector "," set selector from EXPRESSION to current representation"],EXPRESSION:{$help:"Selection expression string as it is in menu->representations->selection"}},mode:{$help:["mode [=...]"," set rendering mode and apply parameters to current representation"],MODE_ID:Ex},color:{$help:["color [=...]"," set colorer and apply parameters to current representation"],COLORER_ID:Cx},material:{$help:["material "," set material to current representation"],MATERIAL_ID:Tx},build:{$help:"build help str",add:{$help:"build.add",new:{$help:["add.new","add.new new line 1","add.new new line 2","add.new new line 3"]}},del:{$help:"build.del"}},list:{$help:["list [-e|-s||]","Print representations if no args print list of representations"," -e expand list and show all representations"," -s show all user-registered selectors"," | show only current representation"]},hide:{$help:["hide (|)","Hide representation referenced in args"]},show:{$help:["show (|)","Show representation referenced in args"]},get:{$help:["get ","Print value"," - path to option use get.PARAMETER to get more info"],PARAMETER:Lx},set:{$help:["set ","Set with "," - path to option use set.PARAMETER to get more info"],PARAMETER:Lx},set_save:{$help:["set_save","Save current settings to cookie"]},set_restore:{$help:["set_restore","Load and apply settings from cookie"]},set_reset:{$help:["set_reset","Reset current settings to the defaults"]},preset:{$help:["preset []","Reset current representation or set preset to "],PRESET:{$help:["default","wire","small","macro"]}},unit:{$help:["unit []","Change current biological structure view. Zero value means asymmetric unit,","positive values set an assembly with corresponding number.","Being called with no parameters command prints current unit information."]},view:{$help:["view []","Get current encoded view or set if ENCODED_VIEW placed as argument"],ENCODED_VIEW:{$help:["encoded view matrix string (binary code)"]}},rotate:{$help:["rotate (x|y|z) [] [(x|y|z) []]...","Rotate scene"]},scale:{$help:["scale ","Scale scene"]},select:{$help:["select [as ]","Select atoms using selector defined in SELECTOR_STRING"," and if SELECTOR_NAME is defined register it in viewer"," you can use it later as a complex selector"]},within:{$help:["within of as ","Build within named selector"," DISTANCE "," SELECTOR_STRING "," SELECTOR_NAME "]},url:{$help:["url [-s] [-v]","Report URL encoded scene"," if -s set that include settings in the URL"," if -v set that include view in the URL"]},screenshot:{$help:["screenshot [ []]","Make a screenshot of the scene"," WIDTH in pixels"," HEIGHT in pixels, equal to WIDTH by default"]},line:{$help:["line [=]","Draw dashed line between two specified atoms"]},removeobj:{$help:["removeobj ","Remove scene object by its index. Indices could be obtained by command"]},listobj:{$help:["listobj","Display the list of all existing scene objects"]},file_list:{$help:["file_list [(|FILE_NAME)] [-f=]","Report registered files on server or presets in file if defined FILE_ID or FILE_NAME"," also you can use -f flag for fast search"," entity by starting part of name"]},file_register:{$help:["file_register ","Try register current opened file to server"]},file_delete:{$help:["file_delete (|FILE_NAME) [-f]","Delete file from server"," if -f not set then file will be deleted"," only when it has not got any presets in it"," if -f set then file will be deleted anyway"]},preset_add:{$help:["preset_add ","Create new preset from current viewer state"," to current opened file on server"]},preset_delete:{$help:["preset_delete (|)","Delete preset from server"]},preset_update:{$help:["preset_update <(|)","Update due the current viewer state"]},preset_rename:{$help:["preset_rename (|) ","Rename preset"]},preset_open:{$help:["preset_open (|)","Load preset"]},create_scenario:{$help:["create_scenario "," Creates scenario context for future work with them"]},reset_scenario:{$help:["reset_scenario"," Clear current scenario context"]},add_scenario_item:{$help:["add_scenario_item"," pdb=( | )"," prst=(|)"," delay="," desc=\n"," Add item to context and update scenario on server"," Pay attention that order of arguments is important"]},delete_scenario:{$help:["delete_scenario (|)"," Deletes scenario from server"]},list_scenario:{$help:["list_scenario [-e [|]]"," Report scenario list, when -e is set reports expanded"," If set -e then reports only requested scenario"]}};function Nx(t){var e=gp.keyword(t[0]);if(!e||!e.SelectorClass)return null;var r=null,n=e.SelectorClass.prototype;return n instanceof gp.PrefixOperator&&2===t.length?r=e(Nx(t[1])):n instanceof gp.InfixOperator&&3===t.length?r=e(Nx(t[1]),Nx(t[2])):n instanceof gp.RangeListSelector&&2===t.length?r=e(function(t){for(var e,r=[],n=0;n"},Gx.prototype.add=function(t,e){if(void 0!==e){if(this.representationMap.hasOwnProperty(t))return"This name has already existed, registered without name";this.representationMap[t.toString()]=e,this.representationID[e]=t.toString()}return"Representation "+t+" successfully added"},Gx.prototype.remove=function(t){t&&this.representationID.hasOwnProperty(t)&&(delete this.representationMap[this.representationID[t]],delete this.representationID[t]);var e=Object.keys(this.representationID).sort();for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];n>t&&(this.representationID[n-1]=this.representationID[n],this.representationMap[this.representationID[n]]-=1,delete this.representationID[n])}},Gx.prototype.clear=function(){this.representationMap={},this.representationID={}};var Wx=new Gx;function Hx(){}Hx.prototype.list=function(t,e,r){var n="";if(t&&void 0!==e&&(void 0===r||"-e"===r))for(var i=t.repCount(),o=0;o"===s?"":s)+"\n",void 0!==n&&(i+=' selection : "'+c+'"\n',i+=" mode : ("+l.id+"), "+l.name+"\n",i+=" colorer : ("+u.id+"), "+u.name+"\n",i+=" material : ("+h.id+"), "+h.name+"\n"),i},Hx.prototype.listSelector=function(t,e){var r="";for(var n in e)e.hasOwnProperty(n)&&(r+=n+' : "'+e[n]+'"\n');return r},Hx.prototype.listObjs=function(t){var e=t._objects;if(!e||!Array.isArray(e)||0===e.length)return"There are no objects on the scene";for(var r=[],n=0,i=e.length;n0)throw{message:t+' must be a "'+Ru(n.get(Bx.defaults,t))+'"'};if("theme"===t){for(var o=Object.keys(Bx.defaults.themes),a=!1,s=0;s1?(void 0!==i&&i("There are two or more files, please specify one by file_id"),o.finish(t)):void 0!==r?r(s[0].id):o.finish(t)}else o.finish(t)},function(e){void 0!==e&&void 0!==i&&i(e),o.finish(t)})},Zx.prototype.requestPdbID=function(t,e,r,n){var i=this;var o=e.split("/");if(t.awaitWhileCMDisInProcess(),1!==o.length)void 0!==n&&n("Path can contain only file name or id"),i.finish(t);else{var a=Number(o[0]);Number.isNaN(a)?t.srvTopologyFind(o[0],function(e){e instanceof Array?e.length<1?(void 0!==n&&n("File not found"),i.finish(t)):e.length>1?(void 0!==n&&n("There are two or more files, please specify one by file_id"),i.finish(t)):void 0!==r?r(e[0].id):i.finish(t):i.finish(t)},function(e){void 0!==e&&void 0!==n&&n(e),i.finish(t)}):r(a)}},Zx.prototype.requestPresetId=function(t,e,r,i){var o=this,a=e.split("/");function s(e){void 0!==e&&void 0!==i&&i(e),o.finish(t)}function l(e){if(e instanceof Array){var s=n.filter(e,function(t){return t.name.toLowerCase()===a[1].toLowerCase()||t.id===Number(a[1])});s.length<1?(void 0!==i&&i("Preset not found"),o.finish(t)):s.length>1?(void 0!==i&&i("There are two or more presets, please specify one by preset_id"),o.finish(t)):void 0!==r?r(s[0].id):o.finish(t)}else o.finish(t)}t.awaitWhileCMDisInProcess(),2!==a.length?(void 0!==i&&i("Path can has 2 levels only (pdb/preset)"),o.finish(t)):this.requestPdbID(t,a[0],function(e){t.srvPresetList(e,l,s)},s)},Zx.prototype.createScenario=function(t){this.scenarioContext=new qx(t)},Zx.prototype.resetScenario=function(){this.scenarioContext=new qx},Zx.prototype.deleteScenario=function(t,e,r,n){var i=this;function o(r){void 0!==r&&e(r),i.finish(t)}function a(e){void 0!==e&&r(e),i.finish(t)}function s(e){t.srvScenarioDelete(e,o,a),i.finish(t)}this.init(t,e),t.awaitWhileCMDisInProcess(),"number"==typeof n?s(n):this.requestScenarioID(t,n,s,a)},Zx.prototype.listScenario=function(t,e,r,n){var i=this;this.init(t,e),t.awaitWhileCMDisInProcess(),t.srvScenarioList(function(r){if(r instanceof Array){for(var o="",a=0,s=r.length;a"),void i.finish(t);if(7!==arguments.length)return 5===arguments.length?(r("not supported now"),void i.finish(t)):(r("internal interpreter error"),void i.finish(t));var l,c,u,h,p=arguments[3],f=arguments[4],d=arguments[5],m=arguments[6];if(n.isString(p))this.requestPdbID(t,p,function(t){t>=0&&(o[3]=t,i.addScenarioItem.apply(i,o))},s);else if(n.isString(f))this.requestPresetId(t,p+"/"+f,function(t){t>=0&&(o[4]=t,i.addScenarioItem.apply(i,o))},s);else{if("number"!=typeof p||"number"!=typeof f)return s("Internal error"),void i.finish(t);l=p,c=f,u=d,h=m,i.scenarioContext.script.addItem(i.scenarioContext.id,new function(t,e,r,n){return this.pdbId=-1,this.presetId=-1,this.delay=-1,this.description="",void 0!==t&&(this.pdbId=t),void 0!==e&&(this.presetId=e),void 0!==r&&(this.delay=r),void 0!==n&&(this.description=n),this}(l,c,u,h)),t.srvScenarioAdd(i.scenarioContext.id,i.scenarioContext.name,JSON.stringify(i.scenarioContext.script),a,s)}},Zx.prototype.init=function(t,e){var r=this;this.isOnApllyPresetEventInitialized||(t.addEventListener("presetApplyFinished",function(){r.finish(t),void 0!==e&&e("Preset applied")}),this.isOnApllyPresetEventInitialized=!0)},Zx.prototype.finish=function(t){t.finishAwaitingCMDInProcess()},Zx.prototype.fileList=function(t,e,r,n,i){var o=this;function a(r){if(void 0!==r)for(var n=0;n1?(r("There are two or more presets, please specify one by preset_id"),s.finish(t)):void 0===a?o.call(t,i[0].id,c,h):o.call(t,i[0].id,a,c,h)}else s.finish(t)}function h(e){void 0!==e&&r(e),s.finish(t)}2!==l.length?(r("Path can has 2 levels only (pdb/preset)"),s.finish(t)):t.srvTopologyFind(l[0],function(e){e instanceof Array?e.length<1?(r("File not found"),s.finish(t)):e.length>1?(r("There are two or more files, please specify one by file_id"),s.finish(t)):t.srvPresetList(e[0].id,u,h):s.finish(t)},h)},Zx.prototype.coroutineWithFileName=function(t,e,r,n,i){var o=this,a=arguments;this.init(t),t.awaitWhileCMDisInProcess();var s=n.split("/");function l(r){void 0!==r&&e(r),o.finish(t)}function c(e){void 0!==e&&r(e),o.finish(t)}1!==s.length?(r("Path can contain only file name or id"),o.finish(t)):t.srvTopologyFind(s[0],function(e){if(e instanceof Array)if(e.length<1)r("File not found");else if(e.length>1)r("There are two or more files, please specify one by file_id");else switch(a.length){case 5:i.call(t,e[0].id,l,c);break;case 6:i.call(t,e[0].id,a[5],l,c);break;case 9:i.call(a[5],a[6],a[7],a[8],e[0].id);break;case 10:i.call(a[5],a[6],a[7],a[8],e[0].id,a[9]);break;default:o.finish(t)}o.finish(t)},c)};var $x=new Zx;function Kx(t){var e={s:"selector",m:"mode",c:"colorer",mt:"material",mode:"modes",color:"colorers",colorer:"colorers",select:"selector",material:"materials",selector:"selector"}[t];return void 0===e?t:e}function Qx(t){if(t instanceof this.constructor)return t;t instanceof Array?this._values=t.slice(0):this._values=t?[t]:[]}Qx.prototype.append=function(t){var e=this._values;return e[e.length]=t,this},Qx.prototype.remove=function(t){var e=this._values,r=e.indexOf(t);return r>=0&&e.splice(r,1),this},Qx.prototype.toJSO=function(t,e,r){for(var i={},o=this._values,a=0,s=o.length;a0},yx.prototype.callNextCmd=function(){if(this.isScriptingCommandAvailable()){var t=this.cmdQueue.shift(),e={success:!1};try{Ax.parse(t),e.success=!0}catch(t){e.error=t.message,Ax.yy.error(e.error),this.finishAwaitingCMDInProcess()}return e}return""},yx.JSONConverter=Ix,Ax.yy=Jx,Ax.yy.parseError=Ax.parseError,yx}); +(function(){var t,e,n,i,o,a,s,l,c,u,h,p,d,f,m,g,v,y,_,x,b,w,S,M,A,E,C=Object.prototype.hasOwnProperty,T=function(t,e){for(var r in e)C.call(e,r)&&(t[r]=e[r]);function n(){this.constructor=t}return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};for(g in p={method:(n={METHOD_NEAREST:"nearest",METHOD_LINEAR:"linear",METHOD_CUBIC:"cubic",METHOD_LANCZOS:"lanczos",METHOD_SINC:"sinc",CLIP_CLAMP:"clamp",CLIP_ZERO:"zero",CLIP_PERIODIC:"periodic",CLIP_MIRROR:"mirror",CUBIC_TENSION_DEFAULT:0,CUBIC_TENSION_CATMULL_ROM:0}).METHOD_CUBIC,cubicTension:n.CUBIC_TENSION_DEFAULT,clip:n.CLIP_CLAMP,scaleTo:0,sincFilterSize:2,sincWindow:void 0},c=function(t,e){return Math.max(0,Math.min(t,e-1))},h=function(t,e){return(t%=e)<0&&(t+=e),t},u=function(t,e){var r;return(t=h(t,r=2*(e-1)))>e-1&&(t=r-t),t},t=function(){function t(t,e){if(this.array=t.slice(0),this.length=this.array.length,!(this.clipHelper={clamp:this.clipHelperClamp,zero:this.clipHelperZero,periodic:this.clipHelperPeriodic,mirror:this.clipHelperMirror}[e.clip]))throw"Invalid clip: "+e.clip}return t.prototype.getClippedInput=function(t){return 0<=t&&t=o;i<=o?r++:r--)n+=this.kernel(t-r)*this.getClippedInput(r);return n},r}(),d=function(t,e){var r,n,i,o;for(o=[],n=0,i=t.length;na;0<=a?c++:c--)e.push(new h(d(t,c),r));return e}(),function(t){var e,r,n,i;for(i=[],r=0,n=m.length;ri&&t[e-1]._isValid?e-1:e}function s(e){return e1&&0!==E&&(c.lerpVectors(y,_,.15/w),u.lerpVectors(y,_,1-.15/w)),E*=.15,c.addScaledVector(S,E),u.addScaledVector(S,E),o.setItem(h,c,u),o.setColor(h++,i.getAtomColor(g,r),i.getAtomColor(v,r))}}o.finalize(),this._chunksIdc=p},tg.prototype.updateToFrame=function(t){for(var e=this._selection.chunks,r=this._selection.bonds,n=this._mode,i=this._colorer,o=this._geo,a=n.drawMultiorderBonds(),s=n.showAromaticLoops(),l=new He,c=new He,u=new He,h=0,p=t.needsColorUpdate(i),d=0,f=e.length;d1&&0!==E&&(c.lerpVectors(y,_,.15/w),u.lerpVectors(y,_,1-.15/w)),E*=.15,c.addScaledVector(S,E),u.addScaledVector(S,E),o.setItem(h,c,u),p&&o.setColor(h,t.getAtomColor(i,g),t.getAtomColor(i,v)),h++}}o.finalize()};var eg=Mm,rg=Am,ng=Em,ig=Nm,og=zm,ag=Fm,sg=Um,lg=Vm,cg=$m,ug=Km,hg=Jm,pg=tg;function dg(t,e,r,n,i,o,a,s){var l=this;bd.call(l),this._complex=r;var c=r.getAtoms(),u=r.getTransforms();r.forEachComponent(function(h){var p=[],d=0;if(h.forEachAtom(function(t){l._checkAtom(t,a)&&(p[d++]=t._index)}),0!==d){var f=new t(e,{atoms:c,chunks:p,parent:r},n,i,u,o,s);f._component=h,l.add(f)}})}function fg(t,e,r,n,i,o,a,s){this._mode=i,dg.call(this,t,e,r,n,i,o,a,s)}function mg(t,e,r,n,i,o,a,s){var l=this;bd.call(l),this._complex=r;var c=r.getResidues(),u=r.getTransforms();r.forEachComponent(function(h){var p=0,d=[];if(h.forEachResidue(function(t){l._checkResidue(t,a)&&(d[p++]=t._index)}),0!==p){var f=new t(e,{residues:c,chunks:d,parent:r},n,i,u,o,s);f._component=h,l.add(f)}})}function gg(t,e,r,n,i,o,a,s){mg.call(this,t,e,r,n,i,o,a,s)}function vg(t,e,r,n,i,o,a,s){var l=this;bd.call(l),this._complex=r;var c=r.getResidues(),u=r.getTransforms();r.forEachComponent(function(h){for(var p=h.getMaskedSubdivSequences(a),d=0,f=[],m=0,g=p.length;m0&&(f[m++]=t)});var g=new t(e,{cycles:f,atoms:c,chunks:p,parent:r},n,i,u,o,s);g._component=h,l.add(g)})}function xg(t,e,r){var n=document.createElement("div");if(n.className="label label-sgroup",n.style.color=e,"string"==typeof r){var i=document.createElement("span");i.style.fontSize="150%";var o=document.createElement("span"),a=document.createTextNode(r);o.appendChild(a),i.appendChild(o),n.appendChild(i)}else n.appendChild(r);var s=new xd(n);s.position.copy(t),s.userData={translation:"translate(-50%, -50%)",color:e};var l=s.getElement();return l.style.visibility="visible",l.style.textAlign="center",l.style.verticalAlign="middle",s}function bg(t,e,r,n,i,o,a,s){bd.call(this);for(var l=new bd,c=0;c0&&l.add(p)}return l},Ng.prototype=Object.create(Rg.prototype),Ng.prototype.constructor=Ng,Ng.prototype.update=function(){var t=this._staticGroups;"no"===this.settings.now.labels?this.depGroups=this.depGroups.slice(0,t):(this.depGroups[t]="TextLabelsGeo",this.depGroups[t+1]="SGroupsLabels")},Ng.prototype.buildGeometry=function(t,e,r,n){return this.update(),Rg.prototype.buildGeometry.call(this,t,e,r,n)},Iu.deriveClass(Og,Ng,{id:"LN",name:"Lines",shortName:"Lines",depGroups:["ALoopsLines","BondsLines","OrphanedAtomsCrosses"]}),Og.prototype.drawMultiorderBonds=function(){return this.opts.multibond},Og.prototype.calcAtomRadius=function(){return this.opts.atom},Og.prototype.getAromaticOffset=function(){return this.opts.offsarom},Og.prototype.getAromaticArcChunks=function(){return this.opts.chunkarom},Og.prototype.showAromaticLoops=function(){return this.opts.showarom},Og.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!0,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},Iu.deriveClass(Dg,Ng,{id:"LC",name:"Licorice",shortName:"Licorice",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),Dg.prototype.calcAtomRadius=function(t){return this.opts.bond},Dg.prototype.calcStickRadius=function(){return this.opts.bond},Dg.prototype.calcSpaceFraction=function(){return this.opts.space},Dg.prototype.getAromRadius=function(){return this.opts.aromrad},Dg.prototype.showAromaticLoops=function(){return this.opts.showarom},Dg.prototype.drawMultiorderBonds=function(){return this.opts.multibond},Dg.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},Iu.deriveClass(zg,Ng,{id:"BS",name:"Balls and Sticks",shortName:"Balls",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),zg.prototype.calcAtomRadius=function(t){return t.element.radius*this.opts.atom},zg.prototype.calcStickRadius=function(){return this.opts.bond},zg.prototype.getAromRadius=function(){return this.opts.aromrad},zg.prototype.showAromaticLoops=function(){return this.opts.showarom},zg.prototype.calcSpaceFraction=function(){return this.opts.space},zg.prototype.drawMultiorderBonds=function(){return this.opts.multibond},zg.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},Iu.deriveClass(Fg,Rg,{id:"VW",name:"Van der Waals",shortName:"VDW",depGroups:["AtomsSpheres"]}),Fg.prototype.calcAtomRadius=function(t){return t.element.radius},Iu.deriveClass(kg,Rg,{id:"TR",name:"Trace",shortName:"Trace",depGroups:["TraceChains"]}),kg.prototype.calcStickRadius=function(){return this.opts.radius},Iu.deriveClass(Bg,Rg,{id:"TU",name:"Tube",shortName:"Tube",depGroups:["CartoonChains"]}),Bg.prototype.getResidueRadius=function(t){return this.TUBE_RADIUS},Bg.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},Bg.prototype.getTension=function(){return this.opts.tension},Bg.prototype.buildGeometry=function(t,e,r,n){var i=this.opts.radius;return this.TUBE_RADIUS=new ye(i,i),Rg.prototype.buildGeometry.call(this,t,e,r,n)},Iu.deriveClass(Ug,Rg,{id:"CA",name:"Cartoon",shortName:"Cartoon",depGroups:["CartoonChains","NucleicSpheres","NucleicCylinders"]}),Ug.prototype.getResidueStartRadius=function(t){var e=t.getSecondary();if(!e||!e.type)return this.TUBE_RADIUS;var r=this.secCache[e.type];return r?e._end===t?r.start:r.center:this.TUBE_RADIUS},Ug.prototype.getResidueEndRadius=function(t){var e=t.getSecondary();if(null===e||!e.type)return this.TUBE_RADIUS;var r=this.secCache[e.type];return r?e._end===t?this.ARROW_END:r.center:this.TUBE_RADIUS},Ug.prototype.getResidueRadius=function(t,e){var r=this.getResidueStartRadius(t);if(0===e)return r;var n=this.getResidueEndRadius(t);return 2===e?n:r.clone().lerp(n,e/2)},Ug.prototype.calcStickRadius=function(t){return this.opts.radius},Ug.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},Ug.prototype.getTension=function(){return this.opts.tension},Ug.prototype.buildGeometry=function(t,e,r,n){var i=this.opts.radius,o=this.opts.depth;this.TUBE_RADIUS=new ye(i,i),this.ARROW_END=new ye(o,i);var a={},s=this.opts.ss;for(var l in s)a[l]={center:new ye(o,s[l].width),start:new ye(o,s[l].arrow)};return this.secCache=a,Rg.prototype.buildGeometry.call(this,t,e,r,n)};var Vg=_d.selectors;function jg(){return{wireframe:this.opts.wireframe,zClip:this.opts.zClip}}function Gg(t){Rg.call(this,t),this.depGroups=this.depGroups.slice(0);for(var e=this.surfaceNames,r=this.depGroups,n=0,i=e.length;n=256?e-256:e))%this.chainColors.length,this.chainColors[e]},getSecondaryColor:function(t,e){var r=this.secondaryColors[t];return r instanceof Object&&(r=r[e]),void 0===r?this.defaultSecondaryColor:r},getSequentialColor:function(t){var e=this.colors,r=e.length;return t<0?e[t%r+r]:e[t%r]},getGradientColor:function(t,e){var r,n,i,o,a=this.gradients[e];if(a){var s=a.length,l=t*(s-1),c=Math.floor(l),u=Jg(c+1,0,s-1);return c=Jg(c,0,s-1),r=a[c],n=a[u],(o=1-(i=l-c))*(r>>16&255)+i*(n>>16&255)<<16|o*(r>>8&255)+i*(n>>8&255)<<8|o*(255&r)+i*(255&n)}return this.defaultNamedColor},getNamedColor:function(t,e){var r=this.namedColors[t];return void 0!==r||e?r:this.defaultNamedColor}};for(var ev=tv.prototype.namedColorsArray,rv=tv.prototype.namedColors,nv=0,iv=ev.length;nv=0?this.opts.carbon:this.palette.getElementColor(r)},gv.prototype.getResidueColor=function(t,e){return this.palette.defaultResidueColor},Iu.deriveClass(vv,mv,{id:"RT",name:"Residue Type",shortName:"Residue"}),vv.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},vv.prototype.getResidueColor=function(t,e){return this.palette.getResidueColor(t._type._name)},Iu.deriveClass(yv,mv,{id:"SQ",aliases:["RI"],name:"Sequence",shortName:"Sequence"}),yv.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},yv.prototype.getResidueColor=function(t,e){var r=t._chain;if(r.minSequence===Number.POSITIVE_INFINITY&&r.maxSequence===Number.NEGATIVE_INFINITY)return this.palette.defaultNamedColor;var n=r.minSequence,i=r.maxSequence>n?r.maxSequence:n+1;return this.palette.getGradientColor((t._sequence-n)/(i-n),this.opts.gradient)},Iu.deriveClass(_v,mv,{id:"CH",name:"Chain",shortName:"Chain"}),_v.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},_v.prototype.getResidueColor=function(t,e){return this.palette.getChainColor(t.getChain()._name)},Iu.deriveClass(xv,mv,{id:"SS",name:"Secondary Structure",shortName:"Structure"}),xv.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},xv.prototype.getResidueColor=function(t,e){if(t._type.flags&Eh.Flags.DNA)return this.palette.getSecondaryColor("dna");if(t._type.flags&Eh.Flags.RNA)return this.palette.getSecondaryColor("rna");var r=t.getSecondary();return r?this.palette.getSecondaryColor(r.type,r._type):this.palette.getSecondaryColor("")},Iu.deriveClass(bv,mv,{id:"UN",name:"Uniform",shortName:"Uniform"}),bv.prototype.getAtomColor=function(t,e){return this.opts.color},bv.prototype.getResidueColor=function(t,e){return this.opts.color},Iu.deriveClass(wv,mv,{id:"CO",name:"Conditional",shortName:"Conditional"}),wv.prototype.getAtomColor=function(t,e){return this._subsetCached.includesAtom(t)?this.opts.color:this.opts.baseColor},wv.prototype.getResidueColor=function(t,e){for(var r=this._subsetCached,n=!0,i=t._atoms,o=0,a=i.length;or.max?1:0:(t._temperature-r.min)/(r.max-r.min),this.palette.getGradientColor(n,r.gradient)):this.palette.defaultElementColor},Mv.prototype.getResidueColor=function(t,e){var r=this.opts;if(!r)return this.palette.defaultResidueColor;var n=-1;if(t.forEachAtom(function(t){t._temperature&&t._role===_d.Element.Constants.Lead&&(n=t._temperature)}),n>0){var i=0;return i=r.min===r.max?n>r.max?1:0:(n-r.min)/(r.max-r.min),this.palette.getGradientColor(i,r.gradient)}return this.palette.defaultResidueColor},Iu.deriveClass(Av,mv,{id:"OC",name:"Occupancy",shortName:"Occupancy"}),Av.prototype.getAtomColor=function(t,e){var r=this.opts;if(t._occupancy&&r){var n=1-t._occupancy;return this.palette.getGradientColor(n,r.gradient)}return this.palette.defaultElementColor},Av.prototype.getResidueColor=function(t,e){var r=this.opts;if(!r)return this.palette.defaultResidueColor;var n=-1;if(t.forEachAtom(function(t){t._occupancy&&t._role===_d.Element.Constants.Lead&&(n=t._occupancy)}),n>0){var i=1-n;return this.palette.getGradientColor(i,r.gradient)}return this.palette.defaultResidueColor},Iu.deriveClass(Ev,mv,{id:"HY",name:"Hydrophobicity",shortName:"Hydrophobicity"}),Ev.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Ev.prototype.getResidueColor=function(t,e){var r=this.palette.defaultResidueColor;if(t._type.hydrophobicity){r=this.palette.getGradientColor((t._type.hydrophobicity- -4.5)/9,this.opts.gradient)}return r},Iu.deriveClass(Cv,mv,{id:"MO",name:"Molecule",shortName:"Molecule"}),Cv.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Cv.prototype.getResidueColor=function(t,e){var r=t._molecule,n=e.getMoleculeCount();return n>1?this.palette.getGradientColor((r._index-1)/(n-1),this.opts.gradient):this.palette.getGradientColor(0,this.opts.gradient)};var Tv=[],Pv={};!function(t){for(var e=0,r=t.length;e0){(e=new ta).matrixAutoUpdate=!1,e.matrix=this.geo.matrix;for(var n=0;n2)return vu.error("Can only edit fragments with one or two bound atoms."),!1;this._fragmentBoundAtoms=r;var n=1<0?this._reprList[0]:null,this._selectionBit=t.length,this._reprUsedBits|=1<=0&&tthis._reprList.length)return vu.error("Rep "+t+" does not exist!"),null;t===this._reprList.length&&(this.repAdd(e),e=void 0,vu.warn("Rep "+t+" does not exist! New representation was created."));var r=this._reprList[t],i={selector:r.selectorString,mode:r.mode.identify(),colorer:r.colorer.identify(),material:r.materialPreset.id};if(e){var o=!1;if(e.selector){var a=jv.parse(e.selector).selector,s=String(a);i.selector!==s&&(r.selectorString=i.selector=s,r.selector=a,r.markAtoms(this._complex),o=!0,vu.debug("rep["+t+"].selector changed to"+s))}if(e.mode){var l=e.mode;n.isEqual(i.mode,l)||(i.mode=l,r.setMode(Qg.create(e.mode)),o=!0,vu.debug("rep["+t+"].mode changed to "+l),!r.mode.isSurface||"ultra"!==qu.now.resolution&&"high"!==qu.now.resolution||(vu.report('Surface resolution was changed to "medium" to avoid hang-ups.'),qu.now.resolution="medium"))}if(e.colorer){var c=e.colorer;n.isEqual(i.colorer,c)||(i.colorer=c,r.colorer=Lv.create(e.colorer),o=!0,vu.debug("rep["+t+"].colorer changed to "+c))}if(e.material){var u=e.material;n.isEqual(i.material,u)||(i.material=u,r.setMaterialPreset(zv.get(e.material)),o=!0,vu.debug("rep["+t+"].material changed to"+u))}o&&(r.needsRebuild=!0)}return i},Gv.prototype.repGet=function(t){return(void 0===t||t instanceof Object)&&(t=this.repCurrent()),t<0||t>=this._reprList.length?null:this._reprList[t]},Gv.prototype._getFreeReprIdx=function(){for(var t=this._reprUsedBits,e=0;e<=Gv.NUM_REPRESENTATION_BITS;++e,t>>=1)if(0==(1&t))return e;return-1},Gv.prototype.repAdd=function(t){if(this._reprList.length>=Gv.NUM_REPRESENTATION_BITS)return-1;var e=this._getFreeReprIdx();if(e<0)return-1;var r=this.buildSelectorFromMask(1<=e||e<=1)){var r=this._reprList[t];r.unmarkAtoms(this._complex),this._reprUsedBits&=~(1<=this._reprList.length)||this._reprList[t].show(!e)},Gv.prototype.select=function(t,e){e?this._selectionCount+=this._complex.markAtomsAdditionally(t,1<0&&(a=jv.chain(r),o=o?jv.or(o,a):a),Object.keys(e).length>0)for(var s in e)e.hasOwnProperty(s)&&(a=jv.and(jv.chain(s),jv.residx(i(e[s]))),o=o?jv.or(o,a):a);t.length>0&&(a=jv.serial(i(t)),o=o?jv.or(o,a):a),o||(o=jv.none())}return o},Gv.prototype.buildSelectorFromMask=function(t){var e=this._complex,r=[],n={},i=[];return e.forEachChain(function(e){e._mask&t&&r.push(e._name)}),e.forEachResidue(function(e){if(e._mask&t&&!(e._chain._mask&t)){var r=e._chain._name;r in n?n[r].push(e._index):n[r]=[e._index]}}),e.forEachAtom(function(e){e._mask&t&&!(e._residue._mask&t)&&i.push(e._serial)}),this._buildSelectorFromSortedLists(i,n,r)},Gv.prototype.getSelectedComponent=function(){var t=1<=0):n<8+y.indices.length&&(this.cullFlag[n]=!0);var w=this.geometry.getAttribute("position"),S=0;for(n=0;n=3&&(u+=3*(r.indices.length-2));var h=0,p=new Uint16Array(u);for(e=0;ee&&(n._prof.end(),n._prof.start(),++i),l>r||i===t?a(Math.max(i,0)):requestAnimationFrame(s)})})},ry.prototype.mean=function(){return this._prof?this._prof.rawMean():0},ry.prototype.min=function(){return this._prof?this._prof.min():0};var ny=function(){function t(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];ku(this,t),this._list=[],this._byType={},r.forEach(function(t){return e.register(t)})}return Bu(t,[{key:"register",value:function(t){Pu(this._list,t),Ru(this._byType,t.types,t)}},{key:"unregister",value:function(t){Lu(this._list,t),Nu(this._byType,t.types,t)}},{key:"find",value:function(t){var e=[];if(t.type)e=this._byType[t.type.toLowerCase()]||[];else if(t.source)return this._list.filter(function(e){return e.canProbablyLoad&&e.canProbablyLoad(t.source)});return[].concat(Hu(e))}},{key:"all",get:function(){return[].concat(Hu(this._list))}},{key:"types",get:function(){return Object.keys(this._byType)}}]),t}(),iy=function(t){function e(t,r){ku(this,e);var n=ju(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n._source=t,n._options=r||{},n._abort=!1,n._agent=null,n}return Vu(e,du),Bu(e,[{key:"load",value:function(t){return t?this._loadOLD(t):this._abort?Promise.reject(new Error("Loading aborted")):this.loadAsync()}},{key:"loadAsync",value:function(){return Promise.reject(new Error("Loading from this source is not implemented"))}},{key:"_loadOLD",value:function(t){return t.progress&&this.addEventListener("progress",function(e){e.lengthComputable&&e.total>0?t.progress(e.loaded/e.total):t.progress()}),this.load().then(function(e){t.ready(e)}).catch(function(e){t.error(e)})}},{key:"abort",value:function(){this._abort=!0,this._agent&&this._agent.abort()}}],[{key:"extractName",value:function(t){}}]),e}();Fd(iy.prototype);var oy=function(t){function e(t,r){ku(this,e);var n=ju(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r));return r=n._options,n._binary=!0===r.binary,n}return Vu(e,iy),Bu(e,[{key:"loadAsync",value:function(){var t=this;return new Promise(function(e,r){var n=t._source,i=t._agent=new FileReader;i.addEventListener("load",function(){e(i.result)}),i.addEventListener("error",function(){r(i.error)}),i.addEventListener("abort",function(){r(new Error("Loading aborted"))}),i.addEventListener("progress",function(e){t.dispatchEvent(e)}),t._binary?i.readAsArrayBuffer(n):i.readAsText(n)})}}],[{key:"canLoad",value:function(t,e){var r=e.sourceType;return t instanceof File&&(!r||"file"===r)}},{key:"canProbablyLoad",value:function(t){return File&&t instanceof File||Blob&&t instanceof Blob}},{key:"extractName",value:function(t){return t&&t.name}}]),e}();oy.types=["file","blob"];var ay=/^(https?|ftp):\/\//i,sy=function(t){function e(t,r){ku(this,e);var n=ju(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r));return r=n._options,n._binary=!0===r.binary,n}return Vu(e,iy),Bu(e,[{key:"loadAsync",value:function(){var t=this;return new Promise(function(e,r){var n=t._source,i=t._agent=new XMLHttpRequest;i.addEventListener("load",function(){200===i.status?e(i.response):r(new Error("HTTP "+i.status+" while fetching "+n))}),i.addEventListener("error",function(){r(new Error("HTTP request failed"))}),i.addEventListener("abort",function(){r(new Error("Loading aborted"))}),i.addEventListener("progress",function(e){t.dispatchEvent(e)}),i.open("GET",n),t._binary?i.responseType="arraybuffer":i.responseType="text",i.send()})}}],[{key:"canLoad",value:function(t,e){var r=e.sourceType;return"string"==typeof t&&(!r||"url"===r)}},{key:"canProbablyLoad",value:function(t){return n.isString(t)&&ay.test(t)}},{key:"extractName",value:function(t){if(t){var e=(t.indexOf("?")+1||t.lastIndexOf("#")+1||t.length+1)-1;return t.slice(t.lastIndexOf("/",e)+1,e)}}}]),e}();sy.types=["url"];var ly=function(t){function e(t,r){return ku(this,e),ju(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r))}return Vu(e,iy),Bu(e,[{key:"loadAsync",value:function(){return Promise.resolve(this._source)}}],[{key:"canLoad",value:function(t,e){return void 0!==t&&void 0!==e&&"immediate"===e.sourceType}},{key:"canProbablyLoad",value:function(t){return!1}}]),e}();ly.types=["immediate"];var cy=new ny([oy,sy,ly]),uy=function(){function t(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];ku(this,t),this._list=[],this._byFormat={},this._byExt={},r.forEach(function(t){return e.register(t)})}return Bu(t,[{key:"register",value:function(t){Pu(this._list,t),Ru(this._byFormat,t.formats,t),Ru(this._byExt,t.extensions,t)}},{key:"unregister",value:function(t){Lu(this._list,t),Nu(this._byFormat,t.formats,t),Nu(this._byExt,t.extensions,t)}},{key:"find",value:function(t){var e=[];return t.format?e=this._byFormat[t.format.toLowerCase()]||[]:t.ext&&(e=this._byExt[t.ext.toLowerCase()]||[]),0===e.length&&!t.format&&t.data?this._list.filter(function(e){return e.canProbablyParse&&e.canProbablyParse(t.data)}):[].concat(Hu(e))}},{key:"all",get:function(){return[].concat(Hu(this._list))}},{key:"formats",get:function(){return Object.keys(this._byFormat)}},{key:"extensions",get:function(){return Object.keys(this._byExt)}}]),t}(),hy=function(){function t(e,r){ku(this,t),this._data=e,this._options=r||{},this._abort=!1}return Bu(t,[{key:"parseSync",value:function(){throw new Error("Parsing this type of data is not implemented")}},{key:"parse",value:function(t){var e=this;return t?this._parseOLD(t):new Promise(function(t,r){setTimeout(function(){try{return e._abort?r(new Error("Parsing aborted")):t(e.parseSync())}catch(t){return r(t)}})})}},{key:"_parseOLD",value:function(t){return this.parse().then(function(e){t.ready(e)}).catch(function(e){t.error(e)})}},{key:"abort",value:function(){this._abort=!0}}],[{key:"checkDataTypeOptions",value:function(t,e,r){var n=t.fileType,i=t.fileName;return r=(r||"."+e).toLowerCase(),Boolean(n&&n.toLowerCase()===e.toLowerCase()||!n&&i&&i.toLowerCase().endsWith(r))}}]),t}();function py(){this.matrices=[],this._matrix=null,this._matrixIndex=-1}Fd(hy.prototype),py.prototype.id=290,py.prototype.parse=function(t){var e=this._matrix;if(" SMTRY"===t.readString(12,18)){var r=t.readCharCode(19)-49,n=t.readString(20,80).trim().split(/\s+/),i=parseInt(n[0],10);null!==this._matrix&&i===this._matrixIndex||(this._matrixIndex=i,this._matrix=e=new We,this.matrices[this.matrices.length]=e);var o=e.elements;o[r]=parseFloat(n[1]),o[r+4]=parseFloat(n[2]),o[r+8]=parseFloat(n[3]),o[r+12]=parseFloat(n[4])}};var dy=_d.Assembly;function fy(t){this._complex=t,this.assemblies=[],this._assembly=null,this._matrix=null,this._matrixIndex=-1}fy.prototype.id=350,fy.prototype.parse=function(t){var e=this._assembly,r=this._matrix;if(e&&" BIOMT"===t.readString(12,18)){var n=t.readCharCode(19)-49,i=t.readString(20,80).trim().split(/\s+/),o=parseInt(i[0],10);null!==this._matrix&&o===this._matrixIndex||(this._matrixIndex=o,this._matrix=r=new We,e.addMatrix(r));var a=r.elements;a[n]=parseFloat(i[1]),a[n+4]=parseFloat(i[2]),a[n+8]=parseFloat(i[3]),a[n+12]=parseFloat(i[4])}else if(e&&"CHAINS:"===t.readString(35,41))for(var s=t.readString(42,80).split(","),l=0,c=s.length;l0&&e.addChain(u)}else"BIOMOLECULE:"===t.readString(12,23)&&(this._matrix=null,this._matrixIndex=-1,this._assembly=e=new dy(this._complex),this.assemblies.push(e))};var my=function(){function t(e){ku(this,t),this._data=e,this._start=0,this._nextCR=-1,this._nextLF=-1,this._next=-1,this._end=e.length,this.next()}return Bu(t,[{key:"readLine",value:function(){return this._data.slice(this._start,this._next)}},{key:"readChar",value:function(t){return(t=this._start+t-1)=this._end}},{key:"next",value:function(){var t=this._next+1;this._start=tthis._nextCR&&(this._nextCR=(this._data.indexOf("\r",this._start)+1||this._end+1)-1),this._start>this._nextLF&&(this._nextLF=(this._data.indexOf("\n",this._start)+1||this._end+1)-1),this._next=this._nextCR+1e&&a.addBond(e,r,0,by.BondType.UNKNOWN,!0),n&&n>e&&a.addBond(e,n,0,by.BondType.UNKNOWN,!0),i&&i>e&&a.addBond(e,i,0,by.BondType.UNKNOWN,!0),o&&o>e&&a.addBond(e,o,0,by.BondType.UNKNOWN,!0)},Sy.prototype._parseCOMPND=function(t){var e=t.readString(11,80),r=e.indexOf(":");if(this._compndCurrToken=r>0?e.substring(0,r).trim():this._compndCurrToken,"MOL_ID"===this._compndCurrToken)this._molecule={_index:"",_chains:[]},this._molecule._index=parseInt(e.substring(r+1,e.indexOf(";")),10),this._molecules.push(this._molecule);else if("MOLECULE"===this._compndCurrToken&&null!=this._molecule)this._molecule._name=e.substring(r+1,e.indexOf(";")).trim();else if("CHAIN"===this._compndCurrToken&&null!=this._molecule){var n=e.substring(r+1,80).trim(),i=n[n.length-1];";"!==i&&","!==i||(n=n.slice(0,-1));var o=(n=n.replace(/\s+/g,"")).split(",");this._molecule._chains=this._molecule._chains.concat(o)}};var Ay={290:py,350:fy};Sy.prototype._parseREMARK=function(t){var e=t.readInt(8,10),r=this._remarks[e];if(n.isUndefined(r)){var i=Ay[e];n.isFunction(i)&&(this._remarks[e]=r=new i(this._complex))}n.isUndefined(r)||r.parse(t)},Sy.prototype._parseHELIX=function(t){this._parseSTRUCTURE(t,[20,22,32,34],function(t){this._complex.addHelix(t)}.bind(this))},Sy.prototype._parseSHEET=function(t){this._parseSTRUCTURE(t,[22,23,33,34],function(t){this._complex.addSheet(t)}.bind(this))},Sy.prototype._parseSTRUCTURE=function(t,e,r){var n=t.readInt(8,10),i=t.readString(12,14).trim(),o=t.readString(41,70).trim(),a=t.readInt(72,76),s=t.readInt(39,40),l=t.readInt(15,16),c=t.readInt(42,45),u=t.readInt(57,60),h=t.readString(e[0],e[2]+1).charCodeAt(0),p=t.readString(e[2],e[2]+1).charCodeAt(0),d=t.readInt(e[1],e[1]+3),f=t.readString(e[1]+4,e[1]+4),m=0;f.length>0&&(m=f.charCodeAt(0));var g,v=t.readInt(e[3],e[3]+3),y=0;(f=t.readString(e[3]+4,e[3]+4)).length>0&&(y=f.charCodeAt(0));var _=this._sheet;if(83===t.readCharCode(1)){null!==_&&_.getName()!==i&&(_=null,this._sheet=null),null===_?(this._sheet=g=new _y(i,l),r(g)):g=_;var x=new xy(g,this._complex.getUnifiedSerial(h,d,m),this._complex.getUnifiedSerial(p,v,y),s,c,u);g.addStrand(x)}else r(g=new yy(n,i,this._complex.getUnifiedSerial(h,d,m),this._complex.getUnifiedSerial(p,v,y),s,o,a))},Sy.prototype._parseHEADER=function(t){var e=this._complex.metadata;e.classification=t.readString(11,50).trim(),e.date=t.readString(51,59).trim();var r=t.readString(63,66).trim();e.id=r,r&&(this._complex.name=r)},Sy.prototype._parseTITLE=function(t){var e=this._complex.metadata;e.title=e.title||[];var r=t.readInt(9,10)||1;e.title[r-1]=t.readString(11,80).trim()};var Ey={HEADER:Sy.prototype._parseHEADER,"TITLE ":Sy.prototype._parseTITLE,"ATOM ":Sy.prototype._parseATOM,HETATM:Sy.prototype._parseATOM,ENDMDL:Sy.prototype._parseENDMDL,CONECT:Sy.prototype._parseCONECT,COMPND:Sy.prototype._parseCOMPND,REMARK:Sy.prototype._parseREMARK,"HELIX ":Sy.prototype._parseHELIX,"SHEET ":Sy.prototype._parseSHEET,"ATOM 1":Sy.prototype._parseATOM,"ATOM 2":Sy.prototype._parseATOM,"ATOM 3":Sy.prototype._parseATOM,"ATOM 4":Sy.prototype._parseATOM,"ATOM 5":Sy.prototype._parseATOM,"ATOM 6":Sy.prototype._parseATOM,"ATOM 7":Sy.prototype._parseATOM,"ATOM 8":Sy.prototype._parseATOM,"ATOM 9":Sy.prototype._parseATOM};Sy.prototype.parseSync=function(){for(var t=new my(this._data),e=this._complex=new gy;!t.end();){var r=t.readString(1,6),i=Ey[r];n.isFunction(i)&&i.call(this,t),t.next()}if(this._finalize(),this._serialAtomMap=null,this._sheet=null,this._residue=null,this._chain=null,this._complex=null,0===e.getAtomCount())throw new Error("The data does not contain valid atoms");return e},Sy.formats=["pdb"],Sy.extensions=[".pdb",".ent"];var Cy=_d.Complex,Ty=_d.Element,Py=_d.AtomName,Ly=_d.SGroup,Ry=_d.Bond,Ny={A:0,S:1,D:2,T:3};function Iy(t,e){hy.call(this,t,e),this._complex=null,this._sheet=null,this._residue=null,this._serialAtomMap=null,this._modelId=1,this._lastMolId=-1,this._readOnlyOneMolecule=!1,this._options.fileType="cml"}Iy.prototype=Object.create(hy.prototype),Iy.prototype.constructor=Iy,Iy.canParse=function(t,e){if(!t)return!1;var r=new RegExp("^\\s*?\\<\\?xml"),n=new RegExp("^\\s*?\\]*\?>\s*<(?:cml|molecule)\b/i;Iy.canProbablyParse=function(t){return n.isString(t)&&Oy.test(t)},Iy.prototype._rebuidBondIndexes=function(t,e){for(var r=t.length,n=0;n1&&a.splice(1,a.length-1),a.forEach(function(t){var e=function(t){var e,n=[];if(t.molecule&&t.molecule.atomArray&&t.molecule.atomArray.atom)Array.isArray(t.molecule.atomArray.atom)?n=t.molecule.atomArray.atom:n.push(t.molecule.atomArray.atom);else if(!t.molecule){var o={atomLabels:null,labelsCount:1};return o}t.molecule.molecule&&i._extractSGroups(t.molecule.molecule,n);for(var a=n.length,s=0;s1)c[u].order=p;else{var d=Ny[h];void 0!==d&&(c[u].order=d,"A"===h&&(c[u].type=Ry.BondType.AROMATIC))}}a=n.length;for(var f=0;f0&&o.push(e)}),o},Iy.prototype._packLabel=function(t,e){return(e<<16)+t},Iy.prototype._unpackLabel=function(t){return{molId:t>>>16,compId:65535&t}},Iy.prototype._breadWidthSearch=function(t,e){var r,n=new Array(t.length);for(r=0;r0;){o++;var s=-1;for(r=0;r0;){var l=i.shift();if(l)for(var c=0;c=0){var i=[Math.min(t,e),Math.max(t,e)];this._complex.addBond(i[0],i[1],r,n,!0)}},Iy.prototype._fixBondsArray=function(){for(var t=this._serialAtomMap={},e=this._complex,r=e._atoms,n=0,i=r.length;n1){var n=new Cy;return n.joinComplexes(t),n.originalCML=t[0].originalCML,n}return 1===t.length?t[0]:new Cy},Iy.formats=["cml"],Iy.extensions=[".cml"];var Dy=r(function(t,e){(function(t){function e(t,e,r){for(var n=(t.byteLength,0),i=r.length;i>n;n++){var o=r.charCodeAt(n);if(128>o)t.setUint8(e++,o>>>0&127|0);else if(2048>o)t.setUint8(e++,o>>>6&31|192),t.setUint8(e++,o>>>0&63|128);else if(65536>o)t.setUint8(e++,o>>>12&15|224),t.setUint8(e++,o>>>6&63|128),t.setUint8(e++,o>>>0&63|128);else{if(!(1114112>o))throw new Error("bad codepoint "+o);t.setUint8(e++,o>>>18&7|240),t.setUint8(e++,o>>>12&63|128),t.setUint8(e++,o>>>6&63|128),t.setUint8(e++,o>>>0&63|128)}}}function r(t){for(var e=0,r=0,n=t.length;n>r;r++){var i=t.charCodeAt(r);if(128>i)e+=1;else if(2048>i)e+=2;else if(65536>i)e+=3;else{if(!(1114112>i))throw new Error("bad codepoint "+i);e+=4}}return e}function n(t){var n=new ArrayBuffer(function t(e){var n=typeof e;if("string"===n){if(32>(i=r(e)))return 1+i;if(256>i)return 2+i;if(65536>i)return 3+i;if(4294967296>i)return 5+i}if(e instanceof Uint8Array){if(256>(i=e.byteLength))return 2+i;if(65536>i)return 3+i;if(4294967296>i)return 5+i}if("number"===n){if(Math.floor(e)!==e)return 9;if(e>=0){if(128>e)return 1;if(256>e)return 2;if(65536>e)return 3;if(4294967296>e)return 5;throw new Error("Number too big 0x"+e.toString(16))}if(e>=-32)return 1;if(e>=-128)return 2;if(e>=-32768)return 3;if(e>=-2147483648)return 5;throw new Error("Number too small -0x"+e.toString(16).substr(1))}if("boolean"===n||null===e)return 1;if("object"===n){var i,o=0;if(Array.isArray(e)){i=e.length;for(var a=0;i>a;a++)o+=t(e[a])}else{var s=Object.keys(e);for(i=s.length,a=0;i>a;a++){var l=s[a];o+=t(l)+t(e[l])}}if(16>i)return 1+o;if(65536>i)return 3+o;if(4294967296>i)return 5+o;throw new Error("Array or object too long 0x"+i.toString(16))}throw new Error("Unknown type "+n)}(t));return function t(n,i,o){var a=typeof n;if("string"===a){if(32>(s=r(n)))return i.setUint8(o,160|s),e(i,o+1,n),1+s;if(256>s)return i.setUint8(o,217),i.setUint8(o+1,s),e(i,o+2,n),2+s;if(65536>s)return i.setUint8(o,218),i.setUint16(o+1,s),e(i,o+3,n),3+s;if(4294967296>s)return i.setUint8(o,219),i.setUint32(o+1,s),e(i,o+5,n),5+s}if(n instanceof Uint8Array){var s=n.byteLength,l=new Uint8Array(i.buffer);if(256>s)return i.setUint8(o,196),i.setUint8(o+1,s),l.set(n,o+2),2+s;if(65536>s)return i.setUint8(o,197),i.setUint16(o+1,s),l.set(n,o+3),3+s;if(4294967296>s)return i.setUint8(o,198),i.setUint32(o+1,s),l.set(n,o+5),5+s}if("number"===a){if(!isFinite(n))throw new Error("Number not finite: "+n);if(Math.floor(n)!==n)return i.setUint8(o,203),i.setFloat64(o+1,n),9;if(n>=0){if(128>n)return i.setUint8(o,n),1;if(256>n)return i.setUint8(o,204),i.setUint8(o+1,n),2;if(65536>n)return i.setUint8(o,205),i.setUint16(o+1,n),3;if(4294967296>n)return i.setUint8(o,206),i.setUint32(o+1,n),5;throw new Error("Number too big 0x"+n.toString(16))}if(n>=-32)return i.setInt8(o,n),1;if(n>=-128)return i.setUint8(o,208),i.setInt8(o+1,n),2;if(n>=-32768)return i.setUint8(o,209),i.setInt16(o+1,n),3;if(n>=-2147483648)return i.setUint8(o,210),i.setInt32(o+1,n),5;throw new Error("Number too small -0x"+(-n).toString(16).substr(1))}if(null===n)return i.setUint8(o,192),1;if("boolean"===a)return i.setUint8(o,n?195:194),1;if("object"===a){var c=0,u=Array.isArray(n);if(u)s=n.length;else{var h=Object.keys(n);s=h.length}if(16>s?(i.setUint8(o,s|(u?144:128)),c=1):65536>s?(i.setUint8(o,u?220:222),i.setUint16(o+1,s),c=3):4294967296>s&&(i.setUint8(o,u?221:223),i.setUint32(o+1,s),c=5),u)for(var p=0;s>p;p++)c+=t(n[p],i,o+c);else for(p=0;s>p;p++){var d=h[p];c+=t(d,i,o+c),c+=t(n[d],i,o+c)}return c}throw new Error("Unknown type "+a)}(t,new DataView(n),0),new Uint8Array(n)}function i(t,e,r){return e?new t(e.buffer,e.byteOffset,e.byteLength/(r||1)):void 0}function o(t){return i(DataView,t)}function a(t){return i(Uint8Array,t)}function s(t){return i(Int8Array,t)}function l(t){return i(Int32Array,t,4)}function c(t,e){var r=t.length/2;e||(e=new Int16Array(r));for(var n=0,i=0;r>n;++n,i+=2)e[n]=t[i]<<8^t[i+1]<<0;return e}function u(t,e){var r=t.length/4;e||(e=new Int32Array(r));for(var n=0,i=0;r>n;++n,i+=4)e[n]=t[i]<<24^t[i+1]<<16^t[i+2]<<8^t[i+3]<<0;return e}function h(t,e){var r=t.length;e||(e=new Uint8Array(4*r));for(var n=o(e),i=0;r>i;++i)n.setInt32(4*i,t[i]);return a(e)}function p(t,e,r){var n=t.length,i=1/e;r||(r=new Float32Array(n));for(var o=0;n>o;++o)r[o]=t[o]*i;return r}function d(t,e,r){var n=t.length;r||(r=new Int32Array(n));for(var i=0;n>i;++i)r[i]=Math.round(t[i]*e);return r}function f(t,e){var r,n;if(!e){var i=0;for(r=0,n=t.length;n>r;r+=2)i+=t[r+1];e=new t.constructor(i)}var o=0;for(r=0,n=t.length;n>r;r+=2)for(var a=t[r],s=t[r+1],l=0;s>l;++l)e[o]=a,++o;return e}function m(t){if(0===t.length)return new Int32Array;var e,r,n=2;for(e=1,r=t.length;r>e;++e)t[e-1]!==t[e]&&(n+=2);var i=new Int32Array(n),o=0,a=1;for(e=1,r=t.length;r>e;++e)t[e-1]!==t[e]?(i[o]=t[e-1],i[o+1]=a,a=1,o+=2):++a;return i[o]=t[t.length-1],i[o+1]=a,i}function g(t,e){var r=t.length;e||(e=new t.constructor(r)),r&&(e[0]=t[0]);for(var n=1;r>n;++n)e[n]=t[n]+e[n-1];return e}function v(t,e){var r=t.length;e||(e=new t.constructor(r)),e[0]=t[0];for(var n=1;r>n;++n)e[n]=t[n]-t[n-1];return e}function y(t,e){var r,n,i=t instanceof Int8Array?127:32767,o=-i-1,a=t.length;if(!e){var s=0;for(r=0;a>r;++r)t[r]o&&++s;e=new Int32Array(s)}for(r=0,n=0;a>r;){for(var l=0;t[r]===i||t[r]===o;)l+=t[r],++r;l+=t[r],++r,e[n]=l,++n}return e}function _(t,e,r){return p(y(t,l(r)),e,r)}function x(t,e,r){var n,o,a,s=y(t,l(r));return n=s,o=e,a=i(Float32Array,s,4),p(g(n,l(a)),o,a)}function b(t,e,r){return function(t,e){var r,n=e?127:32767,i=-n-1,o=t.length,a=0;for(r=0;o>r;++r)0===(c=t[r])?++a:a+=c===n||c===i?2:c>0?Math.ceil(c/n):Math.ceil(c/i);var s=e?new Int8Array(a):new Int16Array(a),l=0;for(r=0;o>r;++r){var c;if((c=t[r])>=0)for(;c>=n;)s[l]=n,++l,c-=n;else for(;i>=c;)s[l]=i,++l,c-=i;s[l]=c,++l}return s}(v(d(t,e),n),r);var n}function w(t,e,r,n){var i=new ArrayBuffer(12+n.byteLength),o=new Uint8Array(i),a=new DataView(i);return a.setInt32(0,t),a.setInt32(4,e),r&&o.set(r,8),o.set(n,12),o}function S(t){return w(2,t.length,void 0,a(t))}function M(t){return w(4,t.length,void 0,h(t))}function A(t,e){return w(5,t.length/e,h([e]),a(t))}function E(t){return w(6,t.length,void 0,h(m(t)))}function C(t){return w(8,t.length,void 0,h(m(v(t))))}function T(t,e){return w(9,t.length,h([e]),h(m(d(t,e))))}function P(t,e){return w(10,t.length,h([e]),function(t,e){var r=t.length;e||(e=new Uint8Array(2*r));for(var n=o(e),i=0;r>i;++i)n.setInt16(2*i,t[i]);return a(e)}(b(t,e)))}function L(t){var e={};return F.forEach(function(r){void 0!==t[r]&&(e[r]=t[r])}),t.bondAtomList&&(e.bondAtomList=M(t.bondAtomList)),t.bondOrderList&&(e.bondOrderList=S(t.bondOrderList)),e.xCoordList=P(t.xCoordList,1e3),e.yCoordList=P(t.yCoordList,1e3),e.zCoordList=P(t.zCoordList,1e3),t.bFactorList&&(e.bFactorList=P(t.bFactorList,100)),t.atomIdList&&(e.atomIdList=C(t.atomIdList)),t.altLocList&&(e.altLocList=E(t.altLocList)),t.occupancyList&&(e.occupancyList=T(t.occupancyList,100)),e.groupIdList=C(t.groupIdList),e.groupTypeList=M(t.groupTypeList),t.secStructList&&(e.secStructList=S(t.secStructList)),t.insCodeList&&(e.insCodeList=E(t.insCodeList)),t.sequenceIndexList&&(e.sequenceIndexList=C(t.sequenceIndexList)),e.chainIdList=A(t.chainIdList,4),t.chainNameList&&(e.chainNameList=A(t.chainNameList,4)),e}function R(t){function e(t){for(var e={},r=0;t>r;r++){e[o()]=o()}return e}function r(e){var r=t.subarray(a,a+e);return a+=e,r}function n(e){var r=t.subarray(a,a+e);a+=e;if(e>65535){for(var n=[],i=0;ir;r++)e[r]=o();return e}function o(){var o,l,c=t[a];if(0==(128&c))return a++,c;if(128==(240&c))return a++,e(l=15&c);if(144==(240&c))return a++,i(l=15&c);if(160==(224&c))return a++,n(l=31&c);if(224==(224&c))return o=s.getInt8(a),a++,o;switch(c){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return l=s.getUint8(a+1),a+=2,r(l);case 197:return l=s.getUint16(a+1),a+=3,r(l);case 198:return l=s.getUint32(a+1),a+=5,r(l);case 202:return o=s.getFloat32(a+1),a+=5,o;case 203:return o=s.getFloat64(a+1),a+=9,o;case 204:return o=t[a+1],a+=2,o;case 205:return o=s.getUint16(a+1),a+=3,o;case 206:return o=s.getUint32(a+1),a+=5,o;case 208:return o=s.getInt8(a+1),a+=2,o;case 209:return o=s.getInt16(a+1),a+=3,o;case 210:return o=s.getInt32(a+1),a+=5,o;case 217:return l=s.getUint8(a+1),a+=2,n(l);case 218:return l=s.getUint16(a+1),a+=3,n(l);case 219:return l=s.getUint32(a+1),a+=5,n(l);case 220:return l=s.getUint16(a+1),a+=3,i(l);case 221:return l=s.getUint32(a+1),a+=5,i(l);case 222:return l=s.getUint16(a+1),a+=3,e(l);case 223:return l=s.getUint32(a+1),a+=5,e(l)}throw new Error("Unknown type 0x"+c.toString(16))}var a=0,s=new DataView(t.buffer);return o()}function N(t,e,r,n){switch(t){case 1:return function(t,e){var r=t.length;e||(e=new Float32Array(r/4));for(var n=o(e),i=o(t),a=0,s=0,l=r/4;l>a;++a,s+=4)n.setFloat32(s,i.getFloat32(s),!0);return e}(e);case 2:return s(e);case 3:return c(e);case 4:return u(e);case 5:return a(e);case 6:return f(u(e),new Uint8Array(r));case 7:return f(u(e));case 8:return g(f(u(e)),m);case 9:return i=u(e),h=u(n)[0],p(f(i,l(d)),h,d);case 10:return x(c(e),u(n)[0]);case 11:return p(c(e),u(n)[0]);case 12:return _(c(e),u(n)[0]);case 13:return _(s(e),u(n)[0]);case 14:return y(c(e));case 15:return y(s(e))}var i,h,d,m}function I(t,e){var r=(e=e||{}).ignoreFields,n={};return k.forEach(function(e){var i,a,s,l,c,u=!!r&&-1!==r.indexOf(e),h=t[e];u||void 0===h||(h instanceof Uint8Array?n[e]=N.apply(null,(a=o(i=h),s=a.getInt32(0),l=a.getInt32(4),c=i.subarray(8,12),[s,i=i.subarray(12),l,c])):n[e]=h)}),n}function O(t){return String.fromCharCode.apply(null,t).replace(/\0/g,"")}function D(t,e){return t instanceof ArrayBuffer&&(t=new Uint8Array(t)),I(t instanceof Uint8Array?R(t):t,e)}function z(t,e,r,n){var i=new XMLHttpRequest;i.addEventListener("load",function(){try{var t=D(i.response);r(t)}catch(t){n(t)}},!0),i.addEventListener("error",n,!0),i.responseType="arraybuffer",i.open("GET",e+t.toUpperCase()),i.send()}var F=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],k=F.concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]),B="//mmtf.rcsb.org/v1.0/",U=B+"full/",V=B+"reduced/";t.encode=function(t){return n(L(t))},t.decode=D,t.traverse=function(t,e,r){var n,i,o,a,s,l,c=(r=r||{}).firstModelOnly,u=e.onModel,h=e.onChain,p=e.onGroup,d=e.onAtom,f=e.onBond,m=0,g=0,v=0,y=0,_=0,x=-1,b=t.chainNameList,w=t.secStructList,S=t.insCodeList,M=t.sequenceIndexList,A=t.atomIdList,E=t.bFactorList,C=t.altLocList,T=t.occupancyList,P=t.bondAtomList,L=t.bondOrderList;for(n=0,i=t.chainsPerModel.length;i>n&&!(c&&m>0);++n){var R=t.chainsPerModel[m];for(u&&u({chainCount:R,modelIndex:m}),o=0;R>o;++o){var N=t.groupsPerChain[g];if(h){var I=O(t.chainIdList.subarray(4*g,4*g+4)),D=null;b&&(D=O(b.subarray(4*g,4*g+4))),h({groupCount:N,chainIndex:g,modelIndex:m,chainId:I,chainName:D})}for(a=0;N>a;++a){var z=t.groupList[t.groupTypeList[v]],F=z.atomNameList.length;if(p){var k=null;w&&(k=w[v]);var B=null;t.insCodeList&&(B=String.fromCharCode(S[v]));var U=null;M&&(U=M[v]),p({atomCount:F,groupIndex:v,chainIndex:g,modelIndex:m,groupId:t.groupIdList[v],groupType:t.groupTypeList[v],groupName:z.groupName,singleLetterCode:z.singleLetterCode,chemCompType:z.chemCompType,secStruct:k,insCode:B,sequenceIndex:U})}for(s=0;F>s;++s){if(d){var V=null;A&&(V=A[y]);var j=null;E&&(j=E[y]);var G=null;C&&(G=String.fromCharCode(C[y]));var H=null;T&&(H=T[y]),d({atomIndex:y,groupIndex:v,chainIndex:g,modelIndex:m,atomId:V,element:z.elementList[s],atomName:z.atomNameList[s],formalCharge:z.formalChargeList[s],xCoord:t.xCoordList[y],yCoord:t.yCoordList[y],zCoord:t.zCoordList[y],bFactor:j,altLoc:G,occupancy:H})}y+=1}if(f){var W=z.bondAtomList;for(s=0,l=z.bondOrderList.length;l>s;++s)f({atomIndex1:y-F+W[2*s],atomIndex2:y-F+W[2*s+1],bondOrder:z.bondOrderList[s]})}v+=1}g+=1}if(_=x+1,x=y-1,f&&P)for(s=0,l=P.length;l>s;s+=2){var X=P[s],Y=P[s+1];(X>=_&&x>=X||Y>=_&&x>=Y)&&f({atomIndex1:X,atomIndex2:Y,bondOrder:L?L[s/2]:null})}m+=1}},t.fetch=function(t,e,r){z(t,U,e,r)},t.fetchReduced=function(t,e,r){z(t,V,e,r)},t.version="v1.1.0dev",t.fetchUrl=U,t.fetchReducedUrl=V,t.encodeMsgpack=n,t.encodeMmtf=L,t.decodeMsgpack=R,t.decodeMmtf=I})(e)}),zy=_d.Complex,Fy=_d.Chain,ky=_d.Atom,By=_d.AtomName,Uy=_d.Element,Vy=_d.Helix,jy=_d.Sheet,Gy=_d.Strand,Hy=_d.Bond,Wy=_d.Assembly,Xy=_d.Molecule;function Yy(t){this._original=Array.from(t),this._original.sort(),this._sum=0;for(var e=0;e=this._complex._atoms.length)){var r=Math.min(t.atomIndex1,t.atomIndex2);this._complex.addBond(this._complex._atoms[r],this._complex._atoms[e],t.bondOrder,Hy.BondType.UNKNOWN,!0)}},qy.prototype._updateSecStructure=function(t,e,r){if(!n.isUndefined(r)&&r.secStruct===this._ssType)return e._secondary=this._ssStruct,void((this._ssStruct instanceof Vy||this._ssStruct instanceof Gy)&&this._ssStruct._residues.push(e));if(-1!==this._ssType&&(this._ssStruct instanceof Vy||this._ssStruct instanceof Gy)&&(this._ssStruct._end=this._ssStruct._residues[this._ssStruct._residues.length-1]),!n.isUndefined(r)){this._ssType=r.secStruct,this._ssStart=e;var i=null;switch(this._ssType){case-1:break;case 0:case 2:case 4:i=new Vy(0,"",e,null,[3,-1,1,-1,5][this._ssType],"",0),t._helices.push(i);break;case 3:var o=new jy("",0);t._sheets.push(o),i=new Gy(o,e,null,0);break;default:i={type:"mmtf"+this._ssType}}this._ssStruct=i,e._secondary=i}},qy.prototype._updateMolecules=function(t){var e=t.entityList;if(e)for(var r=t.chainsPerModel[0],n=0;n=r)){var c=this._complex._chains[l];a=a.concat(c._residues.slice())}}var u=new Xy(this._complex,i.description,n+1);u._residues=a,this._complex._molecules[n]=u}},qy.prototype._traverse=function(t){var e=this,r={onModel:function(t){e._onModel(t)},onChain:function(t){e._onChain(t)},onGroup:function(t){e._onGroup(t)},onAtom:function(t){e._onAtom(t)},onBond:function(t){e._onBond(t)}};this._ssType=-1,this._ssStruct=null,this._ssStart=null,Dy.traverse(t,r),this._updateSecStructure(this._complex),this._updateMolecules(t)},qy.prototype._linkAtomsToResidues=function(){for(var t=0;t=e))for(var a=this._complex._chains[o],s=0;s0&&u.addChain(r[m])}u.matrices=h,t.structures.push(u)}}}},o_._parseToObject=function(t){var e,r,i,o,a=0,s=0,l=t.length,c=NaN,u=!0,h=1,p=1,d=0,f="unexpected character",m={},g={},v=[],y=0,_="",x=[],b=0;function w(t){return 32===t||10===t||13===t||9===t}function S(t,e,r){for(var n=e.length,i=-1;r=l||w(t.charCodeAt(a+1)))){if(u&&59===c){s=a;var r=0;do{if(-1===(s=S(10,t,s+1)))return f="unterminated text block found",null;++r}while(s+1=l);return e=t.substring(a+1,s).replace(/\r/g,""),a=s+2,h+=r,p=1,u=!1,e}if(39===c||34===c){s=a;do{if(-1===(s=S(c,t,s+1)))return f="unterminated quoted string found",null}while(s+10){for(var A=0;A-e.near?"hidden":"visible",s=1e4*(e.far- -this._vector.z)/(e.far-e.near),l=t.getElement();if(void 0===r.fog)l.style.color=i(t.userData.color),"transparent"!==t.userData.background&&(l.style.background=i(t.userData.background));else{var c=ve.smoothstep(-this._vector.z,r.fog.near,r.fog.far);l.style.color=n(t.userData.color,r.fog.color,c),"transparent"!==t.userData.background&&(l.style.background=n(t.userData.background,r.fog.color,c))}this._vector.applyMatrix4(this._projectionMatrix);var u=(t.userData!=={}?t.userData.translation:"translate(-50%, -50%) ")+"translate("+(this._vector.x*this._widthHalf+this._widthHalf)+"px,"+(-this._vector.y*this._heightHalf+this._heightHalf)+"px)";l.style.visibility=a,l.style.WebkitTransform=u,l.style.MozTransform=u,l.style.oTransform=u,l.style.transform=u,l.style.zIndex=Number(s).toFixed(0),l.parentNode!==this._domElement&&this._domElement.appendChild(l)}for(var h=0,p=t.children.length;h0&&(this._altObj.setObjects(a.objects),this._altObj.pivot=a.pivot,"axis"in a?this._altObj.axis=a.axis.clone():this._altObj.axis.set(0,0,1),this._altObj.translate(new ye(o*n,o*i)),this.dispatchEvent({type:"change",action:"translate"}))}else o*=10*(qu.now.inversePanning?-1:1),this.camera.translateX(o*n),this.camera.translateY(o*i),this.dispatchEvent({type:"change",action:"pan"})}}this._lastUpdateTime=t},__.prototype.reset=function(){this._state=v_.NONE,this.object.quaternion.copy(new Ge(0,0,0,1))},__.prototype.mousedown=function(t){if(!1!==this.enabled&&this._state===v_.NONE){if(t.preventDefault(),t.stopPropagation(),this._state===v_.NONE)if(0===t.button){this._affectedObj.stop();var e=!1;if(t.altKey){var r=this.getAltObj();(e=r.objects.length>0)&&(this._altObj.setObjects(r.objects),this._altObj.pivot=r.pivot,"axis"in r?this._altObj.axis=r.axis.clone():this._altObj.axis.set(0,0,1))}this._affectedObj=e?this._altObj:this._mainObj,this._state=e&&t.ctrlKey&&this._isTranslationAllowed?v_.TRANSLATE:v_.ROTATE}else 2===t.button&&(this._state=v_.TRANSLATE_PIVOT);this._state===v_.ROTATE&&(this._mouseCurPos.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos)),this._state!==v_.TRANSLATE&&this._state!==v_.TRANSLATE_PIVOT||(this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos))}},__.prototype.mousemove=function(t){if(!1!==this.enabled&&this._state!==v_.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case v_.ROTATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this.rotateByMouse(t.altKey&&!this._isAltObjFreeRotationAllowed||t.shiftKey),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case v_.TRANSLATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translate();break;case v_.TRANSLATE_PIVOT:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translatePivotByMouse()}},__.prototype.mousewheel=function(t){if(!1!==this.enabled&&qu.now.zooming&&this._state===v_.NONE&&!t.shiftKey){t.preventDefault();var e=0;t.wheelDelta?e=t.wheelDelta/40:t.detail&&(e=-t.detail/3);var r=1+.05*e;this.scale(r),this.dispatchEvent({type:"change",action:"zoom",factor:r})}},__.prototype.mouseup=function(t){!1!==this.enabled&&this._state!==v_.NONE&&(t.preventDefault(),t.stopPropagation(),this._state=v_.NONE,this._clock.getElapsedTime()-this._lastMouseMoveTime>.1&&this._affectedObj.stop())},__.prototype.touchstartend=function(t){if(!1!==this.enabled)switch(t.preventDefault(),t.stopPropagation(),t.touches.length){case 1:this._state=v_.ROTATE,this._mouseCurPos.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY)),this._mousePrevPos.copy(this._mouseCurPos);break;case 2:this._mainObj.stop(),this._altObj.stop(),this._state=v_.SCALE_PAN;var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY;this._touchDistanceCur=this._touchDistanceStart=Math.sqrt(e*e+r*r),this._scaleStart=this.object.scale.x,this._originalPinchCenter=new ye(.5*(t.touches[0].pageX+t.touches[1].pageX),.5*(t.touches[0].pageY+t.touches[1].pageY)),this._originalCameraPos.copy(this.camera.position);break;default:this._state=v_.NONE}},__.prototype.touchmove=function(t){if(!1!==this.enabled&&this._state!==v_.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case v_.ROTATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY)),this.rotateByMouse(!1),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case v_.SCALE_PAN:if(qu.now.zooming){var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY;this._touchDistanceCur=Math.sqrt(e*e+r*r);var n=this.object.scale.x,i=this._scaleStart*this._touchDistanceCur/this._touchDistanceStart;this.setScale(i),this.dispatchEvent({type:"change",action:"zoom",factor:0===n?1:i/n})}if(qu.now.panning){var o=new ye(.5*(t.touches[0].pageX+t.touches[1].pageX),.5*(t.touches[0].pageY+t.touches[1].pageY));o.sub(this._originalPinchCenter),this.camera.position.x=this._originalCameraPos.x-.1*o.x,this.camera.position.y=this._originalCameraPos.y+.1*o.y,this.dispatchEvent({type:"change",action:"pan"})}}},__.prototype.keydownup=function(t){if(!1!==this.enabled&&!1!==this.hotkeysEnabled)switch(t.keyCode){case 37:case 38:case 39:case 40:this._pressedKeys[t.keyCode]="keydown"===t.type,t.preventDefault(),t.stopPropagation()}},__.prototype.getKeyBindObject=function(){return window.top},__.prototype.dispose=function(){for(var t=0;t0){var o=e[0],a=new He;if(qu.now.draft.clipPlane&&this.hasOwnProperty("clipPlaneValue")){var s;for(s=0;s=S_?t-M_:t}function P_(t,e,r){this._complex=t,this._secondary=null,this.isLoading=!1,this._framesRange={start:0,end:-1},this.frameIsReady=!1,this._buffer=null,this._frameRequest=null,this._callbacks=r,"function"==typeof e?(this._framesRequestLength=1,this._downloadDataFn=e):this.parseBinaryData(e,!0),this.reset(),this.setFrame(0)}function L_(t,e){if(this.constructor===L_)throw new Error("Can not instantiate abstract class!");this.params=t,this.opts=n.merge(Iu.deriveDeep(qu.now.objects[this.type],!0),e),this.needsRebuild=!1}function R_(t,e){if(L_.call(this,t,e),t.length<2)throw new Error("Wrong number of argumets on line object creation!");this._id1=t[0],this._id2=t[1]}P_.prototype._prepareBuffer=function(t,e){if(void 0!==t&&null!==t||(t=0),void 0!==e&&null!==e||(e=t+this._framesRequestLength),void 0!==this._framesCount&&(e=Math.min(this._framesCount-1,e)),this._downloadDataFn){var r=this;this._buffer||(this._buffer={}),this._buffer.state="downloading",this.isLoading=!0,r._callbacks&&"function"==typeof r._callbacks.onLoadStatusChanged&&r._callbacks.onLoadStatusChanged(),this._downloadDataFn({start:t,end:e+1},function(n){if(r.isLoading=!1,r._callbacks&&"function"==typeof r._callbacks.onLoadStatusChanged&&r._callbacks.onLoadStatusChanged(),r._buffer={data:n,state:"ready",start:t,end:e},null!==r._frameRequest){var i=r._frameRequest;r._frameRequest=null,r.setFrame(i)}},function(){r.isLoading=!1,r._callbacks&&"function"==typeof r._callbacks.onError&&r._callbacks.onError("Streaming failed")})}},P_.prototype._parseBuffer=function(){if(this._buffer&&"ready"===this._buffer.state){this._framesRange={start:this._buffer.start,end:this._buffer.end},this.parseBinaryData(this._buffer.data,!1);var t=(this._buffer.end+1)%this._framesCount;if(t>=this._framesCount&&(t=0),this._buffer={state:"none"},this._prepareBuffer(t,t+this._framesRequestLength),null!==this._frameRequest){var e=this._frameRequest;this._frameRequest=null,this.setFrame(e)}}},P_.prototype.parseBinaryData=function(t){var e=new DataView(t),r=0,n=e.getUint32(r,!0);r+=4;var i=e.getUint32(r,!0);this._framesCount=i,this._framesRange.end=this._framesRange.end>0?Math.min(this._framesRange.end,i-1):i-1,r+=4,this._atomsCount=n;this._framesRequestLength=Math.ceil(1048576/(8*n));var o=this._framesRange.end-this._framesRange.start+1;if(n!==this._complex._atoms.length||t.byteLength!==12+o*n*8)throw new Error;for(var a=this._complex,s=e.getUint32(r,!0),l=0;s>1e3&&l>>28,y=T_((268435200&g)>>>8>>0),_=T_(((255&g)<<12|(4293918720&m)>>>20)>>0),x=T_((1048575&m)>>0);p[f]=0,v>0&&v<4?p[f]=1:4===v&&(p[f]=2),u[h++]=y/100,u[h++]=_/100,u[h++]=x/100}c.push(C_(p,a))}this._secondaryData=c,this._data=u},P_.prototype.nextFrame=function(){this.setFrame((this._currFrame+1)%this._framesCount)},P_.prototype.needsColorUpdate=function(t){return t instanceof xv},P_.prototype.getAtomColor=function(t,e){return t.getResidueColor(this._residues[e._residue._index],this._complex)},P_.prototype.getResidueColor=function(t,e){return t.getResidueColor(this._residues[e._index],this._complex)},P_.prototype._updateSecondary=function(){var t,e=this._residues,r=e.length;for(t=0;t=this._framesRange.start&&t<=this._framesRange.end)this._currFrame=t,this._cachedResidues=!1,this._updateSecondary(),this.frameIsReady=!0;else if(this._frameRequest=t,this._buffer){switch(this._buffer.state){case"none":this._prepareBuffer(t);break;case"ready":this._parseBuffer()}}else this._prepareBuffer(t)},P_.prototype.disableEvents=function(){this._callbacks=null},P_.prototype.getAtomPos=(w_=new He,function(t){var e=this._data,r=3*(this._atomsCount*(this._currFrame-this._framesRange.start)+t);return w_.set(e[r],e[r+1],e[r+2]),w_}),P_.prototype.getResidues=function(){return this._cachedResidues?this._residues:(this._complex.updateToFrame(this),this._residues)},L_.prototype.type="__",L_.prototype.identify=function(){var t={type:this.type,params:this.params},e=Iu.objectsDiff(this.opts,qu.now.modes[this.id]);return n.isEmpty(e)||(t.opts=e),t},L_.prototype.toString=function(){return"o="+this.type+","+this.params.join(",")+Iu.compareOptionsWithDefaults(this.opts,qu.defaults.objects[this.type])},L_.prototype.getGeometry=function(){return this._mesh},L_.prototype.destroy=function(){this._mesh&&Od.destroyObject(this._mesh)},Iu.deriveClass(R_,L_,{type:"line"}),R_.prototype.constructor=R_,R_.prototype._getAtomFromName=function(t,e){var r=t.getAtomByFullname(e);if(!r)throw new Error(e+" - Wrong atom format it must be '#CHAIN_NAME.#NUMBER.#ATOM_NAME' (e.g. 'A.38.CO1')");return r},R_.prototype.build=function(t){var e=new Di;this._atom1=this._getAtomFromName(t,this._id1),this._atom2=this._getAtomFromName(t,this._id2),e.vertices[0]=this._atom1._position.clone(),e.vertices[1]=this._atom2._position.clone(),e.dynamic=!0,e.computeLineDistances(),e.computeBoundingBox(),this._line=new mm.Line(e,new Cd({lights:!1,overrideColor:!0,dashedLine:!0})),this._line.material.setUberOptions({fixedColor:new Or(this.opts.color),dashedLineSize:this.opts.dashSize,dashedLinePeriod:this.opts.dashSize+this.opts.gapSize}),this._line.material.updateUniforms(),this._line.raycast=function(t,e){},this._mesh=this._line;var r=t.getTransforms();r.length>0&&(this._mesh=new ta,this._mesh.add(this._line),Od.applyTransformsToMeshes(this._mesh,r))},R_.prototype.updateToFrame=function(t){if(this._atom1&&this._atom2&&this._line){var e=this._line.geometry;e.vertices[0].copy(t.getAtomPos(this._atom1._index)),e.vertices[1].copy(t.getAtomPos(this._atom2._index)),e.computeLineDistances(),e.computeBoundingSphere(),e.verticesNeedUpdate=!0}};var N_="varying vec2 vUv;\r\n\r\nvoid main() {\r\n vUv = uv;\r\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\r\n}\r\n",I_="uniform sampler2D srcTex;\r\nuniform vec2 srcTexSize;\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n\r\n vec2 pixelSize = vec2(1, 1) / srcTexSize;\r\n\r\n vec4 c00 = texture2D(srcTex, vUv + vec2(-pixelSize.x,-pixelSize.y));\r\n vec4 c01 = texture2D(srcTex, vUv + vec2(0,-pixelSize.y));\r\n vec4 c02 = texture2D(srcTex, vUv + vec2(pixelSize.x,-pixelSize.y));\r\n vec4 c10 = texture2D(srcTex, vUv + vec2(-pixelSize.x,0));\r\n vec4 c12 = texture2D(srcTex, vUv + vec2(pixelSize.x,0));\r\n vec4 c20 = texture2D(srcTex, vUv + vec2(-pixelSize.x,pixelSize.y));\r\n vec4 c21 = texture2D(srcTex, vUv + vec2(0,pixelSize.y));\r\n vec4 c22 = texture2D(srcTex, vUv + vec2(pixelSize.x,pixelSize.y));\r\n\r\n vec4 horizEdge = - c00 - 2.0 * c01 - c02 + c20 + 2.0 * c21 + c22;\r\n vec4 vertEdge = - c00 - 2.0 * c10 - c20 + c02 + 2.0 * c12 + c22;\r\n\r\n vec4 grad = sqrt(horizEdge * horizEdge + vertEdge * vertEdge);\r\n\r\n gl_FragColor = grad;\r\n}\r\n",O_=kr.merge([{srcTex:{type:"t",value:null},srcTexSize:{type:"v2",value:new ye(512,512)},opacity:{type:"f",value:1}}]);function D_(t){return new dn({uniforms:function(t){var e=kr.clone(O_);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:N_,fragmentShader:I_,transparent:!0,depthTest:!1,depthWrite:!1})}var z_="// edge end finding algorithm parameters\r\n#define FXAA_QUALITY_PS 8\r\n#define FXAA_QUALITY_P0 1.0\r\n#define FXAA_QUALITY_P1 1.5\r\n#define FXAA_QUALITY_P2 2.0\r\n#define FXAA_QUALITY_P3 2.0\r\n#define FXAA_QUALITY_P4 2.0\r\n#define FXAA_QUALITY_P5 2.0\r\n#define FXAA_QUALITY_P6 4.0\r\n#define FXAA_QUALITY_P7 12.0\r\n// constants\r\nfloat fxaaQualityEdgeThreshold = 0.125;\r\nfloat fxaaQualityEdgeThresholdMin = 0.0625;\r\nfloat fxaaQualitySubpix = 0.7; //0.65;\r\n// global params\r\nuniform sampler2D srcTex;\r\nuniform vec2 srcTexelSize;\r\n// from vs\r\nvarying vec2 vUv;\r\n//=====================================================================//\r\n// calc luminance from rgb\r\n//'float FxaaLuma(vec3 rgb) {return rgb.y * (0.587/0.299) + rgb.x; } // Lotte's idea about game luminance\r\nfloat FxaaLuma(vec3 rgb) {return dot(rgb, vec3(0.299, 0.587, 0.114)); } // real luminance calculation\r\n // for non-real scene rendering\r\n// texture sampling by pixel position(coords) and offset(in pixels)\r\nvec3 FxaaTex(sampler2D tex, vec2 pos, vec2 off, vec2 res ) {return texture2D( tex, pos + off * res ).xyz;}\r\nvec3 FxaaTexTop(sampler2D tex, vec2 pos) {return texture2D( tex, pos).xyz;}\r\n//=====================================================================//\r\nvoid main() {\r\n// renaming\r\n vec2 posM = vUv;\r\n// get luminance for neighbours\r\n float lumaS = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, 1.0 ), srcTexelSize));\r\n float lumaE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 0.0 ), srcTexelSize));\r\n float lumaN = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, -1.0 ), srcTexelSize));\r\n float lumaW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 0.0 ), srcTexelSize));\r\n float lumaM = FxaaLuma(FxaaTexTop(srcTex, posM));\r\n// find max and min luminance\r\n float rangeMax = max(max(lumaN, lumaW), max(lumaE, max(lumaS, lumaM)));\r\n float rangeMin = min(min(lumaN, lumaW), min(lumaE, min(lumaS, lumaM)));\r\n// calc maximum non-edge range\r\n float rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\r\n float range = rangeMax - rangeMin;\r\n float rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\r\n// exit when luma contrast is small (is not edge)\r\n if(range < rangeMaxClamped){\r\n gl_FragColor = vec4(FxaaTexTop(srcTex, posM).xyz, 1.0);\r\n return;\r\n }\r\n float subpixRcpRange = 1.0/range;\r\n// calc other neighbours luminance\r\n float lumaNE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, -1.0 ), srcTexelSize));\r\n float lumaSW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 1.0 ), srcTexelSize));\r\n float lumaSE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 1.0 ), srcTexelSize));\r\n float lumaNW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, -1.0 ), srcTexelSize));\r\n/*--------------span calculation and subpix amount calulation-----------------*/\r\n float lumaNS = lumaN + lumaS;\r\n float lumaWE = lumaW + lumaE;\r\n float subpixNSWE = lumaNS + lumaWE;\r\n float edgeHorz1 = (-2.0 * lumaM) + lumaNS;\r\n float edgeVert1 = (-2.0 * lumaM) + lumaWE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNESE = lumaNE + lumaSE;\r\n float lumaNWNE = lumaNW + lumaNE;\r\n float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\r\n float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNWSW = lumaNW + lumaSW;\r\n float lumaSWSE = lumaSW + lumaSE;\r\n float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\r\n float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\r\n float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\r\n float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\r\n float edgeHorz = abs(edgeHorz3) + edgeHorz4;\r\n float edgeVert = abs(edgeVert3) + edgeVert4;\r\n/*--------------------subpix amount calulation------------------------------*/\r\n float subpixNWSWNESE = lumaNWSW + lumaNESE;\r\n float lengthSign = srcTexelSize.x;\r\n bool horzSpan = edgeHorz >= edgeVert;\r\n // debug code edge span visualization\r\n/*' if (horzSpan)\r\n gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\r\n else\r\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\r\n return;*/\r\n float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\r\n/*--------------------------------------------------------------------------*/\r\n if(!horzSpan) lumaN = lumaW;\r\n if(!horzSpan) lumaS = lumaE;\r\n if(horzSpan) lengthSign = srcTexelSize.y;\r\n float subpixB = (subpixA * (1.0/12.0)) - lumaM;\r\n/*--------------------------------------------------------------------------*/\r\n float gradientN = lumaN - lumaM;\r\n float gradientS = lumaS - lumaM;\r\n float lumaNN = lumaN + lumaM;\r\n float lumaSS = lumaS + lumaM;\r\n bool pairN = abs(gradientN) >= abs(gradientS);\r\n float gradient = max(abs(gradientN), abs(gradientS));\r\n if(pairN) lengthSign = -lengthSign;\r\n float subpixC = clamp(abs(subpixB) * subpixRcpRange, 0.0, 1.0);\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posB;\r\n posB = posM;\r\n vec2 offNP;\r\n offNP.x = (!horzSpan) ? 0.0 : srcTexelSize.x;\r\n offNP.y = ( horzSpan) ? 0.0 : srcTexelSize.y;\r\n if(!horzSpan) posB.x += lengthSign * 0.5;\r\n if( horzSpan) posB.y += lengthSign * 0.5;\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posN;\r\n posN = posB - offNP * FXAA_QUALITY_P0;\r\n vec2 posP;\r\n posP = posB + offNP * FXAA_QUALITY_P0;\r\n float subpixD = ((-2.0)*subpixC) + 3.0;\r\n float lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN));\r\n float subpixE = subpixC * subpixC;\r\n float lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP));\r\n/*--------------------------------------------------------------------------*/\r\n if(!pairN) lumaNN = lumaSS;\r\n float gradientScaled = gradient * 1.0/4.0;\r\n float lumaMM = lumaM - lumaNN * 0.5;\r\n float subpixF = subpixD * subpixE;\r\n bool lumaMLTZero = lumaMM < 0.0;\r\n/*---------------------looped edge-end search-------------------------------*/\r\n lumaEndN -= lumaNN * 0.5;\r\n lumaEndP -= lumaNN * 0.5;\r\n bool doneN = abs(lumaEndN) >= gradientScaled;\r\n bool doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P1;\r\n bool doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P1;\r\n/*--------------------------------------------------------------------------*/\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P2;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P2;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 3)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P3;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P3;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 4)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P4;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P4;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 5)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P5;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P5;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 6)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P6;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P6;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 7)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P7;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P7;\r\n/*--------------------------------------------------------------------------*/\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n/*----------------calculate subpix offset due to edge ends-------------------*/\r\n float dstN = posM.x - posN.x;\r\n float dstP = posP.x - posM.x;\r\n if(!horzSpan) dstN = posM.y - posN.y;\r\n if(!horzSpan) dstP = posP.y - posM.y;\r\n/*--------------------------------------------------------------------------*/\r\n bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\r\n float spanLength = (dstP + dstN);\r\n bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\r\n float spanLengthRcp = 1.0/spanLength;\r\n/*--------------------------------------------------------------------------*/\r\n bool directionN = dstN < dstP;\r\n float dst = min(dstN, dstP);\r\n bool goodSpan = directionN ? goodSpanN : goodSpanP;\r\n float subpixG = subpixF * subpixF;\r\n float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\r\n float subpixH = subpixG * fxaaQualitySubpix;\r\n/*-----------------calc texture offest using subpix-------------------------*/\r\n float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\r\n float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\r\n if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\r\n if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\r\n gl_FragColor = vec4(FxaaTexTop(srcTex, posM).xyz, 1.0);\r\n return;\r\n}\r\n",F_=kr.merge([{srcTex:{type:"t",value:null},srcTexelSize:{type:"v2",value:new ye(1/512,1/512)}}]);function k_(t){return new dn({uniforms:function(t){var e=kr.clone(F_);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:N_,fragmentShader:z_,transparent:!0,depthTest:!1,depthWrite:!1})}var B_="#define MAX_SAMPLES_COUNT 32\r\n\r\nuniform vec3 samplesKernel[MAX_SAMPLES_COUNT];\r\nuniform sampler2D noiseTexture;\r\nuniform vec2 noiseTexelSize;\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\nuniform vec2 camNearFar;\r\nuniform mat4 projMatrix;\r\n\r\nuniform float aspectRatio;\r\nuniform float tanHalfFOV;\r\n\r\nuniform float kernelRadius;\r\nuniform float depthThreshold;\r\nuniform float factor;\r\n\r\nuniform vec2 fogNearFar;\r\nvarying vec2 vUv;\r\n\r\nfloat CalcViewZ(vec2 screenPos)\r\n{\r\n float depth = texture2D(depthTexture, screenPos).x;\r\n // [0, 1]->[-1, 1]\r\n float clipedZ = 2.0 * depth - 1.0;\r\n // see THREE.js camera.makeFrustum for projection details\r\n return (- projMatrix[3][2] / (clipedZ + projMatrix[2][2]));\r\n}\r\n\r\nvec3 ViewPosFromDepth(vec2 screenPos)\r\n{\r\n vec3 viewPos;\r\n viewPos.z = CalcViewZ(screenPos);\r\n //[0, 1]->[-1, 1]\r\n vec2 projPos = 2.0 * screenPos - 1.0;\r\n vec2 viewRay = vec2(projPos.x * aspectRatio * tanHalfFOV, projPos.y * tanHalfFOV); // TODO mode to vs\r\n // reconstruct viewposition in right-handed sc with z from viewer\r\n viewPos.xy = vec2(viewRay.x * viewPos.z, viewRay.y * viewPos.z);\r\n return viewPos;\r\n}\r\n\r\nvec3 GetDerivative( vec3 p0, vec3 p1, vec3 p2 )\r\n{\r\n vec3 v1 = p1 - p0;\r\n vec3 v2 = p0 - p2;\r\n return ( dot( v1, v1 ) < dot( v2, v2 ) ) ? v1 : v2;\r\n}\r\n\r\nvec3 RestoreNormalFromDepth(vec2 texcoords, vec3 p) {\r\n\r\n vec2 offset1 = vec2(srcTexelSize.x, 0.0);\r\n vec2 offset2 = vec2(0.0, srcTexelSize.y);\r\n\r\n vec3 p1 = ViewPosFromDepth(texcoords + offset1);\r\n vec3 p2 = ViewPosFromDepth(texcoords + offset2);\r\n vec3 p3 = ViewPosFromDepth(texcoords - offset1);\r\n vec3 p4 = ViewPosFromDepth(texcoords - offset2);\r\n\r\n vec3 dx = GetDerivative(p, p3, p1);\r\n vec3 dy = GetDerivative(p, p4, p2);\r\n vec3 normal = cross(dx, dy);\r\n return normalize(normal);\r\n}\r\n\r\nvoid main() {\r\n vec3 viewPos = ViewPosFromDepth(vUv);\r\n // remap coordinates to prevent noise exture rescale\r\n vec2 vUvNoise = vUv / srcTexelSize * noiseTexelSize;\r\n // restore normal from depth buffer\r\n vec3 normal = RestoreNormalFromDepth(vUv, viewPos); \r\n // get random vector for sampling sphere rotation\r\n vec3 randN = texture2D(noiseTexture, vUvNoise).rgb * 2.0 - 1.0;\r\n randN = normalize(randN);\r\n // build TBN (randomly rotated around normal)\r\n vec3 tangent = normalize(randN - normal * dot(randN, normal));\r\n vec3 bitangent = cross(tangent, normal);\r\n mat3 TBN = mat3(tangent, bitangent, normal);\r\n // calc AO value\r\n float AO = 0.0;\r\n for (int i = 0 ; i < MAX_SAMPLES_COUNT ; i++) {\r\n // rotate sampling kernel around normal\r\n vec3 reflectedSample = TBN * samplesKernel[i];\r\n // get sample\r\n vec3 samplePos = viewPos + reflectedSample * kernelRadius;\r\n // project sample to screen to get sample's screen pos\r\n vec4 offset = vec4(samplePos, 1.0);\r\n offset = projMatrix * offset;\r\n offset.xy /= offset.w;\r\n offset.xy = (-offset.xy + vec2(1.0)) * 0.5;\r\n // get view z for sample projected to the objct surface\r\n float sampleDepth = CalcViewZ(offset.xy);\r\n // calc occlusion made by object surface at the sample\r\n AO += step(samplePos.z, sampleDepth);\r\n }\r\n // add fog to the AO value\r\n AO *= 1.0 - smoothstep(fogNearFar.x, fogNearFar.y, - viewPos.z);\r\n // calc result AO-map color\r\n AO = 1.0 - max(0.0, AO / 32.0 * factor); // TODO use MAX_SAMPLES_COUNT\r\n vec3 color = texture2D(diffuseTexture, vUv).rgb;\r\n // check if the fragment doesn't belong to background\r\n if (abs(- viewPos.z - camNearFar.y) < 0.1) { // FIXME remove temporal fix for background darkening\r\n gl_FragColor = vec4(1.0);\r\n return;\r\n }\r\n // write value to AO-map\r\n gl_FragColor = vec4(AO, AO, AO, 1.0);\r\n}",U_="#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 res = vec4(0.0);\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n vec2 samplePos = vec2(x + samplesOffsets[i] * srcTexelSize.x, y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res += texture2D(aoMap, vec2(x + samplesOffsets[i] * srcTexelSize.x, y )) * weight;\r\n weightSum += weight;\r\n }\r\n gl_FragColor = res / weightSum;\r\n}\r\n",V_="#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 res = vec4(0.0);\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n vec2 samplePos = vec2(x, y + samplesOffsets[i] * srcTexelSize.y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res += texture2D(aoMap, vec2(x, y + samplesOffsets[i] * srcTexelSize.y)) * weight;\r\n weightSum += weight;\r\n }\r\n res /= weightSum;\r\n vec3 color = texture2D(diffuseTexture, vec2(x, y)).rgb;\r\n gl_FragColor = vec4(color * res.rgb, 1.0);\r\n}",j_=kr.merge([{noiseTexture:{type:"t",value:null},noiseTexelSize:{type:"v2",value:new ye(1/512,1/512)},diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new ye(1/512,1/512)},camNearFar:{type:"v2",value:new ye(1,10)},projMatrix:{type:"mat4",value:new We},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0},samplesKernel:{type:"v3v",value:null},kernelRadius:{type:"f",value:1},depthThreshold:{type:"f",value:1},factor:{type:"f",value:1},fogNearFar:{type:"v2",value:new ye(100,100)}}]),G_=kr.merge([{diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new ye(1/512,1/512)},aoMap:{type:"t",value:null},samplesOffsets:{type:"fv1",value:null},camNearFar:{type:"v2",value:new ye(1,10)},projMatrix:{type:"mat4",value:new We},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0}}]);function H_(t,e){var r=kr.clone(e);for(var n in t)r.hasOwnProperty(n)&&(r[n].value=t[n]);return r}var W_={AOMaterial:function(t){return new dn({uniforms:H_(t,j_),vertexShader:N_,fragmentShader:B_,transparent:!1,depthTest:!1,depthWrite:!1})},HorBilateralBlurMaterial:function(t){return new dn({uniforms:H_(t,G_),vertexShader:N_,fragmentShader:U_,transparent:!1,depthTest:!1,depthWrite:!1})},VertBilateralBlurMaterial:function(t){return new dn({uniforms:H_(t,G_),vertexShader:N_,fragmentShader:V_,transparent:!1,depthTest:!1,depthWrite:!1})}},X_="uniform sampler2D srcL;\r\nuniform sampler2D srcR;\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n vec4 l = texture2D(srcL, vUv);\r\n vec4 r = texture2D(srcR, vUv);\r\n gl_FragColor = vec4(l.r, r.g, r.b, 1.0);\r\n}\r\n",Y_=kr.merge([{srcL:{type:"t",value:null},srcR:{type:"t",value:null}}]);function q_(t){return new dn({uniforms:function(t){var e=kr.clone(Y_);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:N_,fragmentShader:X_,transparent:!1,depthTest:!1,depthWrite:!1})}function Z_(){this.position=new He(0,0,0),this.scale=1,this.orientation=new Ge(0,0,0,1)}Z_.prototype.set=function(t,e,r){this.position=t,this.scale=e,this.orientation=r};function $_(){}$_.prototype.setup=function(t,e){this._startTime=void 0,this._endTime=void 0,this._srcView=t,this._dstView=e,this._isMoving=!1},$_.prototype.isMoving=function(){return this._isMoving},$_.prototype.wasStarted=function(){return void 0!==this._startTime&&void 0!==this._endTime},$_.prototype.start=function(){this._startTime=Date.now();var t=qu.now.interpolateViews?1500:0;this._endTime=this._startTime+t,this._isMoving=!0},$_.prototype.getCurrentView=function(){if(void 0===this._srcView||void 0===this._dstView||!this._isMoving||!this.wasStarted())return{success:!1};var t=this.createView(),e=Date.now();if(e>this._endTime)return t=this._dstView,this._reset(),{success:!0,view:t};var r=(e-this._startTime)/(this._endTime-this._startTime);return t.position.copy(this._srcView.position),t.position.lerp(this._dstView.position,r),t.scale=(1-r)*this._srcView.scale+r*this._dstView.scale,t.orientation.copy(this._srcView.orientation),t.orientation.slerp(this._dstView.orientation,r),{success:!0,view:t}},$_.prototype._reset=function(){this._startTime=this._endTime=0,this._isMoving=!1},$_.prototype.createView=function(){return new Z_};var K_=new $_,Q_=qu.now.fbxprec,J_='; FBX 6.1.0 project file\n; Copyright (C) 1997-2007 Autodesk Inc. and/or its licensors.\n; All rights reserved.\n; ----------------------------------------------------\n\n FBXHeaderExtension: {\n FBXHeaderVersion: 1003\n FBXVersion: 6100\n CreationTimeStamp: {\n Version: 1000\n Year: 2015\n Month: 12\n Day: 7\n Hour: 17\n Minute: 34\n Second: 53\n Millisecond: 369\n }\n Creator: "FBX SDK/FBX Plugins build 20080212"\n OtherFlags: {\n FlagPLE: 0\n }\n}\nreationTime: "2015-12-07 17:34:53:369"\nreator: "FBX SDK/FBX Plugins build 20080212"\n\n; Document Description\n;------------------------------------------------------------------\n\n Document: {\n Name: ""\n}\n\n; Document References\n;------------------------------------------------------------------\n\n References: {\n}\n\n; Object definitions\n;------------------------------------------------------------------\n\n Definitions: {\n Version: 100\n Count: 3\n ObjectType: "Model" {\n Count: 1\n }\n ObjectType: "SceneInfo" {\n Count: 1\n }\n ObjectType: "GlobalSettings" {\n Count: 1\n }\n}\n\n; Object properties\n;------------------------------------------------------------------\n\n Objects: {\n Model: "Model::Sphere01", "Mesh" {\n Version: 232\n Properties60: {\n Property: "QuaternionInterpolate", "bool", "",0\n Property: "RotationOffset", "Vector3D", "",0,0,0\n Property: "RotationPivot", "Vector3D", "",0,0,0\n Property: "ScalingOffset", "Vector3D", "",0,0,0\n Property: "ScalingPivot", "Vector3D", "",0,0,0\n Property: "TranslationActive", "bool", "",0\n Property: "TranslationMin", "Vector3D", "",0,0,0\n Property: "TranslationMax", "Vector3D", "",0,0,0\n Property: "TranslationMinX", "bool", "",0\n Property: "TranslationMinY", "bool", "",0\n Property: "TranslationMinZ", "bool", "",0\n Property: "TranslationMaxX", "bool", "",0\n Property: "TranslationMaxY", "bool", "",0\n Property: "TranslationMaxZ", "bool", "",0\n Property: "RotationOrder", "enum", "",0\n Property: "RotationSpaceForLimitOnly", "bool", "",0\n Property: "RotationStiffnessX", "double", "",0\n Property: "RotationStiffnessY", "double", "",0\n Property: "RotationStiffnessZ", "double", "",0\n Property: "AxisLen", "double", "",10\n Property: "PreRotation", "Vector3D", "",0,0,0\n Property: "PostRotation", "Vector3D", "",0,0,0\n Property: "RotationActive", "bool", "",0\n Property: "RotationMin", "Vector3D", "",0,0,0\n Property: "RotationMax", "Vector3D", "",0,0,0\n Property: "RotationMinX", "bool", "",0\n Property: "RotationMinY", "bool", "",0\n Property: "RotationMinZ", "bool", "",0\n Property: "RotationMaxX", "bool", "",0\n Property: "RotationMaxY", "bool", "",0\n Property: "RotationMaxZ", "bool", "",0\n Property: "InheritType", "enum", "",1\n Property: "ScalingActive", "bool", "",0\n Property: "ScalingMin", "Vector3D", "",1,1,1\n Property: "ScalingMax", "Vector3D", "",1,1,1\n Property: "ScalingMinX", "bool", "",0\n Property: "ScalingMinY", "bool", "",0\n Property: "ScalingMinZ", "bool", "",0\n Property: "ScalingMaxX", "bool", "",0\n Property: "ScalingMaxY", "bool", "",0\n Property: "ScalingMaxZ", "bool", "",0\n Property: "GeometricTranslation", "Vector3D", "",0,0,0\n Property: "GeometricRotation", "Vector3D", "",0,0,0\n Property: "GeometricScaling", "Vector3D", "",1,1,1\n Property: "MinDampRangeX", "double", "",0\n Property: "MinDampRangeY", "double", "",0\n Property: "MinDampRangeZ", "double", "",0\n Property: "MaxDampRangeX", "double", "",0\n Property: "MaxDampRangeY", "double", "",0\n Property: "MaxDampRangeZ", "double", "",0\n Property: "MinDampStrengthX", "double", "",0\n Property: "MinDampStrengthY", "double", "",0\n Property: "MinDampStrengthZ", "double", "",0\n Property: "MaxDampStrengthX", "double", "",0\n Property: "MaxDampStrengthY", "double", "",0\n Property: "MaxDampStrengthZ", "double", "",0\n Property: "PreferedAngleX", "double", "",0\n Property: "PreferedAngleY", "double", "",0\n Property: "PreferedAngleZ", "double", "",0\n Property: "LookAtProperty", "object", ""\n Property: "UpVectorProperty", "object", ""\n Property: "Show", "bool", "",1\n Property: "NegativePercentShapeSupport", "bool", "",1\n Property: "DefaultAttributeIndex", "int", "",0\n Property: "Lcl Translation", "Lcl Translation", "A+",-0.169204741716385,-0.507614195346832,0\n Property: "Lcl Rotation", "Lcl Rotation", "A+",0,0,0\n Property: "Lcl Scaling", "Lcl Scaling", "A+",1,1,1\n Property: "Visibility", "Visibility", "A+",1\n Property: "BBoxMin", "Vector3D", "N",0,0,0\n Property: "BBoxMax", "Vector3D", "N",0,0,0\n }\n MultiLayer: 0\n MultiTake: 1\n Shading: T\n Culling: "CullingOff"\n',tx='NodeAttributeName: "Geometry::Sphere01"\n}\nceneInfo: "SceneInfo::GlobalInfo", "UserData" {\n Type: "UserData"\n Version: 100\n MetaData: {\n Version: 100\n Title: ""\n Subject: ""\n Author: ""\n Keywords: ""\n Revision: ""\n Comment: ""\n }\n Properties60: {\n Property: "DocumentUrl", "KString", "", "D:\\depot\\MolViewer\\Assets\\models\\test1.FBX"\n Property: "SrcDocumentUrl", "KString", "", "D:\\depot\\MolViewer\\Assets\\models\\test1.FBX"\n Property: "Original", "Compound", ""\n Property: "Original|ApplicationVendor", "KString", "", "Autodesk"\n Property: "Original|ApplicationName", "KString", "", "3ds Max"\n Property: "Original|ApplicationVersion", "KString", "", "2009.0"\n Property: "Original|DateTime_GMT", "DateTime", "", "07/12/2015 14:34:53.369"\n Property: "Original|FileName", "KString", "", "D:\\depot\\MolViewer\\Assets\\models\\test1.FBX"\n Property: "LastSaved", "Compound", ""\n Property: "LastSaved|ApplicationVendor", "KString", "", "Autodesk"\n Property: "LastSaved|ApplicationName", "KString", "", "3ds Max"\n Property: "LastSaved|ApplicationVersion", "KString", "", "2009.0"\n Property: "LastSaved|DateTime_GMT", "DateTime", "", "07/12/2015 14:34:53.369"\n }\n}\nlobalSettings: {\n Version: 1000\n Properties60: {\n Property: "UpAxis", "int", "",2\n Property: "UpAxisSign", "int", "",1\n Property: "FrontAxis", "int", "",1\n Property: "FrontAxisSign", "int", "",-1\n Property: "CoordAxis", "int", "",0\n Property: "CoordAxisSign", "int", "",1\n Property: "UnitScaleFactor", "double", "",2.54\n }\n}\n}\n\n; Object relations\n;------------------------------------------------------------------\n\n Relations: {\n Model: "Model::Sphere01", "Mesh" {\n }\n SceneInfo: "SceneInfo::GlobalInfo", "UserData" {\n }\n}\n\n; Object connections\n;------------------------------------------------------------------\n\n Connections: {\n Connect: "OO", "Model::Sphere01", "Model::Scene"\n}\n\n;Object data\n;------------------------------------------------------------------\n\n ObjectData: {\n}\n;Takes and animation section\n;----------------------------------------------------\n\n Takes: {\n Current: "Take 001"\n}\n;Version 5 settings\n;------------------------------------------------------------------\n\n Version5: {\n AmbientRenderSettings: {\n Version: 101\n AmbientLightColor: 0.533333003520966,0.533333003520966,0.533333003520966,1\n }\n FogOptions: {\n FlogEnable: 0\n FogMode: 0\n FogDensity: 0.002\n FogStart: 0.3\n FogEnd: 1000\n FogColor: 1,1,1,1\n }\n Settings: {\n FrameRate: "30"\n TimeFormat: 1\n SnapOnFrames: 0\n ReferenceTimeIndex: -1\n TimeLineStartTime: 0\n TimeLineStopTime: 153953860000\n }\n RendererSetting: {\n DefaultCamera: ""\n DefaultViewingMode: 0\n }\n}\n\n';function ex(t){var e;switch(t.code){case FileError.QUOTA_EXCEEDED_ERR:e="QUOTA_EXCEEDED_ERR";break;case FileError.NOT_FOUND_ERR:e="NOT_FOUND_ERR";break;case FileError.SECURITY_ERR:e="SECURITY_ERR";break;case FileError.INVALID_MODIFICATION_ERR:e="INVALID_MODIFICATION_ERR";break;case FileError.INVALID_STATE_ERR:e="INVALID_STATE_ERR";break;default:e="Unknown Error"}throw new Error(e)}var rx=null;function nx(){}function ix(t){for(var e=[],r=0,n=t.length;r0?t.write(o):i()},t.truncate(0))},ex)},ex))};function cx(t,e){this.context=t,this._opts=n.merge({path:"/"},e)}Fd(cx.prototype),cx.prototype.removeCookie=function(t){var e=this._toCount(t),r=this._getSimpleCookie(e);if(r){this._removeSimpleCookie(e),r=parseInt(r,10);for(var n=0;n0?e(t[0],i):r(i)}),i}var o=document.createElement("a");return o.href="https://webvr.info",o.innerHTML="WEBVR NOT SUPPORTED",o.style.left="calc(50% - 90px)",o.style.width="180px",o.style.textDecoration="none",n(o),o}}]),t}(),Cx=_d.selectors,Tx=_d.Atom,Px=_d.Residue,Lx=_d.Chain,Rx=_d.Molecule,Nx=0,Ix=1,Ox=2,Dx=Iu.createElement;function zx(t){var e=t.lastIndexOf(".");return e>=0&&(t=t.substr(0,e)),t}function Fx(t,e,r){void 0!==r?t.debug(e+"... "+Math.floor(100*r)+"%"):t.debug(e+"...")}function kx(t){du.call(this),this._opts=n.merge({settingsCookie:"settings",cookiePath:"/"},t),this._gfx=null,this._container=t&&t.container||document.getElementById("miew-container")||n.head(document.getElementsByClassName("miew-container"))||document.body,this._containerRoot=this._container,this._running=!1,this._halting=!1,this._building=!1,this._needRender=!0,this._hotKeysEnabled=!0,this.settings=qu;var e=vu;e.console=!1,e.level="info",this.logger=e,this._cookies=new cx(this),this._loadSettings(),t&&t.settings&&this.settings.override(t.settings),this._spinner=null,this._loading=[],this._animInterval=null,this._visuals={},this._curVisualName=null,this._objects=[],this._sourceWindow=null,this._srvTopoSource=null,this._srvAnimSource=null,this.reset(),this._repr&&e.debug("Selected "+this._repr.mode.name+" mode with "+this._repr.colorer.name+" colorer.");var r=this;kx.registeredPlugins.forEach(function(t){t.call(r)})}function Bx(t,e){for(var r=t;r.firstChild;)r.removeChild(r.firstChild);r.appendChild(e)}kx.prototype=Object.create(du.prototype),kx.prototype.constructor=kx,kx.prototype.getMaxRepresentationCount=function(){return Gv.NUM_REPRESENTATION_BITS},kx.prototype.init=function(){var t=this._container,e=Iu.createElement("div",{class:"miew-canvas"});Bx(t,e),this._container=e;var r=document.createDocumentFragment();if(r.appendChild(this._msgMode=Dx("div",{class:"mode-message overlay"},Dx("p",{},"COMPONENT EDIT MODE"))),r.appendChild(this._msgAtomInfo=Dx("div",{class:"atom-info overlay"},Dx("p",{},""))),t.appendChild(r),null!==this._gfx)return!0;var n=this;this._showMessage("Viewer is being initialized...");try{this._initGfx(),this._initListeners(),this._spinner=new au({lines:13,length:28,width:14,radius:42,color:"#fff",zIndex:700}),window.top.addEventListener("keydown",function(t){n._onKeyDown(t)}),window.top.addEventListener("keyup",function(t){n._onKeyUp(t)}),this._objectControls=new __(this._gfx.root,this._gfx.pivot,this._gfx.camera,this._gfx.renderer.domElement,function(){return n._getAltObj()}),this._objectControls.addEventListener("change",function(t){switch(t.action){case"rotate":n.dispatchEvent({type:"rotate",angle:t.angle});break;case"zoom":n.dispatchEvent({type:"zoom",factor:t.factor})}n.dispatchEvent({type:"transform"}),n._needRender=!0});var i=this._gfx;this._picker=new x_(i.root,i.camera,i.renderer.domElement),this._picker.addEventListener("newpick",function(t){n._onPick(t)}),this._picker.addEventListener("dblclick",function(t){n._onDblClick(t)}),this._onThemeChanged()}catch(t){if("TypeError"!==t.name||"Cannot read property 'getExtension' of null"!==t.message)throw this._showMessage("Viewer initialization failed."),t;return this._showMessage("Could not create WebGL context."),!1}var o=this._opts&&this._opts.load;if(o){var a=this._opts&&this._opts.type;this.load(o,{fileType:a,keepRepsInfo:!0})}return!0},kx.prototype.term=function(){this._showMessage("Viewer has been terminated."),this._loading.forEach(function(t){t.cancel()}),this._loading.length=0,this.halt(),this._gfx=null},kx.prototype._showMessage=function(t){var e=document.createElement("div");e.setAttribute("class","miew-message"),e.appendChild(document.createElement("p")).appendChild(document.createTextNode(t)),Bx(this._container,e)},kx.prototype._showCanvas=function(){Bx(this._container,this._gfx.renderer.domElement)},kx.prototype._initGfx=function(){var t={width:this._container.clientWidth,height:this._container.clientHeight},e={preserveDrawingBuffer:!0};qu.now.antialias&&(e.antialias=!0),t.renderer2d=new g_,t.renderer=new Fo(e),Md.init(t.renderer),t.renderer.getContext().getExtension("EXT_frag_depth")||(qu.now.zSprites=!1),t.renderer.getContext().getExtension("WEBGL_depth_texture")||(qu.now.ao=!1),t.renderer.autoClear=!1,t.renderer.setPixelRatio(window.devicePixelRatio),t.renderer.setSize(t.width,t.height),t.renderer.setClearColor(qu.now.themes[qu.now.theme]),t.renderer.clearColor(),t.renderer2d.setSize(t.width,t.height),t.camera=new Xn(qu.now.camFov,t.width/t.height,qu.now.camNear,qu.now.camFar),t.camera.setMinimalFov(qu.now.camFov),t.camera.position.z=qu.now.camDistance,t.camera.updateProjectionMatrix(),t.camera.layers.set(Od.LAYERS.DEFAULT),t.camera.layers.enable(Od.LAYERS.VOLUME),t.camera.layers.enable(Od.LAYERS.VOLUME_BFPLANE),t.stereoCam=new Jl,t.scene=new Uo,t.scene.fog=new Bo(qu.now.themes[qu.now.theme],qu.now.camNear,qu.now.camFar),t.root=new Od.RCGroup,t.scene.add(t.root),t.pivot=new Od.RCGroup,t.root.add(t.pivot),t.selectionScene=new Uo,t.selectionRoot=new ta,t.selectionRoot.matrixAutoUpdate=!1,t.selectionScene.add(t.selectionRoot),t.selectionPivot=new ta,t.selectionPivot.matrixAutoUpdate=!1,t.selectionRoot.add(t.selectionPivot);var r=new gs(16777215,.45);r.position.set(0,.414,1),r.layers.enable(Od.LAYERS.TRANSPARENT),t.scene.add(r);var n=new vs(6710886);n.layers.enable(Od.LAYERS.TRANSPARENT),t.scene.add(n),t.axes=new b_(t.root,t.camera),t.offscreenBuf=new Ve(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:bt,magFilter:yt,format:kt,depthBuffer:!0}),t.renderer.getContext().getExtension("WEBGL_depth_texture")&&(t.offscreenBuf.depthTexture=new na,t.offscreenBuf.depthTexture.type=Ct),t.offscreenBuf2=new Ve(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:bt,magFilter:bt,format:kt,depthBuffer:!1}),t.offscreenBuf3=new Ve(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:bt,magFilter:bt,format:kt,depthBuffer:!1}),t.offscreenBuf4=new Ve(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:bt,magFilter:bt,format:kt,depthBuffer:!1}),t.volBFTex=t.offscreenBuf3,t.volFFTex=t.offscreenBuf4,t.volWFFTex=t.offscreenBuf,t.renderer.getContext().getExtension("OES_texture_float")?(t.offscreenBuf5=new Ve(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:bt,magFilter:bt,format:kt,type:Lt,depthBuffer:!1}),t.offscreenBuf6=new Ve(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:bt,magFilter:bt,format:kt,type:Lt,depthBuffer:!1}),t.offscreenBuf7=new Ve(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:bt,magFilter:bt,format:kt,type:Lt,depthBuffer:!0}),t.volBFTex=t.offscreenBuf5,t.volFFTex=t.offscreenBuf6,t.volWFFTex=t.offscreenBuf7):this.logger.warn("Device doesn't support OES_texture_float extension"),t.stereoBufL=new Ve(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:bt,magFilter:bt,format:kt,depthBuffer:!1}),t.stereoBufR=new Ve(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:bt,magFilter:bt,format:kt,depthBuffer:!1}),this._toggleWebVR("WEBVR"===qu.now.stereo,t),this._gfx=t,this._showCanvas(),this._container.appendChild(t.renderer2d.getElement());var i=new zu;i.domElement.style.position="absolute",i.domElement.style.right="0",i.domElement.style.bottom="0",this._container.appendChild(i.domElement),this._fps=i,this._fps.show(qu.now.fps)},kx.prototype._initListeners=function(){var t=this;window.addEventListener("resize",function(){t._onResize()})},kx.prototype._makeUniqueVisualName=function(t){if(!t)return Math.random().toString();for(var e=t,r=1;this._visuals.hasOwnProperty(e);)e=t+" ("+r.toString()+")",r++;return e},kx.prototype._addVisual=function(t){if(!t)return null;var e=this._makeUniqueVisualName(t.name);return t.name=e,this._visuals[e]=t,this._gfx.pivot.add(t),t.getSelectionGeo&&this._gfx.selectionPivot.add(t.getSelectionGeo()),e},kx.prototype._removeVisual=function(t){var e="",r=null;t instanceof zd?(e=t.name,r=t):"string"==typeof t&&(e=t,r=this._visuals[e]),r&&this._visuals.hasOwnProperty(e)&&this._visuals[e]===r&&(e===this._curVisualName&&(this._curVisualName=void 0),delete this._visuals[e],r.release(),this._needRender=!0)},kx.prototype._forEachVisual=function(t){for(var e in this._visuals)this._visuals.hasOwnProperty(e)&&t(this._visuals[e])},kx.prototype._releaseAllVisuals=function(){if(this._gfx&&this._gfx.pivot){for(var t in this._visuals)this._visuals.hasOwnProperty(t)&&this._visuals[t].release();this._visuals={}}},kx.prototype._forEachComplexVisual=function(t){if(this._gfx&&this._gfx.pivot)for(var e in this._visuals)this._visuals.hasOwnProperty(e)&&this._visuals[e]instanceof Gv&&t(this._visuals[e])},kx.prototype._getComplexVisual=function(t){t=t||this._curVisualName;var e=null,r=null;return this._forEachComplexVisual(function(n){e=n,n.name===t&&(r=n)}),r||e},kx.prototype._getVolumeVisual=function(){var t=null;return this._forEachVisual(function(e){e instanceof ty&&(t=e)}),t},kx.prototype._getVisualForComplex=function(t){if(!t)return null;var e=null;return this._forEachComplexVisual(function(r){r.getComplex()===t&&(e=r)}),e},kx.prototype.getVisuals=function(){return Object.keys(this._visuals)},kx.prototype.getCurrentVisual=function(){return this._curVisualName},kx.prototype.setCurrentVisual=function(t){this._visuals[t]&&(this._curVisualName=t)},kx.prototype.run=function(){var t=this;if(!this._running){if(this._running=!0,this._halting)return void(this._halting=!1);this._objectControls.enable(!0),(this._getWebVRDevice()||window).requestAnimationFrame(function(){return t._onTick()})}},kx.prototype.halt=function(){this._running&&(this._discardComponentEdit(),this._discardFragmentEdit(),this._objectControls.enable(!1),this._halting=!0)},kx.prototype.enableHotKeys=function(t){this._hotKeysEnabled=t,this._objectControls.enableHotkeys(t)},kx.prototype._onResize=function(){this._needRender=!0;var t=this._gfx;t.width=this._container.clientWidth,t.height=this._container.clientHeight,t.camera.aspect=t.width/t.height,t.camera.setMinimalFov(qu.now.camFov),t.camera.updateProjectionMatrix(),t.renderer.setSize(t.width,t.height),t.renderer2d.setSize(t.width,t.height),this.dispatchEvent({type:"resize"})},kx.prototype._resizeOffscreenBuffers=function(t,e,r){var n=this._gfx,i="NONE"===(r=r||"NONE")||"ANAGLYPH"===r,o=i?1:.5;n.offscreenBuf.setSize(o*t,e),n.offscreenBuf2.setSize(o*t,e),n.offscreenBuf3.setSize(o*t,e),n.offscreenBuf5&&n.offscreenBuf5.setSize(o*t,e),n.offscreenBuf6&&n.offscreenBuf6.setSize(o*t,e),n.offscreenBuf7&&n.offscreenBuf7.setSize(o*t,e),i&&(n.stereoBufL.setSize(t,e),n.stereoBufR.setSize(t,e))},kx.prototype._onTick=function(){var t=this;if(this._halting)return this._running=!1,void(this._halting=!1);this._fps.update();var e=this._getWebVRDevice();(e||window).requestAnimationFrame(function(){return t._onTick()}),this._onUpdate(),this._needRender&&(this._onRender(),this._needRender=!qu.now.suspendRender||"WEBVR"===qu.now.stereo||!!e)},kx.prototype._toggleWebVR=(ux=new Xn,hx=!1,px=null,function(t,e){var r=e?e.renderer:null;if(!r)throw new Error("No renderer is available to toggle WebVR");if(!e.camera)throw new Error("No camera is available to toggle WebVR");t?(ux.copy(e.camera),hx=!0,r.vr.enabled=!0,px?px.style.display="block":(px=Ex.createButton(r),document.body.appendChild(px))):(r.vr.enabled=!1,px&&(px.style.display="none"),hx&&(e.camera.copy(ux),this._onResize())),this._needRender=!0}),kx.prototype._getWebVRDevice=function(){var t=this._gfx.renderer.vr;return t&&t.enabled?t.getDevice():null},kx.prototype._getBSphereRadius=function(){var t=0;return this._forEachVisual(function(e){t=Math.max(t,e.getBoundaries().boundingSphere.radius)}),t*this._objectControls.getScale()},kx.prototype._updateFog=function(){var t,e,r,n=this._gfx;qu.now.fog?(void 0!==n.scene.fog&&null!==n.scene.fog||(n.scene.fog=new Bo(qu.now.themes[qu.now.theme]),this._setUberMaterialValues({fog:qu.now.fog})),t=n.scene.fog,e=n.camera.position.z,r=this._getBSphereRadius(),t.near=e-r*qu.now.fogNearFactor,t.far=e+r*qu.now.fogFarFactor):n.scene.fog&&(n.scene.fog=void 0,this._setUberMaterialValues({fog:qu.now.fog}))},kx.prototype._onUpdate=function(){void 0!==this.isScriptingCommandAvailable&&this.isScriptingCommandAvailable()&&!this._building&&this.callNextCmd(),this._objectControls.update(),this._forEachComplexVisual(function(t){t.getComplex().update()}),qu.now.autobuild&&!this._loading.length&&!this._building&&this._needRebuild()&&this.rebuild(),this._loading.length||this._building||this._needRebuild()||this._updateView(),this._updateFog()},kx.prototype._onRender=function(){var t=this._gfx;t.scene.updateMatrixWorld(),t.camera.updateMatrixWorld(),this._clipPlaneUpdateValue(this._getBSphereRadius()),this._fogFarUpdateValue(),t.renderer.clearTarget(null),this._renderFrame(qu.now.stereo)},kx.prototype._renderFrame=(dx=new q_,function(t){var e=this._gfx,r=e.renderer;"NONE"!==t&&(e.stereoCam.aspect="ANAGLYPH"===t?1:.5,e.camera.focus=e.camera.position.z,e.stereoCam.update(e.camera));var n=r.getSize();switch(this._resizeOffscreenBuffers(n.width*window.devicePixelRatio,n.height*window.devicePixelRatio,t),t){case"WEBVR":case"NONE":this._renderScene(e.camera,!1);break;case"SIMPLE":case"DISTORTED":r.setScissorTest(!0),r.setScissor(0,0,n.width/2,n.height),r.setViewport(0,0,n.width/2,n.height),this._renderScene(this._gfx.stereoCam.cameraL,"DISTORTED"===t),r.setScissor(n.width/2,0,n.width/2,n.height),r.setViewport(n.width/2,0,n.width/2,n.height),this._renderScene(this._gfx.stereoCam.cameraR,"DISTORTED"===t),r.setScissorTest(!1);break;case"ANAGLYPH":this._renderScene(this._gfx.stereoCam.cameraL,!1,e.stereoBufL),this._renderScene(this._gfx.stereoCam.cameraR,!1,e.stereoBufR),dx.uniforms.srcL.value=e.stereoBufL,dx.uniforms.srcR.value=e.stereoBufR,e.renderer.renderScreenQuad(dx)}e.renderer2d.render(e.scene,e.camera),qu.now.axes&&e.axes&&!e.renderer.vr.enabled&&e.axes.render(r)}),kx.prototype._onThemeChanged=(fx=/\s*theme-\w+\b/g,function(){var t=qu.now.theme,e=this._containerRoot;e.className=e.className.replace(fx,"")+" theme-"+t;var r=this._gfx;if(r){var n=qu.now.themes[t];r.scene.fog&&r.scene.fog.color.set(n),r.renderer.setClearColor(n)}}),kx.prototype._setUberMaterialValues=function(t){this._gfx.root.traverse(function(e){(e instanceof no||e instanceof $o||e instanceof Zo)&&e.material instanceof Cd&&(e.material.setValues(t),e.material.needsUpdate=!0)})},kx.prototype._renderScene=function(t,e,r){e=e||!1,r=r||null;var n=this._gfx;if(n.renderer.setClearColor(qu.now.themes[qu.now.theme],1),n.renderer.clearTarget(r),n.renderer.vr.enabled)n.renderer.render(n.scene,t);else{n.renderer.clearTarget(n.offscreenBuf),"prepass"===qu.now.transparency?this._renderWithPrepassTransparency(t,n.offscreenBuf):"standard"===qu.now.transparency&&n.renderer.render(n.scene,t,n.offscreenBuf);var i=null!==this._getComplexVisual(),o=this._getVolumeVisual(),a=i&&qu.now.fxaa,s=null!==o&&null!=o.getMesh().material,l=s||a||e?n.offscreenBuf2:r,c=n.offscreenBuf;i&&qu.now.ao?this._performAO(c,n.offscreenBuf.depthTexture,l,n.offscreenBuf3,n.offscreenBuf2):n.renderer.renderScreenQuadFromTex(c.texture,1,l),this._renderSelection(t,c,l),s&&(n.renderer.renderScreenQuadFromTex(l.texture,1,n.offscreenBuf),l=n.offscreenBuf,this._renderVolume(o,t,l,n.volBFTex,n.volFFTex,n.volWFFTex),a||e||n.renderer.renderScreenQuadFromTex(l.texture,1,r)),c=l,a&&(l=e?n.offscreenBuf3:r,this._performFXAA(c,l),c=l),e&&(l=r,this._performDistortion(c,l,!0))}},kx.prototype._performDistortion=(mx=new Uo,gx=new Wn(-1,1,1,-1,-500,1e3),vx=new dn({uniforms:{srcTex:{type:"t",value:null},aberration:{type:"fv3",value:new He(1)}},vertexShader:"varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }",fragmentShader:"varying vec2 vUv; uniform sampler2D srcTex; uniform vec3 aberration;void main() {vec2 uv = vUv * 2.0 - 1.0;gl_FragColor.r = texture2D(srcTex, 0.5 * (uv * aberration[0] + 1.0)).r;gl_FragColor.g = texture2D(srcTex, 0.5 * (uv * aberration[1] + 1.0)).g;gl_FragColor.b = texture2D(srcTex, 0.5 * (uv * aberration[2] + 1.0)).b;gl_FragColor.a = 1.0;}",transparent:!1,depthTest:!1,depthWrite:!1}),yx=Od.buildDistorionMesh(10,10,qu.now.debug.stereoBarrel),mx.add(new mm.Mesh(yx,vx)),function(t,e,r){this._gfx.renderer.clearTarget(e),r?(vx.uniforms.srcTex.value=t.texture,vx.uniforms.aberration.value.set(.995,1,1.01),this._gfx.renderer.render(mx,gx,e)):this._gfx.renderer.renderScreenQuadFromTexWithDistortion(t,qu.now.debug.stereoBarrel,e)}),kx.prototype._renderSelection=(_x=new D_,function(t,e,r){var n=this._gfx;n.renderer.setClearColor("black",0),n.renderer.clearTarget(e,!0,!1,!1),n.selectionPivot.children.length>0?(n.selectionRoot.matrix=n.root.matrix,n.selectionPivot.matrix=n.pivot.matrix,n.renderer.render(n.selectionScene,t,e)):n.renderer.renderDummyQuad(e),n.renderer.renderScreenQuadFromTex(e.texture,.6,r),_x.uniforms.srcTex.value=e.texture,_x.uniforms.srcTexSize.value.set(e.width,e.height),n.renderer.renderScreenQuad(_x,r)}),kx.prototype._checkVolumeRenderingSupport=function(t){if(!t)return!1;var e=this._gfx,r=e.renderer.getRenderTarget();e.renderer.setRenderTarget(t);var n=e.renderer.getContext(),i=n.checkFramebufferStatus(n.FRAMEBUFFER);return e.renderer.setRenderTarget(r),i===n.FRAMEBUFFER_COMPLETE||(this.logger.warn("Device doesn't support electron density rendering"),!1)},kx.prototype._renderVolume=(bx=new Qv.BackFacePosMaterial,wx=new Qv.FrontFacePosMaterial,Sx=(new We).makeTranslation(.5,.5,.5),Mx=new We,function(t,e,r,n,i,o){var a=this._gfx;if(void 0===xx&&(xx=this._checkVolumeRenderingSupport(n)),xx){var s=t.getMesh();s.rebuild(e),a.renderer.setClearColor("black",0),a.renderer.clearTarget(n),a.renderer.clearTarget(i),a.renderer.clearTarget(o),e.layers.set(Od.LAYERS.VOLUME_BFPLANE),a.renderer.render(a.scene,e,n),e.layers.set(Od.LAYERS.VOLUME),a.scene.overrideMaterial=bx,a.renderer.render(a.scene,e,n),e.layers.set(Od.LAYERS.VOLUME),a.scene.overrideMaterial=wx,a.renderer.render(a.scene,e,i),a.scene.overrideMaterial=null,e.layers.set(Od.LAYERS.DEFAULT),Mx.getInverse(s.matrixWorld),Cd.prototype.uberOptions.world2colorMatrix.multiplyMatrices(Sx,Mx),this._setUberMaterialValues({colorFromPos:!0}),a.renderer.render(a.scene,e,o),this._setUberMaterialValues({colorFromPos:!1});var l=s.material;l.uniforms._BFRight.value=n.texture,l.uniforms._FFRight.value=i.texture,l.uniforms._WFFRight.value=o.texture,e.layers.set(Od.LAYERS.VOLUME),a.renderer.render(a.scene,e,r),e.layers.set(Od.LAYERS.DEFAULT)}}),kx.prototype._renderWithPrepassTransparency=function(t,e){var r=this._gfx;t.layers.set(Od.LAYERS.DEFAULT),r.renderer.render(r.scene,t,e),t.layers.set(Od.LAYERS.PREPASS_TRANSPARENT),r.renderer.context.colorMask(!1,!1,!1,!1),r.renderer.render(r.scene,t,e),r.renderer.context.colorMask(!0,!0,!0,!0),t.layers.set(Od.LAYERS.TRANSPARENT),r.renderer.render(r.scene,t,e),t.layers.set(Od.LAYERS.DEFAULT)},kx.prototype._performFXAA=(Ax=new k_,function(t,e){if(void 0!==t&&void 0!==e){var r=this._gfx;r.renderer.setClearColor(qu.now.themes[qu.now.theme],1),r.renderer.clearTarget(e),Ax.uniforms.srcTex.value=t.texture,Ax.uniforms.srcTexelSize.value.set(1/t.width,1/t.height),Ax.transparent=!0,r.renderer.renderScreenQuad(Ax,e)}}),kx.prototype._performAO=function(){var t=new W_.AOMaterial,e=new W_.HorBilateralBlurMaterial,r=new W_.VertBilateralBlurMaterial,n=new Xe(new Uint8Array([0,0,0,66,0,0,77,0,0,155,62,0,0,247,0,33,0,0,0,0,0,235,0,0,0,0,0,176,44,0,232,46,0,0,29,0,0,0,0,78,197,0,93,0,0,0,0,0]),4,4,Ft,Mt,300,mt,mt,yt,yt,1);n.needsUpdate=!0;var i=[new He(.295184,.077723,.068429),new He(-.271976,-.365221,.838363),new He(.547713,.467576,.488515),new He(.662808,-.031733,.584758),new He(-.025717,.218955,.657094),new He(-.310153,-.365223,.370701),new He(-.101407,-.006313,.747665),new He(-.769138,.360399,.086847),new He(-.271988,-.27514,.905353),new He(.09674,-.566901,.700151),new He(.562872,-.735136,.094647),new He(.379877,.359278,.190061),new He(.519064,-.023055,.405068),new He(-.301036,.114696,.088885),new He(-.282922,.598305,.487214),new He(-.181859,.25167,.679702),new He(-.191463,-.635818,.512919),new He(-.293655,.427423,.078921),new He(-.267983,.680534,.13288),new He(.139611,.319637,.477439),new He(-.352086,.31104,.653913),new He(.321032,.805279,.487345),new He(.073516,.820734,.414183),new He(-.155324,.589983,.41146),new He(.335976,.170782,.527627),new He(.46346,-.355658,.167689),new He(.222654,.59655,.769406),new He(.922138,-.04207,.147555),new He(-.72705,-.329192,.369826),new He(-.090731,.53382,.463767),new He(-.323457,-.876559,.238524),new He(-.663277,-.372384,.342856)],o=[-2,-1,0,1,2];return function(a,s,l,c,u){if(void 0!==a&&void 0!==s&&void 0!==l&&void 0!==c&&void 0!==u){var h=this._gfx;t.uniforms.diffuseTexture.value=a.texture,t.uniforms.depthTexture.value=s,t.uniforms.srcTexelSize.value.set(1/a.width,1/a.height),t.uniforms.camNearFar.value.set(h.camera.near,h.camera.far),t.uniforms.projMatrix.value=h.camera.projectionMatrix,t.uniforms.aspectRatio.value=h.camera.aspect,t.uniforms.tanHalfFOV.value=Math.tan(.5*ve.DEG2RAD*h.camera.fov),t.uniforms.samplesKernel.value=i;var p=new He,d=new Ge,f=new He;h.root.matrix.decompose(p,d,f),t.uniforms.kernelRadius.value=qu.now.debug.ssaoKernelRadius*f.x,t.uniforms.depthThreshold.value=2*this._getBSphereRadius(),t.uniforms.factor.value=qu.now.debug.ssaoFactor,t.uniforms.noiseTexture.value=n,t.uniforms.noiseTexelSize.value.set(.25,.25);var m=h.scene.fog;m&&t.uniforms.fogNearFar.value.set(m.near,m.far),t.transparent=!1,h.renderer.renderScreenQuad(t,u),e.uniforms.aoMap.value=u.texture,e.uniforms.srcTexelSize.value.set(1/u.width,1/u.height),e.uniforms.depthTexture.value=s,e.uniforms.samplesOffsets.value=o,h.renderer.renderScreenQuad(e,c),r.uniforms.aoMap.value=c.texture,r.uniforms.diffuseTexture.value=a.texture,r.uniforms.srcTexelSize.value.set(1/c.width,1/c.height),r.uniforms.depthTexture.value=s,r.uniforms.samplesOffsets.value=o,h.renderer.renderScreenQuad(r,l)}}}(),kx.prototype.reset=function(){this._picker&&this._picker.reset(),this._lastPick=null,this._releaseAllVisuals(),this._setEditMode(Nx),this._resetObjects(),this._gfx&&(Od.clearTree(this._gfx.pivot),this._gfx.renderer2d.reset()),this.setNeedRender()},kx.prototype._resetScene=function(){this._objectControls.reset(),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this.resetReps(),this.resetPivot(),this.rebuildAll()},kx.prototype.resetView=function(){this._picker&&this._picker.reset(),this._setEditMode(Nx),this._resetScene(),this._forEachComplexVisual(function(t){t.updateSelectionMask({}),t.rebuildSelectionGeometry()})},kx.prototype.load=function(t,e){var r=this;e=n.merge({},e,{context:this}),this.settings.now.use.multiFile||(this._loading.length&&(this._loading.forEach(function(t){t.cancel()}),this._loading.length=0),e.animation||this.reset(!0)),this.dispatchEvent({type:"load",options:e,source:t});var i=new Wu;this._loading.push(i),i.addEventListener("notification",function(t){r.dispatchEvent(t.slaveEvent)}),this._spinner.spin(this._container);var o,a,s,l=function(t){var e=r._loading.indexOf(i);return-1!==e&&r._loading.splice(e,1),r._spinner.stop(),r._refreshTitle(),t};return(o=t,a=e,s=i,new Promise(function(t){if(s.shouldCancel())throw new Error("Operation cancelled");o=function(t,e){if(!n.isString(t))return t;var r=Vx.exec(t);if(r){var i=Gu(r,3),o=i[1],a=void 0===o?"pdb":o,s=i[2];switch(a=a.toLowerCase(),s=s.toUpperCase(),a){case"pdb":t="http://files.rcsb.org/download/"+s+".pdb";break;case"cif":t="http://files.rcsb.org/download/"+s+".cif";break;case"mmtf":t="http://mmtf.rcsb.org/v1.0/full/"+s;break;case"ccp4":t="https://www.ebi.ac.uk/pdbe/coordinates/files/"+s.toLowerCase()+".ccp4";break;default:throw new Error("Unexpected data format shortcut")}return e.fileType=a,e.fileName=s+"."+a,e.sourceType="url",t}var l=jx.exec(t);if(l){var c=l[1].toLowerCase();return t="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/"+c+"/JSON?record_type=3d",e.fileType="pubchem",e.fileName=c+".json",e.sourceType="url",t}return"url"!==e.sourceType&&void 0!==e.sourceType||(e.sourceType="url",Gx.test(t)||(t=Iu.resolveURL(t))),t}(o,a);var e=n.head(f_.loaders.find({type:a.sourceType,source:o}));if(!e)throw new Error("Could not find suitable loader for this source");var r=a.fileName||e.extractName(o);if(r){var i=Iu.splitFileName(r),l=Gu(i,2),c=l[0],u=l[1];n.defaults(a,{name:c,fileExt:u,fileName:r})}!function(t){var e=t.binary;if(void 0!==t.fileType){var r=n.head(f_.parsers.find({format:t.fileType}));if(!r)throw new Error("Could not find suitable parser for this format");e=r.binary||!1}if(void 0===e&&void 0!==t.fileExt){var i=n.head(f_.parsers.find({ext:t.fileExt}));i&&(e=i.binary||!1)}void 0!==t.fileExt&&".man"===t.fileExt.toLowerCase()&&(t.binary=!0,t.animation=!0),void 0!==e&&void 0!==t.binary&&t.binary!==e&&t.context.logger.warn("Overriding incorrect binary mode"),t.binary=e||!1}(a);var h=n.get(a,"preset.expression");if(!n.isUndefined(h)&&(h=JSON.parse(h))&&h.settings)for(var p=["singleUnit","draft.waterBondingHack"],d=0,f=p.length;d0?Fx(v.logger,"Fetching",t.loaded/t.total):Fx(v.logger,"Fetching")});var y=v.load().then(function(t){return a.context.logger.info("Fetching finished"),s.notify({type:"fetchingFinished",data:t}),t}).catch(function(t){throw a.context.logger.debug(t.message),t.stack&&a.context.logger.debug(t.stack),a.context.logger.error("Fetching failed"),s.notify({type:"fetchingFinished",error:t}),t});t(y)})).then(function(t){return r=t,n=e,o=i,new Promise(function(t,e){if(o.shouldCancel())throw new Error("Operation cancelled");if(o.notify({type:"convert"}),n.mdFile){for(var i=new Array(r.length),a=0;a0?"Bio molecule "+n:"Asymmetric unit")+")"}if(!r)throw new Error("There is no complex to change!");return r.getComplex().setCurrentStructure(t)&&this._resetScene(),""},kx.prototype.rebuild=function(){if(this._building)this.logger.warn("Miew.rebuild(): already building!");else{this._building=!0,this.dispatchEvent({type:"rebuild"}),this._rebuildObjects(),this._gfx.renderer2d.reset();var t=[];this._forEachComplexVisual(function(e){e.needsRebuild()&&t.push(e.rebuild().then(function(){return new Promise(function(t){e.rebuildSelectionGeometry(),t()})}))});var e=this;this._spinner.spin(this._container),Promise.all(t).then(function(){e._spinner.stop(),e._needRender=!0,e._refreshTitle(),e._building=!1})}},kx.prototype.rebuildAll=function(){this._forEachComplexVisual(function(t){t.setNeedsRebuild()})},kx.prototype._refreshTitle=function(t){var e;t=void 0===t?"":t;var r=this._getComplexVisual();if(r){e=r.getComplex().name;var n=r.repGet(r.repCurrent());e+=n?" – "+n.mode.name+" Mode":""}else e=Object.keys(this._visuals).length>0?"Unknown":"No Data";e+=t,this.dispatchEvent({type:"titleChanged",data:e})},kx.prototype.setNeedRender=function(){this._needRender=!0},kx.prototype._extractRepresentation=function(){var t=this,e=[];this._forEachComplexVisual(function(r){if(0!==r.getSelectionCount()){var n=r.buildSelectorFromMask(1<0&&(this.logger.report("New representation from selection for complexes: "+e.join(", ")),this.dispatchEvent({type:"repAdd"}))},kx.prototype._setReps=function(t){t=t||this._opts&&this._opts.reps||[],this._forEachComplexVisual(function(e){return e.resetReps(t)})},kx.prototype.applyPreset=function(t){for(var e=qu.now.presets,r=[t||qu.defaults.preset,qu.defaults.preset,Object.keys(e)[0]],n=null,i=0;!n&&i0&&t.push(e)}),1===t.length){var e=t[0].beginFragmentEdit();e&&(this._editors=[e],this.logger.info("FRAGMENT EDIT MODE -- ON (single bond)"),this._setEditMode(Ox),this._objectControls.allowTranslation(!1),this._objectControls.allowAltObjFreeRotation(e.isFreeRotationAllowed()),this._needRender=!0)}}},kx.prototype._applyFragmentEdit=function(){if(this._editMode===Ox){this._objectControls.stop();for(var t=0;t0){if(t){t=null;break}t=r}}if(t)return t}return{objects:[],pivot:new He(0,0,0)}},kx.prototype.resetPivot=function(){var t=new gn;this._forEachVisual(function(e){t.union(e.getBoundaries().boundingBox)}),t.getCenter(this._gfx.pivot.position),this._gfx.pivot.position.negate(),this.dispatchEvent({type:"transform"})},kx.prototype.setPivotResidue=function(t){var e=this._getVisualForComplex(t.getChain().getComplex());if(e){var r=this._gfx.pivot.position;if(t._controlPoint)r.copy(t._controlPoint);else{for(var n=0,i=0,o=0,a=t._atoms.length,s=0;s=5&&(e._gfxScore=1e3/r.mean()),t>0&&(e._gfxScore=.5*t),e._spinner.stop(),n()})):n()})},kx.prototype.screenshot=function(t,e){var r,n,i,o=this._gfx;if(e=e||t||o.height,(t=t||o.width)===o.width&&e===o.height)r=o.renderer.domElement.toDataURL("image/png");else{var a=o.camera.aspect,s=o.camera.fov,l=(i=o.camera.fov,Math.tan(ve.degToRad(.5*i)))*Math.min(o.width,o.height)/o.height,c=t/e;o.camera.aspect=c,o.camera.fov=(n=l/Math.min(c,1),2*ve.radToDeg(Math.atan(n))),o.camera.updateProjectionMatrix(),o.renderer.setSize(t,e),this._renderFrame("NONE"),r=o.renderer.domElement.toDataURL("image/png"),o.camera.aspect=a,o.camera.fov=s,o.camera.updateProjectionMatrix(),o.renderer.setSize(o.width,o.height),this._needRender=!0}return r},kx.prototype.screenshotSave=function(t,e,r){var n=this.screenshot(e,r);Iu.shotDownload(n,t)},kx.prototype._tweakResolution=function(){var t=[["poor",100],["low",500],["medium",1e3],["high",5e3],["ultra",Number.MAX_VALUE]],e=0;if(this._forEachComplexVisual(function(t){e+=t.getComplex().getAtomCount()}),e>0)for(var r=1e6*this._gfxScore/e,n=0;ni?(a=!1,r.preset="empty"):qu.now.preset!==qu.defaults.preset&&(r.preset=qu.now.preset);for(var s=[],l=!0,c=0,u=i;c0&&(e._objects=s),t.view&&(e.view=this.view()),t.settings){var u=this.settings.getDiffs(!1);n.isEmpty(u)||(e.settings=u)}return e},kx.prototype.get=function(t,e){return qu.get(t,e)},kx.prototype._clipPlaneUpdateValue=function(t){var e=Math.max(this._gfx.camera.position.z-t*qu.now.draft.clipPlaneFactor,qu.now.camNear),r={clipPlaneValue:e};this._forEachComplexVisual(function(t){t.setUberOptions(r)});for(var n=0,i=this._objects.length;n2&&A.push("'"+this.terminals_[w]+"'");T=p.showPosition?"Parse error on line "+(l+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[v]||v)+"'":"Parse error on line "+(l+1)+": Unexpected "+(v==u?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(T,{text:p.match,token:this.terminals_[v]||v,line:p.yylineno,loc:m,expected:A})}if(x[0]instanceof Array&&x.length>1)throw new Error("Parse Error: multiple actions possible at state: "+_+", token: "+v);switch(x[0]){case 1:r.push(v),i.push(p.yytext),o.push(p.yylloc),r.push(x[1]),v=null,y?(v=y,y=null):(c=p.yyleng,s=p.yytext,l=p.yylineno,m=p.yylloc);break;case 2:if(S=this.productions_[x[1]][1],C.$=i[i.length-S],C._$={first_line:o[o.length-(S||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(S||1)].first_column,last_column:o[o.length-1].last_column},g&&(C._$.range=[o[o.length-(S||1)].range[0],o[o.length-1].range[1]]),void 0!==(b=this.performAction.apply(C,[s,c,l,d.yy,x[1],i,o].concat(h))))return b;S&&(r=r.slice(0,-1*S*2),i=i.slice(0,-1*S),o=o.slice(0,-1*S)),r.push(this.productions_[x[1]][0]),i.push(C.$),o.push(C._$),M=a[r[r.length-2]][r[r.length-1]],r.push(M);break;case 3:return!0}}return!0}},wt={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],r=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;var t,e,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;oe[0].length)){if(e=r,n=o,this.options.backtrack_lexer){if(!1!==(t=this.test_match(r,i[o])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[n]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,r,n){switch(r){case 0:break;case 1:case 2:return"";case 3:return 41;case 4:return 34;case 5:return 97;case 6:case 7:return 98;case 8:return 8;case 9:return 6;case 10:return 101;case 11:return 7;case 12:return 9;case 13:return 80;case 14:return 82;case 15:return 12;case 16:return 14;case 17:return 16;case 18:return 17;case 19:return 18;case 20:return 19;case 21:return 83;case 22:return 85;case 23:return 22;case 24:return 24;case 25:return 25;case 26:return 26;case 27:return 29;case 28:return 33;case 29:return 32;case 30:return 86;case 31:return 87;case 32:return 36;case 33:return 40;case 34:return 42;case 35:return 52;case 36:return 54;case 37:return 55;case 38:return 45;case 39:return 47;case 40:return 44;case 41:return 56;case 42:return 58;case 43:return 43;case 44:return 59;case 45:return 62;case 46:return 63;case 47:return 64;case 48:return 66;case 49:return 67;case 50:return 68;case 51:return 69;case 52:return 70;case 53:return 71;case 54:return 72;case 55:return 74;case 56:return 73;case 57:case 58:return 91;case 59:case 60:return 92;case 61:case 62:case 63:return 94;case 64:return 30;case 65:return 35;case 66:return 78;case 67:return 75;case 68:return 79;case 69:return 77;case 70:return e.yytext=e.yytext.substr(1,e.yyleng-2),13;case 71:return 37;case 72:return 5;case 73:return 103;case 74:return 104;case 75:return"\\";case 76:return 27;case 77:return 60;case 78:return 28;case 79:return 57;case 80:return 76}},rules:[/^(?:\s+)/i,/^(?:[#].*)/i,/^(?:\/\/.*)/i,/^(?:([_A-Z0-9\/\+]+==))/i,/^(?:-?[0-9]+(\.[0-9]+)?\b)/i,/^(?:0[xX][0-9A-F]+\b)/i,/^(?:false\b)/i,/^(?:true\b)/i,/^(?:all\b)/i,/^(?:reset\b)/i,/^(?:clear\b)/i,/^(?:build\b)/i,/^(?:help\b)/i,/^(?:load\b)/i,/^(?:script\b)/i,/^(?:get\b)/i,/^(?:set\b)/i,/^(?:set_save\b)/i,/^(?:set_restore\b)/i,/^(?:set_reset\b)/i,/^(?:preset\b)/i,/^(?:add\b)/i,/^(?:rep\b)/i,/^(?:remove\b)/i,/^(?:hide\b)/i,/^(?:show\b)/i,/^(?:list\b)/i,/^(?:select\b)/i,/^(?:within\b)/i,/^(?:selector\b)/i,/^(?:mode\b)/i,/^(?:color\b)/i,/^(?:material\b)/i,/^(?:view\b)/i,/^(?:unit\b)/i,/^(?:line\b)/i,/^(?:listobj\b)/i,/^(?:removeobj\b)/i,/^(?:rotate\b)/i,/^(?:translate\b)/i,/^(?:scale\b)/i,/^(?:url\b)/i,/^(?:screenshot\b)/i,/^(?:dssp\b)/i,/^(?:file_list\b)/i,/^(?:file_register\b)/i,/^(?:file_delete\b)/i,/^(?:preset_add\b)/i,/^(?:preset_delete\b)/i,/^(?:preset_update\b)/i,/^(?:preset_rename\b)/i,/^(?:preset_open\b)/i,/^(?:create_scenario\b)/i,/^(?:reset_scenario\b)/i,/^(?:delete_scenario\b)/i,/^(?:add_scenario_item\b)/i,/^(?:list_scenario\b)/i,/^(?:s\b)/i,/^(?:mt\b)/i,/^(?:m\b)/i,/^(?:c\b)/i,/^(?:x\b)/i,/^(?:y\b)/i,/^(?:z\b)/i,/^(?:as\b)/i,/^(?:of\b)/i,/^(?:pdb\b)/i,/^(?:delay\b)/i,/^(?:prst\b)/i,/^(?:desc\b)/i,/^(?:((?:"([^"]*)"|'([^']*)')))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:\.)/i,/^(?:\/)/i,/^(?:\\)/i,/^(?:-e\b)/i,/^(?:-f\b)/i,/^(?:-s\b)/i,/^(?:-v\b)/i,/^(?:=)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80],inclusive:!0}}};function St(){this.yy={}}return bt.lexer=wt,St.prototype=bt,bt.Parser=St,new St}();void 0!==e&&(r.parser=n,r.Parser=n.Parser,r.parse=function(){return n.parse.apply(n,arguments)},r.main=function(t){t[1]||process.exit(1);var e=np.readFileSync(ip.normalize(t[1]),"utf8");return r.parser.parse(e)},e.main===t&&r.main(process.argv.slice(1)))}),Wx=Hx.parser,Xx=(Hx.Parser,Hx.parse,Hx.main,{$help:["Rendering mode shortcut"," BS - balls and sticks mode"," LN - lines mode"," LC - licorice mode"," VW - van der waals mode"," TR - trace mode"," TU - tube mode"," CA - cartoon mode"," SA - isosurface mode"," QS - quick surface mode"," SE - solvent excluded mode"," TX - text mode"],BS:{$help:[" Balls and sticks"," aromrad = #aromatic radius"," atom = #atom radius"," bond = #bond radius"," multibond = #use multibond"," showarom = #show aromatic"," space = #space value\n"]},CA:{$help:[" Cartoon"," arrow = #arrow size"," depth = #depth of surface"," heightSegmentsRatio = "," radius = #tube radius"," tension = #"," width = #secondary width\n"]},LN:{$help:[" Lines"," atom = #atom radius"," chunkarom = "," multibond = #use multibond"," showarom = #show aromatic"," offsarom = \n"]},LC:{$help:[" Licorice"," aromrad = #aromatic radius"," bond = #bond radius"," multibond = #use multibond"," showarom = #show aromatic"," space = #space value\n"]},VW:{$help:[" Van der Waals"," nothing\n"]},TR:{$help:[" Trace"," radius = #tube radius\n"]},TU:{$help:[" Tube"," heightSegmentsRatio = "," radius = #tube radius"," tension = \n"]},SA:{$help:[" Surface"," zClip = #clip z plane\n"]},QS:{$help:[" Quick surface"," isoValue = "," scale = "," wireframe = "," zClip = #clip z plane\n"]},SE:{$help:[" Solvent excluded surface"," zClip = #clip z plane\n"]},TX:{$help:[" Text mode",' template = string that can include "{{ id }}"'," it will be replaced by value, id can be one of next:"," serial, name, type, sequence, residue, chain, hetatm, water\n",' horizontalAlign = {"left", "right", "center"}',' verticalAlign = {"top", "bottom", "middle"}'," dx = #offset along x"," dy = #offset along y"," dz = #offset along z"," fg = #text color modificator"," could be keyword, named color or hex"," fg = #back color modificator"," could be keyword, named color or hex"," showBg = #if set show background"," plate under text"]}}),Yx={$help:["Coloring mode shortcut"," EL - color by element"," CH - color by chain"," SQ - color by sequence"," RT - color by residue type"," SS - color by secondary structure"," UN - uniform"],UN:{$help:["Parameters of coloring modes customization"," Uniform"," color = #RGB->HEX->dec\n"],color:{$help:Object.keys(fv.get(qu.now.palette).namedColors).sort().join("\n")}}},qx={$help:["Material shortcut"," DF - diffuse"," TR - transparent"," SF - soft plastic"," PL - glossy plastic"," ME - metal"," GL - glass"]},Zx={$help:["Short (packed) representation description as a set of variables"," s="," selector property"," m=[!:[,...]]"," render mode property"," c=[!:[,...]]"," color mode property"," mt="," material property"],s:{$help:"Selection expression string as it is in menu->representations->selection"},m:Xx,c:Yx,mt:qx},$x={$help:["Parameters of rendering modes customization: modes","Parameters of colorer customization: colorers","Autobuild: autobuild = (|)"],modes:Xx,colorers:Yx},Kx={$help:["help (| )","You can get detailed information about command options",' using "help cmd.opt.opt.[...]"\n'," you can use one line comments"," everything started from (#|//) will be skipped"," Example: >build //some comment\n","List of available commands:"],reset:{$help:["Reload current object, delete all representations"," Nothing will work until load new object"]},load:{$help:["load (||-f [<*.NC FILE URL STRING>])"," Load new pdb object from selected source"],PDBID:{$help:"pdb id in remote molecule database"},URL:{$help:"url to source file"},f:{$help:["open file system dialog to fetch local file","optionally you can determine trajectory file","via URL for *.top model"]}},clear:{$help:"No args. Clear terminal"},add:{$help:["add [] []"," Add new item to representation set with"," default or params"],REP_NAME:{$help:"Identifier string [_,a-z,A-Z,0-9] can not start from digit"},DESCRIPTION:Zx},rep:{$help:["rep [|] []"," set current representation by name or index"," edit current representation by "],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"},DESCRIPTION:Zx},remove:{$help:["remove (|)","Remove representation by name or index"],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"}},selector:{$help:["selector "," set selector from EXPRESSION to current representation"],EXPRESSION:{$help:"Selection expression string as it is in menu->representations->selection"}},mode:{$help:["mode [=...]"," set rendering mode and apply parameters to current representation"],MODE_ID:Xx},color:{$help:["color [=...]"," set colorer and apply parameters to current representation"],COLORER_ID:Yx},material:{$help:["material "," set material to current representation"],MATERIAL_ID:qx},build:{$help:"build help str",add:{$help:"build.add",new:{$help:["add.new","add.new new line 1","add.new new line 2","add.new new line 3"]}},del:{$help:"build.del"}},list:{$help:["list [-e|-s||]","Print representations if no args print list of representations"," -e expand list and show all representations"," -s show all user-registered selectors"," | show only current representation"]},hide:{$help:["hide (|)","Hide representation referenced in args"]},show:{$help:["show (|)","Show representation referenced in args"]},get:{$help:["get ","Print value"," - path to option use get.PARAMETER to get more info"],PARAMETER:$x},set:{$help:["set ","Set with "," - path to option use set.PARAMETER to get more info"],PARAMETER:$x},set_save:{$help:["set_save","Save current settings to cookie"]},set_restore:{$help:["set_restore","Load and apply settings from cookie"]},set_reset:{$help:["set_reset","Reset current settings to the defaults"]},preset:{$help:["preset []","Reset current representation or set preset to "],PRESET:{$help:["default","wire","small","macro"]}},unit:{$help:["unit []","Change current biological structure view. Zero value means asymmetric unit,","positive values set an assembly with corresponding number.","Being called with no parameters command prints current unit information."]},view:{$help:["view []","Get current encoded view or set if ENCODED_VIEW placed as argument"],ENCODED_VIEW:{$help:["encoded view matrix string (binary code)"]}},rotate:{$help:["rotate (x|y|z) [] [(x|y|z) []]...","Rotate scene"]},scale:{$help:["scale ","Scale scene"]},select:{$help:["select [as ]","Select atoms using selector defined in SELECTOR_STRING"," and if SELECTOR_NAME is defined register it in viewer"," you can use it later as a complex selector"]},within:{$help:["within of as ","Build within named selector"," DISTANCE "," SELECTOR_STRING "," SELECTOR_NAME "]},url:{$help:["url [-s] [-v]","Report URL encoded scene"," if -s set that include settings in the URL"," if -v set that include view in the URL"]},screenshot:{$help:["screenshot [ []]","Make a screenshot of the scene"," WIDTH in pixels"," HEIGHT in pixels, equal to WIDTH by default"]},line:{$help:["line [=]","Draw dashed line between two specified atoms"]},removeobj:{$help:["removeobj ","Remove scene object by its index. Indices could be obtained by command"]},listobj:{$help:["listobj","Display the list of all existing scene objects"]},file_list:{$help:["file_list [(|FILE_NAME)] [-f=]","Report registered files on server or presets in file if defined FILE_ID or FILE_NAME"," also you can use -f flag for fast search"," entity by starting part of name"]},file_register:{$help:["file_register ","Try register current opened file to server"]},file_delete:{$help:["file_delete (|FILE_NAME) [-f]","Delete file from server"," if -f not set then file will be deleted"," only when it has not got any presets in it"," if -f set then file will be deleted anyway"]},preset_add:{$help:["preset_add ","Create new preset from current viewer state"," to current opened file on server"]},preset_delete:{$help:["preset_delete (|)","Delete preset from server"]},preset_update:{$help:["preset_update <(|)","Update due the current viewer state"]},preset_rename:{$help:["preset_rename (|) ","Rename preset"]},preset_open:{$help:["preset_open (|)","Load preset"]},create_scenario:{$help:["create_scenario "," Creates scenario context for future work with them"]},reset_scenario:{$help:["reset_scenario"," Clear current scenario context"]},add_scenario_item:{$help:["add_scenario_item"," pdb=( | )"," prst=(|)"," delay="," desc=\n"," Add item to context and update scenario on server"," Pay attention that order of arguments is important"]},delete_scenario:{$help:["delete_scenario (|)"," Deletes scenario from server"]},list_scenario:{$help:["list_scenario [-e [|]]"," Report scenario list, when -e is set reports expanded"," If set -e then reports only requested scenario"]}};function Qx(t){var e=Sp.keyword(t[0]);if(!e||!e.SelectorClass)return null;var r=null,n=e.SelectorClass.prototype;return n instanceof Sp.PrefixOperator&&2===t.length?r=e(Qx(t[1])):n instanceof Sp.InfixOperator&&3===t.length?r=e(Qx(t[1]),Qx(t[2])):n instanceof Sp.RangeListSelector&&2===t.length?r=e(function(t){for(var e,r=[],n=0;n"},cb.prototype.add=function(t,e){if(void 0!==e){if(this.representationMap.hasOwnProperty(t))return"This name has already existed, registered without name";this.representationMap[t.toString()]=e,this.representationID[e]=t.toString()}return"Representation "+t+" successfully added"},cb.prototype.remove=function(t){t&&this.representationID.hasOwnProperty(t)&&(delete this.representationMap[this.representationID[t]],delete this.representationID[t]);var e=Object.keys(this.representationID).sort();for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];n>t&&(this.representationID[n-1]=this.representationID[n],this.representationMap[this.representationID[n]]-=1,delete this.representationID[n])}},cb.prototype.clear=function(){this.representationMap={},this.representationID={}};var ub=new cb;function hb(){}hb.prototype.list=function(t,e,r){var n="";if(t&&void 0!==e&&(void 0===r||"-e"===r))for(var i=t.repCount(),o=0;o"===s?"":s)+"\n",void 0!==n&&(i+=' selection : "'+c+'"\n',i+=" mode : ("+l.id+"), "+l.name+"\n",i+=" colorer : ("+u.id+"), "+u.name+"\n",i+=" material : ("+h.id+"), "+h.name+"\n"),i},hb.prototype.listSelector=function(t,e){var r="";for(var n in e)e.hasOwnProperty(n)&&(r+=n+' : "'+e[n]+'"\n');return r},hb.prototype.listObjs=function(t){var e=t._objects;if(!e||!Array.isArray(e)||0===e.length)return"There are no objects on the scene";for(var r=[],n=0,i=e.length;n0)throw{message:t+' must be a "'+Fu(n.get(ab.defaults,t))+'"'};if("theme"===t){for(var o=Object.keys(ab.defaults.themes),a=!1,s=0;s1?(void 0!==i&&i("There are two or more files, please specify one by file_id"),o.finish(t)):void 0!==r?r(s[0].id):o.finish(t)}else o.finish(t)},function(e){void 0!==e&&void 0!==i&&i(e),o.finish(t)})},mb.prototype.requestPdbID=function(t,e,r,n){var i=this;var o=e.split("/");if(t.awaitWhileCMDisInProcess(),1!==o.length)void 0!==n&&n("Path can contain only file name or id"),i.finish(t);else{var a=Number(o[0]);Number.isNaN(a)?t.srvTopologyFind(o[0],function(e){e instanceof Array?e.length<1?(void 0!==n&&n("File not found"),i.finish(t)):e.length>1?(void 0!==n&&n("There are two or more files, please specify one by file_id"),i.finish(t)):void 0!==r?r(e[0].id):i.finish(t):i.finish(t)},function(e){void 0!==e&&void 0!==n&&n(e),i.finish(t)}):r(a)}},mb.prototype.requestPresetId=function(t,e,r,i){var o=this,a=e.split("/");function s(e){void 0!==e&&void 0!==i&&i(e),o.finish(t)}function l(e){if(e instanceof Array){var s=n.filter(e,function(t){return t.name.toLowerCase()===a[1].toLowerCase()||t.id===Number(a[1])});s.length<1?(void 0!==i&&i("Preset not found"),o.finish(t)):s.length>1?(void 0!==i&&i("There are two or more presets, please specify one by preset_id"),o.finish(t)):void 0!==r?r(s[0].id):o.finish(t)}else o.finish(t)}t.awaitWhileCMDisInProcess(),2!==a.length?(void 0!==i&&i("Path can has 2 levels only (pdb/preset)"),o.finish(t)):this.requestPdbID(t,a[0],function(e){t.srvPresetList(e,l,s)},s)},mb.prototype.createScenario=function(t){this.scenarioContext=new fb(t)},mb.prototype.resetScenario=function(){this.scenarioContext=new fb},mb.prototype.deleteScenario=function(t,e,r,n){var i=this;function o(r){void 0!==r&&e(r),i.finish(t)}function a(e){void 0!==e&&r(e),i.finish(t)}function s(e){t.srvScenarioDelete(e,o,a),i.finish(t)}this.init(t,e),t.awaitWhileCMDisInProcess(),"number"==typeof n?s(n):this.requestScenarioID(t,n,s,a)},mb.prototype.listScenario=function(t,e,r,n){var i=this;this.init(t,e),t.awaitWhileCMDisInProcess(),t.srvScenarioList(function(r){if(r instanceof Array){for(var o="",a=0,s=r.length;a"),void i.finish(t);if(7!==arguments.length)return 5===arguments.length?(r("not supported now"),void i.finish(t)):(r("internal interpreter error"),void i.finish(t));var l,c,u,h,p=arguments[3],d=arguments[4],f=arguments[5],m=arguments[6];if(n.isString(p))this.requestPdbID(t,p,function(t){t>=0&&(o[3]=t,i.addScenarioItem.apply(i,o))},s);else if(n.isString(d))this.requestPresetId(t,p+"/"+d,function(t){t>=0&&(o[4]=t,i.addScenarioItem.apply(i,o))},s);else{if("number"!=typeof p||"number"!=typeof d)return s("Internal error"),void i.finish(t);l=p,c=d,u=f,h=m,i.scenarioContext.script.addItem(i.scenarioContext.id,new function(t,e,r,n){return this.pdbId=-1,this.presetId=-1,this.delay=-1,this.description="",void 0!==t&&(this.pdbId=t),void 0!==e&&(this.presetId=e),void 0!==r&&(this.delay=r),void 0!==n&&(this.description=n),this}(l,c,u,h)),t.srvScenarioAdd(i.scenarioContext.id,i.scenarioContext.name,JSON.stringify(i.scenarioContext.script),a,s)}},mb.prototype.init=function(t,e){var r=this;this.isOnApllyPresetEventInitialized||(t.addEventListener("presetApplyFinished",function(){r.finish(t),void 0!==e&&e("Preset applied")}),this.isOnApllyPresetEventInitialized=!0)},mb.prototype.finish=function(t){t.finishAwaitingCMDInProcess()},mb.prototype.fileList=function(t,e,r,n,i){var o=this;function a(r){if(void 0!==r)for(var n=0;n1?(r("There are two or more presets, please specify one by preset_id"),s.finish(t)):void 0===a?o.call(t,i[0].id,c,h):o.call(t,i[0].id,a,c,h)}else s.finish(t)}function h(e){void 0!==e&&r(e),s.finish(t)}2!==l.length?(r("Path can has 2 levels only (pdb/preset)"),s.finish(t)):t.srvTopologyFind(l[0],function(e){e instanceof Array?e.length<1?(r("File not found"),s.finish(t)):e.length>1?(r("There are two or more files, please specify one by file_id"),s.finish(t)):t.srvPresetList(e[0].id,u,h):s.finish(t)},h)},mb.prototype.coroutineWithFileName=function(t,e,r,n,i){var o=this,a=arguments;this.init(t),t.awaitWhileCMDisInProcess();var s=n.split("/");function l(r){void 0!==r&&e(r),o.finish(t)}function c(e){void 0!==e&&r(e),o.finish(t)}1!==s.length?(r("Path can contain only file name or id"),o.finish(t)):t.srvTopologyFind(s[0],function(e){if(e instanceof Array)if(e.length<1)r("File not found");else if(e.length>1)r("There are two or more files, please specify one by file_id");else switch(a.length){case 5:i.call(t,e[0].id,l,c);break;case 6:i.call(t,e[0].id,a[5],l,c);break;case 9:i.call(a[5],a[6],a[7],a[8],e[0].id);break;case 10:i.call(a[5],a[6],a[7],a[8],e[0].id,a[9]);break;default:o.finish(t)}o.finish(t)},c)};var gb=new mb;function vb(t){var e={s:"selector",m:"mode",c:"colorer",mt:"material",mode:"modes",color:"colorers",colorer:"colorers",select:"selector",material:"materials",selector:"selector"}[t];return void 0===e?t:e}function yb(t){if(t instanceof this.constructor)return t;t instanceof Array?this._values=t.slice(0):this._values=t?[t]:[]}yb.prototype.append=function(t){var e=this._values;return e[e.length]=t,this},yb.prototype.remove=function(t){var e=this._values,r=e.indexOf(t);return r>=0&&e.splice(r,1),this},yb.prototype.toJSO=function(t,e,r){for(var i={},o=this._values,a=0,s=o.length;a0},kx.prototype.callNextCmd=function(){if(this.isScriptingCommandAvailable()){var t=this.cmdQueue.shift(),e={success:!1};try{Wx.parse(t),e.success=!0}catch(t){e.error=t.message,Wx.yy.error(e.error),this.finishAwaitingCMDInProcess()}return e}return""},kx.JSONConverter=Jx,Wx.yy=_b,Wx.yy.parseError=Wx.parseError,kx}); //# sourceMappingURL=Miew.min.js.map diff --git a/dist/Miew.module.js b/dist/Miew.module.js index a7683d54..84f75b1e 100644 --- a/dist/Miew.module.js +++ b/dist/Miew.module.js @@ -1,4 +1,4 @@ -/** Miew - 3D Molecular Viewer v0.7.11 Copyright (c) 2015-2018 EPAM Systems, Inc. */ +/** Miew - 3D Molecular Viewer v0.7.12 Copyright (c) 2015-2018 EPAM Systems, Inc. */ var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; @@ -27,7 +27,7 @@ var lodash = createCommonjsModule(function (module, exports) { var undefined; /** Used as the semantic version number. */ - var VERSION = '4.17.4'; + var VERSION = '4.17.5'; /** Used as the size to enable large array optimizations. */ var LARGE_ARRAY_SIZE = 200; @@ -158,7 +158,6 @@ var lodash = createCommonjsModule(function (module, exports) { /** Used to match property names within property paths. */ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, - reLeadingDot = /^\./, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; /** @@ -258,8 +257,8 @@ var lodash = createCommonjsModule(function (module, exports) { reOptMod = rsModifier + '?', rsOptVar = '[' + rsVarRange + ']?', rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', - rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)', - rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)', + rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', + rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', rsSeq = rsOptVar + reOptMod + rsOptJoin, rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; @@ -466,34 +465,6 @@ var lodash = createCommonjsModule(function (module, exports) { /*--------------------------------------------------------------------------*/ - /** - * Adds the key-value `pair` to `map`. - * - * @private - * @param {Object} map The map to modify. - * @param {Array} pair The key-value pair to add. - * @returns {Object} Returns `map`. - */ - function addMapEntry(map, pair) { - // Don't return `map.set` because it's not chainable in IE 11. - map.set(pair[0], pair[1]); - return map; - } - - /** - * Adds `value` to `set`. - * - * @private - * @param {Object} set The set to modify. - * @param {*} value The value to add. - * @returns {Object} Returns `set`. - */ - function addSetEntry(set, value) { - // Don't return `set.add` because it's not chainable in IE 11. - set.add(value); - return set; - } - /** * A faster alternative to `Function#apply`, this function invokes `func` * with the `this` binding of `thisArg` and the arguments of `args`. @@ -1260,6 +1231,20 @@ var lodash = createCommonjsModule(function (module, exports) { return result; } + /** + * Gets the value at `key`, unless `key` is "__proto__". + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ + function safeGet(object, key) { + return key == '__proto__' + ? undefined + : object[key]; + } + /** * Converts `set` to an array of its values. * @@ -2692,7 +2677,7 @@ var lodash = createCommonjsModule(function (module, exports) { if (!cloneableTags[tag]) { return object ? value : {}; } - result = initCloneByTag(value, tag, baseClone, isDeep); + result = initCloneByTag(value, tag, isDeep); } } // Check for circular references and return its corresponding clone. @@ -2703,6 +2688,22 @@ var lodash = createCommonjsModule(function (module, exports) { } stack.set(value, result); + if (isSet(value)) { + value.forEach(function(subValue) { + result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); + }); + + return result; + } + + if (isMap(value)) { + value.forEach(function(subValue, key) { + result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + + return result; + } + var keysFunc = isFull ? (isFlat ? getAllKeysIn : getAllKeys) : (isFlat ? keysIn : keys); @@ -3630,7 +3631,7 @@ var lodash = createCommonjsModule(function (module, exports) { } else { var newValue = customizer - ? customizer(object[key], srcValue, (key + ''), object, source, stack) + ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) : undefined; if (newValue === undefined) { @@ -3657,8 +3658,8 @@ var lodash = createCommonjsModule(function (module, exports) { * counterparts. */ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { - var objValue = object[key], - srcValue = source[key], + var objValue = safeGet(object, key), + srcValue = safeGet(source, key), stacked = stack.get(srcValue); if (stacked) { @@ -4566,20 +4567,6 @@ var lodash = createCommonjsModule(function (module, exports) { return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); } - /** - * Creates a clone of `map`. - * - * @private - * @param {Object} map The map to clone. - * @param {Function} cloneFunc The function to clone values. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned map. - */ - function cloneMap(map, isDeep, cloneFunc) { - var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map); - return arrayReduce(array, addMapEntry, new map.constructor); - } - /** * Creates a clone of `regexp`. * @@ -4593,20 +4580,6 @@ var lodash = createCommonjsModule(function (module, exports) { return result; } - /** - * Creates a clone of `set`. - * - * @private - * @param {Object} set The set to clone. - * @param {Function} cloneFunc The function to clone values. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned set. - */ - function cloneSet(set, isDeep, cloneFunc) { - var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set); - return arrayReduce(array, addSetEntry, new set.constructor); - } - /** * Creates a clone of the `symbol` object. * @@ -6201,7 +6174,7 @@ var lodash = createCommonjsModule(function (module, exports) { */ function initCloneArray(array) { var length = array.length, - result = array.constructor(length); + result = new array.constructor(length); // Add properties assigned by `RegExp#exec`. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { @@ -6228,16 +6201,15 @@ var lodash = createCommonjsModule(function (module, exports) { * Initializes an object clone based on its `toStringTag`. * * **Note:** This function only supports cloning values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. * * @private * @param {Object} object The object to clone. * @param {string} tag The `toStringTag` of the object to clone. - * @param {Function} cloneFunc The function to clone values. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the initialized clone. */ - function initCloneByTag(object, tag, cloneFunc, isDeep) { + function initCloneByTag(object, tag, isDeep) { var Ctor = object.constructor; switch (tag) { case arrayBufferTag: @@ -6256,7 +6228,7 @@ var lodash = createCommonjsModule(function (module, exports) { return cloneTypedArray(object, isDeep); case mapTag: - return cloneMap(object, isDeep, cloneFunc); + return new Ctor; case numberTag: case stringTag: @@ -6266,7 +6238,7 @@ var lodash = createCommonjsModule(function (module, exports) { return cloneRegExp(object); case setTag: - return cloneSet(object, isDeep, cloneFunc); + return new Ctor; case symbolTag: return cloneSymbol(object); @@ -6313,10 +6285,13 @@ var lodash = createCommonjsModule(function (module, exports) { * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. */ function isIndex(value, length) { + var type = typeof value; length = length == null ? MAX_SAFE_INTEGER : length; + return !!length && - (typeof value == 'number' || reIsUint.test(value)) && - (value > -1 && value % 1 == 0 && value < length); + (type == 'number' || + (type != 'symbol' && reIsUint.test(value))) && + (value > -1 && value % 1 == 0 && value < length); } /** @@ -6766,11 +6741,11 @@ var lodash = createCommonjsModule(function (module, exports) { */ var stringToPath = memoizeCapped(function(string) { var result = []; - if (reLeadingDot.test(string)) { + if (string.charCodeAt(0) === 46 /* . */) { result.push(''); } - string.replace(rePropName, function(match, number, quote, string) { - result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); + string.replace(rePropName, function(match, number, quote, subString) { + result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); }); return result; }); @@ -10378,9 +10353,11 @@ var lodash = createCommonjsModule(function (module, exports) { function remainingWait(time) { var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, - result = wait - timeSinceLastCall; + timeWaiting = wait - timeSinceLastCall; - return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result; + return maxing + ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) + : timeWaiting; } function shouldInvoke(time) { @@ -12812,9 +12789,35 @@ var lodash = createCommonjsModule(function (module, exports) { * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } */ - var defaults = baseRest(function(args) { - args.push(undefined, customDefaultsAssignIn); - return apply(assignInWith, undefined, args); + var defaults = baseRest(function(object, sources) { + object = Object(object); + + var index = -1; + var length = sources.length; + var guard = length > 2 ? sources[2] : undefined; + + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + length = 1; + } + + while (++index < length) { + var source = sources[index]; + var props = keysIn(source); + var propsIndex = -1; + var propsLength = props.length; + + while (++propsIndex < propsLength) { + var key = props[propsIndex]; + var value = object[key]; + + if (value === undefined || + (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { + object[key] = source[key]; + } + } + } + + return object; }); /** @@ -13211,6 +13214,11 @@ var lodash = createCommonjsModule(function (module, exports) { * // => { '1': 'c', '2': 'b' } */ var invert = createInverter(function(result, value, key) { + if (value != null && + typeof value.toString != 'function') { + value = nativeObjectToString.call(value); + } + result[value] = key; }, constant(identity)); @@ -13241,6 +13249,11 @@ var lodash = createCommonjsModule(function (module, exports) { * // => { 'group1': ['a', 'c'], 'group2': ['b'] } */ var invertBy = createInverter(function(result, value, key) { + if (value != null && + typeof value.toString != 'function') { + value = nativeObjectToString.call(value); + } + if (hasOwnProperty.call(result, value)) { result[value].push(key); } else { @@ -61320,381 +61333,257 @@ var THREE = Object.freeze({ CanvasRenderer: CanvasRenderer }); -var spin = createCommonjsModule(function (module) { -/** - * Copyright (c) 2011-2014 Felix Gnass - * Licensed under the MIT license - * http://spin.js.org/ - * - * Example: - var opts = { - lines: 12 // The number of lines to draw - , length: 7 // The length of each line - , width: 5 // The line thickness - , radius: 10 // The radius of the inner circle - , scale: 1.0 // Scales overall size of the spinner - , corners: 1 // Roundness (0..1) - , color: '#000' // #rgb or #rrggbb - , opacity: 1/4 // Opacity of the lines - , rotate: 0 // Rotation offset - , direction: 1 // 1: clockwise, -1: counterclockwise - , speed: 1 // Rounds per second - , trail: 100 // Afterglow percentage - , fps: 20 // Frames per second when using setTimeout() - , zIndex: 2e9 // Use a high z-index by default - , className: 'spinner' // CSS class to assign to the element - , top: '50%' // center vertically - , left: '50%' // center horizontally - , shadow: false // Whether to render a shadow - , hwaccel: false // Whether to use hardware acceleration (might be buggy) - , position: 'absolute' // Element positioning - } - var target = document.getElementById('foo') - var spinner = new Spinner(opts).spin(target) - */ -(function (root, factory) { - - /* CommonJS */ - if ('object' == 'object' && module.exports) module.exports = factory(); - - /* AMD module */ - else if (typeof undefined == 'function' && undefined.amd) undefined(factory); - - /* Browser global */ - else root.Spinner = factory(); -}(commonjsGlobal, function () { - var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */ - , animations = {} /* Animation rules keyed by their name */ - , useCssAnimations /* Whether to use CSS animations or setTimeout */ - , sheet; /* A stylesheet to hold the @keyframe or VML rules. */ - - /** - * Utility function to create elements. If no tag name is given, - * a DIV is created. Optionally properties can be passed. - */ - function createEl (tag, prop) { - var el = document.createElement(tag || 'div') - , n; - - for (n in prop) el[n] = prop[n]; - return el - } - - /** - * Appends children and returns the parent. - */ - function ins (parent /* child1, child2, ...*/) { - for (var i = 1, n = arguments.length; i < n; i++) { - parent.appendChild(arguments[i]); - } - - return parent - } - - /** - * Creates an opacity keyframe animation rule and returns its name. - * Since most mobile Webkits have timing issues with animation-delay, - * we create separate rules for each line/segment. - */ - function addAnimation (alpha, trail, i, lines) { - var name = ['opacity', trail, ~~(alpha * 100), i, lines].join('-') - , start = 0.01 + i/lines * 100 - , z = Math.max(1 - (1-alpha) / trail * (100-start), alpha) - , prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase() - , pre = prefix && '-' + prefix + '-' || ''; - - if (!animations[name]) { - sheet.insertRule( - '@' + pre + 'keyframes ' + name + '{' + - '0%{opacity:' + z + '}' + - start + '%{opacity:' + alpha + '}' + - (start+0.01) + '%{opacity:1}' + - (start+trail) % 100 + '%{opacity:' + alpha + '}' + - '100%{opacity:' + z + '}' + - '}', sheet.cssRules.length); - - animations[name] = 1; - } - - return name - } - - /** - * Tries various vendor prefixes and returns the first supported property. - */ - function vendor (el, prop) { - var s = el.style - , pp - , i; - - prop = prop.charAt(0).toUpperCase() + prop.slice(1); - if (s[prop] !== undefined) return prop - for (i = 0; i < prefixes.length; i++) { - pp = prefixes[i]+prop; - if (s[pp] !== undefined) return pp - } - } - - /** - * Sets multiple style properties at once. - */ - function css (el, prop) { - for (var n in prop) { - el.style[vendor(el, n) || n] = prop[n]; - } - - return el - } - - /** - * Fills in default values. - */ - function merge (obj) { - for (var i = 1; i < arguments.length; i++) { - var def = arguments[i]; - for (var n in def) { - if (obj[n] === undefined) obj[n] = def[n]; - } +var __assign = (undefined && undefined.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; +var defaults = { + lines: 12, + length: 7, + width: 5, + radius: 10, + scale: 1.0, + corners: 1, + color: '#000', + fadeColor: 'transparent', + opacity: 0.25, + rotate: 0, + direction: 1, + speed: 1, + trail: 100, + fps: 20, + zIndex: 2e9, + className: 'spinner', + top: '50%', + left: '50%', + shadow: 'none', + position: 'absolute', +}; +var Spinner = /** @class */ (function () { + function Spinner(opts) { + if (opts === void 0) { opts = {}; } + this.opts = __assign({}, defaults, opts); } - return obj - } - - /** - * Returns the line color from the given string or array. - */ - function getColor (color, idx) { - return typeof color == 'string' ? color : color[idx % color.length] - } - - // Built-in defaults - - var defaults = { - lines: 12 // The number of lines to draw - , length: 7 // The length of each line - , width: 5 // The line thickness - , radius: 10 // The radius of the inner circle - , scale: 1.0 // Scales overall size of the spinner - , corners: 1 // Roundness (0..1) - , color: '#000' // #rgb or #rrggbb - , opacity: 1/4 // Opacity of the lines - , rotate: 0 // Rotation offset - , direction: 1 // 1: clockwise, -1: counterclockwise - , speed: 1 // Rounds per second - , trail: 100 // Afterglow percentage - , fps: 20 // Frames per second when using setTimeout() - , zIndex: 2e9 // Use a high z-index by default - , className: 'spinner' // CSS class to assign to the element - , top: '50%' // center vertically - , left: '50%' // center horizontally - , shadow: false // Whether to render a shadow - , hwaccel: false // Whether to use hardware acceleration (might be buggy) - , position: 'absolute' // Element positioning - }; - - /** The constructor */ - function Spinner (o) { - this.opts = merge(o || {}, Spinner.defaults, defaults); - } - - // Global defaults that override the built-ins: - Spinner.defaults = {}; - - merge(Spinner.prototype, { /** * Adds the spinner to the given target element. If this instance is already - * spinning, it is automatically removed from its previous target b calling + * spinning, it is automatically removed from its previous target by calling * stop() internally. */ - spin: function (target) { - this.stop(); - - var self = this - , o = self.opts - , el = self.el = createEl(null, {className: o.className}); - - css(el, { - position: o.position - , width: 0 - , zIndex: o.zIndex - , left: o.left - , top: o.top - }); - - if (target) { - target.insertBefore(el, target.firstChild || null); - } - - el.setAttribute('role', 'progressbar'); - self.lines(el, self.opts); - - if (!useCssAnimations) { - // No CSS animation support, use setTimeout() instead - var i = 0 - , start = (o.lines - 1) * (1 - o.direction) / 2 - , alpha - , fps = o.fps - , f = fps / o.speed - , ostep = (1 - o.opacity) / (f * o.trail / 100) - , astep = f / o.lines;(function anim () { - i++; - for (var j = 0; j < o.lines; j++) { - alpha = Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity); - - self.opacity(el, j * o.direction + start, alpha, o); - } - self.timeout = self.el && setTimeout(anim, ~~(1000 / fps)); - })(); - } - return self - } - + Spinner.prototype.spin = function (target) { + var _this = this; + this.stop(); + this.el = document.createElement('div'); + this.el.className = this.opts.className; + this.el.setAttribute('role', 'progressbar'); + css(this.el, { + position: this.opts.position, + width: 0, + zIndex: this.opts.zIndex, + left: this.opts.left, + top: this.opts.top, + transform: "scale(" + this.opts.scale + ")", + }); + if (target) { + target.insertBefore(this.el, target.firstChild || null); + } + var animator; + var getNow; + if (typeof requestAnimationFrame !== 'undefined') { + animator = requestAnimationFrame; + getNow = function () { return performance.now(); }; + } + else { + // fallback for IE 9 + animator = function (callback) { return setTimeout(callback, 1000 / _this.opts.fps); }; + getNow = function () { return Date.now(); }; + } + var lastFrameTime; + var state = 0; // state is rotation percentage (between 0 and 1) + var animate = function () { + var time = getNow(); + if (lastFrameTime === undefined) { + lastFrameTime = time - 1; + } + state += getAdvancePercentage(time - lastFrameTime, _this.opts.speed); + lastFrameTime = time; + if (state > 1) { + state -= Math.floor(state); + } + if (_this.el.childNodes.length === _this.opts.lines) { + for (var line = 0; line < _this.opts.lines; line++) { + var opacity = getLineOpacity(line, state, _this.opts); + _this.el.childNodes[line].childNodes[0].style.opacity = opacity.toString(); + } + } + _this.animateId = _this.el ? animator(animate) : undefined; + }; + drawLines(this.el, this.opts); + animate(); + return this; + }; /** * Stops and removes the Spinner. + * Stopped spinners may be reused by calling spin() again. */ - , stop: function () { - var el = this.el; - if (el) { - clearTimeout(this.timeout); - if (el.parentNode) el.parentNode.removeChild(el); - this.el = undefined; - } - return this - } - - /** - * Internal method that draws the individual lines. Will be overwritten - * in VML fallback mode below. - */ - , lines: function (el, o) { - var i = 0 - , start = (o.lines - 1) * (1 - o.direction) / 2 - , seg; - - function fill (color, shadow) { - return css(createEl(), { - position: 'absolute' - , width: o.scale * (o.length + o.width) + 'px' - , height: o.scale * o.width + 'px' - , background: color - , boxShadow: shadow - , transformOrigin: 'left' - , transform: 'rotate(' + ~~(360/o.lines*i + o.rotate) + 'deg) translate(' + o.scale*o.radius + 'px' + ',0)' - , borderRadius: (o.corners * o.scale * o.width >> 1) + 'px' - }) - } - - for (; i < o.lines; i++) { - seg = css(createEl(), { - position: 'absolute' - , top: 1 + ~(o.scale * o.width / 2) + 'px' - , transform: o.hwaccel ? 'translate3d(0,0,0)' : '' - , opacity: o.opacity - , animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1 / o.speed + 's linear infinite' - }); - - if (o.shadow) ins(seg, css(fill('#000', '0 0 4px #000'), {top: '2px'})); - ins(el, ins(seg, fill(getColor(o.color, i), '0 0 1px rgba(0,0,0,.1)'))); - } - return el + Spinner.prototype.stop = function () { + if (this.el) { + if (typeof requestAnimationFrame !== 'undefined') { + cancelAnimationFrame(this.animateId); + } + else { + clearTimeout(this.animateId); + } + if (this.el.parentNode) { + this.el.parentNode.removeChild(this.el); + } + this.el = undefined; + } + return this; + }; + return Spinner; +}()); +function getAdvancePercentage(msSinceLastFrame, roundsPerSecond) { + return msSinceLastFrame / 1000 * roundsPerSecond; +} +function getLineOpacity(line, state, opts) { + var linePercent = (line + 1) / opts.lines; + var diff = state - (linePercent * opts.direction); + if (diff < 0 || diff > 1) { + diff += opts.direction; + } + // opacity should start at 1, and approach opacity option as diff reaches trail percentage + var trailPercent = opts.trail / 100; + var opacityPercent = 1 - diff / trailPercent; + if (opacityPercent < 0) { + return opts.opacity; + } + var opacityDiff = 1 - opts.opacity; + return opacityPercent * opacityDiff + opts.opacity; +} +/** + * Tries various vendor prefixes and returns the first supported property. + */ +function vendor(el, prop) { + if (el.style[prop] !== undefined) { + return prop; } - - /** - * Internal method that adjusts the opacity of a single line. - * Will be overwritten in VML fallback mode below. - */ - , opacity: function (el, i, val) { - if (i < el.childNodes.length) el.childNodes[i].style.opacity = val; + // needed for transform properties in IE 9 + var prefixed = 'ms' + prop.charAt(0).toUpperCase() + prop.slice(1); + if (el.style[prefixed] !== undefined) { + return prefixed; } - - }); - - - function initVML () { - - /* Utility function to create a VML tag */ - function vml (tag, attr) { - return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr) + return ''; +} +/** + * Sets multiple style properties at once. + */ +function css(el, props) { + for (var prop in props) { + el.style[vendor(el, prop) || prop] = props[prop]; } - - // No CSS transforms but VML support, add a CSS rule for VML elements: - sheet.addRule('.spin-vml', 'behavior:url(#default#VML)'); - - Spinner.prototype.lines = function (el, o) { - var r = o.scale * (o.length + o.width) - , s = o.scale * 2 * r; - - function grp () { - return css( - vml('group', { - coordsize: s + ' ' + s - , coordorigin: -r + ' ' + -r - }) - , { width: s, height: s } - ) - } - - var margin = -(o.width + o.length) * o.scale * 2 + 'px' - , g = css(grp(), {position: 'absolute', top: margin, left: margin}) - , i; - - function seg (i, dx, filter) { - ins( - g - , ins( - css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}) - , ins( - css( - vml('roundrect', {arcsize: o.corners}) - , { width: r - , height: o.scale * o.width - , left: o.scale * o.radius - , top: -o.scale * o.width >> 1 - , filter: filter - } - ) - , vml('fill', {color: getColor(o.color, i), opacity: o.opacity}) - , vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change - ) - ) - ); - } - - if (o.shadow) - for (i = 1; i <= o.lines; i++) { - seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)'); + return el; +} +/** + * Returns the line color from the given string or array. + */ +function getColor(color, idx) { + return typeof color == 'string' ? color : color[idx % color.length]; +} +/** + * Internal method that draws the individual lines. + */ +function drawLines(el, opts) { + var borderRadius = (Math.round(opts.corners * opts.width * 500) / 1000) + 'px'; + var shadow = 'none'; + if (opts.shadow === true) { + shadow = '0 2px 4px #000'; // default shadow + } + else if (typeof opts.shadow === 'string') { + shadow = opts.shadow; + } + var shadows = parseBoxShadow(shadow); + for (var i = 0; i < opts.lines; i++) { + var degrees = ~~(360 / opts.lines * i + opts.rotate); + var backgroundLine = css(document.createElement('div'), { + position: 'absolute', + top: -opts.width / 2 + "px", + width: (opts.length + opts.width) + 'px', + height: opts.width + 'px', + background: getColor(opts.fadeColor, i), + borderRadius: borderRadius, + transformOrigin: 'left', + transform: "rotate(" + degrees + "deg) translateX(" + opts.radius + "px)", + }); + var line = css(document.createElement('div'), { + width: '100%', + height: '100%', + background: getColor(opts.color, i), + borderRadius: borderRadius, + boxShadow: normalizeShadow(shadows, degrees), + opacity: opts.opacity, + }); + backgroundLine.appendChild(line); + el.appendChild(backgroundLine); + } +} +function parseBoxShadow(boxShadow) { + var regex = /^\s*([a-zA-Z]+\s+)?(-?\d+(\.\d+)?)([a-zA-Z]*)\s+(-?\d+(\.\d+)?)([a-zA-Z]*)(.*)$/; + var shadows = []; + for (var _i = 0, _a = boxShadow.split(','); _i < _a.length; _i++) { + var shadow = _a[_i]; + var matches = shadow.match(regex); + if (matches === null) { + continue; // invalid syntax } - - for (i = 1; i <= o.lines; i++) seg(i); - return ins(el, g) - }; - - Spinner.prototype.opacity = function (el, i, val, o) { - var c = el.firstChild; - o = o.shadow && o.lines || 0; - if (c && i + o < c.childNodes.length) { - c = c.childNodes[i + o]; c = c && c.firstChild; c = c && c.firstChild; - if (c) c.opacity = val; - } - }; - } - - if (typeof document !== 'undefined') { - sheet = (function () { - var el = createEl('style', {type : 'text/css'}); - ins(document.getElementsByTagName('head')[0], el); - return el.sheet || el.styleSheet - }()); - - var probe = css(createEl('group'), {behavior: 'url(#default#VML)'}); - - if (!vendor(probe, 'transform') && probe.adj) initVML(); - else useCssAnimations = vendor(probe, 'animation'); - } - - return Spinner - -})); -}); + var x = +matches[2]; + var y = +matches[5]; + var xUnits = matches[4]; + var yUnits = matches[7]; + if (x === 0 && !xUnits) { + xUnits = yUnits; + } + if (y === 0 && !yUnits) { + yUnits = xUnits; + } + if (xUnits !== yUnits) { + continue; // units must match to use as coordinates + } + shadows.push({ + prefix: matches[1] || '', + x: x, + y: y, + xUnits: xUnits, + yUnits: yUnits, + end: matches[8], + }); + } + return shadows; +} +/** + * Modify box-shadow x/y offsets to counteract rotation + */ +function normalizeShadow(shadows, degrees) { + var normalized = []; + for (var _i = 0, shadows_1 = shadows; _i < shadows_1.length; _i++) { + var shadow = shadows_1[_i]; + var xy = convertOffset(shadow.x, shadow.y, degrees); + normalized.push(shadow.prefix + xy[0] + shadow.xUnits + ' ' + xy[1] + shadow.yUnits + shadow.end); + } + return normalized.join(', '); +} +function convertOffset(x, y, degrees) { + var radians = degrees * Math.PI / 180; + var sin = Math.sin(radians); + var cos = Math.cos(radians); + return [ + Math.round((x * cos + y * sin) * 1000) / 1000, + Math.round((-x * sin + y * cos) * 1000) / 1000, + ]; +} /** * This class introduces the simplest event system. @@ -62575,7 +62464,20 @@ var createClass = function () { +var defineProperty = function (obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; +}; @@ -62734,7 +62636,7 @@ var VERSION = 0; * @alias SettingsObject * @namespace */ -var defaults$1 = { +var defaults$2 = { /** * Default options for all available modes. * Use {@link Mode.id} as a dictionary key to access mode options. @@ -63530,7 +63432,7 @@ function Settings() { Settings.prototype = { constructor: Settings, - defaults: defaults$1, + defaults: defaults$2, set: function set(path, value) { lodash.set(this.now, path, value); @@ -63542,7 +63444,7 @@ Settings.prototype = { }, reset: function reset() { - this.now = lodash.cloneDeep(defaults$1); + this.now = lodash.cloneDeep(defaults$2); this.old = null; this._changed = {}; }, @@ -63583,7 +63485,7 @@ Settings.prototype = { }, getDiffs: function getDiffs(versioned) { - var diffs = utils.objectsDiff(this.now, defaults$1); + var diffs = utils.objectsDiff(this.now, defaults$2); if (versioned) { diffs.VERSION = VERSION; } @@ -63591,7 +63493,7 @@ Settings.prototype = { }, setPluginOpts: function setPluginOpts(plugin, opts) { - defaults$1.plugins[plugin] = lodash.cloneDeep(opts); + defaults$2.plugins[plugin] = lodash.cloneDeep(opts); this.now.plugins[plugin] = lodash.cloneDeep(opts); } }; @@ -63717,13 +63619,13 @@ function extractArgs(input, defaultsDict, params) { var args = input.substr(bang + 1).split(cLSep); input = inputVal; if (defaultsDict) { - var defaults$$1 = defaultsDict[input]; - var opts = utils.deriveDeep(defaults$$1, true); + var defaults = defaultsDict[input]; + var opts = utils.deriveDeep(defaults, true); args.forEach(function (arg) { var pair = arg.split(cL2Ass, 2); var key = decodeURIComponent(pair[0]), value = decodeURIComponent(pair[1]); - var adapter = adapters[_typeof(lodash.get(defaults$$1, key))]; + var adapter = adapters[_typeof(lodash.get(defaults, key))]; if (adapter) { lodash.set(opts, key, adapter(value)); } else { @@ -67543,7 +67445,7 @@ Component.prototype.getMaskedSubdivSequences = function (mask) { ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// var cMaxPairsForHashCode = 32; -var cHashTableSize = 16384; +var cHashTableSize = 1024 * 1024; var cNumbersPerPair = 4; var cMaxNeighbours = 14; var cInvalidVal = -1; @@ -67592,7 +67494,7 @@ AtomPairs.prototype.addPair = function (indexA, indexB) { break; } if (code === codeToAdd) { - return; + return false; } } // add this new hash code @@ -67610,6 +67512,7 @@ AtomPairs.prototype.addPair = function (indexA, indexB) { this.intBuffer[j + 1] = ib; this.intBuffer[j + 2] = codeToAdd; this.numPairs++; + return true; }; ////////////////////////////////////////////////////////////////////////////// @@ -67637,23 +67540,6 @@ function _getBondingRadius(atom) { } } -/** - * Returns value, limited in given range (min, max) - * @param {number} val modified value - * @param {number} valMin minimum value in range - * @param {number} valMax maximum value in range - * @returns {number} original value (if it lie inside range) or range bound (left or right) - */ -function _clamp(val, valMin, valMax) { - if (val < valMin) { - return valMin; - } - if (val > valMax) { - return valMax; - } - return val; -} - function _isAtomEligible(atom) { // build for all non-hetatm and for hetatm without bonds return !atom.isHet() || atom._bonds && atom._bonds.length === 0; @@ -67707,80 +67593,60 @@ AutoBond.prototype._addExistingPairs = function () { return 0; }; -AutoBond.prototype._findPairs = function (volMap) { +AutoBond.prototype._findPairs = function () { + var vw = this._complex.getVoxelWorld(); + if (vw === null) { + return; + } + var atoms = this._complex._atoms; var atomsNum = atoms.length; - var vBoxMin = this._vBoxMin; - var xB = this.xB; - var yB = this.yB; - var zB = this.zB; - var invPairDist = this.invPairDist; - var xyTotalBoxes = yB * xB; var isAtomEligible = this.isAtomEligible; + var self = this; - for (var i = 0; i < atomsNum; ++i) { - var atom = atoms[i]; - if (!isAtomEligible(atom)) { - continue; + var rA = void 0; + var isHydrogenA = void 0; + var posA = void 0; + var locationA = void 0; + var atomA = void 0; + + var processAtom = function processAtom(atomB) { + if (isHydrogenA && atomB.isHydrogen()) { + return; } - var rA = atom.element.radiusBonding; - // 'H' == 72 - var isHydrogenA = atom.isHydrogen(); - var locationA = atom.getLocation(); + var locationB = atomB.getLocation(); + if (locationA !== cSpaceCode && locationB !== cSpaceCode && locationA !== locationB) { + return; + } - var posA = atom._position; - var axB = (posA.x - vBoxMin.x) * invPairDist | 0; - var ayB = (posA.y - vBoxMin.y) * invPairDist | 0; - var azB = (posA.z - vBoxMin.z) * invPairDist | 0; + var dist2 = posA.distanceToSquared(atomB._position); + var rB = atomB.element.radiusBonding; + var maxAcceptable = cBondRadInJMOL ? rA + rB + cBondTolerance : cVMDTolerance * (rA + rB); - for (var dz = -1; dz <= 1; ++dz) { - var zInd = azB + dz; - if (zInd < 0 || zInd >= zB) { - continue; - } - for (var dy = -1; dy <= 1; ++dy) { - var yInd = ayB + dy; - if (yInd < 0 || yInd >= yB) { - continue; - } - for (var dx = -1; dx <= 1; ++dx) { - var xInd = axB + dx; - if (xInd < 0 || xInd >= xB) { - continue; - } - var iIndex = zInd * xyTotalBoxes + yInd * xB + xInd; - var neighbours = volMap[iIndex]; - for (var j = 0; j < neighbours.length; ++j) { - var iB = neighbours[j]; - if (iB <= i) { - continue; - } - var atomB = atoms[iB]; - if (isHydrogenA && atomB.isHydrogen()) { - continue; - } + if (dist2 > maxAcceptable * maxAcceptable) { + return; + } - var locationB = atomB.getLocation(); - if (locationA !== cSpaceCode && locationB !== cSpaceCode && locationA !== locationB) { - continue; - } - var dist2 = posA.distanceToSquared(atomB._position); - var rB = atomB.element.radiusBonding; - var maxAcceptable = cBondRadInJMOL ? rA + rB + cBondTolerance : cVMDTolerance * (rA + rB); - if (dist2 > maxAcceptable * maxAcceptable) { - continue; - } + if (dist2 < cEpsilon) { + return; + } - if (dist2 < cEpsilon) { - continue; - } + self._pairCollection.addPair(atomA._index, atomB._index); + }; - this._pairCollection.addPair(i, iB); - } - } - } + for (var i = 0; i < atomsNum; ++i) { + atomA = atoms[i]; + if (!isAtomEligible(atomA)) { + continue; } + + rA = atomA.element.radiusBonding; + isHydrogenA = atomA.isHydrogen(); + posA = atomA._position; + locationA = atomA.getLocation(); + + vw.forEachAtomWithinRadius(posA, 2 * this._maxRad + cBondTolerance, processAtom); } }; @@ -67864,10 +67730,9 @@ AutoBond.prototype._buildInner = function () { this.isAtomEligible = settings.now.draft.waterBondingHack ? _isAtomEligibleWithWaterBondingHack : _isAtomEligible; this._calcBoundingBox(); - var volMap = this._buildGridMap(); this._pairCollection = new AtomPairs(atoms.length * cEstBondsMultiplier); this._addExistingPairs(); - this._findPairs(volMap); + this._findPairs(); this._addPairs(); }; @@ -67883,60 +67748,6 @@ AutoBond.prototype._calcBoundingBox = function () { this._maxRad = maxRad * 1.2; }; -AutoBond.prototype._buildGridMap = function () { - var cMaxBoxes = 125000; - var cRadMultiplier = 1.26; - - var pairDist = this._maxRad * 2; - var newPairDist = pairDist; - var vBoxMin = this._vBoxMin; - var vBoxMax = this._vBoxMax; - var xRange = vBoxMax.x - vBoxMin.x; - var yRange = vBoxMax.y - vBoxMin.y; - var zRange = vBoxMax.z - vBoxMin.z; - var xB, yB, zB, xyTotalBoxes; - var invPairDist; - var totalBoxes; - - do { - pairDist = newPairDist; - invPairDist = 1.0 / pairDist; - xB = (xRange * invPairDist | 0) + 1; - yB = (yRange * invPairDist | 0) + 1; - zB = (zRange * invPairDist | 0) + 1; - xyTotalBoxes = yB * xB; - totalBoxes = xyTotalBoxes * zB; - newPairDist = pairDist * cRadMultiplier; - } while (totalBoxes > cMaxBoxes); - this.xB = xB; - this.yB = yB; - this.zB = zB; - this.invPairDist = invPairDist; - - var voxMap = []; - var i = 0; - for (; i < totalBoxes; ++i) { - voxMap[i] = []; - } - var atoms = this._complex._atoms; - var nAtoms = atoms.length; - var isAtomEligible = this.isAtomEligible; - for (i = 0; i < nAtoms; ++i) { - if (!isAtomEligible(atoms[i])) { - continue; - } - var pos = atoms[i]._position; - var axB = _clamp((pos.x - vBoxMin.x) * invPairDist | 0, 0, xB); - var ayB = _clamp((pos.y - vBoxMin.y) * invPairDist | 0, 0, yB); - var azB = _clamp((pos.z - vBoxMin.z) * invPairDist | 0, 0, zB); - - var iIndex = azB * xyTotalBoxes + ayB * xB + axB; - voxMap[iIndex].push(i); - } - - return voxMap; -}; - AutoBond.prototype.destroy = function () { if (this._pairCollection) { this._pairCollection.destroy(); @@ -68184,6 +67995,1343 @@ AromaticLoopsMarker.prototype.detectCycles = function () { ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// +/** + * Calculate min & max radius of a sphere slice between zMin & zMax + * + * @param {Vector3} center - center of the sphere + * @param {number} radius - sphere radius + * @param {number} zMin - lower bound of the slice + * @param {number} zMax - upper bound of the slice + */ +function _getSphereSliceRadiusRange(center, radius, zMin, zMax) { + var dzMin = zMin - center.z; + var dzMax = zMax - center.z; + var rzMin = Math.sqrt(Math.max(radius * radius - dzMin * dzMin, 0.0)); + var rzMax = Math.sqrt(Math.max(radius * radius - dzMax * dzMax, 0.0)); + + var rMin = Math.min(rzMin, rzMax); + var rMax; + + if (zMin <= center.z && zMax >= center.z) { + // sphere's main diameter is inside slice + rMax = radius; + } else { + rMax = Math.max(rzMin, rzMax); + } + + return [rMin, rMax]; +} + +/** + * Calculate min & max radius of a circle slice between yMin & yMax. + * + * To maintain analogy with _getSphereSliceRadiusRange we call radius what in fact is + * half-width (along X axis) of the slice, i.e. 1D-sphere radius. + * + * @param {Vector3} center - center of the circle (z can be ignored) + * @param {number} radius - circle radius + * @param {number} yMin - lower bound of the slice + * @param {number} yMax - upper bound of the slice + * @returns {Array} - array of two numbers (min & max radius, or half-width) + */ +function _getCircleSliceRadiusRange(center, radius, yMin, yMax) { + var dyMin = yMin - center.y; + var dyMax = yMax - center.y; + var ryMin = Math.sqrt(Math.max(radius * radius - dyMin * dyMin, 0.0)); + var ryMax = Math.sqrt(Math.max(radius * radius - dyMax * dyMax, 0.0)); + + var rMin = Math.min(ryMin, ryMax); + var rMax; + + if (yMin <= center.y && yMax >= center.y) { + // slice's main diameter is inside slice + rMax = radius; + } else { + rMax = Math.max(ryMin, ryMax); + } + + return [rMin, rMax]; +} + +/** + * VoxelWorld constructor + * + * @param {Box3} box - bounding box of the volume to be partitioned + * @param {Vector3} vCellSizeHint - target voxel size (actual voxel size may differ from this) + */ +function VoxelWorld(box, vCellSizeHint) { + var i; + + this._box = box.clone(); + this._count = box.getSize().divide(vCellSizeHint).floor(); + this._last = this._count.clone().subScalar(1); + this._cellSize = box.getSize().divide(this._count); + this._cellInnerR = 0.5 * Math.min(Math.min(this._cellSize.x, this._cellSize.y), this._cellSize.z); + this._cellOuterR = 0.5 * Math.sqrt(this._cellSize.dot(this._cellSize)); + + // array of voxels, each element contains index of first atom in voxel + var numVoxels = this._count.x * this._count.y * this._count.z; + this._voxels = utils.allocateTyped(Int32Array, numVoxels); + for (i = 0; i < numVoxels; ++i) { + this._voxels[i] = -1; + } + + // array of atoms that stores multiple single-linked lists + // two elements for each atom: Atom ref, index of next atom (in this array + this._atoms = []; +} + +/** + * Add all atoms from a complex to voxel world + * + * @param {Complex} complex - complex + */ +VoxelWorld.prototype.addAtoms = function (complex) { + var self = this; + + var idx = this._atoms.length; + + // resize array of atoms + this._atoms.length = this._atoms.length + 2 * complex.getAtomCount(); + + complex.forEachAtom(function (atom) { + // find which voxel contains this atom + var voxelIdx = self._findVoxel(atom._position); + + // push current atom to the head of voxel's atom list + self._atoms[idx] = atom; + self._atoms[idx + 1] = self._voxels[voxelIdx]; + self._voxels[voxelIdx] = idx; + + idx += 2; + }); +}; + +/** + * Get voxel that contains specified 3D point (we use clamp at the edges) + * + * @param {Vector3} point - a point in 3D + * @returns {number} - index of voxel + */ +VoxelWorld.prototype._findVoxel = function () { + var zero = new Vector3(0, 0, 0); + var voxel = new Vector3(); + + return function (point) { + voxel.copy(point).sub(this._box.min).divide(this._cellSize).floor().clamp(zero, this._last); + return voxel.x + this._count.x * (voxel.y + this._count.y * voxel.z); + }; +}(); + +/** + * Call a function for each atom in voxel + * + * @param {number} voxel - index of voxel + * @param {function(Atom)} process - function to call + */ +VoxelWorld.prototype._forEachAtomInVoxel = function (voxel, process) { + for (var i = this._voxels[voxel]; i >= 0; i = this._atoms[i + 1]) { + process(this._atoms[i]); + } +}; + +/** + * Call a function for each voxel that is touched by given sphere. Callback also takes flag + * isInside specifying whether voxel lies inside the sphere entirely. + * + * @param {Vector3} center - center of the sphere + * @param {number} radius - sphere radius + * @param {function(number,bool)} process - function to call that takes voxel index and boolean isInside + */ +VoxelWorld.prototype._forEachVoxelWithinRadius = function () { + var xRange = new Vector2(); + var yRange = new Vector2(); + var zRange = new Vector2(); + + return function (center, radius, process) { + // switch to a faster method unless cell size is much smaller than sphere radius + if (radius / this._cellInnerR < 10) { + this._forEachVoxelWithinRadiusSimple(center, radius, process); + return; + } + + var rRangeXY = void 0, + rRangeX = void 0, + xVal = void 0, + yVal = void 0, + zVal = void 0, + isInsideX = void 0, + isInsideY = void 0, + isInsideZ = void 0; + + zRange.set(center.z - radius, center.z + radius); + zRange.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor().clampScalar(0, this._count.z - 1); + + for (var z = zRange.x; z <= zRange.y; ++z) { + zVal = [this._box.min.z + z * this._cellSize.z, this._box.min.z + (z + 1) * this._cellSize.z]; + + isInsideZ = center.z - radius <= zVal[0] && zVal[1] <= center.z + radius; + + rRangeXY = _getSphereSliceRadiusRange(center, radius, zVal[0], zVal[1]); + + yRange.set(center.y - rRangeXY[1], center.y + rRangeXY[1]); + yRange.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor().clampScalar(0, this._count.y - 1); + + for (var y = yRange.x; y <= yRange.y; ++y) { + yVal = [this._box.min.y + y * this._cellSize.y, this._box.min.y + (y + 1) * this._cellSize.y]; + + isInsideY = center.y - rRangeXY[0] <= yVal[0] && yVal[1] <= center.y + rRangeXY[0]; + + rRangeX = _getCircleSliceRadiusRange(center, rRangeXY[1], yVal[0], yVal[1]); + + xRange.set(center.x - rRangeX[1], center.x + rRangeX[1]); + xRange.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor().clampScalar(0, this._count.x - 1); + + for (var x = xRange.x; x <= xRange.y; ++x) { + xVal = [this._box.min.x + x * this._cellSize.x, this._box.min.x + (x + 1) * this._cellSize.x]; + isInsideX = center.x - rRangeX[0] <= xVal[0] && xVal[1] <= center.x + rRangeX[0]; + + process(x + this._count.x * (y + this._count.y * z), isInsideX && isInsideY && isInsideZ); + } + } + } + }; +}(); + +/** + * Call a function for each voxel that is touched by given sphere. Callback also takes flag + * isInside specifying whether voxel lies inside the sphere entirely. + * This is a version of method that doesn't try to "calculate" what voxels fall inside radius + * but instead just checks all voxels inside sphere's bounding box. This should be faster + * unless cell size is much smaller than sphere radius. + * + * @param {Vector3} center - center of the sphere + * @param {number} radius - sphere radius + * @param {function(number,bool)} process - function to call that takes voxel index and boolean isInside + */ +VoxelWorld.prototype._forEachVoxelWithinRadiusSimple = function () { + var xRange = new Vector2(); + var yRange = new Vector2(); + var zRange = new Vector2(); + var vCenter = new Vector3(); + + return function (center, radius, process) { + var distTouch2 = (radius + this._cellOuterR) * (radius + this._cellOuterR); + var distInside2 = -1.0; + if (radius > this._cellOuterR) { + distInside2 = (radius - this._cellOuterR) * (radius - this._cellOuterR); + } + + // calculate bounding box for the sphere + xRange.set(center.x - radius, center.x + radius); + xRange.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor(); + xRange.x = Math.min(Math.max(xRange.x, 0), this._count.x - 1); + xRange.y = Math.min(Math.max(xRange.y, 0), this._count.x - 1); + + yRange.set(center.y - radius, center.y + radius); + yRange.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor(); + yRange.x = Math.min(Math.max(yRange.x, 0), this._count.y - 1); + yRange.y = Math.min(Math.max(yRange.y, 0), this._count.y - 1); + + zRange.set(center.z - radius, center.z + radius); + zRange.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor(); + zRange.x = Math.min(Math.max(zRange.x, 0), this._count.z - 1); + zRange.y = Math.min(Math.max(zRange.y, 0), this._count.z - 1); + + for (var z = zRange.x; z <= zRange.y; ++z) { + var zVal = [this._box.min.z + z * this._cellSize.z, this._box.min.z + (z + 1) * this._cellSize.z]; + vCenter.z = 0.5 * (zVal[0] + zVal[1]); + + for (var y = yRange.x; y <= yRange.y; ++y) { + var yVal = [this._box.min.y + y * this._cellSize.y, this._box.min.y + (y + 1) * this._cellSize.y]; + vCenter.y = 0.5 * (yVal[0] + yVal[1]); + + for (var x = xRange.x; x <= xRange.y; ++x) { + var xVal = [this._box.min.x + x * this._cellSize.x, this._box.min.x + (x + 1) * this._cellSize.x]; + vCenter.x = 0.5 * (xVal[0] + xVal[1]); + + var d2 = center.distanceToSquared(vCenter); + if (d2 <= distTouch2) { + process(x + this._count.x * (y + this._count.y * z), d2 <= distInside2); + } + } + } + } + }; +}(); + +/** + * Call a function for each atom within given sphere + * + * @param {Vector3} center - center of the sphere + * @param {number} radius - sphere radius + * @param {function(Atom)} process - function to call + */ +VoxelWorld.prototype.forEachAtomWithinRadius = function (center, radius, process) { + var self = this; + var r2 = radius * radius; + + self._forEachVoxelWithinRadius(center, radius, function (voxel, isInside) { + if (isInside) { + self._forEachAtomInVoxel(voxel, process); + } else { + self._forEachAtomInVoxel(voxel, function (atom) { + if (center.distanceToSquared(atom._position) <= r2) { + process(atom); + } + }); + } + }); +}; + +/** + * Call a function for each atom of given complex within given distance from group of atoms defined by mask + * + * @param {Complex} complex - complex + * @param {number} mask - bit mask + * @param {number} dist - distance + * @param {function(Atom)} process - function to call + */ +VoxelWorld.prototype.forEachAtomWithinDistFromMasked = function (complex, mask, dist, process) { + this._forEachAtomWithinDistFromGroup(function (atomProc) { + complex.forEachAtom(function (atom) { + if ((atom._mask & mask) !== 0) { + atomProc(atom); + } + }); + }, dist, process); +}; + +/** + * Call a function for each atom of given complex within given distance from group of atoms defined by selector + * + * @param {Complex} complex - complex + * @param {number} selector - selector + * @param {number} dist - distance + * @param {function(Atom)} process - function to call + */ +VoxelWorld.prototype.forEachAtomWithinDistFromSelected = function (complex, selector, dist, process) { + this._forEachAtomWithinDistFromGroup(function (atomProc) { + complex.forEachAtom(function (atom) { + if (selector.includesAtom(atom)) { + atomProc(atom); + } + }); + }, dist, process); +}; + +/** + * Call a function for each atom of given complex within given distance from group of atoms + * + * @param {function} forEachAtom - enumerator of atoms in the group + * @param {number} dist - distance + * @param {function(Atom)} process - function to call + */ +VoxelWorld.prototype._forEachAtomWithinDistFromGroup = function (forEachAtom, dist, process) { + var self = this; + var r2 = dist * dist; + + var voxels = []; + var atoms = []; + var idx = 0; + + // build "within radius" atom list for each voxel + forEachAtom(function (atom) { + self._forEachVoxelWithinRadius(atom._position, dist, function (voxel, isInside) { + if (isInside) { + // this voxel is inside circle -- no check will be required + voxels[voxel] = -1; + } else if (typeof voxels[voxel] === 'undefined') { + // this voxel isn't covered yet -- start building list of atoms + atoms.push(atom); + atoms.push(-1); + voxels[voxel] = idx; + idx += 2; + } else if (voxels[voxel] !== -1) { + // this voxel has a list of atoms required for distance check -- add atom to the list + atoms.push(atom); + atoms.push(voxels[voxel]); + voxels[voxel] = idx; + idx += 2; + } + }); + }); + + var voxel; + + var processIfWithin = function processIfWithin(atom) { + if (typeof voxels[voxel] === 'undefined') { + return; + } + + idx = voxels[voxel]; + if (idx === -1) { + // this voxel is fully covered + process(atom); + return; + } + + // check distance to each atom within radius from this voxel + for (; idx >= 0; idx = atoms[idx + 1]) { + if (atom._position.distanceToSquared(atoms[idx]._position) < r2) { + process(atom); + break; + } + } + }; + + // for each marked voxel + for (voxel in voxels) { + if (voxels.hasOwnProperty(voxel)) { + self._forEachAtomInVoxel(voxel, processIfWithin); + } + } +}; + +var MINIMAL_DISTANCE = 0.5; +var MIN_HBOND_ENERGY = -9.9; +var MAX_HBOND_ENERGY = -0.5; +var COUPLING_CONSTANT = -27.888; // = -332 * 0.42 * 0.2 +var MAX_COUPLING_DISTANCE = 5.0; // how far is the closest atom of a potential partner residue from CA atom +var MAX_RESIDUES_THRESHOLD = 1000; + +var HBondInfo = function () { + function HBondInfo(complex) { + classCallCheck(this, HBondInfo); + + this._complex = complex; + this._hbonds = []; // array of bond info for each residue + if (this._complex._residues.length > MAX_RESIDUES_THRESHOLD) { + this._buildVW(); // optimized version using voxel grid + } else { + this._build(); // test all pairs of residues + } + } + + createClass(HBondInfo, [{ + key: 'isBond', + value: function isBond(from, to) { + if (this._hbonds[from]) { + var acc = this._hbonds[from].acceptor[0]; + if (acc && acc.residue === to && acc.energy < MAX_HBOND_ENERGY) { + return true; + } + acc = this._hbonds[from].acceptor[1]; + if (acc && acc.residue === to && acc.energy < MAX_HBOND_ENERGY) { + return true; + } + } + return false; + } + }, { + key: '_build', + value: function _build() { + var self = this; + + // TODO Replace quadratic algorithm with something better (use voxel grid?) + for (var i = 0; i < this._complex._residues.length - 1; ++i) { + var ri = this._complex._residues[i]; + if ((ri.getType().flags & ResidueType.Flags.PROTEIN) === 0) { + continue; + } + + // get predecessor in chain + var preri = null; + if (i > 0 && this._complex._residues[i - 1].getType().flags & ResidueType.Flags.PROTEIN && ri._sequence === this._complex._residues[i - 1]._sequence + 1) { + preri = this._complex._residues[i - 1]; + } + + for (var j = i + 1; j < this._complex._residues.length; ++j) { + var rj = this._complex._residues[j]; + if ((rj.getType().flags & ResidueType.Flags.PROTEIN) === 0) { + continue; + } + + // get predecessor in chain + var prerj = null; + if (this._complex._residues[j - 1].getType().flags & ResidueType.Flags.PROTEIN && rj._sequence === this._complex._residues[j - 1]._sequence + 1) { + prerj = this._complex._residues[j - 1]; + } + + self._calcHBondEnergy(preri, ri, rj); + if (j !== i + 1) { + self._calcHBondEnergy(prerj, rj, ri); + } + } + } + } + }, { + key: '_buildVW', + value: function _buildVW() { + var self = this; + var residues = this._complex._residues; + var ri = void 0, + preri = void 0; + + var vw = this._complex.getVoxelWorld(); + if (vw === null) { + return; + } + + var pairs = new AtomPairs(this._complex._residues.length * this._complex._residues.length / 2); + + function processAtom(atom) { + var rj = atom._residue; + + if (rj._index === ri._index) { + return; + } + + if ((rj.getType().flags & ResidueType.Flags.PROTEIN) === 0) { + return; + } + + if (!pairs.addPair(ri._index, rj._index)) { + // we've seen this pair + return; + } + + // get predecessor in chain + var prerj = rj._index > 0 ? residues[rj._index - 1] : null; + if (prerj && ((prerj.getType().flags & ResidueType.Flags.PROTEIN) === 0 || rj._sequence !== prerj._sequence + 1)) { + prerj = null; + } + + self._calcHBondEnergy(preri, ri, rj); + if (rj._index !== ri._index + 1) { + self._calcHBondEnergy(prerj, rj, ri); + } + } + + for (var i = 0; i < residues.length - 1; ++i) { + ri = residues[i]; + if ((ri.getType().flags & ResidueType.Flags.PROTEIN) === 0) { + continue; + } + + // get predecessor in chain + preri = i > 0 ? residues[i - 1] : null; + if (preri && ((preri.getType().flags & ResidueType.Flags.PROTEIN) === 0 || ri._sequence !== preri._sequence + 1)) { + preri = null; + } + + vw.forEachAtomWithinRadius(this._residueGetCAlpha(ri), MAX_COUPLING_DISTANCE, processAtom); + } + } + }, { + key: '_residueGetCAlpha', + value: function _residueGetCAlpha(res) { + for (var i = 0; i < res._atoms.length; ++i) { + var name = res._atoms[i].getName().getString(); + if (name === 'CA' || name === 'C1') { + return res._atoms[i].getPosition(); + } + } + + return null; + } + }, { + key: '_residueGetCO', + value: function _residueGetCO(res) { + var c = null, + o = null; + + res.forEachAtom(function (a) { + if (a.getName().getString() === 'C') { + c = a.getPosition(); + } else if (a.getName().getString() === 'O') { + o = a.getPosition(); + } + }); + + return [c, o]; + } + + // TODO Support hydrogen defined in complex + + }, { + key: '_residueGetNH', + value: function _residueGetNH(prev, res) { + var _residueGetCO2 = this._residueGetCO(prev), + _residueGetCO3 = slicedToArray(_residueGetCO2, 2), + c = _residueGetCO3[0], + o = _residueGetCO3[1]; + + var n = void 0; + res.forEachAtom(function (a) { + if (a.getName().getString() === 'N') { + n = a.getPosition(); + } + }); + + if (c && o && n) { + // calculate hydrogen position + var h = c.clone(); + h.sub(o); + h.multiplyScalar(1.0 / h.length()); + h.add(n); + + return [n, h]; + } + + return [null, null]; + } + }, { + key: '_calcHBondEnergy', + value: function _calcHBondEnergy(predonor, donor, acceptor) { + var result = 0; + + if (predonor === null) { + return result; + } + + if (donor.getType().getName() !== 'PRO') { + var _residueGetNH2 = this._residueGetNH(predonor, donor), + _residueGetNH3 = slicedToArray(_residueGetNH2, 2), + n = _residueGetNH3[0], + h = _residueGetNH3[1]; + + var _residueGetCO4 = this._residueGetCO(acceptor), + _residueGetCO5 = slicedToArray(_residueGetCO4, 2), + c = _residueGetCO5[0], + o = _residueGetCO5[1]; + + if (n === null || h === null || c === null || o === null) { + return result; + } + + var distanceHO = h.distanceTo(o); + var distanceHC = h.distanceTo(c); + var distanceNC = n.distanceTo(c); + var distanceNO = n.distanceTo(o); + + if (distanceHO < MINIMAL_DISTANCE || distanceHC < MINIMAL_DISTANCE || distanceNC < MINIMAL_DISTANCE || distanceNO < MINIMAL_DISTANCE) { + result = MIN_HBOND_ENERGY; + } else { + result = COUPLING_CONSTANT / distanceHO - COUPLING_CONSTANT / distanceHC + COUPLING_CONSTANT / distanceNC - COUPLING_CONSTANT / distanceNO; + } + + // DSSP compatibility mode: + result = Math.round(result * 1000) / 1000; + + if (result < MIN_HBOND_ENERGY) { + result = MIN_HBOND_ENERGY; + } + } + + // update donor + if (typeof this._hbonds[donor._index] === 'undefined') { + this._hbonds[donor._index] = { + donor: [], + acceptor: [] + }; + } + var donorInfo = this._hbonds[donor._index]; + + if (donorInfo.acceptor.length < 2) { + donorInfo.acceptor.push({ + residue: acceptor._index, + energy: result + }); + } + + if (donorInfo.acceptor.length > 1) { + if (result < donorInfo.acceptor[0].energy) { + donorInfo.acceptor[1].residue = donorInfo.acceptor[0].residue; + donorInfo.acceptor[1].energy = donorInfo.acceptor[0].energy; + donorInfo.acceptor[0].residue = acceptor._index; + donorInfo.acceptor[0].energy = result; + } else if (result < donorInfo.acceptor[1].energy) { + donorInfo.acceptor[1].residue = acceptor._index; + donorInfo.acceptor[1].energy = result; + } + } + + // update acceptor + if (typeof this._hbonds[acceptor._index] === 'undefined') { + this._hbonds[acceptor._index] = { + donor: [], + acceptor: [] + }; + } + var accInfo = this._hbonds[acceptor._index]; + + if (accInfo.donor.length < 2) { + accInfo.donor.push({ + residue: donor._index, + energy: result + }); + } + + if (accInfo.donor.length > 1) { + if (result < accInfo.donor[0].energy) { + accInfo.donor[1].residue = accInfo.donor[0].residue; + accInfo.donor[1].energy = accInfo.donor[0].energy; + accInfo.donor[0].residue = donor._index; + accInfo.donor[0].energy = result; + } else if (result < accInfo.donor[1].energy) { + accInfo.donor[1].residue = donor._index; + accInfo.donor[1].energy = result; + } + } + + return result; + } + }]); + return HBondInfo; +}(); + +var BridgeType = Object.freeze({ + NO_BRIDGE: 0, + PARALLEL: 1, + ANTI_PARALLEL: 2 +}); + +var HelixFlag = Object.freeze({ + START: 1, + MIDDLE: 2, + END: 3, + START_AND_END: 4 +}); + +var StructureType = Object.freeze({ + LOOP: ' ', + ALPHA_HELIX: 'H', + BETA_BRIDGE: 'B', + STRAND: 'E', + HELIX_3_10: 'G', + PI_HELIX: 'I', + TURN: 'T', + BEND: 'S' +}); + +var SecondaryStructureMap = function () { + function SecondaryStructureMap(complex) { + classCallCheck(this, SecondaryStructureMap); + + this._complex = complex; + this._build(); + } + + createClass(SecondaryStructureMap, [{ + key: '_build', + value: function _build() { + var self = this; + this._hbonds = new HBondInfo(this._complex); + this._ss = []; // DSSP map by residue + + // auxilliary data + this._sheet = []; + this._betaPartners = []; + this._bend = []; + for (var i = 0; i < this._complex.getResidues().length; ++i) { + this._betaPartners[i] = []; + } + this._helixFlags = []; + this._helixFlags[3] = []; + this._helixFlags[4] = []; + this._helixFlags[5] = []; + + // calculate peptide chain lengths + this._chainLengths = []; + for (var _i = 0; _i < this._complex._chains.length; ++_i) { + var chain = this._complex._chains[_i].getResidues(); + var len = 0; + for (; len < chain.length; ++len) { + if ((chain[len].getType().flags & ResidueType.Flags.PROTEIN) === 0) { + break; + } + } + this._chainLengths[_i] = len; + } + + this._buildBetaSheets(); + + for (var _i2 = 0; _i2 < this._complex._chains.length; ++_i2) { + self._buildAlphaHelices(this._complex._chains[_i2].getResidues(), this._chainLengths[_i2], false); + } + } + }, { + key: '_buildAlphaHelices', + value: function _buildAlphaHelices(inResidues, chainLength, inPreferPiHelices) { + // Helix and Turn + for (var stride = 3; stride <= 5; ++stride) { + if (inResidues.length < stride) { + break; + } + + for (var i = 0; i + stride < chainLength; ++i) { + if (this._hbonds.isBond(inResidues[i + stride]._index, inResidues[i]._index) + /*&& NoChainBreak(res[i], res[i + stride])*/) { + this._helixFlags[stride][inResidues[i + stride]._index] = HelixFlag.END; + for (var j = i + 1; j < i + stride; ++j) { + if (typeof this._helixFlags[stride][inResidues[j]._index] === 'undefined') { + this._helixFlags[stride][inResidues[j]._index] = HelixFlag.MIDDLE; + } + } + + if (this._helixFlags[stride][inResidues[i]._index] === HelixFlag.END) { + this._helixFlags[stride][inResidues[i]._index] = HelixFlag.START_AND_END; + } else { + this._helixFlags[stride][inResidues[i]._index] = HelixFlag.START; + } + } + } + } + + for (var _i3 = 2; _i3 < chainLength - 2; ++_i3) { + var kappa = this._kappa(inResidues[_i3 - 2], inResidues[_i3], inResidues[_i3 + 2]); + this._bend[inResidues[_i3]._index] = kappa !== 360 && kappa > 70; + } + + for (var _i4 = 1; _i4 + 4 < chainLength; ++_i4) { + if (this._isHelixStart(inResidues[_i4]._index, 4) && this._isHelixStart(inResidues[_i4 - 1]._index, 4)) { + for (var _j = _i4; _j <= _i4 + 3; ++_j) { + this._ss[inResidues[_j]._index] = StructureType.ALPHA_HELIX; + } + } + } + + for (var _i5 = 1; _i5 + 3 < chainLength; ++_i5) { + if (this._isHelixStart(inResidues[_i5]._index, 3) && this._isHelixStart(inResidues[_i5 - 1]._index, 3)) { + var empty = true; + for (var _j2 = _i5; empty && _j2 <= _i5 + 2; ++_j2) { + empty = typeof this._ss[inResidues[_j2]._index] === 'undefined' || this._ss[inResidues[_j2]._index] === StructureType.HELIX_3_10; + } + if (empty) { + for (var _j3 = _i5; _j3 <= _i5 + 2; ++_j3) { + this._ss[inResidues[_j3]._index] = StructureType.HELIX_3_10; + } + } + } + } + + for (var _i6 = 1; _i6 + 5 < chainLength; ++_i6) { + if (this._isHelixStart(inResidues[_i6]._index, 5) && this._isHelixStart(inResidues[_i6 - 1]._index, 5)) { + var _empty = true; + for (var _j4 = _i6; _empty && _j4 <= _i6 + 4; ++_j4) { + _empty = typeof this._ss[inResidues[_j4]._index] === 'undefined' || this._ss[inResidues[_j4]._index] === StructureType.PI_HELIX || inPreferPiHelices && this._ss[inResidues[_j4]._index] === StructureType.ALPHA_HELIX; + } + if (_empty) { + for (var _j5 = _i6; _j5 <= _i6 + 4; ++_j5) { + this._ss[inResidues[_j5]._index] = StructureType.PI_HELIX; + } + } + } + } + + for (var _i7 = 1; _i7 + 1 < chainLength; ++_i7) { + if (typeof this._ss[inResidues[_i7]._index] === 'undefined') { + var isTurn = false; + for (var _stride = 3; _stride <= 5 && !isTurn; ++_stride) { + for (var k = 1; k < _stride && !isTurn; ++k) { + isTurn = _i7 >= k && this._isHelixStart(inResidues[_i7 - k]._index, _stride); + } + } + + if (isTurn) { + this._ss[inResidues[_i7]._index] = StructureType.TURN; + } else if (this._bend[inResidues[_i7]._index]) { + this._ss[inResidues[_i7]._index] = StructureType.BEND; + } + } + } + } + }, { + key: '_residueGetCAlpha', + value: function _residueGetCAlpha(res) { + for (var i = 0; i < res._atoms.length; ++i) { + var name = res._atoms[i].getName().getString(); + if (name === 'CA' || name === 'C1') { + return res._atoms[i].getPosition(); + } + } + + return null; + } + }, { + key: '_cosinusAngle', + value: function _cosinusAngle(p1, p2, p3, p4) { + var v12 = p1.clone();v12.sub(p2); + var v34 = p3.clone();v34.sub(p4); + + var result = 0; + + var x = v12.dot(v12) * v34.dot(v34); + if (x > 0) { + result = v12.dot(v34) / Math.sqrt(x); + } + + return result; + } + }, { + key: '_kappa', + value: function _kappa(prevPrev, res, nextNext) { + var curCA = this._residueGetCAlpha(res); + var ppCA = this._residueGetCAlpha(prevPrev); + var nnCA = this._residueGetCAlpha(nextNext); + if (curCA === null || ppCA === null || nnCA === null) { + return 180; + } + + var ckap = this._cosinusAngle(curCA, ppCA, nnCA, curCA); + var skap = Math.sqrt(1 - ckap * ckap); + return Math.atan2(skap, ckap) * 180 / Math.PI; + } + }, { + key: '_isHelixStart', + value: function _isHelixStart(res, stride) { + return this._helixFlags[stride][res] === HelixFlag.START || this._helixFlags[stride][res] === HelixFlag.START_AND_END; + } + }, { + key: '_buildBetaSheets', + value: function _buildBetaSheets() { + // find bridges + // check each chain against each other chain, and against itself + var bridges = []; + for (var a = 0; a < this._complex._chains.length; ++a) { + var lenA = this._chainLengths[a]; + if (lenA <= 4) { + continue; + } + + var chainA = this._complex._chains[a].getResidues(); + + for (var b = a; b < this._complex._chains.length; ++b) { + var lenB = this._chainLengths[b]; + if (lenB <= 4) { + continue; + } + + var chainB = this._complex._chains[b].getResidues(); + + for (var i = 1; i + 1 < lenA; ++i) { + var ri = chainA[i]; + + var j = 1; + if (b === a) { + j = i + 3; // check for self-bridges forward down the chain + } + + for (; j + 1 < lenB; ++j) { + var rj = chainB[j]; + + var type = this._testBridge(chainA, i, chainB, j); + if (type === BridgeType.NO_BRIDGE) { + continue; + } + + // there is a bridge, try to attach it to previously found sequence + var found = false; + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = bridges[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var bridge = _step.value; + + if (type !== bridge.type || ri._index !== bridge.i[bridge.i.length - 1] + 1) { + continue; + } + + if (type === BridgeType.PARALLEL && bridge.j[bridge.j.length - 1] + 1 === rj._index) { + bridge.i.push(ri._index); + bridge.j.push(rj._index); + found = true; + break; + } + + if (type === BridgeType.ANTI_PARALLEL && bridge.j[0] - 1 === rj._index) { + bridge.i.push(ri._index); + bridge.j.unshift(rj._index); + found = true; + break; + } + } + + // this bridge cannot be attached anywhere, start a new sequence + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + if (!found) { + bridges.push({ + type: type, + i: [ri._index], + chainI: ri.getChain()._index, + j: [rj._index], + chainJ: rj.getChain()._index + }); + } + } + } + } + } + + // extend ladders + bridges.sort(function (a, b) { + if (a.chainI < b.chainI || a.chainI === b.chainI && a.i[0] < b.i[0]) { + return -1; + } + return 1; + }); + + for (var _i8 = 0; _i8 < bridges.length; ++_i8) { + for (var _j6 = _i8 + 1; _j6 < bridges.length; ++_j6) { + var ibi = bridges[_i8].i[0]; + var iei = bridges[_i8].i[bridges[_i8].i.length - 1]; + var jbi = bridges[_i8].j[0]; + var jei = bridges[_i8].j[bridges[_i8].j.length - 1]; + var ibj = bridges[_j6].i[0]; + var iej = bridges[_j6].i[bridges[_j6].i.length - 1]; + var jbj = bridges[_j6].j[0]; + var jej = bridges[_j6].j[bridges[_j6].j.length - 1]; + + if (bridges[_i8].type !== bridges[_j6].type || this._hasChainBreak(Math.min(ibi, ibj), Math.max(iei, iej)) || this._hasChainBreak(Math.min(jbi, jbj), Math.max(jei, jej)) || ibj - iei >= 6 || iei >= ibj && ibi <= iej) { + continue; + } + + var bulge = false; + if (bridges[_i8].type === BridgeType.PARALLEL) { + bulge = jbj - jei < 6 && ibj - iei < 3 || jbj - jei < 3; + } else { + bulge = jbi - jej < 6 && ibj - iei < 3 || jbi - jej < 3; + } + + if (bulge) { + bridges[_i8].i = bridges[_i8].i.concat(bridges[_j6].i); + if (bridges[_i8].type === BridgeType.PARALLEL) { + bridges[_i8].j = bridges[_i8].j.concat(bridges[_j6].j); + } else { + bridges[_i8].j = bridges[_j6].j.concat(bridges[_i8].j); + } + bridges.splice(_j6--, 1); + } + } + } + + // Sheet + var ladderset = new Set(); + for (var _i9 = 0; _i9 < bridges.length; ++_i9) { + ladderset.add(bridges[_i9]); + } + + var sheet = 1, + ladder = 0; + while (ladderset.size > 0) { + var _bridge = ladderset.values().next().value; + ladderset.delete(_bridge); + + var sheetset = new Set(); + sheetset.add(_bridge); + + var toMove = void 0; + do { + toMove = new Set(); + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = sheetset.values()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var _a = _step2.value; + var _iteratorNormalCompletion4 = true; + var _didIteratorError4 = false; + var _iteratorError4 = undefined; + + try { + for (var _iterator4 = ladderset.values()[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { + var _b = _step4.value; + + if (this._areBridgesLinked(_a, _b)) { + toMove.add(_b); + } + } + } catch (err) { + _didIteratorError4 = true; + _iteratorError4 = err; + } finally { + try { + if (!_iteratorNormalCompletion4 && _iterator4.return) { + _iterator4.return(); + } + } finally { + if (_didIteratorError4) { + throw _iteratorError4; + } + } + } + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + + var _iteratorNormalCompletion3 = true; + var _didIteratorError3 = false; + var _iteratorError3 = undefined; + + try { + for (var _iterator3 = toMove.values()[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { + _bridge = _step3.value; + + sheetset.add(_bridge); + ladderset.delete(_bridge); + } + } catch (err) { + _didIteratorError3 = true; + _iteratorError3 = err; + } finally { + try { + if (!_iteratorNormalCompletion3 && _iterator3.return) { + _iterator3.return(); + } + } finally { + if (_didIteratorError3) { + throw _iteratorError3; + } + } + } + } while (toMove.size > 0); + + var _iteratorNormalCompletion5 = true; + var _didIteratorError5 = false; + var _iteratorError5 = undefined; + + try { + for (var _iterator5 = sheetset.values()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { + _bridge = _step5.value; + + _bridge.ladder = ladder; + _bridge.sheet = sheet; + _bridge.link = sheetset; + ++ladder; + } + } catch (err) { + _didIteratorError5 = true; + _iteratorError5 = err; + } finally { + try { + if (!_iteratorNormalCompletion5 && _iterator5.return) { + _iterator5.return(); + } + } finally { + if (_didIteratorError5) { + throw _iteratorError5; + } + } + } + + ++sheet; + } + + for (var _i10 = 0; _i10 < bridges.length; ++_i10) { + var _bridge2 = bridges[_i10]; + + // find out if any of the i and j set members already have + // a bridge assigned, if so, we're assigning bridge 2 + + var betai = 0, + betaj = 0; + + for (var l = 0; l < _bridge2.i.length; ++l) { + if (this._betaPartners[_bridge2.i[l]][0]) { + betai = 1; + break; + } + } + + for (var _l = 0; _l < _bridge2.j.length; ++_l) { + if (this._betaPartners[_bridge2.j[_l]][0]) { + betaj = 1; + break; + } + } + + var ss = StructureType.BETA_BRIDGE; + if (_bridge2.i.length > 1) { + ss = StructureType.STRAND; + } + + if (_bridge2.type === BridgeType.PARALLEL) { + var _j7 = 0; + for (var k = 0; k < _bridge2.i.length; ++k) { + this._betaPartners[_bridge2.i[k]][betai] = { + residue: _bridge2.j[_j7++], + ladder: _bridge2.ladder, + parallel: true + }; + } + + _j7 = 0; + for (var _k = 0; _k < _bridge2.j.length; ++_k) { + this._betaPartners[_bridge2.j[_k]][betaj] = { + residue: _bridge2.i[_j7++], + ladder: _bridge2.ladder, + parallel: true + }; + } + } else { + var _j8 = _bridge2.j.length - 1; + for (var _k2 = 0; _k2 < _bridge2.i.length; ++_k2) { + this._betaPartners[_bridge2.i[_k2]][betai] = { + residue: _bridge2.j[_j8--], + ladder: _bridge2.ladder, + parallel: false + }; + } + + _j8 = _bridge2.i.length - 1; + for (var _k3 = 0; _k3 < _bridge2.j.length; ++_k3) { + this._betaPartners[_bridge2.j[_k3]][betaj] = { + residue: _bridge2.i[_j8--], + ladder: _bridge2.ladder, + parallel: false + }; + } + } + + for (var _k4 = _bridge2.i[0]; _k4 <= _bridge2.i[_bridge2.i.length - 1]; ++_k4) { + if (this._ss[_k4] !== StructureType.STRAND) { + this._ss[_k4] = ss; + this._sheet[_k4] = _bridge2.sheet; + } + } + + for (var _k5 = _bridge2.j[0]; _k5 <= _bridge2.j[_bridge2.j.length - 1]; ++_k5) { + if (this._ss[_k5] !== StructureType.STRAND) { + this._ss[_k5] = ss; + this._sheet[_k5] = _bridge2.sheet; + } + } + } + } + }, { + key: '_testBridge', + value: function _testBridge(chainA, from, chainB, to) { + var result = BridgeType.NO_BRIDGE; + + var a = chainA[from - 1]._index; + var b = chainA[from]._index; + var c = chainA[from + 1]._index; + var d = chainB[to - 1]._index; + var e = chainB[to]._index; + var f = chainB[to + 1]._index; + + var isBond = this._hbonds.isBond.bind(this._hbonds); + if (isBond(c, e) && isBond(e, a) || isBond(f, b) && isBond(b, d)) { + result = BridgeType.PARALLEL; + } else if (isBond(c, d) && isBond(f, a) || isBond(e, b) && isBond(b, e)) { + result = BridgeType.ANTI_PARALLEL; + } + return result; + } + + // return true if any of the residues in bridge a is identical to any of the residues in bridge b + // TODO Optimize + + }, { + key: '_areBridgesLinked', + value: function _areBridgesLinked(a, b) { + var ai = new Set(a.i); + var aj = new Set(a.j); + + var _iteratorNormalCompletion6 = true; + var _didIteratorError6 = false; + var _iteratorError6 = undefined; + + try { + for (var _iterator6 = b.i[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) { + var i = _step6.value; + + if (ai.has(i) || aj.has(i)) { + return true; + } + } + } catch (err) { + _didIteratorError6 = true; + _iteratorError6 = err; + } finally { + try { + if (!_iteratorNormalCompletion6 && _iterator6.return) { + _iterator6.return(); + } + } finally { + if (_didIteratorError6) { + throw _iteratorError6; + } + } + } + + var _iteratorNormalCompletion7 = true; + var _didIteratorError7 = false; + var _iteratorError7 = undefined; + + try { + for (var _iterator7 = b.j[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) { + var _i11 = _step7.value; + + if (ai.has(_i11) || aj.has(_i11)) { + return true; + } + } + } catch (err) { + _didIteratorError7 = true; + _iteratorError7 = err; + } finally { + try { + if (!_iteratorNormalCompletion7 && _iterator7.return) { + _iterator7.return(); + } + } finally { + if (_didIteratorError7) { + throw _iteratorError7; + } + } + } + + return false; + } + }, { + key: '_hasChainBreak', + value: function _hasChainBreak(from, to) { + for (var i = from + 1; i <= to; ++i) { + if (this._complex._residues[i]._sequence !== this._complex._residues[i - 1]._sequence + 1) { + return true; + } + } + return false; + } + }]); + return SecondaryStructureMap; +}(); + +SecondaryStructureMap.StructureType = StructureType; + +var VOXEL_SIZE = 5.0; + /** * The entire complex of the molecules under study. * @@ -69197,6 +70345,20 @@ Complex.prototype.getAltLocNames = function () { return this._altlocNames; }; +Complex.prototype.getVoxelWorld = function () { + if (!this.hasOwnProperty('_voxelWorld')) { + try { + this._voxelWorld = new VoxelWorld(this.getDefaultBoundaries().boundingBox, new Vector3(VOXEL_SIZE, VOXEL_SIZE, VOXEL_SIZE)); + this._voxelWorld.addAtoms(this); + } catch (e) { + logger.warn('Unable to create voxel world'); + this._voxelWorld = null; + } + } + + return this._voxelWorld; +}; + // this function joins multiple complexes into one (this) // atom, bond, ... objects are reused -- so input complexes are no longer valid Complex.prototype.joinComplexes = function (complexes) { @@ -69290,6 +70452,68 @@ Complex.prototype.joinComplexes = function (complexes) { this._computeBounds(); }; +/** + * Replace secondary structure with calculated one. + * + * DSSP algorithm implementation is used. + * + * Kabsch W, Sander C. 1983. Dictionary of protein secondary structure: pattern recognition of hydrogen-bonded and + * geometrical features. Biopolymers. 22(12):2577-2637. doi:10.1002/bip.360221211. + */ +Complex.prototype.dssp = function () { + var _helixTypes; + + var ssMap = new SecondaryStructureMap(this); + var StructureType = SecondaryStructureMap.StructureType; + var helixTypes = (_helixTypes = {}, defineProperty(_helixTypes, StructureType.ALPHA_HELIX, 1), defineProperty(_helixTypes, StructureType.HELIX_3_10, 3), defineProperty(_helixTypes, StructureType.PI_HELIX, 5), _helixTypes); + + var helices = []; + var sheets = []; + var curHelix = null; + var curStrand = null; + for (var i = 0, n = this._residues.length; i < n; ++i) { + var ssCode = ssMap._ss[i]; + var residue = this._residues[i]; + residue._secondary = null; + + var helixType = helixTypes[ssCode]; + if (helixType) { + if (curHelix === null) { + curHelix = new Helix(helices.length + 1, '', residue, residue, helixType, '', 0); + helices.push(curHelix); + } + residue._secondary = curHelix; + curHelix._residues.push(residue); + curHelix._end = residue; + curHelix._length++; + } else if (curHelix) { + curHelix = null; + } + + if (ssCode === StructureType.STRAND) { + if (curStrand === null) { + var curSheet = sheets[ssMap._sheet[i]]; + if (curSheet === undefined) { + curSheet = sheets[ssMap._sheet[i]] = new Sheet('', 0); + } + curStrand = new Strand(curSheet, residue, residue, 0, null, null); + curSheet.addStrand(curStrand); + curSheet._width++; + } + residue._secondary = curStrand; + curStrand._residues.push(residue); + curStrand._end = residue; + } else if (curStrand) { + curStrand = null; + } + } + + this._helices = helices; + this._sheets = sheets.filter(function (_sheet) { + return true; + }); // squeeze sheets array +}; + ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// @@ -69601,323 +70825,6 @@ Volume.prototype.getStrideZ = function () { return this._planeElements; }; -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -/** - * Calculate min & max radius of a sphere slice between zMin & zMax - * - * @param {Vector3} center - center of the sphere - * @param {number} radius - sphere radius - * @param {number} zMin - lower bound of the slice - * @param {number} zMax - upper bound of the slice - */ -function _getSphereSliceRadiusRange(center, radius, zMin, zMax) { - var dzMin = zMin - center.z; - var dzMax = zMax - center.z; - var rzMin = Math.sqrt(Math.max(radius * radius - dzMin * dzMin, 0.0)); - var rzMax = Math.sqrt(Math.max(radius * radius - dzMax * dzMax, 0.0)); - - var rMin = Math.min(rzMin, rzMax); - var rMax; - - if (zMin <= center.z && zMax >= center.z) { - // sphere's main diameter is inside slice - rMax = radius; - } else { - rMax = Math.max(rzMin, rzMax); - } - - return [rMin, rMax]; -} - -/** - * Calculate min & max radius of a circle slice between yMin & yMax. - * - * To maintain analogy with _getSphereSliceRadiusRange we call radius what in fact is - * half-width (along X axis) of the slice, i.e. 1D-sphere radius. - * - * @param {Vector3} center - center of the circle (z can be ignored) - * @param {number} radius - circle radius - * @param {number} yMin - lower bound of the slice - * @param {number} yMax - upper bound of the slice - * @returns {Array} - array of two numbers (min & max radius, or half-width) - */ -function _getCircleSliceRadiusRange(center, radius, yMin, yMax) { - var dyMin = yMin - center.y; - var dyMax = yMax - center.y; - var ryMin = Math.sqrt(Math.max(radius * radius - dyMin * dyMin, 0.0)); - var ryMax = Math.sqrt(Math.max(radius * radius - dyMax * dyMax, 0.0)); - - var rMin = Math.min(ryMin, ryMax); - var rMax; - - if (yMin <= center.y && yMax >= center.y) { - // slice's main diameter is inside slice - rMax = radius; - } else { - rMax = Math.max(ryMin, ryMax); - } - - return [rMin, rMax]; -} - -/** - * VoxelWorld constructor - * - * @param {Box3} box - bounding box of the volume to be partitioned - * @param {Vector3} vCellSizeHint - target voxel size (actual voxel size may differ from this) - */ -function VoxelWorld(box, vCellSizeHint) { - var i; - - this._box = box.clone(); - this._count = box.size().divide(vCellSizeHint).floor(); - this._last = this._count.clone().subScalar(1); - this._cellSize = box.size().divide(this._count); - - // array of voxels, each element contains index of first atom in voxel - var numVoxels = this._count.x * this._count.y * this._count.z; - this._voxels = utils.allocateTyped(Int32Array, numVoxels); - for (i = 0; i < numVoxels; ++i) { - this._voxels[i] = -1; - } - - // array of atoms that stores multiple single-linked lists - // two elements for each atom: Atom ref, index of next atom (in this array - this._atoms = []; -} - -/** - * Add all atoms from a complex to voxel world - * - * @param {Complex} complex - complex - */ -VoxelWorld.prototype.addAtoms = function (complex) { - var self = this; - - var idx = this._atoms.length; - - // resize array of atoms - this._atoms.length = this._atoms.length + 2 * complex.getAtomCount(); - - complex.forEachAtom(function (atom) { - // find which voxel contains this atom - var voxelIdx = self._findVoxel(atom._position); - - // push current atom to the head of voxel's atom list - self._atoms[idx] = atom; - self._atoms[idx + 1] = self._voxels[voxelIdx]; - self._voxels[voxelIdx] = idx; - - idx += 2; - }); -}; - -/** - * Get voxel that contains specified 3D point (we use clamp at the edges) - * - * @param {Vector3} point - a point in 3D - * @returns {number} - index of voxel - */ -VoxelWorld.prototype._findVoxel = function () { - var zero = new Vector3(0, 0, 0); - var voxel = new Vector3(); - - return function (point) { - voxel.copy(point).sub(this._box.min).divide(this._cellSize).floor().clamp(zero, this._last); - return voxel.x + this._count.x * (voxel.y + this._count.y * voxel.z); - }; -}(); - -/** - * Call a function for each atom in voxel - * - * @param {number} voxel - index of voxel - * @param {function(Atom)} process - function to call - */ -VoxelWorld.prototype._forEachAtomInVoxel = function (voxel, process) { - for (var i = this._voxels[voxel]; i >= 0; i = this._atoms[i + 1]) { - process(this._atoms[i]); - } -}; - -/** - * Call a function for each voxel that is touched by given sphere. Callback also takes flag - * isInside specifying whether voxel lies inside the sphere entirely. - * - * @param {Vector3} center - center of the sphere - * @param {number} radius - sphere radius - * @param {function(number,bool)} process - function to call that takes voxel index and boolean isInside - */ -VoxelWorld.prototype._forEachVoxelWithinRadius = function (center, radius, process) { - - var rRangeXY, rRangeX, xVal, yVal, zVal, isInsideX, isInsideY, isInsideZ; - var xRange = new Vector2(); - var yRange = new Vector2(); - var zRange = new Vector2(); - - zRange.set(center.z - radius, center.z + radius); - zRange.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor().clampScalar(0, this._count.z - 1); - - for (var z = zRange.x; z <= zRange.y; ++z) { - zVal = [this._box.min.z + z * this._cellSize.z, this._box.min.z + (z + 1) * this._cellSize.z]; - - isInsideZ = center.z - radius <= zVal[0] && zVal[1] <= center.z + radius; - - rRangeXY = _getSphereSliceRadiusRange(center, radius, zVal[0], zVal[1]); - - yRange.set(center.y - rRangeXY[1], center.y + rRangeXY[1]); - yRange.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor().clampScalar(0, this._count.y - 1); - - for (var y = yRange.x; y <= yRange.y; ++y) { - yVal = [this._box.min.y + y * this._cellSize.y, this._box.min.y + (y + 1) * this._cellSize.y]; - - isInsideY = center.y - rRangeXY[0] <= yVal[0] && yVal[1] <= center.y + rRangeXY[0]; - - rRangeX = _getCircleSliceRadiusRange(center, rRangeXY[1], yVal[0], yVal[1]); - - xRange.set(center.x - rRangeX[1], center.x + rRangeX[1]); - xRange.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor().clampScalar(0, this._count.x - 1); - - for (var x = xRange.x; x <= xRange.y; ++x) { - xVal = [this._box.min.x + x * this._cellSize.x, this._box.min.x + (x + 1) * this._cellSize.x]; - isInsideX = center.x - rRangeX[0] <= xVal[0] && xVal[1] <= center.x + rRangeX[0]; - - process(x + this._count.x * (y + this._count.y * z), isInsideX && isInsideY && isInsideZ); - } - } - } -}; - -/** - * Call a function for each atom within given sphere - * - * @param {Vector3} center - center of the sphere - * @param {number} radius - sphere radius - * @param {function(Atom)} process - function to call - */ -VoxelWorld.prototype.forEachAtomWithinRadius = function (center, radius, process) { - var self = this; - var r2 = radius * radius; - - self._forEachVoxelWithinRadius(center, radius, function (voxel, isInside) { - if (isInside) { - self._forEachAtomInVoxel(voxel, process); - } else { - self._forEachAtomInVoxel(voxel, function (atom) { - if (center.distanceToSquared(atom._position) < r2) { - process(atom); - } - }); - } - }); -}; - -/** - * Call a function for each atom of given complex within given distance from group of atoms defined by mask - * - * @param {Complex} complex - complex - * @param {number} mask - bit mask - * @param {number} dist - distance - * @param {function(Atom)} process - function to call - */ -VoxelWorld.prototype.forEachAtomWithinDistFromMasked = function (complex, mask, dist, process) { - this._forEachAtomWithinDistFromGroup(function (atomProc) { - complex.forEachAtom(function (atom) { - if ((atom._mask & mask) !== 0) { - atomProc(atom); - } - }); - }, dist, process); -}; - -/** - * Call a function for each atom of given complex within given distance from group of atoms defined by selector - * - * @param {Complex} complex - complex - * @param {number} selector - selector - * @param {number} dist - distance - * @param {function(Atom)} process - function to call - */ -VoxelWorld.prototype.forEachAtomWithinDistFromSelected = function (complex, selector, dist, process) { - this._forEachAtomWithinDistFromGroup(function (atomProc) { - complex.forEachAtom(function (atom) { - if (selector.includesAtom(atom)) { - atomProc(atom); - } - }); - }, dist, process); -}; - -/** - * Call a function for each atom of given complex within given distance from group of atoms - * - * @param {function} forEachAtom - enumerator of atoms in the group - * @param {number} dist - distance - * @param {function(Atom)} process - function to call - */ -VoxelWorld.prototype._forEachAtomWithinDistFromGroup = function (forEachAtom, dist, process) { - var self = this; - var r2 = dist * dist; - - var voxels = []; - var atoms = []; - var idx = 0; - - // build "within radius" atom list for each voxel - forEachAtom(function (atom) { - self._forEachVoxelWithinRadius(atom._position, dist, function (voxel, isInside) { - if (isInside) { - // this voxel is inside circle -- no check will be required - voxels[voxel] = -1; - } else if (typeof voxels[voxel] === 'undefined') { - // this voxel isn't covered yet -- start building list of atoms - atoms.push(atom); - atoms.push(-1); - voxels[voxel] = idx; - idx += 2; - } else if (voxels[voxel] !== -1) { - // this voxel has a list of atoms required for distance check -- add atom to the list - atoms.push(atom); - atoms.push(voxels[voxel]); - voxels[voxel] = idx; - idx += 2; - } - }); - }); - - var voxel; - - var processIfWithin = function processIfWithin(atom) { - if (typeof voxels[voxel] === 'undefined') { - return; - } - - idx = voxels[voxel]; - if (idx === -1) { - // this voxel is fully covered - process(atom); - return; - } - - // check distance to each atom within radius from this voxel - for (; idx >= 0; idx = atoms[idx + 1]) { - if (atom._position.distanceToSquared(atoms[idx]._position) < r2) { - process(atom); - break; - } - } - }; - - // for each marked voxel - for (voxel in voxels) { - if (voxels.hasOwnProperty(voxel)) { - self._forEachAtomInVoxel(voxel, processIfWithin); - } - } -}; - ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// @@ -78614,8 +79521,7 @@ TextMode.prototype.getTemplateOptions = function () { }; TextMode.prototype.getLabelOpts = function () { - - return _.merge(this.opts, { + return lodash.merge(this.opts, { labels: this.settings.now.labels, colors: true, adjustColor: true, @@ -80271,8 +81177,6 @@ var ComplexVisualEdit = { FragmentEditor: ComplexFragmentEditor }; -var VOXEL_SIZE = 5.0; - var selectors$3 = chem.selectors; function ComplexVisual(name, dataSource) { @@ -81111,16 +82015,9 @@ ComplexVisual.prototype.setUberOptions = function (values) { * @returns {Selector} selector describing result group of atoms */ ComplexVisual.prototype.within = function (selector, radius) { - // build voxel world - if (!this._voxelWorld) { - try { - this._voxelWorld = new chem.VoxelWorld(this._complex.getDefaultBoundaries().boundingBox, new Vector3(VOXEL_SIZE, VOXEL_SIZE, VOXEL_SIZE)); - this._voxelWorld.addAtoms(this._complex); - } catch (e) { - logger.warn('Unable to create voxel world'); - this._voxelWorld = null; - return selectors$3.none(); - } + var vw = this._complex.getVoxelWorld(); + if (vw === null) { + return false; } // mark atoms of the group as selected @@ -81128,9 +82025,11 @@ ComplexVisual.prototype.within = function (selector, radius) { this._complex.markAtoms(selector, selectionMask); // mark all atoms within distance as selected - this._voxelWorld.forEachAtomWithinDistFromMasked(this._complex, selectionMask, Number(radius), function (atom) { - atom._mask |= selectionMask; - }); + if (vw) { + vw.forEachAtomWithinDistFromMasked(this._complex, selectionMask, Number(radius), function (atom) { + atom._mask |= selectionMask; + }); + } // update selection count this._selectionCount = this._complex.countAtomsByMask(selectionMask); @@ -87658,7 +88557,7 @@ var WEBVR = function () { return WEBVR; }(); -/* global "0.7.11":false */ +/* global "0.7.12":false */ ////////////////////////////////////////////////////////////////////////////// @@ -87837,7 +88736,7 @@ Miew.prototype.init = function () { this._initGfx(); this._initListeners(); - this._spinner = new spin({ + this._spinner = new Spinner({ lines: 13, length: 28, width: 14, @@ -90916,6 +91815,31 @@ Miew.prototype.projected = function (fullAtomName, complexName) { }; }; +/** + * Replace secondary structure with calculated one. + * + * DSSP algorithm implementation is used. + * + * Kabsch W, Sander C. 1983. Dictionary of protein secondary structure: pattern recognition of hydrogen-bonded and + * geometrical features. Biopolymers. 22(12):2577-2637. doi:10.1002/bip.360221211. + * + * @param {string=} complexName - complex name + */ +Miew.prototype.dssp = function (complexName) { + var visual = this._getComplexVisual(complexName); + if (!visual) { + return; + } + visual.getComplex().dssp(); + + // rebuild dependent representations (cartoon or ss-colored) + visual._reprList.forEach(function (rep) { + if (rep.mode.id === 'CA' || rep.colorer.id === 'SS') { + rep.needsRebuild = true; + } + }); +}; + var rePdbId = /^(?:(pdb|cif|mmtf|ccp4):\s*)?(\d[a-z\d]{3})$/i; var rePubchem = /^(?:pc|pubchem):\s*([a-z]+)$/i; var reUrlScheme = /^([a-z][a-z\d\-+.]*):/i; @@ -91177,10 +92101,86 @@ function _parseData(data, opts, job) { }); } +Miew.prototype.exportCML = function () { + var self = this; + + function extractRotation(m) { + var xAxis = new Vector3(); + var yAxis = new Vector3(); + var zAxis = new Vector3(); + m.extractBasis(xAxis, yAxis, zAxis); + xAxis.normalize(); + yAxis.normalize(); + zAxis.normalize(); + var retMat = new Matrix4(); + retMat.identity(); + retMat.makeBasis(xAxis, yAxis, zAxis); + return retMat; + } + + function updateCMLData(complex) { + var root = self._gfx.root; + var mat = extractRotation(root.matrixWorld); + var v4 = new Vector4(0, 0, 0, 0); + var vCenter = new Vector4(0, 0, 0, 0); + var xml = null; + var ap = null; + + // update atoms in cml + complex.forEachAtom(function (atom) { + if (atom.xmlNodeRef && atom.xmlNodeRef.xmlNode) { + xml = atom.xmlNodeRef.xmlNode; + ap = atom.getPosition(); + v4.set(ap.x, ap.y, ap.z, 1.0); + v4.applyMatrix4(mat); + xml.setAttribute('x3', v4.x.toString()); + xml.setAttribute('y3', v4.y.toString()); + xml.setAttribute('z3', v4.z.toString()); + xml.removeAttribute('x2'); + xml.removeAttribute('y2'); + } + }); + // update stereo groups in cml + complex.forEachSGroup(function (sGroup) { + if (sGroup.xmlNodeRef && sGroup.xmlNodeRef.xmlNode) { + xml = sGroup.xmlNodeRef.xmlNode; + ap = sGroup.getPosition(); + v4.set(ap.x, ap.y, ap.z, 1.0); + var cp = sGroup.getCentralPoint(); + if (cp === null) { + v4.applyMatrix4(mat); + } else { + vCenter.set(cp.x, cp.y, cp.z, 0.0); + v4.add(vCenter); + v4.applyMatrix4(mat); // pos in global space + vCenter.set(cp.x, cp.y, cp.z, 1.0); + vCenter.applyMatrix4(mat); + v4.sub(vCenter); + } + xml.setAttribute('x', v4.x.toString()); + xml.setAttribute('y', v4.y.toString()); + xml.setAttribute('z', v4.z.toString()); + } + }); + } + + // FIXME save data for all complexes (not only current) + var visual = self._getComplexVisual(); + var complex = visual ? visual.getComplex() : null; + if (complex && complex.originalCML) { + updateCMLData(complex); + + // serialize xml structure to string + var oSerializer = new XMLSerializer(); + return oSerializer.serializeToString(complex.originalCML); + } + + return null; +}; //////////////////////////////////////////////////////////////////////////// // Additional exports -Miew.prototype.VERSION = typeof "0.7.11" !== 'undefined' && "0.7.11" || '0.0.0-dev'; +Miew.prototype.VERSION = typeof "0.7.12" !== 'undefined' && "0.7.12" || '0.0.0-dev'; // Miew.prototype.debugTracer = new utils.DebugTracer(Miew.prototype); lodash.assign(Miew, /** @lends Miew */{ @@ -91297,12 +92297,12 @@ var MiewCLIParser = createCommonjsModule(function (module, exports) { } */ var parser = (function(){ -var o=function(k,v,o,l){for(o=o||{}, l=k.length;l--;o[k[l]]=v);return o},$V0=[1,73],$V1=[1,75],$V2=[1,76],$V3=[1,79],$V4=[1,80],$V5=[1,81],$V6=[1,82],$V7=[1,83],$V8=[1,94],$V9=[1,86],$Va=[1,87],$Vb=[1,88],$Vc=[1,89],$Vd=[1,112],$Ve=[1,90],$Vf=[1,113],$Vg=[1,93],$Vh=[1,64],$Vi=[1,95],$Vj=[1,96],$Vk=[1,98],$Vl=[1,97],$Vm=[1,109],$Vn=[1,110],$Vo=[1,111],$Vp=[1,99],$Vq=[1,100],$Vr=[1,101],$Vs=[1,102],$Vt=[1,103],$Vu=[1,104],$Vv=[1,105],$Vw=[1,106],$Vx=[1,107],$Vy=[1,108],$Vz=[1,114],$VA=[1,115],$VB=[1,116],$VC=[1,118],$VD=[1,117],$VE=[1,70],$VF=[1,72],$VG=[1,69],$VH=[1,71],$VI=[1,77],$VJ=[1,78],$VK=[1,84],$VL=[1,85],$VM=[1,91],$VN=[1,92],$VO=[1,66],$VP=[1,67],$VQ=[1,68],$VR=[1,74],$VS=[1,128],$VT=[1,124],$VU=[1,127],$VV=[1,125],$VW=[1,126],$VX=[1,131],$VY=[1,130],$VZ=[1,147],$V_=[1,155],$V$=[1,162],$V01=[1,163],$V11=[1,200],$V21=[5,6,7,9,12,13,14,16,17,18,19,22,24,25,26,29,32,33,34,36,37,40,42,43,44,51,53,54,55,57,58,59,61,62,63,65,66,67,68,69,70,71,72,73,74,76,77,78,79,81,82,84,85,86,90,91,93,96,97,100,102,103],$V31=[5,6,7,9,12,13,14,16,17,18,19,22,24,25,26,29,32,33,34,36,37,40,42,43,44,51,53,54,55,57,58,59,61,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,81,82,84,85,86,90,91,93,96,97,100,102,103],$V41=[5,6,7,9,12,14,16,17,18,19,22,24,25,26,29,32,33,36,37,40,42,43,44,51,53,54,55,57,58,61,62,63,65,66,67,68,69,70,71,72,73,79,81,82,84,85,86,90,91,100],$V51=[5,90,91],$V61=[5,93],$V71=[1,226],$V81=[5,13,59,74,103],$V91=[75,102]; +var o=function(k,v,o,l){for(o=o||{}, l=k.length;l--;o[k[l]]=v);return o},$V0=[1,74],$V1=[1,76],$V2=[1,77],$V3=[1,80],$V4=[1,81],$V5=[1,82],$V6=[1,83],$V7=[1,84],$V8=[1,95],$V9=[1,87],$Va=[1,88],$Vb=[1,89],$Vc=[1,90],$Vd=[1,113],$Ve=[1,91],$Vf=[1,114],$Vg=[1,94],$Vh=[1,65],$Vi=[1,96],$Vj=[1,97],$Vk=[1,99],$Vl=[1,98],$Vm=[1,110],$Vn=[1,111],$Vo=[1,112],$Vp=[1,100],$Vq=[1,101],$Vr=[1,102],$Vs=[1,103],$Vt=[1,104],$Vu=[1,105],$Vv=[1,106],$Vw=[1,107],$Vx=[1,108],$Vy=[1,109],$Vz=[1,115],$VA=[1,116],$VB=[1,117],$VC=[1,119],$VD=[1,118],$VE=[1,71],$VF=[1,73],$VG=[1,70],$VH=[1,72],$VI=[1,78],$VJ=[1,79],$VK=[1,85],$VL=[1,86],$VM=[1,92],$VN=[1,93],$VO=[1,67],$VP=[1,68],$VQ=[1,69],$VR=[1,75],$VS=[1,129],$VT=[1,125],$VU=[1,128],$VV=[1,126],$VW=[1,127],$VX=[1,132],$VY=[1,131],$VZ=[1,148],$V_=[1,156],$V$=[1,163],$V01=[1,164],$V11=[1,201],$V21=[5,6,7,9,12,13,14,16,17,18,19,22,24,25,26,29,32,33,34,36,37,40,42,44,45,52,54,55,56,58,59,60,62,63,64,66,67,68,69,70,71,72,73,74,75,77,78,79,80,82,83,85,86,87,91,92,94,97,98,101,103,104],$V31=[5,6,7,9,12,13,14,16,17,18,19,22,24,25,26,29,32,33,34,36,37,40,42,44,45,52,54,55,56,58,59,60,62,63,64,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,85,86,87,91,92,94,97,98,101,103,104],$V41=[5,6,7,9,12,14,16,17,18,19,22,24,25,26,29,32,33,36,37,40,42,44,45,52,54,55,56,58,59,62,63,64,66,67,68,69,70,71,72,73,74,80,82,83,85,86,87,91,92,101],$V51=[5,91,92],$V61=[5,94],$V71=[1,227],$V81=[5,13,60,75,104],$V91=[76,103]; var parser = {trace: function trace() { }, yy: {}, -symbols_: {"error":2,"Program":3,"Command":4,"EOF":5,"RESET":6,"BUILD":7,"ALL":8,"HELP":9,"Path":10,"OneArgCommand":11,"GET":12,"STRING":13,"SET":14,"Value":15,"SET_SAVE":16,"SET_RESTORE":17,"SET_RESET":18,"PRESET":19,"AddRepresentation":20,"EditRepresentation":21,"REMOVE":22,"RepresentationReference":23,"HIDE":24,"SHOW":25,"LIST":26,"EXPAND_KEY":27,"SELECTOR_KEY":28,"SELECT":29,"AS":30,"WordAll":31,"SELECTOR":32,"WITHIN":33,"NUMBER":34,"OF":35,"MATERIAL":36,"IDENTIFIER":37,"ModeCMD":38,"ColorCMD":39,"VIEW":40,"BASE_64":41,"UNIT":42,"SCALE":43,"ROTATE":44,"AxesList":45,"TRANSLATE":46,"GetURLBranch":47,"Screenshot":48,"SrvCMD":49,"SrvScenarioCMD":50,"LINE":51,"ArgList":52,"LISTOBJ":53,"REMOVEOBJ":54,"URL":55,"VIEW_KEY":56,"SCREENSHOT":57,"FILE_LIST":58,"FILE_KEY":59,"PresetPath":60,"FILE_REGISTER":61,"FILE_DELETE":62,"PRESET_ADD":63,"Word":64,"PRESET_DELETE":65,"PRESET_UPDATE":66,"PRESET_RENAME":67,"PRESET_OPEN":68,"CREATE_SCENARIO":69,"RESET_SCENARIO":70,"DELETE_SCENARIO":71,"LIST_SCENARIO":72,"ADD_SCENARIO_ITEM":73,"DELAY_KEY":74,"=":75,"DESCRIPTION_KEY":76,"PDB_KEY":77,"PRST_KEY":78,"LOAD":79,"Url":80,"SCRIPT":81,"ADD":82,"Description":83,"REP":84,"MODE":85,"COLOR":86,"Descriptor":87,"RepresentationOwnProperty":88,"RepresentationOwnPropertyOpts":89,"DESC_KEY":90,"DESC_KEY_OPTS":91,"AxesArg":92,"DESC_KEY_AXES":93,"Arg":94,"PathWoDescKey":95,"HEX":96,"BOOL":97,"CommandSetWoDESC_KEY":98,"DescKeys":99,"CLEAR":100,"CommandSet":101,".":102,"/":103,"HexOrNumber":104,"$accept":0,"$end":1}, -terminals_: {2:"error",5:"EOF",6:"RESET",7:"BUILD",8:"ALL",9:"HELP",12:"GET",13:"STRING",14:"SET",16:"SET_SAVE",17:"SET_RESTORE",18:"SET_RESET",19:"PRESET",22:"REMOVE",24:"HIDE",25:"SHOW",26:"LIST",27:"EXPAND_KEY",28:"SELECTOR_KEY",29:"SELECT",30:"AS",32:"SELECTOR",33:"WITHIN",34:"NUMBER",35:"OF",36:"MATERIAL",37:"IDENTIFIER",40:"VIEW",41:"BASE_64",42:"UNIT",43:"SCALE",44:"ROTATE",46:"TRANSLATE",51:"LINE",53:"LISTOBJ",54:"REMOVEOBJ",55:"URL",56:"VIEW_KEY",57:"SCREENSHOT",58:"FILE_LIST",59:"FILE_KEY",61:"FILE_REGISTER",62:"FILE_DELETE",63:"PRESET_ADD",65:"PRESET_DELETE",66:"PRESET_UPDATE",67:"PRESET_RENAME",68:"PRESET_OPEN",69:"CREATE_SCENARIO",70:"RESET_SCENARIO",71:"DELETE_SCENARIO",72:"LIST_SCENARIO",73:"ADD_SCENARIO_ITEM",74:"DELAY_KEY",75:"=",76:"DESCRIPTION_KEY",77:"PDB_KEY",78:"PRST_KEY",79:"LOAD",81:"SCRIPT",82:"ADD",84:"REP",85:"MODE",86:"COLOR",90:"DESC_KEY",91:"DESC_KEY_OPTS",93:"DESC_KEY_AXES",96:"HEX",97:"BOOL",100:"CLEAR",102:".",103:"/"}, -productions_: [0,[3,2],[3,1],[4,1],[4,1],[4,2],[4,1],[4,2],[4,1],[4,2],[4,2],[4,3],[4,3],[4,1],[4,1],[4,1],[4,1],[4,2],[4,1],[4,1],[4,2],[4,2],[4,2],[4,2],[4,1],[4,2],[4,2],[4,2],[4,4],[4,2],[4,6],[4,2],[4,1],[4,1],[4,1],[4,2],[4,2],[4,1],[4,2],[4,2],[4,2],[4,2],[4,1],[4,1],[4,1],[4,1],[4,3],[4,3],[4,4],[4,4],[4,1],[4,2],[47,1],[47,2],[47,2],[47,3],[47,3],[48,1],[48,2],[48,3],[49,1],[49,3],[49,2],[49,4],[49,2],[49,4],[49,2],[49,4],[49,1],[49,2],[49,2],[49,2],[49,3],[49,3],[49,3],[49,2],[49,2],[49,2],[49,2],[49,2],[49,2],[49,2],[49,2],[49,3],[49,3],[49,3],[49,2],[49,2],[49,2],[50,2],[50,2],[50,1],[50,2],[50,2],[50,2],[50,1],[50,2],[50,3],[50,3],[50,3],[50,7],[50,13],[50,13],[50,13],[50,13],[11,2],[11,2],[11,2],[11,2],[20,1],[20,2],[20,2],[20,3],[21,2],[21,3],[38,2],[38,3],[39,2],[39,3],[23,1],[23,1],[83,1],[83,2],[83,3],[83,4],[87,1],[87,1],[87,2],[88,3],[89,3],[45,1],[45,2],[92,2],[52,1],[52,2],[94,3],[15,1],[15,1],[15,1],[15,1],[15,1],[64,1],[64,1],[31,1],[31,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[101,1],[101,1],[95,1],[95,3],[95,3],[10,1],[10,1],[10,3],[10,3],[10,3],[80,1],[60,1],[60,3],[104,1],[104,1]], +symbols_: {"error":2,"Program":3,"Command":4,"EOF":5,"RESET":6,"BUILD":7,"ALL":8,"HELP":9,"Path":10,"OneArgCommand":11,"GET":12,"STRING":13,"SET":14,"Value":15,"SET_SAVE":16,"SET_RESTORE":17,"SET_RESET":18,"PRESET":19,"AddRepresentation":20,"EditRepresentation":21,"REMOVE":22,"RepresentationReference":23,"HIDE":24,"SHOW":25,"LIST":26,"EXPAND_KEY":27,"SELECTOR_KEY":28,"SELECT":29,"AS":30,"WordAll":31,"SELECTOR":32,"WITHIN":33,"NUMBER":34,"OF":35,"MATERIAL":36,"IDENTIFIER":37,"ModeCMD":38,"ColorCMD":39,"VIEW":40,"BASE_64":41,"UNIT":42,"DSSP":43,"SCALE":44,"ROTATE":45,"AxesList":46,"TRANSLATE":47,"GetURLBranch":48,"Screenshot":49,"SrvCMD":50,"SrvScenarioCMD":51,"LINE":52,"ArgList":53,"LISTOBJ":54,"REMOVEOBJ":55,"URL":56,"VIEW_KEY":57,"SCREENSHOT":58,"FILE_LIST":59,"FILE_KEY":60,"PresetPath":61,"FILE_REGISTER":62,"FILE_DELETE":63,"PRESET_ADD":64,"Word":65,"PRESET_DELETE":66,"PRESET_UPDATE":67,"PRESET_RENAME":68,"PRESET_OPEN":69,"CREATE_SCENARIO":70,"RESET_SCENARIO":71,"DELETE_SCENARIO":72,"LIST_SCENARIO":73,"ADD_SCENARIO_ITEM":74,"DELAY_KEY":75,"=":76,"DESCRIPTION_KEY":77,"PDB_KEY":78,"PRST_KEY":79,"LOAD":80,"Url":81,"SCRIPT":82,"ADD":83,"Description":84,"REP":85,"MODE":86,"COLOR":87,"Descriptor":88,"RepresentationOwnProperty":89,"RepresentationOwnPropertyOpts":90,"DESC_KEY":91,"DESC_KEY_OPTS":92,"AxesArg":93,"DESC_KEY_AXES":94,"Arg":95,"PathWoDescKey":96,"HEX":97,"BOOL":98,"CommandSetWoDESC_KEY":99,"DescKeys":100,"CLEAR":101,"CommandSet":102,".":103,"/":104,"HexOrNumber":105,"$accept":0,"$end":1}, +terminals_: {2:"error",5:"EOF",6:"RESET",7:"BUILD",8:"ALL",9:"HELP",12:"GET",13:"STRING",14:"SET",16:"SET_SAVE",17:"SET_RESTORE",18:"SET_RESET",19:"PRESET",22:"REMOVE",24:"HIDE",25:"SHOW",26:"LIST",27:"EXPAND_KEY",28:"SELECTOR_KEY",29:"SELECT",30:"AS",32:"SELECTOR",33:"WITHIN",34:"NUMBER",35:"OF",36:"MATERIAL",37:"IDENTIFIER",40:"VIEW",41:"BASE_64",42:"UNIT",43:"DSSP",44:"SCALE",45:"ROTATE",47:"TRANSLATE",52:"LINE",54:"LISTOBJ",55:"REMOVEOBJ",56:"URL",57:"VIEW_KEY",58:"SCREENSHOT",59:"FILE_LIST",60:"FILE_KEY",62:"FILE_REGISTER",63:"FILE_DELETE",64:"PRESET_ADD",66:"PRESET_DELETE",67:"PRESET_UPDATE",68:"PRESET_RENAME",69:"PRESET_OPEN",70:"CREATE_SCENARIO",71:"RESET_SCENARIO",72:"DELETE_SCENARIO",73:"LIST_SCENARIO",74:"ADD_SCENARIO_ITEM",75:"DELAY_KEY",76:"=",77:"DESCRIPTION_KEY",78:"PDB_KEY",79:"PRST_KEY",80:"LOAD",82:"SCRIPT",83:"ADD",85:"REP",86:"MODE",87:"COLOR",91:"DESC_KEY",92:"DESC_KEY_OPTS",94:"DESC_KEY_AXES",97:"HEX",98:"BOOL",101:"CLEAR",103:".",104:"/"}, +productions_: [0,[3,2],[3,1],[4,1],[4,1],[4,2],[4,1],[4,2],[4,1],[4,2],[4,2],[4,3],[4,3],[4,1],[4,1],[4,1],[4,1],[4,2],[4,1],[4,1],[4,2],[4,2],[4,2],[4,2],[4,1],[4,2],[4,2],[4,2],[4,4],[4,2],[4,6],[4,2],[4,1],[4,1],[4,1],[4,2],[4,2],[4,1],[4,2],[4,1],[4,2],[4,2],[4,2],[4,1],[4,1],[4,1],[4,1],[4,3],[4,3],[4,4],[4,4],[4,1],[4,2],[48,1],[48,2],[48,2],[48,3],[48,3],[49,1],[49,2],[49,3],[50,1],[50,3],[50,2],[50,4],[50,2],[50,4],[50,2],[50,4],[50,1],[50,2],[50,2],[50,2],[50,3],[50,3],[50,3],[50,2],[50,2],[50,2],[50,2],[50,2],[50,2],[50,2],[50,2],[50,3],[50,3],[50,3],[50,2],[50,2],[50,2],[51,2],[51,2],[51,1],[51,2],[51,2],[51,2],[51,1],[51,2],[51,3],[51,3],[51,3],[51,7],[51,13],[51,13],[51,13],[51,13],[11,2],[11,2],[11,2],[11,2],[20,1],[20,2],[20,2],[20,3],[21,2],[21,3],[38,2],[38,3],[39,2],[39,3],[23,1],[23,1],[84,1],[84,2],[84,3],[84,4],[88,1],[88,1],[88,2],[89,3],[90,3],[46,1],[46,2],[93,2],[53,1],[53,2],[95,3],[15,1],[15,1],[15,1],[15,1],[15,1],[65,1],[65,1],[31,1],[31,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[99,1],[100,1],[100,1],[100,1],[100,1],[100,1],[100,1],[100,1],[102,1],[102,1],[96,1],[96,3],[96,3],[10,1],[10,1],[10,3],[10,3],[10,3],[81,1],[61,1],[61,3],[105,1],[105,1]], performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { /* this == yyval */ @@ -91396,240 +92396,243 @@ case 38: this.$ = yy.miew.changeUnit($$[$0]); break; case 39: -this.$ = yy.miew.scale($$[$0]); +this.$ = yy.miew.dssp(); break; case 40: - for (var i = 0, n = $$[$0].length; i < n; i++) {yy.miew.rotate($$[$0][i]['x'] * Math.PI / 180.0, $$[$0][i]['y'] * Math.PI / 180.0, $$[$0][i]['z'] * Math.PI / 180.0);} +this.$ = yy.miew.scale($$[$0]); break; case 41: + for (var i = 0, n = $$[$0].length; i < n; i++) {yy.miew.rotate($$[$0][i]['x'] * Math.PI / 180.0, $$[$0][i]['y'] * Math.PI / 180.0, $$[$0][i]['z'] * Math.PI / 180.0);} +break; +case 42: for (var i = 0, n = $$[$0].length; i < n; i++) {yy.miew.translate($$[$0][i]['x'] || 0, $$[$0][i]['y'] || 0, $$[$0][i]['z'] || 0);} break; -case 46: case 47: +case 47: case 48: this.$ = yy.miew.addObject({type: 'line', params: [$$[$0-1], $$[$0]]}, true); break; -case 48: case 49: +case 49: case 50: this.$ = yy.miew.addObject({type: 'line', params: [$$[$0-2], $$[$0-1]], opts:$$[$0].toJSO(yy.utils, 'objects', 'line')}, true); break; -case 50: +case 51: this.$ = yy.echo(yy.utils.listObjs(yy.miew)); break; -case 51: +case 52: this.$ = yy.miew.removeObject($$[$0]); break; -case 52: +case 53: this.$ = yy.echo(yy.miew.getURL({view: false, settings: false})); break; -case 53: +case 54: this.$ = yy.echo(yy.miew.getURL({view: false, settings: true})); break; -case 54: +case 55: this.$ = yy.echo(yy.miew.getURL({view: true, settings: false})); break; -case 55: case 56: +case 56: case 57: this.$ = yy.echo(yy.miew.getURL({view: true, settings: true})); break; -case 57: +case 58: this.$ = yy.miew.screenshotSave(); break; -case 58: +case 59: this.$ = yy.miew.screenshotSave('', Number($$[$0])); break; -case 59: +case 60: this.$ = yy.miew.screenshotSave('', Number($$[$0-1]), Number($$[$0])); break; -case 60: +case 61: this.$ = yy.srv.fileList(yy.miew, yy.echo, yy.error); break; -case 61: +case 62: this.$ = yy.srv.fileList(yy.miew, yy.echo, yy.error, "", $$[$0]); break; -case 62: +case 63: this.$ = yy.srv.fileList(yy.miew, yy.echo, yy.error, $$[$0]); break; -case 63: +case 64: this.$ = yy.srv.fileList(yy.miew, yy.echo, yy.error, $$[$0-2], $$[$0]); break; -case 64: case 66: +case 65: case 67: this.$ = yy.srv.coroutineWithFileName(yy.miew, yy.echo, yy.error, $$[$0], yy.srv.fileList, yy.srv, yy.miew, yy.echo, yy.error); break; -case 65: case 67: +case 66: case 68: this.$ = yy.srv.coroutineWithFileName(yy.miew, yy.echo, yy.error, $$[$0-2], yy.srv.fileList, yy.srv, yy.miew, yy.echo, yy.error, $$[$0]); break; -case 68: +case 69: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvTopologyRegister"); break; -case 69: +case 70: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvTopologyDelete", $$[$0], false); break; -case 70: case 71: +case 71: case 72: this.$ = yy.srv.coroutineWithFileName(yy.miew, yy.echo, yy.error, $$[$0], yy.miew.srvTopologyDelete, false); break; -case 72: +case 73: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvTopologyDelete", $$[$0-1], true); break; -case 73: case 74: +case 74: case 75: this.$ = yy.srv.coroutineWithFileName(yy.miew, yy.echo, yy.error, $$[$0-1], yy.miew.srvTopologyDelete, true); break; -case 75: case 76: +case 76: case 77: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvPresetCreate", $$[$0]); break; -case 77: +case 78: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvPresetDelete", $$[$0]); break; -case 78: case 79: +case 79: case 80: this.$ = yy.srv.coroutineWithPresetPath(yy.miew, yy.echo, yy.error, $$[$0], yy.miew.srvPresetDelete); break; -case 80: +case 81: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvPresetUpdate", $$[$0]); break; -case 81: case 82: +case 82: case 83: this.$ = yy.srv.coroutineWithPresetPath(yy.miew, yy.echo, yy.error, $$[$0], yy.miew.srvPresetUpdate); break; -case 83: +case 84: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvPresetRename", $$[$0-1], $$[$0]); break; -case 84: case 85: +case 85: case 86: this.$ = yy.srv.coroutineWithPresetPath(yy.miew, yy.echo, yy.error, $$[$0-1], yy.miew.srvPresetRename, $$[$0]); break; -case 86: +case 87: this.$ = yy.srv.callSrvFunc(yy.miew, yy.echo, yy.error, "srvPresetApply", $$[$0]); yy.representations.clear(); break; -case 87: case 88: +case 88: case 89: this.$ = yy.srv.coroutineWithPresetPath(yy.miew, yy.echo, yy.error, $$[$0], yy.miew.srvPresetApply); yy.representations.clear(); break; -case 89: case 90: +case 90: case 91: this.$ = yy.srv.createScenario($$[$0]); break; -case 91: +case 92: this.$ = yy.srv.resetScenario(); break; -case 92: case 93: +case 93: case 94: this.$ = yy.srv.deleteScenario(yy.miew, yy.echo, yy.error, $$[$0]); break; -case 94: +case 95: this.$ = yy.srv.deleteScenario(yy.miew, yy.echo, yy.error, Number($$[$0])); break; -case 95: +case 96: this.$ = yy.srv.listScenario(yy.miew, yy.echo, yy.error); break; -case 96: case 97: case 98: case 99: +case 97: case 98: case 99: case 100: this.$ = yy.srv.listScenario(yy.miew, yy.echo, yy.error, $$[$0]); break; -case 100: +case 101: this.$ =yy.srv.addScenarioItem(yy.miew, yy.echo, yy.error, Number($$[$0-3]), $$[$0]); break; -case 101: +case 102: this.$ =yy.srv.addScenarioItem(yy.miew, yy.echo, yy.error, Number($$[$0-9]), Number($$[$0-6]), Number($$[$0-3]), $$[$0]); break; -case 102: +case 103: this.$ =yy.srv.addScenarioItem(yy.miew, yy.echo, yy.error, $$[$0-9], Number($$[$0-6]), Number($$[$0-3]), $$[$0]); break; -case 103: +case 104: this.$ =yy.srv.addScenarioItem(yy.miew, yy.echo, yy.error, Number($$[$0-9]), $$[$0-6], Number($$[$0-3]), $$[$0]); break; -case 104: +case 105: this.$ =yy.srv.addScenarioItem(yy.miew, yy.echo, yy.error, $$[$0-9], $$[$0-6], Number($$[$0-3]), $$[$0]); break; -case 105: case 106: case 107: +case 106: case 107: case 108: this.$ = yy.utils.load(yy.miew, $$[$0]); yy.representations.clear(); break; -case 108: +case 109: this.$ = yy.notimplemented(); break; -case 109: +case 110: this.$ = yy.echo(yy.representations.add(yy.miew.repAdd())); break; -case 110: +case 111: this.$ = yy.echo(yy.representations.add($$[$0], yy.miew.repAdd())); break; -case 111: +case 112: this.$ = yy.echo(yy.representations.add(yy.miew.repAdd($$[$0]))); break; -case 112: +case 113: this.$ = yy.echo(yy.representations.add($$[$0-1], yy.miew.repAdd($$[$0]))); break; -case 113: +case 114: this.$ = yy.miew.rep($$[$0]); yy.miew.repCurrent($$[$0]); break; -case 114: +case 115: this.$ = yy.miew.rep($$[$0-1], $$[$0]); yy.miew.repCurrent($$[$0-1]); break; -case 115: +case 116: this.$ = yy.miew.rep(yy.miew.repCurrent(), {mode : yy.utils.checkArg($$[$0-1].toLowerCase(), $$[$0].toUpperCase())}); break; -case 116: +case 117: this.$ = yy.miew.rep(yy.miew.repCurrent(), {mode : new Array(yy.utils.checkArg($$[$0-2].toLowerCase(), $$[$0-1].toUpperCase()), $$[$0].toJSO(yy.utils, $$[$0-2], $$[$0-1].toUpperCase()))}); break; -case 117: +case 118: this.$ = yy.miew.rep(yy.miew.repCurrent(), {colorer : yy.utils.checkArg($$[$0-1].toLowerCase(), $$[$0].toUpperCase())}); break; -case 118: +case 119: this.$ = yy.miew.rep(yy.miew.repCurrent(), {colorer : new Array(yy.utils.checkArg($$[$0-2].toLowerCase(), $$[$0-1].toUpperCase()), $$[$0].toJSO(yy.utils, $$[$0-2], $$[$0-1].toUpperCase()))}); break; -case 119: +case 120: this.$ = Number(yy.representations.get($$[$0])); break; -case 120: case 136: +case 121: case 137: this.$ = Number($$[$0]); break; -case 121: +case 122: this.$ = $$[$0]; break; -case 122: +case 123: this.$ = yy._.assign($$[$0-1], $$[$0]); break; -case 123: +case 124: this.$ = yy._.assign($$[$0-2], $$[$0-1], $$[$0]); break; -case 124: +case 125: this.$ = yy._.assign($$[$0-3], $$[$0-2], $$[$0-1], $$[$0]); break; -case 125: case 126: +case 126: case 127: this.$ = yy.CreateObjectPair($$[$0].key, $$[$0].val); break; -case 127: +case 128: this.$ = yy.CreateObjectPair($$[$0-1].key, new Array($$[$0-1].val, $$[$0].toJSO(yy.utils, $$[$0-1].key, $$[$0-1].val))); break; -case 128: case 129: +case 129: case 130: this.$ = Object.create({'key': yy.keyRemap($$[$0-2]), 'val': yy.utils.checkArg($$[$0-2], $$[$0])}); break; -case 130: +case 131: this.$ = [$$[$0]]; break; -case 131: +case 132: this.$ = $$[$0-1].concat($$[$0]); break; -case 132: +case 133: this.$ = yy.CreateObjectPair($$[$0-1].toLowerCase(), Number($$[$0])); break; -case 133: +case 134: this.$ = new yy.ArgList($$[$0]); break; -case 134: +case 135: this.$ = $$[$0-1].append($$[$0]); break; -case 135: +case 136: this.$ = new yy.Arg($$[$0-2], $$[$0]); break; -case 137: +case 138: this.$ = parseInt($$[$0]); break; -case 138: +case 139: this.$ = JSON.parse($$[$0]); break; -case 139: case 140: +case 140: case 141: this.$ = String($$[$0]); break; -case 201: case 202: case 205: case 206: case 207: +case 202: case 203: case 206: case 207: case 208: this.$ = $$[$0-2] + $$[$0-1] + $$[$0]; //cause of could be color word in path; break; -case 210: +case 211: this.$ = $$[$0-2] = $$[$0-2] + $$[$0-1] + $$[$0]; break; } }, -table: [{3:1,4:2,5:[1,3],6:[1,4],7:[1,5],9:[1,6],11:7,12:[1,8],14:[1,9],16:[1,10],17:[1,11],18:[1,12],19:[1,13],20:14,21:15,22:[1,16],24:[1,17],25:[1,18],26:[1,19],29:[1,20],32:[1,21],33:[1,22],36:[1,23],38:24,39:25,40:[1,26],42:[1,27],43:[1,28],44:[1,29],46:[1,30],47:31,48:32,49:33,50:34,51:[1,35],53:[1,36],54:[1,37],55:[1,44],57:[1,45],58:[1,46],61:[1,47],62:[1,48],63:[1,49],65:[1,50],66:[1,51],67:[1,52],68:[1,53],69:[1,54],70:[1,55],71:[1,56],72:[1,57],73:[1,58],79:[1,38],81:[1,39],82:[1,40],84:[1,41],85:[1,42],86:[1,43]},{1:[3]},{5:[1,59]},{1:[2,2]},{5:[2,3]},{5:[2,4],8:[1,60]},{5:[2,6],6:$V0,7:$V1,9:$V2,10:61,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{5:[2,8]},{6:$V0,7:$V1,9:$V2,10:119,12:$V3,13:[1,120],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{6:$V0,7:$V1,9:$V2,10:121,12:$V3,13:[1,122],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{5:[2,13]},{5:[2,14]},{5:[2,15]},{5:[2,16],13:$VS,15:123,34:$VT,37:$VU,96:$VV,97:$VW},{5:[2,18]},{5:[2,19]},{23:129,34:$VX,37:$VY},{23:132,34:$VX,37:$VY},{23:133,34:$VX,37:$VY},{5:[2,24],23:134,27:[1,135],28:[1,136],34:$VX,37:$VY},{13:[1,137]},{13:[1,138]},{34:[1,139]},{37:[1,140]},{5:[2,32]},{5:[2,33]},{5:[2,34],13:[1,141],41:[1,142]},{5:[2,37],34:[1,143]},{34:[1,144]},{45:145,92:146,93:$VZ},{45:148,92:146,93:$VZ},{5:[2,42]},{5:[2,43]},{5:[2,44]},{5:[2,45]},{6:$V0,7:$V1,9:$V2,10:150,12:$V3,13:[1,149],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{5:[2,50]},{34:[1,151]},{13:$V_,37:[1,153],59:[1,154],80:152},{13:$V_,80:156},{5:[2,109],37:[1,157],83:158,87:159,88:160,89:161,90:$V$,91:$V01},{23:164,34:$VX,37:$VY},{37:[1,165]},{37:[1,166]},{5:[2,52],28:[1,167],56:[1,168]},{5:[2,57],34:[1,169]},{5:[2,60],6:$V0,7:$V1,9:$V2,10:174,12:$V3,13:[1,173],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,171],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,59:[1,170],60:172,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{5:[2,68]},{6:$V0,7:$V1,9:$V2,10:174,12:$V3,13:[1,176],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,175],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,60:177,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{6:$V0,7:$V1,9:$V2,12:$V3,13:[1,178],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:179,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,98:65,100:$VR},{6:$V0,7:$V1,9:$V2,10:174,12:$V3,13:[1,181],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,180],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,60:182,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{6:$V0,7:$V1,9:$V2,10:174,12:$V3,13:[1,184],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,183],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,60:185,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{6:$V0,7:$V1,9:$V2,10:174,12:$V3,13:[1,187],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,186],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,60:188,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{6:$V0,7:$V1,9:$V2,10:174,12:$V3,13:[1,190],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,189],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,60:191,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{6:$V0,7:$V1,9:$V2,12:$V3,13:[1,192],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:193,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,98:65,100:$VR},{5:[2,91]},{6:$V0,7:$V1,9:$V2,12:$V3,13:[1,194],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,196],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:195,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,98:65,100:$VR},{5:[2,95],27:[1,197]},{74:[1,198],77:[1,199]},{1:[2,1]},{5:[2,5]},{5:[2,7],102:$V11},o($V21,[2,203]),o($V21,[2,204]),o($V31,[2,141]),o($V31,[2,142]),o($V21,[2,191]),o($V21,[2,192]),o($V21,[2,193]),o($V21,[2,194]),o($V21,[2,195]),o($V21,[2,196]),o($V21,[2,197]),o($V31,[2,145]),o($V31,[2,146]),o($V31,[2,147]),o($V31,[2,148]),o($V31,[2,149]),o($V31,[2,150]),o($V31,[2,151]),o($V31,[2,152]),o($V31,[2,153]),o($V31,[2,154]),o($V31,[2,155]),o($V31,[2,156]),o($V31,[2,157]),o($V31,[2,158]),o($V31,[2,159]),o($V31,[2,160]),o($V31,[2,161]),o($V31,[2,162]),o($V31,[2,163]),o($V31,[2,164]),o($V31,[2,165]),o($V31,[2,166]),o($V31,[2,167]),o($V31,[2,168]),o($V31,[2,169]),o($V31,[2,170]),o($V31,[2,171]),o($V31,[2,172]),o($V31,[2,173]),o($V31,[2,174]),o($V31,[2,175]),o($V31,[2,176]),o($V31,[2,177]),o($V31,[2,178]),o($V31,[2,179]),o($V31,[2,180]),o($V31,[2,181]),o($V31,[2,182]),o($V31,[2,183]),o($V31,[2,184]),o($V31,[2,185]),o($V31,[2,186]),o($V31,[2,187]),o($V31,[2,188]),o($V31,[2,189]),o($V31,[2,190]),{5:[2,9],102:$V11},{5:[2,10]},{13:$VS,15:201,34:$VT,37:$VU,96:$VV,97:$VW,102:$V11},{13:$VS,15:202,34:$VT,37:$VU,96:$VV,97:$VW},{5:[2,17]},o($V41,[2,136]),o($V41,[2,137]),o($V41,[2,138]),o($V41,[2,139]),o($V41,[2,140]),{5:[2,20]},o($V51,[2,119]),o($V51,[2,120]),{5:[2,21]},{5:[2,22]},{5:[2,23]},{5:[2,25]},{5:[2,26]},{5:[2,27],30:[1,203]},{5:[2,29]},{35:[1,204]},{5:[2,31]},{5:[2,35]},{5:[2,36]},{5:[2,38]},{5:[2,39]},{5:[2,40],92:205,93:$VZ},o($V61,[2,130]),{34:[1,206]},{5:[2,41],92:205,93:$VZ},{13:[1,207]},{6:$V0,7:$V1,9:$V2,10:208,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR,102:$V11},{5:[2,51]},{5:[2,105]},{5:[2,106]},{5:[2,107]},{5:[2,208]},{5:[2,108]},{5:[2,110],83:209,87:159,88:160,89:161,90:$V$,91:$V01},{5:[2,111]},{5:[2,121],87:210,88:160,89:161,90:$V$,91:$V01},o($V51,[2,125]),o($V51,[2,126],{98:65,52:211,94:212,95:213,64:214,6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,100:$VR}),{75:[1,215]},{75:[1,216]},{5:[2,113],83:217,87:159,88:160,89:161,90:$V$,91:$V01},{5:[2,115],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,52:218,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:212,95:213,98:65,100:$VR},{5:[2,117],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,52:219,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:212,95:213,98:65,100:$VR},{5:[2,53],56:[1,220]},{5:[2,54],28:[1,221]},{5:[2,58],34:[1,222]},{13:[1,223]},{5:[2,62],59:[1,224]},{5:[2,64],59:[1,225],103:$V71},{5:[2,66],59:[1,227]},o($V81,[2,209],{102:$V11}),{5:[2,69],59:[1,228]},{5:[2,70],59:[1,229]},{5:[2,71],59:[1,230],103:$V71},{5:[2,75]},{5:[2,76]},{5:[2,77]},{5:[2,78]},{5:[2,79],103:$V71},{5:[2,80]},{5:[2,81]},{5:[2,82],103:$V71},{13:[1,231]},{13:[1,232]},{13:[1,233],103:$V71},{5:[2,86]},{5:[2,87]},{5:[2,88],103:$V71},{5:[2,89]},{5:[2,90]},{5:[2,92]},{5:[2,93]},{5:[2,94]},{5:[2,96],6:$V0,7:$V1,9:$V2,12:$V3,13:[1,236],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,234],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:235,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,98:65,100:$VR},{75:[1,237]},{75:[1,238]},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,240],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:239,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:241,100:$VR},{5:[2,11]},{5:[2,12]},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,31:242,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:243,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:244,100:$VR},{13:[1,245]},o($V61,[2,131]),o($V61,[2,132]),{5:[2,46],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,52:246,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:212,95:213,98:65,100:$VR},{5:[2,47],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,52:247,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:212,95:213,98:65,100:$VR,102:$V11},{5:[2,112]},{5:[2,122],87:248,88:160,89:161,90:$V$,91:$V01},o($V51,[2,127],{98:65,95:213,64:214,94:249,6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,100:$VR}),o($V41,[2,133]),{75:[1,250],102:[1,251]},o($V91,[2,200]),{13:$VS,15:252,34:$VT,37:$VU,96:$VV,97:$VW},{13:$VS,15:253,34:$VT,37:$VU,96:$VV,97:$VW},{5:[2,114]},{5:[2,116],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:249,95:213,98:65,100:$VR},{5:[2,118],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:249,95:213,98:65,100:$VR},{5:[2,55]},{5:[2,56]},{5:[2,59]},{5:[2,61]},{13:[1,254]},{13:[1,255]},{6:$V0,7:$V1,9:$V2,10:256,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{13:[1,257]},{5:[2,72]},{5:[2,73]},{5:[2,74]},{5:[2,83]},{5:[2,84]},{5:[2,85]},{5:[2,97]},{5:[2,98]},{5:[2,99]},{34:[1,258]},{34:[1,259],37:[1,260]},o($V21,[2,205]),o($V21,[2,206]),o($V21,[2,207]),{5:[2,28]},{5:[2,143]},{5:[2,144]},{30:[1,261]},{5:[2,48],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:249,95:213,98:65,100:$VR},{5:[2,49],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:214,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,94:249,95:213,98:65,100:$VR},{5:[2,123],87:262,88:160,89:161,90:$V$,91:$V01},o($V41,[2,134]),{13:$VS,15:263,34:$VT,37:$VU,96:$VV,97:$VW},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,265],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:264,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,98:65,100:$VR},o($V51,[2,128]),o($V41,[2,129]),{5:[2,63]},{5:[2,65]},o($V81,[2,210],{102:$V11}),{5:[2,67]},{76:[1,266]},{78:[1,267]},{78:[1,268]},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,31:269,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,61:$Vs,62:$Vt,63:$Vu,64:243,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:244,100:$VR},{5:[2,124]},o($V41,[2,135]),o($V91,[2,201]),o($V91,[2,202]),{75:[1,270]},{75:[1,271]},{75:[1,272]},{5:[2,30]},{13:[1,273]},{6:$V0,7:$V1,9:$V2,10:174,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,274],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,60:275,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{6:$V0,7:$V1,9:$V2,10:174,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,276],36:$Vg,37:$Vh,40:$Vi,42:$Vj,43:$Vk,44:$Vl,51:$Vm,53:$Vn,54:$Vo,55:$Vp,57:$Vq,58:$Vr,60:277,61:$Vs,62:$Vt,63:$Vu,64:62,65:$Vv,66:$Vw,67:$Vx,68:$Vy,69:$Vz,70:$VA,71:$VB,72:$VC,73:$VD,74:$VE,76:$VF,77:$VG,78:$VH,79:$VI,81:$VJ,82:$VK,84:$VL,85:$VM,86:$VN,90:$VO,91:$VP,93:$VQ,98:65,99:63,100:$VR},{5:[2,100]},{74:[1,278]},{74:[1,279],103:$V71},{74:[1,280]},{74:[1,281],103:$V71},{75:[1,282]},{75:[1,283]},{75:[1,284]},{75:[1,285]},{34:[1,286]},{34:[1,287]},{34:[1,288]},{34:[1,289]},{76:[1,290]},{76:[1,291]},{76:[1,292]},{76:[1,293]},{75:[1,294]},{75:[1,295]},{75:[1,296]},{75:[1,297]},{13:[1,298]},{13:[1,299]},{13:[1,300]},{13:[1,301]},{5:[2,101]},{5:[2,103]},{5:[2,102]},{5:[2,104]}], -defaultActions: {3:[2,2],4:[2,3],7:[2,8],10:[2,13],11:[2,14],12:[2,15],14:[2,18],15:[2,19],24:[2,32],25:[2,33],31:[2,42],32:[2,43],33:[2,44],34:[2,45],36:[2,50],47:[2,68],55:[2,91],59:[2,1],60:[2,5],120:[2,10],123:[2,17],129:[2,20],132:[2,21],133:[2,22],134:[2,23],135:[2,25],136:[2,26],138:[2,29],140:[2,31],141:[2,35],142:[2,36],143:[2,38],144:[2,39],151:[2,51],152:[2,105],153:[2,106],154:[2,107],155:[2,208],156:[2,108],158:[2,111],178:[2,75],179:[2,76],180:[2,77],181:[2,78],183:[2,80],184:[2,81],189:[2,86],190:[2,87],192:[2,89],193:[2,90],194:[2,92],195:[2,93],196:[2,94],201:[2,11],202:[2,12],209:[2,112],217:[2,114],220:[2,55],221:[2,56],222:[2,59],223:[2,61],228:[2,72],229:[2,73],230:[2,74],231:[2,83],232:[2,84],233:[2,85],234:[2,97],235:[2,98],236:[2,99],242:[2,28],243:[2,143],244:[2,144],254:[2,63],255:[2,65],257:[2,67],262:[2,124],269:[2,30],273:[2,100],298:[2,101],299:[2,103],300:[2,102],301:[2,104]}, +table: [{3:1,4:2,5:[1,3],6:[1,4],7:[1,5],9:[1,6],11:7,12:[1,8],14:[1,9],16:[1,10],17:[1,11],18:[1,12],19:[1,13],20:14,21:15,22:[1,16],24:[1,17],25:[1,18],26:[1,19],29:[1,20],32:[1,21],33:[1,22],36:[1,23],38:24,39:25,40:[1,26],42:[1,27],43:[1,28],44:[1,29],45:[1,30],47:[1,31],48:32,49:33,50:34,51:35,52:[1,36],54:[1,37],55:[1,38],56:[1,45],58:[1,46],59:[1,47],62:[1,48],63:[1,49],64:[1,50],66:[1,51],67:[1,52],68:[1,53],69:[1,54],70:[1,55],71:[1,56],72:[1,57],73:[1,58],74:[1,59],80:[1,39],82:[1,40],83:[1,41],85:[1,42],86:[1,43],87:[1,44]},{1:[3]},{5:[1,60]},{1:[2,2]},{5:[2,3]},{5:[2,4],8:[1,61]},{5:[2,6],6:$V0,7:$V1,9:$V2,10:62,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{5:[2,8]},{6:$V0,7:$V1,9:$V2,10:120,12:$V3,13:[1,121],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{6:$V0,7:$V1,9:$V2,10:122,12:$V3,13:[1,123],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{5:[2,13]},{5:[2,14]},{5:[2,15]},{5:[2,16],13:$VS,15:124,34:$VT,37:$VU,97:$VV,98:$VW},{5:[2,18]},{5:[2,19]},{23:130,34:$VX,37:$VY},{23:133,34:$VX,37:$VY},{23:134,34:$VX,37:$VY},{5:[2,24],23:135,27:[1,136],28:[1,137],34:$VX,37:$VY},{13:[1,138]},{13:[1,139]},{34:[1,140]},{37:[1,141]},{5:[2,32]},{5:[2,33]},{5:[2,34],13:[1,142],41:[1,143]},{5:[2,37],34:[1,144]},{5:[2,39]},{34:[1,145]},{46:146,93:147,94:$VZ},{46:149,93:147,94:$VZ},{5:[2,43]},{5:[2,44]},{5:[2,45]},{5:[2,46]},{6:$V0,7:$V1,9:$V2,10:151,12:$V3,13:[1,150],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{5:[2,51]},{34:[1,152]},{13:$V_,37:[1,154],60:[1,155],81:153},{13:$V_,81:157},{5:[2,110],37:[1,158],84:159,88:160,89:161,90:162,91:$V$,92:$V01},{23:165,34:$VX,37:$VY},{37:[1,166]},{37:[1,167]},{5:[2,53],28:[1,168],57:[1,169]},{5:[2,58],34:[1,170]},{5:[2,61],6:$V0,7:$V1,9:$V2,10:175,12:$V3,13:[1,174],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,172],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,60:[1,171],61:173,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{5:[2,69]},{6:$V0,7:$V1,9:$V2,10:175,12:$V3,13:[1,177],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,176],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,61:178,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{6:$V0,7:$V1,9:$V2,12:$V3,13:[1,179],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:180,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,99:66,101:$VR},{6:$V0,7:$V1,9:$V2,10:175,12:$V3,13:[1,182],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,181],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,61:183,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{6:$V0,7:$V1,9:$V2,10:175,12:$V3,13:[1,185],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,184],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,61:186,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{6:$V0,7:$V1,9:$V2,10:175,12:$V3,13:[1,188],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,187],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,61:189,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{6:$V0,7:$V1,9:$V2,10:175,12:$V3,13:[1,191],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,190],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,61:192,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{6:$V0,7:$V1,9:$V2,12:$V3,13:[1,193],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:194,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,99:66,101:$VR},{5:[2,92]},{6:$V0,7:$V1,9:$V2,12:$V3,13:[1,195],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,197],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:196,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,99:66,101:$VR},{5:[2,96],27:[1,198]},{75:[1,199],78:[1,200]},{1:[2,1]},{5:[2,5]},{5:[2,7],103:$V11},o($V21,[2,204]),o($V21,[2,205]),o($V31,[2,142]),o($V31,[2,143]),o($V21,[2,192]),o($V21,[2,193]),o($V21,[2,194]),o($V21,[2,195]),o($V21,[2,196]),o($V21,[2,197]),o($V21,[2,198]),o($V31,[2,146]),o($V31,[2,147]),o($V31,[2,148]),o($V31,[2,149]),o($V31,[2,150]),o($V31,[2,151]),o($V31,[2,152]),o($V31,[2,153]),o($V31,[2,154]),o($V31,[2,155]),o($V31,[2,156]),o($V31,[2,157]),o($V31,[2,158]),o($V31,[2,159]),o($V31,[2,160]),o($V31,[2,161]),o($V31,[2,162]),o($V31,[2,163]),o($V31,[2,164]),o($V31,[2,165]),o($V31,[2,166]),o($V31,[2,167]),o($V31,[2,168]),o($V31,[2,169]),o($V31,[2,170]),o($V31,[2,171]),o($V31,[2,172]),o($V31,[2,173]),o($V31,[2,174]),o($V31,[2,175]),o($V31,[2,176]),o($V31,[2,177]),o($V31,[2,178]),o($V31,[2,179]),o($V31,[2,180]),o($V31,[2,181]),o($V31,[2,182]),o($V31,[2,183]),o($V31,[2,184]),o($V31,[2,185]),o($V31,[2,186]),o($V31,[2,187]),o($V31,[2,188]),o($V31,[2,189]),o($V31,[2,190]),o($V31,[2,191]),{5:[2,9],103:$V11},{5:[2,10]},{13:$VS,15:202,34:$VT,37:$VU,97:$VV,98:$VW,103:$V11},{13:$VS,15:203,34:$VT,37:$VU,97:$VV,98:$VW},{5:[2,17]},o($V41,[2,137]),o($V41,[2,138]),o($V41,[2,139]),o($V41,[2,140]),o($V41,[2,141]),{5:[2,20]},o($V51,[2,120]),o($V51,[2,121]),{5:[2,21]},{5:[2,22]},{5:[2,23]},{5:[2,25]},{5:[2,26]},{5:[2,27],30:[1,204]},{5:[2,29]},{35:[1,205]},{5:[2,31]},{5:[2,35]},{5:[2,36]},{5:[2,38]},{5:[2,40]},{5:[2,41],93:206,94:$VZ},o($V61,[2,131]),{34:[1,207]},{5:[2,42],93:206,94:$VZ},{13:[1,208]},{6:$V0,7:$V1,9:$V2,10:209,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR,103:$V11},{5:[2,52]},{5:[2,106]},{5:[2,107]},{5:[2,108]},{5:[2,209]},{5:[2,109]},{5:[2,111],84:210,88:160,89:161,90:162,91:$V$,92:$V01},{5:[2,112]},{5:[2,122],88:211,89:161,90:162,91:$V$,92:$V01},o($V51,[2,126]),o($V51,[2,127],{99:66,53:212,95:213,96:214,65:215,6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,101:$VR}),{76:[1,216]},{76:[1,217]},{5:[2,114],84:218,88:160,89:161,90:162,91:$V$,92:$V01},{5:[2,116],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,53:219,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:213,96:214,99:66,101:$VR},{5:[2,118],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,53:220,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:213,96:214,99:66,101:$VR},{5:[2,54],57:[1,221]},{5:[2,55],28:[1,222]},{5:[2,59],34:[1,223]},{13:[1,224]},{5:[2,63],60:[1,225]},{5:[2,65],60:[1,226],104:$V71},{5:[2,67],60:[1,228]},o($V81,[2,210],{103:$V11}),{5:[2,70],60:[1,229]},{5:[2,71],60:[1,230]},{5:[2,72],60:[1,231],104:$V71},{5:[2,76]},{5:[2,77]},{5:[2,78]},{5:[2,79]},{5:[2,80],104:$V71},{5:[2,81]},{5:[2,82]},{5:[2,83],104:$V71},{13:[1,232]},{13:[1,233]},{13:[1,234],104:$V71},{5:[2,87]},{5:[2,88]},{5:[2,89],104:$V71},{5:[2,90]},{5:[2,91]},{5:[2,93]},{5:[2,94]},{5:[2,95]},{5:[2,97],6:$V0,7:$V1,9:$V2,12:$V3,13:[1,237],14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,235],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:236,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,99:66,101:$VR},{76:[1,238]},{76:[1,239]},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,241],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:240,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:242,101:$VR},{5:[2,11]},{5:[2,12]},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,31:243,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:244,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:245,101:$VR},{13:[1,246]},o($V61,[2,132]),o($V61,[2,133]),{5:[2,47],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,53:247,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:213,96:214,99:66,101:$VR},{5:[2,48],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,53:248,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:213,96:214,99:66,101:$VR,103:$V11},{5:[2,113]},{5:[2,123],88:249,89:161,90:162,91:$V$,92:$V01},o($V51,[2,128],{99:66,96:214,65:215,95:250,6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,101:$VR}),o($V41,[2,134]),{76:[1,251],103:[1,252]},o($V91,[2,201]),{13:$VS,15:253,34:$VT,37:$VU,97:$VV,98:$VW},{13:$VS,15:254,34:$VT,37:$VU,97:$VV,98:$VW},{5:[2,115]},{5:[2,117],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:250,96:214,99:66,101:$VR},{5:[2,119],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:250,96:214,99:66,101:$VR},{5:[2,56]},{5:[2,57]},{5:[2,60]},{5:[2,62]},{13:[1,255]},{13:[1,256]},{6:$V0,7:$V1,9:$V2,10:257,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{13:[1,258]},{5:[2,73]},{5:[2,74]},{5:[2,75]},{5:[2,84]},{5:[2,85]},{5:[2,86]},{5:[2,98]},{5:[2,99]},{5:[2,100]},{34:[1,259]},{34:[1,260],37:[1,261]},o($V21,[2,206]),o($V21,[2,207]),o($V21,[2,208]),{5:[2,28]},{5:[2,144]},{5:[2,145]},{30:[1,262]},{5:[2,49],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:250,96:214,99:66,101:$VR},{5:[2,50],6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:215,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,95:250,96:214,99:66,101:$VR},{5:[2,124],88:263,89:161,90:162,91:$V$,92:$V01},o($V41,[2,135]),{13:$VS,15:264,34:$VT,37:$VU,97:$VV,98:$VW},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,266],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:265,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,99:66,101:$VR},o($V51,[2,129]),o($V41,[2,130]),{5:[2,64]},{5:[2,66]},o($V81,[2,211],{103:$V11}),{5:[2,68]},{77:[1,267]},{79:[1,268]},{79:[1,269]},{6:$V0,7:$V1,9:$V2,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,31:270,32:$Ve,33:$Vf,36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,62:$Vs,63:$Vt,64:$Vu,65:244,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:245,101:$VR},{5:[2,125]},o($V41,[2,136]),o($V91,[2,202]),o($V91,[2,203]),{76:[1,271]},{76:[1,272]},{76:[1,273]},{5:[2,30]},{13:[1,274]},{6:$V0,7:$V1,9:$V2,10:175,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,275],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,61:276,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{6:$V0,7:$V1,9:$V2,10:175,12:$V3,14:$V4,16:$V5,17:$V6,18:$V7,19:$V8,22:$V9,24:$Va,25:$Vb,26:$Vc,29:$Vd,32:$Ve,33:$Vf,34:[1,277],36:$Vg,37:$Vh,40:$Vi,42:$Vj,44:$Vk,45:$Vl,52:$Vm,54:$Vn,55:$Vo,56:$Vp,58:$Vq,59:$Vr,61:278,62:$Vs,63:$Vt,64:$Vu,65:63,66:$Vv,67:$Vw,68:$Vx,69:$Vy,70:$Vz,71:$VA,72:$VB,73:$VC,74:$VD,75:$VE,77:$VF,78:$VG,79:$VH,80:$VI,82:$VJ,83:$VK,85:$VL,86:$VM,87:$VN,91:$VO,92:$VP,94:$VQ,99:66,100:64,101:$VR},{5:[2,101]},{75:[1,279]},{75:[1,280],104:$V71},{75:[1,281]},{75:[1,282],104:$V71},{76:[1,283]},{76:[1,284]},{76:[1,285]},{76:[1,286]},{34:[1,287]},{34:[1,288]},{34:[1,289]},{34:[1,290]},{77:[1,291]},{77:[1,292]},{77:[1,293]},{77:[1,294]},{76:[1,295]},{76:[1,296]},{76:[1,297]},{76:[1,298]},{13:[1,299]},{13:[1,300]},{13:[1,301]},{13:[1,302]},{5:[2,102]},{5:[2,104]},{5:[2,103]},{5:[2,105]}], +defaultActions: {3:[2,2],4:[2,3],7:[2,8],10:[2,13],11:[2,14],12:[2,15],14:[2,18],15:[2,19],24:[2,32],25:[2,33],28:[2,39],32:[2,43],33:[2,44],34:[2,45],35:[2,46],37:[2,51],48:[2,69],56:[2,92],60:[2,1],61:[2,5],121:[2,10],124:[2,17],130:[2,20],133:[2,21],134:[2,22],135:[2,23],136:[2,25],137:[2,26],139:[2,29],141:[2,31],142:[2,35],143:[2,36],144:[2,38],145:[2,40],152:[2,52],153:[2,106],154:[2,107],155:[2,108],156:[2,209],157:[2,109],159:[2,112],179:[2,76],180:[2,77],181:[2,78],182:[2,79],184:[2,81],185:[2,82],190:[2,87],191:[2,88],193:[2,90],194:[2,91],195:[2,93],196:[2,94],197:[2,95],202:[2,11],203:[2,12],210:[2,113],218:[2,115],221:[2,56],222:[2,57],223:[2,60],224:[2,62],229:[2,73],230:[2,74],231:[2,75],232:[2,84],233:[2,85],234:[2,86],235:[2,98],236:[2,99],237:[2,100],243:[2,28],244:[2,144],245:[2,145],255:[2,64],256:[2,66],258:[2,68],263:[2,125],270:[2,30],274:[2,101],299:[2,102],300:[2,104],301:[2,103],302:[2,105]}, parseError: function parseError(str, hash) { if (hash.recoverable) { this.trace(str); @@ -92111,25 +93114,25 @@ case 3:return 41; break; case 4:return 34; break; -case 5:return 96; +case 5:return 97; break; -case 6:return 97; +case 6:return 98; break; -case 7:return 97; +case 7:return 98; break; case 8:return 8; break; case 9:return 6; break; -case 10:return 100; +case 10:return 101; break; case 11:return 7; break; case 12:return 9; break; -case 13:return 79; +case 13:return 80; break; -case 14:return 81; +case 14:return 82; break; case 15:return 12 break; @@ -92143,9 +93146,9 @@ case 19:return 18 break; case 20:return 19 break; -case 21:return 82 +case 21:return 83 break; -case 22:return 84 +case 22:return 85 break; case 23:return 22 break; @@ -92161,9 +93164,9 @@ case 28:return 33 break; case 29:return 32 break; -case 30:return 85 +case 30:return 86 break; -case 31:return 86 +case 31:return 87 break; case 32:return 36 break; @@ -92171,31 +93174,31 @@ case 33:return 40 break; case 34:return 42 break; -case 35:return 51 +case 35:return 52 break; -case 36:return 53 +case 36:return 54 break; -case 37:return 54 +case 37:return 55 break; -case 38:return 44 +case 38:return 45 break; -case 39:return 46 +case 39:return 47 break; -case 40:return 43 +case 40:return 44 break; -case 41:return 55 +case 41:return 56 break; -case 42:return 57; +case 42:return 58; break; -case 43:return 58 +case 43:return 43 break; -case 44:return 61 +case 44:return 59 break; case 45:return 62 break; case 46:return 63 break; -case 47:return 65 +case 47:return 64 break; case 48:return 66 break; @@ -92209,62 +93212,64 @@ case 52:return 70 break; case 53:return 71 break; -case 54:return 73 +case 54:return 72 break; -case 55:return 72 +case 55:return 74 break; -case 56:return 90 +case 56:return 73 break; -case 57:return 90 +case 57:return 91 break; case 58:return 91 break; -case 59:return 91 +case 59:return 92 break; -case 60:return 93 +case 60:return 92 break; -case 61:return 93 +case 61:return 94 break; -case 62:return 93 +case 62:return 94 break; -case 63:return 30 +case 63:return 94 break; -case 64:return 35 +case 64:return 30 break; -case 65:return 77 +case 65:return 35 break; -case 66:return 74 +case 66:return 78 break; -case 67:return 78 +case 67:return 75 break; -case 68:return 76 +case 68:return 79 break; -case 69:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 13; +case 69:return 77 break; -case 70:return 37; +case 70:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 13; break; -case 71:return 5; +case 71:return 37; break; -case 72:return 102; +case 72:return 5; break; case 73:return 103; break; -case 74:return '\\'; +case 74:return 104; +break; +case 75:return '\\'; break; -case 75:return 27 +case 76:return 27 break; -case 76:return 59 +case 77:return 60 break; -case 77:return 28 +case 78:return 28 break; -case 78:return 56 +case 79:return 57 break; -case 79:return 75 +case 80:return 76 break; } }, -rules: [/^(?:\s+)/i,/^(?:[#].*)/i,/^(?:\/\/.*)/i,/^(?:([_A-Z0-9\/\+]+==))/i,/^(?:-?[0-9]+(\.[0-9]+)?\b)/i,/^(?:0[xX][0-9A-F]+\b)/i,/^(?:false\b)/i,/^(?:true\b)/i,/^(?:all\b)/i,/^(?:reset\b)/i,/^(?:clear\b)/i,/^(?:build\b)/i,/^(?:help\b)/i,/^(?:load\b)/i,/^(?:script\b)/i,/^(?:get\b)/i,/^(?:set\b)/i,/^(?:set_save\b)/i,/^(?:set_restore\b)/i,/^(?:set_reset\b)/i,/^(?:preset\b)/i,/^(?:add\b)/i,/^(?:rep\b)/i,/^(?:remove\b)/i,/^(?:hide\b)/i,/^(?:show\b)/i,/^(?:list\b)/i,/^(?:select\b)/i,/^(?:within\b)/i,/^(?:selector\b)/i,/^(?:mode\b)/i,/^(?:color\b)/i,/^(?:material\b)/i,/^(?:view\b)/i,/^(?:unit\b)/i,/^(?:line\b)/i,/^(?:listobj\b)/i,/^(?:removeobj\b)/i,/^(?:rotate\b)/i,/^(?:translate\b)/i,/^(?:scale\b)/i,/^(?:url\b)/i,/^(?:screenshot\b)/i,/^(?:file_list\b)/i,/^(?:file_register\b)/i,/^(?:file_delete\b)/i,/^(?:preset_add\b)/i,/^(?:preset_delete\b)/i,/^(?:preset_update\b)/i,/^(?:preset_rename\b)/i,/^(?:preset_open\b)/i,/^(?:create_scenario\b)/i,/^(?:reset_scenario\b)/i,/^(?:delete_scenario\b)/i,/^(?:add_scenario_item\b)/i,/^(?:list_scenario\b)/i,/^(?:s\b)/i,/^(?:mt\b)/i,/^(?:m\b)/i,/^(?:c\b)/i,/^(?:x\b)/i,/^(?:y\b)/i,/^(?:z\b)/i,/^(?:as\b)/i,/^(?:of\b)/i,/^(?:pdb\b)/i,/^(?:delay\b)/i,/^(?:prst\b)/i,/^(?:desc\b)/i,/^(?:((?:"([^"]*)"|'([^']*)')))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:\.)/i,/^(?:\/)/i,/^(?:\\)/i,/^(?:-e\b)/i,/^(?:-f\b)/i,/^(?:-s\b)/i,/^(?:-v\b)/i,/^(?:=)/i], -conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79],"inclusive":true}} +rules: [/^(?:\s+)/i,/^(?:[#].*)/i,/^(?:\/\/.*)/i,/^(?:([_A-Z0-9\/\+]+==))/i,/^(?:-?[0-9]+(\.[0-9]+)?\b)/i,/^(?:0[xX][0-9A-F]+\b)/i,/^(?:false\b)/i,/^(?:true\b)/i,/^(?:all\b)/i,/^(?:reset\b)/i,/^(?:clear\b)/i,/^(?:build\b)/i,/^(?:help\b)/i,/^(?:load\b)/i,/^(?:script\b)/i,/^(?:get\b)/i,/^(?:set\b)/i,/^(?:set_save\b)/i,/^(?:set_restore\b)/i,/^(?:set_reset\b)/i,/^(?:preset\b)/i,/^(?:add\b)/i,/^(?:rep\b)/i,/^(?:remove\b)/i,/^(?:hide\b)/i,/^(?:show\b)/i,/^(?:list\b)/i,/^(?:select\b)/i,/^(?:within\b)/i,/^(?:selector\b)/i,/^(?:mode\b)/i,/^(?:color\b)/i,/^(?:material\b)/i,/^(?:view\b)/i,/^(?:unit\b)/i,/^(?:line\b)/i,/^(?:listobj\b)/i,/^(?:removeobj\b)/i,/^(?:rotate\b)/i,/^(?:translate\b)/i,/^(?:scale\b)/i,/^(?:url\b)/i,/^(?:screenshot\b)/i,/^(?:dssp\b)/i,/^(?:file_list\b)/i,/^(?:file_register\b)/i,/^(?:file_delete\b)/i,/^(?:preset_add\b)/i,/^(?:preset_delete\b)/i,/^(?:preset_update\b)/i,/^(?:preset_rename\b)/i,/^(?:preset_open\b)/i,/^(?:create_scenario\b)/i,/^(?:reset_scenario\b)/i,/^(?:delete_scenario\b)/i,/^(?:add_scenario_item\b)/i,/^(?:list_scenario\b)/i,/^(?:s\b)/i,/^(?:mt\b)/i,/^(?:m\b)/i,/^(?:c\b)/i,/^(?:x\b)/i,/^(?:y\b)/i,/^(?:z\b)/i,/^(?:as\b)/i,/^(?:of\b)/i,/^(?:pdb\b)/i,/^(?:delay\b)/i,/^(?:prst\b)/i,/^(?:desc\b)/i,/^(?:((?:"([^"]*)"|'([^']*)')))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:\.)/i,/^(?:\/)/i,/^(?:\\)/i,/^(?:-e\b)/i,/^(?:-f\b)/i,/^(?:-s\b)/i,/^(?:-v\b)/i,/^(?:=)/i], +conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80],"inclusive":true}} }); return lexer; })(); diff --git a/package.json b/package.json index baa0fe98..33275847 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "miew", - "version": "0.7.11", + "version": "0.7.12", "description": "Miew - 3D Molecular Viewer", "author": "EPAM Systems, Inc.", "main": "dist/Miew.js", diff --git a/sonar-project.properties b/sonar-project.properties index ca9870ab..20da1b35 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,6 @@ sonar.projectKey=epam:miew sonar.projectName=Miew - 3D Molecular Viewer -sonar.projectVersion=0.7.11 +sonar.projectVersion=0.7.12 sonar.links.homepage=https://github.com/epam/miew sonar.links.ci=https://travis-ci.org/epam/miew