diff --git a/CHANGELOG.md b/CHANGELOG.md index beb377c9..f4d92883 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.7.10] - 2017-12-25 +### Added +- Add more unit tests for loaders. +- Add WebVR stereo mode (still in PoC stage). + +### Changed +- Refactor loaders API and switch to the new way of loader auto detection. + - You may load electron density data by PDB ID using prefixed notation, e.g. "ccp4:3C9L" + (the full list of prefixes is pdb, cif, mmtf, ccp4). In the case the prefix is omitted, + it is a "pdb". + - Another prefix is "pc" (or "pubchem") which allows loading a compound from PubChem database, + e.g. "pc:serotonin". + - Otherwise, the source string is assumed to contain a URL, either absolute or relative to + the current page location. + +### Fixed +- Fix loading electron density presets from a server. + ## [0.7.9] - 2017-12-11 ### Added - Add an `ImmediateLoader` for loading structures from pre-fetched data. @@ -175,7 +193,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.9...HEAD +[Unreleased]: https://github.com/epam/miew/compare/v0.7.10...HEAD +[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 [0.7.8]: https://github.com/epam/miew/compare/v0.7.7...v0.7.8 [0.7.7+hotfix]: https://github.com/epam/miew/tree/v0.7.7+hotfix diff --git a/dist/Miew.js b/dist/Miew.js index b4678b67..af2c47df 100644 --- a/dist/Miew.js +++ b/dist/Miew.js @@ -1,4 +1,4 @@ -/** Miew - 3D Molecular Viewer v0.7.9 Copyright (c) 2015-2017 EPAM Systems, Inc. */ +/** Miew - 3D Molecular Viewer v0.7.10 Copyright (c) 2015-2017 EPAM Systems, Inc. */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : @@ -62051,6 +62051,21 @@ function getUrlParametersAsDict(url) { return result; } +function resolveURL(str) { + if (typeof URL !== 'undefined') { + if (typeof window !== 'undefined') { + return new URL(str, window.location).href; + } else { + return new URL(str).href; + } + } else if (typeof document !== 'undefined') { + var anchor = document.createElement('a'); + anchor.href = str; + return anchor.href; + } + return str; +} + /** * Generates regular expression object that includes all symbols * listed in the argument @@ -62307,6 +62322,12 @@ function getFileExtension(fileName) { return fileName.slice(Math.max(0, fileName.lastIndexOf('.')) || Infinity); } +function splitFileName(fileName) { + var ext = getFileExtension(fileName); + var name = fileName.slice(0, fileName.length - ext.length); + return [name, ext]; +} + function dataUrlToBlob(url) { var parts = url.split(/[:;,]/); var partsCount = parts.length; @@ -62370,6 +62391,45 @@ function correctSelectorIdentifier(value) { return enquoteHelper.join(''); } +function registerInList(list, value) { + if (!list.includes(value)) { + list.push(value); + } +} + +function unregisterFromList(list, value) { + var pos = list.indexOf(value); + if (pos !== -1) { + list.splice(pos, 1); + } +} + +function registerInDict(dict, keys, value) { + keys.forEach(function (key) { + key = key.toLowerCase(); + var list = dict[key] = dict[key] || []; + if (!list.includes(value)) { + list.push(value); + } + }); +} + +function unregisterFromDict(dict, keys, value) { + keys.forEach(function (key) { + key = key.toLowerCase(); + var list = dict[key]; + if (list) { + var pos = list.indexOf(value); + if (pos !== -1) { + list.splice(pos, 1); + } + if (list.length === 0) { + delete dict[key]; + } + } + }); +} + //////////////////////////////////////////////////////////////////////////// // Exports @@ -62379,6 +62439,7 @@ var utils = { decodeQueryComponent: decodeQueryComponent, getUrlParameters: getUrlParameters, getUrlParametersAsDict: getUrlParametersAsDict, + resolveURL: resolveURL, generateRegExp: generateRegExp, createElement: createElement$2, deriveClass: deriveClass, @@ -62400,7 +62461,8 @@ var utils = { copySubArrays: copySubArrays, shallowCloneNode: shallowCloneNode, correctSelectorIdentifier: correctSelectorIdentifier, - getFileExtension: getFileExtension + getFileExtension: getFileExtension, + splitFileName: splitFileName }; var now = utils.Timer.now; @@ -62470,29 +62532,188 @@ Stats.prototype = { }; -function JobHandle() { - EventDispatcher$1.call(this); +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; +} : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; +}; + + + + + + + + - this._cancellationRequested = false; -} -utils.deriveClass(JobHandle, EventDispatcher$1); -JobHandle.prototype.cancel = function () { - this._cancellationRequested = true; - this.dispatchEvent('cancel'); +var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } }; -JobHandle.prototype.isCancellationRequested = function () { - return this._cancellationRequested; +var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; +}(); + + + + + + + + + +var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }; -// slaves use this to notify master about their events -// master routes these notifications to a single event slot -JobHandle.prototype.notify = function (event) { - this.dispatchEvent({ type: 'notification', slaveEvent: event }); + + + + + + + + + + +var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; }; + + + + +var slicedToArray = function () { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + return function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; +}(); + + + + + + + + + + + + + +var toConsumableArray = function (arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + + return arr2; + } else { + return Array.from(arr); + } +}; + +var JobHandle = function (_EventDispatcher) { + inherits(JobHandle, _EventDispatcher); + + function JobHandle() { + classCallCheck(this, JobHandle); + + var _this = possibleConstructorReturn(this, (JobHandle.__proto__ || Object.getPrototypeOf(JobHandle)).call(this)); + + _this._shouldCancel = false; + return _this; + } + + createClass(JobHandle, [{ + key: 'cancel', + value: function cancel() { + this._shouldCancel = true; + this.dispatchEvent({ type: 'cancel' }); + } + }, { + key: 'shouldCancel', + value: function shouldCancel() { + return this._shouldCancel; + } + + // slaves use this to notify master about their events + // master routes these notifications to a single event slot + + }, { + key: 'notify', + value: function notify(event) { + this.dispatchEvent({ type: 'notification', slaveEvent: event }); + } + }]); + return JobHandle; +}(EventDispatcher$1); + var VERSION = 0; ////////////////////////////////////////////////////////////////////////// @@ -62514,7 +62735,7 @@ var VERSION = 0; * @alias SettingsObject * @namespace */ -var defaults = { +var defaults$1 = { /** * Default options for all available modes. * Use {@link Mode.id} as a dictionary key to access mode options. @@ -63310,7 +63531,7 @@ function Settings() { Settings.prototype = { constructor: Settings, - defaults: defaults, + defaults: defaults$1, set: function set(path, value) { lodash.set(this.now, path, value); @@ -63322,7 +63543,7 @@ Settings.prototype = { }, reset: function reset() { - this.now = lodash.cloneDeep(defaults); + this.now = lodash.cloneDeep(defaults$1); this.old = null; this._changed = {}; }, @@ -63363,7 +63584,7 @@ Settings.prototype = { }, getDiffs: function getDiffs(versioned) { - var diffs = utils.objectsDiff(this.now, defaults); + var diffs = utils.objectsDiff(this.now, defaults$1); if (versioned) { diffs.VERSION = VERSION; } @@ -63371,123 +63592,13 @@ Settings.prototype = { }, setPluginOpts: function setPluginOpts(plugin, opts) { - defaults.plugins[plugin] = lodash.cloneDeep(opts); + defaults$1.plugins[plugin] = lodash.cloneDeep(opts); this.now.plugins[plugin] = lodash.cloneDeep(opts); } }; var settings = new Settings(); -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; -} : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; -}; - - - - - - - - - - - -var classCallCheck = function (instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } -}; - -var createClass = function () { - function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps); - if (staticProps) defineProperties(Constructor, staticProps); - return Constructor; - }; -}(); - - - - - - - - - -var inherits = function (subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - enumerable: false, - writable: true, - configurable: true - } - }); - if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; -}; - - - - - - - - - - - -var possibleConstructorReturn = function (self, call) { - if (!self) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return call && (typeof call === "object" || typeof call === "function") ? call : self; -}; - - - - - - - - - - - - - - - - - - - -var toConsumableArray = function (arr) { - if (Array.isArray(arr)) { - for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; - - return arr2; - } else { - return Array.from(arr); - } -}; - var repIndex = 0; function asBoolean(value) { @@ -63607,13 +63718,13 @@ function extractArgs(input, defaultsDict, params) { var args = input.substr(bang + 1).split(cLSep); input = inputVal; if (defaultsDict) { - var defaults = defaultsDict[input]; - var opts = utils.deriveDeep(defaults, true); + var defaults$$1 = defaultsDict[input]; + var opts = utils.deriveDeep(defaults$$1, 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, key))]; + var adapter = adapters[_typeof(lodash.get(defaults$$1, key))]; if (adapter) { lodash.set(opts, key, adapter(value)); } else { @@ -75344,7 +75455,7 @@ var geometries = { LabelsGeometry: LabelsGeometry }; -var UberObject = function (SuperClass) { +function UberObject (SuperClass) { function NewObjectType() { SuperClass.apply(this, arguments); this.onBeforeRender = NewObjectType.prototype.onBeforeRender; @@ -75372,7 +75483,7 @@ var UberObject = function (SuperClass) { }; return NewObjectType; -}; +} var Mesh$1 = UberObject(Mesh); @@ -81734,6 +81845,77 @@ GfxProfiler.prototype.min = function () { return this._prof ? this._prof.min() : 0.0; }; +var LoaderList = function () { + function LoaderList() { + var _this = this; + + var someLoaders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + classCallCheck(this, LoaderList); + + this._list = []; + this._byType = {}; + + someLoaders.forEach(function (SomeLoader) { + return _this.register(SomeLoader); + }); + } + + /** + * Register a parser for a specific data format. + * + * @param {function} SomeLoader - a Parser subclass to register + * @param {string[]} SomeLoader.types - supported data formats + */ + + + createClass(LoaderList, [{ + key: 'register', + value: function register(SomeLoader) { + registerInList(this._list, SomeLoader); + registerInDict(this._byType, SomeLoader.types, SomeLoader); + } + }, { + key: 'unregister', + value: function unregister(SomeLoader) { + unregisterFromList(this._list, SomeLoader); + unregisterFromDict(this._byType, SomeLoader.types, SomeLoader); + } + }, { + key: 'find', + + + /** + * Find a suitable loader for the data source + * + * @param {object} specs - parser specifications + * @param {string=} specs.type - supported source type + * @param {data=} specs.source - source to load from + */ + value: function find(specs) { + var list = []; + if (specs.type) { + list = this._byType[specs.type.toLowerCase()] || []; + } else if (specs.source) { + return this._list.filter(function (SomeLoader) { + return SomeLoader.canProbablyLoad && SomeLoader.canProbablyLoad(specs.source); + }); + } + return [].concat(toConsumableArray(list)); + } + }, { + key: 'all', + get: function get$$1() { + return [].concat(toConsumableArray(this._list)); + } + }, { + key: 'types', + get: function get$$1() { + return Object.keys(this._byType); + } + }]); + return LoaderList; +}(); + var Loader$1 = function (_EventDispatcher) { inherits(Loader, _EventDispatcher); @@ -81744,6 +81926,7 @@ var Loader$1 = function (_EventDispatcher) { _this._source = source; _this._options = options || {}; + _this._abort = false; _this._agent = null; return _this; } @@ -81754,6 +81937,9 @@ var Loader$1 = function (_EventDispatcher) { if (callbacks) { return this._loadOLD(callbacks); } + if (this._abort) { + return Promise.reject(new Error('Loading aborted')); + } return this.loadAsync(); } @@ -81788,10 +81974,16 @@ var Loader$1 = function (_EventDispatcher) { }, { key: 'abort', value: function abort() { + this._abort = true; if (this._agent) { this._agent.abort(); } } + }], [{ + key: 'extractName', + value: function extractName(_source) { + return undefined; + } }]); return Loader; }(EventDispatcher$1); @@ -81807,9 +81999,6 @@ var FileLoader$1 = function (_Loader) { var _this = possibleConstructorReturn(this, (FileLoader.__proto__ || Object.getPrototypeOf(FileLoader)).call(this, source, options)); options = _this._options; - if (!options.fileName) { - options.fileName = source.name; - } _this._binary = options.binary === true; return _this; } @@ -81843,16 +82032,34 @@ var FileLoader$1 = function (_Loader) { } }); } + + /** @deprecated */ + }], [{ key: 'canLoad', value: function canLoad(source, options) { var sourceType = options.sourceType; return source instanceof File && (!sourceType || sourceType === 'file'); } + }, { + key: 'canProbablyLoad', + value: function canProbablyLoad(source) { + return File && source instanceof File || Blob && source instanceof Blob; + } + }, { + key: 'extractName', + value: function extractName(source) { + return source && source.name; + } }]); return FileLoader; }(Loader$1); +FileLoader$1.types = ['file', 'blob']; + +// we don't need to detect all kinds of URLs, just the evident ones +var urlStartRegexp = /^(https?|ftp):\/\//i; + var XHRLoader$1 = function (_Loader) { inherits(XHRLoader, _Loader); @@ -81862,13 +82069,6 @@ var XHRLoader$1 = function (_Loader) { var _this = possibleConstructorReturn(this, (XHRLoader.__proto__ || Object.getPrototypeOf(XHRLoader)).call(this, source, options)); options = _this._options; - if (!options.fileName) { - var last = source.indexOf('?'); - if (last === -1) { - last = source.length; - } - options.fileName = source.slice(source.lastIndexOf('/') + 1, last); - } _this._binary = options.binary === true; return _this; } @@ -81908,16 +82108,35 @@ var XHRLoader$1 = function (_Loader) { request.send(); }); } + + /** @deprecated */ + }], [{ key: 'canLoad', value: function canLoad(source, options) { var sourceType = options.sourceType; return typeof source === 'string' && (!sourceType || sourceType === 'url'); } + }, { + key: 'canProbablyLoad', + value: function canProbablyLoad(source) { + return lodash.isString(source) && urlStartRegexp.test(source); + } + }, { + key: 'extractName', + value: function extractName(source) { + if (source) { + var last = (source.indexOf('?') + 1 || source.lastIndexOf('#') + 1 || source.length + 1) - 1; + return source.slice(source.lastIndexOf('/', last) + 1, last); + } + return undefined; + } }]); return XHRLoader; }(Loader$1); +XHRLoader$1.types = ['url']; + var ImmediateLoader = function (_Loader) { inherits(ImmediateLoader, _Loader); @@ -81931,92 +82150,28 @@ var ImmediateLoader = function (_Loader) { value: function loadAsync() { return Promise.resolve(this._source); } + + /** @deprecated */ + }], [{ key: 'canLoad', value: function canLoad(source, options) { return typeof source !== 'undefined' && typeof options !== 'undefined' && options.sourceType === 'immediate'; } + }, { + key: 'canProbablyLoad', + value: function canProbablyLoad(_source) { + return false; + } }]); return ImmediateLoader; }(Loader$1); -/** - * Loaders list. - * @module io/loaders - */ -// FIXME: deps for amdclean - -var loaderList = []; -var ag$3 = [FileLoader$1, XHRLoader$1, ImmediateLoader]; - -(function (plugins) { - for (var i = 0, n = plugins.length; i < n; ++i) { - var currLoader = plugins[i]; - loaderList.push(currLoader); - } -})(ag$3); - -// NOTE: workaround for https://github.com/gfranko/amdclean/issues/115 -var exports$3 = /** @alias module:io/loaders */{ - /** - * The list of loader constructor functions available. - * @type {Array} - */ - list: loaderList, - - Loader: Loader$1, +ImmediateLoader.types = ['immediate']; - /** - * Create a loader instance. - * @param {object} context - Current context. - * @param {object} source - Data to be loaded. - * @param {object} options - Loader options object overriding defaults. - * @returns {Loader} New loader object. - */ - create: function create(context, source, options) { - var loader = new Loader$1(source, options); // this behaviour was copied from the previous version - var i = 0, - n = loaderList.length; - for (; i < n; ++i) { - var SomeLoader = loaderList[i]; - if (SomeLoader.canLoad && SomeLoader.canLoad(source, options)) { - loader = new SomeLoader(source, options); - break; - } - } - loader.context = context; - if (i === n) { - loader.logger.error('Could not select a suitable Loader.'); - } - return loader; - } -}; - -function registerIn(dict, keys, value) { - keys.forEach(function (key) { - key = key.toLowerCase(); - var list = dict[key] = dict[key] || []; - if (!list.includes(value)) { - list.push(value); - } - }); -} - -function unregisterFrom(dict, keys, value) { - keys.forEach(function (key) { - key = key.toLowerCase(); - var list = dict[key]; - if (list) { - var pos = list.indexOf(value); - if (pos !== -1) { - list.splice(pos, 1); - } - if (list.length === 0) { - delete dict[key]; - } - } - }); -} +var loaders = new LoaderList([ +// note: order might be important +FileLoader$1, XHRLoader$1, ImmediateLoader]); var ParserList = function () { function ParserList() { @@ -82044,26 +82199,21 @@ var ParserList = function () { createClass(ParserList, [{ - key: "register", + key: 'register', value: function register(SomeParser) { - if (!this._list.includes(SomeParser)) { - this._list.push(SomeParser); - } - registerIn(this._byFormat, SomeParser.formats, SomeParser); - registerIn(this._byExt, SomeParser.extensions, SomeParser); + registerInList(this._list, SomeParser); + registerInDict(this._byFormat, SomeParser.formats, SomeParser); + registerInDict(this._byExt, SomeParser.extensions, SomeParser); } }, { - key: "unregister", + key: 'unregister', value: function unregister(SomeParser) { - var pos = this._list.indexOf(SomeParser); - if (pos !== -1) { - this._list.splice(pos, 1); - } - unregisterFrom(this._byFormat, SomeParser.formats, SomeParser); - unregisterFrom(this._byExt, SomeParser.extensions, SomeParser); + unregisterFromList(this._list, SomeParser); + unregisterFromDict(this._byFormat, SomeParser.formats, SomeParser); + unregisterFromDict(this._byExt, SomeParser.extensions, SomeParser); } }, { - key: "find", + key: 'find', /** @@ -82090,17 +82240,17 @@ var ParserList = function () { return [].concat(toConsumableArray(list)); } }, { - key: "all", + key: 'all', get: function get$$1() { return [].concat(toConsumableArray(this._list)); } }, { - key: "formats", + key: 'formats', get: function get$$1() { return Object.keys(this._byFormat); } }, { - key: "extensions", + key: 'extensions', get: function get$$1() { return Object.keys(this._byExt); } @@ -82113,7 +82263,7 @@ var Parser = function () { classCallCheck(this, Parser); this._data = data; - this._options = options; + this._options = options || {}; this._abort = false; } @@ -82413,7 +82563,7 @@ function PDBParser(data, options) { this._molecule = null; this._compndCurrToken = ''; - options.fileType = 'pdb'; + this._options.fileType = 'pdb'; } //////////////////////////////////////////////////////////////////////////// @@ -82872,7 +83022,7 @@ function CMLParser(data, options) { this._lastMolId = -1; this._readOnlyOneMolecule = false; - options.fileType = 'cml'; + this._options.fileType = 'cml'; } //////////////////////////////////////////////////////////////////////////// @@ -83578,7 +83728,7 @@ ArrayComparator.prototype.compare = function (candidate) { function MMTFParser(data, options) { Parser.call(this, data, options); - options.fileType = 'mmtf'; + this._options.fileType = 'mmtf'; } //////////////////////////////////////////////////////////////////////////// @@ -83965,6 +84115,7 @@ MMTFParser.prototype.parseSync = function () { MMTFParser.formats = ['mmtf']; MMTFParser.extensions = ['.mmtf']; +MMTFParser.binary = true; var Complex$5 = chem.Complex; var Element$6 = chem.Element; @@ -84023,7 +84174,7 @@ function CIFParser(data, options) { Parser.call(this, data, options); this.asymDict = {}; this.molecules = []; - options.fileType = 'cif'; + this._options.fileType = 'cif'; } //////////////////////////////////////////////////////////////////////////// @@ -84956,7 +85107,7 @@ Ccp4Model.prototype.toXYZData = function () { function CCP4Parser(data, options) { Parser.call(this, data, options); - options.fileType = 'ccp4'; + this._options.fileType = 'ccp4'; } //////////////////////////////////////////////////////////////////////////// @@ -84987,13 +85138,14 @@ CCP4Parser.prototype.parseSync = function () { CCP4Parser.formats = ['ccp4']; CCP4Parser.extensions = ['.ccp4']; +CCP4Parser.binary = true; var Complex$6 = chem.Complex; var Element$7 = chem.Element; function PubChemParser(data, options) { Parser.call(this, data, options); - options.fileType = 'pubchem+json'; + this._options.fileType = 'pubchem+json'; } //////////////////////////////////////////////////////////////////////////// @@ -85086,7 +85238,7 @@ var parsers = new ParserList([ PDBParser, CIFParser, MMTFParser, CMLParser, PubChemParser, CCP4Parser]); var io = { - loaders: exports$3, + loaders: loaders, parsers: parsers }; @@ -87407,7 +87559,111 @@ Cookies.prototype._exists = function (key) { return document.cookie.match(new RegExp('(?:^|; )' + key + '=([^;]*)')); }; -/* global "0.7.9":false */ +/******* + * Toggling WebVR is done through button.click because of limitations on calling requestPresent in webVR: + * VRDisplay::requestPresent should be called from user gesture: + * https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/requestPresent + */ +var WEBVR = function () { + function WEBVR() { + classCallCheck(this, WEBVR); + } + + createClass(WEBVR, null, [{ + key: 'createButton', + value: function createButton(renderer) { + function showEnterVR(display, button) { + + button.style.display = ''; + button.style.cursor = 'pointer'; + button.style.left = 'calc(50% - 50px)'; + button.style.width = '100px'; + + button.textContent = 'ENTER VR'; + + button.onmouseenter = function () { + button.style.opacity = '1.0'; + }; + button.onmouseleave = function () { + button.style.opacity = '0.5'; + }; + + button.onclick = function () { + if (display.isPresenting) { + display.exitPresent(); + } else { + display.requestPresent([{ source: renderer.domElement }]); + } + }; + renderer.vr.setDevice(display); + } + + function showVRNotFound(button) { + + button.style.display = ''; + button.style.cursor = 'auto'; + button.style.left = 'calc(50% - 75px)'; + button.style.width = '150px'; + button.textContent = 'VR NOT FOUND'; + button.onmouseenter = null; + button.onmouseleave = null; + button.onclick = null; + + renderer.vr.setDevice(null); + } + + function stylizeElement(element) { + element.style.position = 'absolute'; + element.style.bottom = '20px'; + element.style.padding = '12px 6px'; + element.style.border = '1px solid #fff'; + element.style.borderRadius = '4px'; + element.style.background = 'transparent'; + element.style.color = '#fff'; + element.style.font = 'normal 13px sans-serif'; + element.style.textAlign = 'center'; + element.style.opacity = '0.5'; + element.style.outline = 'none'; + element.style.zIndex = '999'; + } + + if ('getVRDisplays' in navigator) { + var button = document.createElement('button'); + button.style.display = 'none'; + stylizeElement(button); + window.addEventListener('vrdisplayconnect', function (event) { + showEnterVR(event.display, button); + }, false); + window.addEventListener('vrdisplaydisconnect', function (_event) { + showVRNotFound(button); + }, false); + window.addEventListener('vrdisplaypresentchange', function (event) { + button.textContent = event.display.isPresenting ? 'EXIT VR' : 'ENTER VR'; + }, false); + navigator.getVRDisplays().then(function (displays) { + if (displays.length > 0) { + showEnterVR(displays[0], button); + } else { + showVRNotFound(button); + } + }); + return button; + } else { + var message = document.createElement('a'); + message.href = 'https://webvr.info'; + message.innerHTML = 'WEBVR NOT SUPPORTED'; + message.style.left = 'calc(50% - 90px)'; + message.style.width = '180px'; + message.style.textDecoration = 'none'; + stylizeElement(message); + return message; + } + } + }]); + return WEBVR; +}(); + +/* global "0.7.10":false */ ////////////////////////////////////////////////////////////////////////////// @@ -87436,25 +87692,6 @@ function removeExtension(fileName) { return fileName; } -function normalizeSource(source) { - // special translation for local data files - if (typeof source === 'string') { - if (source.match(/^[0-9A-Z]{4}$/i)) { - // normalize if PDBID - source = source.toUpperCase(); - } else if (source.match(/^data\/[0-9A-Z]{4}\.pdb$/i)) { - // extract PDBID for cached files - source = source.substr(5, 4).toUpperCase(); - } else { - // otherwise use neat hack to restore the full url (https://gist.github.com/jlong/2428561) - var ref = document.createElement('a'); - ref.href = source; - source = ref.href; - } - } - return source; -} - function hasValidResidues(complex) { var hasValidRes = false; complex.forEachComponent(function (component) { @@ -87469,7 +87706,7 @@ function hasValidResidues(complex) { function reportProgress(log, action, percent) { var TOTAL_PERCENT = 100; - if (percent) { + if (percent !== undefined) { log.debug(action + '... ' + Math.floor(percent * TOTAL_PERCENT) + '%'); } else { log.debug(action + '...'); @@ -87536,8 +87773,8 @@ function Miew$1(opts) { /** @type {?Spinner} */ this._spinner = null; - /** @type {?Loader} */ - this._loader = null; + /** @type {JobHandle[]} */ + this._loading = []; /** @type {?number} */ this._animInterval = null; @@ -87554,8 +87791,8 @@ function Miew$1(opts) { // TODO make this being not so ugly - this._fileSource = null; - this._fileSourceAnim = null; + this._srvTopoSource = null; + this._srvAnimSource = null; this.reset(); @@ -87677,10 +87914,10 @@ Miew$1.prototype.init = function () { */ Miew$1.prototype.term = function () { this._showMessage('Viewer has been terminated.'); - if (this._loader) { - this._loader.cancel(); - this._loader = null; - } + this._loading.forEach(function (job) { + job.cancel(); + }); + this._loading.length = 0; this.halt(); this._gfx = null; }; @@ -87853,6 +88090,8 @@ Miew$1.prototype._initGfx = function () { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat, depthBuffer: false }); + this._toggleWebVR(settings.now.stereo === 'WEBVR', gfx); + this._gfx = gfx; this._showCanvas(); @@ -88076,6 +88315,8 @@ Miew$1.prototype.setCurrentVisual = function (name) { * @see Miew#halt */ Miew$1.prototype.run = function () { + var _this = this; + if (!this._running) { this._running = true; if (this._halting) { @@ -88085,9 +88326,9 @@ Miew$1.prototype.run = function () { this._objectControls.enable(true); - var self = this; - requestAnimationFrame(function _onAnimationFrame() { - self._onTick(); + var device = this._getWebVRDevice(); + (device || window).requestAnimationFrame(function () { + return _this._onTick(); }); } }; @@ -88165,6 +88406,8 @@ Miew$1.prototype._resizeOffscreenBuffers = function (width, height, stereo) { * @private */ Miew$1.prototype._onTick = function () { + var _this2 = this; + if (this._halting) { this._running = false; this._halting = false; @@ -88173,18 +88416,70 @@ Miew$1.prototype._onTick = function () { this._fps.update(); - var self = this; - requestAnimationFrame(function _onAnimationFrame() { - self._onTick(); + var device = this._getWebVRDevice(); + (device || window).requestAnimationFrame(function () { + return _this2._onTick(); }); this._onUpdate(); if (this._needRender) { this._onRender(); - this._needRender = !settings.now.suspendRender; + this._needRender = !settings.now.suspendRender || settings.now.stereo === 'WEBVR' || !!device; } }; +/** + * Turn the WebVR when it is supported + * NOTE: we toggle using button.click, because VRDisplay.requestPresent should be called from user gesture + */ +Miew$1.prototype._toggleWebVR = function () { + + var _mainCamera = new PerspectiveCamera(); + var _cameraWasStored = false; + var _webVRButton = null; + + return function (enable, gfx) { + var self = this; + var renderer = gfx ? gfx.renderer : null; + if (!renderer) { + throw new Error('No renderer is available to toggle WebVR'); + } else if (!gfx.camera) { + throw new Error('No camera is available to toggle WebVR'); + } + + if (enable) { + // store common camera + _mainCamera.copy(gfx.camera); + _cameraWasStored = true; + // enable vr in renderer + renderer.vr.enabled = true; + if (!_webVRButton) { + _webVRButton = WEBVR.createButton(renderer); + document.body.appendChild(_webVRButton); + } else { + _webVRButton.style.display = 'block'; + } + } else { + //disable vr + renderer.vr.enabled = false; + if (_webVRButton) { + _webVRButton.style.display = 'none'; + } + // restore common camera + if (_cameraWasStored) { + gfx.camera.copy(_mainCamera); + self._onResize(); + } + } + self._needRender = true; + }; +}(); + +Miew$1.prototype._getWebVRDevice = function () { + var vr = this._gfx.renderer.vr; + return vr && vr.enabled ? vr.getDevice() : null; +}; + Miew$1.prototype._getBSphereRadius = function () { // calculate radius that would include all visuals var radius = 0; @@ -88221,11 +88516,11 @@ Miew$1.prototype._onUpdate = function () { visual.getComplex().update(); }); - if (settings.now.autobuild && !this._loader && !this._building && this._needRebuild()) { + if (settings.now.autobuild && !this._loading.length && !this._building && this._needRebuild()) { this.rebuild(); } - if (!this._loader && !this._building && !this._needRebuild()) { + if (!this._loading.length && !this._building && !this._needRebuild()) { this._updateView(); } @@ -88270,6 +88565,7 @@ Miew$1.prototype._renderFrame = function () { this._resizeOffscreenBuffers(size.width * window.devicePixelRatio, size.height * window.devicePixelRatio, stereo); switch (stereo) { + case 'WEBVR': case 'NONE': this._renderScene(gfx.camera, false); break; @@ -88299,7 +88595,7 @@ Miew$1.prototype._renderFrame = function () { gfx.renderer2d.render(gfx.scene, gfx.camera); - if (settings.now.axes && gfx.axes) { + if (settings.now.axes && gfx.axes && !gfx.renderer.vr.enabled) { gfx.axes.render(renderer); } }; @@ -88342,6 +88638,10 @@ Miew$1.prototype._renderScene = function () { // render to offscreen buffer gfx.renderer.setClearColor(settings.now.themes[settings.now.theme], 1); gfx.renderer.clearTarget(target); + if (gfx.renderer.vr.enabled) { + gfx.renderer.render(gfx.scene, camera); + return; + } gfx.renderer.clearTarget(gfx.offscreenBuf); // FIXME clean up targets in render selection @@ -88744,55 +89044,61 @@ Miew$1.prototype.resetView = function () { * @returns {Promise} name of the visual that was added to the viewer */ Miew$1.prototype.load = function (source, opts) { - var self = this; + var _this3 = this; - if (self._loader) { - self._loader.cancel(); - } + opts = lodash.merge({}, opts, { + context: this + }); - self.dispatchEvent({ type: 'load', options: opts }); + // for a single-file scenario + if (!this.settings.now.use.multiFile) { - // remember file sources - if (source instanceof File && source.name.match(/.man$/i)) { - this._fileSourceAnim = normalizeSource(source); - } else { - this._fileSource = normalizeSource(source); - } - if (opts && opts.mdFile) { - this._fileSourceAnim = opts.mdFile; - } + // abort all loaders in progress + if (this._loading.length) { + this._loading.forEach(function (job) { + job.cancel(); + }); + this._loading.length = 0; + } - if (!this.settings.now.use.multiFile && !(opts && opts.animation)) { - this.reset(true); + // reset + if (!opts.animation) { + // FIXME: sometimes it is set AFTERWARDS! + this.reset(true); + } } - self._loader = new JobHandle(); - self._loader.addEventListener('notification', function (e) { - self.dispatchEvent(e.slaveEvent); + this.dispatchEvent({ type: 'load', options: opts, source: source }); + + var job = new JobHandle(); + this._loading.push(job); + job.addEventListener('notification', function (e) { + _this3.dispatchEvent(e.slaveEvent); }); - self._spinner.spin(this._container); + this._spinner.spin(this._container); - var onLoadEnd = function onLoadEnd(res) { - self._loader = null; - self._spinner.stop(); - self._refreshTitle(); - return res; + var onLoadEnd = function onLoadEnd(anything) { + var jobIndex = _this3._loading.indexOf(job); + if (jobIndex !== -1) { + _this3._loading.splice(jobIndex, 1); + } + _this3._spinner.stop(); + _this3._refreshTitle(); + return anything; }; - return _fetchData(source, opts, self._loader, self).then(function (res) { - return _convertData(res.data, res.opts, res.master); - }).then(function (res) { - return _parseData(res.data, res.opts, res.master, self); - }).then(function (res) { - return self._onLoad(res.data, res.opts); - }).then(function (res) { - return onLoadEnd(res); + return _fetchData(source, opts, job).then(function (data) { + return _convertData(data, opts, job); + }).then(function (data) { + return _parseData(data, opts, job); + }).then(function (object) { + var name = _this3._onLoad(object, opts); + return onLoadEnd(name); }).catch(function (err) { - onLoadEnd(); - self.logger.error('Could not load data'); - self.logger.debug(err); - throw err; + _this3.logger.error('Could not load data'); + _this3.logger.debug(err); + throw onLoadEnd(err); }); }; @@ -88930,7 +89236,7 @@ Miew$1.prototype._stopAnimation = function () { this._frameInfo.disableEvents(); this._frameInfo = null; this._animInterval = null; - this._fileSourceAnim = null; + this._srvAnimSource = null; this.dispatchEvent({ type: 'mdPlayerStateChanged', state: null @@ -89058,30 +89364,32 @@ Miew$1.prototype.resetEd = function () { this._needRender = true; }; -Miew$1.prototype.loadEd = function (file) { - var self = this; +Miew$1.prototype.loadEd = function (source) { + var _this4 = this; this.resetEd(); - var loader = this._edLoader = io.loaders.create(self, file, { binary: true }); + var TheLoader = lodash.head(io.loaders.find({ source: source })); + if (!TheLoader) { + this.logger.error('Could not find suitable loader for this source'); + return Promise.reject(new Error('Could not find suitable loader for this source')); + } - loader.load({ - ready: function ready(data) { - var parser = io.parsers.create(self, data, { fileType: 'ccp4' }); - parser.parse({ - ready: function ready(dataSource) { - self._onLoadEd(dataSource); - }, - progress: function progress(percent) { - // TODO: Update progress bar - reportProgress(self.logger, 'Parsing ED', percent); - } - }); - }, - progress: function progress(percent) { - // TODO: Update progress bar - reportProgress(self.logger, 'Loading ED', percent); + var loader = this._edLoader = new TheLoader(source, { binary: true }); + loader.context = this; + return loader.load().then(function (data) { + var TheParser = lodash.head(io.parsers.find({ format: 'ccp4' })); + if (!TheParser) { + throw new Error('Could not find suitable parser for this source'); } + var parser = new TheParser(data); + parser.context = _this4; + return parser.parse().then(function (dataSource) { + _this4._onLoadEd(dataSource); + }); + }).catch(function (error) { + _this4.logger.error('Could not load ED data'); + _this4.logger.debug(error); }); }; @@ -89223,7 +89531,7 @@ Miew$1.prototype.setNeedRender = function () { }; Miew$1.prototype._extractRepresentation = function () { - var _this = this; + var _this5 = this; var changed = []; @@ -89241,7 +89549,7 @@ Miew$1.prototype._extractRepresentation = function () { }); if (idx < 0) { if (visual.repCount() === ComplexVisual.NUM_REPRESENTATION_BITS) { - _this.logger.warn('Number of representations is limited to ' + ComplexVisual.NUM_REPRESENTATION_BITS); + _this5.logger.warn('Number of representations is limited to ' + ComplexVisual.NUM_REPRESENTATION_BITS); } return; } @@ -90366,6 +90674,9 @@ Miew$1.prototype._onSettingsChanged = function (changes) { if (changes.autoResolution && !this._gfxScore) { this.logger.warn('Benchmarks are missed, autoresolution will not work! ' + 'Autoresolution should be set during miew startup.'); } + if (changes.stereo) { + this._toggleWebVR(changes.stereo === 'WEBVR', this._gfx); + } this._needRender = true; }; @@ -90613,67 +90924,138 @@ Miew$1.prototype.projected = function (fullAtomName, complexName) { }; }; -// FIXME: rewrite the function, it looks a little bit ugly -function _fetchData(file, opts, master, context) { - return new Promise(function (resolve, reject) { - opts = opts || {}; // TODO: clone - if (file instanceof File && file.name.match(/.man$/i)) { - opts.binary = true; - opts.animation = true; - } - - if (file instanceof File && (file.name.match(/.mmtf$/i) || file.name.match(/.ccp4$/i))) { - opts.binary = true; - } else if (lodash.isString(file) && file.match(/.mmtf$/i)) { - opts.binary = true; - } - - // convert PDB ID to URL - if (!opts.mdFile && !opts.fileType && typeof file === 'string') { - - var matched = file.match(/^(?:\s*([+\w]+)\s*:)?\s*(.*)$/); - if (matched) { - var id = matched[2].trim(); - var type = matched[1]; - switch (type) { - case 'pubchem': - case 'pubchem+json': - type = 'pubchem+json'; - file = 'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/' + encodeURIComponent(id) + '/JSON?record_type=3d'; - opts.sourceType = 'url'; - opts.fileName = id + '.json'; - break; - default: - if (id.match(/^\w{4}$/i)) { - type = type || 'pdb'; - switch (type) { - case 'mmtf': - file = 'http://mmtf.rcsb.org/v1.0/full/' + id; - opts.sourceType = 'url'; - break; - case 'cif': - case 'pdb': - file = 'http://files.rcsb.org/view/' + id + '.' + type; - opts.sourceType = 'url'; - break; - default: - } - } else { - type = undefined; - } - } +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; - if (type) { - opts.fileType = type; - } - } +function resolveSourceShortcut(source, opts) { + if (!lodash.isString(source)) { + return source; + } + + // e.g. "mmtf:1CRN" + var matchesPdbId = rePdbId.exec(source); + if (matchesPdbId) { + var _matchesPdbId = slicedToArray(matchesPdbId, 3), + _matchesPdbId$ = _matchesPdbId[1], + format = _matchesPdbId$ === undefined ? 'pdb' : _matchesPdbId$, + id = _matchesPdbId[2]; + + format = format.toLowerCase(); + id = id.toUpperCase(); + + switch (format) { + case 'pdb': + source = 'http://files.rcsb.org/download/' + id + '.pdb'; + break; + case 'cif': + source = 'http://files.rcsb.org/download/' + id + '.cif'; + break; + case 'mmtf': + source = 'http://mmtf.rcsb.org/v1.0/full/' + id; + break; + case 'ccp4': + source = 'https://www.ebi.ac.uk/pdbe/coordinates/files/' + id.toLowerCase() + '.ccp4'; + break; + default: + throw new Error('Unexpected data format shortcut'); } - if (opts.fileType === 'mmtf') { - opts.binary = true; + opts.fileType = format; + opts.fileName = id + '.' + format; + opts.sourceType = 'url'; + return source; + } + + // e.g. "pc:aspirin" + var matchesPubchem = rePubchem.exec(source); + if (matchesPubchem) { + var compound = matchesPubchem[1].toLowerCase(); + source = 'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/' + compound + '/JSON?record_type=3d'; + opts.fileType = 'pubchem'; + opts.fileName = compound + '.json'; + opts.sourceType = 'url'; + return source; + } + + // otherwise is should be an URL + if (opts.sourceType === 'url' || opts.sourceType === undefined) { + opts.sourceType = 'url'; + + // e.g. "./data/1CRN.pdb" + if (!reUrlScheme.test(source)) { + source = utils.resolveURL(source); } + } - var loader = io.loaders.create(context, file, opts); + return source; +} + +function updateBinaryMode(opts) { + var binary = opts.binary; + + // detect by format + if (opts.fileType !== undefined) { + var TheParser = lodash.head(io.parsers.find({ format: opts.fileType })); + if (TheParser) { + binary = TheParser.binary || false; + } else { + throw new Error('Could not find suitable parser for this format'); + } + } + + // detect by file extension + if (binary === undefined && opts.fileExt !== undefined) { + var _TheParser = lodash.head(io.parsers.find({ ext: opts.fileExt })); + if (_TheParser) { + binary = _TheParser.binary || false; + } + } + + // temporary workaround for animation + if (opts.fileExt !== undefined && opts.fileExt.toLowerCase() === '.man') { + opts.binary = true; + opts.animation = true; // who cares? + } + + // update if detected + if (binary !== undefined) { + if (opts.binary !== undefined && opts.binary !== binary) { + opts.context.logger.warn('Overriding incorrect binary mode'); + } + } + + opts.binary = binary || false; +} + +function _fetchData(source, opts, job) { + return new Promise(function (resolve) { + if (job.shouldCancel()) { + throw new Error('Operation cancelled'); + } + + // allow for source shortcuts + source = resolveSourceShortcut(source, opts); + + // detect a proper loader + var TheLoader = lodash.head(io.loaders.find({ type: opts.sourceType, source: source })); + if (!TheLoader) { + throw new Error('Could not find suitable loader for this source'); + } + + // split file name + var fileName = opts.fileName || TheLoader.extractName(source); + if (fileName) { + var _utils$splitFileName = utils.splitFileName(fileName), + _utils$splitFileName2 = slicedToArray(_utils$splitFileName, 2), + name = _utils$splitFileName2[0], + fileExt = _utils$splitFileName2[1]; + + lodash.defaults(opts, { name: name, fileExt: fileExt, fileName: fileName }); + } + + // should it be text or binary? + updateBinaryMode(opts); // FIXME: All new settings retrieved from server are applied after the loading is complete. However, we need some // flags to alter the loading process itself. Here we apply them in advance. Dirty hack. Kill the server, remove @@ -90693,41 +91075,47 @@ function _fetchData(file, opts, master, context) { } } - if (master) { - master.addEventListener('cancel', function () { - loader.abort(); - }); - if (master.isCancellationRequested()) { - loader.abort(); - } - } + // create a loader + var loader = new TheLoader(source, opts); + loader.context = opts.context; + job.addEventListener('cancel', function () { + return loader.abort(); + }); - console.time('load'); - loader.load({ - ready: function ready(data) { - console.timeEnd('load'); - context.logger.info('Loading finished'); - resolve({ data: data, opts: opts, master: master }); - }, - error: function error(err) { - console.timeEnd('load'); - context.logger.error('Loading failed'); - reject(err); - }, - progress: function progress(percent) { - reportProgress(loader.logger, 'Loading', percent); + loader.addEventListener('progress', function (event) { + if (event.lengthComputable && event.total > 0) { + reportProgress(loader.logger, 'Fetching', event.loaded / event.total); + } else { + reportProgress(loader.logger, 'Fetching'); } }); + + console.time('fetch'); + var promise = loader.load().then(function (data) { + console.timeEnd('fetch'); + opts.context.logger.info('Fetching finished'); + job.notify({ type: 'fetchingFinished', data: data }); + return data; + }).catch(function (error) { + console.timeEnd('fetch'); + opts.context.logger.debug(error.message); + if (error.stack) { + opts.context.logger.debug(error.stack); + } + opts.context.logger.error('Fetching failed'); + job.notify({ type: 'fetchingFinished', error: error }); + throw error; + }); + resolve(promise); }); } -function _convertData(data, opts, master) { +function _convertData(data, opts, job) { return new Promise(function (resolve, reject) { - if (master) { - master.notify({ type: 'convert' }); + if (job.shouldCancel()) { + throw new Error('Operation cancelled'); } - - opts = opts || {}; + job.notify({ type: 'convert' }); if (opts.mdFile) { var byteNumbers = new Array(data.length); @@ -90745,74 +91133,54 @@ function _convertData(data, opts, master) { opts.convertedFile = new File([bytes], opts.fileName); opts.fileName = null; opts.fileType = 'pdb'; - if (master) { - master.notify({ type: 'convertingFinished' }); - } - resolve({ data: newData, opts: opts, master: master }); + job.notify({ type: 'convertingFinished' }); + resolve(newData); } else { opts.converted = false; logger.error(message); opts.error = message; - if (master) { - master.notify({ type: 'convertingFinished', error: message }); - } + job.notify({ type: 'convertingFinished', error: message }); reject(new Error(message)); } }); } else { opts.converted = true; - resolve({ data: data, opts: opts, master: master }); + resolve(data); } }); } -function _parseData(data, opts, master, context) { - if (master) { - master.notify({ type: 'parse' }); +function _parseData(data, opts, job) { + if (job.shouldCancel()) { + return Promise.reject(new Error('Operation cancelled')); } + job.notify({ type: 'parse' }); - opts = opts || {}; // TODO: clone - - var TheParser = lodash.head(io.parsers.find({ - format: opts.fileType, - ext: utils.getFileExtension(opts.fileName || ''), - data: data - })); - + var TheParser = lodash.head(io.parsers.find({ format: opts.fileType, ext: opts.fileExt, data: data })); if (!TheParser) { return Promise.reject(new Error('Could not find suitable parser')); } var parser = new TheParser(data, opts); - parser.context = context; - - if (master) { - master.addEventListener('cancel', function () { - parser.abort(); - }); - if (master.isCancellationRequested()) { - return Promise.reject(); - } - } + parser.context = opts.context; + job.addEventListener('cancel', function () { + return parser.abort(); + }); console.time('parse'); return parser.parse().then(function (dataSet) { console.timeEnd('parse'); - if (master) { - master.notify({ type: 'parsingFinished', data: dataSet }); - } - return { data: dataSet, opts: opts, master: master }; + job.notify({ type: 'parsingFinished', data: dataSet }); + return dataSet; }).catch(function (error) { console.timeEnd('parse'); opts.error = error; - context.logger.debug(error.message); + opts.context.logger.debug(error.message); if (error.stack) { - context.logger.debug(error.stack); - } - context.logger.error('Parsing failed'); - if (master) { - master.notify({ type: 'parsingFinished', error: error }); + opts.context.logger.debug(error.stack); } + opts.context.logger.error('Parsing failed'); + job.notify({ type: 'parsingFinished', error: error }); throw error; }); } @@ -90820,7 +91188,7 @@ function _parseData(data, opts, master, context) { //////////////////////////////////////////////////////////////////////////// // Additional exports -Miew$1.prototype.VERSION = typeof "0.7.9" !== 'undefined' && "0.7.9" || '0.0.0-dev'; +Miew$1.prototype.VERSION = typeof "0.7.10" !== 'undefined' && "0.7.10" || '0.0.0-dev'; // Miew.prototype.debugTracer = new utils.DebugTracer(Miew.prototype); lodash.assign(Miew$1, /** @lends Miew */{ diff --git a/dist/Miew.min.js b/dist/Miew.min.js index 1654d7ed..d2730bd6 100644 --- a/dist/Miew.min.js +++ b/dist/Miew.min.js @@ -1,9 +1,9 @@ -/** Miew - 3D Molecular Viewer v0.7.9 Copyright (c) 2015-2017 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";function t(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function e(t,e){return e={exports:{}},t(e,e.exports),e.exports}function r(){}function n(t,e){this.x=t||0,this.y=e||0}function i(t,e,r,o,a,s,c,l,u,h){Object.defineProperty(this,"id",{value:bh++}),this.uuid=xh.generateUUID(),this.name="",this.image=void 0!==t?t:i.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:i.DEFAULT_MAPPING,this.wrapS=void 0!==r?r:Su,this.wrapT=void 0!==o?o:Su,this.magFilter=void 0!==a?a:Tu,this.minFilter=void 0!==s?s:Lu,this.anisotropy=void 0!==u?u:1,this.format=void 0!==c?c:Hu,this.type=void 0!==l?l:Ru,this.offset=new n(0,0),this.repeat=new n(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==h?h:hh,this.version=0,this.onUpdate=null}function o(t,e,r,n){this.x=t||0,this.y=e||0,this.z=r||0,this.w=void 0!==n?n:1}function a(t,e,r){this.uuid=xh.generateUUID(),this.width=t,this.height=e,this.scissor=new o(0,0,t,e),this.scissorTest=!1,this.viewport=new o(0,0,t,e),void 0===(r=r||{}).minFilter&&(r.minFilter=Tu),this.texture=new i(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 s(t,e,r){a.call(this,t,e,r),this.activeCubeFace=0,this.activeMipMapLevel=0}function c(t,e,r,n){this._x=t||0,this._y=e||0,this._z=r||0,this._w=void 0!==n?n:1}function l(t,e,r){this.x=t||0,this.y=e||0,this.z=r||0}function u(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length}function h(t,e,r,n,o,a,s,c,l,u,h,p){i.call(this,null,a,s,c,l,u,n,o,h,p),this.image={data:t,width:e,height:r},this.magFilter=void 0!==l?l:Au,this.minFilter=void 0!==u?u:Au,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function p(t,e,r,n,o,a,s,c,l,u){i.call(this,t=void 0!==t?t:[],e=void 0!==e?e:mu,r,n,o,a,s,c,l,u),this.flipY=!1}function f(){this.seq=[],this.map={}}function d(t,e,r){var n=t[0];if(n<=0||n>0)return t;var i=e*r,o=Mh[i];if(void 0===o&&(o=new Float32Array(i),Mh[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 m(t,e){var r=Ah[e];void 0===r&&(r=new Int32Array(e),Ah[e]=r);for(var n=0;n!==e;++n)r[n]=t.allocTextureUnit();return r}function g(t,e){t.uniform1f(this.addr,e)}function v(t,e){t.uniform1i(this.addr,e)}function y(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function x(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 b(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function w(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function S(t,e){void 0===e.elements?t.uniformMatrix3fv(this.addr,!1,e):(Ch.set(e.elements),t.uniformMatrix3fv(this.addr,!1,Ch))}function M(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(Eh.set(e.elements),t.uniformMatrix4fv(this.addr,!1,Eh))}function A(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTexture2D(e||wh,n)}function E(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTextureCube(e||Sh,n)}function C(t,e){t.uniform2iv(this.addr,e)}function T(t,e){t.uniform3iv(this.addr,e)}function P(t,e){t.uniform4iv(this.addr,e)}function L(t,e){t.uniform1fv(this.addr,e)}function R(t,e){t.uniform1iv(this.addr,e)}function N(t,e){t.uniform2fv(this.addr,d(e,this.size,2))}function I(t,e){t.uniform3fv(this.addr,d(e,this.size,3))}function O(t,e){t.uniform4fv(this.addr,d(e,this.size,4))}function D(t,e){t.uniformMatrix2fv(this.addr,!1,d(e,this.size,4))}function F(t,e){t.uniformMatrix3fv(this.addr,!1,d(e,this.size,9))}function z(t,e){t.uniformMatrix4fv(this.addr,!1,d(e,this.size,16))}function k(t,e,r){var n=e.length,i=m(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTexture2D(e[o]||wh,i[o])}function U(t,e,r){var n=e.length,i=m(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTextureCube(e[o]||Sh,i[o])}function B(t,e,r){this.id=t,this.addr=r,this.setValue=function(t){switch(t){case 5126:return g;case 35664:return y;case 35665:return x;case 35666:return b;case 35674:return w;case 35675:return S;case 35676:return M;case 35678:case 36198:return A;case 35680:return E;case 5124:case 35670:return v;case 35667:case 35671:return C;case 35668:case 35672:return T;case 35669:case 35673:return P}}(e.type)}function V(t,e,r){this.id=t,this.addr=r,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return L;case 35664:return N;case 35665:return I;case 35666:return O;case 35674:return D;case 35675:return F;case 35676:return z;case 35678:return k;case 35680:return U;case 5124:case 35670:return R;case 35667:case 35671:return C;case 35668:case 35672:return T;case 35669:case 35673:return P}}(e.type)}function j(t){this.id=t,f.call(this)}function G(t,e){t.seq.push(e),t.map[e.id]=e}function W(t,e,r){var n=t.name,i=n.length;for(Th.lastIndex=0;;){var o=Th.exec(n),a=Th.lastIndex,s=o[1],c="]"===o[2],l=o[3];if(c&&(s|=0),void 0===l||"["===l&&a+2===i){G(r,void 0===l?new B(s,t,e):new V(s,t,e));break}var u=r.map[s];void 0===u&&G(r,u=new j(s)),r=u}}function H(t,e,r){f.call(this),this.renderer=r;for(var n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),i=0;i.001&&R.scale>.001&&(S.x=R.x,S.y=R.y,S.z=R.z,b=R.size*R.scale/g.w,w.x=b*y,w.y=b,e.uniform3f(f.screenPosition,S.x,S.y,S.z),e.uniform2f(f.scale,w.x,w.y),e.uniform1f(f.rotation,R.rotation),e.uniform1f(f.opacity,R.opacity),e.uniform3f(f.color,R.color.r,R.color.g,R.color.b),r.setBlending(R.blending,R.blendEquation,R.blendSrc,R.blendDst),i.setTexture2D(R.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 $(t,e,r,n,o,a,s,c,l){i.call(this,t,e,r,n,o,a,s,c,l),this.needsUpdate=!0}function Z(t,e,r,n,i){function o(){var t=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),r=new Uint16Array([0,1,2,0,2,3]);s=e.createBuffer(),u=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u),e.bufferData(e.ELEMENT_ARRAY_BUFFER,r,e.STATIC_DRAW),h=function(){var t=e.createProgram(),r=e.createShader(e.VERTEX_SHADER),n=e.createShader(e.FRAGMENT_SHADER);return 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),t}(),p={position:e.getAttribLocation(h,"position"),uv:e.getAttribLocation(h,"uv")},f={uvOffset:e.getUniformLocation(h,"uvOffset"),uvScale:e.getUniformLocation(h,"uvScale"),rotation:e.getUniformLocation(h,"rotation"),scale:e.getUniformLocation(h,"scale"),color:e.getUniformLocation(h,"color"),map:e.getUniformLocation(h,"map"),opacity:e.getUniformLocation(h,"opacity"),modelViewMatrix:e.getUniformLocation(h,"modelViewMatrix"),projectionMatrix:e.getUniformLocation(h,"projectionMatrix"),fogType:e.getUniformLocation(h,"fogType"),fogDensity:e.getUniformLocation(h,"fogDensity"),fogNear:e.getUniformLocation(h,"fogNear"),fogFar:e.getUniformLocation(h,"fogFar"),fogColor:e.getUniformLocation(h,"fogColor"),alphaTest:e.getUniformLocation(h,"alphaTest")};var n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");n.width=8,n.height=8;var o=n.getContext("2d");o.fillStyle="white",o.fillRect(0,0,8,8),d=new $(n)}function a(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}var s,u,h,p,f,d,m=new l,g=new c,v=new l;this.render=function(i,c,l){if(0!==i.length){void 0===h&&o(),r.useProgram(h),r.initAttributes(),r.enableAttribute(p.position),r.enableAttribute(p.uv),r.disableUnusedAttributes(),r.disable(e.CULL_FACE),r.enable(e.BLEND),e.bindBuffer(e.ARRAY_BUFFER,s),e.vertexAttribPointer(p.position,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(p.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u),e.uniformMatrix4fv(f.projectionMatrix,!1,l.projectionMatrix.elements),r.activeTexture(e.TEXTURE0),e.uniform1i(f.map,0);var y=0,_=0,x=c.fog;x?(e.uniform3f(f.fogColor,x.color.r,x.color.g,x.color.b),x.isFog?(e.uniform1f(f.fogNear,x.near),e.uniform1f(f.fogFar,x.far),e.uniform1i(f.fogType,1),y=1,_=1):x.isFogExp2&&(e.uniform1f(f.fogDensity,x.density),e.uniform1i(f.fogType,2),y=2,_=2)):(e.uniform1i(f.fogType,0),y=0,_=0);for(var b=0,w=i.length;b0:s&&s.isGeometry&&(h=s.morphTargets&&s.morphTargets.length>0)),e.isSkinnedMesh&&r.skinning;var p=e.isSkinnedMesh&&r.skinning,f=0;h&&(f|=g),p&&(f|=v),c=l[f]}if(t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var d=c.uuid,m=r.uuid,y=b[d];void 0===y&&(y={},b[d]=y);var w=y[m];void 0===w&&(w=c.clone(),y[m]=w),c=w}c.visible=r.visible,c.wireframe=r.wireframe;var S=r.side;return L.renderSingleSided&&S==Cl&&(S=Al),L.renderReverseSided&&(S===Al?S=El:S===El&&(S=Al)),c.side=S,c.clipShadows=r.clipShadows,c.clippingPlanes=r.clippingPlanes,c.clipIntersection=r.clipIntersection,c.wireframeLinewidth=r.wireframeLinewidth,c.linewidth=r.linewidth,n&&c.isMeshDistanceMaterial&&(c.referencePosition.copy(i),c.nearDistance=o,c.farDistance=a),c}function s(r,n,o,a){if(!1!==r.visible){if(r.layers.test(n.layers)&&(r.isMesh||r.isLine||r.isPoints)&&r.castShadow&&(!r.frustumCulled||c.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,r.matrixWorld);var l=e.update(r),u=r.material;if(Array.isArray(u))for(var h=l.groups,p=0,f=h.length;pe&&(e=t[r]);return e}function Pt(){Object.defineProperty(this,"id",{value:mt()}),this.uuid=xh.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 Lt(t,e,r,n,i,o){gt.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:o},this.fromBufferGeometry(new Rt(t,e,r,n,i,o)),this.mergeVertices()}function Rt(t,e,r,n,i,o){function a(t,e,r,n,i,o,a,m,g,v,y){var _,x,b=o/g,w=a/v,S=o/2,M=a/2,A=m/2,E=g+1,C=v+1,T=0,P=0,L=new l;for(x=0;x0?1:-1,h.push(L.x,L.y,L.z),p.push(_/g),p.push(1-x/v),T+=1}}for(x=0;x1&&r.sort(Ut),n.length>1&&n.sort(Bt)}}},t[n]=i),i},dispose:function(){t={}}}}function jt(t,e){return Math.abs(e[1])-Math.abs(t[1])}function Gt(){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 l,color:new X,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n};break;case"SpotLight":r={position:new l,direction:new l,color:new X,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n};break;case"PointLight":r={position:new l,color:new X,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":r={direction:new l,skyColor:new X,groundColor:new X};break;case"RectAreaLight":r={color:new X,position:new l,halfWidth:new l,halfHeight:new l}}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 l,i=new u,o=new u;return{setup:function(n,a,s){for(var c=0,l=0,u=0,h=0,p=0,f=0,d=0,m=0,g=s.matrixWorldInverse,v=0,y=n.length;v/gm,function(t,e){var r=Nh[e];if(void 0===r)throw new Error("Can not resolve #include <"+e+">");return $t(r)})}function Zt(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,v=function(t,e,r){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.normalMap||e.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(t.fragDepth||e.logarithmicDepthBuffer)&&r.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",t.drawBuffers&&r.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(t.shaderTextureLOD||e.envMap)&&r.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Yt).join("\n")}(n.extensions,o,e),y=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),_=a.createProgram();n.isRawShaderMaterial?(d=[y,"\n"].filter(Yt).join("\n"),m=[v,y,"\n"].filter(Yt).join("\n")):(d=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,y,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#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(Yt).join("\n"),m=[v,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,y,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+g,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!==uu?"#define TONE_MAPPING":"",o.toneMapping!==uu?Nh.tonemapping_pars_fragment:"",o.toneMapping!==uu?function(t,e){var r;switch(e){case hu:r="Linear";break;case pu:r="Reinhard";break;case fu:r="Uncharted2";break;case du: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?Nh.encodings_pars_fragment:"",o.mapEncoding?Xt("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?Xt("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?Xt("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?function(t,e){var r=Ht(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+r[0]+r[1]+"; }"}("linearToOutputTexel",o.outputEncoding):"",o.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Yt).join("\n")),c=qt(c=$t(c),o),l=qt(l=$t(l),o),n.isShaderMaterial||(c=Zt(c),l=Zt(l));var x=d+c,b=m+l,w=Wt(a,a.VERTEX_SHADER,x),S=Wt(a,a.FRAGMENT_SHADER,b);a.attachShader(_,w),a.attachShader(_,S),void 0!==n.index0AttributeName?a.bindAttribLocation(_,0,n.index0AttributeName):!0===o.morphTargets&&a.bindAttribLocation(_,0,"position"),a.linkProgram(_);var M=a.getProgramInfoLog(_),A=a.getShaderInfoLog(w),E=a.getShaderInfoLog(S),C=!0,T=!0;!1===a.getProgramParameter(_,a.LINK_STATUS)?C=!1:""!==M||""!==A&&""!==E||(T=!1),T&&(this.diagnostics={runnable:C,material:n,programLog:M,vertexShader:{log:A,prefix:d},fragmentShader:{log:E,prefix:m}}),a.deleteShader(w),a.deleteShader(S);var P;this.getUniforms=function(){return void 0===P&&(P=new H(a,_,t)),P};var L;return this.getAttributes=function(){return void 0===L&&(L=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:i.directional.length,numPointLights:i.point.length,numSpotLights:i.spot.length,numRectAreaLights:i.rectArea.length,numHemiLights:i.hemi.length,numClippingPlanes:c,numClipIntersection:l,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&u.receiveShadow&&a.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===Cl,flipSided:e.side===El,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 o=0;oe||t.height>e){var r=e/Math.max(t.width,t.height),n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");n.width=Math.floor(t.width*r),n.height=Math.floor(t.height*r);return n.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,n.width,n.height),n}return t}function c(t){return xh.isPowerOfTwo(t.width)&&xh.isPowerOfTwo(t.height)}function l(t,e){return t.generateMipmaps&&e&&t.minFilter!==Au&&t.minFilter!==Tu}function u(e){return e===Au||e===Eu||e===Cu?t.NEAREST:t.LINEAR}function h(e){var r=e.target;r.removeEventListener("dispose",h),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 p(e){var r=e.target;r.removeEventListener("dispose",p),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,u){var p=n.get(e);if(e.version>0&&p.__version!==e.version){var f=e.image;if(void 0===f);else if(!1!==f.complete)return void function(e,n,u){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",h),e.__webglTexture=t.createTexture(),a.textures++);r.activeTexture(t.TEXTURE0+u),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 p=s(n.image,i.maxTextureSize);(function(t){return t.wrapS!==Su||t.wrapT!==Su||t.minFilter!==Au&&t.minFilter!==Tu})(n)&&!1===c(p)&&(p=function(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=xh.nearestPowerOfTwo(t.width),e.height=xh.nearestPowerOfTwo(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),e}return t}(p));var f=c(p),m=o.convert(n.format),g=o.convert(n.type);d(t.TEXTURE_2D,n,f);var v,_=n.mipmaps;if(n.isDepthTexture){var x=t.DEPTH_COMPONENT;if(n.type===zu){if(!y)throw new Error("Float Depth Texture only supported in WebGL2.0");x=t.DEPTH_COMPONENT32F}else y&&(x=t.DEPTH_COMPONENT16);n.format===$u&&x===t.DEPTH_COMPONENT&&n.type!==Ou&&n.type!==Fu&&(n.type=Ou,g=o.convert(n.type)),n.format===Zu&&(x=t.DEPTH_STENCIL,n.type!==ju&&(n.type=ju,g=o.convert(n.type))),r.texImage2D(t.TEXTURE_2D,0,x,p.width,p.height,0,m,g,null)}else if(n.isDataTexture)if(_.length>0&&f){for(var b=0,w=_.length;b-1&&r.compressedTexImage2D(t.TEXTURE_2D,b,m,v.width,v.height,0,v.data):r.texImage2D(t.TEXTURE_2D,b,m,v.width,v.height,0,m,g,v.data);else if(_.length>0&&f){for(var b=0,w=_.length;b1||n.get(a).__currentAnisotropy)&&(t.texParameterf(r,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),n.get(a).__currentAnisotropy=a.anisotropy)}}function m(e,i,a,s){var c=o.convert(i.texture.format),l=o.convert(i.texture.type);r.texImage2D(s,0,c,i.width,i.height,0,c,l,null),t.bindFramebuffer(t.FRAMEBUFFER,e),t.framebufferTexture2D(t.FRAMEBUFFER,a,s,n.get(i.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function g(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 v(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===$u)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,i,0);else{if(r.depthTexture.format!==Zu)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(),g(r.__webglDepthbuffer[o],e)}else t.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=t.createRenderbuffer(),g(r.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}var y="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext;this.setTexture2D=f,this.setTextureCube=function(e,u){var p=n.get(e);if(6===e.image.length)if(e.version>0&&p.__version!==e.version){p.__image__webglTextureCube||(e.addEventListener("dispose",h),p.__image__webglTextureCube=t.createTexture(),a.textures++),r.activeTexture(t.TEXTURE0+u),r.bindTexture(t.TEXTURE_CUBE_MAP,p.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var f=e&&e.isCompressedTexture,m=e.image[0]&&e.image[0].isDataTexture,g=[],v=0;v<6;v++)g[v]=f||m?m?e.image[v].image:e.image[v]:s(e.image[v],i.maxCubemapSize);var y=c(g[0]),_=o.convert(e.format),x=o.convert(e.type);for(d(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 m?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]);l(e,y)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),p.__version=e.version,e.onUpdate&&e.onUpdate(e)}else r.activeTexture(t.TEXTURE0+u),r.bindTexture(t.TEXTURE_CUBE_MAP,p.__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",p),o.__webglTexture=t.createTexture(),a.textures++;var s=!0===e.isWebGLRenderTargetCube,u=c(e);if(s)for(i.__webglFramebuffer=[],h=0;h<6;h++)i.__webglFramebuffer[h]=t.createFramebuffer();else i.__webglFramebuffer=t.createFramebuffer();if(s){r.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),d(t.TEXTURE_CUBE_MAP,e.texture,u);for(var h=0;h<6;h++)m(i.__webglFramebuffer[h],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+h);l(e.texture,u)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),r.bindTexture(t.TEXTURE_CUBE_MAP,null)}else r.bindTexture(t.TEXTURE_2D,o.__webglTexture),d(t.TEXTURE_2D,e.texture,u),m(i.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),l(e.texture,u)&&t.generateMipmap(t.TEXTURE_2D),r.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&v(e)},this.updateRenderTargetMipmap=function(e){var i=e.texture;if(l(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 te(t){ft.call(this),this.cameras=t||[]}function ee(t,e){return{convert:function(r){var n;if(r===wu)return t.REPEAT;if(r===Su)return t.CLAMP_TO_EDGE;if(r===Mu)return t.MIRRORED_REPEAT;if(r===Au)return t.NEAREST;if(r===Eu)return t.NEAREST_MIPMAP_NEAREST;if(r===Cu)return t.NEAREST_MIPMAP_LINEAR;if(r===Tu)return t.LINEAR;if(r===Pu)return t.LINEAR_MIPMAP_NEAREST;if(r===Lu)return t.LINEAR_MIPMAP_LINEAR;if(r===Ru)return t.UNSIGNED_BYTE;if(r===Uu)return t.UNSIGNED_SHORT_4_4_4_4;if(r===Bu)return t.UNSIGNED_SHORT_5_5_5_1;if(r===Vu)return t.UNSIGNED_SHORT_5_6_5;if(r===Nu)return t.BYTE;if(r===Iu)return t.SHORT;if(r===Ou)return t.UNSIGNED_SHORT;if(r===Du)return t.INT;if(r===Fu)return t.UNSIGNED_INT;if(r===zu)return t.FLOAT;if(r===ku&&null!==(n=e.get("OES_texture_half_float")))return n.HALF_FLOAT_OES;if(r===Gu)return t.ALPHA;if(r===Wu)return t.RGB;if(r===Hu)return t.RGBA;if(r===Xu)return t.LUMINANCE;if(r===Yu)return t.LUMINANCE_ALPHA;if(r===$u)return t.DEPTH_COMPONENT;if(r===Zu)return t.DEPTH_STENCIL;if(r===zl)return t.FUNC_ADD;if(r===kl)return t.FUNC_SUBTRACT;if(r===Ul)return t.FUNC_REVERSE_SUBTRACT;if(r===jl)return t.ZERO;if(r===Gl)return t.ONE;if(r===Wl)return t.SRC_COLOR;if(r===Hl)return t.ONE_MINUS_SRC_COLOR;if(r===Xl)return t.SRC_ALPHA;if(r===Yl)return t.ONE_MINUS_SRC_ALPHA;if(r===ql)return t.DST_ALPHA;if(r===$l)return t.ONE_MINUS_DST_ALPHA;if(r===Zl)return t.DST_COLOR;if(r===Kl)return t.ONE_MINUS_DST_COLOR;if(r===Ql)return t.SRC_ALPHA_SATURATE;if((r===Ku||r===Qu||r===Ju||r===th)&&null!==(n=e.get("WEBGL_compressed_texture_s3tc"))){if(r===Ku)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===Qu)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===Ju)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===th)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((r===eh||r===rh||r===nh||r===ih)&&null!==(n=e.get("WEBGL_compressed_texture_pvrtc"))){if(r===eh)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===rh)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===nh)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===ih)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(r===oh&&null!==(n=e.get("WEBGL_compressed_texture_etc1")))return n.COMPRESSED_RGB_ETC1_WEBGL;if((r===Bl||r===Vl)&&null!==(n=e.get("EXT_blend_minmax"))){if(r===Bl)return n.MIN_EXT;if(r===Vl)return n.MAX_EXT}return r===ju&&null!==(n=e.get("WEBGL_depth_texture"))?n.UNSIGNED_INT_24_8_WEBGL:0}}}function re(t){function e(){return null===D?K:1}function r(){(_t=new function(t){var e={};return{get:function(r){if(void 0!==e[r])return e[r];var n;switch(r){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":n=t.getExtension("WEBGL_compressed_texture_etc1");break;default:n=t.getExtension(r)}return e[r]=n,n}}}(vt)).get("WEBGL_depth_texture"),_t.get("OES_texture_float"),_t.get("OES_texture_float_linear"),_t.get("OES_texture_half_float"),_t.get("OES_texture_half_float_linear"),_t.get("OES_standard_derivatives"),_t.get("ANGLE_instanced_arrays"),_t.get("OES_element_index_uint")&&(Pt.MaxIndex=4294967296),Yt=new ee(vt,_t),xt=new function(t,e,r){function n(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&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 i,o=void 0!==r.precision?r.precision:"highp",a=n(o);a!==o&&(o=a);var s=!0===r.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),l=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=l>0,v=!!e.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==i)return i;var r=e.get("EXT_texture_filter_anisotropic");return i=null!==r?t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:n,precision:o,logarithmicDepthBuffer:s,maxTextures:c,maxVertexTextures:l,maxTextureSize:u,maxCubemapSize:h,maxAttributes:p,maxVertexUniforms:f,maxVaryings:d,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v}}(vt,_t,t),(bt=new function(t,e,r){function n(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;a=1,k=null,U={},B=new o,V=new o,j={};return j[t.TEXTURE_2D]=n(t.TEXTURE_2D,t.TEXTURE_2D,1),j[t.TEXTURE_CUBE_MAP]=n(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),p.setClear(0,0,0,1),f.setClear(1),d.setClear(0),i(t.DEPTH_TEST),f.setFunc(ru),c(!1),l(xl),i(t.CULL_FACE),i(t.BLEND),s(Nl),{buffers:{color:p,depth:f,stencil:d},initAttributes:function(){for(var t=0,e=g.length;t65535?Mt:wt)(i,1),e.update(n,t.ELEMENT_ARRAY_BUFFER),o[r.id]=n,n}}}(vt,Et,mt),Lt=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={}}}}(Ct,gt),Ut=new function(t){var e={},r=new Float32Array(8);return{update:function(n,i,o,a){var s=n.morphTargetInfluences,c=s.length,l=e[i.id];if(void 0===l){for(l=[],p=0;p=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(var p=0;p=0&&t.numSupportedMorphNormals++}var f=n.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=ct.numPlanes,n.numIntersection=ct.numIntersection,f.clippingPlanes=ct.uniform),n.fog=e,n.lightsHash=Nt.state.hash,t.lights&&(f.ambientLightColor.value=Nt.state.ambient,f.directionalLights.value=Nt.state.directional,f.spotLights.value=Nt.state.spot,f.rectAreaLights.value=Nt.state.rectArea,f.pointLights.value=Nt.state.point,f.hemisphereLights.value=Nt.state.hemi,f.directionalShadowMap.value=Nt.state.directionalShadowMap,f.directionalShadowMatrix.value=Nt.state.directionalShadowMatrix,f.spotShadowMap.value=Nt.state.spotShadowMap,f.spotShadowMatrix.value=Nt.state.spotShadowMatrix,f.pointShadowMap.value=Nt.state.pointShadowMap,f.pointShadowMatrix.value=Nt.state.pointShadowMatrix);var d=n.program.getUniforms(),m=H.seqWithValue(d.seq,f);n.uniformsList=m}function g(t,e,r,n){W=0;var i=St.get(r);if(lt&&(ut||t!==U)){var o=t===U&&r.id===z;ct.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!==Nt.state.hash?r.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===ct.numPlanes&&i.numIntersection===ct.numIntersection||(r.needsUpdate=!0)),r.needsUpdate&&(m(r,e,n),r.needsUpdate=!1);var a=!1,s=!1,c=!1,l=i.program,u=l.getUniforms(),p=i.shader.uniforms;if(bt.useProgram(l.program)&&(a=!0,s=!0,c=!0),r.id!==z&&(z=r.id,s=!0),a||t!==U){if(u.setValue(vt,"projectionMatrix",t.projectionMatrix),xt.logarithmicDepthBuffer&&u.setValue(vt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),U!==(B||t)&&(U=B||t,s=!0,c=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var f=u.map.cameraPosition;void 0!==f&&f.setValue(vt,dt.setFromMatrixPosition(t.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&u.setValue(vt,"viewMatrix",t.matrixWorldInverse)}if(r.skinning){u.setOptional(vt,n,"bindMatrix"),u.setOptional(vt,n,"bindMatrixInverse");var d=n.skeleton;if(d){var g=d.bones;if(xt.floatVertexTextures){if(void 0===d.boneTexture){var x=Math.sqrt(4*g.length);x=xh.nextPowerOfTwo(Math.ceil(x)),x=Math.max(x,4);var b=new Float32Array(x*x*4);b.set(d.boneMatrices);var w=new h(b,x,x,Hu,zu);d.boneMatrices=b,d.boneTexture=w,d.boneTextureSize=x}u.setValue(vt,"boneTexture",d.boneTexture),u.setValue(vt,"boneTextureSize",d.boneTextureSize)}else u.setOptional(vt,d,"boneMatrices")}}return(s||r.forceUniformsUpdate)&&(u.setValue(vt,"toneMappingExposure",I.toneMappingExposure),u.setValue(vt,"toneMappingWhitePoint",I.toneMappingWhitePoint),r.lights&&function(t,e){t.ambientLightColor.needsUpdate=e,t.directionalLights.needsUpdate=e,t.pointLights.needsUpdate=e,t.spotLights.needsUpdate=e,t.rectAreaLights.needsUpdate=e,t.hemisphereLights.needsUpdate=e}(p,c),e&&r.fog&&function(t,e){t.fogColor.value=e.color,e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}(p,e),r.isMeshBasicMaterial?v(p,r):r.isMeshLambertMaterial?(v(p,r),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(p,r)):r.isMeshPhongMaterial?(v(p,r),r.isMeshToonMaterial?function(t,e){y(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(p,r):y(p,r)):r.isMeshStandardMaterial?(v(p,r),r.isMeshPhysicalMaterial?function(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,_(t,e)}(p,r):_(p,r)):r.isMeshDepthMaterial?(v(p,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(p,r)):r.isMeshDistanceMaterial?(v(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?(v(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?(function(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}(p,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(p,r)):r.isPointsMaterial?function(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*K,t.scale.value=.5*$,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=Lh.LTC_MAT_TEXTURE),void 0!==p.ltcMag&&(p.ltcMag.value=Lh.LTC_MAG_TEXTURE),H.upload(vt,i.uniformsList,p,I)),u.setValue(vt,"modelViewMatrix",n.modelViewMatrix),u.setValue(vt,"normalMatrix",n.normalMatrix),u.setValue(vt,"modelMatrix",n.matrixWorld),l}function v(t,e){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);var r;if(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 y(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 _(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)}var x=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),b=void 0!==t.context?t.context:null,w=void 0!==t.alpha&&t.alpha,S=void 0===t.depth||t.depth,M=void 0===t.stencil||t.stencil,A=void 0!==t.antialias&&t.antialias,E=void 0===t.premultipliedAlpha||t.premultipliedAlpha,C=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,T=[],P=[],L=null,R=[],N=[];this.domElement=x,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=hu,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var I=this,O=!1,D=null,F=null,z=-1,k="",U=null,B=null,V=new o,j=new o,G=null,W=0,Y=x.width,$=x.height,K=1,J=new o(0,0,Y,$),tt=new o(0,0,Y,$),et=!1,rt=new ot,ct=new function(){function t(){l.value!==n&&(l.value=n,l.needsUpdate=i>0),r.numPlanes=i,r.numIntersection=0}function e(t,e,n,i){var o=null!==t?t.length:0,a=null;if(0!==o){if(a=l.value,!0!==i||null===a){var u=n+4*o,h=e.matrixWorldInverse;c.getNormalMatrix(h),(null===a||a.length=0){var l=i[s];if(void 0!==l){var u=l.normalized,h=l.itemSize,p=Et.get(l);if(void 0===p)continue;var f=p.buffer,d=p.type,m=p.bytesPerElement;if(l.isInterleavedBufferAttribute){var g=l.data,v=g.stride,y=l.offset;g&&g.isInstancedInterleavedBuffer?(bt.enableAttributeAndDivisor(c,g.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=g.meshPerAttribute*g.count)):bt.enableAttribute(c),vt.bindBuffer(vt.ARRAY_BUFFER,f),vt.vertexAttribPointer(c,h,d,u,v*m,(n*v+y)*m)}else l.isInstancedBufferAttribute?(bt.enableAttributeAndDivisor(c,l.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=l.meshPerAttribute*l.count)):bt.enableAttribute(c),vt.bindBuffer(vt.ARRAY_BUFFER,f),vt.vertexAttribPointer(c,h,d,u,0,n*h*m)}else if(void 0!==a){var _=a[s];if(void 0!==_)switch(_.length){case 2:vt.vertexAttrib2fv(c,_);break;case 3:vt.vertexAttrib3fv(c,_);break;case 4:vt.vertexAttrib4fv(c,_);break;default:vt.vertexAttrib1fv(c,_)}}}}bt.disableUnusedAttributes()}}(i,s,n),null!==u&&vt.bindBuffer(vt.ELEMENT_ARRAY_BUFFER,f.buffer));var m=0;null!==u?m=u.count:void 0!==h&&(m=h.count);var v=n.drawRange.start*p,y=n.drawRange.count*p,_=null!==a?a.start*p:0,x=null!==a?a.count*p:1/0,b=Math.max(v,_),w=Math.min(m,v+y,_+x)-1,S=Math.max(0,w-b+1);if(0!==S){if(o.isMesh)if(!0===i.wireframe)bt.setLineWidth(i.wireframeLinewidth*e()),d.setMode(vt.LINES);else switch(o.drawMode){case ch:d.setMode(vt.TRIANGLES);break;case lh:d.setMode(vt.TRIANGLE_STRIP);break;case uh:d.setMode(vt.TRIANGLE_FAN)}else if(o.isLine){var M=i.linewidth;void 0===M&&(M=1),bt.setLineWidth(M*e()),o.isLineSegments?d.setMode(vt.LINES):o.isLineLoop?d.setMode(vt.LINE_LOOP):d.setMode(vt.LINE_STRIP)}else o.isPoints&&d.setMode(vt.POINTS);n&&n.isInstancedBufferGeometry?n.maxInstancedCount>0&&d.renderInstances(n,b,S):d.render(b,S)}},this.compile=function(t,e){T.length=0,P.length=0,t.traverse(function(t){t.isLight&&(T.push(t),t.castShadow&&P.push(t))}),Nt.setup(T,P,e),t.traverse(function(e){if(e.material)if(Array.isArray(e.material))for(var r=0;r=0&&e<=t.width-n&&r>=0&&r<=t.height-i&&vt.readPixels(e,r,n,i,Yt.convert(l),Yt.convert(u),o)}finally{s&&vt.bindFramebuffer(vt.FRAMEBUFFER,F)}}}}}function ne(t,e){this.name="",this.color=new X(t),this.density=void 0!==e?e:25e-5}function ie(t,e,r){this.name="",this.color=new X(t),this.near=void 0!==e?e:1,this.far=void 0!==r?r:1e3}function oe(){ut.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function ae(t,e,r,n,i){ut.call(this),this.lensFlares=[],this.positionScreen=new l,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,r,n,i)}function se(t){K.call(this),this.type="SpriteMaterial",this.color=new X(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function ce(t){ut.call(this),this.type="Sprite",this.material=void 0!==t?t:new se}function le(){ut.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function ue(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&&(h.needsUpdate=!0)}i.call(this,t,e,r,n,o,a,s,c,l),this.generateMipmaps=!1;var h=this;u()}function be(t,e,r,n,o,a,s,c,l,u,h,p){i.call(this,null,a,s,c,l,u,n,o,h,p),this.image={width:e,height:r},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function we(t,e,r,n,o,a,s,c,l,u){if((u=void 0!==u?u:$u)!==$u&&u!==Zu)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&u===$u&&(r=Ou),void 0===r&&u===Zu&&(r=ju),i.call(this,null,n,o,a,s,c,u,r,l),this.image={width:t,height:e},this.magFilter=void 0!==s?s:Au,this.minFilter=void 0!==c?c:Au,this.flipY=!1,this.generateMipmaps=!1}function Se(t){Pt.call(this),this.type="WireframeGeometry";var e,r,n,i,o,a,s,c,u,h,p=[],f=[0,0],d={},m=["a","b","c"];if(t&&t.isGeometry){var g=t.faces;for(e=0,n=g.length;e=0?(p=t(v-1e-5,g,p),f.subVectors(h,p)):(p=t(v+1e-5,g,p),f.subVectors(p,h)),g-1e-5>=0?(p=t(v,g-1e-5,p),d.subVectors(h,p)):(p=t(v,g+1e-5,p),d.subVectors(p,h)),u.crossVectors(f,d).normalize(),s.push(u.x,u.y,u.z),c.push(v,g)}}for(n=0;n.9&&o<.1&&(e<.2&&(h[t+0]+=1),r<.2&&(h[t+2]+=1),n<.2&&(h[t+4]+=1))}}()}(),this.addAttribute("position",new At(u,3)),this.addAttribute("normal",new At(u.slice(),3)),this.addAttribute("uv",new At(h,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}function Te(t,e){gt.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Pe(t,e)),this.mergeVertices()}function Pe(t,e){Ce.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 Le(t,e){gt.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Re(t,e)),this.mergeVertices()}function Re(t,e){Ce.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 Ne(t,e){gt.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Ie(t,e)),this.mergeVertices()}function Ie(t,e){var r=(1+Math.sqrt(5))/2;Ce.call(this,[-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],[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 Oe(t,e){gt.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new De(t,e)),this.mergeVertices()}function De(t,e){var r=(1+Math.sqrt(5))/2,n=1/r;Ce.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-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],[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 Fe(t,e,r,n,i,o){gt.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:r,radialSegments:n,closed:i};var a=new ze(t,e,r,n,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function ze(t,e,r,i,o){function a(n){var o=t.getPointAt(n/e),a=s.normals[n],c=s.binormals[n];for(u=0;u<=i;u++){var l=u/i*Math.PI*2,f=Math.sin(l),g=-Math.cos(l);p.x=g*a.x+f*c.x,p.y=g*a.y+f*c.y,p.z=g*a.z+f*c.z,p.normalize(),m.push(p.x,p.y,p.z),h.x=o.x+r*p.x,h.y=o.y+r*p.y,h.z=o.z+r*p.z,d.push(h.x,h.y,h.z)}}Pt.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:r,radialSegments:i,closed:o},e=e||64,r=r||1,i=i||8,o=o||!1;var s=t.computeFrenetFrames(e,o);this.tangents=s.tangents,this.normals=s.normals,this.binormals=s.binormals;var c,u,h=new l,p=new l,f=new n,d=[],m=[],g=[],v=[];!function(){for(c=0;c0)&&m.push(w,S,A),(c!==r-1||u0&&u(!0),e>0&&u(!1)),this.setIndex(p),this.addAttribute("position",new At(f,3)),this.addAttribute("normal",new At(d,3)),this.addAttribute("uv",new At(m,2))}function nr(t,e,r,n,i,o,a){er.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 ir(t,e,r,n,i,o,a){rr.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 or(t,e,r,n){gt.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},this.fromBufferGeometry(new ar(t,e,r,n)),this.mergeVertices()}function ar(t,e,r,i){Pt.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:i},t=t||50,e=void 0!==e?Math.max(3,e):8,r=void 0!==r?r:0,i=void 0!==i?i:2*Math.PI;var o,a,s=[],c=[],u=[],h=[],p=new l,f=new n;for(c.push(0,0,0),u.push(0,0,1),h.push(.5,.5),a=0,o=3;a<=e;a++,o+=3){var d=r+a/e*i;p.x=t*Math.cos(d),p.y=t*Math.sin(d),c.push(p.x,p.y,p.z),u.push(0,0,1),f.x=(c[o]/t+1)/2,f.y=(c[o+1]/t+1)/2,h.push(f.x,f.y)}for(o=1;o<=e;o++)s.push(o,o+1,0);this.setIndex(s),this.addAttribute("position",new At(c,3)),this.addAttribute("normal",new At(u,3)),this.addAttribute("uv",new At(h,2))}function sr(t){K.call(this),this.type="ShadowMaterial",this.color=new X(0),this.opacity=1,this.lights=!0,this.transparent=!0,this.setValues(t)}function cr(t){Q.call(this,t),this.type="RawShaderMaterial"}function lr(t){K.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new X(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new X(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function ur(t){lr.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(t)}function hr(t){K.call(this),this.type="MeshPhongMaterial",this.color=new X(16777215),this.specular=new X(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new X(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=su,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function pr(t){hr.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function fr(t){K.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function dr(t){K.call(this),this.type="MeshLambertMaterial",this.color=new X(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new X(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=su,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function mr(t){fe.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}function gr(t,e,r){var n=this,i=!1,o=0,a=0;this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(t){a++,!1===i&&void 0!==n.onStart&&n.onStart(t,o,a),i=!0},this.itemEnd=function(t){o++,void 0!==n.onProgress&&n.onProgress(t,o,a),o===a&&(i=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(t){void 0!==n.onError&&n.onError(t)}}function vr(t){this.manager=void 0!==t?t:jh}function yr(t){this.manager=void 0!==t?t:jh,this._parser=null}function _r(t){this.manager=void 0!==t?t:jh,this._parser=null}function xr(t){this.manager=void 0!==t?t:jh}function br(t){this.manager=void 0!==t?t:jh}function wr(t){this.manager=void 0!==t?t:jh}function Sr(t,e){ut.call(this),this.type="Light",this.color=new X(t),this.intensity=void 0!==e?e:1,this.receiveShadow=void 0}function Mr(t,e,r){Sr.call(this,t,r),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(ut.DefaultUp),this.updateMatrix(),this.groundColor=new X(e)}function Ar(t){this.camera=t,this.bias=0,this.radius=1,this.mapSize=new n(512,512),this.map=null,this.matrix=new u}function Er(){Ar.call(this,new ft(50,1,.5,500))}function Cr(t,e,r,n,i,o){Sr.call(this,t,e),this.type="SpotLight",this.position.copy(ut.DefaultUp),this.updateMatrix(),this.target=new ut,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==r?r:0,this.angle=void 0!==n?n:Math.PI/3,this.penumbra=void 0!==i?i:0,this.decay=void 0!==o?o:1,this.shadow=new Er}function Tr(t,e,r,n){Sr.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(t){this.intensity=t/(4*Math.PI)}}),this.distance=void 0!==r?r:0,this.decay=void 0!==n?n:1,this.shadow=new Ar(new ft(90,1,.5,500))}function Pr(){Ar.call(this,new pt(-5,5,5,-5,.5,500))}function Lr(t,e){Sr.call(this,t,e),this.type="DirectionalLight",this.position.copy(ut.DefaultUp),this.updateMatrix(),this.target=new ut,this.shadow=new Pr}function Rr(t,e){Sr.call(this,t,e),this.type="AmbientLight",this.castShadow=void 0}function Nr(t,e,r,n){Sr.call(this,t,e),this.type="RectAreaLight",this.position.set(0,1,0),this.updateMatrix(),this.width=void 0!==r?r:10,this.height=void 0!==n?n:10}function Ir(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 Or(t,e,r,n){Ir.call(this,t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Dr(t,e,r,n){Ir.call(this,t,e,r,n)}function Fr(t,e,r,n){Ir.call(this,t,e,r,n)}function zr(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=Gh.convertArray(e,this.TimeBufferType),this.values=Gh.convertArray(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation),this.validate(),this.optimize()}function kr(t,e,r,n){zr.call(this,t,e,r,n)}function Ur(t,e,r,n){Ir.call(this,t,e,r,n)}function Br(t,e,r,n){zr.call(this,t,e,r,n)}function Vr(t,e,r,n){zr.call(this,t,e,r,n)}function jr(t,e,r,n){zr.call(this,t,e,r,n)}function Gr(t,e,r){zr.call(this,t,e,r)}function Wr(t,e,r,n){zr.call(this,t,e,r,n)}function Hr(t,e,r,n){zr.apply(this,arguments)}function Xr(t,e,r){this.name=t,this.tracks=r,this.duration=void 0!==e?e:-1,this.uuid=xh.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function Yr(t){this.manager=void 0!==t?t:jh,this.textures={}}function qr(t){this.manager=void 0!==t?t:jh}function $r(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function Zr(t){"boolean"==typeof t&&(t=void 0),this.manager=void 0!==t?t:jh,this.withCredentials=!1}function Kr(t){this.manager=void 0!==t?t:jh,this.texturePath=""}function Qr(t,e,r,n,i){var o=.5*(n-e),a=.5*(i-r),s=t*t;return(2*r-2*n+o+a)*(t*s)+(-3*r+3*n-2*o-a)*s+o*t+r}function Jr(t,e,r,n){return function(t,e){var r=1-t;return r*r*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,r)+function(t,e){return t*t*e}(t,n)}function tn(t,e,r,n,i){return function(t,e){var r=1-t;return r*r*r*e}(t,e)+function(t,e){var r=1-t;return 3*r*r*t*e}(t,r)+function(t,e){return 3*(1-t)*t*t*e}(t,n)+function(t,e){return t*t*t*e}(t,i)}function en(){this.arcLengthDivisions=200}function rn(t,e){en.call(this),this.v1=t,this.v2=e}function nn(){en.call(this),this.curves=[],this.autoClose=!1}function on(t,e,r,n,i,o,a,s){en.call(this),this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=n,this.aStartAngle=i,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s||0}function an(t){en.call(this),this.points=void 0===t?[]:t}function sn(t,e,r,n){en.call(this),this.v0=t,this.v1=e,this.v2=r,this.v3=n}function cn(t,e,r){en.call(this),this.v0=t,this.v1=e,this.v2=r}function ln(t){nn.call(this),this.currentPoint=new n,t&&this.fromPoints(t)}function un(){ln.apply(this,arguments),this.holes=[]}function hn(){this.subPaths=[],this.currentPath=null}function pn(t){this.data=t}function fn(t){this.manager=void 0!==t?t:jh}function dn(t){this.manager=void 0!==t?t:jh}function mn(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ft,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ft,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function gn(t,e,r){ut.call(this),this.type="CubeCamera";var n=new ft(90,1,t,e);n.up.set(0,-1,0),n.lookAt(new l(1,0,0)),this.add(n);var i=new ft(90,1,t,e);i.up.set(0,-1,0),i.lookAt(new l(-1,0,0)),this.add(i);var o=new ft(90,1,t,e);o.up.set(0,0,1),o.lookAt(new l(0,1,0)),this.add(o);var a=new ft(90,1,t,e);a.up.set(0,0,-1),a.lookAt(new l(0,-1,0)),this.add(a);var c=new ft(90,1,t,e);c.up.set(0,-1,0),c.lookAt(new l(0,0,1)),this.add(c);var u=new ft(90,1,t,e);u.up.set(0,-1,0),u.lookAt(new l(0,0,-1)),this.add(u);var h={format:Wu,magFilter:Tu,minFilter:Tu};this.renderTarget=new s(r,r,h),this.renderTarget.texture.name="CubeCamera",this.update=function(t,e){null===this.parent&&this.updateMatrixWorld();var r=this.renderTarget,s=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,r.activeCubeFace=0,t.render(e,n,r),r.activeCubeFace=1,t.render(e,i,r),r.activeCubeFace=2,t.render(e,o,r),r.activeCubeFace=3,t.render(e,a,r),r.activeCubeFace=4,t.render(e,c,r),r.texture.generateMipmaps=s,r.activeCubeFace=5,t.render(e,u,r),t.setRenderTarget(null)},this.clear=function(t,e,r,n){for(var i=this.renderTarget,o=0;o<6;o++)i.activeCubeFace=o,t.setRenderTarget(i),t.clear(e,r,n);t.setRenderTarget(null)}}function vn(){ut.call(this),this.type="AudioListener",this.context=Kh.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function yn(t){ut.call(this),this.type="Audio",this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.loop=!1,this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function _n(t){yn.call(this,t),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function xn(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=void 0!==e?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}function bn(t,e,r){this.binding=t,this.valueSize=r;var n,i=Float64Array;switch(e){case"quaternion":n=this._slerp;break;case"string":case"bool":i=Array,n=this._select;break;default:n=this._lerp}this.buffer=new i(4*r),this._mixBufferRegion=n,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}function wn(t,e,r){var n=r||Sn.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}function Sn(t,e,r){this.path=e,this.parsedPath=r||Sn.parseTrackName(e),this.node=Sn.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function Mn(t){this.uuid=xh.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var r=0,n=arguments.length;r!==n;++r)e[arguments[r].uuid]=r;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var i=this;this.stats={objects:{get total(){return i._objects.length},get inUse(){return this.total-i.nCachedObjects_}},get bindingsPerObject(){return i._bindings.length}}}function An(t,e,r){this._mixer=t,this._clip=e,this._localRoot=r||null;for(var n=e.tracks,i=n.length,o=new Array(i),a={endingStart:sh,endingEnd:sh},s=0;s!==i;++s){var c=n[s].createInterpolant(null);o[s]=c,c.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=ah,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function En(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Cn(t){"string"==typeof t&&(t=arguments[1]),this.value=t}function Tn(){Pt.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function Pn(t,e,r,n){this.uuid=xh.generateUUID(),this.data=t,this.itemSize=e,this.offset=r,this.normalized=!0===n}function Ln(t,e){this.uuid=xh.generateUUID(),this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function Rn(t,e,r){Ln.call(this,t,e),this.meshPerAttribute=r||1}function Nn(t,e,r){vt.call(this,t,e),this.meshPerAttribute=r||1}function In(t,e,r,n){this.ray=new Dt(t,e),this.near=r||0,this.far=n||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return this.Points}}})}function On(t,e){return t.distance-e.distance}function Dn(t,e,r,n){if(!1!==t.visible&&(t.raycast(e,r),!0===n))for(var i=t.children,o=0,a=i.length;o0&&(i=Object.create(i))}return i}function _i(t){function e(t,e){return function(){var i=_i.spaces.substr(0,2*n);r&&up.debug(i+e+" {"),n++;var o=t.apply(this,arguments);return n--,r&&up.debug(i+"} // "+e),o}}var r=!1;this.enable=function(t){r=t};for(var n=0,i=Object.keys(t),o=0,a=i.length;o=3&&"base64"===e[r-2]?new Blob([wi(e[r-1])]):null}function Ai(t,e,r){var n=document.createElement(t);return n.id=e,n.style.cssText=r,n}function Ei(){this.domElement=Ai("div","stats","padding:8px"),this._text=Ai("p","fps","margin:0;color:silver;font-size:large"),this.domElement.appendChild(this._text),this._startTime=dp(),this._prevTime=this._startTime,this._deltas=new Array(20),this._index=0,this._total=0,this._count=0}function Ci(){fi.call(this),this._cancellationRequested=!1}function Ti(){this.old=null,this.now={},this._changed={},this.reset()}function Pi(t){return!(!t||"0"===t||vl.isString(t)&&"false"===t.toLowerCase())}function Li(t){return fp.encodeQueryComponent(t,Lp)}function Ri(t){return fp.encodeQueryComponent(t,Rp)}function Ni(t){var e=t.reps;if(!e){var r=gp.now.presets,n=t.preset||gp.now.preset;(e=r[n])||(up.warn('Unknown preset "'+n+'"'),e=r[n=Object.keys(r)[0]]),t.preset=n,t.reps=fp.deriveDeep(e,!0)}}function Ii(t,e,r){Ni(t);var n=t.reps[Sp];n.hasOwnProperty(e)&&++Sp>=t.reps.length&&(t.reps[Sp]=fp.deriveDeep(n,!0)),void 0!==r&&(t.reps[Sp][e]=r)}function Oi(t,e,r){if(t){var n=t.indexOf(Ep),i=function(t,e){var r=t.indexOf(",");return r>=0?(e.push(t.substr(r+1).split(",")),t.substr(0,r)):t}(t.substr(0,n>=0?n:void 0),r);if(n>=0){var o=t.substr(n+1).split(Tp);if(t=i,e){var a=e[t],s=fp.deriveDeep(a,!0);o.forEach(function(e){var r=e.split(Cp,2),n=decodeURIComponent(r[0]),i=decodeURIComponent(r[1]),o=Mp[vp(vl.get(a,n))];o?vl.set(s,n,o(i)):up.warn('Unknown argument "'+n+'" for option "'+t+'"')}),Object.keys(s).length>0&&(t=[t,s])}}else t=i}return t}function Di(t){Sp=0;for(var e={},r=0,n=t.length;r0&&(e+=","+t.params.join(",")),t.opts&&(e+=Ep+Fi(t.opts)),e}}function Ui(t){var e=[],r=0;return fp.forInRecursive(t,function(t,n){e[r++]=n+"="+fp.enquoteString(t)}),e.join(" ")}function Bi(t){return vl.isArray(t)?t[0]+(t.length<2?"":" "+Ui(t[1])):t}function Vi(t){if(t&&t.type){var e=t.type;return vl.isArray(t.params)&&t.params.length>0&&(e+=" "+t.params.map(fp.enquoteString).join(" ")),t.opts&&(e+=" "+Ui(t.opts)),e}}function ji(t,e){function r(t,e){null!==e&&void 0!==e&&(n[i++]=t+e)}var n=[],i=0;return vl.isEmpty(t)?null:(r("",e),r("s=",fp.enquoteString(t.selector)),r("m=",Bi(t.mode)),r("c=",Bi(t.colorer)),r("mt=",Bi(t.material)),n.join(" "))}function Gi(t,e){this._node=e||null,this._name=t||null,null===this._node&&null===this._name&&(this._name="Unknown")}function Wi(t,e,r,n,i,o,a){this.number=t,this.name=e,this.fullName=r,this.weight=n,this.radius=i,this.radiusBonding=o,this.hydrogenValency=a}function Hi(t,e,r,n,i,o,a,s,c,l,u){this._index=-1,this._residue=t,this._name=e instanceof Gi?e:new Gi(e),this.element=r,this._position=n,this._role=i,this._mask=1,this._index=-1,this._het=o,this._serial=a,this._location=(s||" ").charCodeAt(0),this._occupancy=c||1,this._temperature=l,this._charge=u,this._hydrogenCount=-1,this._radicalCount=0,this._valence=-1,this._bonds=[],this.flags=0,"H"===r.name?this.flags|=Hi.Flags.HYDROGEN:"C"===r.name&&(this.flags|=Hi.Flags.CARBON)}function Xi(t){return t<2?1:t}function Yi(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 qi(t,e,r){this._name=t,this._fullName=e,this.letterCode=r,this.flags=0}function $i(t,e){for(var r=0,n=e.length;r0)return t;var i=e*r,o=Lh[i];if(void 0===o&&(o=new Float32Array(i),Lh[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 m(t,e){var r=Rh[e];void 0===r&&(r=new Int32Array(e),Rh[e]=r);for(var n=0;n!==e;++n)r[n]=t.allocTextureUnit();return r}function g(t,e){t.uniform1f(this.addr,e)}function v(t,e){t.uniform1i(this.addr,e)}function y(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function x(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 b(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function w(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function S(t,e){void 0===e.elements?t.uniformMatrix3fv(this.addr,!1,e):(Ih.set(e.elements),t.uniformMatrix3fv(this.addr,!1,Ih))}function M(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(Nh.set(e.elements),t.uniformMatrix4fv(this.addr,!1,Nh))}function A(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTexture2D(e||Th,n)}function E(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTextureCube(e||Ph,n)}function C(t,e){t.uniform2iv(this.addr,e)}function T(t,e){t.uniform3iv(this.addr,e)}function P(t,e){t.uniform4iv(this.addr,e)}function L(t,e){t.uniform1fv(this.addr,e)}function R(t,e){t.uniform1iv(this.addr,e)}function N(t,e){t.uniform2fv(this.addr,d(e,this.size,2))}function I(t,e){t.uniform3fv(this.addr,d(e,this.size,3))}function O(t,e){t.uniform4fv(this.addr,d(e,this.size,4))}function D(t,e){t.uniformMatrix2fv(this.addr,!1,d(e,this.size,4))}function F(t,e){t.uniformMatrix3fv(this.addr,!1,d(e,this.size,9))}function z(t,e){t.uniformMatrix4fv(this.addr,!1,d(e,this.size,16))}function k(t,e,r){var n=e.length,i=m(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTexture2D(e[o]||Th,i[o])}function U(t,e,r){var n=e.length,i=m(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTextureCube(e[o]||Ph,i[o])}function B(t,e,r){this.id=t,this.addr=r,this.setValue=function(t){switch(t){case 5126:return g;case 35664:return y;case 35665:return x;case 35666:return b;case 35674:return w;case 35675:return S;case 35676:return M;case 35678:case 36198:return A;case 35680:return E;case 5124:case 35670:return v;case 35667:case 35671:return C;case 35668:case 35672:return T;case 35669:case 35673:return P}}(e.type)}function V(t,e,r){this.id=t,this.addr=r,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return L;case 35664:return N;case 35665:return I;case 35666:return O;case 35674:return D;case 35675:return F;case 35676:return z;case 35678:return k;case 35680:return U;case 5124:case 35670:return R;case 35667:case 35671:return C;case 35668:case 35672:return T;case 35669:case 35673:return P}}(e.type)}function j(t){this.id=t,f.call(this)}function G(t,e){t.seq.push(e),t.map[e.id]=e}function W(t,e,r){var n=t.name,i=n.length;for(Oh.lastIndex=0;;){var o=Oh.exec(n),a=Oh.lastIndex,s=o[1],c="]"===o[2],l=o[3];if(c&&(s|=0),void 0===l||"["===l&&a+2===i){G(r,void 0===l?new B(s,t,e):new V(s,t,e));break}var u=r.map[s];void 0===u&&G(r,u=new j(s)),r=u}}function H(t,e,r){f.call(this),this.renderer=r;for(var n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),i=0;i.001&&R.scale>.001&&(S.x=R.x,S.y=R.y,S.z=R.z,b=R.size*R.scale/g.w,w.x=b*y,w.y=b,e.uniform3f(f.screenPosition,S.x,S.y,S.z),e.uniform2f(f.scale,w.x,w.y),e.uniform1f(f.rotation,R.rotation),e.uniform1f(f.opacity,R.opacity),e.uniform3f(f.color,R.color.r,R.color.g,R.color.b),r.setBlending(R.blending,R.blendEquation,R.blendSrc,R.blendDst),i.setTexture2D(R.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 Z(t,e,r,n,o,a,s,c,l){i.call(this,t,e,r,n,o,a,s,c,l),this.needsUpdate=!0}function $(t,e,r,n,i){function o(){var t=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),r=new Uint16Array([0,1,2,0,2,3]);s=e.createBuffer(),u=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u),e.bufferData(e.ELEMENT_ARRAY_BUFFER,r,e.STATIC_DRAW),h=function(){var t=e.createProgram(),r=e.createShader(e.VERTEX_SHADER),n=e.createShader(e.FRAGMENT_SHADER);return 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),t}(),p={position:e.getAttribLocation(h,"position"),uv:e.getAttribLocation(h,"uv")},f={uvOffset:e.getUniformLocation(h,"uvOffset"),uvScale:e.getUniformLocation(h,"uvScale"),rotation:e.getUniformLocation(h,"rotation"),scale:e.getUniformLocation(h,"scale"),color:e.getUniformLocation(h,"color"),map:e.getUniformLocation(h,"map"),opacity:e.getUniformLocation(h,"opacity"),modelViewMatrix:e.getUniformLocation(h,"modelViewMatrix"),projectionMatrix:e.getUniformLocation(h,"projectionMatrix"),fogType:e.getUniformLocation(h,"fogType"),fogDensity:e.getUniformLocation(h,"fogDensity"),fogNear:e.getUniformLocation(h,"fogNear"),fogFar:e.getUniformLocation(h,"fogFar"),fogColor:e.getUniformLocation(h,"fogColor"),alphaTest:e.getUniformLocation(h,"alphaTest")};var n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");n.width=8,n.height=8;var o=n.getContext("2d");o.fillStyle="white",o.fillRect(0,0,8,8),d=new Z(n)}function a(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}var s,u,h,p,f,d,m=new l,g=new c,v=new l;this.render=function(i,c,l){if(0!==i.length){void 0===h&&o(),r.useProgram(h),r.initAttributes(),r.enableAttribute(p.position),r.enableAttribute(p.uv),r.disableUnusedAttributes(),r.disable(e.CULL_FACE),r.enable(e.BLEND),e.bindBuffer(e.ARRAY_BUFFER,s),e.vertexAttribPointer(p.position,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(p.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u),e.uniformMatrix4fv(f.projectionMatrix,!1,l.projectionMatrix.elements),r.activeTexture(e.TEXTURE0),e.uniform1i(f.map,0);var y=0,_=0,x=c.fog;x?(e.uniform3f(f.fogColor,x.color.r,x.color.g,x.color.b),x.isFog?(e.uniform1f(f.fogNear,x.near),e.uniform1f(f.fogFar,x.far),e.uniform1i(f.fogType,1),y=1,_=1):x.isFogExp2&&(e.uniform1f(f.fogDensity,x.density),e.uniform1i(f.fogType,2),y=2,_=2)):(e.uniform1i(f.fogType,0),y=0,_=0);for(var b=0,w=i.length;b0:s&&s.isGeometry&&(h=s.morphTargets&&s.morphTargets.length>0)),e.isSkinnedMesh&&r.skinning;var p=e.isSkinnedMesh&&r.skinning,f=0;h&&(f|=g),p&&(f|=v),c=l[f]}if(t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var d=c.uuid,m=r.uuid,y=b[d];void 0===y&&(y={},b[d]=y);var w=y[m];void 0===w&&(w=c.clone(),y[m]=w),c=w}c.visible=r.visible,c.wireframe=r.wireframe;var S=r.side;return L.renderSingleSided&&S==Il&&(S=Rl),L.renderReverseSided&&(S===Rl?S=Nl:S===Nl&&(S=Rl)),c.side=S,c.clipShadows=r.clipShadows,c.clippingPlanes=r.clippingPlanes,c.clipIntersection=r.clipIntersection,c.wireframeLinewidth=r.wireframeLinewidth,c.linewidth=r.linewidth,n&&c.isMeshDistanceMaterial&&(c.referencePosition.copy(i),c.nearDistance=o,c.farDistance=a),c}function s(r,n,o,a){if(!1!==r.visible){if(r.layers.test(n.layers)&&(r.isMesh||r.isLine||r.isPoints)&&r.castShadow&&(!r.frustumCulled||c.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,r.matrixWorld);var l=e.update(r),u=r.material;if(Array.isArray(u))for(var h=l.groups,p=0,f=h.length;pe&&(e=t[r]);return e}function Pt(){Object.defineProperty(this,"id",{value:mt()}),this.uuid=Eh.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 Lt(t,e,r,n,i,o){gt.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:o},this.fromBufferGeometry(new Rt(t,e,r,n,i,o)),this.mergeVertices()}function Rt(t,e,r,n,i,o){function a(t,e,r,n,i,o,a,m,g,v,y){var _,x,b=o/g,w=a/v,S=o/2,M=a/2,A=m/2,E=g+1,C=v+1,T=0,P=0,L=new l;for(x=0;x0?1:-1,h.push(L.x,L.y,L.z),p.push(_/g),p.push(1-x/v),T+=1}}for(x=0;x1&&r.sort(Ut),n.length>1&&n.sort(Bt)}}},t[n]=i),i},dispose:function(){t={}}}}function jt(t,e){return Math.abs(e[1])-Math.abs(t[1])}function Gt(){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 l,color:new X,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n};break;case"SpotLight":r={position:new l,direction:new l,color:new X,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n};break;case"PointLight":r={position:new l,color:new X,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":r={direction:new l,skyColor:new X,groundColor:new X};break;case"RectAreaLight":r={color:new X,position:new l,halfWidth:new l,halfHeight:new l}}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 l,i=new u,o=new u;return{setup:function(n,a,s){for(var c=0,l=0,u=0,h=0,p=0,f=0,d=0,m=0,g=s.matrixWorldInverse,v=0,y=n.length;v/gm,function(t,e){var r=kh[e];if(void 0===r)throw new Error("Can not resolve #include <"+e+">");return Zt(r)})}function $t(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,v=function(t,e,r){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.normalMap||e.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(t.fragDepth||e.logarithmicDepthBuffer)&&r.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",t.drawBuffers&&r.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(t.shaderTextureLOD||e.envMap)&&r.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Yt).join("\n")}(n.extensions,o,e),y=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),_=a.createProgram();n.isRawShaderMaterial?(d=[y,"\n"].filter(Yt).join("\n"),m=[v,y,"\n"].filter(Yt).join("\n")):(d=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,y,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#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(Yt).join("\n"),m=[v,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,y,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+g,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!==gu?"#define TONE_MAPPING":"",o.toneMapping!==gu?kh.tonemapping_pars_fragment:"",o.toneMapping!==gu?function(t,e){var r;switch(e){case vu:r="Linear";break;case yu:r="Reinhard";break;case _u:r="Uncharted2";break;case xu: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?kh.encodings_pars_fragment:"",o.mapEncoding?Xt("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?Xt("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?Xt("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?function(t,e){var r=Ht(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+r[0]+r[1]+"; }"}("linearToOutputTexel",o.outputEncoding):"",o.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Yt).join("\n")),c=qt(c=Zt(c),o),l=qt(l=Zt(l),o),n.isShaderMaterial||(c=$t(c),l=$t(l));var x=d+c,b=m+l,w=Wt(a,a.VERTEX_SHADER,x),S=Wt(a,a.FRAGMENT_SHADER,b);a.attachShader(_,w),a.attachShader(_,S),void 0!==n.index0AttributeName?a.bindAttribLocation(_,0,n.index0AttributeName):!0===o.morphTargets&&a.bindAttribLocation(_,0,"position"),a.linkProgram(_);var M=a.getProgramInfoLog(_),A=a.getShaderInfoLog(w),E=a.getShaderInfoLog(S),C=!0,T=!0;!1===a.getProgramParameter(_,a.LINK_STATUS)?C=!1:""!==M||""!==A&&""!==E||(T=!1),T&&(this.diagnostics={runnable:C,material:n,programLog:M,vertexShader:{log:A,prefix:d},fragmentShader:{log:E,prefix:m}}),a.deleteShader(w),a.deleteShader(S);var P;this.getUniforms=function(){return void 0===P&&(P=new H(a,_,t)),P};var L;return this.getAttributes=function(){return void 0===L&&(L=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:i.directional.length,numPointLights:i.point.length,numSpotLights:i.spot.length,numRectAreaLights:i.rectArea.length,numHemiLights:i.hemi.length,numClippingPlanes:c,numClipIntersection:l,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&u.receiveShadow&&a.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===Il,flipSided:e.side===Nl,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 o=0;oe||t.height>e){var r=e/Math.max(t.width,t.height),n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");n.width=Math.floor(t.width*r),n.height=Math.floor(t.height*r);return n.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,n.width,n.height),n}return t}function c(t){return Eh.isPowerOfTwo(t.width)&&Eh.isPowerOfTwo(t.height)}function l(t,e){return t.generateMipmaps&&e&&t.minFilter!==Ru&&t.minFilter!==Ou}function u(e){return e===Ru||e===Nu||e===Iu?t.NEAREST:t.LINEAR}function h(e){var r=e.target;r.removeEventListener("dispose",h),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 p(e){var r=e.target;r.removeEventListener("dispose",p),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,u){var p=n.get(e);if(e.version>0&&p.__version!==e.version){var f=e.image;if(void 0===f);else if(!1!==f.complete)return void function(e,n,u){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",h),e.__webglTexture=t.createTexture(),a.textures++);r.activeTexture(t.TEXTURE0+u),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 p=s(n.image,i.maxTextureSize);(function(t){return t.wrapS!==Pu||t.wrapT!==Pu||t.minFilter!==Ru&&t.minFilter!==Ou})(n)&&!1===c(p)&&(p=function(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=Eh.nearestPowerOfTwo(t.width),e.height=Eh.nearestPowerOfTwo(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),e}return t}(p));var f=c(p),m=o.convert(n.format),g=o.convert(n.type);d(t.TEXTURE_2D,n,f);var v,_=n.mipmaps;if(n.isDepthTexture){var x=t.DEPTH_COMPONENT;if(n.type===Gu){if(!y)throw new Error("Float Depth Texture only supported in WebGL2.0");x=t.DEPTH_COMPONENT32F}else y&&(x=t.DEPTH_COMPONENT16);n.format===eh&&x===t.DEPTH_COMPONENT&&n.type!==Bu&&n.type!==ju&&(n.type=Bu,g=o.convert(n.type)),n.format===rh&&(x=t.DEPTH_STENCIL,n.type!==qu&&(n.type=qu,g=o.convert(n.type))),r.texImage2D(t.TEXTURE_2D,0,x,p.width,p.height,0,m,g,null)}else if(n.isDataTexture)if(_.length>0&&f){for(var b=0,w=_.length;b-1&&r.compressedTexImage2D(t.TEXTURE_2D,b,m,v.width,v.height,0,v.data):r.texImage2D(t.TEXTURE_2D,b,m,v.width,v.height,0,m,g,v.data);else if(_.length>0&&f){for(var b=0,w=_.length;b1||n.get(a).__currentAnisotropy)&&(t.texParameterf(r,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),n.get(a).__currentAnisotropy=a.anisotropy)}}function m(e,i,a,s){var c=o.convert(i.texture.format),l=o.convert(i.texture.type);r.texImage2D(s,0,c,i.width,i.height,0,c,l,null),t.bindFramebuffer(t.FRAMEBUFFER,e),t.framebufferTexture2D(t.FRAMEBUFFER,a,s,n.get(i.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function g(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 v(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===eh)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,i,0);else{if(r.depthTexture.format!==rh)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(),g(r.__webglDepthbuffer[o],e)}else t.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=t.createRenderbuffer(),g(r.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}var y="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext;this.setTexture2D=f,this.setTextureCube=function(e,u){var p=n.get(e);if(6===e.image.length)if(e.version>0&&p.__version!==e.version){p.__image__webglTextureCube||(e.addEventListener("dispose",h),p.__image__webglTextureCube=t.createTexture(),a.textures++),r.activeTexture(t.TEXTURE0+u),r.bindTexture(t.TEXTURE_CUBE_MAP,p.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var f=e&&e.isCompressedTexture,m=e.image[0]&&e.image[0].isDataTexture,g=[],v=0;v<6;v++)g[v]=f||m?m?e.image[v].image:e.image[v]:s(e.image[v],i.maxCubemapSize);var y=c(g[0]),_=o.convert(e.format),x=o.convert(e.type);for(d(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 m?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]);l(e,y)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),p.__version=e.version,e.onUpdate&&e.onUpdate(e)}else r.activeTexture(t.TEXTURE0+u),r.bindTexture(t.TEXTURE_CUBE_MAP,p.__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",p),o.__webglTexture=t.createTexture(),a.textures++;var s=!0===e.isWebGLRenderTargetCube,u=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),d(t.TEXTURE_CUBE_MAP,e.texture,u),h=0;h<6;h++)m(i.__webglFramebuffer[h],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+h);l(e.texture,u)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),r.bindTexture(t.TEXTURE_CUBE_MAP,null)}else r.bindTexture(t.TEXTURE_2D,o.__webglTexture),d(t.TEXTURE_2D,e.texture,u),m(i.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),l(e.texture,u)&&t.generateMipmap(t.TEXTURE_2D),r.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&v(e)},this.updateRenderTargetMipmap=function(e){var i=e.texture;if(l(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 te(t){ft.call(this),this.cameras=t||[]}function ee(t,e){return{convert:function(r){var n;if(r===Tu)return t.REPEAT;if(r===Pu)return t.CLAMP_TO_EDGE;if(r===Lu)return t.MIRRORED_REPEAT;if(r===Ru)return t.NEAREST;if(r===Nu)return t.NEAREST_MIPMAP_NEAREST;if(r===Iu)return t.NEAREST_MIPMAP_LINEAR;if(r===Ou)return t.LINEAR;if(r===Du)return t.LINEAR_MIPMAP_NEAREST;if(r===Fu)return t.LINEAR_MIPMAP_LINEAR;if(r===zu)return t.UNSIGNED_BYTE;if(r===Hu)return t.UNSIGNED_SHORT_4_4_4_4;if(r===Xu)return t.UNSIGNED_SHORT_5_5_5_1;if(r===Yu)return t.UNSIGNED_SHORT_5_6_5;if(r===ku)return t.BYTE;if(r===Uu)return t.SHORT;if(r===Bu)return t.UNSIGNED_SHORT;if(r===Vu)return t.INT;if(r===ju)return t.UNSIGNED_INT;if(r===Gu)return t.FLOAT;if(r===Wu&&null!==(n=e.get("OES_texture_half_float")))return n.HALF_FLOAT_OES;if(r===Zu)return t.ALPHA;if(r===$u)return t.RGB;if(r===Ku)return t.RGBA;if(r===Qu)return t.LUMINANCE;if(r===Ju)return t.LUMINANCE_ALPHA;if(r===eh)return t.DEPTH_COMPONENT;if(r===rh)return t.DEPTH_STENCIL;if(r===Gl)return t.FUNC_ADD;if(r===Wl)return t.FUNC_SUBTRACT;if(r===Hl)return t.FUNC_REVERSE_SUBTRACT;if(r===ql)return t.ZERO;if(r===Zl)return t.ONE;if(r===$l)return t.SRC_COLOR;if(r===Kl)return t.ONE_MINUS_SRC_COLOR;if(r===Ql)return t.SRC_ALPHA;if(r===Jl)return t.ONE_MINUS_SRC_ALPHA;if(r===tu)return t.DST_ALPHA;if(r===eu)return t.ONE_MINUS_DST_ALPHA;if(r===ru)return t.DST_COLOR;if(r===nu)return t.ONE_MINUS_DST_COLOR;if(r===iu)return t.SRC_ALPHA_SATURATE;if((r===nh||r===ih||r===oh||r===ah)&&null!==(n=e.get("WEBGL_compressed_texture_s3tc"))){if(r===nh)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===ih)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===oh)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===ah)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((r===sh||r===ch||r===lh||r===uh)&&null!==(n=e.get("WEBGL_compressed_texture_pvrtc"))){if(r===sh)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===ch)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===lh)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===uh)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(r===hh&&null!==(n=e.get("WEBGL_compressed_texture_etc1")))return n.COMPRESSED_RGB_ETC1_WEBGL;if((r===Xl||r===Yl)&&null!==(n=e.get("EXT_blend_minmax"))){if(r===Xl)return n.MIN_EXT;if(r===Yl)return n.MAX_EXT}return r===qu&&null!==(n=e.get("WEBGL_depth_texture"))?n.UNSIGNED_INT_24_8_WEBGL:0}}}function re(t){function e(){return null===D?K:1}function r(){(_t=new function(t){var e={};return{get:function(r){if(void 0!==e[r])return e[r];var n;switch(r){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":n=t.getExtension("WEBGL_compressed_texture_etc1");break;default:n=t.getExtension(r)}return e[r]=n,n}}}(vt)).get("WEBGL_depth_texture"),_t.get("OES_texture_float"),_t.get("OES_texture_float_linear"),_t.get("OES_texture_half_float"),_t.get("OES_texture_half_float_linear"),_t.get("OES_standard_derivatives"),_t.get("ANGLE_instanced_arrays"),_t.get("OES_element_index_uint")&&(Pt.MaxIndex=4294967296),Yt=new ee(vt,_t),xt=new function(t,e,r){function n(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&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 i,o=void 0!==r.precision?r.precision:"highp",a=n(o);a!==o&&(o=a);var s=!0===r.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),l=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=l>0,v=!!e.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==i)return i;var r=e.get("EXT_texture_filter_anisotropic");return i=null!==r?t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:n,precision:o,logarithmicDepthBuffer:s,maxTextures:c,maxVertexTextures:l,maxTextureSize:u,maxCubemapSize:h,maxAttributes:p,maxVertexUniforms:f,maxVaryings:d,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v}}(vt,_t,t),(bt=new function(t,e,r){function n(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;a=1,k=null,U={},B=new o,V=new o,j={};return j[t.TEXTURE_2D]=n(t.TEXTURE_2D,t.TEXTURE_2D,1),j[t.TEXTURE_CUBE_MAP]=n(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),p.setClear(0,0,0,1),f.setClear(1),d.setClear(0),i(t.DEPTH_TEST),f.setFunc(cu),c(!1),l(El),i(t.CULL_FACE),i(t.BLEND),s(kl),{buffers:{color:p,depth:f,stencil:d},initAttributes:function(){for(var t=0,e=g.length;t65535?Mt:wt)(i,1),e.update(n,t.ELEMENT_ARRAY_BUFFER),o[r.id]=n,n}}}(vt,Et,mt),Lt=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={}}}}(Ct,gt),Ut=new function(t){var e={},r=new Float32Array(8);return{update:function(n,i,o,a){var s=n.morphTargetInfluences,c=s.length,l=e[i.id];if(void 0===l){l=[];for(var u=0;u=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(p=0;p=0&&t.numSupportedMorphNormals++}var f=n.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=ct.numPlanes,n.numIntersection=ct.numIntersection,f.clippingPlanes=ct.uniform),n.fog=e,n.lightsHash=Nt.state.hash,t.lights&&(f.ambientLightColor.value=Nt.state.ambient,f.directionalLights.value=Nt.state.directional,f.spotLights.value=Nt.state.spot,f.rectAreaLights.value=Nt.state.rectArea,f.pointLights.value=Nt.state.point,f.hemisphereLights.value=Nt.state.hemi,f.directionalShadowMap.value=Nt.state.directionalShadowMap,f.directionalShadowMatrix.value=Nt.state.directionalShadowMatrix,f.spotShadowMap.value=Nt.state.spotShadowMap,f.spotShadowMatrix.value=Nt.state.spotShadowMatrix,f.pointShadowMap.value=Nt.state.pointShadowMap,f.pointShadowMatrix.value=Nt.state.pointShadowMatrix);var d=n.program.getUniforms(),m=H.seqWithValue(d.seq,f);n.uniformsList=m}function g(t,e,r,n){W=0;var i=St.get(r);if(lt&&(ut||t!==U)){var o=t===U&&r.id===z;ct.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!==Nt.state.hash?r.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===ct.numPlanes&&i.numIntersection===ct.numIntersection||(r.needsUpdate=!0)),r.needsUpdate&&(m(r,e,n),r.needsUpdate=!1);var a=!1,s=!1,c=!1,l=i.program,u=l.getUniforms(),p=i.shader.uniforms;if(bt.useProgram(l.program)&&(a=!0,s=!0,c=!0),r.id!==z&&(z=r.id,s=!0),a||t!==U){if(u.setValue(vt,"projectionMatrix",t.projectionMatrix),xt.logarithmicDepthBuffer&&u.setValue(vt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),U!==(B||t)&&(U=B||t,s=!0,c=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var f=u.map.cameraPosition;void 0!==f&&f.setValue(vt,dt.setFromMatrixPosition(t.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&u.setValue(vt,"viewMatrix",t.matrixWorldInverse)}if(r.skinning){u.setOptional(vt,n,"bindMatrix"),u.setOptional(vt,n,"bindMatrixInverse");var d=n.skeleton;if(d){var g=d.bones;if(xt.floatVertexTextures){if(void 0===d.boneTexture){var x=Math.sqrt(4*g.length);x=Eh.nextPowerOfTwo(Math.ceil(x)),x=Math.max(x,4);var b=new Float32Array(x*x*4);b.set(d.boneMatrices);var w=new h(b,x,x,Ku,Gu);d.boneMatrices=b,d.boneTexture=w,d.boneTextureSize=x}u.setValue(vt,"boneTexture",d.boneTexture),u.setValue(vt,"boneTextureSize",d.boneTextureSize)}else u.setOptional(vt,d,"boneMatrices")}}return(s||r.forceUniformsUpdate)&&(u.setValue(vt,"toneMappingExposure",I.toneMappingExposure),u.setValue(vt,"toneMappingWhitePoint",I.toneMappingWhitePoint),r.lights&&function(t,e){t.ambientLightColor.needsUpdate=e,t.directionalLights.needsUpdate=e,t.pointLights.needsUpdate=e,t.spotLights.needsUpdate=e,t.rectAreaLights.needsUpdate=e,t.hemisphereLights.needsUpdate=e}(p,c),e&&r.fog&&function(t,e){t.fogColor.value=e.color,e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}(p,e),r.isMeshBasicMaterial?v(p,r):r.isMeshLambertMaterial?(v(p,r),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(p,r)):r.isMeshPhongMaterial?(v(p,r),r.isMeshToonMaterial?function(t,e){y(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(p,r):y(p,r)):r.isMeshStandardMaterial?(v(p,r),r.isMeshPhysicalMaterial?function(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,_(t,e)}(p,r):_(p,r)):r.isMeshDepthMaterial?(v(p,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(p,r)):r.isMeshDistanceMaterial?(v(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?(v(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?(function(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}(p,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(p,r)):r.isPointsMaterial?function(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*K,t.scale.value=.5*Z,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=Fh.LTC_MAT_TEXTURE),void 0!==p.ltcMag&&(p.ltcMag.value=Fh.LTC_MAG_TEXTURE),H.upload(vt,i.uniformsList,p,I)),u.setValue(vt,"modelViewMatrix",n.modelViewMatrix),u.setValue(vt,"normalMatrix",n.normalMatrix),u.setValue(vt,"modelMatrix",n.matrixWorld),l}function v(t,e){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);var r;if(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 y(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 _(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)}var x=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),b=void 0!==t.context?t.context:null,w=void 0!==t.alpha&&t.alpha,S=void 0===t.depth||t.depth,M=void 0===t.stencil||t.stencil,A=void 0!==t.antialias&&t.antialias,E=void 0===t.premultipliedAlpha||t.premultipliedAlpha,C=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,T=[],P=[],L=null,R=[],N=[];this.domElement=x,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=vu,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var I=this,O=!1,D=null,F=null,z=-1,k="",U=null,B=null,V=new o,j=new o,G=null,W=0,Y=x.width,Z=x.height,K=1,J=new o(0,0,Y,Z),tt=new o(0,0,Y,Z),et=!1,rt=new ot,ct=new function(){function t(){l.value!==n&&(l.value=n,l.needsUpdate=i>0),r.numPlanes=i,r.numIntersection=0}function e(t,e,n,i){var o=null!==t?t.length:0,a=null;if(0!==o){if(a=l.value,!0!==i||null===a){var u=n+4*o,h=e.matrixWorldInverse;c.getNormalMatrix(h),(null===a||a.length=0){var l=i[s];if(void 0!==l){var u=l.normalized,h=l.itemSize,p=Et.get(l);if(void 0===p)continue;var f=p.buffer,d=p.type,m=p.bytesPerElement;if(l.isInterleavedBufferAttribute){var g=l.data,v=g.stride,y=l.offset;g&&g.isInstancedInterleavedBuffer?(bt.enableAttributeAndDivisor(c,g.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=g.meshPerAttribute*g.count)):bt.enableAttribute(c),vt.bindBuffer(vt.ARRAY_BUFFER,f),vt.vertexAttribPointer(c,h,d,u,v*m,(n*v+y)*m)}else l.isInstancedBufferAttribute?(bt.enableAttributeAndDivisor(c,l.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=l.meshPerAttribute*l.count)):bt.enableAttribute(c),vt.bindBuffer(vt.ARRAY_BUFFER,f),vt.vertexAttribPointer(c,h,d,u,0,n*h*m)}else if(void 0!==a){var _=a[s];if(void 0!==_)switch(_.length){case 2:vt.vertexAttrib2fv(c,_);break;case 3:vt.vertexAttrib3fv(c,_);break;case 4:vt.vertexAttrib4fv(c,_);break;default:vt.vertexAttrib1fv(c,_)}}}}bt.disableUnusedAttributes()}}(i,s,n),null!==u&&vt.bindBuffer(vt.ELEMENT_ARRAY_BUFFER,f.buffer));var m=0;null!==u?m=u.count:void 0!==h&&(m=h.count);var v=n.drawRange.start*p,y=n.drawRange.count*p,_=null!==a?a.start*p:0,x=null!==a?a.count*p:1/0,b=Math.max(v,_),w=Math.min(m,v+y,_+x)-1,S=Math.max(0,w-b+1);if(0!==S){if(o.isMesh)if(!0===i.wireframe)bt.setLineWidth(i.wireframeLinewidth*e()),d.setMode(vt.LINES);else switch(o.drawMode){case dh:d.setMode(vt.TRIANGLES);break;case mh:d.setMode(vt.TRIANGLE_STRIP);break;case gh:d.setMode(vt.TRIANGLE_FAN)}else if(o.isLine){var M=i.linewidth;void 0===M&&(M=1),bt.setLineWidth(M*e()),o.isLineSegments?d.setMode(vt.LINES):o.isLineLoop?d.setMode(vt.LINE_LOOP):d.setMode(vt.LINE_STRIP)}else o.isPoints&&d.setMode(vt.POINTS);n&&n.isInstancedBufferGeometry?n.maxInstancedCount>0&&d.renderInstances(n,b,S):d.render(b,S)}},this.compile=function(t,e){T.length=0,P.length=0,t.traverse(function(t){t.isLight&&(T.push(t),t.castShadow&&P.push(t))}),Nt.setup(T,P,e),t.traverse(function(e){if(e.material)if(Array.isArray(e.material))for(var r=0;r=0&&e<=t.width-n&&r>=0&&r<=t.height-i&&vt.readPixels(e,r,n,i,Yt.convert(l),Yt.convert(u),o)}finally{s&&vt.bindFramebuffer(vt.FRAMEBUFFER,F)}}}}}function ne(t,e){this.name="",this.color=new X(t),this.density=void 0!==e?e:25e-5}function ie(t,e,r){this.name="",this.color=new X(t),this.near=void 0!==e?e:1,this.far=void 0!==r?r:1e3}function oe(){ut.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function ae(t,e,r,n,i){ut.call(this),this.lensFlares=[],this.positionScreen=new l,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,r,n,i)}function se(t){K.call(this),this.type="SpriteMaterial",this.color=new X(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function ce(t){ut.call(this),this.type="Sprite",this.material=void 0!==t?t:new se}function le(){ut.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function ue(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&&(h.needsUpdate=!0)}i.call(this,t,e,r,n,o,a,s,c,l),this.generateMipmaps=!1;var h=this;u()}function be(t,e,r,n,o,a,s,c,l,u,h,p){i.call(this,null,a,s,c,l,u,n,o,h,p),this.image={width:e,height:r},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function we(t,e,r,n,o,a,s,c,l,u){if((u=void 0!==u?u:eh)!==eh&&u!==rh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&u===eh&&(r=Bu),void 0===r&&u===rh&&(r=qu),i.call(this,null,n,o,a,s,c,u,r,l),this.image={width:t,height:e},this.magFilter=void 0!==s?s:Ru,this.minFilter=void 0!==c?c:Ru,this.flipY=!1,this.generateMipmaps=!1}function Se(t){Pt.call(this),this.type="WireframeGeometry";var e,r,n,i,o,a,s,c,u,h,p=[],f=[0,0],d={},m=["a","b","c"];if(t&&t.isGeometry){var g=t.faces;for(e=0,n=g.length;e=0?(p=t(v-1e-5,g,p),f.subVectors(h,p)):(p=t(v+1e-5,g,p),f.subVectors(p,h)),g-1e-5>=0?(p=t(v,g-1e-5,p),d.subVectors(h,p)):(p=t(v,g+1e-5,p),d.subVectors(p,h)),u.crossVectors(f,d).normalize(),s.push(u.x,u.y,u.z),c.push(v,g)}}for(n=0;n.9&&o<.1&&(e<.2&&(h[t+0]+=1),r<.2&&(h[t+2]+=1),n<.2&&(h[t+4]+=1))}}()}(),this.addAttribute("position",new At(u,3)),this.addAttribute("normal",new At(u.slice(),3)),this.addAttribute("uv",new At(h,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}function Te(t,e){gt.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Pe(t,e)),this.mergeVertices()}function Pe(t,e){Ce.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 Le(t,e){gt.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Re(t,e)),this.mergeVertices()}function Re(t,e){Ce.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 Ne(t,e){gt.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Ie(t,e)),this.mergeVertices()}function Ie(t,e){var r=(1+Math.sqrt(5))/2;Ce.call(this,[-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],[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 Oe(t,e){gt.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new De(t,e)),this.mergeVertices()}function De(t,e){var r=(1+Math.sqrt(5))/2,n=1/r;Ce.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-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],[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 Fe(t,e,r,n,i,o){gt.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:r,radialSegments:n,closed:i};var a=new ze(t,e,r,n,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function ze(t,e,r,i,o){function a(n){var o=t.getPointAt(n/e),a=s.normals[n],c=s.binormals[n];for(u=0;u<=i;u++){var l=u/i*Math.PI*2,f=Math.sin(l),g=-Math.cos(l);p.x=g*a.x+f*c.x,p.y=g*a.y+f*c.y,p.z=g*a.z+f*c.z,p.normalize(),m.push(p.x,p.y,p.z),h.x=o.x+r*p.x,h.y=o.y+r*p.y,h.z=o.z+r*p.z,d.push(h.x,h.y,h.z)}}Pt.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:r,radialSegments:i,closed:o},e=e||64,r=r||1,i=i||8,o=o||!1;var s=t.computeFrenetFrames(e,o);this.tangents=s.tangents,this.normals=s.normals,this.binormals=s.binormals;var c,u,h=new l,p=new l,f=new n,d=[],m=[],g=[],v=[];!function(){for(c=0;c0)&&m.push(w,S,A),(c!==r-1||u0&&u(!0),e>0&&u(!1)),this.setIndex(p),this.addAttribute("position",new At(f,3)),this.addAttribute("normal",new At(d,3)),this.addAttribute("uv",new At(m,2))}function nr(t,e,r,n,i,o,a){er.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 ir(t,e,r,n,i,o,a){rr.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 or(t,e,r,n){gt.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},this.fromBufferGeometry(new ar(t,e,r,n)),this.mergeVertices()}function ar(t,e,r,i){Pt.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:i},t=t||50,e=void 0!==e?Math.max(3,e):8,r=void 0!==r?r:0,i=void 0!==i?i:2*Math.PI;var o,a,s=[],c=[],u=[],h=[],p=new l,f=new n;for(c.push(0,0,0),u.push(0,0,1),h.push(.5,.5),a=0,o=3;a<=e;a++,o+=3){var d=r+a/e*i;p.x=t*Math.cos(d),p.y=t*Math.sin(d),c.push(p.x,p.y,p.z),u.push(0,0,1),f.x=(c[o]/t+1)/2,f.y=(c[o+1]/t+1)/2,h.push(f.x,f.y)}for(o=1;o<=e;o++)s.push(o,o+1,0);this.setIndex(s),this.addAttribute("position",new At(c,3)),this.addAttribute("normal",new At(u,3)),this.addAttribute("uv",new At(h,2))}function sr(t){K.call(this),this.type="ShadowMaterial",this.color=new X(0),this.opacity=1,this.lights=!0,this.transparent=!0,this.setValues(t)}function cr(t){Q.call(this,t),this.type="RawShaderMaterial"}function lr(t){K.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new X(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new X(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function ur(t){lr.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(t)}function hr(t){K.call(this),this.type="MeshPhongMaterial",this.color=new X(16777215),this.specular=new X(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new X(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=fu,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function pr(t){hr.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function fr(t){K.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function dr(t){K.call(this),this.type="MeshLambertMaterial",this.color=new X(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new X(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=fu,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function mr(t){fe.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}function gr(t,e,r){var n=this,i=!1,o=0,a=0;this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(t){a++,!1===i&&void 0!==n.onStart&&n.onStart(t,o,a),i=!0},this.itemEnd=function(t){o++,void 0!==n.onProgress&&n.onProgress(t,o,a),o===a&&(i=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(t){void 0!==n.onError&&n.onError(t)}}function vr(t){this.manager=void 0!==t?t:qh}function yr(t){this.manager=void 0!==t?t:qh,this._parser=null}function _r(t){this.manager=void 0!==t?t:qh,this._parser=null}function xr(t){this.manager=void 0!==t?t:qh}function br(t){this.manager=void 0!==t?t:qh}function wr(t){this.manager=void 0!==t?t:qh}function Sr(t,e){ut.call(this),this.type="Light",this.color=new X(t),this.intensity=void 0!==e?e:1,this.receiveShadow=void 0}function Mr(t,e,r){Sr.call(this,t,r),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(ut.DefaultUp),this.updateMatrix(),this.groundColor=new X(e)}function Ar(t){this.camera=t,this.bias=0,this.radius=1,this.mapSize=new n(512,512),this.map=null,this.matrix=new u}function Er(){Ar.call(this,new ft(50,1,.5,500))}function Cr(t,e,r,n,i,o){Sr.call(this,t,e),this.type="SpotLight",this.position.copy(ut.DefaultUp),this.updateMatrix(),this.target=new ut,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==r?r:0,this.angle=void 0!==n?n:Math.PI/3,this.penumbra=void 0!==i?i:0,this.decay=void 0!==o?o:1,this.shadow=new Er}function Tr(t,e,r,n){Sr.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(t){this.intensity=t/(4*Math.PI)}}),this.distance=void 0!==r?r:0,this.decay=void 0!==n?n:1,this.shadow=new Ar(new ft(90,1,.5,500))}function Pr(){Ar.call(this,new pt(-5,5,5,-5,.5,500))}function Lr(t,e){Sr.call(this,t,e),this.type="DirectionalLight",this.position.copy(ut.DefaultUp),this.updateMatrix(),this.target=new ut,this.shadow=new Pr}function Rr(t,e){Sr.call(this,t,e),this.type="AmbientLight",this.castShadow=void 0}function Nr(t,e,r,n){Sr.call(this,t,e),this.type="RectAreaLight",this.position.set(0,1,0),this.updateMatrix(),this.width=void 0!==r?r:10,this.height=void 0!==n?n:10}function Ir(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 Or(t,e,r,n){Ir.call(this,t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Dr(t,e,r,n){Ir.call(this,t,e,r,n)}function Fr(t,e,r,n){Ir.call(this,t,e,r,n)}function zr(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=Zh.convertArray(e,this.TimeBufferType),this.values=Zh.convertArray(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation),this.validate(),this.optimize()}function kr(t,e,r,n){zr.call(this,t,e,r,n)}function Ur(t,e,r,n){Ir.call(this,t,e,r,n)}function Br(t,e,r,n){zr.call(this,t,e,r,n)}function Vr(t,e,r,n){zr.call(this,t,e,r,n)}function jr(t,e,r,n){zr.call(this,t,e,r,n)}function Gr(t,e,r){zr.call(this,t,e,r)}function Wr(t,e,r,n){zr.call(this,t,e,r,n)}function Hr(t,e,r,n){zr.apply(this,arguments)}function Xr(t,e,r){this.name=t,this.tracks=r,this.duration=void 0!==e?e:-1,this.uuid=Eh.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function Yr(t){this.manager=void 0!==t?t:qh,this.textures={}}function qr(t){this.manager=void 0!==t?t:qh}function Zr(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function $r(t){"boolean"==typeof t&&(t=void 0),this.manager=void 0!==t?t:qh,this.withCredentials=!1}function Kr(t){this.manager=void 0!==t?t:qh,this.texturePath=""}function Qr(t,e,r,n,i){var o=.5*(n-e),a=.5*(i-r),s=t*t;return(2*r-2*n+o+a)*(t*s)+(-3*r+3*n-2*o-a)*s+o*t+r}function Jr(t,e,r,n){return function(t,e){var r=1-t;return r*r*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,r)+function(t,e){return t*t*e}(t,n)}function tn(t,e,r,n,i){return function(t,e){var r=1-t;return r*r*r*e}(t,e)+function(t,e){var r=1-t;return 3*r*r*t*e}(t,r)+function(t,e){return 3*(1-t)*t*t*e}(t,n)+function(t,e){return t*t*t*e}(t,i)}function en(){this.arcLengthDivisions=200}function rn(t,e){en.call(this),this.v1=t,this.v2=e}function nn(){en.call(this),this.curves=[],this.autoClose=!1}function on(t,e,r,n,i,o,a,s){en.call(this),this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=n,this.aStartAngle=i,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s||0}function an(t){en.call(this),this.points=void 0===t?[]:t}function sn(t,e,r,n){en.call(this),this.v0=t,this.v1=e,this.v2=r,this.v3=n}function cn(t,e,r){en.call(this),this.v0=t,this.v1=e,this.v2=r}function ln(t){nn.call(this),this.currentPoint=new n,t&&this.fromPoints(t)}function un(){ln.apply(this,arguments),this.holes=[]}function hn(){this.subPaths=[],this.currentPath=null}function pn(t){this.data=t}function fn(t){this.manager=void 0!==t?t:qh}function dn(t){this.manager=void 0!==t?t:qh}function mn(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ft,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ft,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function gn(t,e,r){ut.call(this),this.type="CubeCamera";var n=new ft(90,1,t,e);n.up.set(0,-1,0),n.lookAt(new l(1,0,0)),this.add(n);var i=new ft(90,1,t,e);i.up.set(0,-1,0),i.lookAt(new l(-1,0,0)),this.add(i);var o=new ft(90,1,t,e);o.up.set(0,0,1),o.lookAt(new l(0,1,0)),this.add(o);var a=new ft(90,1,t,e);a.up.set(0,0,-1),a.lookAt(new l(0,-1,0)),this.add(a);var c=new ft(90,1,t,e);c.up.set(0,-1,0),c.lookAt(new l(0,0,1)),this.add(c);var u=new ft(90,1,t,e);u.up.set(0,-1,0),u.lookAt(new l(0,0,-1)),this.add(u);var h={format:$u,magFilter:Ou,minFilter:Ou};this.renderTarget=new s(r,r,h),this.renderTarget.texture.name="CubeCamera",this.update=function(t,e){null===this.parent&&this.updateMatrixWorld();var r=this.renderTarget,s=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,r.activeCubeFace=0,t.render(e,n,r),r.activeCubeFace=1,t.render(e,i,r),r.activeCubeFace=2,t.render(e,o,r),r.activeCubeFace=3,t.render(e,a,r),r.activeCubeFace=4,t.render(e,c,r),r.texture.generateMipmaps=s,r.activeCubeFace=5,t.render(e,u,r),t.setRenderTarget(null)},this.clear=function(t,e,r,n){for(var i=this.renderTarget,o=0;o<6;o++)i.activeCubeFace=o,t.setRenderTarget(i),t.clear(e,r,n);t.setRenderTarget(null)}}function vn(){ut.call(this),this.type="AudioListener",this.context=np.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function yn(t){ut.call(this),this.type="Audio",this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.loop=!1,this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function _n(t){yn.call(this,t),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function xn(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=void 0!==e?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}function bn(t,e,r){this.binding=t,this.valueSize=r;var n,i=Float64Array;switch(e){case"quaternion":n=this._slerp;break;case"string":case"bool":i=Array,n=this._select;break;default:n=this._lerp}this.buffer=new i(4*r),this._mixBufferRegion=n,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}function wn(t,e,r){var n=r||Sn.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}function Sn(t,e,r){this.path=e,this.parsedPath=r||Sn.parseTrackName(e),this.node=Sn.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function Mn(t){this.uuid=Eh.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var r=0,n=arguments.length;r!==n;++r)e[arguments[r].uuid]=r;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var i=this;this.stats={objects:{get total(){return i._objects.length},get inUse(){return this.total-i.nCachedObjects_}},get bindingsPerObject(){return i._bindings.length}}}function An(t,e,r){this._mixer=t,this._clip=e,this._localRoot=r||null;for(var n=e.tracks,i=n.length,o=new Array(i),a={endingStart:fh,endingEnd:fh},s=0;s!==i;++s){var c=n[s].createInterpolant(null);o[s]=c,c.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=ph,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function En(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Cn(t){"string"==typeof t&&(t=arguments[1]),this.value=t}function Tn(){Pt.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function Pn(t,e,r,n){this.uuid=Eh.generateUUID(),this.data=t,this.itemSize=e,this.offset=r,this.normalized=!0===n}function Ln(t,e){this.uuid=Eh.generateUUID(),this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function Rn(t,e,r){Ln.call(this,t,e),this.meshPerAttribute=r||1}function Nn(t,e,r){vt.call(this,t,e),this.meshPerAttribute=r||1}function In(t,e,r,n){this.ray=new Dt(t,e),this.near=r||0,this.far=n||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return this.Points}}})}function On(t,e){return t.distance-e.distance}function Dn(t,e,r,n){if(!1!==t.visible&&(t.raycast(e,r),!0===n))for(var i=t.children,o=0,a=i.length;o0&&(i=Object.create(i))}return i}function _i(t){function e(t,e){return function(){var i=_i.spaces.substr(0,2*n);r&&gp.debug(i+e+" {"),n++;var o=t.apply(this,arguments);return n--,r&&gp.debug(i+"} // "+e),o}}var r=!1;this.enable=function(t){r=t};for(var n=0,i=Object.keys(t),o=0,a=i.length;o=3&&"base64"===e[r-2]?new Blob([wi(e[r-1])]):null}function Ei(t,e){t.includes(e)||t.push(e)}function Ci(t,e){var r=t.indexOf(e);-1!==r&&t.splice(r,1)}function Ti(t,e,r){e.forEach(function(e){e=e.toLowerCase();var n=t[e]=t[e]||[];n.includes(r)||n.push(r)})}function Pi(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]}})}function Li(t,e,r){var n=document.createElement(t);return n.id=e,n.style.cssText=r,n}function Ri(){this.domElement=Li("div","stats","padding:8px"),this._text=Li("p","fps","margin:0;color:silver;font-size:large"),this.domElement.appendChild(this._text),this._startTime=xp(),this._prevTime=this._startTime,this._deltas=new Array(20),this._index=0,this._total=0,this._count=0}function Ni(){this.old=null,this.now={},this._changed={},this.reset()}function Ii(t){return!(!t||"0"===t||Sl.isString(t)&&"false"===t.toLowerCase())}function Oi(t){return _p.encodeQueryComponent(t,kp)}function Di(t){return _p.encodeQueryComponent(t,Up)}function Fi(t){var e=t.reps;if(!e){var r=Lp.now.presets,n=t.preset||Lp.now.preset;(e=r[n])||(gp.warn('Unknown preset "'+n+'"'),e=r[n=Object.keys(r)[0]]),t.preset=n,t.reps=_p.deriveDeep(e,!0)}}function zi(t,e,r){Fi(t);var n=t.reps[Rp];n.hasOwnProperty(e)&&++Rp>=t.reps.length&&(t.reps[Rp]=_p.deriveDeep(n,!0)),void 0!==r&&(t.reps[Rp][e]=r)}function ki(t,e,r){if(t){var n=t.indexOf(Op),i=function(t,e){var r=t.indexOf(",");return r>=0?(e.push(t.substr(r+1).split(",")),t.substr(0,r)):t}(t.substr(0,n>=0?n:void 0),r);if(n>=0){var o=t.substr(n+1).split(Fp);if(t=i,e){var a=e[t],s=_p.deriveDeep(a,!0);o.forEach(function(e){var r=e.split(Dp,2),n=decodeURIComponent(r[0]),i=decodeURIComponent(r[1]),o=Np[bp(Sl.get(a,n))];o?Sl.set(s,n,o(i)):gp.warn('Unknown argument "'+n+'" for option "'+t+'"')}),Object.keys(s).length>0&&(t=[t,s])}}else t=i}return t}function Ui(t){Rp=0;for(var e={},r=0,n=t.length;r0&&(e+=","+t.params.join(",")),t.opts&&(e+=Op+Bi(t.opts)),e}}function Gi(t){var e=[],r=0;return _p.forInRecursive(t,function(t,n){e[r++]=n+"="+_p.enquoteString(t)}),e.join(" ")}function Wi(t){return Sl.isArray(t)?t[0]+(t.length<2?"":" "+Gi(t[1])):t}function Hi(t){if(t&&t.type){var e=t.type;return Sl.isArray(t.params)&&t.params.length>0&&(e+=" "+t.params.map(_p.enquoteString).join(" ")),t.opts&&(e+=" "+Gi(t.opts)),e}}function Xi(t,e){function r(t,e){null!==e&&void 0!==e&&(n[i++]=t+e)}var n=[],i=0;return Sl.isEmpty(t)?null:(r("",e),r("s=",_p.enquoteString(t.selector)),r("m=",Wi(t.mode)),r("c=",Wi(t.colorer)),r("mt=",Wi(t.material)),n.join(" "))}function Yi(t,e){this._node=e||null,this._name=t||null,null===this._node&&null===this._name&&(this._name="Unknown")}function qi(t,e,r,n,i,o,a){this.number=t,this.name=e,this.fullName=r,this.weight=n,this.radius=i,this.radiusBonding=o,this.hydrogenValency=a}function Zi(t,e,r,n,i,o,a,s,c,l,u){this._index=-1,this._residue=t,this._name=e instanceof Yi?e:new Yi(e),this.element=r,this._position=n,this._role=i,this._mask=1,this._index=-1,this._het=o,this._serial=a,this._location=(s||" ").charCodeAt(0),this._occupancy=c||1,this._temperature=l,this._charge=u,this._hydrogenCount=-1,this._radicalCount=0,this._valence=-1,this._bonds=[],this.flags=0,"H"===r.name?this.flags|=Zi.Flags.HYDROGEN:"C"===r.name&&(this.flags|=Zi.Flags.CARBON)}function $i(t){return t<2?1:t}function Ki(t){return t._position}function Qi(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 Ji(t,e,r){this._name=t,this._fullName=e,this.letterCode=r,this.flags=0}function to(t,e){for(var r=0,n=e.length;r=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}function no(){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=ro(ho(t.split("/"),function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function io(t){var e=oo(t),r="/"===Xp(t,-1);return(t=ro(ho(t.split("/"),function(t){return!!t}),!e).join("/"))||e||(t="."),t&&r&&(t+="/"),(e?"/":"")+t}function oo(t){return"/"===t.charAt(0)}function ao(){return io(ho(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 so(t,e){function r(t){for(var e=0;e=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=no(t).substr(1),e=no(e).substr(1);for(var n=r(t.split("/")),i=r(e.split("/")),o=Math.min(n.length,i.length),a=o,s=0;sr?r:t}function So(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}function Mo(t,e){for(var r=0;r3}function Ro(t){return!0}function No(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 Fo(t,e,r,n){var i,o=r-t.z,a=n-t.z,s=Math.sqrt(Math.max(e*e-o*o,0)),c=Math.sqrt(Math.max(e*e-a*a,0)),l=Math.min(s,c);return i=r<=t.z&&n>=t.z?e:Math.max(s,c),[l,i]}function zo(t,e,r,n){var i,o=r-t.y,a=n-t.y,s=Math.sqrt(Math.max(e*e-o*o,0)),c=Math.sqrt(Math.max(e*e-a*a,0)),l=Math.min(s,c);return i=r<=t.y&&n>=t.y?e:Math.max(s,c),[l,i]}function ko(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=fp.allocateTyped(Int32Array,n),r=0;r0,c=!1===o&&e>0,u=(i+1)*n+s*(n+1)+c*(n+1),h=(2*i+s+c)*n,p=r/2,f=new vt(fp.allocateTyped(Float32Array,3*u),3),d=new vt(fp.allocateTyped(Float32Array,3*u),3),m=new wt(fp.allocateTyped(Uint16Array,h*kf),1),g=new vt(fp.allocateTyped(Float32Array,2*u),2),v=0,y=0,_=-(e-t)/r,x=0;x<=i;x++){if(x!==i)for(var b=0;bp&&(p=n),h[t]=n*n}!function(){d=r.scaleFactor,g=e.dim,C=Math.min(5,2+Math.floor(f*d));var t=g[0]*g[1]*g[2];v=function(t,e,r){for(var n=fp.allocateTyped(t,e),i=0;iC&&(C=L)}this.neighbourListLength=27*C+1,this.withinRadii=function(e,r,n,s,h){var p=0,f=i(e,c),v=i(r,l),_=i(n,u),x=Math.max(0,f-1),b=Math.max(0,v-1),E=Math.max(0,_-1),C=Math.min(d-1,f+1),T=Math.min(m-1,v+1),P=Math.min(g-1,_+1);for(o=x;o<=C;++o){var L=o*y;for(w=b;w<=T;++w)for(var R=w*g,N=E;N<=P;++N)for(var I=S[a=L+R+N],O=I+M[a],D=I;D=0;){if(o!==n&&o!==i&&s(o,t,e,r))return F=o,o;o=E[++a]}return F=-1,-1}function s(t,e,r,n){var i=T*t,o=h[t],a=P[i]-e,s=P[i+1]-r,c=P[i+2]-n;return a*a+s*s+c*c=0;)t0&&fz[Z]&&(z[Z]=J,k[Z]=R[t]),v[Z]<0&&(v[Z]=-v[Z]);var et=Math.sqrt(Q),rt=o/et,nt=K*rt,it=X*rt,ot=G*rt;if(nt+=r,it+=n,ot+=i,-1===a(nt,it,ot,t,-1)){var at=o-et;at0){r=1/r;var n=3*t;y[n]*=r,y[n+1]*=r,y[n+2]*=r}}}()}var h,p,f,d,m,g,v,y,_,x,b,w,S,M,A,E,C,T=4,P=t.posRad,L=t.colors,R=t.atoms,N=P.length/T,I=e.bbox,O=I.minPosRad,D=I.maxPosRad,F=-1,z=null,k=null,U=null,B=new l(0,0,0),V=new l(0,0,0),j=new l(0,0,0);this.build=function(){u(),this.volTexMap=y,this.weightsMap=z,this.atomMap=k,this.volMap=v}}function Ma(t,e){ba.call(this,t,e)}function Aa(t,e){this.coord=new l,this.coord.copy(t),this.radius=e,this.colorX=.99999,this.colorY=0,this.colorZ=0,this.atomType=0,this.srcAtom=null}function Ea(t,e,r,n,i){this._numAtoms=t,this._atoms=e,this._vBoxMin=new l,this._vBoxMax=new l,this._vBoxMin.copy(r),this._vBoxMax.copy(n),this._probeRadius=i,this._atomsList=null,this._voxelList=null}function Ca(t,e,r,n,i,o,a){this.complex=t,this.atoms=r,this.pdbAtoms=e,this.numVoxels=o,this.colorMode=a,this.vBoxMin=new l,this.vBoxMax=new l,this.vBoxMin.copy(n),this.vBoxMax.copy(i),this.voxelsRefs=null,this.voxels=null}function Ta(t,e,r){this._maxNumVertices=t,this._maxNumTriangles=e,this._vertices=new Array(t),this._normals=new Array(t),this._colors=null,r&&(this._colors=new Array(t)),this._indices=new Array(3*e),this._numVertices=0,this._numTriangles=0;var n;for(n=0;n0?n:[new u];for(var o=this._createMeshes(t),a=0,s=o.length;as&&t[e-1]._isValid?e-1:e}function o(e){return e0&&(d[m++]=t)});var g=new t(e,{cycles:d,atoms:l,chunks:p,parent:r},n,i,u,o,s);g._component=h,c.add(g)})}function xs(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 Bo(n);s.position.copy(t),s.userData={translation:"translate(-50%, -50%)",color:e};var c=s.getElement();return c.style.visibility="visible",c.style.textAlign="center",c.style.verticalAlign="middle",s}function bs(t,e,r,n,i,o,a,s){Vo.call(this);for(var c=new Vo,u=0;u=tg?t-eg:t}function Uc(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 Bc(t,e){if(this.constructor===Bc)throw new Error("Can not instantiate abstract class!");this.params=t,this.opts=vl.merge(fp.deriveDeep(gp.now.objects[this.type],!0),e),this.needsRebuild=!1}function Vc(t,e){if(Bc.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]}function jc(t){return new Q({uniforms:function(t){var e=Rh.clone(ag);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:ig,fragmentShader:og,transparent:!0,depthTest:!1,depthWrite:!1})}function Gc(t){return new Q({uniforms:function(t){var e=Rh.clone(cg);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:ig,fragmentShader:sg,transparent:!0,depthTest:!1,depthWrite:!1})}function Wc(t,e){var r=Rh.clone(e);for(var n in t)r.hasOwnProperty(n)&&(r[n].value=t[n]);return r}function Hc(t){return new Q({uniforms:function(t){var e=Rh.clone(gg);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:ig,fragmentShader:mg,transparent:!1,depthTest:!1,depthWrite:!1})}function Xc(){this.position=new l(0,0,0),this.scale=1,this.orientation=new c(0,0,0,1)}function Yc(){}function qc(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)}function $c(){}function Zc(t){for(var e=[],r=0,n=t.length;r=0&&(t=t.substr(0,e)),t}function nl(t){if("string"==typeof t)if(t.match(/^[0-9A-Z]{4}$/i))t=t.toUpperCase();else if(t.match(/^data\/[0-9A-Z]{4}\.pdb$/i))t=t.substr(5,4).toUpperCase();else{var e=document.createElement("a");e.href=t,t=e.href}return t}function il(t,e,r){r?t.debug(e+"... "+Math.floor(100*r)+"%"):t.debug(e+"...")}function ol(t){fi.call(this),this._opts=vl.merge({settingsCookie:"settings",cookiePath:"/"},t),this._gfx=null,this._container=t&&t.container||document.getElementById("miew-container")||vl.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=gp;var e=up;e.console=!1,e.level="info",this.logger=e,this._cookies=new el(this),this._loadSettings(),t&&t.settings&&this.settings.override(t.settings),this._spinner=null,this._loader=null,this._animInterval=null,this._visuals={},this._curVisualName=null,this._objects=[],this._sourceWindow=null,this._fileSource=null,this._fileSourceAnim=null,this.reset(),this._repr&&e.debug("Selected "+this._repr.mode.name+" mode with "+this._repr.colorer.name+" colorer.");var r=this;ol.registeredPlugins.forEach(function(t){t.call(r)})}function al(t,e){for(var r=t;r.firstChild;)r.removeChild(r.firstChild);r.appendChild(e)}function sl(t){return t instanceof Array?new pf.Range(t[0],t[1]):new pf.Range(t,t)}function cl(t){var e=pf.keyword(t[0]);if(!e||!e.SelectorClass)return null;var r=null,n=e.SelectorClass.prototype;return n instanceof pf.PrefixOperator&&2===t.length?r=e(cl(t[1])):n instanceof pf.InfixOperator&&3===t.length?r=e(cl(t[1]),cl(t[2])):n instanceof pf.RangeListSelector&&2===t.length?r=e(function(t){for(var e=[],r=0;r=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}function co(){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=so(vo(t.split("/"),function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function lo(t){var e=uo(t),r="/"===tf(t,-1);return(t=so(vo(t.split("/"),function(t){return!!t}),!e).join("/"))||e||(t="."),t&&r&&(t+="/"),(e?"/":"")+t}function uo(t){return"/"===t.charAt(0)}function ho(){return lo(vo(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 po(t,e){function r(t){for(var e=0;e=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=co(t).substr(1),e=co(e).substr(1);for(var n=r(t.split("/")),i=r(e.split("/")),o=Math.min(n.length,i.length),a=o,s=0;sr?r:t}function To(t){return!t.isHet()||t._bonds&&0===t._bonds.length}function Po(t){return"HOH"!==t._residue._type._name&&!t.isHet()}function Lo(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}function Ro(t,e){for(var r=0;r3}function ko(t){return!0}function Uo(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 Go(t,e,r,n){var i,o=r-t.z,a=n-t.z,s=Math.sqrt(Math.max(e*e-o*o,0)),c=Math.sqrt(Math.max(e*e-a*a,0)),l=Math.min(s,c);return i=r<=t.z&&n>=t.z?e:Math.max(s,c),[l,i]}function Wo(t,e,r,n){var i,o=r-t.y,a=n-t.y,s=Math.sqrt(Math.max(e*e-o*o,0)),c=Math.sqrt(Math.max(e*e-a*a,0)),l=Math.min(s,c);return i=r<=t.y&&n>=t.y?e:Math.max(s,c),[l,i]}function Ho(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=_p.allocateTyped(Int32Array,n),r=0;r0,c=!1===o&&e>0,u=(i+1)*n+s*(n+1)+c*(n+1),h=(2*i+s+c)*n,p=r/2,f=new vt(_p.allocateTyped(Float32Array,3*u),3),d=new vt(_p.allocateTyped(Float32Array,3*u),3),m=new wt(_p.allocateTyped(Uint16Array,h*Xf),1),g=new vt(_p.allocateTyped(Float32Array,2*u),2),v=0,y=0,_=-(e-t)/r,x=0;x<=i;x++){if(x!==i)for(var b=0;bp&&(p=n),h[t]=n*n}!function(){d=r.scaleFactor,g=e.dim,C=Math.min(5,2+Math.floor(f*d));var t=g[0]*g[1]*g[2];v=function(t,e,r){for(var n=_p.allocateTyped(t,e),i=0;iC&&(C=L)}this.neighbourListLength=27*C+1,this.withinRadii=function(e,r,n,s,h){var p=0,f=i(e,c),v=i(r,l),_=i(n,u),x=Math.max(0,f-1),b=Math.max(0,v-1),E=Math.max(0,_-1),C=Math.min(d-1,f+1),T=Math.min(m-1,v+1),P=Math.min(g-1,_+1);for(o=x;o<=C;++o){var L=o*y;for(w=b;w<=T;++w)for(var R=w*g,N=E;N<=P;++N)for(var I=S[a=L+R+N],O=I+M[a],D=I;D=0;){if(o!==n&&o!==i&&s(o,t,e,r))return F=o,o;o=E[++a]}return F=-1,-1}function s(t,e,r,n){var i=T*t,o=h[t],a=P[i]-e,s=P[i+1]-r,c=P[i+2]-n;return a*a+s*s+c*c=0;)t0&&fz[$]&&(z[$]=J,k[$]=R[t]),v[$]<0&&(v[$]=-v[$]);var et=Math.sqrt(Q),rt=o/et,nt=K*rt,it=X*rt,ot=G*rt;if(nt+=r,it+=n,ot+=i,-1===a(nt,it,ot,t,-1)){var at=o-et;at0){r=1/r;var n=3*t;y[n]*=r,y[n+1]*=r,y[n+2]*=r}}}()}var h,p,f,d,m,g,v,y,_,x,b,w,S,M,A,E,C,T=4,P=t.posRad,L=t.colors,R=t.atoms,N=P.length/T,I=e.bbox,O=I.minPosRad,D=I.maxPosRad,F=-1,z=null,k=null,U=null,B=new l(0,0,0),V=new l(0,0,0),j=new l(0,0,0);this.build=function(){u(),this.volTexMap=y,this.weightsMap=z,this.atomMap=k,this.volMap=v}}function Ra(t,e){Ta.call(this,t,e)}function Na(t,e){this.coord=new l,this.coord.copy(t),this.radius=e,this.colorX=.99999,this.colorY=0,this.colorZ=0,this.atomType=0,this.srcAtom=null}function Ia(t,e,r,n,i){this._numAtoms=t,this._atoms=e,this._vBoxMin=new l,this._vBoxMax=new l,this._vBoxMin.copy(r),this._vBoxMax.copy(n),this._probeRadius=i,this._atomsList=null,this._voxelList=null}function Oa(t,e,r,n,i,o,a){this.complex=t,this.atoms=r,this.pdbAtoms=e,this.numVoxels=o,this.colorMode=a,this.vBoxMin=new l,this.vBoxMax=new l,this.vBoxMin.copy(n),this.vBoxMax.copy(i),this.voxelsRefs=null,this.voxels=null}function Da(t,e,r){this._maxNumVertices=t,this._maxNumTriangles=e,this._vertices=new Array(t),this._normals=new Array(t),this._colors=null,r&&(this._colors=new Array(t)),this._indices=new Array(3*e),this._numVertices=0,this._numTriangles=0;var n;for(n=0;n0?n:[new u];for(var o=this._createMeshes(t),a=0,s=o.length;as&&t[e-1]._isValid?e-1:e}function o(e){return e0&&(d[m++]=t)});var g=new t(e,{cycles:d,atoms:l,chunks:p,parent:r},n,i,u,o,s);g._component=h,c.add(g)})}function Ts(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 Yo(n);s.position.copy(t),s.userData={translation:"translate(-50%, -50%)",color:e};var c=s.getElement();return c.style.visibility="visible",c.style.textAlign="center",c.style.verticalAlign="middle",s}function Ps(t,e,r,n,i,o,a,s){qo.call(this);for(var c=new qo,u=0;u=Tg?t-Pg:t}function Hc(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 Xc(t,e){if(this.constructor===Xc)throw new Error("Can not instantiate abstract class!");this.params=t,this.opts=Sl.merge(_p.deriveDeep(Lp.now.objects[this.type],!0),e),this.needsRebuild=!1}function Yc(t,e){if(Xc.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]}function qc(t){return new Q({uniforms:function(t){var e=zh.clone(Og);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:Ng,fragmentShader:Ig,transparent:!0,depthTest:!1,depthWrite:!1})}function Zc(t){return new Q({uniforms:function(t){var e=zh.clone(Fg);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:Ng,fragmentShader:Dg,transparent:!0,depthTest:!1,depthWrite:!1})}function $c(t,e){var r=zh.clone(e);for(var n in t)r.hasOwnProperty(n)&&(r[n].value=t[n]);return r}function Kc(t){return new Q({uniforms:function(t){var e=zh.clone(Wg);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:Ng,fragmentShader:Gg,transparent:!1,depthTest:!1,depthWrite:!1})}function Qc(){this.position=new l(0,0,0),this.scale=1,this.orientation=new c(0,0,0,1)}function Jc(){}function tl(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)}function el(){}function rl(t){for(var e=[],r=0,n=t.length;r=0&&(t=t.substr(0,e)),t}function ll(t,e,r){void 0!==r?t.debug(e+"... "+Math.floor(100*r)+"%"):t.debug(e+"...")}function ul(t){fi.call(this),this._opts=Sl.merge({settingsCookie:"settings",cookiePath:"/"},t),this._gfx=null,this._container=t&&t.container||document.getElementById("miew-container")||Sl.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=Lp;var e=gp;e.console=!1,e.level="info",this.logger=e,this._cookies=new sl(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;ul.registeredPlugins.forEach(function(t){t.call(r)})}function hl(t,e){for(var r=t;r.firstChild;)r.removeChild(r.firstChild);r.appendChild(e)}function pl(t,e,r){return new Promise(function(n){if(r.shouldCancel())throw new Error("Operation cancelled");t=function(t,e){if(!Sl.isString(t))return t;var r=sv.exec(t);if(r){var n=Ep(r,3),i=n[1],o=void 0===i?"pdb":i,a=n[2];switch(o=o.toLowerCase(),a=a.toUpperCase(),o){case"pdb":t="http://files.rcsb.org/download/"+a+".pdb";break;case"cif":t="http://files.rcsb.org/download/"+a+".cif";break;case"mmtf":t="http://mmtf.rcsb.org/v1.0/full/"+a;break;case"ccp4":t="https://www.ebi.ac.uk/pdbe/coordinates/files/"+a.toLowerCase()+".ccp4";break;default:throw new Error("Unexpected data format shortcut")}return e.fileType=o,e.fileName=a+"."+o,e.sourceType="url",t}var s=cv.exec(t);if(s){var c=s[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",lv.test(t)||(t=_p.resolveURL(t))),t}(t,e);var i=Sl.head(Ag.loaders.find({type:e.sourceType,source:t}));if(!i)throw new Error("Could not find suitable loader for this source");var o=e.fileName||i.extractName(t);if(o){var a=_p.splitFileName(o),s=Ep(a,2),c=s[0],l=s[1];Sl.defaults(e,{name:c,fileExt:l,fileName:o})}!function(t){var e=t.binary;if(void 0!==t.fileType){var r=Sl.head(Ag.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 n=Sl.head(Ag.parsers.find({ext:t.fileExt}));n&&(e=n.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}(e);var u=Sl.get(e,"preset.expression");if(!Sl.isUndefined(u)&&(u=JSON.parse(u))&&u.settings)for(var h=["singleUnit","draft.waterBondingHack"],p=0,f=h.length;p0?ll(g.logger,"Fetching",t.loaded/t.total):ll(g.logger,"Fetching")});n(g.load().then(function(t){return e.context.logger.info("Fetching finished"),r.notify({type:"fetchingFinished",data:t}),t}).catch(function(t){throw e.context.logger.debug(t.message),t.stack&&e.context.logger.debug(t.stack),e.context.logger.error("Fetching failed"),r.notify({type:"fetchingFinished",error:t}),t}))})}function fl(t){return t instanceof Array?new xf.Range(t[0],t[1]):new xf.Range(t,t)}function dl(t){var e=xf.keyword(t[0]);if(!e||!e.SelectorClass)return null;var r=null,n=e.SelectorClass.prototype;return n instanceof xf.PrefixOperator&&2===t.length?r=e(dl(t[1])):n instanceof xf.InfixOperator&&3===t.length?r=e(dl(t[1]),dl(t[2])):n instanceof xf.RangeListSelector&&2===t.length?r=e(function(t){for(var e=[],r=0;r * Copyright JS Foundation and other contributors @@ -11,7 +11,7 @@ function ro(t,e){for(var r=0,n=t.length-1;n>=0;n--){var i=t[n];"."===i?t.splice( * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ -(function(){function r(t,e){return t.set(e[0],e[1]),t}function n(t,e){return t.add(e),t}function i(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 o(t,e){for(var r=-1,n=null==t?0:t.length;++r-1}function l(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function T(t,e){for(var r=t.length;r--&&g(e,t[r],0)>-1;);return r}function P(t){return"\\"+cr[t]}function L(t){return rr.test(t)}function R(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function N(t,e){return function(r){return t(e(r))}}function I(t,e){for(var r=-1,n=t.length,i=0,o=[];++r>>1,_t=[["ary",nt],["bind",Z],["bindKey",K],["curry",J],["curryRight",tt],["flip",ot],["partial",et],["partialRight",rt],["rearg",it]],xt="[object Arguments]",bt="[object Array]",wt="[object AsyncFunction]",St="[object Boolean]",Mt="[object Date]",At="[object DOMException]",Et="[object Error]",Ct="[object Function]",Tt="[object GeneratorFunction]",Pt="[object Map]",Lt="[object Number]",Rt="[object Null]",Nt="[object Object]",It="[object Proxy]",Ot="[object RegExp]",Dt="[object Set]",Ft="[object String]",zt="[object Symbol]",kt="[object Undefined]",Ut="[object WeakMap]",Bt="[object WeakSet]",Vt="[object ArrayBuffer]",jt="[object DataView]",Gt="[object Float32Array]",Wt="[object Float64Array]",Ht="[object Int8Array]",Xt="[object Int16Array]",Yt="[object Int32Array]",qt="[object Uint8Array]",$t="[object Uint8ClampedArray]",Zt="[object Uint16Array]",Kt="[object Uint32Array]",Qt=/\b__p \+= '';/g,Jt=/\b(__p \+=) '' \+/g,te=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ee=/&(?:amp|lt|gt|quot|#39);/g,re=/[&<>"']/g,ne=RegExp(ee.source),ie=RegExp(re.source),oe=/<%-([\s\S]+?)%>/g,ae=/<%([\s\S]+?)%>/g,se=/<%=([\s\S]+?)%>/g,ce=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,le=/^\w*$/,ue=/^\./,he=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,pe=/[\\^$.*+?()[\]{}|]/g,fe=RegExp(pe.source),de=/^\s+|\s+$/g,me=/^\s+/,ge=/\s+$/,ve=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ye=/\{\n\/\* \[wrapped with (.+)\] \*/,_e=/,? & /,xe=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,be=/\\(\\)?/g,we=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Se=/\w*$/,Me=/^[-+]0x[0-9a-f]+$/i,Ae=/^0b[01]+$/i,Ee=/^\[object .+?Constructor\]$/,Ce=/^0o[0-7]+$/i,Te=/^(?:0|[1-9]\d*)$/,Pe=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Le=/($^)/,Re=/['\n\r\u2028\u2029\\]/g,Ne="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",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="[\\ud800-\\udfff]",De="["+Ie+"]",Fe="["+Ne+"]",ze="\\d+",ke="[\\u2700-\\u27bf]",Ue="[a-z\\xdf-\\xf6\\xf8-\\xff]",Be="[^\\ud800-\\udfff"+Ie+ze+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",Ve="\\ud83c[\\udffb-\\udfff]",je="[^\\ud800-\\udfff]",Ge="(?:\\ud83c[\\udde6-\\uddff]){2}",We="[\\ud800-\\udbff][\\udc00-\\udfff]",He="[A-Z\\xc0-\\xd6\\xd8-\\xde]",Xe="(?:"+Ue+"|"+Be+")",Ye="(?:"+He+"|"+Be+")",qe="(?:"+Fe+"|"+Ve+")"+"?",$e="[\\ufe0e\\ufe0f]?"+qe+("(?:\\u200d(?:"+[je,Ge,We].join("|")+")[\\ufe0e\\ufe0f]?"+qe+")*"),Ze="(?:"+[ke,Ge,We].join("|")+")"+$e,Ke="(?:"+[je+Fe+"?",Fe,Ge,We,Oe].join("|")+")",Qe=RegExp("['’]","g"),Je=RegExp(Fe,"g"),tr=RegExp(Ve+"(?="+Ve+")|"+Ke+$e,"g"),er=RegExp([He+"?"+Ue+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[De,He,"$"].join("|")+")",Ye+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[De,He+Xe,"$"].join("|")+")",He+"?"+Xe+"+(?:['’](?:d|ll|m|re|s|t|ve))?",He+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)","\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)",ze,Ze].join("|"),"g"),rr=RegExp("[\\u200d\\ud800-\\udfff"+Ne+"\\ufe0e\\ufe0f]"),nr=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ir=["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"],or=-1,ar={};ar[Gt]=ar[Wt]=ar[Ht]=ar[Xt]=ar[Yt]=ar[qt]=ar[$t]=ar[Zt]=ar[Kt]=!0,ar[xt]=ar[bt]=ar[Vt]=ar[St]=ar[jt]=ar[Mt]=ar[Et]=ar[Ct]=ar[Pt]=ar[Lt]=ar[Nt]=ar[Ot]=ar[Dt]=ar[Ft]=ar[Ut]=!1;var sr={};sr[xt]=sr[bt]=sr[Vt]=sr[jt]=sr[St]=sr[Mt]=sr[Gt]=sr[Wt]=sr[Ht]=sr[Xt]=sr[Yt]=sr[Pt]=sr[Lt]=sr[Nt]=sr[Ot]=sr[Dt]=sr[Ft]=sr[zt]=sr[qt]=sr[$t]=sr[Zt]=sr[Kt]=!0,sr[Et]=sr[Ct]=sr[Ut]=!1;var cr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},lr=parseFloat,ur=parseInt,hr="object"==typeof gl&&gl&&gl.Object===Object&&gl,pr="object"==typeof self&&self&&self.Object===Object&&self,fr=hr||pr||Function("return this")(),dr=e&&!e.nodeType&&e,mr=dr&&!0&&t&&!t.nodeType&&t,gr=mr&&mr.exports===dr,vr=gr&&hr.process,yr=function(){try{return vr&&vr.binding&&vr.binding("util")}catch(t){}}(),_r=yr&&yr.isArrayBuffer,xr=yr&&yr.isDate,br=yr&&yr.isMap,wr=yr&&yr.isRegExp,Sr=yr&&yr.isSet,Mr=yr&&yr.isTypedArray,Ar=_("length"),Er=x({"À":"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"}),Cr=x({"&":"&","<":"<",">":">",'"':""","'":"'"}),Tr=x({"&":"&","<":"<",">":">",""":'"',"'":"'"}),Pr=function t(e){function x(t){if(to(t)&&!Ws(t)&&!(t instanceof Oe)){if(t instanceof Ie)return t;if(Wo.call(t,"__wrapped__"))return Mi(t)}return new Ie(t)}function Ne(){}function Ie(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=k}function Oe(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=gt,this.__views__=[]}function De(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function $e(t,e,i,a,s,c){var l,u=e&H,h=e&X,f=e&Y;if(i&&(l=s?i(t,a,s,c):i(t)),l!==k)return l;if(!Ji(t))return t;var d=Ws(t);if(d){if(l=function(t){var e=t.length,r=t.constructor(e);return e&&"string"==typeof t[0]&&Wo.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!u)return En(t,l)}else{var m=ts(t),g=m==Ct||m==Tt;if(Xs(t))return xn(t,u);if(m==Nt||m==xt||g&&!s){if(l=h||g?{}:ci(t),!u)return h?function(t,e){return Cn(t,Ja(t),e)}(t,function(e,r){return e&&Cn(t,go(t),e)}(l)):function(t,e){return Cn(t,Qa(t),e)}(t,He(l,t))}else{if(!sr[m])return s?t:{};l=function(t,e,i,o){var a=t.constructor;switch(e){case Vt:return bn(t);case St:case Mt:return new a(+t);case jt:return function(t,e){var r=e?bn(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,o);case Gt:case Wt:case Ht:case Xt:case Yt:case qt:case $t:case Zt:case Kt:return wn(t,o);case Pt:return function(t,e,n){return p(e?n(R(t),H):R(t),r,new t.constructor)}(t,o,i);case Lt:case Ft:return new a(t);case Ot:return function(t){var e=new t.constructor(t.source,Se.exec(t));return e.lastIndex=t.lastIndex,e}(t);case Dt:return function(t,e,r){return p(e?r(O(t),H):O(t),n,new t.constructor)}(t,o,i);case zt:return function(t){return Ua?Do(Ua.call(t)):{}}(t)}}(t,m,$e,u)}}c||(c=new Ue);var v=c.get(t);if(v)return v;c.set(t,l);var y=d?k:(f?h?ti:Jn:h?go:mo)(t);return o(y||t,function(r,n){y&&(r=t[n=r]),Ge(l,n,$e(r,e,i,n,t,c))}),l}function Ze(t,e,r){var n=r.length;if(null==t)return!n;for(t=Do(t);n--;){var i=r[n],o=e[i],a=t[i];if(a===k&&!(i in t)||!o(a))return!1}return!0}function Ke(t,e,r){if("function"!=typeof t)throw new ko(V);return ns(function(){t.apply(k,r)},e)}function tr(t,e,r,n){var i=-1,o=c,a=!0,s=t.length,h=[],p=e.length;if(!s)return h;r&&(e=u(e,M(r))),n?(o=l,a=!1):e.length>=U&&(o=E,a=!1,e=new ke(e));t:for(;++i0&&r(s)?e>1?hr(s,e-1,r,n,i):h(i,s):n||(i[i.length]=s)}return i}function pr(t,e){return t&&Wa(t,e,mo)}function dr(t,e){return t&&Ha(t,e,mo)}function mr(t,e){return s(e,function(e){return Zi(t[e])})}function vr(t,e){for(var r=0,n=(e=yn(e,t)).length;null!=t&&re}function Rr(t,e){return null!=t&&Wo.call(t,e)}function Nr(t,e){return null!=t&&e in Do(t)}function Ir(t,e,r){for(var n=r?l:c,i=t[0].length,o=t.length,a=o,s=Lo(o),h=1/0,p=[];a--;){var f=t[a];a&&e&&(f=u(f,M(e))),h=xa(f.length,h),s[a]=!r&&(e||i>=120&&f.length>=120)?new ke(a&&f):k}f=t[0];var d=-1,m=s[0];t:for(;++d=s)return c;var l=r[n];return c*("desc"==l?-1:1)}}return t.index-e.index}(t,e,r)})}function $r(t,e,r){for(var n=-1,i=e.length,o={};++n-1;)s!==t&&ia.call(s,c,1),ia.call(t,c,1);return t}function Kr(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;ui(i)?ia.call(t,i,1):un(t,i)}}return t}function Qr(t,e){return t+fa(Sa()*(e-t+1))}function Jr(t,e){var r="";if(!t||e<1||e>ft)return r;do{e%2&&(r+=t),(e=fa(e/2))&&(t+=t)}while(e);return r}function tn(t,e){return is(vi(t,e,So),t+"")}function en(t,e,r,n){if(!Ji(t))return t;for(var i=-1,o=(e=yn(e,t)).length,a=o-1,s=t;null!=s&&++ii?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Lo(i);++n>>1,a=t[o];null!==a&&!io(a)&&(r?a<=e:a=U){var h=e?null:Za(t);if(h)return O(h);a=!1,i=E,u=new ke}else u=e?[]:s;t:for(;++n=n?t:rn(t,e,r)}function xn(t,e){if(e)return t.slice();var r=t.length,n=ta?ta(r):new t.constructor(r);return t.copy(n),n}function bn(t){var e=new t.constructor(t.byteLength);return new Jo(e).set(new Jo(t)),e}function wn(t,e){var r=e?bn(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function Sn(t,e){if(t!==e){var r=t!==k,n=null===t,i=t==t,o=io(t),a=e!==k,s=null===e,c=e==e,l=io(e);if(!s&&!l&&!o&&t>e||o&&a&&c&&!s&&!l||n&&a&&c||!r&&c||!i)return 1;if(!n&&!o&&!l&&t1?r[i-1]:k,a=i>2?r[2]:k;for(o=t.length>3&&"function"==typeof o?(i--,o):k,a&&hi(r[0],r[1],a)&&(o=i<3?k:o,i=1),e=Do(e);++n-1?i[o?e[a]:a]:k}}function Fn(t){return Qn(function(e){var r=e.length,n=r,i=Ie.prototype.thru;for(t&&e.reverse();n--;){var o=e[n];if("function"!=typeof o)throw new ko(V);if(i&&!a&&"wrapper"==ei(o))var a=new Ie([],!0)}for(n=a?n:r;++n1&&y.reverse(),h&&cs))return!1;var l=o.get(t);if(l&&o.get(e))return l==e;var u=-1,h=!0,p=r&$?new ke:k;for(o.set(t,e),o.set(e,t);++u-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(ve,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return o(_t,function(r){var n="_."+r[0];e&r[1]&&!c(t,n)&&t.push(n)}),t.sort()}(function(t){var e=t.match(ye);return e?e[1].split(_e):[]}(n),r)))}function xi(t){var e=0,r=0;return function(){var n=ba(),i=lt-(n-r);if(r=n,i>0){if(++e>=ct)return arguments[0]}else e=0;return t.apply(k,arguments)}}function bi(t,e){var r=-1,n=t.length,i=n-1;for(e=e===k?n:e;++r0&&(r=e.apply(this,arguments)),t<=1&&(e=k),r}}function Vi(t,e,r){var n=Yn(t,J,k,k,k,k,k,e=r?k:e);return n.placeholder=Vi.placeholder,n}function ji(t,e,r){var n=Yn(t,tt,k,k,k,k,k,e=r?k:e);return n.placeholder=ji.placeholder,n}function Gi(t,e,r){function n(e){var r=c,n=l;return c=l=k,d=e,h=t.apply(n,r)}function i(t){var r=t-f;return f===k||r>=e||r<0||g&&t-d>=u}function o(){var t=Ns();if(i(t))return a(t);p=ns(o,function(t){var r=e-(t-f);return g?xa(r,u-(t-d)):r}(t))}function a(t){return p=k,v&&c?n(t):(c=l=k,h)}function s(){var t=Ns(),r=i(t);if(c=arguments,l=this,f=t,r){if(p===k)return function(t){return d=t,p=ns(o,e),m?n(t):h}(f);if(g)return p=ns(o,e),n(f)}return p===k&&(p=ns(o,e)),h}var c,l,u,h,p,f,d=0,m=!1,g=!1,v=!0;if("function"!=typeof t)throw new ko(V);return e=lo(e)||0,Ji(r)&&(m=!!r.leading,u=(g="maxWait"in r)?_a(lo(r.maxWait)||0,e):u,v="trailing"in r?!!r.trailing:v),s.cancel=function(){p!==k&&$a(p),d=0,c=f=l=p=k},s.flush=function(){return p===k?h:a(Ns())},s}function Wi(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ko(V);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(Wi.Cache||ze),r}function Hi(t){if("function"!=typeof t)throw new ko(V);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)}}function Xi(t,e){return t===e||t!=t&&e!=e}function Yi(t){return null!=t&&Qi(t.length)&&!Zi(t)}function qi(t){return to(t)&&Yi(t)}function $i(t){if(!to(t))return!1;var e=Ar(t);return e==Et||e==At||"string"==typeof t.message&&"string"==typeof t.name&&!ro(t)}function Zi(t){if(!Ji(t))return!1;var e=Ar(t);return e==Ct||e==Tt||e==wt||e==It}function Ki(t){return"number"==typeof t&&t==so(t)}function Qi(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=ft}function Ji(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function to(t){return null!=t&&"object"==typeof t}function eo(t){return"number"==typeof t||to(t)&&Ar(t)==Lt}function ro(t){if(!to(t)||Ar(t)!=Nt)return!1;var e=ea(t);if(null===e)return!0;var r=Wo.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Go.call(r)==qo}function no(t){return"string"==typeof t||!Ws(t)&&to(t)&&Ar(t)==Ft}function io(t){return"symbol"==typeof t||to(t)&&Ar(t)==zt}function oo(t){if(!t)return[];if(Yi(t))return no(t)?z(t):En(t);if(aa&&t[aa])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[aa]());var e=ts(t);return(e==Pt?R:e==Dt?O:yo)(t)}function ao(t){return t?(t=lo(t))===pt||t===-pt?(t<0?-1:1)*dt:t==t?t:0:0===t?t:0}function so(t){var e=ao(t),r=e%1;return e==e?r?e-r:e:0}function co(t){return t?qe(so(t),0,gt):0}function lo(t){if("number"==typeof t)return t;if(io(t))return mt;if(Ji(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ji(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(de,"");var r=Ae.test(t);return r||Ce.test(t)?ur(t.slice(2),r?2:8):Me.test(t)?mt:+t}function uo(t){return Cn(t,go(t))}function ho(t){return null==t?"":cn(t)}function po(t,e,r){var n=null==t?k:vr(t,e);return n===k?r:n}function fo(t,e){return null!=t&&si(t,e,Nr)}function mo(t){return Yi(t)?Be(t):Br(t)}function go(t){return Yi(t)?Be(t,!0):Vr(t)}function vo(t,e){if(null==t)return{};var r=u(ti(t),function(t){return[t]});return e=ni(e),$r(t,r,function(t,r){return e(t,r[0])})}function yo(t){return null==t?[]:A(t,mo(t))}function _o(t){return Sc(ho(t).toLowerCase())}function xo(t){return(t=ho(t))&&t.replace(Pe,Er).replace(Je,"")}function bo(t,e,r){return t=ho(t),(e=r?k:e)===k?function(t){return nr.test(t)}(t)?function(t){return t.match(er)||[]}(t):function(t){return t.match(xe)||[]}(t):t.match(e)||[]}function wo(t){return function(){return t}}function So(t){return t}function Mo(t){return Ur("function"==typeof t?t:$e(t,H))}function Ao(t,e,r){var n=mo(e),i=mr(e,n);null!=r||Ji(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=mr(e,mo(e)));var a=!(Ji(r)&&"chain"in r&&!r.chain),s=Zi(t);return o(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(a||e){var r=t(this.__wrapped__);return(r.__actions__=En(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,h([this.value()],arguments))})}),t}function Eo(){}function Co(t){return pi(t)?_(wi(t)):function(t){return function(e){return vr(e,t)}}(t)}function To(){return[]}function Po(){return!1}var Lo=(e=null==e?fr:Pr.defaults(fr.Object(),e,Pr.pick(fr,ir))).Array,Ro=e.Date,No=e.Error,Io=e.Function,Oo=e.Math,Do=e.Object,Fo=e.RegExp,zo=e.String,ko=e.TypeError,Uo=Lo.prototype,Bo=Io.prototype,Vo=Do.prototype,jo=e["__core-js_shared__"],Go=Bo.toString,Wo=Vo.hasOwnProperty,Ho=0,Xo=function(){var t=/[^.]+$/.exec(jo&&jo.keys&&jo.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Yo=Vo.toString,qo=Go.call(Do),$o=fr._,Zo=Fo("^"+Go.call(Wo).replace(pe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ko=gr?e.Buffer:k,Qo=e.Symbol,Jo=e.Uint8Array,ta=Ko?Ko.allocUnsafe:k,ea=N(Do.getPrototypeOf,Do),ra=Do.create,na=Vo.propertyIsEnumerable,ia=Uo.splice,oa=Qo?Qo.isConcatSpreadable:k,aa=Qo?Qo.iterator:k,sa=Qo?Qo.toStringTag:k,ca=function(){try{var t=ai(Do,"defineProperty");return t({},"",{}),t}catch(t){}}(),la=e.clearTimeout!==fr.clearTimeout&&e.clearTimeout,ua=Ro&&Ro.now!==fr.Date.now&&Ro.now,ha=e.setTimeout!==fr.setTimeout&&e.setTimeout,pa=Oo.ceil,fa=Oo.floor,da=Do.getOwnPropertySymbols,ma=Ko?Ko.isBuffer:k,ga=e.isFinite,va=Uo.join,ya=N(Do.keys,Do),_a=Oo.max,xa=Oo.min,ba=Ro.now,wa=e.parseInt,Sa=Oo.random,Ma=Uo.reverse,Aa=ai(e,"DataView"),Ea=ai(e,"Map"),Ca=ai(e,"Promise"),Ta=ai(e,"Set"),Pa=ai(e,"WeakMap"),La=ai(Do,"create"),Ra=Pa&&new Pa,Na={},Ia=Si(Aa),Oa=Si(Ea),Da=Si(Ca),Fa=Si(Ta),za=Si(Pa),ka=Qo?Qo.prototype:k,Ua=ka?ka.valueOf:k,Ba=ka?ka.toString:k,Va=function(){function t(){}return function(e){if(!Ji(e))return{};if(ra)return ra(e);t.prototype=e;var r=new t;return t.prototype=k,r}}();x.templateSettings={escape:oe,evaluate:ae,interpolate:se,variable:"",imports:{_:x}},(x.prototype=Ne.prototype).constructor=x,(Ie.prototype=Va(Ne.prototype)).constructor=Ie,(Oe.prototype=Va(Ne.prototype)).constructor=Oe,De.prototype.clear=function(){this.__data__=La?La(null):{},this.size=0},De.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},De.prototype.get=function(t){var e=this.__data__;if(La){var r=e[t];return r===j?k:r}return Wo.call(e,t)?e[t]:k},De.prototype.has=function(t){var e=this.__data__;return La?e[t]!==k:Wo.call(e,t)},De.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=La&&e===k?j:e,this},Fe.prototype.clear=function(){this.__data__=[],this.size=0},Fe.prototype.delete=function(t){var e=this.__data__,r=We(e,t);return!(r<0||(r==e.length-1?e.pop():ia.call(e,r,1),--this.size,0))},Fe.prototype.get=function(t){var e=this.__data__,r=We(e,t);return r<0?k:e[r][1]},Fe.prototype.has=function(t){return We(this.__data__,t)>-1},Fe.prototype.set=function(t,e){var r=this.__data__,n=We(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},ze.prototype.clear=function(){this.size=0,this.__data__={hash:new De,map:new(Ea||Fe),string:new De}},ze.prototype.delete=function(t){var e=ii(this,t).delete(t);return this.size-=e?1:0,e},ze.prototype.get=function(t){return ii(this,t).get(t)},ze.prototype.has=function(t){return ii(this,t).has(t)},ze.prototype.set=function(t,e){var r=ii(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},ke.prototype.add=ke.prototype.push=function(t){return this.__data__.set(t,j),this},ke.prototype.has=function(t){return this.__data__.has(t)},Ue.prototype.clear=function(){this.__data__=new Fe,this.size=0},Ue.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Ue.prototype.get=function(t){return this.__data__.get(t)},Ue.prototype.has=function(t){return this.__data__.has(t)},Ue.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Fe){var n=r.__data__;if(!Ea||n.length1?t[e-1]:k;return r="function"==typeof r?(t.pop(),r):k,Ii(t,r)}),Ss=Qn(function(t){var e=t.length,r=e?t[0]:0,n=this.__wrapped__,i=function(e){return Ye(e,t)};return!(e>1||this.__actions__.length)&&n instanceof Oe&&ui(r)?((n=n.slice(r,+r+(e?1:0))).__actions__.push({func:Di,args:[i],thisArg:k}),new Ie(n,this.__chain__).thru(function(t){return e&&!t.length&&t.push(k),t})):this.thru(i)}),Ms=Tn(function(t,e,r){Wo.call(t,r)?++t[r]:Xe(t,r,1)}),As=Dn(Ai),Es=Dn(Ei),Cs=Tn(function(t,e,r){Wo.call(t,r)?t[r].push(e):Xe(t,r,[e])}),Ts=tn(function(t,e,r){var n=-1,o="function"==typeof e,a=Yi(t)?Lo(t.length):[];return ja(t,function(t){a[++n]=o?i(e,t,r):Or(t,e,r)}),a}),Ps=Tn(function(t,e,r){Xe(t,r,e)}),Ls=Tn(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]}),Rs=tn(function(t,e){if(null==t)return[];var r=e.length;return r>1&&hi(t,e[0],e[1])?e=[]:r>2&&hi(e[0],e[1],e[2])&&(e=[e[0]]),qr(t,hr(e,1),[])}),Ns=ua||function(){return fr.Date.now()},Is=tn(function(t,e,r){var n=Z;if(r.length){var i=I(r,ri(Is));n|=et}return Yn(t,n,e,r,i)}),Os=tn(function(t,e,r){var n=Z|K;if(r.length){var i=I(r,ri(Os));n|=et}return Yn(e,n,t,r,i)}),Ds=tn(function(t,e){return Ke(t,1,e)}),Fs=tn(function(t,e,r){return Ke(t,lo(e)||0,r)});Wi.Cache=ze;var zs=qa(function(t,e){var r=(e=1==e.length&&Ws(e[0])?u(e[0],M(ni())):u(hr(e,1),M(ni()))).length;return tn(function(n){for(var o=-1,a=xa(n.length,r);++o=e}),Gs=Dr(function(){return arguments}())?Dr:function(t){return to(t)&&Wo.call(t,"callee")&&!na.call(t,"callee")},Ws=Lo.isArray,Hs=_r?M(_r):function(t){return to(t)&&Ar(t)==Vt},Xs=ma||Po,Ys=xr?M(xr):function(t){return to(t)&&Ar(t)==Mt},qs=br?M(br):function(t){return to(t)&&ts(t)==Pt},$s=wr?M(wr):function(t){return to(t)&&Ar(t)==Ot},Zs=Sr?M(Sr):function(t){return to(t)&&ts(t)==Dt},Ks=Mr?M(Mr):function(t){return to(t)&&Qi(t.length)&&!!ar[Ar(t)]},Qs=Gn(jr),Js=Gn(function(t,e){return t<=e}),tc=Pn(function(t,e){if(di(e)||Yi(e))Cn(e,mo(e),t);else for(var r in e)Wo.call(e,r)&&Ge(t,r,e[r])}),ec=Pn(function(t,e){Cn(e,go(e),t)}),rc=Pn(function(t,e,r,n){Cn(e,go(e),t,n)}),nc=Pn(function(t,e,r,n){Cn(e,mo(e),t,n)}),ic=Qn(Ye),oc=tn(function(t){return t.push(k,qn),i(rc,k,t)}),ac=tn(function(t){return t.push(k,$n),i(hc,k,t)}),sc=kn(function(t,e,r){t[e]=r},wo(So)),cc=kn(function(t,e,r){Wo.call(t,e)?t[e].push(r):t[e]=[r]},ni),lc=tn(Or),uc=Pn(function(t,e,r){Xr(t,e,r)}),hc=Pn(function(t,e,r,n){Xr(t,e,r,n)}),pc=Qn(function(t,e){var r={};if(null==t)return r;var n=!1;e=u(e,function(e){return e=yn(e,t),n||(n=e.length>1),e}),Cn(t,ti(t),r),n&&(r=$e(r,H|X|Y,Zn));for(var i=e.length;i--;)un(r,e[i]);return r}),fc=Qn(function(t,e){return null==t?{}:function(t,e){return $r(t,e,function(e,r){return fo(t,r)})}(t,e)}),dc=Xn(mo),mc=Xn(go),gc=In(function(t,e,r){return e=e.toLowerCase(),t+(r?_o(e):e)}),vc=In(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),yc=In(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),_c=Nn("toLowerCase"),xc=In(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()}),bc=In(function(t,e,r){return t+(r?" ":"")+Sc(e)}),wc=In(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),Sc=Nn("toUpperCase"),Mc=tn(function(t,e){try{return i(t,k,e)}catch(t){return $i(t)?t:new No(t)}}),Ac=Qn(function(t,e){return o(e,function(e){e=wi(e),Xe(t,e,Is(t[e],t))}),t}),Ec=Fn(),Cc=Fn(!0),Tc=tn(function(t,e){return function(r){return Or(r,t,e)}}),Pc=tn(function(t,e){return function(r){return Or(t,r,e)}}),Lc=Bn(u),Rc=Bn(a),Nc=Bn(f),Ic=jn(),Oc=jn(!0),Dc=Un(function(t,e){return t+e},0),Fc=Hn("ceil"),zc=Un(function(t,e){return t/e},1),kc=Hn("floor"),Uc=Un(function(t,e){return t*e},1),Bc=Hn("round"),Vc=Un(function(t,e){return t-e},0);return x.after=function(t,e){if("function"!=typeof e)throw new ko(V);return t=so(t),function(){if(--t<1)return e.apply(this,arguments)}},x.ary=Ui,x.assign=tc,x.assignIn=ec,x.assignInWith=rc,x.assignWith=nc,x.at=ic,x.before=Bi,x.bind=Is,x.bindAll=Ac,x.bindKey=Os,x.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Ws(t)?t:[t]},x.chain=Oi,x.chunk=function(t,e,r){e=(r?hi(t,e,r):e===k)?1:_a(so(e),0);var n=null==t?0:t.length;if(!n||e<1)return[];for(var i=0,o=0,a=Lo(pa(n/e));ii?0:i+r),(n=n===k||n>i?i:so(n))<0&&(n+=i),n=r>n?0:co(n);r>>0)?(t=ho(t))&&("string"==typeof e||null!=e&&!$s(e))&&!(e=cn(e))&&L(t)?_n(z(t),0,r):t.split(e,r):[]},x.spread=function(t,e){if("function"!=typeof t)throw new ko(V);return e=null==e?0:_a(so(e),0),tn(function(r){var n=r[e],o=_n(r,0,e);return n&&h(o,n),i(t,this,o)})},x.tail=function(t){var e=null==t?0:t.length;return e?rn(t,1,e):[]},x.take=function(t,e,r){return t&&t.length?(e=r||e===k?1:so(e),rn(t,0,e<0?0:e)):[]},x.takeRight=function(t,e,r){var n=null==t?0:t.length;return n?(e=r||e===k?1:so(e),e=n-e,rn(t,e<0?0:e,n)):[]},x.takeRightWhile=function(t,e){return t&&t.length?pn(t,ni(e,3),!1,!0):[]},x.takeWhile=function(t,e){return t&&t.length?pn(t,ni(e,3)):[]},x.tap=function(t,e){return e(t),t},x.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ko(V);return Ji(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),Gi(t,e,{leading:n,maxWait:e,trailing:i})},x.thru=Di,x.toArray=oo,x.toPairs=dc,x.toPairsIn=mc,x.toPath=function(t){return Ws(t)?u(t,wi):io(t)?[t]:En(os(ho(t)))},x.toPlainObject=uo,x.transform=function(t,e,r){var n=Ws(t),i=n||Xs(t)||Ks(t);if(e=ni(e,4),null==r){var a=t&&t.constructor;r=i?n?new a:[]:Ji(t)&&Zi(a)?Va(ea(t)):{}}return(i?o:pr)(t,function(t,n,i){return e(r,t,n,i)}),r},x.unary=function(t){return Ui(t,1)},x.union=ds,x.unionBy=ms,x.unionWith=gs,x.uniq=function(t){return t&&t.length?ln(t):[]},x.uniqBy=function(t,e){return t&&t.length?ln(t,ni(e,2)):[]},x.uniqWith=function(t,e){return e="function"==typeof e?e:k,t&&t.length?ln(t,k,e):[]},x.unset=function(t,e){return null==t||un(t,e)},x.unzip=Ni,x.unzipWith=Ii,x.update=function(t,e,r){return null==t?t:hn(t,e,vn(r))},x.updateWith=function(t,e,r,n){return n="function"==typeof n?n:k,null==t?t:hn(t,e,vn(r),n)},x.values=yo,x.valuesIn=function(t){return null==t?[]:A(t,go(t))},x.without=vs,x.words=bo,x.wrap=function(t,e){return ks(vn(e),t)},x.xor=ys,x.xorBy=_s,x.xorWith=xs,x.zip=bs,x.zipObject=function(t,e){return mn(t||[],e||[],Ge)},x.zipObjectDeep=function(t,e){return mn(t||[],e||[],en)},x.zipWith=ws,x.entries=dc,x.entriesIn=mc,x.extend=ec,x.extendWith=rc,Ao(x,x),x.add=Dc,x.attempt=Mc,x.camelCase=gc,x.capitalize=_o,x.ceil=Fc,x.clamp=function(t,e,r){return r===k&&(r=e,e=k),r!==k&&(r=(r=lo(r))==r?r:0),e!==k&&(e=(e=lo(e))==e?e:0),qe(lo(t),e,r)},x.clone=function(t){return $e(t,Y)},x.cloneDeep=function(t){return $e(t,H|Y)},x.cloneDeepWith=function(t,e){return e="function"==typeof e?e:k,$e(t,H|Y,e)},x.cloneWith=function(t,e){return e="function"==typeof e?e:k,$e(t,Y,e)},x.conformsTo=function(t,e){return null==e||Ze(t,e,mo(e))},x.deburr=xo,x.defaultTo=function(t,e){return null==t||t!=t?e:t},x.divide=zc,x.endsWith=function(t,e,r){t=ho(t),e=cn(e);var n=t.length,i=r=r===k?n:qe(so(r),0,n);return(r-=e.length)>=0&&t.slice(r,i)==e},x.eq=Xi,x.escape=function(t){return(t=ho(t))&&ie.test(t)?t.replace(re,Cr):t},x.escapeRegExp=function(t){return(t=ho(t))&&fe.test(t)?t.replace(pe,"\\$&"):t},x.every=function(t,e,r){var n=Ws(t)?a:function(t,e){var r=!0;return ja(t,function(t,n,i){return r=!!e(t,n,i)}),r};return r&&hi(t,e,r)&&(e=k),n(t,ni(e,3))},x.find=As,x.findIndex=Ai,x.findKey=function(t,e){return d(t,ni(e,3),pr)},x.findLast=Es,x.findLastIndex=Ei,x.findLastKey=function(t,e){return d(t,ni(e,3),dr)},x.floor=kc,x.forEach=Fi,x.forEachRight=zi,x.forIn=function(t,e){return null==t?t:Wa(t,ni(e,3),go)},x.forInRight=function(t,e){return null==t?t:Ha(t,ni(e,3),go)},x.forOwn=function(t,e){return t&&pr(t,ni(e,3))},x.forOwnRight=function(t,e){return t&&dr(t,ni(e,3))},x.get=po,x.gt=Vs,x.gte=js,x.has=function(t,e){return null!=t&&si(t,e,Rr)},x.hasIn=fo,x.head=Ti,x.identity=So,x.includes=function(t,e,r,n){t=Yi(t)?t:yo(t),r=r&&!n?so(r):0;var i=t.length;return r<0&&(r=_a(i+r,0)),no(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&g(t,e,r)>-1},x.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:so(r);return i<0&&(i=_a(n+i,0)),g(t,e,i)},x.inRange=function(t,e,r){return e=ao(e),r===k?(r=e,e=0):r=ao(r),t=lo(t),function(t,e,r){return t>=xa(e,r)&&t<_a(e,r)}(t,e,r)},x.invoke=lc,x.isArguments=Gs,x.isArray=Ws,x.isArrayBuffer=Hs,x.isArrayLike=Yi,x.isArrayLikeObject=qi,x.isBoolean=function(t){return!0===t||!1===t||to(t)&&Ar(t)==St},x.isBuffer=Xs,x.isDate=Ys,x.isElement=function(t){return to(t)&&1===t.nodeType&&!ro(t)},x.isEmpty=function(t){if(null==t)return!0;if(Yi(t)&&(Ws(t)||"string"==typeof t||"function"==typeof t.splice||Xs(t)||Ks(t)||Gs(t)))return!t.length;var e=ts(t);if(e==Pt||e==Dt)return!t.size;if(di(t))return!Br(t).length;for(var r in t)if(Wo.call(t,r))return!1;return!0},x.isEqual=function(t,e){return Fr(t,e)},x.isEqualWith=function(t,e,r){var n=(r="function"==typeof r?r:k)?r(t,e):k;return n===k?Fr(t,e,k,r):!!n},x.isError=$i,x.isFinite=function(t){return"number"==typeof t&&ga(t)},x.isFunction=Zi,x.isInteger=Ki,x.isLength=Qi,x.isMap=qs,x.isMatch=function(t,e){return t===e||zr(t,e,oi(e))},x.isMatchWith=function(t,e,r){return r="function"==typeof r?r:k,zr(t,e,oi(e),r)},x.isNaN=function(t){return eo(t)&&t!=+t},x.isNative=function(t){if(es(t))throw new No(B);return kr(t)},x.isNil=function(t){return null==t},x.isNull=function(t){return null===t},x.isNumber=eo,x.isObject=Ji,x.isObjectLike=to,x.isPlainObject=ro,x.isRegExp=$s,x.isSafeInteger=function(t){return Ki(t)&&t>=-ft&&t<=ft},x.isSet=Zs,x.isString=no,x.isSymbol=io,x.isTypedArray=Ks,x.isUndefined=function(t){return t===k},x.isWeakMap=function(t){return to(t)&&ts(t)==Ut},x.isWeakSet=function(t){return to(t)&&Ar(t)==Bt},x.join=function(t,e){return null==t?"":va.call(t,e)},x.kebabCase=vc,x.last=Pi,x.lastIndexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=n;return r!==k&&(i=(i=so(r))<0?_a(n+i,0):xa(i,n-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,i):m(t,v,i,!0)},x.lowerCase=yc,x.lowerFirst=_c,x.lt=Qs,x.lte=Js,x.max=function(t){return t&&t.length?rr(t,So,Lr):k},x.maxBy=function(t,e){return t&&t.length?rr(t,ni(e,2),Lr):k},x.mean=function(t){return y(t,So)},x.meanBy=function(t,e){return y(t,ni(e,2))},x.min=function(t){return t&&t.length?rr(t,So,jr):k},x.minBy=function(t,e){return t&&t.length?rr(t,ni(e,2),jr):k},x.stubArray=To,x.stubFalse=Po,x.stubObject=function(){return{}},x.stubString=function(){return""},x.stubTrue=function(){return!0},x.multiply=Uc,x.nth=function(t,e){return t&&t.length?Yr(t,so(e)):k},x.noConflict=function(){return fr._===this&&(fr._=$o),this},x.noop=Eo,x.now=Ns,x.pad=function(t,e,r){t=ho(t);var n=(e=so(e))?F(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return Vn(fa(i),r)+t+Vn(pa(i),r)},x.padEnd=function(t,e,r){t=ho(t);var n=(e=so(e))?F(t):0;return e&&ne){var n=t;t=e,e=n}if(r||t%1||e%1){var i=Sa();return xa(t+i*(e-t+lr("1e-"+((i+"").length-1))),e)}return Qr(t,e)},x.reduce=function(t,e,r){var n=Ws(t)?p:b,i=arguments.length<3;return n(t,ni(e,4),r,i,ja)},x.reduceRight=function(t,e,r){var n=Ws(t)?function(t,e,r,n){var i=null==t?0:t.length;for(n&&i&&(r=t[--i]);i--;)r=e(r,t[i],i,t);return r}:b,i=arguments.length<3;return n(t,ni(e,4),r,i,Ga)},x.repeat=function(t,e,r){return e=(r?hi(t,e,r):e===k)?1:so(e),Jr(ho(t),e)},x.replace=function(){var t=arguments,e=ho(t[0]);return t.length<3?e:e.replace(t[1],t[2])},x.result=function(t,e,r){var n=-1,i=(e=yn(e,t)).length;for(i||(i=1,t=k);++nft)return[];var r=gt,n=xa(t,gt);e=ni(e),t-=gt;for(var i=S(n,e);++r=o)return t;var s=r-F(n);if(s<1)return n;var c=a?_n(a,0,s).join(""):t.slice(0,s);if(i===k)return c+n;if(a&&(s+=c.length-s),$s(i)){if(t.slice(s).search(i)){var l,u=c;for(i.global||(i=Fo(i.source,ho(Se.exec(i))+"g")),i.lastIndex=0;l=i.exec(u);)var h=l.index;c=c.slice(0,h===k?s:h)}}else if(t.indexOf(cn(i),s)!=s){var p=c.lastIndexOf(i);p>-1&&(c=c.slice(0,p))}return c+n},x.unescape=function(t){return(t=ho(t))&&ne.test(t)?t.replace(ee,Tr):t},x.uniqueId=function(t){var e=++Ho;return ho(t)+e},x.upperCase=wc,x.upperFirst=Sc,x.each=Fi,x.eachRight=zi,x.first=Ti,Ao(x,function(){var t={};return pr(x,function(e,r){Wo.call(x.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),x.VERSION="4.17.4",o(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){x[t].placeholder=x}),o(["drop","take"],function(t,e){Oe.prototype[t]=function(r){r=r===k?1:_a(so(r),0);var n=this.__filtered__&&!e?new Oe(this):this.clone();return n.__filtered__?n.__takeCount__=xa(r,n.__takeCount__):n.__views__.push({size:xa(r,gt),type:t+(n.__dir__<0?"Right":"")}),n},Oe.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),o(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==ut||3==r;Oe.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:ni(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),o(["head","last"],function(t,e){var r="take"+(e?"Right":"");Oe.prototype[t]=function(){return this[r](1).value()[0]}}),o(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");Oe.prototype[t]=function(){return this.__filtered__?new Oe(this):this[r](1)}}),Oe.prototype.compact=function(){return this.filter(So)},Oe.prototype.find=function(t){return this.filter(t).head()},Oe.prototype.findLast=function(t){return this.reverse().find(t)},Oe.prototype.invokeMap=tn(function(t,e){return"function"==typeof t?new Oe(this):this.map(function(r){return Or(r,t,e)})}),Oe.prototype.reject=function(t){return this.filter(Hi(ni(t)))},Oe.prototype.slice=function(t,e){t=so(t);var r=this;return r.__filtered__&&(t>0||e<0)?new Oe(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==k&&(r=(e=so(e))<0?r.dropRight(-e):r.take(e-t)),r)},Oe.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Oe.prototype.toArray=function(){return this.take(gt)},pr(Oe.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),n=/^(?:head|last)$/.test(e),i=x[n?"take"+("last"==e?"Right":""):e],o=n||/^find/.test(e);i&&(x.prototype[e]=function(){var e=this.__wrapped__,a=n?[1]:arguments,s=e instanceof Oe,c=a[0],l=s||Ws(e),u=function(t){var e=i.apply(x,h([t],a));return n&&p?e[0]:e};l&&r&&"function"==typeof c&&1!=c.length&&(s=l=!1);var p=this.__chain__,f=!!this.__actions__.length,d=o&&!p,m=s&&!f;if(!o&&l){e=m?e:new Oe(this);var g=t.apply(e,a);return g.__actions__.push({func:Di,args:[u],thisArg:k}),new Ie(g,p)}return d&&m?t.apply(this,a):(g=this.thru(u),d?n?g.value()[0]:g.value():g)})}),o(["pop","push","shift","sort","splice","unshift"],function(t){var e=Uo[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);x.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(Ws(i)?i:[],t)}return this[r](function(r){return e.apply(Ws(r)?r:[],t)})}}),pr(Oe.prototype,function(t,e){var r=x[e];if(r){var n=r.name+"";(Na[n]||(Na[n]=[])).push({name:e,func:r})}}),Na[zn(k,K).name]=[{name:"wrapper",func:k}],Oe.prototype.clone=function(){var t=new Oe(this.__wrapped__);return t.__actions__=En(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=En(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=En(this.__views__),t},Oe.prototype.reverse=function(){if(this.__filtered__){var t=new Oe(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Oe.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=Ws(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?k:this.__values__[this.__index__++]}},x.prototype.plant=function(t){for(var e,r=this;r instanceof Ne;){var n=Mi(r);n.__index__=0,n.__values__=k,e?i.__wrapped__=n:e=n;var i=n;r=r.__wrapped__}return i.__wrapped__=t,e},x.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Oe){var e=t;return this.__actions__.length&&(e=new Oe(this)),(e=e.reverse()).__actions__.push({func:Di,args:[Ri],thisArg:k}),new Ie(e,this.__chain__)}return this.thru(Ri)},x.prototype.toJSON=x.prototype.valueOf=x.prototype.value=function(){return fn(this.__wrapped__,this.__actions__)},x.prototype.first=x.prototype.head,aa&&(x.prototype[aa]=function(){return this}),x}();"function"==typeof k&&"object"==typeof k.amd&&k.amd?(fr._=Pr,k(function(){return Pr})):mr?((mr.exports=Pr)._=Pr,dr._=Pr):fr._=Pr}).call(gl)});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,r[i]=e[19===i?3&t|8:t]);return r.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*xh.DEG2RAD},radToDeg:function(t){return t*xh.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}};Object.defineProperties(n.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(n.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:function(){var t=new n,e=new n;return function(r,n){return t.set(r,r),e.set(n,n),this.clamp(t,e)}}(),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 bh=0;i.DEFAULT_IMAGE=void 0,i.DEFAULT_MAPPING=300,Object.defineProperty(i.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(i.prototype,r.prototype,{constructor:i,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=xh.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 wu:t.x=t.x-Math.floor(t.x);break;case Su:t.x=t.x<0?0:1;break;case Mu: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 wu:t.y=t.y-Math.floor(t.y);break;case Su:t.y=t.y<0?0:1;break;case Mu: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(o.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],c=o[8],l=o[1],u=o[5],h=o[9],p=o[2],f=o[6],d=o[10];if(Math.abs(s-l)<.01&&Math.abs(c-p)<.01&&Math.abs(h-f)<.01){if(Math.abs(s+l)<.1&&Math.abs(c+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+l)/4,_=(c+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)+(c-p)*(c-p)+(l-s)*(l-s));return Math.abs(b)<.001&&(b=1),this.x=(f-h)/b,this.y=(c-p)/b,this.z=(l-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(){var t,e;return function(r,n){return void 0===t&&(t=new o,e=new o),t.set(r,r,r,r),e.set(n,n,n,n),this.clamp(t,e)}}(),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(a.prototype,r.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"})}}),(s.prototype=Object.create(a.prototype)).constructor=s,s.prototype.isWebGLRenderTargetCube=!0,Object.assign(c,{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],c=r[n+1],l=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||c!==p||l!==f){var m=1-a,g=s*h+c*p+l*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,c=c*m+p*b,l=l*m+f*b,u=u*m+d*b,m===1-a){var w=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=w,c*=w,l*=w,u*=w}}t[e]=s,t[e+1]=c,t[e+2]=l,t[e+3]=u}}),Object.defineProperties(c.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(c.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,c=a(r/2),l=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*l*u+c*p*f,this._y=c*p*u-h*l*f,this._z=c*l*f+h*p*u,this._w=c*l*u-h*p*f):"YXZ"===o?(this._x=h*l*u+c*p*f,this._y=c*p*u-h*l*f,this._z=c*l*f-h*p*u,this._w=c*l*u+h*p*f):"ZXY"===o?(this._x=h*l*u-c*p*f,this._y=c*p*u+h*l*f,this._z=c*l*f+h*p*u,this._w=c*l*u-h*p*f):"ZYX"===o?(this._x=h*l*u-c*p*f,this._y=c*p*u+h*l*f,this._z=c*l*f-h*p*u,this._w=c*l*u+h*p*f):"YZX"===o?(this._x=h*l*u+c*p*f,this._y=c*p*u+h*l*f,this._z=c*l*f-h*p*u,this._w=c*l*u-h*p*f):"XZY"===o&&(this._x=h*l*u-c*p*f,this._y=c*p*u-h*l*f,this._z=c*l*f+h*p*u,this._w=c*l*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],c=r[9],l=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-c)*e,this._y=(o-l)*e,this._z=(a-i)*e):n>s&&n>h?(e=2*Math.sqrt(1+n-s-h),this._w=(u-c)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(o+l)/e):s>h?(e=2*Math.sqrt(1+s-n-h),this._w=(o-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(c+u)/e):(e=2*Math.sqrt(1+h-n-s),this._w=(a-i)/e,this._x=(o+l)/e,this._y=(c+u)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e=new l;return function(r,n){return void 0===e&&(e=new l),(t=r.dot(n)+1)<1e-6?(t=0,Math.abs(r.x)>Math.abs(r.z)?e.set(-r.y,r.x,0):e.set(0,-r.z,r.y)):e.crossVectors(r,n),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,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,c=e._z,l=e._w;return this._x=r*l+o*a+n*c-i*s,this._y=n*l+o*s+i*a-r*c,this._z=i*l+o*c+r*s-n*a,this._w=o*l-r*a-n*s-i*c,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 c=Math.atan2(s,a),l=Math.sin((1-e)*c)/s,u=Math.sin(e*c)/s;return this._w=o*l+this._w*u,this._x=r*l+this._x*u,this._y=n*l+this._y*u,this._z=i*l+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(l.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:function(){var t=new c;return function(e){return!e||e.isEuler,this.applyQuaternion(t.setFromEuler(e))}}(),applyAxisAngle:function(){var t=new c;return function(e,r){return this.applyQuaternion(t.setFromAxisAngle(e,r))}}(),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,c=s*e+o*n-a*r,l=s*r+a*e-i*n,u=s*n+i*r-o*e,h=-i*e-o*r-a*n;return this.x=c*s+h*-i+l*-a-u*-o,this.y=l*s+h*-o+u*-i-c*-a,this.z=u*s+h*-a+c*-o-l*-i,this},project:function(){var t=new u;return function(e){return t.multiplyMatrices(e.projectionMatrix,t.getInverse(e.matrixWorld)),this.applyMatrix4(t)}}(),unproject:function(){var t=new u;return function(e){return t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyMatrix4(t)}}(),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:function(){var t=new l,e=new l;return function(r,n){return t.set(r,r,r),e.set(n,n,n),this.clamp(t,e)}}(),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:function(){var t=new l;return function(e){return t.copy(this).projectOnVector(e),this.sub(t)}}(),reflect:function(){var t=new l;return function(e){return this.sub(t.copy(e).multiplyScalar(2*this.dot(e)))}}(),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(xh.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(u.prototype,{isMatrix4:!0,set:function(t,e,r,n,i,o,a,s,c,l,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]=c,g[6]=l,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 u).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:function(){var t=new l;return function(e){var r=this.elements,n=e.elements,i=1/t.setFromMatrixColumn(e,0).length(),o=1/t.setFromMatrixColumn(e,1).length(),a=1/t.setFromMatrixColumn(e,2).length();return r[0]=n[0]*i,r[1]=n[1]*i,r[2]=n[2]*i,r[4]=n[4]*o,r[5]=n[5]*o,r[6]=n[6]*o,r[8]=n[8]*a,r[9]=n[9]*a,r[10]=n[10]*a,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),c=Math.sin(n),l=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){var h=o*l,p=o*u,f=a*l,d=a*u;e[0]=s*l,e[4]=-s*u,e[8]=c,e[1]=p+f*c,e[5]=h-d*c,e[9]=-a*s,e[2]=d-h*c,e[6]=f+p*c,e[10]=o*s}else if("YXZ"===t.order){var m=s*l,g=s*u,v=c*l,y=c*u;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*c,e[1]=o*u,e[5]=o*l,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){var m=s*l,g=s*u,v=c*l,y=c*u;e[0]=m-y*a,e[4]=-o*u,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*l,e[9]=y-m*a,e[2]=-o*c,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){var h=o*l,p=o*u,f=a*l,d=a*u;e[0]=s*l,e[4]=f*c-p,e[8]=h*c+d,e[1]=s*u,e[5]=d*c+h,e[9]=p*c-f,e[2]=-c,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var _=o*s,x=o*c,b=a*s,w=a*c;e[0]=s*l,e[4]=w-_*u,e[8]=b*u+x,e[1]=u,e[5]=o*l,e[9]=-a*l,e[2]=-c*l,e[6]=x*u+b,e[10]=_-w*u}else if("XZY"===t.order){var _=o*s,x=o*c,b=a*s,w=a*c;e[0]=s*l,e[4]=-u,e[8]=c*l,e[1]=_*u+w,e[5]=o*l,e[9]=x*u-b,e[2]=b*u-x,e[6]=a*l,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,c=i+i,l=r*a,u=r*s,h=r*c,p=n*s,f=n*c,d=i*c,m=o*a,g=o*s,v=o*c;return e[0]=1-(p+d),e[4]=u-v,e[8]=h+g,e[1]=u+v,e[5]=1-(l+d),e[9]=f-m,e[2]=h-g,e[6]=f+m,e[10]=1-(l+p),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:function(){var t=new l,e=new l,r=new l;return function(n,i,o){var a=this.elements;return r.subVectors(n,i),0===r.lengthSq()&&(r.z=1),r.normalize(),t.crossVectors(o,r),0===t.lengthSq()&&(1===Math.abs(o.z)?r.x+=1e-4:r.z+=1e-4,r.normalize(),t.crossVectors(o,r)),t.normalize(),e.crossVectors(r,t),a[0]=t.x,a[4]=e.x,a[8]=r.x,a[1]=t.y,a[5]=e.y,a[9]=r.y,a[2]=t.z,a[6]=e.z,a[10]=r.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],c=r[12],l=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+c*I,i[4]=o*w+a*E+s*L+c*O,i[8]=o*S+a*C+s*R+c*D,i[12]=o*M+a*T+s*N+c*F,i[1]=l*b+u*A+h*P+p*I,i[5]=l*w+u*E+h*L+p*O,i[9]=l*S+u*C+h*R+p*D,i[13]=l*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:function(){var t=new l;return function(e){for(var r=0,n=e.count;r>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=xh.euclideanModulo(e,1),r=xh.clamp(r,0,1),n=xh.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,c=parseInt(n[3],10)/100;return e(n[5]),this.setHSL(a,s,c)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(t)){var l=(u=r[1]).length;if(3===l)return this.r=parseInt(u.charAt(0)+u.charAt(0),16)/255,this.g=parseInt(u.charAt(1)+u.charAt(1),16)/255,this.b=parseInt(u.charAt(2)+u.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(u.charAt(0)+u.charAt(1),16)/255,this.g=parseInt(u.charAt(2)+u.charAt(3),16)/255,this.b=parseInt(u.charAt(4)+u.charAt(5),16)/255,this}if(t&&t.length>0){var u=Ph[t];void 0!==u&&this.setHex(u)}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),c=Math.min(i,o,a),l=(c+s)/2;if(c===s)e=0,r=0;else{var u=s-c;switch(r=l<=.5?u/(s+c):u/(2-s-c),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"},Ih={basic:{uniforms:Rh.merge([Lh.common,Lh.specularmap,Lh.envmap,Lh.aomap,Lh.lightmap,Lh.fog]),vertexShader:Nh.meshbasic_vert,fragmentShader:Nh.meshbasic_frag},lambert:{uniforms:Rh.merge([Lh.common,Lh.specularmap,Lh.envmap,Lh.aomap,Lh.lightmap,Lh.emissivemap,Lh.fog,Lh.lights,{emissive:{value:new X(0)}}]),vertexShader:Nh.meshlambert_vert,fragmentShader:Nh.meshlambert_frag},phong:{uniforms:Rh.merge([Lh.common,Lh.specularmap,Lh.envmap,Lh.aomap,Lh.lightmap,Lh.emissivemap,Lh.bumpmap,Lh.normalmap,Lh.displacementmap,Lh.gradientmap,Lh.fog,Lh.lights,{emissive:{value:new X(0)},specular:{value:new X(1118481)},shininess:{value:30}}]),vertexShader:Nh.meshphong_vert,fragmentShader:Nh.meshphong_frag},standard:{uniforms:Rh.merge([Lh.common,Lh.envmap,Lh.aomap,Lh.lightmap,Lh.emissivemap,Lh.bumpmap,Lh.normalmap,Lh.displacementmap,Lh.roughnessmap,Lh.metalnessmap,Lh.fog,Lh.lights,{emissive:{value:new X(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Nh.meshphysical_vert,fragmentShader:Nh.meshphysical_frag},points:{uniforms:Rh.merge([Lh.points,Lh.fog]),vertexShader:Nh.points_vert,fragmentShader:Nh.points_frag},dashed:{uniforms:Rh.merge([Lh.common,Lh.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Nh.linedashed_vert,fragmentShader:Nh.linedashed_frag},depth:{uniforms:Rh.merge([Lh.common,Lh.displacementmap]),vertexShader:Nh.depth_vert,fragmentShader:Nh.depth_frag},normal:{uniforms:Rh.merge([Lh.common,Lh.bumpmap,Lh.normalmap,Lh.displacementmap,{opacity:{value:1}}]),vertexShader:Nh.normal_vert,fragmentShader:Nh.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Nh.cube_vert,fragmentShader:Nh.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Nh.equirect_vert,fragmentShader:Nh.equirect_frag},distanceRGBA:{uniforms:Rh.merge([Lh.common,Lh.displacementmap,{referencePosition:{value:new l},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Nh.distanceRGBA_vert,fragmentShader:Nh.distanceRGBA_frag},shadow:{uniforms:Rh.merge([Lh.lights,{color:{value:new X(0)},opacity:{value:1}}]),vertexShader:Nh.shadow_vert,fragmentShader:Nh.shadow_frag}};Ih.physical={uniforms:Rh.merge([Ih.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:Nh.meshphysical_vert,fragmentShader:Nh.meshphysical_frag},Object.assign(Y.prototype,{set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,r=t.length;ethis.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 n).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 n).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new n;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).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)}}),($.prototype=Object.create(i.prototype)).constructor=$;var Oh=0;Object.assign(K.prototype,r.prototype,{isMaterial:!0,onBeforeCompile:function(){},setValues:function(t){if(void 0!==t)for(var e in t){var r=t[e];if(void 0!==r)if("shading"!==e){var n=this[e];void 0!==n&&(n&&n.isColor?n.set(r):n&&n.isVector3&&r&&r.isVector3?n.copy(r):this[e]="overdraw"===e?Number(r):r)}else this.flatShading=1===r}},toJSON:function(t){function e(t){var e=[];for(var r in t){var n=t[r];delete n.metadata,e.push(n)}return e}var r=void 0===t;r&&(t={textures:{},images:{}});var n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearCoat&&(n.clearCoat=this.clearCoat),void 0!==this.clearCoatRoughness&&(n.clearCoatRoughness=this.clearCoatRoughness),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,n.reflectivity=this.reflectivity),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(n.size=this.size),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Nl&&(n.blending=this.blending),!0===this.flatShading&&(n.flatShading=this.flatShading),this.side!==Al&&(n.side=this.side),this.vertexColors!==Tl&&(n.vertexColors=this.vertexColors),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(n.morphTargets=!0),!0===this.skinning&&(n.skinning=!0),!1===this.visible&&(n.visible=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),r){var i=e(t.textures),o=e(t.images);i.length>0&&(n.textures=i),o.length>0&&(n.images=o)}return n},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"})}}),(Q.prototype=Object.create(K.prototype)).constructor=Q,Q.prototype.isShaderMaterial=!0,Q.prototype.copy=function(t){return K.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Rh.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},Q.prototype.toJSON=function(t){var e=K.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},(J.prototype=Object.create(K.prototype)).constructor=J,J.prototype.isMeshDepthMaterial=!0,J.prototype.copy=function(t){return K.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},(tt.prototype=Object.create(K.prototype)).constructor=tt,tt.prototype.isMeshDistanceMaterial=!0,tt.prototype.copy=function(t){return K.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(et.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,c=t.length;si&&(i=l),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,c=t.count;si&&(i=l),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 l).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:function(){var t=new l;return function(e){return this.clampPoint(e.center,t),t.distanceToSquared(e.center)<=e.radius*e.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 l).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new l;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),getBoundingSphere:function(){var t=new l;return function(e){var r=e||new rt;return this.getCenter(r.center),r.radius=.5*this.getSize(t).length(),r}}(),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:function(){var t=[new l,new l,new l,new l,new l,new l,new l,new l];return function(e){return this.isEmpty()?this:(t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(t),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(rt.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(){var t=new et;return function(e,r){var n=this.center;void 0!==r?n.copy(r):t.setFromPoints(e).getCenter(n);for(var i=0,o=0,a=e.length;othis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n},getBoundingBox:function(t){var e=t||new et;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(nt.prototype,{isMatrix3:!0,set:function(t,e,r,n,i,o,a,s,c){var l=this.elements;return l[0]=t,l[1]=n,l[2]=a,l[3]=e,l[4]=i,l[5]=s,l[6]=r,l[7]=o,l[8]=c,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:function(){var t=new l;return function(e){for(var r=0,n=e.count;r1))return n.copy(i).multiplyScalar(a).add(e.start)}else if(0===this.distanceToPoint(e.start))return n.copy(e.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 l).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new l,e=new nt;return function(r,n){var i=n||e.getNormalMatrix(r),o=this.coplanarPoint(t).applyMatrix4(r),a=this.normal.applyMatrix3(i).normalize();return this.constant=-o.dot(a),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(ot.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],c=r[5],l=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+c,d+p,y+g).normalize(),e[3].setComponents(a-i,u-c,d-p,y-g).normalize(),e[4].setComponents(a-o,u-l,d-f,y-v).normalize(),e[5].setComponents(a+o,u+l,d+f,y+v).normalize(),this},intersectsObject:function(){var t=new rt;return function(e){var r=e.geometry;return null===r.boundingSphere&&r.computeBoundingSphere(),t.copy(r.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSprite:function(){var t=new rt;return function(e){return t.center.set(0,0,0),t.radius=.7071067811865476,t.applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),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?r.min.x:r.max.x,e.x=o.normal.x>0?r.max.x:r.min.x,t.y=o.normal.y>0?r.min.y:r.max.y,e.y=o.normal.y>0?r.max.y:r.min.y,t.z=o.normal.z>0?r.min.z:r.max.z,e.z=o.normal.z>0?r.max.z:r.min.z;var a=o.distanceToPoint(t),s=o.distanceToPoint(e);if(a<0&&s<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}}),ct.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],ct.DefaultOrder="XYZ",Object.defineProperties(ct.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(ct.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=xh.clamp,i=t.elements,o=i[0],a=i[4],s=i[8],c=i[1],l=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,l),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(c,l)):(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,l)):(this._y=0,this._z=Math.atan2(c,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(c,o)):(this._x=0,this._z=Math.atan2(-a,l))):"YZX"===e?(this._z=Math.asin(n(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-u,l),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,l),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-u,f),this._y=0)),this._order=e,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:function(){var t=new u;return function(e,r,n){return t.makeRotationFromQuaternion(e),this.setFromRotationMatrix(t,r,n)}}(),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:function(){var t=new c;return function(e){return t.setFromEuler(this),this.setFromQuaternion(t,e)}}(),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 l(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(lt.prototype,{set:function(t){this.mask=1<1){for(var e=0;e1){for(var e=0;e0){o.children=[];for(s=0;s0&&(i.geometries=l),u.length>0&&(i.materials=u),h.length>0&&(i.textures=h),p.length>0&&(i.images=p)}return i.object=o,i},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;r0)for(m=0;m0&&(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 et),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new rt),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,c=t.faces,l=this.faceVertexUvs[0],u=t.faceVertexUvs[0],h=this.colors,p=t.colors;void 0===r&&(r=0),void 0!==e&&(n=(new nt).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,x=v.vertexNormals.length>0,b=1!==v.color.r||1!==v.color.g||1!==v.color.b,w=v.vertexColors.length>0,S=0;if(S=t(S,0,0),S=t(S,1,!0),S=t(S,2,!1),S=t(S,3,y),S=t(S,4,_),S=t(S,5,x),S=t(S,6,b),S=t(S,7,w),u.push(S),u.push(v.a,v.b,v.c),u.push(v.materialIndex),y){var M=this.faceVertexUvs[0][c];u.push(n(M[0]),n(M[1]),n(M[2]))}if(_&&u.push(e(v.normal)),x){var A=v.vertexNormals;u.push(e(A[0]),e(A[1]),e(A[2]))}if(b&&u.push(r(v.color)),w){var E=v.vertexColors;u.push(r(E[0]),r(E[1]),r(E[2]))}}return i.data={},i.data.vertices=s,i.data.normals=h,f.length>0&&(i.data.colors=f),m.length>0&&(i.data.uvs=[m]),i.data.faces=u,i},clone:function(){return(new gt).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,s=o[1]&&o[1].length>0,c=t.morphTargets,l=c.length;if(l>0){e=[];for(v=0;v0){u=[];for(v=0;v65535?Mt:wt)(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 vt(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;if(void 0!==r){(new nt).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var t=new u;return function(e){return t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t=new u;return function(e){return t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t=new u;return function(e){return t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t=new u;return function(e,r,n){return t.makeTranslation(e,r,n),this.applyMatrix(t),this}}(),scale:function(){var t=new u;return function(e,r,n){return t.makeScale(e,r,n),this.applyMatrix(t),this}}(),lookAt:function(){var t=new ut;return function(e){t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.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 At(3*e.vertices.length,3),n=new At(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 At(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=t.geometry;if(t.isMesh){var r=e.__directGeometry;if(!0===e.elementsNeedUpdate&&(r=void 0,e.elementsNeedUpdate=!1),void 0===r)return this.fromGeometry(e);r.verticesNeedUpdate=e.verticesNeedUpdate,r.normalsNeedUpdate=e.normalsNeedUpdate,r.colorsNeedUpdate=e.colorsNeedUpdate,r.uvsNeedUpdate=e.uvsNeedUpdate,r.groupsNeedUpdate=e.groupsNeedUpdate,e.verticesNeedUpdate=!1,e.normalsNeedUpdate=!1,e.colorsNeedUpdate=!1,e.uvsNeedUpdate=!1,e.groupsNeedUpdate=!1,e=r}var n;return!0===e.verticesNeedUpdate&&(void 0!==(n=this.attributes.position)&&(n.copyVector3sArray(e.vertices),n.needsUpdate=!0),e.verticesNeedUpdate=!1),!0===e.normalsNeedUpdate&&(void 0!==(n=this.attributes.normal)&&(n.copyVector3sArray(e.normals),n.needsUpdate=!0),e.normalsNeedUpdate=!1),!0===e.colorsNeedUpdate&&(void 0!==(n=this.attributes.color)&&(n.copyColorsArray(e.colors),n.needsUpdate=!0),e.colorsNeedUpdate=!1),e.uvsNeedUpdate&&(void 0!==(n=this.attributes.uv)&&(n.copyVector2sArray(e.uvs),n.needsUpdate=!0),e.uvsNeedUpdate=!1),e.lineDistancesNeedUpdate&&(void 0!==(n=this.attributes.lineDistance)&&(n.copyArray(e.lineDistances),n.needsUpdate=!0),e.lineDistancesNeedUpdate=!1),e.groupsNeedUpdate&&(e.computeGroups(t.geometry),this.groups=e.groups,e.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new Ct).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new vt(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){var r=new Float32Array(3*t.normals.length);this.addAttribute("normal",new vt(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new vt(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new vt(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new vt(o,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var a=new(Tt(t.indices)>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new vt(a,1).copyIndicesArray(t.indices))}this.groups=t.groups;for(var s in t.morphTargets){for(var c=[],l=t.morphTargets[s],u=0,h=l.length;u0){var d=new At(4*t.skinIndices.length,4);this.addAttribute("skinIndex",d.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var m=new At(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 et);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:function(){var t=new et,e=new l;return function(){null===this.boundingSphere&&(this.boundingSphere=new rt);var r=this.attributes.position;if(r){var n=this.boundingSphere.center;t.setFromBufferAttribute(r),t.getCenter(n);for(var i=0,o=0,a=r.count;o0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(t.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),t},clone:function(){return(new Pt).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 c=[],l=s[e];for(r=0,n=l.length;r0)if(s=p*d-f,c=p*f-d,u=h*g,s>=0)if(c>=-u)if(c<=u){var v=1/g;l=(s*=v)*(s+p*(c*=v)+2*f)+c*(p*s+c+2*d)+m}else c=h,l=-(s=Math.max(0,-(p*c+f)))*s+c*(c+2*d)+m;else c=-h,l=-(s=Math.max(0,-(p*c+f)))*s+c*(c+2*d)+m;else c<=-u?l=-(s=Math.max(0,-(-p*h+f)))*s+(c=s>0?-h:Math.min(Math.max(-h,-d),h))*(c+2*d)+m:c<=u?(s=0,l=(c=Math.min(Math.max(-h,-d),h))*(c+2*d)+m):l=-(s=Math.max(0,-(p*h+f)))*s+(c=s>0?h:Math.min(Math.max(-h,-d),h))*(c+2*d)+m;else c=p>0?-h:h,l=-(s=Math.max(0,-(p*c+f)))*s+c*(c+2*d)+m;return o&&o.copy(this.direction).multiplyScalar(s).add(this.origin),a&&a.copy(e).multiplyScalar(c).add(t),l}}(),intersectSphere:function(){var t=new l;return function(e,r){t.subVectors(e.center,this.origin);var n=t.dot(this.direction),i=t.dot(t)-n*n,o=e.radius*e.radius;if(i>o)return null;var a=Math.sqrt(o-i),s=n-a,c=n+a;return s<0&&c<0?null:s<0?this.at(c,r):this.at(s,r)}}(),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);if(0===e)return!0;return t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var r,n,i,o,a,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;return c>=0?(r=(t.min.x-h.x)*c,n=(t.max.x-h.x)*c):(r=(t.max.x-h.x)*c,n=(t.min.x-h.x)*c),l>=0?(i=(t.min.y-h.y)*l,o=(t.max.y-h.y)*l):(i=(t.max.y-h.y)*l,o=(t.min.y-h.y)*l),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:function(){var t=new l;return function(e){return null!==this.intersectBox(e,t)}}(),intersectTriangle:function(){var t=new l,e=new l,r=new l,n=new l;return function(i,o,a,s,c){e.subVectors(o,i),r.subVectors(a,i),n.crossVectors(e,r);var l,u=this.direction.dot(n);if(u>0){if(s)return null;l=1}else{if(!(u<0))return null;l=-1,u=-u}t.subVectors(this.origin,i);var h=l*this.direction.dot(r.crossVectors(t,r));if(h<0)return null;var p=l*this.direction.dot(e.cross(t));if(p<0)return null;if(h+p>u)return null;var f=-l*t.dot(n);return f<0?null:this.at(f/u,c)}}(),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(Ft.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 l).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return(t||new l).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 l;return this.delta(r).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(){var t=new l,e=new l;return function(r,n){t.subVectors(r,this.start),e.subVectors(this.end,this.start);var i=e.dot(e),o=e.dot(t)/i;return n&&(o=xh.clamp(o,0,1)),o}}(),closestPointToPoint:function(t,e,r){var n=this.closestPointToPointParameter(t,e),i=r||new l;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(zt,{normal:function(){var t=new l;return function(e,r,n,i){var o=i||new l;o.subVectors(n,r),t.subVectors(e,r),o.cross(t);var a=o.lengthSq();return a>0?o.multiplyScalar(1/Math.sqrt(a)):o.set(0,0,0)}}(),barycoordFromPoint:function(){var t=new l,e=new l,r=new l;return function(n,i,o,a,s){t.subVectors(a,i),e.subVectors(o,i),r.subVectors(n,i);var c=t.dot(t),u=t.dot(e),h=t.dot(r),p=e.dot(e),f=e.dot(r),d=c*p-u*u,m=s||new l;if(0===d)return m.set(-2,-1,-1);var g=1/d,v=(p*h-u*f)*g,y=(c*f-u*h)*g;return m.set(1-v-y,y,v)}}(),containsPoint:function(){var t=new l;return function(e,r,n,i){var o=zt.barycoordFromPoint(e,r,n,i,t);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}()}),Object.assign(zt.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:function(){var t=new l,e=new l;return function(){return t.subVectors(this.c,this.b),e.subVectors(this.a,this.b),.5*t.cross(e).length()}}(),midpoint:function(t){return(t||new l).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return zt.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new it).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return zt.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return zt.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:function(){var t=new it,e=[new Ft,new Ft,new Ft],r=new l,n=new l;return function(i,o){var a=o||new l,s=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(i,r),!0===this.containsPoint(r))a.copy(r);else{e[0].set(this.a,this.b),e[1].set(this.b,this.c),e[2].set(this.c,this.a);for(var c=0;c0){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:c,point:x.clone(),object:t}}function r(r,n,i,o,a,l,u,p){s.fromBufferAttribute(o,l),c.fromBufferAttribute(o,u),h.fromBufferAttribute(o,p);var f=e(r,r.material,n,i,s,c,h,_);return f&&(a&&(m.fromBufferAttribute(a,l),g.fromBufferAttribute(a,u),v.fromBufferAttribute(a,p),f.uv=t(_,s,c,h,m,g,v)),f.face=new dt(l,u,p,zt.normal(s,c,h)),f.faceIndex=l),f}var i=new u,o=new Dt,a=new rt,s=new l,c=new l,h=new l,p=new l,f=new l,d=new l,m=new n,g=new n,v=new n,y=new l,_=new l,x=new l;return function(n,l){var u=this.geometry,y=this.material,x=this.matrixWorld;if(void 0!==y&&(null===u.boundingSphere&&u.computeBoundingSphere(),a.copy(u.boundingSphere),a.applyMatrix4(x),!1!==n.ray.intersectsSphere(a)&&(i.getInverse(x),o.copy(n.ray).applyMatrix4(i),null===u.boundingBox||!1!==o.intersectsBox(u.boundingBox)))){var b;if(u.isBufferGeometry){var w,S,M,A,E,C=u.index,T=u.attributes.position,P=u.attributes.uv;if(null!==C)for(A=0,E=C.count;A0&&(I=z);for(var k=0,U=F.length;ko)){var a=n.ray.origin.distanceTo(t);an.far||i.push({distance:a,point:t.clone(),face:null,object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),le.prototype=Object.assign(Object.create(ut.prototype),{constructor:le,copy:function(t){ut.prototype.copy.call(this,t,!1);for(var e=t.levels,r=0,n=e.length;r1){t.setFromMatrixPosition(r.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var i=t.distanceTo(e);n[0].object.visible=!0;for(var o=1,a=n.length;o=n[o].distance;o++)n[o-1].object.visible=!1,n[o].object.visible=!0;for(;oa)){f.applyMatrix4(this.matrixWorld);(A=n.ray.origin.distanceTo(f))n.far||i.push({distance:A,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else for(var y=0,_=g.length/3-1;y<_;y+=d){u.fromArray(g,3*y),h.fromArray(g,3*y+3);if(!((M=e.distanceSqToSegment(u,h,f,p))>a)){f.applyMatrix4(this.matrixWorld);(A=n.ray.origin.distanceTo(f))n.far||i.push({distance:A,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}else if(s.isGeometry)for(var w=s.vertices,S=w.length,y=0;ya)){f.applyMatrix4(this.matrixWorld);var A=n.ray.origin.distanceTo(f);An.far||i.push({distance:A,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),me.prototype=Object.assign(Object.create(de.prototype),{constructor:me,isLineSegments:!0}),ge.prototype=Object.assign(Object.create(de.prototype),{constructor:ge,isLineLoop:!0}),(ve.prototype=Object.create(K.prototype)).constructor=ve,ve.prototype.isPointsMaterial=!0,ve.prototype.copy=function(t){return K.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},ye.prototype=Object.assign(Object.create(ut.prototype),{constructor:ye,isPoints:!0,raycast:function(){var t=new u,e=new Dt,r=new rt;return function(n,i){function o(t,r){var o=e.distanceSqToPoint(t);if(on.far)return;i.push({distance:l,distanceToRay:Math.sqrt(o),point:s.clone(),index:r,face:null,object:a})}}var a=this,s=this.geometry,c=this.matrixWorld,u=n.params.Points.threshold;if(null===s.boundingSphere&&s.computeBoundingSphere(),r.copy(s.boundingSphere),r.applyMatrix4(c),r.radius+=u,!1!==n.ray.intersectsSphere(r)){t.getInverse(c),e.copy(n.ray).applyMatrix4(t);var h=u/((this.scale.x+this.scale.y+this.scale.z)/3),p=h*h,f=new l;if(s.isBufferGeometry){var d=s.index,m=s.attributes.position.array;if(null!==d)for(var g=d.array,v=0,y=g.length;v=-Number.EPSILON&&T>=-Number.EPSILON&&C>=-Number.EPSILON))return!1;return!0}return function(e,r){var n=e.length;if(n<3)return null;var i,o,a,s=[],c=[],l=[];if(kh.area(e)>0)for(o=0;o2;){if(h--<=0)return r?l:s;if(i=o,u<=i&&(i=0),o=i+1,u<=o&&(o=0),a=o+1,u<=a&&(a=0),t(e,i,o,a,u,c)){var p,f,d,m,g;for(p=c[i],f=c[o],d=c[a],s.push([e[p],e[f],e[d]]),l.push([c[i],c[o],c[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=l*u-c*h)<0||d>p)return[]}else{if(f>0||f0||dA?[]:x===A?o?[]:[y]:b<=A?[y,_]:[y,S]}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,c=n.x-t.x,l=n.y-t.y,u=i*s-o*a,h=i*l-o*c;if(Math.abs(u)>Number.EPSILON){var p=c*s-l*a;return u>0?h>=0&&p>=0:h>=0||p>=0}return h>0}r(t),e.forEach(r);for(var a,s,c,l,u,h,p={},f=t.concat(),d=0,m=e.length;dr&&(i=0);var a=o(y[t],y[n],y[i],s[e]);if(!a)return!1;var c=s.length-1,l=e-1;l<0&&(l=c);var u=e+1;return u>c&&(u=0),!!(a=o(s[e],s[l],s[u],y[t]))}function n(t,e){var r,n;for(r=0;r0)return!0;return!1}function a(t,r){var n,o,a,s;for(n=0;n<_.length;n++)for(o=e[_[n]],a=0;a0)return!0;return!1}for(var s,c,l,u,h,p,f,d,m,g,v,y=t.concat(),_=[],x=[],b=0,w=e.length;b0&&!(--M<0);)for(l=S;l=0)break;x[f]=!0}if(c>=0)break}return y}(t,e),v=kh.triangulate(g,!1);for(a=0,s=v.length;aNumber.EPSILON){var f=Math.sqrt(h),d=Math.sqrt(l*l+u*u),m=e.x-c/f,g=e.y+s/f,v=((r.x-u/d-m)*u-(r.y+l/d-g)*l)/(s*u-c*l),y=(i=m+s*v-t.x)*i+(o=g+c*v-t.y)*o;if(y<=2)return new n(i,o);a=Math.sqrt(y/2)}else{var _=!1;s>Number.EPSILON?l>Number.EPSILON&&(_=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(_=!0):Math.sign(c)===Math.sign(u)&&(_=!0),_?(i=-c,o=s,a=Math.sqrt(h)):(i=s,o=c,a=Math.sqrt(h/2))}return new n(i/a,o/a)}function o(t,e){var r,n;for($=t.length;--$>=0;){r=$,(n=$-1)<0&&(n=t.length-1);var i=0,o=C+2*M;for(i=0;i=0;B--){for(j=B/M,G=w*Math.cos(j*Math.PI/2),V=S*Math.sin(j*Math.PI/2),$=0,Z=U.length;$0||0===t.search(/^data\:image\/jpeg/);a.format=r?Wu:Hu,a.needsUpdate=!0,void 0!==e&&e(a)},r,n),a},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Sr.prototype=Object.assign(Object.create(ut.prototype),{constructor:Sr,isLight:!0,copy:function(t){return ut.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=ut.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}}),Mr.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Mr,isHemisphereLight:!0,copy:function(t){return Sr.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(Ar.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}}),Er.prototype=Object.assign(Object.create(Ar.prototype),{constructor:Er,isSpotLightShadow:!0,update:function(t){var e=this.camera,r=2*xh.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())}}),Cr.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Cr,isSpotLight:!0,copy:function(t){return Sr.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}}),Tr.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Tr,isPointLight:!0,copy:function(t){return Sr.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),Pr.prototype=Object.assign(Object.create(Ar.prototype),{constructor:Pr}),Lr.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Lr,isDirectionalLight:!0,copy:function(t){return Sr.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Rr.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Rr,isAmbientLight:!0}),Nr.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Nr,isRectAreaLight:!0,copy:function(t){return Sr.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){var e=Sr.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});var Gh={arraySlice:function(t,e,r){return Gh.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,c=0;c!==e;++c)i[a++]=t[s+c];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)}}};Object.assign(Ir.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 a=e[1];t=i)break e}o=r,r=0}}for(;r>>1;te;)--o;if(++o,0!==i||o!==n){i>=o&&(o=Math.max(o,1),i=o-1);var a=this.getValueSize();this.times=Gh.arraySlice(r,i,o),this.values=Gh.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&&Gh.isTypedArray(n))for(var a=0,c=n.length;a!==c;++a){var l=n[a];if(isNaN(l)){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(var d=o*r,m=i*r,p=0;p!==r;++p)e[m+p]=e[d+p];++i}return i!==t.length&&(this.times=Gh.arraySlice(t,0,i),this.values=Gh.arraySlice(e,0,i*r)),this}},kr.prototype=Object.assign(Object.create(Wh),{constructor:kr,ValueTypeName:"vector"}),Ur.prototype=Object.assign(Object.create(Ir.prototype),{constructor:Ur,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),u=s+a;s!==u;s+=4)c.slerpFlat(i,0,o,s-a,o,s,l);return i}}),Br.prototype=Object.assign(Object.create(Wh),{constructor:Br,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(t){return new Ur(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),Vr.prototype=Object.assign(Object.create(Wh),{constructor:Vr,ValueTypeName:"number"}),jr.prototype=Object.assign(Object.create(Wh),{constructor:jr,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Gr.prototype=Object.assign(Object.create(Wh),{constructor:Gr,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Wr.prototype=Object.assign(Object.create(Wh),{constructor:Wr,ValueTypeName:"color"}),Hr.prototype=Wh,Wh.constructor=Hr,Object.assign(Hr,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=Hr._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var r=[],n=[];Gh.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:Gh.convertArray(t.times,Array),values:Gh.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 Vr;case"vector":case"vector2":case"vector3":case"vector4":return kr;case"color":return Wr;case"quaternion":return Br;case"bool":case"boolean":return Gr;case"string":return jr}throw new Error("Unsupported typeName: "+t)}}),Object.assign(Xr,{parse:function(t){for(var e=[],r=t.tracks,n=1/(t.fps||1),i=0,o=r.length;i!==o;++i)e.push(Hr.parse(r[i]).scale(n));return new Xr(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(Hr.toJSON(r[i]));return n},CreateFromMorphTargetSequence:function(t,e,r,n){for(var i=e.length,o=[],a=0;a1){var l=n[h=c[1]];l||(n[h]=l=[]),l.push(s)}}var u=[];for(var h in n)u.push(Xr.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=[];Gh.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||[],c=0;c1?t.skinWeights[n+1]:0,c=r>2?t.skinWeights[n+2]:0,l=r>3?t.skinWeights[n+3]:0;e.skinWeights.push(new o(a,s,c,l))}if(t.skinIndices)for(var n=0,i=t.skinIndices.length;n1?t.skinIndices[n+1]:0,p=r>2?t.skinIndices[n+2]:0,f=r>3?t.skinIndices[n+3]:0;e.skinIndices.push(new o(u,h,p,f))}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)for(var h=e.faces,p=t.morphColors[0].colors,n=0,i=h.length;n0&&(e.animations=r)}(t,r),r.computeFaceNormals(),r.computeBoundingSphere(),void 0===t.materials||0===t.materials.length)return{geometry:r};return{geometry:r,materials:$r.prototype.initMaterials(t.materials,e,this.crossOrigin)}}}()}),Object.assign(Kr.prototype,{load:function(t,e,r,n){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var i=this;new vr(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 Zr,n=new qr,i=0,o=t.length;i0){var o=new xr(new gr(e));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=t.length;a0?new pe(s,c):new kt(s,c);break;case"LOD":a=new le;break;case"Line":a=new de(i(e.geometry),o(e.material),e.mode);break;case"LineLoop":a=new ge(i(e.geometry),o(e.material));break;case"LineSegments":a=new me(i(e.geometry),o(e.material));break;case"PointCloud":case"Points":a=new ye(i(e.geometry),o(e.material));break;case"Sprite":a=new ce(o(e.material));break;case"Group":a=new _e;break;default:a=new ut}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(t.fromArray(e.matrix),t.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.children)for(var l=e.children,u=0;u0)){c=i;break}c=i-1}if(i=c,n[i]===r)return i/(o-1);var l=n[i];return(i+(r-l)/(n[i+1]-l))/(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 l,a=[],s=[],c=[],h=new l,p=new u;for(r=0;r<=t;r++)n=r/t,a[r]=this.getTangentAt(n),a[r].normalize();s[0]=new l,c[0]=new l;var f=Number.MAX_VALUE,d=Math.abs(a[0].x),m=Math.abs(a[0].y),g=Math.abs(a[0].z);for(d<=f&&(f=d,o.set(1,0,0)),m<=f&&(f=m,o.set(0,1,0)),g<=f&&o.set(0,0,1),h.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],h),c[0].crossVectors(a[0],s[0]),r=1;r<=t;r++)s[r]=s[r-1].clone(),c[r]=c[r-1].clone(),h.crossVectors(a[r-1],a[r]),h.length()>Number.EPSILON&&(h.normalize(),i=Math.acos(xh.clamp(a[r-1].dot(a[r]),-1,1)),s[r].applyMatrix4(p.makeRotationAxis(h,i))),c[r].crossVectors(a[r],s[r]);if(!0===e)for(i=Math.acos(xh.clamp(s[0].dot(s[t]),-1,1)),i/=t,a[0].dot(h.crossVectors(s[0],s[t]))>0&&(i=-i),r=1;r<=t;r++)s[r].applyMatrix4(p.makeRotationAxis(a[r],i*r)),c[r].crossVectors(a[r],s[r]);return{tangents:a,normals:s,binormals:c}}}),(rn.prototype=Object.create(en.prototype)).constructor=rn,rn.prototype.isLineCurve=!0,rn.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},rn.prototype.getPointAt=function(t){return this.getPoint(t)},rn.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},nn.prototype=Object.assign(Object.create(en.prototype),{constructor:nn,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 rn(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 gt,r=0,n=t.length;re;)r-=e;re.length-2?e.length-1:i+1],l=e[i>e.length-3?e.length-1:i+2];return new n(Qr(o,a.x,s.x,c.x,l.x),Qr(o,a.y,s.y,c.y,l.y))},(sn.prototype=Object.create(en.prototype)).constructor=sn,sn.prototype.getPoint=function(t){var e=this.v0,r=this.v1,i=this.v2,o=this.v3;return new n(tn(t,e.x,r.x,i.x,o.x),tn(t,e.y,r.y,i.y,o.y))},(cn.prototype=Object.create(en.prototype)).constructor=cn,cn.prototype.getPoint=function(t){var e=this.v0,r=this.v1,i=this.v2;return new n(Jr(t,e.x,r.x,i.x),Jr(t,e.y,r.y,i.y))};var $h=Object.assign(Object.create(nn.prototype),{fromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,r=t.length;e0){var l=c.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(c);var u=c.getPoint(1);this.currentPoint.copy(u)}});ln.prototype=$h,$h.constructor=ln,un.prototype=Object.assign(Object.create($h),{constructor:un,getPointsHoles:function(t){for(var e=[],r=0,n=this.holes.length;rNumber.EPSILON){if(l<0&&(a=e[o],c=-c,s=e[i],l=-l),t.ys.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var u=l*(t.x-a.x)-c*(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=kh.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return r(o);var a,s,c,l=[];if(1===o.length)return s=o[0],c=new un,c.curves=s.curves,l.push(c),l;var u=!i(o[0].getPoints());u=t?!u:u;var h,p=[],f=[],d=[],m=0;f[m]=void 0,d[m]=[];for(var g=0,v=o.length;g1){for(var y=!1,_=[],x=0,b=f.length;x0&&(y||(d=p))}for(var C,g=0,T=f.length;g0){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){c.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(wn.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(Sn,{Composite:wn,create:function(t,e,r){return t&&t.isAnimationObjectGroup?new Sn.Composite(t,e,r):new Sn(t,e,r)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(/[^\w-]/g,"")},parseTrackName:function(){var t=new RegExp("^"+/((?:[\w-]+[\/:])*)/.source+/([\w-\.]+)?/.source+/(?:\.([\w-]+)(?:\[(.+)\])?)?/.source+/\.([\w-]+)(?:\[(.+)\])?/.source+"$"),e=["material","materials","bones"];return function(r){var n=t.exec(r);if(!n)throw new Error("PropertyBinding: Cannot parse trackName: "+r);var i={nodeName:n[2],objectName:n[3],objectIndex:n[4],propertyName:n[5],propertyIndex:n[6]},o=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==o&&-1!==o){var a=i.nodeName.substring(o+1);-1!==e.indexOf(a)&&(i.nodeName=i.nodeName.substring(0,o),i.objectName=a)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+r);return i}}(),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[l]=h,e[h]=c;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,c=arguments.length;s!==c;++s){var l=arguments[s].uuid,u=i[l];if(void 0!==u)if(delete i[l],u0)for(var c=this._interpolants,l=this._propertyBindings,u=0,h=c.length;u!==h;++u)c[u].evaluate(a),l[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 c=t<0;this._setEndings(c,!c,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=2401,n.endingEnd=2401):(n.endingStart=t?this.zeroSlopeAtStart?2401:sh:2402,n.endingEnd=e?this.zeroSlopeAtEnd?2401:sh:2402)},_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(En.prototype,r.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,c=this._bindingsByRootAndName,l=c[s];void 0===l&&(l={},c[s]=l);for(var u=0;u!==i;++u){var h=n[u],p=h.name,f=l[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 bn(Sn.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):r.y<-.99999?this.quaternion.set(1,0,0,0):(e.set(r.z,0,-r.x).normalize(),t=Math.acos(r.y),this.quaternion.setFromAxisAngle(e,t))}}(),ei.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()},ei.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},(ri.prototype=Object.create(me.prototype)).constructor=ri;var tp=new l,ep=new ni,rp=new ni,np=new ni;(ii.prototype=Object.create(en.prototype)).constructor=ii,ii.prototype.getPoint=function(t){var e=this.points,r=e.length,n=(r-(this.closed?0:1))*t,i=Math.floor(n),o=n-i;this.closed?i+=i>0?0:(Math.floor(Math.abs(i)/e.length)+1)*e.length:0===o&&i===r-1&&(i=r-2,o=1);var a,s,c,u;if(this.closed||i>0?a=e[(i-1)%r]:(tp.subVectors(e[0],e[1]).add(e[0]),a=tp),s=e[i%r],c=e[(i+1)%r],this.closed||i+2-1}function h(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function N(t,e){for(var r=t.length;r--&&_(e,t[r],0)>-1;);return r}function I(t){return"\\"+xr[t]}function O(t){return dr.test(t)}function D(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function F(t,e){return function(r){return t(e(r))}}function z(t,e){for(var r=-1,n=t.length,i=0,o=[];++r>>1,wt=[["ary",at],["bind",J],["bindKey",tt],["curry",rt],["curryRight",nt],["flip",ct],["partial",it],["partialRight",ot],["rearg",st]],St="[object Arguments]",Mt="[object Array]",At="[object AsyncFunction]",Et="[object Boolean]",Ct="[object Date]",Tt="[object DOMException]",Pt="[object Error]",Lt="[object Function]",Rt="[object GeneratorFunction]",Nt="[object Map]",It="[object Number]",Ot="[object Null]",Dt="[object Object]",Ft="[object Promise]",zt="[object Proxy]",kt="[object RegExp]",Ut="[object Set]",Bt="[object String]",Vt="[object Symbol]",jt="[object Undefined]",Gt="[object WeakMap]",Wt="[object WeakSet]",Ht="[object ArrayBuffer]",Xt="[object DataView]",Yt="[object Float32Array]",qt="[object Float64Array]",Zt="[object Int8Array]",$t="[object Int16Array]",Kt="[object Int32Array]",Qt="[object Uint8Array]",Jt="[object Uint8ClampedArray]",te="[object Uint16Array]",ee="[object Uint32Array]",re=/\b__p \+= '';/g,ne=/\b(__p \+=) '' \+/g,ie=/(__e\(.*?\)|\b__t\)) \+\n'';/g,oe=/&(?:amp|lt|gt|quot|#39);/g,ae=/[&<>"']/g,se=RegExp(oe.source),ce=RegExp(ae.source),le=/<%-([\s\S]+?)%>/g,ue=/<%([\s\S]+?)%>/g,he=/<%=([\s\S]+?)%>/g,pe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,fe=/^\w*$/,de=/^\./,me=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ge=/[\\^$.*+?()[\]{}|]/g,ve=RegExp(ge.source),ye=/^\s+|\s+$/g,_e=/^\s+/,xe=/\s+$/,be=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,we=/\{\n\/\* \[wrapped with (.+)\] \*/,Se=/,? & /,Me=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ae=/\\(\\)?/g,Ee=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ce=/\w*$/,Te=/^[-+]0x[0-9a-f]+$/i,Pe=/^0b[01]+$/i,Le=/^\[object .+?Constructor\]$/,Re=/^0o[0-7]+$/i,Ne=/^(?:0|[1-9]\d*)$/,Ie=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Oe=/($^)/,De=/['\n\r\u2028\u2029\\]/g,Fe="\\ud800-\\udfff",ze="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",ke="\\u2700-\\u27bf",Ue="a-z\\xdf-\\xf6\\xf8-\\xff",Be="A-Z\\xc0-\\xd6\\xd8-\\xde",Ve="\\ufe0e\\ufe0f",je="\\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",Ge="["+Fe+"]",We="["+je+"]",He="["+ze+"]",Xe="\\d+",Ye="["+ke+"]",qe="["+Ue+"]",Ze="[^"+Fe+je+Xe+ke+Ue+Be+"]",$e="\\ud83c[\\udffb-\\udfff]",Ke="[^"+Fe+"]",Qe="(?:\\ud83c[\\udde6-\\uddff]){2}",Je="[\\ud800-\\udbff][\\udc00-\\udfff]",tr="["+Be+"]",er="(?:"+qe+"|"+Ze+")",rr="(?:"+tr+"|"+Ze+")",nr="(?:['’](?:d|ll|m|re|s|t|ve))?",ir="(?:['’](?:D|LL|M|RE|S|T|VE))?",or="(?:"+He+"|"+$e+")"+"?",ar="["+Ve+"]?",sr=ar+or+("(?:\\u200d(?:"+[Ke,Qe,Je].join("|")+")"+ar+or+")*"),cr="(?:"+[Ye,Qe,Je].join("|")+")"+sr,lr="(?:"+[Ke+He+"?",He,Qe,Je,Ge].join("|")+")",ur=RegExp("['’]","g"),hr=RegExp(He,"g"),pr=RegExp($e+"(?="+$e+")|"+lr+sr,"g"),fr=RegExp([tr+"?"+qe+"+"+nr+"(?="+[We,tr,"$"].join("|")+")",rr+"+"+ir+"(?="+[We,tr+er,"$"].join("|")+")",tr+"?"+er+"+"+nr,tr+"+"+ir,"\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)","\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)",Xe,cr].join("|"),"g"),dr=RegExp("[\\u200d"+Fe+ze+Ve+"]"),mr=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,gr=["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"],vr=-1,yr={};yr[Yt]=yr[qt]=yr[Zt]=yr[$t]=yr[Kt]=yr[Qt]=yr[Jt]=yr[te]=yr[ee]=!0,yr[St]=yr[Mt]=yr[Ht]=yr[Et]=yr[Xt]=yr[Ct]=yr[Pt]=yr[Lt]=yr[Nt]=yr[It]=yr[Dt]=yr[kt]=yr[Ut]=yr[Bt]=yr[Gt]=!1;var _r={};_r[St]=_r[Mt]=_r[Ht]=_r[Xt]=_r[Et]=_r[Ct]=_r[Yt]=_r[qt]=_r[Zt]=_r[$t]=_r[Kt]=_r[Nt]=_r[It]=_r[Dt]=_r[kt]=_r[Ut]=_r[Bt]=_r[Vt]=_r[Qt]=_r[Jt]=_r[te]=_r[ee]=!0,_r[Pt]=_r[Lt]=_r[Gt]=!1;var xr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},br=parseFloat,wr=parseInt,Sr="object"==typeof wl&&wl&&wl.Object===Object&&wl,Mr="object"==typeof self&&self&&self.Object===Object&&self,Ar=Sr||Mr||Function("return this")(),Er=e&&!e.nodeType&&e,Cr=Er&&t&&!t.nodeType&&t,Tr=Cr&&Cr.exports===Er,Pr=Tr&&Sr.process,Lr=function(){try{return Pr&&Pr.binding&&Pr.binding("util")}catch(t){}}(),Rr=Lr&&Lr.isArrayBuffer,Nr=Lr&&Lr.isDate,Ir=Lr&&Lr.isMap,Or=Lr&&Lr.isRegExp,Dr=Lr&&Lr.isSet,Fr=Lr&&Lr.isTypedArray,zr=S("length"),kr=M({"À":"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"}),Ur=M({"&":"&","<":"<",">":">",'"':""","'":"'"}),Br=M({"&":"&","<":"<",">":">",""":'"',"'":"'"}),Vr=function t(e){function M(t){if(po(t)&&!rc(t)&&!(t instanceof ke)){if(t instanceof ze)return t;if(ra.call(t,"__wrapped__"))return Fi(t)}return new ze(t)}function Fe(){}function ze(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=V}function ke(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=_t,this.__views__=[]}function Ue(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function rr(t,e,i,o,s,c){var l,u=e&q,h=e&Z,p=e&$;if(i&&(l=s?i(t,o,s,c):i(t)),l!==V)return l;if(!ho(t))return t;var f=rc(t);if(f){if(l=function(t){var e=t.length,r=t.constructor(e);return e&&"string"==typeof t[0]&&ra.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!u)return kn(t,l)}else{var m=ps(t),g=m==Lt||m==Rt;if(ic(t))return Nn(t,u);if(m==Dt||m==St||g&&!s){if(l=h||g?{}:xi(t),!u)return h?function(t,e){return Un(t,hs(t),e)}(t,function(t,e){return t&&Un(e,To(e),t)}(l,t)):function(t,e){return Un(t,us(t),e)}(t,Qe(l,t))}else{if(!_r[m])return s?t:{};l=function(t,e,i,o){var a=t.constructor;switch(e){case Ht:return In(t);case Et:case Ct:return new a(+t);case Xt:return function(t,e){var r=e?In(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,o);case Yt:case qt:case Zt:case $t:case Kt:case Qt:case Jt:case te:case ee:return On(t,o);case Nt:return function(t,e,n){return d(e?n(D(t),q):D(t),r,new t.constructor)}(t,o,i);case It:case Bt:return new a(t);case kt:return function(t){var e=new t.constructor(t.source,Ce.exec(t));return e.lastIndex=t.lastIndex,e}(t);case Ut:return function(t,e,r){return d(e?r(k(t),q):k(t),n,new t.constructor)}(t,o,i);case Vt:return function(t){return Ka?Yo(Ka.call(t)):{}}(t)}}(t,m,rr,u)}}c||(c=new Ge);var v=c.get(t);if(v)return v;c.set(t,l);var y=f?V:(p?h?pi:hi:h?To:Co)(t);return a(y||t,function(r,n){y&&(r=t[n=r]),Ze(l,n,rr(r,e,i,n,t,c))}),l}function nr(t,e,r){var n=r.length;if(null==t)return!n;for(t=Yo(t);n--;){var i=r[n],o=e[i],a=t[i];if(a===V&&!(i in t)||!o(a))return!1}return!0}function ir(t,e,r){if("function"!=typeof t)throw new $o(W);return ms(function(){t.apply(V,r)},e)}function or(t,e,r,n){var i=-1,o=u,a=!0,s=t.length,c=[],l=e.length;if(!s)return c;r&&(e=p(e,T(r))),n?(o=h,a=!1):e.length>=j&&(o=L,a=!1,e=new je(e));t:for(;++i0&&r(s)?e>1?lr(s,e-1,r,n,i):f(i,s):n||(i[i.length]=s)}return i}function pr(t,e){return t&&rs(t,e,Co)}function dr(t,e){return t&&ns(t,e,Co)}function xr(t,e){return l(e,function(e){return co(t[e])})}function Sr(t,e){for(var r=0,n=(e=Ln(e,t)).length;null!=t&&re}function Pr(t,e){return null!=t&&ra.call(t,e)}function Lr(t,e){return null!=t&&e in Yo(t)}function zr(t,e,r){for(var n=r?h:u,i=t[0].length,o=t.length,a=o,s=jo(o),c=1/0,l=[];a--;){var f=t[a];a&&e&&(f=p(f,T(e))),c=Na(f.length,c),s[a]=!r&&(e||i>=120&&f.length>=120)?new je(a&&f):V}f=t[0];var d=-1,m=s[0];t:for(;++d=s)return c;var l=r[n];return c*("desc"==l?-1:1)}}return t.index-e.index}(t,e,r)})}function nn(t,e,r){for(var n=-1,i=e.length,o={};++n-1;)s!==t&&ga.call(s,c,1),ga.call(t,c,1);return t}function an(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;wi(i)?ga.call(t,i,1):wn(t,i)}}return t}function sn(t,e){return t+Aa(Da()*(e-t+1))}function cn(t,e){var r="";if(!t||e<1||e>gt)return r;do{e%2&&(r+=t),(e=Aa(e/2))&&(t+=t)}while(e);return r}function ln(t,e){return gs(Pi(t,e,Do),t+"")}function un(t){return He(Lo(t))}function hn(t,e){var r=Lo(t);return Ii(r,er(e,0,r.length))}function pn(t,e,r,n){if(!ho(t))return t;for(var i=-1,o=(e=Ln(e,t)).length,a=o-1,s=t;null!=s&&++ii?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=jo(i);++n>>1,a=t[o];null!==a&&!vo(a)&&(r?a<=e:a=j){var l=e?null:cs(t);if(l)return k(l);a=!1,i=L,c=new je}else c=e?[]:s;t:for(;++n=n?t:dn(t,e,r)}function Nn(t,e){if(e)return t.slice();var r=t.length,n=pa?pa(r):new t.constructor(r);return t.copy(n),n}function In(t){var e=new t.constructor(t.byteLength);return new ha(e).set(new ha(t)),e}function On(t,e){var r=e?In(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function Dn(t,e){if(t!==e){var r=t!==V,n=null===t,i=t==t,o=vo(t),a=e!==V,s=null===e,c=e==e,l=vo(e);if(!s&&!l&&!o&&t>e||o&&a&&c&&!s&&!l||n&&a&&c||!r&&c||!i)return 1;if(!n&&!o&&!l&&t1?r[i-1]:V,a=i>2?r[2]:V;for(o=t.length>3&&"function"==typeof o?(i--,o):V,a&&Si(r[0],r[1],a)&&(o=i<3?V:o,i=1),e=Yo(e);++n-1?i[o?e[a]:a]:V}}function qn(t){return ui(function(e){var r=e.length,n=r,i=ze.prototype.thru;for(t&&e.reverse();n--;){var o=e[n];if("function"!=typeof o)throw new $o(W);if(i&&!a&&"wrapper"==fi(o))var a=new ze([],!0)}for(n=a?n:r;++n1&&y.reverse(),h&&cs))return!1;var l=o.get(t);if(l&&o.get(e))return l==e;var u=-1,h=!0,p=r&Q?new je:V;for(o.set(t,e),o.set(e,t);++u-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(be,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return a(wt,function(r){var n="_."+r[0];e&r[1]&&!u(t,n)&&t.push(n)}),t.sort()}(function(t){var e=t.match(we);return e?e[1].split(Se):[]}(n),r)))}function Ni(t){var e=0,r=0;return function(){var n=Ia(),i=pt-(n-r);if(r=n,i>0){if(++e>=ht)return arguments[0]}else e=0;return t.apply(V,arguments)}}function Ii(t,e){var r=-1,n=t.length,i=n-1;for(e=e===V?n:e;++r0&&(r=e.apply(this,arguments)),t<=1&&(e=V),r}}function Ji(t,e,r){var n=oi(t,rt,V,V,V,V,V,e=r?V:e);return n.placeholder=Ji.placeholder,n}function to(t,e,r){var n=oi(t,nt,V,V,V,V,V,e=r?V:e);return n.placeholder=to.placeholder,n}function eo(t,e,r){function n(e){var r=c,n=l;return c=l=V,d=e,h=t.apply(n,r)}function i(t){var r=t-f;return f===V||r>=e||r<0||g&&t-d>=u}function o(){var t=Ws();if(i(t))return a(t);p=ms(o,function(t){var r=e-(t-f);return g?Na(r,u-(t-d)):r}(t))}function a(t){return p=V,v&&c?n(t):(c=l=V,h)}function s(){var t=Ws(),r=i(t);if(c=arguments,l=this,f=t,r){if(p===V)return function(t){return d=t,p=ms(o,e),m?n(t):h}(f);if(g)return p=ms(o,e),n(f)}return p===V&&(p=ms(o,e)),h}var c,l,u,h,p,f,d=0,m=!1,g=!1,v=!0;if("function"!=typeof t)throw new $o(W);return e=wo(e)||0,ho(r)&&(m=!!r.leading,u=(g="maxWait"in r)?Ra(wo(r.maxWait)||0,e):u,v="trailing"in r?!!r.trailing:v),s.cancel=function(){p!==V&&ss(p),d=0,c=f=l=p=V},s.flush=function(){return p===V?h:a(Ws())},s}function ro(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new $o(W);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(ro.Cache||Ve),r}function no(t){if("function"!=typeof t)throw new $o(W);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)}}function io(t,e){return t===e||t!=t&&e!=e}function oo(t){return null!=t&&uo(t.length)&&!co(t)}function ao(t){return po(t)&&oo(t)}function so(t){if(!po(t))return!1;var e=Er(t);return e==Pt||e==Tt||"string"==typeof t.message&&"string"==typeof t.name&&!mo(t)}function co(t){if(!ho(t))return!1;var e=Er(t);return e==Lt||e==Rt||e==At||e==zt}function lo(t){return"number"==typeof t&&t==xo(t)}function uo(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=gt}function ho(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function po(t){return null!=t&&"object"==typeof t}function fo(t){return"number"==typeof t||po(t)&&Er(t)==It}function mo(t){if(!po(t)||Er(t)!=Dt)return!1;var e=fa(t);if(null===e)return!0;var r=ra.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ea.call(r)==aa}function go(t){return"string"==typeof t||!rc(t)&&po(t)&&Er(t)==Bt}function vo(t){return"symbol"==typeof t||po(t)&&Er(t)==Vt}function yo(t){if(!t)return[];if(oo(t))return go(t)?B(t):kn(t);if(ya&&t[ya])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[ya]());var e=ps(t);return(e==Nt?D:e==Ut?k:Lo)(t)}function _o(t){return t?(t=wo(t))===mt||t===-mt?(t<0?-1:1)*vt:t==t?t:0:0===t?t:0}function xo(t){var e=_o(t),r=e%1;return e==e?r?e-r:e:0}function bo(t){return t?er(xo(t),0,_t):0}function wo(t){if("number"==typeof t)return t;if(vo(t))return yt;if(ho(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ho(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(ye,"");var r=Pe.test(t);return r||Re.test(t)?wr(t.slice(2),r?2:8):Te.test(t)?yt:+t}function So(t){return Un(t,To(t))}function Mo(t){return null==t?"":xn(t)}function Ao(t,e,r){var n=null==t?V:Sr(t,e);return n===V?r:n}function Eo(t,e){return null!=t&&_i(t,e,Lr)}function Co(t){return oo(t)?We(t):qr(t)}function To(t){return oo(t)?We(t,!0):Zr(t)}function Po(t,e){if(null==t)return{};var r=p(pi(t),function(t){return[t]});return e=mi(e),nn(t,r,function(t,r){return e(t,r[0])})}function Lo(t){return null==t?[]:P(t,Co(t))}function Ro(t){return Dc(Mo(t).toLowerCase())}function No(t){return(t=Mo(t))&&t.replace(Ie,kr).replace(hr,"")}function Io(t,e,r){return t=Mo(t),(e=r?V:e)===V?function(t){return mr.test(t)}(t)?function(t){return t.match(fr)||[]}(t):function(t){return t.match(Me)||[]}(t):t.match(e)||[]}function Oo(t){return function(){return t}}function Do(t){return t}function Fo(t){return Yr("function"==typeof t?t:rr(t,q))}function zo(t,e,r){var n=Co(e),i=xr(e,n);null!=r||ho(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=xr(e,Co(e)));var o=!(ho(r)&&"chain"in r&&!r.chain),s=co(t);return a(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(o||e){var r=t(this.__wrapped__);return(r.__actions__=kn(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,f([this.value()],arguments))})}),t}function ko(){}function Uo(t){return Mi(t)?S(Oi(t)):function(t){return function(e){return Sr(e,t)}}(t)}function Bo(){return[]}function Vo(){return!1}var jo=(e=null==e?Ar:Vr.defaults(Ar.Object(),e,Vr.pick(Ar,gr))).Array,Go=e.Date,Wo=e.Error,Ho=e.Function,Xo=e.Math,Yo=e.Object,qo=e.RegExp,Zo=e.String,$o=e.TypeError,Ko=jo.prototype,Qo=Ho.prototype,Jo=Yo.prototype,ta=e["__core-js_shared__"],ea=Qo.toString,ra=Jo.hasOwnProperty,na=0,ia=function(){var t=/[^.]+$/.exec(ta&&ta.keys&&ta.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),oa=Jo.toString,aa=ea.call(Yo),sa=Ar._,ca=qo("^"+ea.call(ra).replace(ge,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),la=Tr?e.Buffer:V,ua=e.Symbol,ha=e.Uint8Array,pa=la?la.allocUnsafe:V,fa=F(Yo.getPrototypeOf,Yo),da=Yo.create,ma=Jo.propertyIsEnumerable,ga=Ko.splice,va=ua?ua.isConcatSpreadable:V,ya=ua?ua.iterator:V,_a=ua?ua.toStringTag:V,xa=function(){try{var t=yi(Yo,"defineProperty");return t({},"",{}),t}catch(t){}}(),ba=e.clearTimeout!==Ar.clearTimeout&&e.clearTimeout,wa=Go&&Go.now!==Ar.Date.now&&Go.now,Sa=e.setTimeout!==Ar.setTimeout&&e.setTimeout,Ma=Xo.ceil,Aa=Xo.floor,Ea=Yo.getOwnPropertySymbols,Ca=la?la.isBuffer:V,Ta=e.isFinite,Pa=Ko.join,La=F(Yo.keys,Yo),Ra=Xo.max,Na=Xo.min,Ia=Go.now,Oa=e.parseInt,Da=Xo.random,Fa=Ko.reverse,za=yi(e,"DataView"),ka=yi(e,"Map"),Ua=yi(e,"Promise"),Ba=yi(e,"Set"),Va=yi(e,"WeakMap"),ja=yi(Yo,"create"),Ga=Va&&new Va,Wa={},Ha=Di(za),Xa=Di(ka),Ya=Di(Ua),qa=Di(Ba),Za=Di(Va),$a=ua?ua.prototype:V,Ka=$a?$a.valueOf:V,Qa=$a?$a.toString:V,Ja=function(){function t(){}return function(e){if(!ho(e))return{};if(da)return da(e);t.prototype=e;var r=new t;return t.prototype=V,r}}();M.templateSettings={escape:le,evaluate:ue,interpolate:he,variable:"",imports:{_:M}},(M.prototype=Fe.prototype).constructor=M,(ze.prototype=Ja(Fe.prototype)).constructor=ze,(ke.prototype=Ja(Fe.prototype)).constructor=ke,Ue.prototype.clear=function(){this.__data__=ja?ja(null):{},this.size=0},Ue.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Ue.prototype.get=function(t){var e=this.__data__;if(ja){var r=e[t];return r===H?V:r}return ra.call(e,t)?e[t]:V},Ue.prototype.has=function(t){var e=this.__data__;return ja?e[t]!==V:ra.call(e,t)},Ue.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=ja&&e===V?H:e,this},Be.prototype.clear=function(){this.__data__=[],this.size=0},Be.prototype.delete=function(t){var e=this.__data__,r=$e(e,t);return!(r<0||(r==e.length-1?e.pop():ga.call(e,r,1),--this.size,0))},Be.prototype.get=function(t){var e=this.__data__,r=$e(e,t);return r<0?V:e[r][1]},Be.prototype.has=function(t){return $e(this.__data__,t)>-1},Be.prototype.set=function(t,e){var r=this.__data__,n=$e(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},Ve.prototype.clear=function(){this.size=0,this.__data__={hash:new Ue,map:new(ka||Be),string:new Ue}},Ve.prototype.delete=function(t){var e=gi(this,t).delete(t);return this.size-=e?1:0,e},Ve.prototype.get=function(t){return gi(this,t).get(t)},Ve.prototype.has=function(t){return gi(this,t).has(t)},Ve.prototype.set=function(t,e){var r=gi(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},je.prototype.add=je.prototype.push=function(t){return this.__data__.set(t,H),this},je.prototype.has=function(t){return this.__data__.has(t)},Ge.prototype.clear=function(){this.__data__=new Be,this.size=0},Ge.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Ge.prototype.get=function(t){return this.__data__.get(t)},Ge.prototype.has=function(t){return this.__data__.has(t)},Ge.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Be){var n=r.__data__;if(!ka||n.length1?t[e-1]:V;return r="function"==typeof r?(t.pop(),r):V,Hi(t,r)}),Ds=ui(function(t){var e=t.length,r=e?t[0]:0,n=this.__wrapped__,i=function(e){return tr(e,t)};return!(e>1||this.__actions__.length)&&n instanceof ke&&wi(r)?((n=n.slice(r,+r+(e?1:0))).__actions__.push({func:Yi,args:[i],thisArg:V}),new ze(n,this.__chain__).thru(function(t){return e&&!t.length&&t.push(V),t})):this.thru(i)}),Fs=Bn(function(t,e,r){ra.call(t,r)?++t[r]:Je(t,r,1)}),zs=Yn(zi),ks=Yn(ki),Us=Bn(function(t,e,r){ra.call(t,r)?t[r].push(e):Je(t,r,[e])}),Bs=ln(function(t,e,r){var n=-1,o="function"==typeof e,a=oo(t)?jo(t.length):[];return ts(t,function(t){a[++n]=o?i(e,t,r):jr(t,e,r)}),a}),Vs=Bn(function(t,e,r){Je(t,r,e)}),js=Bn(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]}),Gs=ln(function(t,e){if(null==t)return[];var r=e.length;return r>1&&Si(t,e[0],e[1])?e=[]:r>2&&Si(e[0],e[1],e[2])&&(e=[e[0]]),rn(t,lr(e,1),[])}),Ws=wa||function(){return Ar.Date.now()},Hs=ln(function(t,e,r){var n=J;if(r.length){var i=z(r,di(Hs));n|=it}return oi(t,n,e,r,i)}),Xs=ln(function(t,e,r){var n=J|tt;if(r.length){var i=z(r,di(Xs));n|=it}return oi(e,n,t,r,i)}),Ys=ln(function(t,e){return ir(t,1,e)}),qs=ln(function(t,e,r){return ir(t,wo(e)||0,r)});ro.Cache=Ve;var Zs=as(function(t,e){var r=(e=1==e.length&&rc(e[0])?p(e[0],T(mi())):p(lr(e,1),T(mi()))).length;return ln(function(n){for(var o=-1,a=Na(n.length,r);++o=e}),ec=Gr(function(){return arguments}())?Gr:function(t){return po(t)&&ra.call(t,"callee")&&!ma.call(t,"callee")},rc=jo.isArray,nc=Rr?T(Rr):function(t){return po(t)&&Er(t)==Ht},ic=Ca||Vo,oc=Nr?T(Nr):function(t){return po(t)&&Er(t)==Ct},ac=Ir?T(Ir):function(t){return po(t)&&ps(t)==Nt},sc=Or?T(Or):function(t){return po(t)&&Er(t)==kt},cc=Dr?T(Dr):function(t){return po(t)&&ps(t)==Ut},lc=Fr?T(Fr):function(t){return po(t)&&uo(t.length)&&!!yr[Er(t)]},uc=ei($r),hc=ei(function(t,e){return t<=e}),pc=Vn(function(t,e){if(Ei(e)||oo(e))Un(e,Co(e),t);else for(var r in e)ra.call(e,r)&&Ze(t,r,e[r])}),fc=Vn(function(t,e){Un(e,To(e),t)}),dc=Vn(function(t,e,r,n){Un(e,To(e),t,n)}),mc=Vn(function(t,e,r,n){Un(e,Co(e),t,n)}),gc=ui(tr),vc=ln(function(t){return t.push(V,ai),i(dc,V,t)}),yc=ln(function(t){return t.push(V,si),i(Sc,V,t)}),_c=$n(function(t,e,r){t[e]=r},Oo(Do)),xc=$n(function(t,e,r){ra.call(t,e)?t[e].push(r):t[e]=[r]},mi),bc=ln(jr),wc=Vn(function(t,e,r){tn(t,e,r)}),Sc=Vn(function(t,e,r,n){tn(t,e,r,n)}),Mc=ui(function(t,e){var r={};if(null==t)return r;var n=!1;e=p(e,function(e){return e=Ln(e,t),n||(n=e.length>1),e}),Un(t,pi(t),r),n&&(r=rr(r,q|Z|$,ci));for(var i=e.length;i--;)wn(r,e[i]);return r}),Ac=ui(function(t,e){return null==t?{}:function(t,e){return nn(t,e,function(e,r){return Eo(t,r)})}(t,e)}),Ec=ii(Co),Cc=ii(To),Tc=Hn(function(t,e,r){return e=e.toLowerCase(),t+(r?Ro(e):e)}),Pc=Hn(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),Lc=Hn(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),Rc=Wn("toLowerCase"),Nc=Hn(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()}),Ic=Hn(function(t,e,r){return t+(r?" ":"")+Dc(e)}),Oc=Hn(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),Dc=Wn("toUpperCase"),Fc=ln(function(t,e){try{return i(t,V,e)}catch(t){return so(t)?t:new Wo(t)}}),zc=ui(function(t,e){return a(e,function(e){e=Oi(e),Je(t,e,Hs(t[e],t))}),t}),kc=qn(),Uc=qn(!0),Bc=ln(function(t,e){return function(r){return jr(r,t,e)}}),Vc=ln(function(t,e){return function(r){return jr(t,r,e)}}),jc=Qn(p),Gc=Qn(c),Wc=Qn(g),Hc=ti(),Xc=ti(!0),Yc=Kn(function(t,e){return t+e},0),qc=ni("ceil"),Zc=Kn(function(t,e){return t/e},1),$c=ni("floor"),Kc=Kn(function(t,e){return t*e},1),Qc=ni("round"),Jc=Kn(function(t,e){return t-e},0);return M.after=function(t,e){if("function"!=typeof e)throw new $o(W);return t=xo(t),function(){if(--t<1)return e.apply(this,arguments)}},M.ary=Ki,M.assign=pc,M.assignIn=fc,M.assignInWith=dc,M.assignWith=mc,M.at=gc,M.before=Qi,M.bind=Hs,M.bindAll=zc,M.bindKey=Xs,M.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return rc(t)?t:[t]},M.chain=Xi,M.chunk=function(t,e,r){e=(r?Si(t,e,r):e===V)?1:Ra(xo(e),0);var n=null==t?0:t.length;if(!n||e<1)return[];for(var i=0,o=0,a=jo(Ma(n/e));ii?0:i+r),(n=n===V||n>i?i:xo(n))<0&&(n+=i),n=r>n?0:bo(n);r>>0)?(t=Mo(t))&&("string"==typeof e||null!=e&&!sc(e))&&!(e=xn(e))&&O(t)?Rn(B(t),0,r):t.split(e,r):[]},M.spread=function(t,e){if("function"!=typeof t)throw new $o(W);return e=null==e?0:Ra(xo(e),0),ln(function(r){var n=r[e],o=Rn(r,0,e);return n&&f(o,n),i(t,this,o)})},M.tail=function(t){var e=null==t?0:t.length;return e?dn(t,1,e):[]},M.take=function(t,e,r){return t&&t.length?(e=r||e===V?1:xo(e),dn(t,0,e<0?0:e)):[]},M.takeRight=function(t,e,r){var n=null==t?0:t.length;return n?(e=r||e===V?1:xo(e),e=n-e,dn(t,e<0?0:e,n)):[]},M.takeRightWhile=function(t,e){return t&&t.length?Mn(t,mi(e,3),!1,!0):[]},M.takeWhile=function(t,e){return t&&t.length?Mn(t,mi(e,3)):[]},M.tap=function(t,e){return e(t),t},M.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new $o(W);return ho(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),eo(t,e,{leading:n,maxWait:e,trailing:i})},M.thru=Yi,M.toArray=yo,M.toPairs=Ec,M.toPairsIn=Cc,M.toPath=function(t){return rc(t)?p(t,Oi):vo(t)?[t]:kn(vs(Mo(t)))},M.toPlainObject=So,M.transform=function(t,e,r){var n=rc(t),i=n||ic(t)||lc(t);if(e=mi(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:ho(t)&&co(o)?Ja(fa(t)):{}}return(i?a:pr)(t,function(t,n,i){return e(r,t,n,i)}),r},M.unary=function(t){return Ki(t,1)},M.union=Es,M.unionBy=Cs,M.unionWith=Ts,M.uniq=function(t){return t&&t.length?bn(t):[]},M.uniqBy=function(t,e){return t&&t.length?bn(t,mi(e,2)):[]},M.uniqWith=function(t,e){return e="function"==typeof e?e:V,t&&t.length?bn(t,V,e):[]},M.unset=function(t,e){return null==t||wn(t,e)},M.unzip=Wi,M.unzipWith=Hi,M.update=function(t,e,r){return null==t?t:Sn(t,e,Pn(r))},M.updateWith=function(t,e,r,n){return n="function"==typeof n?n:V,null==t?t:Sn(t,e,Pn(r),n)},M.values=Lo,M.valuesIn=function(t){return null==t?[]:P(t,To(t))},M.without=Ps,M.words=Io,M.wrap=function(t,e){return $s(Pn(e),t)},M.xor=Ls,M.xorBy=Rs,M.xorWith=Ns,M.zip=Is,M.zipObject=function(t,e){return Cn(t||[],e||[],Ze)},M.zipObjectDeep=function(t,e){return Cn(t||[],e||[],pn)},M.zipWith=Os,M.entries=Ec,M.entriesIn=Cc,M.extend=fc,M.extendWith=dc,zo(M,M),M.add=Yc,M.attempt=Fc,M.camelCase=Tc,M.capitalize=Ro,M.ceil=qc,M.clamp=function(t,e,r){return r===V&&(r=e,e=V),r!==V&&(r=(r=wo(r))==r?r:0),e!==V&&(e=(e=wo(e))==e?e:0),er(wo(t),e,r)},M.clone=function(t){return rr(t,$)},M.cloneDeep=function(t){return rr(t,q|$)},M.cloneDeepWith=function(t,e){return e="function"==typeof e?e:V,rr(t,q|$,e)},M.cloneWith=function(t,e){return e="function"==typeof e?e:V,rr(t,$,e)},M.conformsTo=function(t,e){return null==e||nr(t,e,Co(e))},M.deburr=No,M.defaultTo=function(t,e){return null==t||t!=t?e:t},M.divide=Zc,M.endsWith=function(t,e,r){t=Mo(t),e=xn(e);var n=t.length,i=r=r===V?n:er(xo(r),0,n);return(r-=e.length)>=0&&t.slice(r,i)==e},M.eq=io,M.escape=function(t){return(t=Mo(t))&&ce.test(t)?t.replace(ae,Ur):t},M.escapeRegExp=function(t){return(t=Mo(t))&&ve.test(t)?t.replace(ge,"\\$&"):t},M.every=function(t,e,r){var n=rc(t)?c:ar;return r&&Si(t,e,r)&&(e=V),n(t,mi(e,3))},M.find=zs,M.findIndex=zi,M.findKey=function(t,e){return v(t,mi(e,3),pr)},M.findLast=ks,M.findLastIndex=ki,M.findLastKey=function(t,e){return v(t,mi(e,3),dr)},M.floor=$c,M.forEach=qi,M.forEachRight=Zi,M.forIn=function(t,e){return null==t?t:rs(t,mi(e,3),To)},M.forInRight=function(t,e){return null==t?t:ns(t,mi(e,3),To)},M.forOwn=function(t,e){return t&&pr(t,mi(e,3))},M.forOwnRight=function(t,e){return t&&dr(t,mi(e,3))},M.get=Ao,M.gt=Js,M.gte=tc,M.has=function(t,e){return null!=t&&_i(t,e,Pr)},M.hasIn=Eo,M.head=Bi,M.identity=Do,M.includes=function(t,e,r,n){t=oo(t)?t:Lo(t),r=r&&!n?xo(r):0;var i=t.length;return r<0&&(r=Ra(i+r,0)),go(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&_(t,e,r)>-1},M.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:xo(r);return i<0&&(i=Ra(n+i,0)),_(t,e,i)},M.inRange=function(t,e,r){return e=_o(e),r===V?(r=e,e=0):r=_o(r),t=wo(t),function(t,e,r){return t>=Na(e,r)&&t=-gt&&t<=gt},M.isSet=cc,M.isString=go,M.isSymbol=vo,M.isTypedArray=lc,M.isUndefined=function(t){return t===V},M.isWeakMap=function(t){return po(t)&&ps(t)==Gt},M.isWeakSet=function(t){return po(t)&&Er(t)==Wt},M.join=function(t,e){return null==t?"":Pa.call(t,e)},M.kebabCase=Pc,M.last=Vi,M.lastIndexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=n;return r!==V&&(i=(i=xo(r))<0?Ra(n+i,0):Na(i,n-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,i):y(t,b,i,!0)},M.lowerCase=Lc,M.lowerFirst=Rc,M.lt=uc,M.lte=hc,M.max=function(t){return t&&t.length?sr(t,Do,Cr):V},M.maxBy=function(t,e){return t&&t.length?sr(t,mi(e,2),Cr):V},M.mean=function(t){return w(t,Do)},M.meanBy=function(t,e){return w(t,mi(e,2))},M.min=function(t){return t&&t.length?sr(t,Do,$r):V},M.minBy=function(t,e){return t&&t.length?sr(t,mi(e,2),$r):V},M.stubArray=Bo,M.stubFalse=Vo,M.stubObject=function(){return{}},M.stubString=function(){return""},M.stubTrue=function(){return!0},M.multiply=Kc,M.nth=function(t,e){return t&&t.length?en(t,xo(e)):V},M.noConflict=function(){return Ar._===this&&(Ar._=sa),this},M.noop=ko,M.now=Ws,M.pad=function(t,e,r){t=Mo(t);var n=(e=xo(e))?U(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return Jn(Aa(i),r)+t+Jn(Ma(i),r)},M.padEnd=function(t,e,r){t=Mo(t);var n=(e=xo(e))?U(t):0;return e&&ne){var n=t;t=e,e=n}if(r||t%1||e%1){var i=Da();return Na(t+i*(e-t+br("1e-"+((i+"").length-1))),e)}return sn(t,e)},M.reduce=function(t,e,r){var n=rc(t)?d:A,i=arguments.length<3;return n(t,mi(e,4),r,i,ts)},M.reduceRight=function(t,e,r){var n=rc(t)?m:A,i=arguments.length<3;return n(t,mi(e,4),r,i,es)},M.repeat=function(t,e,r){return e=(r?Si(t,e,r):e===V)?1:xo(e),cn(Mo(t),e)},M.replace=function(){var t=arguments,e=Mo(t[0]);return t.length<3?e:e.replace(t[1],t[2])},M.result=function(t,e,r){var n=-1,i=(e=Ln(e,t)).length;for(i||(i=1,t=V);++ngt)return[];var r=_t,n=Na(t,_t);e=mi(e),t-=_t;for(var i=C(n,e);++r=o)return t;var s=r-U(n);if(s<1)return n;var c=a?Rn(a,0,s).join(""):t.slice(0,s);if(i===V)return c+n;if(a&&(s+=c.length-s),sc(i)){if(t.slice(s).search(i)){var l,u=c;for(i.global||(i=qo(i.source,Mo(Ce.exec(i))+"g")),i.lastIndex=0;l=i.exec(u);)var h=l.index;c=c.slice(0,h===V?s:h)}}else if(t.indexOf(xn(i),s)!=s){var p=c.lastIndexOf(i);p>-1&&(c=c.slice(0,p))}return c+n},M.unescape=function(t){return(t=Mo(t))&&se.test(t)?t.replace(oe,Br):t},M.uniqueId=function(t){var e=++na;return Mo(t)+e},M.upperCase=Oc,M.upperFirst=Dc,M.each=qi,M.eachRight=Zi,M.first=Bi,zo(M,function(){var t={};return pr(M,function(e,r){ra.call(M.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),M.VERSION="4.17.4",a(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){M[t].placeholder=M}),a(["drop","take"],function(t,e){ke.prototype[t]=function(r){r=r===V?1:Ra(xo(r),0);var n=this.__filtered__&&!e?new ke(this):this.clone();return n.__filtered__?n.__takeCount__=Na(r,n.__takeCount__):n.__views__.push({size:Na(r,_t),type:t+(n.__dir__<0?"Right":"")}),n},ke.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),a(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==ft||3==r;ke.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:mi(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),a(["head","last"],function(t,e){var r="take"+(e?"Right":"");ke.prototype[t]=function(){return this[r](1).value()[0]}}),a(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");ke.prototype[t]=function(){return this.__filtered__?new ke(this):this[r](1)}}),ke.prototype.compact=function(){return this.filter(Do)},ke.prototype.find=function(t){return this.filter(t).head()},ke.prototype.findLast=function(t){return this.reverse().find(t)},ke.prototype.invokeMap=ln(function(t,e){return"function"==typeof t?new ke(this):this.map(function(r){return jr(r,t,e)})}),ke.prototype.reject=function(t){return this.filter(no(mi(t)))},ke.prototype.slice=function(t,e){t=xo(t);var r=this;return r.__filtered__&&(t>0||e<0)?new ke(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==V&&(r=(e=xo(e))<0?r.dropRight(-e):r.take(e-t)),r)},ke.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},ke.prototype.toArray=function(){return this.take(_t)},pr(ke.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),n=/^(?:head|last)$/.test(e),i=M[n?"take"+("last"==e?"Right":""):e],o=n||/^find/.test(e);i&&(M.prototype[e]=function(){var e=this.__wrapped__,a=n?[1]:arguments,s=e instanceof ke,c=a[0],l=s||rc(e),u=function(t){var e=i.apply(M,f([t],a));return n&&h?e[0]:e};l&&r&&"function"==typeof c&&1!=c.length&&(s=l=!1);var h=this.__chain__,p=!!this.__actions__.length,d=o&&!h,m=s&&!p;if(!o&&l){e=m?e:new ke(this);var g=t.apply(e,a);return g.__actions__.push({func:Yi,args:[u],thisArg:V}),new ze(g,h)}return d&&m?t.apply(this,a):(g=this.thru(u),d?n?g.value()[0]:g.value():g)})}),a(["pop","push","shift","sort","splice","unshift"],function(t){var e=Ko[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);M.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(rc(i)?i:[],t)}return this[r](function(r){return e.apply(rc(r)?r:[],t)})}}),pr(ke.prototype,function(t,e){var r=M[e];if(r){var n=r.name+"";(Wa[n]||(Wa[n]=[])).push({name:e,func:r})}}),Wa[Zn(V,tt).name]=[{name:"wrapper",func:V}],ke.prototype.clone=function(){var t=new ke(this.__wrapped__);return t.__actions__=kn(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=kn(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=kn(this.__views__),t},ke.prototype.reverse=function(){if(this.__filtered__){var t=new ke(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},ke.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=rc(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?V:this.__values__[this.__index__++]}},M.prototype.plant=function(t){for(var e,r=this;r instanceof Fe;){var n=Fi(r);n.__index__=0,n.__values__=V,e?i.__wrapped__=n:e=n;var i=n;r=r.__wrapped__}return i.__wrapped__=t,e},M.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof ke){var e=t;return this.__actions__.length&&(e=new ke(this)),(e=e.reverse()).__actions__.push({func:Yi,args:[Gi],thisArg:V}),new ze(e,this.__chain__)}return this.thru(Gi)},M.prototype.toJSON=M.prototype.valueOf=M.prototype.value=function(){return An(this.__wrapped__,this.__actions__)},M.prototype.first=M.prototype.head,ya&&(M.prototype[ya]=function(){return this}),M}();"function"==typeof V&&"object"==typeof V.amd&&V.amd?(Ar._=Vr,V(function(){return Vr})):Cr?((Cr.exports=Vr)._=Vr,Er._=Vr):Ar._=Vr}).call(wl)});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,r[i]=e[19===i?3&t|8:t]);return r.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*Eh.DEG2RAD},radToDeg:function(t){return t*Eh.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}};Object.defineProperties(n.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(n.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:function(){var t=new n,e=new n;return function(r,n){return t.set(r,r),e.set(n,n),this.clamp(t,e)}}(),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 Ch=0;i.DEFAULT_IMAGE=void 0,i.DEFAULT_MAPPING=300,Object.defineProperty(i.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(i.prototype,r.prototype,{constructor:i,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=Eh.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 Tu:t.x=t.x-Math.floor(t.x);break;case Pu:t.x=t.x<0?0:1;break;case Lu: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 Tu:t.y=t.y-Math.floor(t.y);break;case Pu:t.y=t.y<0?0:1;break;case Lu: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(o.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],c=o[8],l=o[1],u=o[5],h=o[9],p=o[2],f=o[6],d=o[10];if(Math.abs(s-l)<.01&&Math.abs(c-p)<.01&&Math.abs(h-f)<.01){if(Math.abs(s+l)<.1&&Math.abs(c+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+l)/4,_=(c+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)+(c-p)*(c-p)+(l-s)*(l-s));return Math.abs(b)<.001&&(b=1),this.x=(f-h)/b,this.y=(c-p)/b,this.z=(l-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(){var t,e;return function(r,n){return void 0===t&&(t=new o,e=new o),t.set(r,r,r,r),e.set(n,n,n,n),this.clamp(t,e)}}(),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(a.prototype,r.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"})}}),(s.prototype=Object.create(a.prototype)).constructor=s,s.prototype.isWebGLRenderTargetCube=!0,Object.assign(c,{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],c=r[n+1],l=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||c!==p||l!==f){var m=1-a,g=s*h+c*p+l*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,c=c*m+p*b,l=l*m+f*b,u=u*m+d*b,m===1-a){var w=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=w,c*=w,l*=w,u*=w}}t[e]=s,t[e+1]=c,t[e+2]=l,t[e+3]=u}}),Object.defineProperties(c.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(c.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,c=a(r/2),l=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*l*u+c*p*f,this._y=c*p*u-h*l*f,this._z=c*l*f+h*p*u,this._w=c*l*u-h*p*f):"YXZ"===o?(this._x=h*l*u+c*p*f,this._y=c*p*u-h*l*f,this._z=c*l*f-h*p*u,this._w=c*l*u+h*p*f):"ZXY"===o?(this._x=h*l*u-c*p*f,this._y=c*p*u+h*l*f,this._z=c*l*f+h*p*u,this._w=c*l*u-h*p*f):"ZYX"===o?(this._x=h*l*u-c*p*f,this._y=c*p*u+h*l*f,this._z=c*l*f-h*p*u,this._w=c*l*u+h*p*f):"YZX"===o?(this._x=h*l*u+c*p*f,this._y=c*p*u+h*l*f,this._z=c*l*f-h*p*u,this._w=c*l*u-h*p*f):"XZY"===o&&(this._x=h*l*u-c*p*f,this._y=c*p*u-h*l*f,this._z=c*l*f+h*p*u,this._w=c*l*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],c=r[9],l=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-c)*e,this._y=(o-l)*e,this._z=(a-i)*e):n>s&&n>h?(e=2*Math.sqrt(1+n-s-h),this._w=(u-c)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(o+l)/e):s>h?(e=2*Math.sqrt(1+s-n-h),this._w=(o-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(c+u)/e):(e=2*Math.sqrt(1+h-n-s),this._w=(a-i)/e,this._x=(o+l)/e,this._y=(c+u)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e=new l;return function(r,n){return void 0===e&&(e=new l),(t=r.dot(n)+1)<1e-6?(t=0,Math.abs(r.x)>Math.abs(r.z)?e.set(-r.y,r.x,0):e.set(0,-r.z,r.y)):e.crossVectors(r,n),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,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,c=e._z,l=e._w;return this._x=r*l+o*a+n*c-i*s,this._y=n*l+o*s+i*a-r*c,this._z=i*l+o*c+r*s-n*a,this._w=o*l-r*a-n*s-i*c,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 c=Math.atan2(s,a),l=Math.sin((1-e)*c)/s,u=Math.sin(e*c)/s;return this._w=o*l+this._w*u,this._x=r*l+this._x*u,this._y=n*l+this._y*u,this._z=i*l+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(l.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:function(){var t=new c;return function(e){return!e||e.isEuler,this.applyQuaternion(t.setFromEuler(e))}}(),applyAxisAngle:function(){var t=new c;return function(e,r){return this.applyQuaternion(t.setFromAxisAngle(e,r))}}(),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,c=s*e+o*n-a*r,l=s*r+a*e-i*n,u=s*n+i*r-o*e,h=-i*e-o*r-a*n;return this.x=c*s+h*-i+l*-a-u*-o,this.y=l*s+h*-o+u*-i-c*-a,this.z=u*s+h*-a+c*-o-l*-i,this},project:function(){var t=new u;return function(e){return t.multiplyMatrices(e.projectionMatrix,t.getInverse(e.matrixWorld)),this.applyMatrix4(t)}}(),unproject:function(){var t=new u;return function(e){return t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyMatrix4(t)}}(),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:function(){var t=new l,e=new l;return function(r,n){return t.set(r,r,r),e.set(n,n,n),this.clamp(t,e)}}(),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:function(){var t=new l;return function(e){return t.copy(this).projectOnVector(e),this.sub(t)}}(),reflect:function(){var t=new l;return function(e){return this.sub(t.copy(e).multiplyScalar(2*this.dot(e)))}}(),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(Eh.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(u.prototype,{isMatrix4:!0,set:function(t,e,r,n,i,o,a,s,c,l,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]=c,g[6]=l,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 u).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:function(){var t=new l;return function(e){var r=this.elements,n=e.elements,i=1/t.setFromMatrixColumn(e,0).length(),o=1/t.setFromMatrixColumn(e,1).length(),a=1/t.setFromMatrixColumn(e,2).length();return r[0]=n[0]*i,r[1]=n[1]*i,r[2]=n[2]*i,r[4]=n[4]*o,r[5]=n[5]*o,r[6]=n[6]*o,r[8]=n[8]*a,r[9]=n[9]*a,r[10]=n[10]*a,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),c=Math.sin(n),l=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){var h=o*l,p=o*u,f=a*l,d=a*u;e[0]=s*l,e[4]=-s*u,e[8]=c,e[1]=p+f*c,e[5]=h-d*c,e[9]=-a*s,e[2]=d-h*c,e[6]=f+p*c,e[10]=o*s}else if("YXZ"===t.order){var m=s*l,g=s*u,v=c*l,y=c*u;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*c,e[1]=o*u,e[5]=o*l,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){m=s*l,g=s*u,v=c*l,y=c*u;e[0]=m-y*a,e[4]=-o*u,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*l,e[9]=y-m*a,e[2]=-o*c,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){h=o*l,p=o*u,f=a*l,d=a*u;e[0]=s*l,e[4]=f*c-p,e[8]=h*c+d,e[1]=s*u,e[5]=d*c+h,e[9]=p*c-f,e[2]=-c,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var _=o*s,x=o*c,b=a*s,w=a*c;e[0]=s*l,e[4]=w-_*u,e[8]=b*u+x,e[1]=u,e[5]=o*l,e[9]=-a*l,e[2]=-c*l,e[6]=x*u+b,e[10]=_-w*u}else if("XZY"===t.order){_=o*s,x=o*c,b=a*s,w=a*c;e[0]=s*l,e[4]=-u,e[8]=c*l,e[1]=_*u+w,e[5]=o*l,e[9]=x*u-b,e[2]=b*u-x,e[6]=a*l,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,c=i+i,l=r*a,u=r*s,h=r*c,p=n*s,f=n*c,d=i*c,m=o*a,g=o*s,v=o*c;return e[0]=1-(p+d),e[4]=u-v,e[8]=h+g,e[1]=u+v,e[5]=1-(l+d),e[9]=f-m,e[2]=h-g,e[6]=f+m,e[10]=1-(l+p),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:function(){var t=new l,e=new l,r=new l;return function(n,i,o){var a=this.elements;return r.subVectors(n,i),0===r.lengthSq()&&(r.z=1),r.normalize(),t.crossVectors(o,r),0===t.lengthSq()&&(1===Math.abs(o.z)?r.x+=1e-4:r.z+=1e-4,r.normalize(),t.crossVectors(o,r)),t.normalize(),e.crossVectors(r,t),a[0]=t.x,a[4]=e.x,a[8]=r.x,a[1]=t.y,a[5]=e.y,a[9]=r.y,a[2]=t.z,a[6]=e.z,a[10]=r.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],c=r[12],l=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+c*I,i[4]=o*w+a*E+s*L+c*O,i[8]=o*S+a*C+s*R+c*D,i[12]=o*M+a*T+s*N+c*F,i[1]=l*b+u*A+h*P+p*I,i[5]=l*w+u*E+h*L+p*O,i[9]=l*S+u*C+h*R+p*D,i[13]=l*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:function(){var t=new l;return function(e){for(var r=0,n=e.count;r>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=Eh.euclideanModulo(e,1),r=Eh.clamp(r,0,1),n=Eh.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,c=parseInt(n[3],10)/100;return e(n[5]),this.setHSL(a,s,c)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(t)){var l=(u=r[1]).length;if(3===l)return this.r=parseInt(u.charAt(0)+u.charAt(0),16)/255,this.g=parseInt(u.charAt(1)+u.charAt(1),16)/255,this.b=parseInt(u.charAt(2)+u.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(u.charAt(0)+u.charAt(1),16)/255,this.g=parseInt(u.charAt(2)+u.charAt(3),16)/255,this.b=parseInt(u.charAt(4)+u.charAt(5),16)/255,this}if(t&&t.length>0){var u;void 0!==(u=Dh[t])&&this.setHex(u)}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),c=Math.min(i,o,a),l=(c+s)/2;if(c===s)e=0,r=0;else{var u=s-c;switch(r=l<=.5?u/(s+c):u/(2-s-c),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"},Uh={basic:{uniforms:zh.merge([Fh.common,Fh.specularmap,Fh.envmap,Fh.aomap,Fh.lightmap,Fh.fog]),vertexShader:kh.meshbasic_vert,fragmentShader:kh.meshbasic_frag},lambert:{uniforms:zh.merge([Fh.common,Fh.specularmap,Fh.envmap,Fh.aomap,Fh.lightmap,Fh.emissivemap,Fh.fog,Fh.lights,{emissive:{value:new X(0)}}]),vertexShader:kh.meshlambert_vert,fragmentShader:kh.meshlambert_frag},phong:{uniforms:zh.merge([Fh.common,Fh.specularmap,Fh.envmap,Fh.aomap,Fh.lightmap,Fh.emissivemap,Fh.bumpmap,Fh.normalmap,Fh.displacementmap,Fh.gradientmap,Fh.fog,Fh.lights,{emissive:{value:new X(0)},specular:{value:new X(1118481)},shininess:{value:30}}]),vertexShader:kh.meshphong_vert,fragmentShader:kh.meshphong_frag},standard:{uniforms:zh.merge([Fh.common,Fh.envmap,Fh.aomap,Fh.lightmap,Fh.emissivemap,Fh.bumpmap,Fh.normalmap,Fh.displacementmap,Fh.roughnessmap,Fh.metalnessmap,Fh.fog,Fh.lights,{emissive:{value:new X(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:kh.meshphysical_vert,fragmentShader:kh.meshphysical_frag},points:{uniforms:zh.merge([Fh.points,Fh.fog]),vertexShader:kh.points_vert,fragmentShader:kh.points_frag},dashed:{uniforms:zh.merge([Fh.common,Fh.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:kh.linedashed_vert,fragmentShader:kh.linedashed_frag},depth:{uniforms:zh.merge([Fh.common,Fh.displacementmap]),vertexShader:kh.depth_vert,fragmentShader:kh.depth_frag},normal:{uniforms:zh.merge([Fh.common,Fh.bumpmap,Fh.normalmap,Fh.displacementmap,{opacity:{value:1}}]),vertexShader:kh.normal_vert,fragmentShader:kh.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:kh.cube_vert,fragmentShader:kh.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:kh.equirect_vert,fragmentShader:kh.equirect_frag},distanceRGBA:{uniforms:zh.merge([Fh.common,Fh.displacementmap,{referencePosition:{value:new l},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:kh.distanceRGBA_vert,fragmentShader:kh.distanceRGBA_frag},shadow:{uniforms:zh.merge([Fh.lights,{color:{value:new X(0)},opacity:{value:1}}]),vertexShader:kh.shadow_vert,fragmentShader:kh.shadow_frag}};Uh.physical={uniforms:zh.merge([Uh.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:kh.meshphysical_vert,fragmentShader:kh.meshphysical_frag},Object.assign(Y.prototype,{set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,r=t.length;ethis.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 n).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 n).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new n;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).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)}}),(Z.prototype=Object.create(i.prototype)).constructor=Z;var Bh=0;Object.assign(K.prototype,r.prototype,{isMaterial:!0,onBeforeCompile:function(){},setValues:function(t){if(void 0!==t)for(var e in t){var r=t[e];if(void 0!==r)if("shading"!==e){var n=this[e];void 0!==n&&(n&&n.isColor?n.set(r):n&&n.isVector3&&r&&r.isVector3?n.copy(r):this[e]="overdraw"===e?Number(r):r)}else this.flatShading=1===r}},toJSON:function(t){function e(t){var e=[];for(var r in t){var n=t[r];delete n.metadata,e.push(n)}return e}var r=void 0===t;r&&(t={textures:{},images:{}});var n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearCoat&&(n.clearCoat=this.clearCoat),void 0!==this.clearCoatRoughness&&(n.clearCoatRoughness=this.clearCoatRoughness),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,n.reflectivity=this.reflectivity),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(n.size=this.size),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==kl&&(n.blending=this.blending),!0===this.flatShading&&(n.flatShading=this.flatShading),this.side!==Rl&&(n.side=this.side),this.vertexColors!==Ol&&(n.vertexColors=this.vertexColors),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(n.morphTargets=!0),!0===this.skinning&&(n.skinning=!0),!1===this.visible&&(n.visible=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),r){var i=e(t.textures),o=e(t.images);i.length>0&&(n.textures=i),o.length>0&&(n.images=o)}return n},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"})}}),(Q.prototype=Object.create(K.prototype)).constructor=Q,Q.prototype.isShaderMaterial=!0,Q.prototype.copy=function(t){return K.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=zh.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},Q.prototype.toJSON=function(t){var e=K.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},(J.prototype=Object.create(K.prototype)).constructor=J,J.prototype.isMeshDepthMaterial=!0,J.prototype.copy=function(t){return K.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},(tt.prototype=Object.create(K.prototype)).constructor=tt,tt.prototype.isMeshDistanceMaterial=!0,tt.prototype.copy=function(t){return K.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(et.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,c=t.length;si&&(i=l),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,c=t.count;si&&(i=l),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 l).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:function(){var t=new l;return function(e){return this.clampPoint(e.center,t),t.distanceToSquared(e.center)<=e.radius*e.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 l).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new l;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),getBoundingSphere:function(){var t=new l;return function(e){var r=e||new rt;return this.getCenter(r.center),r.radius=.5*this.getSize(t).length(),r}}(),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:function(){var t=[new l,new l,new l,new l,new l,new l,new l,new l];return function(e){return this.isEmpty()?this:(t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(t),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(rt.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(){var t=new et;return function(e,r){var n=this.center;void 0!==r?n.copy(r):t.setFromPoints(e).getCenter(n);for(var i=0,o=0,a=e.length;othis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n},getBoundingBox:function(t){var e=t||new et;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(nt.prototype,{isMatrix3:!0,set:function(t,e,r,n,i,o,a,s,c){var l=this.elements;return l[0]=t,l[1]=n,l[2]=a,l[3]=e,l[4]=i,l[5]=s,l[6]=r,l[7]=o,l[8]=c,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:function(){var t=new l;return function(e){for(var r=0,n=e.count;r1))return n.copy(i).multiplyScalar(a).add(e.start)}else if(0===this.distanceToPoint(e.start))return n.copy(e.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 l).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new l,e=new nt;return function(r,n){var i=n||e.getNormalMatrix(r),o=this.coplanarPoint(t).applyMatrix4(r),a=this.normal.applyMatrix3(i).normalize();return this.constant=-o.dot(a),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(ot.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],c=r[5],l=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+c,d+p,y+g).normalize(),e[3].setComponents(a-i,u-c,d-p,y-g).normalize(),e[4].setComponents(a-o,u-l,d-f,y-v).normalize(),e[5].setComponents(a+o,u+l,d+f,y+v).normalize(),this},intersectsObject:function(){var t=new rt;return function(e){var r=e.geometry;return null===r.boundingSphere&&r.computeBoundingSphere(),t.copy(r.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSprite:function(){var t=new rt;return function(e){return t.center.set(0,0,0),t.radius=.7071067811865476,t.applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),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?r.min.x:r.max.x,e.x=o.normal.x>0?r.max.x:r.min.x,t.y=o.normal.y>0?r.min.y:r.max.y,e.y=o.normal.y>0?r.max.y:r.min.y,t.z=o.normal.z>0?r.min.z:r.max.z,e.z=o.normal.z>0?r.max.z:r.min.z;var a=o.distanceToPoint(t),s=o.distanceToPoint(e);if(a<0&&s<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}}),ct.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],ct.DefaultOrder="XYZ",Object.defineProperties(ct.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(ct.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=Eh.clamp,i=t.elements,o=i[0],a=i[4],s=i[8],c=i[1],l=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,l),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(c,l)):(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,l)):(this._y=0,this._z=Math.atan2(c,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(c,o)):(this._x=0,this._z=Math.atan2(-a,l))):"YZX"===e?(this._z=Math.asin(n(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-u,l),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,l),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-u,f),this._y=0)),this._order=e,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:function(){var t=new u;return function(e,r,n){return t.makeRotationFromQuaternion(e),this.setFromRotationMatrix(t,r,n)}}(),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:function(){var t=new c;return function(e){return t.setFromEuler(this),this.setFromQuaternion(t,e)}}(),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 l(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(lt.prototype,{set:function(t){this.mask=1<1){for(var e=0;e1){for(var e=0;e0){o.children=[];for(s=0;s0&&(i.geometries=l),u.length>0&&(i.materials=u),h.length>0&&(i.textures=h),p.length>0&&(i.images=p)}return i.object=o,i},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;r0)for(m=0;m0&&(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 et),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new rt),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,c=t.faces,l=this.faceVertexUvs[0],u=t.faceVertexUvs[0],h=this.colors,p=t.colors;void 0===r&&(r=0),void 0!==e&&(n=(new nt).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,x=v.vertexNormals.length>0,b=1!==v.color.r||1!==v.color.g||1!==v.color.b,w=v.vertexColors.length>0,S=0;if(S=t(S,0,0),S=t(S,1,!0),S=t(S,2,!1),S=t(S,3,y),S=t(S,4,_),S=t(S,5,x),S=t(S,6,b),S=t(S,7,w),u.push(S),u.push(v.a,v.b,v.c),u.push(v.materialIndex),y){var M=this.faceVertexUvs[0][c];u.push(n(M[0]),n(M[1]),n(M[2]))}if(_&&u.push(e(v.normal)),x){var A=v.vertexNormals;u.push(e(A[0]),e(A[1]),e(A[2]))}if(b&&u.push(r(v.color)),w){var E=v.vertexColors;u.push(r(E[0]),r(E[1]),r(E[2]))}}return i.data={},i.data.vertices=s,i.data.normals=h,f.length>0&&(i.data.colors=f),m.length>0&&(i.data.uvs=[m]),i.data.faces=u,i},clone:function(){return(new gt).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,s=o[1]&&o[1].length>0,c=t.morphTargets,l=c.length;if(l>0){e=[];for(var u=0;u0){h=[];for(u=0;u65535?Mt:wt)(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 vt(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;if(void 0!==r){(new nt).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var t=new u;return function(e){return t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t=new u;return function(e){return t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t=new u;return function(e){return t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t=new u;return function(e,r,n){return t.makeTranslation(e,r,n),this.applyMatrix(t),this}}(),scale:function(){var t=new u;return function(e,r,n){return t.makeScale(e,r,n),this.applyMatrix(t),this}}(),lookAt:function(){var t=new ut;return function(e){t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.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 At(3*e.vertices.length,3),n=new At(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 At(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=t.geometry;if(t.isMesh){var r=e.__directGeometry;if(!0===e.elementsNeedUpdate&&(r=void 0,e.elementsNeedUpdate=!1),void 0===r)return this.fromGeometry(e);r.verticesNeedUpdate=e.verticesNeedUpdate,r.normalsNeedUpdate=e.normalsNeedUpdate,r.colorsNeedUpdate=e.colorsNeedUpdate,r.uvsNeedUpdate=e.uvsNeedUpdate,r.groupsNeedUpdate=e.groupsNeedUpdate,e.verticesNeedUpdate=!1,e.normalsNeedUpdate=!1,e.colorsNeedUpdate=!1,e.uvsNeedUpdate=!1,e.groupsNeedUpdate=!1,e=r}var n;return!0===e.verticesNeedUpdate&&(void 0!==(n=this.attributes.position)&&(n.copyVector3sArray(e.vertices),n.needsUpdate=!0),e.verticesNeedUpdate=!1),!0===e.normalsNeedUpdate&&(void 0!==(n=this.attributes.normal)&&(n.copyVector3sArray(e.normals),n.needsUpdate=!0),e.normalsNeedUpdate=!1),!0===e.colorsNeedUpdate&&(void 0!==(n=this.attributes.color)&&(n.copyColorsArray(e.colors),n.needsUpdate=!0),e.colorsNeedUpdate=!1),e.uvsNeedUpdate&&(void 0!==(n=this.attributes.uv)&&(n.copyVector2sArray(e.uvs),n.needsUpdate=!0),e.uvsNeedUpdate=!1),e.lineDistancesNeedUpdate&&(void 0!==(n=this.attributes.lineDistance)&&(n.copyArray(e.lineDistances),n.needsUpdate=!0),e.lineDistancesNeedUpdate=!1),e.groupsNeedUpdate&&(e.computeGroups(t.geometry),this.groups=e.groups,e.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new Ct).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new vt(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){var r=new Float32Array(3*t.normals.length);this.addAttribute("normal",new vt(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new vt(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new vt(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new vt(o,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var a=new(Tt(t.indices)>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new vt(a,1).copyIndicesArray(t.indices))}this.groups=t.groups;for(var s in t.morphTargets){for(var c=[],l=t.morphTargets[s],u=0,h=l.length;u0){var d=new At(4*t.skinIndices.length,4);this.addAttribute("skinIndex",d.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var m=new At(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 et);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:function(){var t=new et,e=new l;return function(){null===this.boundingSphere&&(this.boundingSphere=new rt);var r=this.attributes.position;if(r){var n=this.boundingSphere.center;t.setFromBufferAttribute(r),t.getCenter(n);for(var i=0,o=0,a=r.count;o0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(t.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),t},clone:function(){return(new Pt).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 c=[],l=s[e];for(r=0,n=l.length;r0)if(s=p*d-f,c=p*f-d,u=h*g,s>=0)if(c>=-u)if(c<=u){var v=1/g;l=(s*=v)*(s+p*(c*=v)+2*f)+c*(p*s+c+2*d)+m}else c=h,l=-(s=Math.max(0,-(p*c+f)))*s+c*(c+2*d)+m;else c=-h,l=-(s=Math.max(0,-(p*c+f)))*s+c*(c+2*d)+m;else c<=-u?l=-(s=Math.max(0,-(-p*h+f)))*s+(c=s>0?-h:Math.min(Math.max(-h,-d),h))*(c+2*d)+m:c<=u?(s=0,l=(c=Math.min(Math.max(-h,-d),h))*(c+2*d)+m):l=-(s=Math.max(0,-(p*h+f)))*s+(c=s>0?h:Math.min(Math.max(-h,-d),h))*(c+2*d)+m;else c=p>0?-h:h,l=-(s=Math.max(0,-(p*c+f)))*s+c*(c+2*d)+m;return o&&o.copy(this.direction).multiplyScalar(s).add(this.origin),a&&a.copy(e).multiplyScalar(c).add(t),l}}(),intersectSphere:function(){var t=new l;return function(e,r){t.subVectors(e.center,this.origin);var n=t.dot(this.direction),i=t.dot(t)-n*n,o=e.radius*e.radius;if(i>o)return null;var a=Math.sqrt(o-i),s=n-a,c=n+a;return s<0&&c<0?null:s<0?this.at(c,r):this.at(s,r)}}(),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);if(0===e)return!0;return t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var r,n,i,o,a,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;return c>=0?(r=(t.min.x-h.x)*c,n=(t.max.x-h.x)*c):(r=(t.max.x-h.x)*c,n=(t.min.x-h.x)*c),l>=0?(i=(t.min.y-h.y)*l,o=(t.max.y-h.y)*l):(i=(t.max.y-h.y)*l,o=(t.min.y-h.y)*l),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:function(){var t=new l;return function(e){return null!==this.intersectBox(e,t)}}(),intersectTriangle:function(){var t=new l,e=new l,r=new l,n=new l;return function(i,o,a,s,c){e.subVectors(o,i),r.subVectors(a,i),n.crossVectors(e,r);var l,u=this.direction.dot(n);if(u>0){if(s)return null;l=1}else{if(!(u<0))return null;l=-1,u=-u}t.subVectors(this.origin,i);var h=l*this.direction.dot(r.crossVectors(t,r));if(h<0)return null;var p=l*this.direction.dot(e.cross(t));if(p<0)return null;if(h+p>u)return null;var f=-l*t.dot(n);return f<0?null:this.at(f/u,c)}}(),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(Ft.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 l).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return(t||new l).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 l;return this.delta(r).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(){var t=new l,e=new l;return function(r,n){t.subVectors(r,this.start),e.subVectors(this.end,this.start);var i=e.dot(e),o=e.dot(t)/i;return n&&(o=Eh.clamp(o,0,1)),o}}(),closestPointToPoint:function(t,e,r){var n=this.closestPointToPointParameter(t,e),i=r||new l;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(zt,{normal:function(){var t=new l;return function(e,r,n,i){var o=i||new l;o.subVectors(n,r),t.subVectors(e,r),o.cross(t);var a=o.lengthSq();return a>0?o.multiplyScalar(1/Math.sqrt(a)):o.set(0,0,0)}}(),barycoordFromPoint:function(){var t=new l,e=new l,r=new l;return function(n,i,o,a,s){t.subVectors(a,i),e.subVectors(o,i),r.subVectors(n,i);var c=t.dot(t),u=t.dot(e),h=t.dot(r),p=e.dot(e),f=e.dot(r),d=c*p-u*u,m=s||new l;if(0===d)return m.set(-2,-1,-1);var g=1/d,v=(p*h-u*f)*g,y=(c*f-u*h)*g;return m.set(1-v-y,y,v)}}(),containsPoint:function(){var t=new l;return function(e,r,n,i){var o=zt.barycoordFromPoint(e,r,n,i,t);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}()}),Object.assign(zt.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:function(){var t=new l,e=new l;return function(){return t.subVectors(this.c,this.b),e.subVectors(this.a,this.b),.5*t.cross(e).length()}}(),midpoint:function(t){return(t||new l).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return zt.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new it).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return zt.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return zt.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:function(){var t=new it,e=[new Ft,new Ft,new Ft],r=new l,n=new l;return function(i,o){var a=o||new l,s=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(i,r),!0===this.containsPoint(r))a.copy(r);else{e[0].set(this.a,this.b),e[1].set(this.b,this.c),e[2].set(this.c,this.a);for(var c=0;c0){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:c,point:x.clone(),object:t}}function r(r,n,i,o,a,l,u,p){s.fromBufferAttribute(o,l),c.fromBufferAttribute(o,u),h.fromBufferAttribute(o,p);var f=e(r,r.material,n,i,s,c,h,_);return f&&(a&&(m.fromBufferAttribute(a,l),g.fromBufferAttribute(a,u),v.fromBufferAttribute(a,p),f.uv=t(_,s,c,h,m,g,v)),f.face=new dt(l,u,p,zt.normal(s,c,h)),f.faceIndex=l),f}var i=new u,o=new Dt,a=new rt,s=new l,c=new l,h=new l,p=new l,f=new l,d=new l,m=new n,g=new n,v=new n,y=new l,_=new l,x=new l;return function(n,l){var u=this.geometry,y=this.material,x=this.matrixWorld;if(void 0!==y&&(null===u.boundingSphere&&u.computeBoundingSphere(),a.copy(u.boundingSphere),a.applyMatrix4(x),!1!==n.ray.intersectsSphere(a)&&(i.getInverse(x),o.copy(n.ray).applyMatrix4(i),null===u.boundingBox||!1!==o.intersectsBox(u.boundingBox)))){var b;if(u.isBufferGeometry){var w,S,M,A,E,C=u.index,T=u.attributes.position,P=u.attributes.uv;if(null!==C)for(A=0,E=C.count;A0&&(I=z);for(var k=0,U=F.length;ko)){var a=n.ray.origin.distanceTo(t);an.far||i.push({distance:a,point:t.clone(),face:null,object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),le.prototype=Object.assign(Object.create(ut.prototype),{constructor:le,copy:function(t){ut.prototype.copy.call(this,t,!1);for(var e=t.levels,r=0,n=e.length;r1){t.setFromMatrixPosition(r.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var i=t.distanceTo(e);n[0].object.visible=!0;for(var o=1,a=n.length;o=n[o].distance;o++)n[o-1].object.visible=!1,n[o].object.visible=!0;for(;oa)){f.applyMatrix4(this.matrixWorld);(M=n.ray.origin.distanceTo(f))n.far||i.push({distance:M,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else for(y=0,_=g.length/3-1;y<_;y+=d){u.fromArray(g,3*y),h.fromArray(g,3*y+3);if(!(e.distanceSqToSegment(u,h,f,p)>a)){f.applyMatrix4(this.matrixWorld);(M=n.ray.origin.distanceTo(f))n.far||i.push({distance:M,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}else if(s.isGeometry){var w=s.vertices,S=w.length;for(y=0;ya)){f.applyMatrix4(this.matrixWorld);var M;(M=n.ray.origin.distanceTo(f))n.far||i.push({distance:M,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),me.prototype=Object.assign(Object.create(de.prototype),{constructor:me,isLineSegments:!0}),ge.prototype=Object.assign(Object.create(de.prototype),{constructor:ge,isLineLoop:!0}),(ve.prototype=Object.create(K.prototype)).constructor=ve,ve.prototype.isPointsMaterial=!0,ve.prototype.copy=function(t){return K.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},ye.prototype=Object.assign(Object.create(ut.prototype),{constructor:ye,isPoints:!0,raycast:function(){var t=new u,e=new Dt,r=new rt;return function(n,i){function o(t,r){var o=e.distanceSqToPoint(t);if(on.far)return;i.push({distance:l,distanceToRay:Math.sqrt(o),point:s.clone(),index:r,face:null,object:a})}}var a=this,s=this.geometry,c=this.matrixWorld,u=n.params.Points.threshold;if(null===s.boundingSphere&&s.computeBoundingSphere(),r.copy(s.boundingSphere),r.applyMatrix4(c),r.radius+=u,!1!==n.ray.intersectsSphere(r)){t.getInverse(c),e.copy(n.ray).applyMatrix4(t);var h=u/((this.scale.x+this.scale.y+this.scale.z)/3),p=h*h,f=new l;if(s.isBufferGeometry){var d=s.index,m=s.attributes.position.array;if(null!==d)for(var g=d.array,v=0,y=g.length;v=-Number.EPSILON&&T>=-Number.EPSILON&&C>=-Number.EPSILON))return!1;return!0}return function(e,r){var n=e.length;if(n<3)return null;var i,o,a,s=[],c=[],l=[];if(Wh.area(e)>0)for(o=0;o2;){if(h--<=0)return r?l:s;if(i=o,u<=i&&(i=0),o=i+1,u<=o&&(o=0),a=o+1,u<=a&&(a=0),t(e,i,o,a,u,c)){var p,f,d,m,g;for(p=c[i],f=c[o],d=c[a],s.push([e[p],e[f],e[d]]),l.push([c[i],c[o],c[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=l*u-c*h)<0||d>p)return[]}else{if(f>0||f0||dA?[]:x===A?o?[]:[y]:b<=A?[y,_]:[y,S]}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,c=n.x-t.x,l=n.y-t.y,u=i*s-o*a,h=i*l-o*c;if(Math.abs(u)>Number.EPSILON){var p=c*s-l*a;return u>0?h>=0&&p>=0:h>=0||p>=0}return h>0}r(t),e.forEach(r);for(var a,s,c,l,u,h,p={},f=t.concat(),d=0,m=e.length;dr&&(i=0);var a=o(y[t],y[n],y[i],s[e]);if(!a)return!1;var c=s.length-1,l=e-1;l<0&&(l=c);var u=e+1;return u>c&&(u=0),!!(a=o(s[e],s[l],s[u],y[t]))}function n(t,e){var r,n;for(r=0;r0)return!0;return!1}function a(t,r){var n,o,a,s;for(n=0;n<_.length;n++)for(o=e[_[n]],a=0;a0)return!0;return!1}for(var s,c,l,u,h,p,f,d,m,g,v,y=t.concat(),_=[],x=[],b=0,w=e.length;b0&&!(--M<0);)for(l=S;l=0)break;x[f]=!0}if(c>=0)break}return y}(t,e),v=Wh.triangulate(g,!1);for(a=0,s=v.length;aNumber.EPSILON){var f=Math.sqrt(h),d=Math.sqrt(l*l+u*u),m=e.x-c/f,g=e.y+s/f,v=((r.x-u/d-m)*u-(r.y+l/d-g)*l)/(s*u-c*l),y=(i=m+s*v-t.x)*i+(o=g+c*v-t.y)*o;if(y<=2)return new n(i,o);a=Math.sqrt(y/2)}else{var _=!1;s>Number.EPSILON?l>Number.EPSILON&&(_=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(_=!0):Math.sign(c)===Math.sign(u)&&(_=!0),_?(i=-c,o=s,a=Math.sqrt(h)):(i=s,o=c,a=Math.sqrt(h/2))}return new n(i/a,o/a)}function o(t,e){var r,n;for(Z=t.length;--Z>=0;){r=Z,(n=Z-1)<0&&(n=t.length-1);var i=0,o=C+2*M;for(i=0;i=0;B--){for(j=B/M,G=w*Math.cos(j*Math.PI/2),V=S*Math.sin(j*Math.PI/2),Z=0,$=U.length;Z<$;Z++)a((W=r(U[Z],q[Z],V)).x,W.y,b+G);for(N=0,I=z.length;N0||0===t.search(/^data\:image\/jpeg/);a.format=r?$u:Ku,a.needsUpdate=!0,void 0!==e&&e(a)},r,n),a},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Sr.prototype=Object.assign(Object.create(ut.prototype),{constructor:Sr,isLight:!0,copy:function(t){return ut.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=ut.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}}),Mr.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Mr,isHemisphereLight:!0,copy:function(t){return Sr.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(Ar.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}}),Er.prototype=Object.assign(Object.create(Ar.prototype),{constructor:Er,isSpotLightShadow:!0,update:function(t){var e=this.camera,r=2*Eh.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())}}),Cr.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Cr,isSpotLight:!0,copy:function(t){return Sr.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}}),Tr.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Tr,isPointLight:!0,copy:function(t){return Sr.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),Pr.prototype=Object.assign(Object.create(Ar.prototype),{constructor:Pr}),Lr.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Lr,isDirectionalLight:!0,copy:function(t){return Sr.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Rr.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Rr,isAmbientLight:!0}),Nr.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Nr,isRectAreaLight:!0,copy:function(t){return Sr.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){var e=Sr.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});var Zh={arraySlice:function(t,e,r){return Zh.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,c=0;c!==e;++c)i[a++]=t[s+c];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)}}};Object.assign(Ir.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)break e}o=r,r=0}}for(;r>>1;te;)--o;if(++o,0!==i||o!==n){i>=o&&(o=Math.max(o,1),i=o-1);var a=this.getValueSize();this.times=Zh.arraySlice(r,i,o),this.values=Zh.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&&Zh.isTypedArray(n)){a=0;for(var c=n.length;a!==c;++a){var l=n[a];if(isNaN(l)){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=Zh.arraySlice(t,0,i),this.values=Zh.arraySlice(e,0,i*r)),this}},kr.prototype=Object.assign(Object.create($h),{constructor:kr,ValueTypeName:"vector"}),Ur.prototype=Object.assign(Object.create(Ir.prototype),{constructor:Ur,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),u=s+a;s!==u;s+=4)c.slerpFlat(i,0,o,s-a,o,s,l);return i}}),Br.prototype=Object.assign(Object.create($h),{constructor:Br,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(t){return new Ur(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),Vr.prototype=Object.assign(Object.create($h),{constructor:Vr,ValueTypeName:"number"}),jr.prototype=Object.assign(Object.create($h),{constructor:jr,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Gr.prototype=Object.assign(Object.create($h),{constructor:Gr,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Wr.prototype=Object.assign(Object.create($h),{constructor:Wr,ValueTypeName:"color"}),Hr.prototype=$h,$h.constructor=Hr,Object.assign(Hr,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=Hr._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var r=[],n=[];Zh.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:Zh.convertArray(t.times,Array),values:Zh.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 Vr;case"vector":case"vector2":case"vector3":case"vector4":return kr;case"color":return Wr;case"quaternion":return Br;case"bool":case"boolean":return Gr;case"string":return jr}throw new Error("Unsupported typeName: "+t)}}),Object.assign(Xr,{parse:function(t){for(var e=[],r=t.tracks,n=1/(t.fps||1),i=0,o=r.length;i!==o;++i)e.push(Hr.parse(r[i]).scale(n));return new Xr(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(Hr.toJSON(r[i]));return n},CreateFromMorphTargetSequence:function(t,e,r,n){for(var i=e.length,o=[],a=0;a1){var l=n[h=c[1]];l||(n[h]=l=[]),l.push(s)}}var u=[];for(var h in n)u.push(Xr.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=[];Zh.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||[],c=0;c1?t.skinWeights[n+1]:0,c=r>2?t.skinWeights[n+2]:0,l=r>3?t.skinWeights[n+3]:0;e.skinWeights.push(new o(a,s,c,l))}if(t.skinIndices)for(n=0,i=t.skinIndices.length;n1?t.skinIndices[n+1]:0,p=r>2?t.skinIndices[n+2]:0,f=r>3?t.skinIndices[n+3]:0;e.skinIndices.push(new o(u,h,p,f))}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 h=e.faces,p=t.morphColors[0].colors;for(n=0,i=h.length;n0&&(e.animations=r)}(t,r),r.computeFaceNormals(),r.computeBoundingSphere(),void 0===t.materials||0===t.materials.length)return{geometry:r};return{geometry:r,materials:Zr.prototype.initMaterials(t.materials,e,this.crossOrigin)}}}()}),Object.assign(Kr.prototype,{load:function(t,e,r,n){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var i=this;new vr(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 $r,n=new qr,i=0,o=t.length;i0){var o=new xr(new gr(e));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=t.length;a0?new pe(s,c):new kt(s,c);break;case"LOD":a=new le;break;case"Line":a=new de(i(e.geometry),o(e.material),e.mode);break;case"LineLoop":a=new ge(i(e.geometry),o(e.material));break;case"LineSegments":a=new me(i(e.geometry),o(e.material));break;case"PointCloud":case"Points":a=new ye(i(e.geometry),o(e.material));break;case"Sprite":a=new ce(o(e.material));break;case"Group":a=new _e;break;default:a=new ut}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(t.fromArray(e.matrix),t.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.children)for(var l=e.children,u=0;u0)){c=i;break}c=i-1}if(i=c,n[i]===r)return i/(o-1);var l=n[i];return(i+(r-l)/(n[i+1]-l))/(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 l,a=[],s=[],c=[],h=new l,p=new u;for(r=0;r<=t;r++)n=r/t,a[r]=this.getTangentAt(n),a[r].normalize();s[0]=new l,c[0]=new l;var f=Number.MAX_VALUE,d=Math.abs(a[0].x),m=Math.abs(a[0].y),g=Math.abs(a[0].z);for(d<=f&&(f=d,o.set(1,0,0)),m<=f&&(f=m,o.set(0,1,0)),g<=f&&o.set(0,0,1),h.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],h),c[0].crossVectors(a[0],s[0]),r=1;r<=t;r++)s[r]=s[r-1].clone(),c[r]=c[r-1].clone(),h.crossVectors(a[r-1],a[r]),h.length()>Number.EPSILON&&(h.normalize(),i=Math.acos(Eh.clamp(a[r-1].dot(a[r]),-1,1)),s[r].applyMatrix4(p.makeRotationAxis(h,i))),c[r].crossVectors(a[r],s[r]);if(!0===e)for(i=Math.acos(Eh.clamp(s[0].dot(s[t]),-1,1)),i/=t,a[0].dot(h.crossVectors(s[0],s[t]))>0&&(i=-i),r=1;r<=t;r++)s[r].applyMatrix4(p.makeRotationAxis(a[r],i*r)),c[r].crossVectors(a[r],s[r]);return{tangents:a,normals:s,binormals:c}}}),(rn.prototype=Object.create(en.prototype)).constructor=rn,rn.prototype.isLineCurve=!0,rn.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},rn.prototype.getPointAt=function(t){return this.getPoint(t)},rn.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},nn.prototype=Object.assign(Object.create(en.prototype),{constructor:nn,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 rn(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 gt,r=0,n=t.length;re;)r-=e;re.length-2?e.length-1:i+1],l=e[i>e.length-3?e.length-1:i+2];return new n(Qr(o,a.x,s.x,c.x,l.x),Qr(o,a.y,s.y,c.y,l.y))},(sn.prototype=Object.create(en.prototype)).constructor=sn,sn.prototype.getPoint=function(t){var e=this.v0,r=this.v1,i=this.v2,o=this.v3;return new n(tn(t,e.x,r.x,i.x,o.x),tn(t,e.y,r.y,i.y,o.y))},(cn.prototype=Object.create(en.prototype)).constructor=cn,cn.prototype.getPoint=function(t){var e=this.v0,r=this.v1,i=this.v2;return new n(Jr(t,e.x,r.x,i.x),Jr(t,e.y,r.y,i.y))};var ep=Object.assign(Object.create(nn.prototype),{fromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,r=t.length;e0){var l=c.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(c);var u=c.getPoint(1);this.currentPoint.copy(u)}});ln.prototype=ep,ep.constructor=ln,un.prototype=Object.assign(Object.create(ep),{constructor:un,getPointsHoles:function(t){for(var e=[],r=0,n=this.holes.length;rNumber.EPSILON){if(l<0&&(a=e[o],c=-c,s=e[i],l=-l),t.ys.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var u=l*(t.x-a.x)-c*(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=Wh.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return r(o);var a,s,c,l=[];if(1===o.length)return s=o[0],c=new un,c.curves=s.curves,l.push(c),l;var u=!i(o[0].getPoints());u=t?!u:u;var h,p=[],f=[],d=[],m=0;f[m]=void 0,d[m]=[];for(var g=0,v=o.length;g1){for(var y=!1,_=[],x=0,b=f.length;x0&&(y||(d=p))}g=0;for(var C,T=f.length;g0){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){c.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(wn.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(Sn,{Composite:wn,create:function(t,e,r){return t&&t.isAnimationObjectGroup?new Sn.Composite(t,e,r):new Sn(t,e,r)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(/[^\w-]/g,"")},parseTrackName:function(){var t=new RegExp("^"+/((?:[\w-]+[\/:])*)/.source+/([\w-\.]+)?/.source+/(?:\.([\w-]+)(?:\[(.+)\])?)?/.source+/\.([\w-]+)(?:\[(.+)\])?/.source+"$"),e=["material","materials","bones"];return function(r){var n=t.exec(r);if(!n)throw new Error("PropertyBinding: Cannot parse trackName: "+r);var i={nodeName:n[2],objectName:n[3],objectIndex:n[4],propertyName:n[5],propertyIndex:n[6]},o=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==o&&-1!==o){var a=i.nodeName.substring(o+1);-1!==e.indexOf(a)&&(i.nodeName=i.nodeName.substring(0,o),i.objectName=a)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+r);return i}}(),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[l]=h,e[h]=c;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,c=arguments.length;s!==c;++s){var l=arguments[s].uuid,u=i[l];if(void 0!==u)if(delete i[l],u0)for(var c=this._interpolants,l=this._propertyBindings,u=0,h=c.length;u!==h;++u)c[u].evaluate(a),l[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 c=t<0;this._setEndings(c,!c,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=2401,n.endingEnd=2401):(n.endingStart=t?this.zeroSlopeAtStart?2401:fh:2402,n.endingEnd=e?this.zeroSlopeAtEnd?2401:fh:2402)},_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(En.prototype,r.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,c=this._bindingsByRootAndName,l=c[s];void 0===l&&(l={},c[s]=l);for(var u=0;u!==i;++u){var h=n[u],p=h.name,f=l[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 bn(Sn.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):r.y<-.99999?this.quaternion.set(1,0,0,0):(e.set(r.z,0,-r.x).normalize(),t=Math.acos(r.y),this.quaternion.setFromAxisAngle(e,t))}}(),ei.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()},ei.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},(ri.prototype=Object.create(me.prototype)).constructor=ri;var ap=new l,sp=new ni,cp=new ni,lp=new ni;(ii.prototype=Object.create(en.prototype)).constructor=ii,ii.prototype.getPoint=function(t){var e=this.points,r=e.length,n=(r-(this.closed?0:1))*t,i=Math.floor(n),o=n-i;this.closed?i+=i>0?0:(Math.floor(Math.abs(i)/e.length)+1)*e.length:0===o&&i===r-1&&(i=r-2,o=1);var a,s,c,u;if(this.closed||i>0?a=e[(i-1)%r]:(ap.subVectors(e[0],e[1]).add(e[0]),a=ap),s=e[i%r],c=e[(i+1)%r],this.closed||i+2=0;n--){var i=t[n];"."===i?t.splice( var target = document.getElementById('foo') var spinner = new Spinner(opts).spin(target) */ -!function(e,r){t.exports?t.exports=r():e.Spinner=r()}(gl,function(){function t(t,e){var r,n=document.createElement(t||"div");for(r in e)n[r]=e[r];return n}function e(t){for(var e=1,r=arguments.length;e>1)+"px"})}for(var l,u=0,h=(o.lines-1)*(1-o.direction)/2;u',r)}l.addRule(".spin-vml","behavior:url(#default#VML)"),s.prototype.lines=function(t,n){function o(){return i(r("group",{coordsize:u+" "+u,coordorigin:-l+" "+-l}),{width:u,height:u})}function s(t,s,c){e(p,e(i(o(),{rotation:360/n.lines*t+"deg",left:~~s}),e(i(r("roundrect",{arcsize:n.corners}),{width:l,height:n.scale*n.width,left:n.scale*n.radius,top:-n.scale*n.width>>1,filter:c}),r("fill",{color:a(n.color,t),opacity:n.opacity}),r("stroke",{opacity:0}))))}var c,l=n.scale*(n.length+n.width),u=2*n.scale*l,h=-(n.width+n.length)*n.scale*2+"px",p=i(o(),{position:"absolute",top:h,left:h});if(n.shadow)for(c=1;c<=n.lines;c++)s(c,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(c=1;c<=n.lines;c++)s(c);return e(t,p)},s.prototype.opacity=function(t,e,r,n){var i=t.firstChild;n=n.shadow&&n.lines||0,i&&e+n0)return"!"+r.join()}return""},objectsDiff:Si,forInRecursive:function(t,e){function r(t,n){vl.forIn(t,function(t,i){var o=n+(n.length>0?".":"");t instanceof Object?r(t,o+i):void 0!==t&&e(t,o+i)})}r(t,"")},enquoteString:function(t){return vl.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(Mi(t),e);else if("undefined"!=typeof document){var r=document.createElement("a");r.download=e,r.innerHTML="download",r.href=window.URL.createObjectURL(Mi(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"}},fp.deriveClass(Ci,fi),Ci.prototype.cancel=function(){this._cancellationRequested=!0,this.dispatchEvent("cancel")},Ci.prototype.isCancellationRequested=function(){return this._cancellationRequested},Ci.prototype.notify=function(t){this.dispatchEvent({type:"notification",slaveEvent:t})};var mp={modes:{BS:{atom:.23,bond:.15,space:.5,multibond:!0,aromrad:.1,showarom:!0,polyComplexity:{poor:2,low:4,medium:6,high:12,ultra:32}},VW:{polyComplexity:{poor:4,low:6,medium:8,high:16,ultra:32}},LN:{multibond:!0,showarom:!0,offsarom:.2,chunkarom:10,atom:.23,lineWidth:2},LC:{bond:.2,space:0,multibond:!0,aromrad:.1,showarom:!0,polyComplexity:{poor:3,low:4,medium:6,high:12,ultra:32}},SA:{zClip:!1,probeRadius:1.5,subset:"",wireframe:!1,polyComplexity:{poor:6,low:8,medium:16,high:30,ultra:60}},SE:{zClip:!1,probeRadius:1.5,subset:"",wireframe:!1,polyComplexity:{poor:6,low:8,medium:16,high:30,ultra:60}},QS:{isoValue:.5,gaussLim:{poor:1.5,low:2,medium:2.5,high:3,ultra:4},scale:1,wireframe:!1,gridSpacing:{poor:2,low:1.5,medium:1,high:.5,ultra:.25},subset:"",zClip:!1},CS:{probeRadius:1.4,isoValue:1.5,wireframe:!1,probePositions:30,polyComplexity:{poor:.5,low:1,medium:1.5,high:1.75,ultra:2},subset:"",zClip:!1},TR:{radius:.3,polyComplexity:{poor:12,low:16,medium:32,high:64,ultra:64}},TU:{radius:.3,heightSegmentsRatio:1.5,tension:-.7,polyComplexity:{poor:5,low:6,medium:10,high:18,ultra:34}},CA:{radius:.3,depth:.25,ss:{helix:{width:1,arrow:2},strand:{width:1,arrow:2}},heightSegmentsRatio:1.5,tension:-.7,polyComplexity:{poor:5,low:6,medium:10,high:18,ultra:34}},TX:{template:"{{Chain}}.{{Residue}}{{Sequence}}.{{Name}}",horizontalAlign:"center",verticalAlign:"middle",dx:0,dy:0,dz:1,fg:"none",bg:"0x202020",showBg:!0}},colorers:{EL:{carbon:-1},UN:{color:16777215},CO:{subset:"charged",color:16711680,baseColor:16777215},SQ:{gradient:"rainbow"},TM:{gradient:"temp",min:5,max:40},OC:{gradient:"reds"},HY:{gradient:"blue-red"},MO:{gradient:"rainbow"}},labels:"no",antialias:!0,camFov:45,camNear:.5,camFar:100,camDistance:2.5,radiusToFit:1,fogNearFactor:.5,fogFarFactor:1,palette:"JM",resolution:"medium",autoResolution:!1,autoPreset:!0,preset:"default",presets:{default:[{mode:"BS",colorer:"EL",selector:"all",material:"SF"}],empty:[],wire:[{mode:"LN",colorer:"EL",selector:"all",material:"SF"}],small:[{mode:"BS",colorer:"EL",selector:"all",material:"SF"}],macro:[{mode:"CA",colorer:"SS",selector:"not hetatm",material:"SF"},{mode:"BS",colorer:"EL",selector:"hetatm and not water",material:"SF"}]},objects:{line:{color:4294967295,dashSize:.3,gapSize:.05}},theme:"dark",themes:{dark:2105376,light:13421772},draft:{clipPlane:!1,clipPlaneFactor:.5,clipPlaneSpeed:3e-5,waterBondingHack:!1},plugins:{},axes:!0,fog:!0,fps:!0,zSprites:!0,isoSurfaceFakeOpacity:!0,suspendRender:!0,nowater:!1,autobuild:!0,fxaa:!0,ao:!1,autoRotation:0,maxfps:30,fbxprec:4,autoRotationAxisFixed:!0,zooming:!0,panning:!1,inversePanning:!1,picking:!0,pick:"atom",editing:!1,aromatic:!1,singleUnit:!0,stereo:"NONE",interpolateViews:!0,transparency:"prepass",translationSpeed:2,debug:{example:3.5,text:"hello!",good:!0,ssaoKernelRadius:.7,ssaoFactor:.7,stereoBarrel:.25},use:{multiFile:!1}};Ti.prototype={constructor:Ti,defaults:mp,set:function(t,e){vl.set(this.now,t,e),this._changed[t]=!0},get:function(t,e){return vl.get(this.now,t,e)},reset:function(){this.now=vl.cloneDeep(mp),this.old=null,this._changed={}},checkpoint:function(){this.old=vl.cloneDeep(this.now),this._changed={}},undo:function(){this.now=vl.cloneDeep(this.old),this._changed={}},changed:function(){if(!this.old)return[];var t=this.old,e=this.now;return vl.filter(Object.keys(this._changed),function(r){return vl.get(t,r)!==vl.get(e,r)})},override:function(t){vl.merge(this.now,t)},applyDiffs:function(t){if(t.hasOwnProperty("VERSION")&&0!==t.VERSION)throw new Error("Settings version does not match!");this.reset(),vl.merge(this.now,t)},getDiffs:function(t){var e=fp.objectsDiff(this.now,mp);return t&&(e.VERSION=0),e},setPluginOpts:function(t,e){mp.plugins[t]=vl.cloneDeep(e),this.now.plugins[t]=vl.cloneDeep(e)}};var gp=new Ti,vp="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},yp=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},_p=function(){function t(t,e){for(var r=0;r0?fp.deriveDeep(e.reps[Sp-1],!0):fp.deriveDeep(gp.defaults.presets.default[0],!0))},s:"select",select:function(t,e){Ii(e,"selector",t)},m:"mode",mode:function(t,e){Ii(e,"mode",Oi(t,gp.defaults.modes))},c:"color",color:function(t,e){Ii(e,"colorer",Oi(t,gp.defaults.colorers))},mt:"material",material:function(t,e){Ii(e,"material",Oi(t,gp.defaults.materials))},dup:function(t,e){Ni(e);var r=e.reps,n=r[Sp];++Sp>=r.length&&(r[Sp]=fp.deriveDeep(n,!0))},ar:"autoResolution",background:"theme"},Ip={fromURL:function(t){return Di(fp.getUrlParameters(t))},fromAttr:function(t){return Di(fp.getUrlParameters("?"+(t||"")))},adapters:Mp,toURL:function(t){function e(t,e){null!==e&&void 0!==e&&(r[n++]=Li(t)+Ap+Li(e))}var r=[],n=0;e("l",t.load),e("u",t.unit),e("p",t.preset),function(t){if(t)for(var r=0,n=t.length;r0&&(i+="?"+r.join("&")),i},toScript:function(t){function e(t,e){null!==e&&void 0!==e&&(r[n++]=t+" "+e)}var r=[],n=0;return e("set","autobuild false"),e("load",t.load),e("unit",t.unit),e("preset",t.preset),function(t){if(t)for(var r=0,n=t.length;r0?t.getString():this.element.name.trim()},Hi.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}},Hi.prototype.getAtomBondsCount=function(){for(var t=this.getBonds(),e=0,r=0;r=t){r=e[n];break}return r},Hi.prototype.getCharge=function(){return this._charge},Hi.prototype.getLocation=function(){return this._location},Hi.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 Op={UNKNOWN:0,COVALENT:1,AROMATIC:2};Yi.BondType=Op,Yi.prototype.BondType=Op,Yi.prototype.getLeft=function(){return this._left},Yi.prototype.getRight=function(){return this._right},Yi.prototype.getOrder=function(){return this._order},Yi.prototype.calcLength=function(){return this._left._position.distanceTo(this._right._position)},Yi.prototype._forEachNeighbour=function(t,e){for(var r=t._bonds,n=0,i=r.length;n0?++o:++a}function i(t){"C"===t.element.name&&n(t)}for(var o=0,a=0,s=t.clone(),c=[[this.forEachLevelOne,i],[this.forEachLevelOne,n],[this.forEachLevelTwo,i],[this.forEachLevelTwo,n]],l=0;lo)return e.multiplyScalar(-1);if(ar._bonds.length&&(n=r,i=e);for(var o=n,a=0,s=i._bonds,c=0,l=s.length;ca&&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)},qi.prototype.getName=function(){return this._name},qi.StandardTypes={ALA:new qi("ALA","Alanine","A"),ARG:new qi("ARG","Arginine","R"),ASN:new qi("ASN","Asparagine","N"),ASP:new qi("ASP","Aspartic Acid","D"),CYS:new qi("CYS","Cysteine","C"),GLN:new qi("GLN","Glutamine","Q"),GLU:new qi("GLU","Glutamic Acid","E"),GLY:new qi("GLY","Glycine","G"),HIS:new qi("HIS","Histidine","H"),ILE:new qi("ILE","Isoleucine","I"),LEU:new qi("LEU","Leucine","L"),LYS:new qi("LYS","Lysine","K"),MET:new qi("MET","Methionine","M"),PHE:new qi("PHE","Phenylalanine","F"),PRO:new qi("PRO","Proline","P"),PYL:new qi("PYL","Pyrrolysine","O"),SEC:new qi("SEC","Selenocysteine","U"),SER:new qi("SER","Serine","S"),THR:new qi("THR","Threonine","T"),TRP:new qi("TRP","Tryptophan","W"),TYR:new qi("TYR","Tyrosine","Y"),VAL:new qi("VAL","Valine","V"),A:new qi("A","Adenine","A"),C:new qi("C","Cytosine","C"),G:new qi("G","Guanine","G"),I:new qi("I","Inosine","I"),T:new qi("T","Thymine","T"),U:new qi("U","Uracil","U"),DA:new qi("DA","Adenine","A"),DC:new qi("DC","Cytosine","C"),DG:new qi("DG","Guanine","G"),DI:new qi("DI","Inosine","I"),DT:new qi("DT","Thymine","T"),DU:new qi("DU","Uracil","U"),"+A":new qi("+A","Adenine","A"),"+C":new qi("+C","Cytosine","C"),"+G":new qi("+G","Guanine","G"),"+I":new qi("+I","Inosine","I"),"+T":new qi("+T","Thymine","T"),"+U":new qi("+U","Uracil","U"),WAT:new qi("WAT","Water",""),H2O:new qi("H2O","Water",""),HOH:new qi("HOH","Water",""),DOD:new qi("DOD","Water",""),UNK:new qi("UNK","Unknown",""),UNL:new qi("UNL","Unknown Ligand","")};var Dp=qi.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};$i(Dp.WATER,["WAT","H2O","HOH","DOD"]),$i(Dp.PROTEIN,["ALA","ARG","ASN","ASP","CYS","GLY","GLU","GLN","HIS","ILE","LEU","LYS","MET","PHE","PRO","PYL","SEC","SER","THR","TRP","TYR","VAL"]),$i(Dp.BASIC,["ARG","HIS","LYS"]),$i(Dp.ACIDIC,["ASP","GLU"]),$i(Dp.POLAR,["ASN","CYS","GLN","SER","THR","TYR"]),$i(Dp.NONPOLAR,["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL","GLY"]),$i(Dp.AROMATIC,["PHE","TRP","TYR"]),$i(Dp.NUCLEIC,["A","G","I","DA","DG","DI","+A","+G","+I","C","T","U","DC","DT","DU","+C","+T","+U"]),$i(Dp.PURINE,["A","G","I","DA","DG","DI","+A","+G","+I"]),$i(Dp.PYRIMIDINE,["C","T","U","DC","DT","DU","+C","+T","+U"]),$i(Dp.DNA,["DA","DG","DI","DC","DT","DU"]),$i(Dp.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},Zi.prototype._innerFinalize=function(t,e,r,n,i){var o=null===e,a=i(this._leadAtom),s=new l(a.x,a.y,a.z);if(0==(this._type.flags&qi.Flags.NUCLEIC)){if(o)n._midPoint=i(this._firstAtom).clone();else{var c=e._controlPoint;n._midPoint=c.clone().lerp(s,.5),n._wingVector=this.calcWing(c,s,i(t._wingAtom),e._wingVector)}n._controlPoint=s}else this._detectLeadWing(n,r,i)},Zi.prototype._finalize2=function(t,e){this._innerFinalize(t,t,e,this,function(t){return t._position})},Zi.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 l(a.x,a.y,a.z)}else t.length>0&&(t[0]._wingVector=new l(1,0,0))},Ki.prototype.updateToFrame=function(t){function e(e){return t.getAtomPos(e._index)}for(var r=this._residues,n=null,i=null,o=t._residues,a=r.length,s=0;s1?o[r[1]._index]._wingVector:new l(1,0,0)},Ki.prototype.addResidue=function(t,e,r){var n=this._complex.getResidueType(t);null===n&&(n=this._complex.addResidueType(t));var i=new Zi(this,n,e,r);return this._complex.addResidue(i),this._residues.push(i),n.flags&(qi.Flags.NUCLEIC|qi.Flags.PROTEIN)&&(this.maxSequencee&&(this.minSequence=e)),i},Ki.prototype.getResidueCount=function(){return this._residues.length},Ki.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 Vp={},jp=Object.freeze({default:Vp}),Gp=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,Wp=function(t){return Gp.exec(t).slice(1)},Hp={extname:uo,basename:lo,dirname:co,sep:"/",delimiter:":",relative:so,join:ao,isAbsolute:oo,normalize:io,resolve:no},Xp="b"==="ab".substr(-1)?function(t,e,r){return t.substr(e,r)}:function(t,e,r){return e<0&&(e=t.length+e),t.substr(e,r)},Yp=Object.freeze({resolve:no,normalize:io,isAbsolute:oo,join:ao,relative:so,sep:"/",delimiter:":",dirname:co,basename:lo,extname:uo,default:Hp}),qp=jp&&Vp||jp,$p=Yp&&Hp||Yp,Zp=e(function(e,r){var n=function(){function t(){this.yy={}}var e=function(t,e,r,n){for(r=r||{},n=t.length;n--;r[t[n]]=e);return r},r=[1,4],n=[1,5],i=[1,6],o=[1,7],a=[1,8],s=[1,9],c=[1,11],l=[1,12],u=[5,7,8,11],h=[1,17],p=[1,22],f=[1,20],d=[1,21],m=[5,7,8,11,19],g={trace:function(){},yy:{},symbols_:{error:2,Program:3,Expression:4,EOF:5,Selector:6,OR:7,AND:8,NOT:9,"(":10,")":11,SELECTOR:12,NAMED_SELECTOR:13,SELECTOR_RANGED:14,RangeList:15,SELECTOR_NAMED:16,NameList:17,Range:18,",":19,NUMBER:20,":":21,Name:22,IDENTIFIER:23,STRING:24,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",7:"OR",8:"AND",9:"NOT",10:"(",11:")",12:"SELECTOR",13:"NAMED_SELECTOR",14:"SELECTOR_RANGED",16:"SELECTOR_NAMED",19:",",20:"NUMBER",21:":",23:"IDENTIFIER",24:"STRING"},productions_:[0,[3,2],[4,1],[4,3],[4,3],[4,2],[4,3],[6,1],[6,1],[6,2],[6,2],[15,1],[15,3],[18,1],[18,3],[17,1],[17,3],[22,1],[22,1],[22,1]],performAction:function(t,e,r,n,i,o,a){var s=o.length-1;switch(i){case 1:return o[s-1];case 3:this.$=n.keyword("or")(o[s-2],o[s]);break;case 4:this.$=n.keyword("and")(o[s-2],o[s]);break;case 5:this.$=n.keyword("not")(o[s]);break;case 6:this.$=o[s-1];break;case 7:this.$=n.keyword(o[s])();break;case 8:this.$=n.GetSelector(o[s].toLowerCase().slice(1,o[s].length));break;case 9:case 10:this.$=n.keyword(o[s-1])(o[s]);break;case 11:this.$=new n.RangeList(o[s]);break;case 12:case 16:this.$=o[s-2].append(o[s]);break;case 13:this.$=new n.Range(Number(o[s]));break;case 14:this.$=new n.Range(Number(o[s-2]),Number(o[s]));break;case 15:this.$=new n.ValueList(o[s])}},table:[{3:1,4:2,6:3,9:r,10:n,12:i,13:o,14:a,16:s},{1:[3]},{5:[1,10],7:c,8:l},e(u,[2,2]),{4:13,6:3,9:r,10:n,12:i,13:o,14:a,16:s},{4:14,6:3,9:r,10:n,12:i,13:o,14:a,16:s},e(u,[2,7]),e(u,[2,8]),{15:15,18:16,20:h},{17:18,20:p,22:19,23:f,24:d},{1:[2,1]},{4:23,6:3,9:r,10:n,12:i,13:o,14:a,16:s},{4:24,6:3,9:r,10:n,12:i,13:o,14:a,16:s},e(u,[2,5]),{7:c,8:l,11:[1,25]},e(u,[2,9],{19:[1,26]}),e(m,[2,11]),e(m,[2,13],{21:[1,27]}),e(u,[2,10],{19:[1,28]}),e(m,[2,15]),e(m,[2,17]),e(m,[2,18]),e(m,[2,19]),e([5,7,11],[2,3],{8:l}),e(u,[2,4]),e(u,[2,6]),{18:29,20:h},{20:[1,30]},{20:p,22:31,23:f,24:d},e(m,[2,12]),e(m,[2,14]),e(m,[2,16])],defaultActions:{10:[2,1]},parseError:function(t,e){if(!e.recoverable){var r=function(t,e){this.message=t,this.hash=e};throw r.prototype=Error,new r(t,e)}this.trace(t)},parse:function(t){function e(){var t;return"number"!=typeof(t=i.pop()||f.lex()||h)&&(t instanceof Array&&(t=(i=t).pop()),t=r.symbols_[t]||t),t}var r=this,n=[0],i=[],o=[null],a=[],s=this.table,c="",l=0,u=0,h=1,p=a.slice.call(arguments,1),f=Object.create(this.lexer),d={yy:{}};for(var m in this.yy)Object.prototype.hasOwnProperty.call(this.yy,m)&&(d.yy[m]=this.yy[m]);f.setInput(t,d.yy),d.yy.lexer=f,d.yy.parser=this,void 0===f.yylloc&&(f.yylloc={});var g=f.yylloc;a.push(g);var v=f.options&&f.options.ranges;"function"==typeof d.yy.parseError?this.parseError=d.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var y,_,x,b,w,S,M,A,E,C={};;){if(x=n[n.length-1],this.defaultActions[x]?b=this.defaultActions[x]:(null!==y&&void 0!==y||(y=e()),b=s[x]&&s[x][y]),void 0===b||!b.length||!b[0]){var T="";E=[];for(S in s[x])this.terminals_[S]&&S>2&&E.push("'"+this.terminals_[S]+"'");T=f.showPosition?"Parse error on line "+(l+1)+":\n"+f.showPosition()+"\nExpecting "+E.join(", ")+", got '"+(this.terminals_[y]||y)+"'":"Parse error on line "+(l+1)+": Unexpected "+(y==h?"end of input":"'"+(this.terminals_[y]||y)+"'"),this.parseError(T,{text:f.match,token:this.terminals_[y]||y,line:f.yylineno,loc:g,expected:E})}if(b[0]instanceof Array&&b.length>1)throw new Error("Parse Error: multiple actions possible at state: "+x+", token: "+y);switch(b[0]){case 1:n.push(y),o.push(f.yytext),a.push(f.yylloc),n.push(b[1]),y=null,_?(y=_,_=null):(u=f.yyleng,c=f.yytext,l=f.yylineno,g=f.yylloc);break;case 2:if(M=this.productions_[b[1]][1],C.$=o[o.length-M],C._$={first_line:a[a.length-(M||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(M||1)].first_column,last_column:a[a.length-1].last_column},v&&(C._$.range=[a[a.length-(M||1)].range[0],a[a.length-1].range[1]]),void 0!==(w=this.performAction.apply(C,[c,u,l,d.yy,b[1],o,a].concat(p))))return w;M&&(n=n.slice(0,-1*M*2),o=o.slice(0,-1*M),a=a.slice(0,-1*M)),n.push(this.productions_[b[1]][0]),o.push(C.$),a.push(C._$),A=s[n[n.length-2]][n[n.length-1]],n.push(A);break;case 3:return!0}}return!0}},v={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];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;return 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;this._input||(this.done=!0);var t,e,r,n;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}}};return g.lexer=v,t.prototype=g,g.Parser=t,new t}();void 0!==t&&(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=qp.readFileSync($p.normalize(t[1]),"utf8");return r.parser.parse(e)},t.main===e&&r.main(process.argv.slice(1)))}),Kp=Zp.parser,Qp=(Zp.Parser,Zp.parse,Zp.main,{}),Jp=function(){function t(e,r){yp(this,t),this.min=e,this.max=void 0===r?e:r}return _p(t,[{key:"includes",value:function(t){return this.min<=t&&t<=this.max}},{key:"toString",value:function(){var t=this.min,e=this.max;return t===e?String(t):[t,e].join(":")}},{key:"toJSON",value:function(){return[this.min,this.max]}}]),t}(),tf=function(){function t(e){if(yp(this,t),e instanceof this.constructor)return e;e instanceof Array?this._values=e.slice(0):this._values=e?[e]:[]}return _p(t,[{key:"append",value:function(t){var e=this._values;return e[e.length]=t,this}},{key:"remove",value:function(t){var e=this._values,r=e.indexOf(t);return r>=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}();uf.prototype.priority=1;var hf=function(t){function e(t,r){yp(this,e);var n=bp(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.lhs=t||lf,n.rhs=r||lf,n}return xp(e,of),_p(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}();hf.prototype.priority=1e3,mo("Not",1,function(t){function e(){return yp(this,e),bp(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return xp(e,uf),_p(e,[{key:"includesAtom",value:function(t){return!this.rhs.includesAtom(t)}}]),e}()),mo("And",2,function(t){function e(){return yp(this,e),bp(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return xp(e,hf),_p(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)&&this.rhs.includesAtom(t)}}]),e}()),mo("Or",3,function(t){function e(){return yp(this,e),bp(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return xp(e,hf),_p(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)||this.rhs.includesAtom(t)}}]),e}());var pf=Object.create(Qp);pf.Selector=of,pf.RangeListSelector=sf,pf.ValueListSelector=cf,pf.Range=Jp,pf.RangeList=ef,pf.ValueList=nf,pf.PrefixOperator=uf,pf.InfixOperator=hf,pf.Context=Object.create({}),pf.GetSelector=function(t){if(!pf.Context.hasOwnProperty(t)){throw{message:"selector "+t+" is not registered"}}return pf.Context[t]||lf},pf.ClearContext=function(){Object.keys(pf.Context).forEach(function(t){delete pf.Context[t]})},pf.keyword=function(t){return Qp[t.toLowerCase()]||Qp.none},pf.parse=function(t){var e={};try{e.selector=Kp.parse(t)}catch(t){e.selector=lf,e.error=t.message}return e},Kp.yy=pf,Kp.yy.parseError=Kp.parseError,go.prototype.constructor=go,go.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 l(a,a,a))}else for(t=0;t0?this._selector=pf.keyword("Chain")(this.chains):this._selector=pf.keyword("None")()},yo.prototype.id="__",_o.prototype.getResidues=function(){return this._complex._residues},_o.prototype.getResidueCount=function(){return this._residueCount},_o.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&df-1)*ff,a=0;a=ff)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*mf,this.intBuffer[o]=r,this.intBuffer[o+1]=n,this.intBuffer[o+2]=i,this.numPairs++};So.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*c+w*i+M],E=0;EN*N||L<.001||this._pairCollection.addPair(u,C)}}}}}}}}},So.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)&&t.dot(e)>=0}}();Co.prototype.update=function(){for(var t=this.atoms,e=new l,r=t.length,n=0;ni[c]?++c:++s}return!1},No.prototype._tryBond=function(t,e,r){var n=[],i=this._bondsData,o=Ao(t,e),a=e._position.clone().sub(o._position),s=this._currStart,c=this,l=this._bondMarks,u=this._checkBond;l[t._index]=!0,u=void 0===u?To:u,e.forEachBond(function(o){if(u(o)&&o!==t&&!l[o._index]&&!c._haveSameCycle(i,t,o)){var h=Ao(o,e),p=h._position.clone().sub(e._position),f=h===s?-2:1-function(t,e){var r=t.dot(e)/Math.sqrt(t.lengthSq()*e.lengthSq());return xh.clamp(r,-1,1)}(a,p),d=p.cross(a);if(_f(d,r)){for(var m=0;ms?1:0},Io.prototype._atomNameCompareCWithH=function(t,e){return this._atomNameCompare(t,e,2)},Io.prototype._atomNameCompareCWithoutH=function(t,e){return this._atomNameCompare(t,e,254)},Io.prototype._buildFormulaSimple=function(t,e){var r=t.atoms,n=null,i={},o="",a=this,s=Wi.ByName.H.name,c=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),c+=t.getCharge()});var l=Object.keys(i);return i.C?l.sort(this._atomNameCompareCWithH.bind(this)):l.sort(function(t,e){return a._atomNameCompare(t,e,"H".charCodeAt(0))}),l.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!==c&&(l.length>1&&(o="("+o+")"),c>1&&(o+="^{"+c.toString()+"+}"),1===c&&(o+="^+"),c<-1&&(o+="^{"+Math.abs(c).toString()+"-}"),-1===c&&(o+="^-")),t.repeatCount>1&&(o=t.repeatCount.toString(10)+o)):e(l.length,c),o},Io.prototype._buildPartFormula=function(t){return t.owner instanceof Io||t.owner instanceof _o?this._buildFormulaSimple(t,null):t.owner instanceof eo?t.owner.buildChemicalFormula(this,t):""},Io.prototype._partCompareFunc=function(t,e){return this._partCompareFuncInt(t,e,!0)},Io.prototype._getCumulativeCharge=function(t){for(var e=t.length,r=0,n=0;n0&&(r[a]?r[a]+=n:r[a]=n)}});var n=Object.keys(r);return n.sort(o._atomNameCompareCWithoutH.bind(o)),{seq:n,data:r}}for(var i,o=this,a=Wi.ByName.H.name,s=[r,!1],c=0;cWi.ByName.MT.number)return"}\\text{Could not create chemical formula for this structure.}{"}return""},Io.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()]&&up.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,c=t.length-2;s>=0&&c>=0;){var l=t[s],u=t[c];l.owner instanceof Io||l.owner instanceof _o?u.owner instanceof Io||u.owner instanceof _o?(0===this._partCompareFuncInt(u,l,!1)&&(u.repeatCount+=l.repeatCount,t.splice(s,1)),c--,s--):c--:--s===c&&c--}return t.forEach(function(t){var e=o._buildPartFormula(t);e.length>0&&(a.length>0&&(a+="*"),a+=e)}),a},Io.prototype.getUnifiedSerial=function(t,e,r){return e+65536*r+16777216*t},Io.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}},Io.prototype._fillCmpEdit=function(){function t(){var t=new _o(e);return t._index=r.length,r[t._index]=t,t}var e=this,r=this._components;this.forEachChain(function(e){var r=e._residues,n=r.length;if(!(n<1))for(var i=t(),o=r[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},Oo.prototype.computeGradient=function(){function t(t,e,r){return Math.min(r,Math.max(e,t))}function e(t,e,r){return c[r*o*a+e*o+t]}if(1!==this._dimVec)return null;for(var r=new Oo(Float32Array,[this._dimX,this._dimY,this._dimZ],this._box,3),n=this.getCellSize(),i=new l(-.5/n.x,-.5/n.y,-.5/n.z),o=this._dimX,a=this._dimY,s=this._dimZ,c=this._data,u=0;u=0;r=this._atoms[r+1])e(this._atoms[r])},ko.prototype._forEachVoxelWithinRadius=function(t,e,r){var i,o,a,s,c,l,u,h,p=new n,f=new n,d=new n;d.set(t.z-e,t.z+e),d.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor().clampScalar(0,this._count.z-1);for(var m=d.x;m<=d.y;++m){c=[this._box.min.z+m*this._cellSize.z,this._box.min.z+(m+1)*this._cellSize.z],h=t.z-e<=c[0]&&c[1]<=t.z+e,i=Fo(t,e,c[0],c[1]),f.set(t.y-i[1],t.y+i[1]),f.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor().clampScalar(0,this._count.y-1);for(var g=f.x;g<=f.y;++g){s=[this._box.min.y+g*this._cellSize.y,this._box.min.y+(g+1)*this._cellSize.y],u=t.y-i[0]<=s[0]&&s[1]<=t.y+i[0],o=zo(t,i[1],s[0],s[1]),p.set(t.x-o[1],t.x+o[1]),p.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor().clampScalar(0,this._count.x-1);for(var v=p.x;v<=p.y;++v)a=[this._box.min.x+v*this._cellSize.x,this._box.min.x+(v+1)*this._cellSize.x],l=t.x-o[0]<=a[0]&&a[1]<=t.x+o[0],r(v+this._count.x*(g+this._count.y*m),l&&u&&h)}}},ko.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;s=a[s+1])if(t._position.distanceToSquared(a[s]._position)=1?this.fov=t:this.fov=xh.radToDeg(2*Math.atan(Math.tan(.5*xh.degToRad(t))/this.aspect))},ft.prototype.setDistanceToFit=function(t,e){this.position.z=t/Math.sin(.5*xh.degToRad(e))},vt.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 It(2,2,t,e),o=i.getAttribute("position"),a=0;a65535,s=i*e,c=this._index=fp.allocateTyped(a?Uint32Array:Uint16Array,s);this._positions=fp.allocateTyped(Float32Array,3*o),this._normals=fp.allocateTyped(Float32Array,3*o),this._colors=fp.allocateTyped(Float32Array,3*o);var l=this._alpha=fp.allocateTyped(Float32Array,o);vl.fill(l,1);for(var u=0;u65535;this._index=fp.allocateTyped(r?Uint32Array:Uint16Array,6*t),this._positions=fp.allocateTyped(Float32Array,4*e),this._colors=fp.allocateTyped(Float32Array,3*e),this._directions=fp.allocateTyped(Float32Array,3*e);var n=this._alpha=fp.allocateTyped(Float32Array,e);vl.fill(n,1);for(var i=this._index,o=0,a=0,s=0;s117440512)throw new Error("Too large cube dimension: lead to memory huge uasge");return this.pointsValuesLinear=fp.allocateTyped(Float32Array,32*e),this.hasIntersection=fp.allocateTyped(Int32Array,e),this.bitsInside=fp.allocateTyped(Int32Array,e),0},ga.prototype.destroy=function(){this.bitsInside=null,this.hasIntersection=null,this.pointsValuesLinear=null},ga.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 sd=[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];ya.prototype.constructor=ya,_a.prototype.constructor=_a,xa.prototype.constructor=xa,xa.prototype._prepareAxesAndDirs=function(){var t=this._volumetricData.getCellSize(),e=this._xAxis,r=this._yAxis,n=this._zAxis,i=this._xDir,o=this._yDir,a=this._zDir;e.set(t.x,0,0),r.set(0,t.y,0),n.set(0,0,t.z),i.set(1,0,0),o.set(0,1,0),a.set(0,0,1);var s=new l;return s.crossVectors(i,o),s.dot(a)<0&&(i.negate(),o.negate(),a.negate()),!(i.x<0||i.y<0||i.z<0||o.x<0||o.y<0||o.z<0||a.x<0||a.y<0||a.z<0)&&!(0!==e.y||0!==e.z||0!==r.x||0!==r.z||0!==n.x||0!==n.y)},xa.prototype._vertexInterp=function(t,e,r,n,i,o){var a=e.p[r],s=e.p[n],c=e.g[r],l=e.g[n],u=e.val[r],h=t-u,p=e.val[n]-u,f=0;Math.abs(p)>0&&(f=h/p),f=f>1?1:f,i.lerpVectors(a,s,f),o.lerpVectors(c,l,f)},xa.prototype._polygonize=function(){for(var t=ga.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 l,i[o]=new l;return function(a,s,c){var l=a.cubeIndex;for(o=0;o<12;++o)sd[l]&1<s?s:l+e,h=-1,p=l;pV&&(j=G,V=C[G]);if(j<0||!n.includesAtom(E[j])){P[a]=-1;continue}}P[a]=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))}},xa.prototype.toMesh=function(){var t=new Pt;return t.setIndex(new vt(this._indices,1)),t.addAttribute("position",new vt(this._position,3)),t.addAttribute("normal",new vt(this._normals,3)),t.addAttribute("color",new vt(this._colors,3)),t.computeBoundingSphere(),t},(ba.prototype=Object.create(ma.prototype)).constructor=ba,ba.prototype._build=function(){var t=this._opts;this.numVoxels=[128,128,128],this.xAxis=new l(1,0,0),this.yAxis=new l(0,1,0),this.zAxis=new l(0,0,1),this.origin=new l(0,0,0),this._visibilitySelector=t.visibilitySelector,this._calcSurface(t)},ba.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 c=0;c<3;++c)i[c]-=a,o[c]+=a;for(c=0;c<3;++c)r[c]=Math.ceil((o[c]-i[c])/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}},ba.prototype._makeSurface=function(t,e){var r=new xa;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 vt(r._indices,1)),this.addAttribute("position",new vt(r._position,3)),this.addAttribute("normal",new vt(r._normals,3)),this.addAttribute("color",new vt(r._colors,3)))},ba.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 et(this.origin,new l(this.xAxis.x,this.yAxis.y,this.zAxis.z).add(this.origin)),i=this._computeSurface(e,n,r,t);this._makeSurface(i,t)}};var cd=xf.Volume;(wa.prototype=Object.create(ba.prototype)).constructor=wa,wa.prototype._computeSurface=function(t,e,r,n){this._shiftByOrigin(t.posRad);var i={volMap:new cd(Float32Array,this.numVoxels,e),volTexMap:new cd(Float32Array,this.numVoxels,e,3)};return null!=this._visibilitySelector&&(i.atomMap=[],i.atomWeightMap=new cd(Float32Array,this.numVoxels,e)),this.gaussdensity(i,t,null,n),i},wa.prototype.gaussdensity=function(t,e,r,n){var i,o=e.posRad.length/4,a=e.posRad,s=e.colors,c=this.numVoxels,l=n.radScale,u=n.gaussLim,h=n.gridSpacing,p=1/n.isoValue,f=1/h,d=c[0]-1,m=c[1]-1,g=c[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 $=3*M;b[W]+=q*s[$],b[W+1]+=q*s[$+1],b[W+2]+=q*s[$+2]}}}},wa.prototype._shiftByOrigin=function(t){for(var e=this.origin.x,r=this.origin.y,n=this.origin.z,i=t.length/4,o=0;ol?e:l,u+=e;var h=Math.floor(s/l);h<2&&(h=2),u/=r,this._numCells=h,this._aveRad=u,this._maxRad=l;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(c=0;c=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]])}},Ea.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),l+=e*f,u+=r*f,h+=d*f,o++}},y=0;y0&&(p=1/Math.sqrt(n),l*=p,u*=p,h*=p),r[y].x=l,r[y].y=u,r[y].z=h;return 0},Ea.prototype.buildColors=function(t,e,r,n){for(var i=this,o=0,a=0,s=0,c=0,l=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;(c=d-m*m)<0&&(c=-c),l=1/(.8+c),h.push([t.colorX,t.colorY,t.colorZ]),p.push(l),f+=l}},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 X(e.getAtomColor(t,this.atoms[D]));if(0===this.colorMode&&(c=this.atomColors[D].x,l=this.atomColors[D].y,u=this.atomColors[D].z),1===this.colorMode){var z=this.complex.monomerTypeArray[h].color;c=z.r,l=z.g,u=z.b}1!==this.colorMode&&0!==this.colorMode&&(c=this.atomColors[D].x,l=this.atomColors[D].y,u=this.atomColors[D].z),F.set(E,C,T),s[x]=new Aa(F,L),s[x].colorX=c,s[x].colorY=l,s[x].colorZ=u,x++}return this.voxelsRefs=null,this.voxels=null,s},Ta.prototype.destroy=function(){this._vertices=null,this._normals=null,this._indices=null};var ud=xf.Element;(Pa.prototype=Object.create(ma.prototype)).constructor=Pa,Pa.prototype._build=function(){this._innerBuild();var t=this.getGeo();this.destroy(),this._fromGeo(t)},Pa.prototype._fromGeo=function(t){var e=null,r=fp.allocateTyped(Float32Array,3*t._numVertices),n=fp.allocateTyped(Float32Array,3*t._numVertices);null!==t._colors&&(e=fp.allocateTyped(Float32Array,3*t._numVertices));var i,o=fp.allocateTyped(Uint32Array,3*t._numTriangles),a=0;for(i=0;ii?c:i,s.x-cr.x&&(r.x=s.x+c),s.y+c>r.y&&(r.y=s.y+c),s.z+c>r.z&&(r.z=s.z+c)}e.x-=i,e.y-=i,e.z-=i,r.x+=i,r.y+=i,r.z+=i},Pa.prototype.getCornerCoord=function(t,e,r,n,i,o,a){var s=1/(o-1),c=r*s,l=n*s,u=i*s;a.x=t.x*(1-c)+e.x*c,a.y=t.y*(1-l)+e.y*l,a.z=t.z*(1-u)+e.z*u},Pa.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],c=n.pointsValuesLinear[i+3*t+1],l=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=c*(1-a)+h*a,o.z=l*(1-a)+p*a}},Pa.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))},Pa.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},Pa.prototype.buildGeoFromCorners=function(t,e,r,n,i,o){var a,s,c=t-1,u=t,h=t*t,p=new Array(12);for(a=0;a<12;a++)p[a]=new l;var f=[];for(a=0;a<8;a++)f[a]=1;for(var d=new l,m=0,g=0,v=0;ve.length/2||2*Object.keys(ud.ByAtomicNumber).length!==e.length)throw new Error("atomT.length should be equal Element.ByAtomicNumber.length * 2");return e[2*t]},Pa.prototype.calculateGridCorners=function(t,e,r,n,i,o){for(var a=e*e,s=a*e,c=new l,u=new l,h=0;h=0;r=this.hashEntries[2*r+1]){var u=this.hashEntries[2*r+0];i.copy(t._vertices[u]),i.x-=e.x,i.y-=e.y,i.z-=e.z;if(i.x*i.x+i.y*i.y+i.z*i.z<1e-6)return u}if(t._numVertices>=this.maxNumVertices)return-1;var h=t._numVertices;if(t._vertices[h].copy(e),null!==this.vBoxMin&&null!==this.vBoxMax){if((r=this.getNewHashEntry())<0)return-1;var p=this.hashLines[c+1];this.hashLines[c+1]=r,this.hashEntries[2*r+0]=h,this.hashEntries[2*r+1]=p,this.hashLines[c+0]++}return t._numVertices++,h},Pa.prototype.modifyExcludedFromGeo=function(t,e,r,n,i,o){function a(){l>0?(o[s]<0&&(o[s]=l),l>o[s]&&(o[s]=l)):l>o[s]&&(o[s]=l)}for(var s,c,l,u=t*t,h=(t-1)/(n.x-r.x),p=(t-1)/(n.y-r.y),f=(t-1)/(n.z-r.z),d=2*e*(2*e),m=1/(t-1),g=0;g=0?_:0,x=x>=0?x:0,b=b>=0?b:0,w=w<=t-1?w:t-1,S=S<=t-1?S:t-1,M=M<=t-1?M:t-1;for(var A=x;A<=S;A++)for(var E=A*u,C=b;C<=M;C++)for(var T=C*t,P=_;P<=w;P++){s=E+T+P;var L=P*m,R=r.x*(1-L)+n.x*L;L=A*m;var N=r.y*(1-L)+n.y*L;L=C*m;var I=r.z*(1-L)+n.z*L,O=R-v.x,D=N-v.y,F=I-v.z,z=O*O+D*D+F*F;z=100&&(h=Math.floor(Math.pow(2*p,1/3))),u>h&&(u=h);var f=this.probeRadius*this.atomRadiusScale,d=null,m=null;this.clusterizationType>0?(d=new Ca(this.complex,this.atoms,r,n,i,u,this.colorMode),m=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(c,a,n,i,m,f)):this.calculateGridCorners(c,a,n,i,r,f);var g=o-1,v=new ga;if((t=v.create(g))<0)return t;var y=new l;y.x=(i.x-n.x)/g,y.y=(i.y-n.y)/g,y.z=(i.z-n.z)/g;var _=this.getNumIntersectedCells(a,g,c,v),x=Math.floor(1.2*_),b=Math.floor(1.2*_*2);if(this.geoOut=new Ta(x,b,this.useVertexColors),(t=this.createVertexHash(x,b))<0)return t;var w=f;if(this.excludeProbe&&(w=.01),this.voxelWorld=null,this.clusterizationType>0?this.voxelWorld=new Ea(m.length,m,n,i,w):this.voxelWorld=new Ea(r.length,r,n,i,w),this.voxelWorld.createVoxels(),t=this.buildGeoFromCorners(o,n,i,c,y,v),this.excludeProbe){if(this.modifyExcludedFromGeo(a,f,n,i,this.geoOut,c),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,_=this.getNumIntersectedCells(a,g,c,v),x=Math.floor(1.2*_),b=Math.floor(1.2*_*2),this.geoOut=new Ta(x,b,this.useVertexColors),(t=this.createVertexHash(x,b))<0)return t;t=this.buildGeoFromCorners(a,n,i,c,y,v)}if(null!==this.voxelWorld){this.voxelWorld.buildNormals(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._normals);var S=6.5;this.excludeProbe&&(S-=1.5),this.useVertexColors&&this.voxelWorld.buildColors(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._colors,S)}return this.voxelWorld.destroyVoxels(),this.voxelWorld=null,null!==d&&d.destroy(),v.destroy(),t},(La.prototype=Object.create(fi.prototype)).constructor=La,La.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,n=this.geometry.userData,i=r.length;for(e=0;e>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)}},yd={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()}},_d=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(),yd.hasOwnProperty(r)?yd[r](t):"null"})};(qa.prototype=Object.create(ja.prototype)).constructor=qa,qa.prototype._makeGeoArgs=function(t,e,r,n){var i=e.getLabelOpts();return[t.chunks.length,i]},qa.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>1)+"px"})}for(var l,u=0,h=(o.lines-1)*(1-o.direction)/2;u',r)}l.addRule(".spin-vml","behavior:url(#default#VML)"),s.prototype.lines=function(t,n){function o(){return i(r("group",{coordsize:u+" "+u,coordorigin:-l+" "+-l}),{width:u,height:u})}function s(t,s,c){e(p,e(i(o(),{rotation:360/n.lines*t+"deg",left:~~s}),e(i(r("roundrect",{arcsize:n.corners}),{width:l,height:n.scale*n.width,left:n.scale*n.radius,top:-n.scale*n.width>>1,filter:c}),r("fill",{color:a(n.color,t),opacity:n.opacity}),r("stroke",{opacity:0}))))}var c,l=n.scale*(n.length+n.width),u=2*n.scale*l,h=-(n.width+n.length)*n.scale*2+"px",p=i(o(),{position:"absolute",top:h,left:h});if(n.shadow)for(c=1;c<=n.lines;c++)s(c,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(c=1;c<=n.lines;c++)s(c);return e(t,p)},s.prototype.opacity=function(t,e,r,n){var i=t.firstChild;n=n.shadow&&n.lines||0,i&&e+n0)return"!"+r.join()}return""},objectsDiff:Si,forInRecursive:function(t,e){function r(t,n){Sl.forIn(t,function(t,i){var o=n+(n.length>0?".":"");t instanceof Object?r(t,o+i):void 0!==t&&e(t,o+i)})}r(t,"")},enquoteString:function(t){return Sl.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(Ai(t),e);else if("undefined"!=typeof document){var r=document.createElement("a");r.download=e,r.innerHTML="download",r.href=window.URL.createObjectURL(Ai(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 bp="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},wp=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},Sp=function(){function t(t,e){for(var r=0;r0?_p.deriveDeep(e.reps[Rp-1],!0):_p.deriveDeep(Lp.defaults.presets.default[0],!0))},s:"select",select:function(t,e){zi(e,"selector",t)},m:"mode",mode:function(t,e){zi(e,"mode",ki(t,Lp.defaults.modes))},c:"color",color:function(t,e){zi(e,"colorer",ki(t,Lp.defaults.colorers))},mt:"material",material:function(t,e){zi(e,"material",ki(t,Lp.defaults.materials))},dup:function(t,e){Fi(e);var r=e.reps,n=r[Rp];++Rp>=r.length&&(r[Rp]=_p.deriveDeep(n,!0))},ar:"autoResolution",background:"theme"},Vp={fromURL:function(t){return Ui(_p.getUrlParameters(t))},fromAttr:function(t){return Ui(_p.getUrlParameters("?"+(t||"")))},adapters:Np,toURL:function(t){function e(t,e){null!==e&&void 0!==e&&(r[n++]=Oi(t)+Ip+Oi(e))}var r=[],n=0;e("l",t.load),e("u",t.unit),e("p",t.preset),function(t){if(t)for(var r=0,n=t.length;r0&&(i+="?"+r.join("&")),i},toScript:function(t){function e(t,e){null!==e&&void 0!==e&&(r[n++]=t+" "+e)}var r=[],n=0;return e("set","autobuild false"),e("load",t.load),e("unit",t.unit),e("preset",t.preset),function(t){if(t)for(var r=0,n=t.length;r0?t.getString():this.element.name.trim()},Zi.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}},Zi.prototype.getAtomBondsCount=function(){for(var t=this.getBonds(),e=0,r=0;r=t){r=e[n];break}return r},Zi.prototype.getCharge=function(){return this._charge},Zi.prototype.getLocation=function(){return this._location},Zi.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 jp={UNKNOWN:0,COVALENT:1,AROMATIC:2};Qi.BondType=jp,Qi.prototype.BondType=jp,Qi.prototype.getLeft=function(){return this._left},Qi.prototype.getRight=function(){return this._right},Qi.prototype.getOrder=function(){return this._order},Qi.prototype.calcLength=function(){return this._left._position.distanceTo(this._right._position)},Qi.prototype._forEachNeighbour=function(t,e){for(var r=t._bonds,n=0,i=r.length;n0?++o:++a}function i(t){"C"===t.element.name&&n(t)}for(var o=0,a=0,s=t.clone(),c=[[this.forEachLevelOne,i],[this.forEachLevelOne,n],[this.forEachLevelTwo,i],[this.forEachLevelTwo,n]],l=0;lo)return e.multiplyScalar(-1);if(ar._bonds.length&&(n=r,i=e);for(var o=n,a=0,s=i._bonds,c=0,l=s.length;ca&&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)},Ji.prototype.getName=function(){return this._name},Ji.StandardTypes={ALA:new Ji("ALA","Alanine","A"),ARG:new Ji("ARG","Arginine","R"),ASN:new Ji("ASN","Asparagine","N"),ASP:new Ji("ASP","Aspartic Acid","D"),CYS:new Ji("CYS","Cysteine","C"),GLN:new Ji("GLN","Glutamine","Q"),GLU:new Ji("GLU","Glutamic Acid","E"),GLY:new Ji("GLY","Glycine","G"),HIS:new Ji("HIS","Histidine","H"),ILE:new Ji("ILE","Isoleucine","I"),LEU:new Ji("LEU","Leucine","L"),LYS:new Ji("LYS","Lysine","K"),MET:new Ji("MET","Methionine","M"),PHE:new Ji("PHE","Phenylalanine","F"),PRO:new Ji("PRO","Proline","P"),PYL:new Ji("PYL","Pyrrolysine","O"),SEC:new Ji("SEC","Selenocysteine","U"),SER:new Ji("SER","Serine","S"),THR:new Ji("THR","Threonine","T"),TRP:new Ji("TRP","Tryptophan","W"),TYR:new Ji("TYR","Tyrosine","Y"),VAL:new Ji("VAL","Valine","V"),A:new Ji("A","Adenine","A"),C:new Ji("C","Cytosine","C"),G:new Ji("G","Guanine","G"),I:new Ji("I","Inosine","I"),T:new Ji("T","Thymine","T"),U:new Ji("U","Uracil","U"),DA:new Ji("DA","Adenine","A"),DC:new Ji("DC","Cytosine","C"),DG:new Ji("DG","Guanine","G"),DI:new Ji("DI","Inosine","I"),DT:new Ji("DT","Thymine","T"),DU:new Ji("DU","Uracil","U"),"+A":new Ji("+A","Adenine","A"),"+C":new Ji("+C","Cytosine","C"),"+G":new Ji("+G","Guanine","G"),"+I":new Ji("+I","Inosine","I"),"+T":new Ji("+T","Thymine","T"),"+U":new Ji("+U","Uracil","U"),WAT:new Ji("WAT","Water",""),H2O:new Ji("H2O","Water",""),HOH:new Ji("HOH","Water",""),DOD:new Ji("DOD","Water",""),UNK:new Ji("UNK","Unknown",""),UNL:new Ji("UNL","Unknown Ligand","")};var Gp=Ji.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};to(Gp.WATER,["WAT","H2O","HOH","DOD"]),to(Gp.PROTEIN,["ALA","ARG","ASN","ASP","CYS","GLY","GLU","GLN","HIS","ILE","LEU","LYS","MET","PHE","PRO","PYL","SEC","SER","THR","TRP","TYR","VAL"]),to(Gp.BASIC,["ARG","HIS","LYS"]),to(Gp.ACIDIC,["ASP","GLU"]),to(Gp.POLAR,["ASN","CYS","GLN","SER","THR","TYR"]),to(Gp.NONPOLAR,["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL","GLY"]),to(Gp.AROMATIC,["PHE","TRP","TYR"]),to(Gp.NUCLEIC,["A","G","I","DA","DG","DI","+A","+G","+I","C","T","U","DC","DT","DU","+C","+T","+U"]),to(Gp.PURINE,["A","G","I","DA","DG","DI","+A","+G","+I"]),to(Gp.PYRIMIDINE,["C","T","U","DC","DT","DU","+C","+T","+U"]),to(Gp.DNA,["DA","DG","DI","DC","DT","DU"]),to(Gp.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},eo.prototype._innerFinalize=function(t,e,r,n,i){var o=null===e,a=i(this._leadAtom),s=new l(a.x,a.y,a.z);if(0==(this._type.flags&Ji.Flags.NUCLEIC)){if(o)n._midPoint=i(this._firstAtom).clone();else{var c=e._controlPoint;n._midPoint=c.clone().lerp(s,.5),n._wingVector=this.calcWing(c,s,i(t._wingAtom),e._wingVector)}n._controlPoint=s}else this._detectLeadWing(n,r,i)},eo.prototype._finalize2=function(t,e){this._innerFinalize(t,t,e,this,function(t){return t._position})},eo.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 l(a.x,a.y,a.z)}else t.length>0&&(t[0]._wingVector=new l(1,0,0))},ro.prototype.updateToFrame=function(t){function e(e){return t.getAtomPos(e._index)}for(var r=this._residues,n=null,i=null,o=t._residues,a=r.length,s=0;s1?o[r[1]._index]._wingVector:new l(1,0,0)},ro.prototype.addResidue=function(t,e,r){var n=this._complex.getResidueType(t);null===n&&(n=this._complex.addResidueType(t));var i=new eo(this,n,e,r);return this._complex.addResidue(i),this._residues.push(i),n.flags&(Ji.Flags.NUCLEIC|Ji.Flags.PROTEIN)&&(this.maxSequencee&&(this.minSequence=e)),i},ro.prototype.getResidueCount=function(){return this._residues.length},ro.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 Zp={},$p=Object.freeze({default:Zp}),Kp=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,Qp=function(t){return Kp.exec(t).slice(1)},Jp={extname:go,basename:mo,dirname:fo,sep:"/",delimiter:":",relative:po,join:ho,isAbsolute:uo,normalize:lo,resolve:co},tf="b"==="ab".substr(-1)?function(t,e,r){return t.substr(e,r)}:function(t,e,r){return e<0&&(e=t.length+e),t.substr(e,r)},ef=Object.freeze({resolve:co,normalize:lo,isAbsolute:uo,join:ho,relative:po,sep:"/",delimiter:":",dirname:fo,basename:mo,extname:go,default:Jp}),rf=$p&&Zp||$p,nf=ef&&Jp||ef,of=e(function(e,r){var n=function(){function t(){this.yy={}}var e=function(t,e,r,n){for(r=r||{},n=t.length;n--;r[t[n]]=e);return r},r=[1,4],n=[1,5],i=[1,6],o=[1,7],a=[1,8],s=[1,9],c=[1,11],l=[1,12],u=[5,7,8,11],h=[1,17],p=[1,22],f=[1,20],d=[1,21],m=[5,7,8,11,19],g={trace:function(){},yy:{},symbols_:{error:2,Program:3,Expression:4,EOF:5,Selector:6,OR:7,AND:8,NOT:9,"(":10,")":11,SELECTOR:12,NAMED_SELECTOR:13,SELECTOR_RANGED:14,RangeList:15,SELECTOR_NAMED:16,NameList:17,Range:18,",":19,NUMBER:20,":":21,Name:22,IDENTIFIER:23,STRING:24,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",7:"OR",8:"AND",9:"NOT",10:"(",11:")",12:"SELECTOR",13:"NAMED_SELECTOR",14:"SELECTOR_RANGED",16:"SELECTOR_NAMED",19:",",20:"NUMBER",21:":",23:"IDENTIFIER",24:"STRING"},productions_:[0,[3,2],[4,1],[4,3],[4,3],[4,2],[4,3],[6,1],[6,1],[6,2],[6,2],[15,1],[15,3],[18,1],[18,3],[17,1],[17,3],[22,1],[22,1],[22,1]],performAction:function(t,e,r,n,i,o,a){var s=o.length-1;switch(i){case 1:return o[s-1];case 3:this.$=n.keyword("or")(o[s-2],o[s]);break;case 4:this.$=n.keyword("and")(o[s-2],o[s]);break;case 5:this.$=n.keyword("not")(o[s]);break;case 6:this.$=o[s-1];break;case 7:this.$=n.keyword(o[s])();break;case 8:this.$=n.GetSelector(o[s].toLowerCase().slice(1,o[s].length));break;case 9:case 10:this.$=n.keyword(o[s-1])(o[s]);break;case 11:this.$=new n.RangeList(o[s]);break;case 12:case 16:this.$=o[s-2].append(o[s]);break;case 13:this.$=new n.Range(Number(o[s]));break;case 14:this.$=new n.Range(Number(o[s-2]),Number(o[s]));break;case 15:this.$=new n.ValueList(o[s])}},table:[{3:1,4:2,6:3,9:r,10:n,12:i,13:o,14:a,16:s},{1:[3]},{5:[1,10],7:c,8:l},e(u,[2,2]),{4:13,6:3,9:r,10:n,12:i,13:o,14:a,16:s},{4:14,6:3,9:r,10:n,12:i,13:o,14:a,16:s},e(u,[2,7]),e(u,[2,8]),{15:15,18:16,20:h},{17:18,20:p,22:19,23:f,24:d},{1:[2,1]},{4:23,6:3,9:r,10:n,12:i,13:o,14:a,16:s},{4:24,6:3,9:r,10:n,12:i,13:o,14:a,16:s},e(u,[2,5]),{7:c,8:l,11:[1,25]},e(u,[2,9],{19:[1,26]}),e(m,[2,11]),e(m,[2,13],{21:[1,27]}),e(u,[2,10],{19:[1,28]}),e(m,[2,15]),e(m,[2,17]),e(m,[2,18]),e(m,[2,19]),e([5,7,11],[2,3],{8:l}),e(u,[2,4]),e(u,[2,6]),{18:29,20:h},{20:[1,30]},{20:p,22:31,23:f,24:d},e(m,[2,12]),e(m,[2,14]),e(m,[2,16])],defaultActions:{10:[2,1]},parseError:function(t,e){if(!e.recoverable){var r=function(t,e){this.message=t,this.hash=e};throw r.prototype=Error,new r(t,e)}this.trace(t)},parse:function(t){function e(){var t;return"number"!=typeof(t=i.pop()||f.lex()||h)&&(t instanceof Array&&(t=(i=t).pop()),t=r.symbols_[t]||t),t}var r=this,n=[0],i=[],o=[null],a=[],s=this.table,c="",l=0,u=0,h=1,p=a.slice.call(arguments,1),f=Object.create(this.lexer),d={yy:{}};for(var m in this.yy)Object.prototype.hasOwnProperty.call(this.yy,m)&&(d.yy[m]=this.yy[m]);f.setInput(t,d.yy),d.yy.lexer=f,d.yy.parser=this,void 0===f.yylloc&&(f.yylloc={});var g=f.yylloc;a.push(g);var v=f.options&&f.options.ranges;"function"==typeof d.yy.parseError?this.parseError=d.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var y,_,x,b,w,S,M,A,E,C={};;){if(x=n[n.length-1],this.defaultActions[x]?b=this.defaultActions[x]:(null!==y&&void 0!==y||(y=e()),b=s[x]&&s[x][y]),void 0===b||!b.length||!b[0]){var T="";E=[];for(S in s[x])this.terminals_[S]&&S>2&&E.push("'"+this.terminals_[S]+"'");T=f.showPosition?"Parse error on line "+(l+1)+":\n"+f.showPosition()+"\nExpecting "+E.join(", ")+", got '"+(this.terminals_[y]||y)+"'":"Parse error on line "+(l+1)+": Unexpected "+(y==h?"end of input":"'"+(this.terminals_[y]||y)+"'"),this.parseError(T,{text:f.match,token:this.terminals_[y]||y,line:f.yylineno,loc:g,expected:E})}if(b[0]instanceof Array&&b.length>1)throw new Error("Parse Error: multiple actions possible at state: "+x+", token: "+y);switch(b[0]){case 1:n.push(y),o.push(f.yytext),a.push(f.yylloc),n.push(b[1]),y=null,_?(y=_,_=null):(u=f.yyleng,c=f.yytext,l=f.yylineno,g=f.yylloc);break;case 2:if(M=this.productions_[b[1]][1],C.$=o[o.length-M],C._$={first_line:a[a.length-(M||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(M||1)].first_column,last_column:a[a.length-1].last_column},v&&(C._$.range=[a[a.length-(M||1)].range[0],a[a.length-1].range[1]]),void 0!==(w=this.performAction.apply(C,[c,u,l,d.yy,b[1],o,a].concat(p))))return w;M&&(n=n.slice(0,-1*M*2),o=o.slice(0,-1*M),a=a.slice(0,-1*M)),n.push(this.productions_[b[1]][0]),o.push(C.$),a.push(C._$),A=s[n[n.length-2]][n[n.length-1]],n.push(A);break;case 3:return!0}}return!0}},v={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];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;return 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;this._input||(this.done=!0);var t,e,r,n;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}}};return g.lexer=v,t.prototype=g,g.Parser=t,new t}();void 0!==t&&(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=rf.readFileSync(nf.normalize(t[1]),"utf8");return r.parser.parse(e)},t.main===e&&r.main(process.argv.slice(1)))}),af=of.parser,sf=(of.Parser,of.parse,of.main,{}),cf=function(){function t(e,r){wp(this,t),this.min=e,this.max=void 0===r?e:r}return Sp(t,[{key:"includes",value:function(t){return this.min<=t&&t<=this.max}},{key:"toString",value:function(){var t=this.min,e=this.max;return t===e?String(t):[t,e].join(":")}},{key:"toJSON",value:function(){return[this.min,this.max]}}]),t}(),lf=function(){function t(e){if(wp(this,t),e instanceof this.constructor)return e;e instanceof Array?this._values=e.slice(0):this._values=e?[e]:[]}return Sp(t,[{key:"append",value:function(t){var e=this._values;return e[e.length]=t,this}},{key:"remove",value:function(t){var e=this._values,r=e.indexOf(t);return r>=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}();yf.prototype.priority=1;var _f=function(t){function e(t,r){wp(this,e);var n=Ap(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.lhs=t||vf,n.rhs=r||vf,n}return Mp(e,ff),Sp(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}();_f.prototype.priority=1e3,xo("Not",1,function(t){function e(){return wp(this,e),Ap(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Mp(e,yf),Sp(e,[{key:"includesAtom",value:function(t){return!this.rhs.includesAtom(t)}}]),e}()),xo("And",2,function(t){function e(){return wp(this,e),Ap(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Mp(e,_f),Sp(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)&&this.rhs.includesAtom(t)}}]),e}()),xo("Or",3,function(t){function e(){return wp(this,e),Ap(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Mp(e,_f),Sp(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)||this.rhs.includesAtom(t)}}]),e}());var xf=Object.create(sf);xf.Selector=ff,xf.RangeListSelector=mf,xf.ValueListSelector=gf,xf.Range=cf,xf.RangeList=uf,xf.ValueList=pf,xf.PrefixOperator=yf,xf.InfixOperator=_f,xf.Context=Object.create({}),xf.GetSelector=function(t){if(!xf.Context.hasOwnProperty(t)){throw{message:"selector "+t+" is not registered"}}return xf.Context[t]||vf},xf.ClearContext=function(){Object.keys(xf.Context).forEach(function(t){delete xf.Context[t]})},xf.keyword=function(t){return sf[t.toLowerCase()]||sf.none},xf.parse=function(t){var e={};try{e.selector=af.parse(t)}catch(t){e.selector=vf,e.error=t.message}return e},af.yy=xf,af.yy.parseError=af.parseError,bo.prototype.constructor=bo,bo.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 l(a,a,a))}else for(t=0;t0?this._selector=xf.keyword("Chain")(this.chains):this._selector=xf.keyword("None")()},So.prototype.id="__",Mo.prototype.getResidues=function(){return this._complex._residues},Mo.prototype.getResidueCount=function(){return this._residueCount},Mo.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&wf-1)*bf,a=0;a=bf)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*Sf,this.intBuffer[o]=r,this.intBuffer[o+1]=n,this.intBuffer[o+2]=i,this.numPairs++};Lo.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*c+w*i+M],E=0;EN*N||L<.001||this._pairCollection.addPair(u,C)}}}}}}}}},Lo.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)&&t.dot(e)>=0}}();Oo.prototype.update=function(){for(var t=this.atoms,e=new l,r=t.length,n=0;ni[c]?++c:++s}return!1},Uo.prototype._tryBond=function(t,e,r){var n=[],i=this._bondsData,o=No(t,e),a=e._position.clone().sub(o._position),s=this._currStart,c=this,l=this._bondMarks,u=this._checkBond;l[t._index]=!0,u=void 0===u?Do:u,e.forEachBond(function(o){if(u(o)&&o!==t&&!l[o._index]&&!c._haveSameCycle(i,t,o)){var h=No(o,e),p=h._position.clone().sub(e._position),f=h===s?-2:1-function(t,e){var r=t.dot(e)/Math.sqrt(t.lengthSq()*e.lengthSq());return Eh.clamp(r,-1,1)}(a,p),d=p.cross(a);if(Cf(d,r)){for(var m=0;ms?1:0},Bo.prototype._atomNameCompareCWithH=function(t,e){return this._atomNameCompare(t,e,2)},Bo.prototype._atomNameCompareCWithoutH=function(t,e){return this._atomNameCompare(t,e,254)},Bo.prototype._buildFormulaSimple=function(t,e){var r=t.atoms,n=null,i={},o="",a=this,s=qi.ByName.H.name,c=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),c+=t.getCharge()});var l=Object.keys(i);return i.C?l.sort(this._atomNameCompareCWithH.bind(this)):l.sort(function(t,e){return a._atomNameCompare(t,e,"H".charCodeAt(0))}),l.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!==c&&(l.length>1&&(o="("+o+")"),c>1&&(o+="^{"+c.toString()+"+}"),1===c&&(o+="^+"),c<-1&&(o+="^{"+Math.abs(c).toString()+"-}"),-1===c&&(o+="^-")),t.repeatCount>1&&(o=t.repeatCount.toString(10)+o)):e(l.length,c),o},Bo.prototype._buildPartFormula=function(t){return t.owner instanceof Bo||t.owner instanceof Mo?this._buildFormulaSimple(t,null):t.owner instanceof ao?t.owner.buildChemicalFormula(this,t):""},Bo.prototype._partCompareFunc=function(t,e){return this._partCompareFuncInt(t,e,!0)},Bo.prototype._getCumulativeCharge=function(t){for(var e=t.length,r=0,n=0;n0&&(r[a]?r[a]+=n:r[a]=n)}});var n=Object.keys(r);return n.sort(o._atomNameCompareCWithoutH.bind(o)),{seq:n,data:r}}for(var i,o=this,a=qi.ByName.H.name,s=[r,!1],c=0;cqi.ByName.MT.number)return"}\\text{Could not create chemical formula for this structure.}{"}return""},Bo.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()]&&gp.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,c=t.length-2;s>=0&&c>=0;){var l=t[s],u=t[c];l.owner instanceof Bo||l.owner instanceof Mo?u.owner instanceof Bo||u.owner instanceof Mo?(0===this._partCompareFuncInt(u,l,!1)&&(u.repeatCount+=l.repeatCount,t.splice(s,1)),c--,s--):c--:--s===c&&c--}return t.forEach(function(t){var e=o._buildPartFormula(t);e.length>0&&(a.length>0&&(a+="*"),a+=e)}),a},Bo.prototype.getUnifiedSerial=function(t,e,r){return e+65536*r+16777216*t},Bo.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}},Bo.prototype._fillCmpEdit=function(){function t(){var t=new Mo(e);return t._index=r.length,r[t._index]=t,t}var e=this,r=this._components;this.forEachChain(function(e){var r=e._residues,n=r.length;if(!(n<1))for(var i=t(),o=r[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},Vo.prototype.computeGradient=function(){function t(t,e,r){return Math.min(r,Math.max(e,t))}function e(t,e,r){return c[r*o*a+e*o+t]}if(1!==this._dimVec)return null;for(var r=new Vo(Float32Array,[this._dimX,this._dimY,this._dimZ],this._box,3),n=this.getCellSize(),i=new l(-.5/n.x,-.5/n.y,-.5/n.z),o=this._dimX,a=this._dimY,s=this._dimZ,c=this._data,u=0;u=0;r=this._atoms[r+1])e(this._atoms[r])},Ho.prototype._forEachVoxelWithinRadius=function(t,e,r){var i,o,a,s,c,l,u,h,p=new n,f=new n,d=new n;d.set(t.z-e,t.z+e),d.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor().clampScalar(0,this._count.z-1);for(var m=d.x;m<=d.y;++m){c=[this._box.min.z+m*this._cellSize.z,this._box.min.z+(m+1)*this._cellSize.z],h=t.z-e<=c[0]&&c[1]<=t.z+e,i=Go(t,e,c[0],c[1]),f.set(t.y-i[1],t.y+i[1]),f.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor().clampScalar(0,this._count.y-1);for(var g=f.x;g<=f.y;++g){s=[this._box.min.y+g*this._cellSize.y,this._box.min.y+(g+1)*this._cellSize.y],u=t.y-i[0]<=s[0]&&s[1]<=t.y+i[0],o=Wo(t,i[1],s[0],s[1]),p.set(t.x-o[1],t.x+o[1]),p.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor().clampScalar(0,this._count.x-1);for(var v=p.x;v<=p.y;++v)a=[this._box.min.x+v*this._cellSize.x,this._box.min.x+(v+1)*this._cellSize.x],l=t.x-o[0]<=a[0]&&a[1]<=t.x+o[0],r(v+this._count.x*(g+this._count.y*m),l&&u&&h)}}},Ho.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;s=a[s+1])if(t._position.distanceToSquared(a[s]._position)=1?this.fov=t:this.fov=Eh.radToDeg(2*Math.atan(Math.tan(.5*Eh.degToRad(t))/this.aspect))},ft.prototype.setDistanceToFit=function(t,e){this.position.z=t/Math.sin(.5*Eh.degToRad(e))},vt.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 It(2,2,t,e),o=i.getAttribute("position"),a=0;a65535,s=i*e,c=this._index=_p.allocateTyped(a?Uint32Array:Uint16Array,s);this._positions=_p.allocateTyped(Float32Array,3*o),this._normals=_p.allocateTyped(Float32Array,3*o),this._colors=_p.allocateTyped(Float32Array,3*o);var l=this._alpha=_p.allocateTyped(Float32Array,o);Sl.fill(l,1);for(var u=0;u65535;this._index=_p.allocateTyped(r?Uint32Array:Uint16Array,6*t),this._positions=_p.allocateTyped(Float32Array,4*e),this._colors=_p.allocateTyped(Float32Array,3*e),this._directions=_p.allocateTyped(Float32Array,3*e);var n=this._alpha=_p.allocateTyped(Float32Array,e);Sl.fill(n,1);for(var i=this._index,o=0,a=0,s=0;s117440512)throw new Error("Too large cube dimension: lead to memory huge uasge");return this.pointsValuesLinear=_p.allocateTyped(Float32Array,32*e),this.hasIntersection=_p.allocateTyped(Int32Array,e),this.bitsInside=_p.allocateTyped(Int32Array,e),0},Sa.prototype.destroy=function(){this.bitsInside=null,this.hasIntersection=null,this.pointsValuesLinear=null},Sa.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 md=[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];Aa.prototype.constructor=Aa,Ea.prototype.constructor=Ea,Ca.prototype.constructor=Ca,Ca.prototype._prepareAxesAndDirs=function(){var t=this._volumetricData.getCellSize(),e=this._xAxis,r=this._yAxis,n=this._zAxis,i=this._xDir,o=this._yDir,a=this._zDir;e.set(t.x,0,0),r.set(0,t.y,0),n.set(0,0,t.z),i.set(1,0,0),o.set(0,1,0),a.set(0,0,1);var s=new l;return s.crossVectors(i,o),s.dot(a)<0&&(i.negate(),o.negate(),a.negate()),!(i.x<0||i.y<0||i.z<0||o.x<0||o.y<0||o.z<0||a.x<0||a.y<0||a.z<0)&&!(0!==e.y||0!==e.z||0!==r.x||0!==r.z||0!==n.x||0!==n.y)},Ca.prototype._vertexInterp=function(t,e,r,n,i,o){var a=e.p[r],s=e.p[n],c=e.g[r],l=e.g[n],u=e.val[r],h=t-u,p=e.val[n]-u,f=0;Math.abs(p)>0&&(f=h/p),f=f>1?1:f,i.lerpVectors(a,s,f),o.lerpVectors(c,l,f)},Ca.prototype._polygonize=function(){for(var t=Sa.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 l,i[o]=new l;return function(a,s,c){var l=a.cubeIndex;for(o=0;o<12;++o)md[l]&1<s?s:l+e,h=-1,p=l;pV&&(j=G,V=C[G]);if(j<0||!n.includesAtom(E[j])){P[a]=-1;continue}}P[a]=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))}},Ca.prototype.toMesh=function(){var t=new Pt;return t.setIndex(new vt(this._indices,1)),t.addAttribute("position",new vt(this._position,3)),t.addAttribute("normal",new vt(this._normals,3)),t.addAttribute("color",new vt(this._colors,3)),t.computeBoundingSphere(),t},(Ta.prototype=Object.create(wa.prototype)).constructor=Ta,Ta.prototype._build=function(){var t=this._opts;this.numVoxels=[128,128,128],this.xAxis=new l(1,0,0),this.yAxis=new l(0,1,0),this.zAxis=new l(0,0,1),this.origin=new l(0,0,0),this._visibilitySelector=t.visibilitySelector,this._calcSurface(t)},Ta.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 c=0;c<3;++c)i[c]-=a,o[c]+=a;for(c=0;c<3;++c)r[c]=Math.ceil((o[c]-i[c])/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}},Ta.prototype._makeSurface=function(t,e){var r=new Ca;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 vt(r._indices,1)),this.addAttribute("position",new vt(r._position,3)),this.addAttribute("normal",new vt(r._normals,3)),this.addAttribute("color",new vt(r._colors,3)))},Ta.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 et(this.origin,new l(this.xAxis.x,this.yAxis.y,this.zAxis.z).add(this.origin)),i=this._computeSurface(e,n,r,t);this._makeSurface(i,t)}};var gd=Tf.Volume;(Pa.prototype=Object.create(Ta.prototype)).constructor=Pa,Pa.prototype._computeSurface=function(t,e,r,n){this._shiftByOrigin(t.posRad);var i={volMap:new gd(Float32Array,this.numVoxels,e),volTexMap:new gd(Float32Array,this.numVoxels,e,3)};return null!=this._visibilitySelector&&(i.atomMap=[],i.atomWeightMap=new gd(Float32Array,this.numVoxels,e)),this.gaussdensity(i,t,null,n),i},Pa.prototype.gaussdensity=function(t,e,r,n){var i,o=e.posRad.length/4,a=e.posRad,s=e.colors,c=this.numVoxels,l=n.radScale,u=n.gaussLim,h=n.gridSpacing,p=1/n.isoValue,f=1/h,d=c[0]-1,m=c[1]-1,g=c[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]}}}},Pa.prototype._shiftByOrigin=function(t){for(var e=this.origin.x,r=this.origin.y,n=this.origin.z,i=t.length/4,o=0;ol?e:l,u+=e;var h=Math.floor(s/l);h<2&&(h=2),u/=r,this._numCells=h,this._aveRad=u,this._maxRad=l;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(c=0;c=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]])}},Ia.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),l+=e*f,u+=r*f,h+=d*f,o++}},y=0;y0&&(p=1/Math.sqrt(n),l*=p,u*=p,h*=p),r[y].x=l,r[y].y=u,r[y].z=h;return 0},Ia.prototype.buildColors=function(t,e,r,n){for(var i=this,o=0,a=0,s=0,c=0,l=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;(c=d-m*m)<0&&(c=-c),l=1/(.8+c),h.push([t.colorX,t.colorY,t.colorZ]),p.push(l),f+=l}},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 X(e.getAtomColor(t,this.atoms[D]));if(0===this.colorMode&&(c=this.atomColors[D].x,l=this.atomColors[D].y,u=this.atomColors[D].z),1===this.colorMode){var z=this.complex.monomerTypeArray[h].color;c=z.r,l=z.g,u=z.b}1!==this.colorMode&&0!==this.colorMode&&(c=this.atomColors[D].x,l=this.atomColors[D].y,u=this.atomColors[D].z),F.set(E,C,T),s[x]=new Na(F,L),s[x].colorX=c,s[x].colorY=l,s[x].colorZ=u,x++}return this.voxelsRefs=null,this.voxels=null,s},Da.prototype.destroy=function(){this._vertices=null,this._normals=null,this._indices=null};var yd=Tf.Element;(Fa.prototype=Object.create(wa.prototype)).constructor=Fa,Fa.prototype._build=function(){this._innerBuild();var t=this.getGeo();this.destroy(),this._fromGeo(t)},Fa.prototype._fromGeo=function(t){var e=null,r=_p.allocateTyped(Float32Array,3*t._numVertices),n=_p.allocateTyped(Float32Array,3*t._numVertices);null!==t._colors&&(e=_p.allocateTyped(Float32Array,3*t._numVertices));var i,o=_p.allocateTyped(Uint32Array,3*t._numTriangles),a=0;for(i=0;ii?c:i,s.x-cr.x&&(r.x=s.x+c),s.y+c>r.y&&(r.y=s.y+c),s.z+c>r.z&&(r.z=s.z+c)}e.x-=i,e.y-=i,e.z-=i,r.x+=i,r.y+=i,r.z+=i},Fa.prototype.getCornerCoord=function(t,e,r,n,i,o,a){var s=1/(o-1),c=r*s,l=n*s,u=i*s;a.x=t.x*(1-c)+e.x*c,a.y=t.y*(1-l)+e.y*l,a.z=t.z*(1-u)+e.z*u},Fa.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],c=n.pointsValuesLinear[i+3*t+1],l=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=c*(1-a)+h*a,o.z=l*(1-a)+p*a}},Fa.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))},Fa.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},Fa.prototype.buildGeoFromCorners=function(t,e,r,n,i,o){var a,s,c=t-1,u=t,h=t*t,p=new Array(12);for(a=0;a<12;a++)p[a]=new l;var f=[];for(a=0;a<8;a++)f[a]=1;for(var d=new l,m=0,g=0,v=0;ve.length/2||2*Object.keys(yd.ByAtomicNumber).length!==e.length)throw new Error("atomT.length should be equal Element.ByAtomicNumber.length * 2");return e[2*t]},Fa.prototype.calculateGridCorners=function(t,e,r,n,i,o){for(var a=e*e,s=a*e,c=new l,u=new l,h=0;h=0;r=this.hashEntries[2*r+1]){var u=this.hashEntries[2*r+0];i.copy(t._vertices[u]),i.x-=e.x,i.y-=e.y,i.z-=e.z;if(i.x*i.x+i.y*i.y+i.z*i.z<1e-6)return u}if(t._numVertices>=this.maxNumVertices)return-1;var h=t._numVertices;if(t._vertices[h].copy(e),null!==this.vBoxMin&&null!==this.vBoxMax){if((r=this.getNewHashEntry())<0)return-1;var p=this.hashLines[c+1];this.hashLines[c+1]=r,this.hashEntries[2*r+0]=h,this.hashEntries[2*r+1]=p,this.hashLines[c+0]++}return t._numVertices++,h},Fa.prototype.modifyExcludedFromGeo=function(t,e,r,n,i,o){function a(){l>0?(o[s]<0&&(o[s]=l),l>o[s]&&(o[s]=l)):l>o[s]&&(o[s]=l)}for(var s,c,l,u=t*t,h=(t-1)/(n.x-r.x),p=(t-1)/(n.y-r.y),f=(t-1)/(n.z-r.z),d=2*e*(2*e),m=1/(t-1),g=0;g=0?_:0,x=x>=0?x:0,b=b>=0?b:0,w=w<=t-1?w:t-1,S=S<=t-1?S:t-1,M=M<=t-1?M:t-1;for(var A=x;A<=S;A++)for(var E=A*u,C=b;C<=M;C++)for(var T=C*t,P=_;P<=w;P++){s=E+T+P;var L=P*m,R=r.x*(1-L)+n.x*L;L=A*m;var N=r.y*(1-L)+n.y*L;L=C*m;var I=r.z*(1-L)+n.z*L,O=R-v.x,D=N-v.y,F=I-v.z,z=O*O+D*D+F*F;z=100&&(h=Math.floor(Math.pow(2*p,1/3))),u>h&&(u=h);var f=this.probeRadius*this.atomRadiusScale,d=null,m=null;this.clusterizationType>0?(d=new Oa(this.complex,this.atoms,r,n,i,u,this.colorMode),m=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(c,a,n,i,m,f)):this.calculateGridCorners(c,a,n,i,r,f);var g=o-1,v=new Sa;if((t=v.create(g))<0)return t;var y=new l;y.x=(i.x-n.x)/g,y.y=(i.y-n.y)/g,y.z=(i.z-n.z)/g;var _=this.getNumIntersectedCells(a,g,c,v),x=Math.floor(1.2*_),b=Math.floor(1.2*_*2);if(this.geoOut=new Da(x,b,this.useVertexColors),(t=this.createVertexHash(x,b))<0)return t;var w=f;if(this.excludeProbe&&(w=.01),this.voxelWorld=null,this.clusterizationType>0?this.voxelWorld=new Ia(m.length,m,n,i,w):this.voxelWorld=new Ia(r.length,r,n,i,w),this.voxelWorld.createVoxels(),t=this.buildGeoFromCorners(o,n,i,c,y,v),this.excludeProbe){if(this.modifyExcludedFromGeo(a,f,n,i,this.geoOut,c),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,_=this.getNumIntersectedCells(a,g,c,v),x=Math.floor(1.2*_),b=Math.floor(1.2*_*2),this.geoOut=new Da(x,b,this.useVertexColors),(t=this.createVertexHash(x,b))<0)return t;t=this.buildGeoFromCorners(a,n,i,c,y,v)}if(null!==this.voxelWorld){this.voxelWorld.buildNormals(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._normals);var S=6.5;this.excludeProbe&&(S-=1.5),this.useVertexColors&&this.voxelWorld.buildColors(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._colors,S)}return this.voxelWorld.destroyVoxels(),this.voxelWorld=null,null!==d&&d.destroy(),v.destroy(),t},(za.prototype=Object.create(fi.prototype)).constructor=za,za.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,n=this.geometry.userData,i=r.length;for(e=0;e>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)}},Ad={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()}},Ed=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(),Ad.hasOwnProperty(r)?Ad[r](t):"null"})};(rs.prototype=Object.create($a.prototype)).constructor=rs,rs.prototype._makeGeoArgs=function(t,e,r,n){var i=e.getLabelOpts();return[t.chunks.length,i]},rs.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?l++:l--)r.push(new h(f(t,l),e));return r}(),function(t){var e,r,n,i;for(i=[],r=0,n=m.length;r1&&0!==C&&(u.lerpVectors(_,x,.15/S),h.lerpVectors(_,x,1-.15/S)),C*=.15,u.addScaledVector(M,C),h.addScaledVector(M,C),o.setItem(p,u,h),o.setColor(p++,i.getAtomColor(v,r),i.getAtomColor(y,r))}}o.finalize(),this._chunksIdc=f},ps.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(),c=new l,u=new l,h=new l,p=0,f=t.needsColorUpdate(i),d=0,m=e.length;d1&&0!==C&&(u.lerpVectors(_,x,.15/S),h.lerpVectors(_,x,1-.15/S)),C*=.15,u.addScaledVector(M,C),h.addScaledVector(M,C),o.setItem(p,u,h),f&&o.setColor(p,t.getAtomColor(i,v),t.getAtomColor(i,y)),p++}}o.finalize()};var Md={AtomsSphereGroup:Ga,AtomsSurfaceGroup:Wa,AtomsSASSESGroup_stub:Ha,AtomsTextGroup:qa,AromaticTorusGroup:Ka,AromaticLinesGroup:Qa,NucleicCylindersGroup:es,NucleicSpheresGroup:rs,ResiduesSubseqGroup:cs,ResiduesTraceGroup:ls,BondsCylinderGroup:hs,BondsLinesGroup:ps};(fs.prototype=Object.create(Vo.prototype)).constructor=fs,fs.prototype._checkAtom=function(t,e){return t._mask&e},fs.prototype.getSubset=function(t,e){for(var r=[],n=this.children,i=0,o=0,a=n.length;o0&&s.add(h)}return s},(As.prototype=Object.create(Ms.prototype)).constructor=As,As.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")},As.prototype.buildGeometry=function(t,e,r,n){return this.update(),Ms.prototype.buildGeometry.call(this,t,e,r,n)},fp.deriveClass(Cs,As,{id:"LN",name:"Lines",shortName:"Lines",depGroups:["ALoopsLines","BondsLines","OrphanedAtomsCrosses"]}),Cs.prototype.drawMultiorderBonds=function(){return this.opts.multibond},Cs.prototype.calcAtomRadius=function(){return this.opts.atom},Cs.prototype.getAromaticOffset=function(){return this.opts.offsarom},Cs.prototype.getAromaticArcChunks=function(){return this.opts.chunkarom},Cs.prototype.showAromaticLoops=function(){return this.opts.showarom},Cs.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!0,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},fp.deriveClass(Ts,As,{id:"LC",name:"Licorice",shortName:"Licorice",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),Ts.prototype.calcAtomRadius=function(t){return this.opts.bond},Ts.prototype.calcStickRadius=function(){return this.opts.bond},Ts.prototype.calcSpaceFraction=function(){return this.opts.space},Ts.prototype.getAromRadius=function(){return this.opts.aromrad},Ts.prototype.showAromaticLoops=function(){return this.opts.showarom},Ts.prototype.drawMultiorderBonds=function(){return this.opts.multibond},Ts.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},fp.deriveClass(Ps,As,{id:"BS",name:"Balls and Sticks",shortName:"Balls",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),Ps.prototype.calcAtomRadius=function(t){return t.element.radius*this.opts.atom},Ps.prototype.calcStickRadius=function(){return this.opts.bond},Ps.prototype.getAromRadius=function(){return this.opts.aromrad},Ps.prototype.showAromaticLoops=function(){return this.opts.showarom},Ps.prototype.calcSpaceFraction=function(){return this.opts.space},Ps.prototype.drawMultiorderBonds=function(){return this.opts.multibond},Ps.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},fp.deriveClass(Ls,Ms,{id:"VW",name:"Van der Waals",shortName:"VDW",depGroups:["AtomsSpheres"]}),Ls.prototype.calcAtomRadius=function(t){return t.element.radius},fp.deriveClass(Rs,Ms,{id:"TR",name:"Trace",shortName:"Trace",depGroups:["TraceChains"]}),Rs.prototype.calcStickRadius=function(){return this.opts.radius},fp.deriveClass(Ns,Ms,{id:"TU",name:"Tube",shortName:"Tube",depGroups:["CartoonChains"]}),Ns.prototype.getResidueRadius=function(t){return this.TUBE_RADIUS},Ns.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},Ns.prototype.getTension=function(){return this.opts.tension},Ns.prototype.buildGeometry=function(t,e,r,i){var o=this.opts.radius;return this.TUBE_RADIUS=new n(o,o),Ms.prototype.buildGeometry.call(this,t,e,r,i)},fp.deriveClass(Is,Ms,{id:"CA",name:"Cartoon",shortName:"Cartoon",depGroups:["CartoonChains","NucleicSpheres","NucleicCylinders"]}),Is.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},Is.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},Is.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)},Is.prototype.calcStickRadius=function(t){return this.opts.radius},Is.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},Is.prototype.getTension=function(){return this.opts.tension},Is.prototype.buildGeometry=function(t,e,r,i){var o=this.opts.radius,a=this.opts.depth;this.TUBE_RADIUS=new n(o,o),this.ARROW_END=new n(a,o);var s={},c=this.opts.ss;for(var l in c)s[l]={center:new n(a,c[l].width),start:new n(a,c[l].arrow)};return this.secCache=s,Ms.prototype.buildGeometry.call(this,t,e,r,i)};var Ed=xf.selectors;fp.deriveClass(Ds,Ms,{isSurface:!0,surfaceNames:[]}),Ds.prototype.calcAtomRadius=function(t){return t.element.radius},Ds.prototype.getVisibilitySelector=function(){var t=null;if(""!==this.opts.subset){var e=Ed.parse(this.opts.subset);e.error||(t=e.selector)}return t},fp.deriveClass(Fs,Ds,{id:"QS",name:"Quick Surface",shortName:"Quick Surf",surfaceNames:["QuickSurfGeo"]}),Fs.prototype.getSurfaceOpts=function(){return{useBeads:!1,isoValue:this.opts.isoValue,gaussLim:this.opts.gaussLim[this.settings.now.resolution],radScale:this.opts.scale,gridSpacing:this.opts.gridSpacing[this.settings.now.resolution],zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector()}},fp.deriveClass(zs,Ds,{id:"SU",name:"Surface",shortName:"Surface",surfaceNames:["SASSESSurfaceGeo"]}),zs.prototype._radScale=1,zs.prototype._isVertexNormalsRendered=!1,zs.prototype._isSurfaceTransparent=!1,zs.prototype._clusterViaKMeans=0,zs.prototype._excludeProbe=!1,zs.prototype.calcAtomRadius=function(t){return t.element.radius},zs.prototype.getSurfaceOpts=function(){return{gridSpacing:this.opts.polyComplexity[this.settings.now.resolution],radScale:this._radScale,zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector(),probeRadius:this.opts.probeRadius,excludeProbe:this._excludeProbe,clusterizationType:this._clusterViaKMeans}},fp.deriveClass(ks,zs,{id:"SA",name:"Solvent Accessible Surface",shortName:"SAS"}),fp.deriveClass(Us,zs,{id:"SE",name:"Solvent Excluded Surface",shortName:"SES"}),fp.deriveClass(Bs,Ds,{id:"CS",name:"Contact Surface",shortName:"Contact Surf",isSurface:!0,surfaceNames:["ContactSurfaceGeo"]}),Bs.prototype.getSurfaceOpts=function(){return{probeRadius:this.opts.probeRadius,radScale:this.opts.polyComplexity[this.settings.now.resolution],scaleFactor:this.opts.polyComplexity[this.settings.now.resolution],gridSpacing:1/this.opts.polyComplexity[this.settings.now.resolution],isoValue:this.opts.isoValue,probePositions:this.opts.probePositions,zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector()}},fp.deriveClass(Vs,Ms,{id:"TX",name:"Text mode",shortName:"Text",depGroups:["TextLabelsGeo"]}),Vs.prototype.getTemplateOptions=function(){return this.opts.template},Vs.prototype.getLabelOpts=function(){return _.merge(this.opts,{labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0})};var Cd=[],Td={};!function(t){for(var e=0,r=t.length;e=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=this.gradients[e];if(r){var n=r.length,i=t*(n-1),o=Math.floor(i),a=js(o+1,0,n-1);return o=js(o,0,n-1),function(t,e,r){var n=1-r;return n*(t>>16&255)+r*(e>>16&255)<<16|n*(t>>8&255)+r*(e>>8&255)<<8|n*(255&t)+r*(255&e)}(r[o],r[a],i-o)}return this.defaultNamedColor},getNamedColor:function(t,e){var r=this.namedColors[t];return void 0!==r||e?r:this.defaultNamedColor}}).namedColorsArray,Rd=Gs.prototype.namedColors,Nd=0,Id=Ld.length;Nd=0?this.opts.carbon:this.palette.getElementColor(r)},Hs.prototype.getResidueColor=function(t,e){return this.palette.defaultResidueColor},fp.deriveClass(Xs,Ws,{id:"RT",name:"Residue Type",shortName:"Residue"}),Xs.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Xs.prototype.getResidueColor=function(t,e){return this.palette.getResidueColor(t._type._name)},fp.deriveClass(Ys,Ws,{id:"SQ",aliases:["RI"],name:"Sequence",shortName:"Sequence"}),Ys.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Ys.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)},fp.deriveClass(qs,Ws,{id:"CH",name:"Chain",shortName:"Chain"}),qs.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},qs.prototype.getResidueColor=function(t,e){return this.palette.getChainColor(t.getChain()._name)},fp.deriveClass($s,Ws,{id:"SS",name:"Secondary Structure",shortName:"Structure"}),$s.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},$s.prototype.getResidueColor=function(t,e){if(t._type.flags&qi.Flags.DNA)return this.palette.getSecondaryColor("dna");if(t._type.flags&qi.Flags.RNA)return this.palette.getSecondaryColor("rna");var r=t.getSecondary();return r?this.palette.getSecondaryColor(r.type,r._type):this.palette.getSecondaryColor("")},fp.deriveClass(Zs,Ws,{id:"UN",name:"Uniform",shortName:"Uniform"}),Zs.prototype.getAtomColor=function(t,e){return this.opts.color},Zs.prototype.getResidueColor=function(t,e){return this.opts.color},fp.deriveClass(Ks,Ws,{id:"CO",name:"Conditional",shortName:"Conditional"}),Ks.prototype.getAtomColor=function(t,e){return this._subsetCached.includesAtom(t)?this.opts.color:this.opts.baseColor},Ks.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},Js.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===xf.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},fp.deriveClass(tc,Ws,{id:"OC",name:"Occupancy",shortName:"Occupancy"}),tc.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},tc.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===xf.Element.Constants.Lead&&(n=t._occupancy)}),n>0){var i=1-n;return this.palette.getGradientColor(i,r.gradient)}return this.palette.defaultResidueColor},fp.deriveClass(ec,Ws,{id:"HY",name:"Hydrophobicity",shortName:"Hydrophobicity"}),ec.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},ec.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},fp.deriveClass(rc,Ws,{id:"MO",name:"Molecule",shortName:"Molecule"}),rc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},rc.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 Wd=[],Hd={};!function(t){for(var e=0,r=t.length;e0){(e=new _e).matrixAutoUpdate=!1,e.matrix=this.geo.matrix;for(var n=0;n2)return up.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 up.error("Rep "+t+" does not exist!"),null;t===this._reprList.length&&(this.repAdd(e),e=void 0,up.warn("Rep "+t+" does not exist! New representation was created."));var r=this._reprList[t],n={selector:r.selectorString,mode:r.mode.identify(),colorer:r.colorer.identify(),material:r.materialPreset.id};if(e){var i=!1;if(e.selector){var o=Jd.parse(e.selector).selector,a=String(o);n.selector!==a&&(r.selectorString=n.selector=a,r.selector=o,r.markAtoms(this._complex),i=!0,up.debug("rep["+t+"].selector changed to"+a))}if(e.mode){var s=e.mode;vl.isEqual(n.mode,s)||(n.mode=s,r.setMode(Pd.create(e.mode)),i=!0,up.debug("rep["+t+"].mode changed to "+s),!r.mode.isSurface||"ultra"!==gp.now.resolution&&"high"!==gp.now.resolution||(up.report('Surface resolution was changed to "medium" to avoid hang-ups.'),gp.now.resolution="medium"))}if(e.colorer){var c=e.colorer;vl.isEqual(n.colorer,c)||(n.colorer=c,r.colorer=Xd.create(e.colorer),i=!0,up.debug("rep["+t+"].colorer changed to "+c))}if(e.material){var l=e.material;vl.isEqual(n.material,l)||(n.material=l,r.setMaterialPreset(Kd.get(e.material)),i=!0,up.debug("rep["+t+"].material changed to"+l))}i&&(r.needsRebuild=!0)}return n},lc.prototype.repGet=function(t){return(void 0===t||t instanceof Object)&&(t=this.repCurrent()),t<0||t>=this._reprList.length?null:this._reprList[t]},lc.prototype._getFreeReprIdx=function(){for(var t=this._reprUsedBits,e=0;e<=lc.NUM_REPRESENTATION_BITS;++e,t>>=1)if(0==(1&t))return e;return-1},lc.prototype.repAdd=function(t){if(this._reprList.length>=lc.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)}},lc.prototype.select=function(t,e){e?this._selectionCount+=this._complex.markAtomsAdditionally(t,1<0&&(a=Jd.chain(r),o=o?Jd.or(o,a):a),Object.keys(e).length>0)for(var s in e)e.hasOwnProperty(s)&&(a=Jd.and(Jd.chain(s),Jd.residx(n(e[s]))),o=o?Jd.or(o,a):a);t.length>0&&(a=Jd.serial(n(t)),o=o?Jd.or(o,a):a),o||(o=Jd.none())}return o},lc.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)},lc.prototype.getSelectedComponent=function(){var t=1<=0):a<8+_.indices.length&&(this.cullFlag[a]=!0);var S=this.geometry.getAttribute("position"),M=0;for(a=0;a=3&&(h+=3*(r.indices.length-2));var p=0,f=new Uint16Array(h);for(e=0;ee&&(n._prof.end(),n._prof.start(),++i),c>r||i===t?a(Math.max(i,0)):requestAnimationFrame(s)}requestAnimationFrame(s)})},dc.prototype.mean=function(){return this._prof?this._prof.rawMean():0},dc.prototype.min=function(){return this._prof?this._prof.min():0};var nm=function(t){function e(t,r){yp(this,e);var n=bp(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n._source=t,n._options=r||{},n._agent=null,n}return xp(e,fi),_p(e,[{key:"load",value:function(t){return t?this._loadOLD(t):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._agent&&this._agent.abort()}}]),e}();Xo(nm.prototype);var im=[];!function(t){for(var e=0,r=t.length;e0&&void 0!==arguments[0]?arguments[0]:[];yp(this,t),this._list=[],this._byFormat={},this._byExt={},r.forEach(function(t){return e.register(t)})}return _p(t,[{key:"register",value:function(t){this._list.includes(t)||this._list.push(t),mc(this._byFormat,t.formats,t),mc(this._byExt,t.extensions,t)}},{key:"unregister",value:function(t){var e=this._list.indexOf(t);-1!==e&&this._list.splice(e,1),gc(this._byFormat,t.formats,t),gc(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(wp(e))}},{key:"all",get:function(){return[].concat(wp(this._list))}},{key:"formats",get:function(){return Object.keys(this._byFormat)}},{key:"extensions",get:function(){return Object.keys(this._byExt)}}]),t}(),sm=function(){function t(e,r){yp(this,t),this._data=e,this._options=r,this._abort=!1}return _p(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}();Xo(sm.prototype),vc.prototype.id=290,vc.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 u,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 cm=xf.Assembly;yc.prototype.id=350,yc.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 u,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(","),c=0,l=s.length;c0&&e.addChain(h)}else"BIOMOLECULE:"===t.readString(12,23)&&(this._matrix=null,this._matrixIndex=-1,this._assembly=e=new cm(this._complex),this.assemblies.push(e))};var lm=function(){function t(e){yp(this,t),this._data=e,this._start=0,this._nextCR=-1,this._nextLF=-1,this._next=-1,this._end=e.length,this.next()}return _p(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,mm.BondType.UNKNOWN,!0),n&&n>e&&a.addBond(e,n,0,mm.BondType.UNKNOWN,!0),i&&i>e&&a.addBond(e,i,0,mm.BondType.UNKNOWN,!0),o&&o>e&&a.addBond(e,o,0,mm.BondType.UNKNOWN,!0)},_c.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 ym={290:vc,350:yc};_c.prototype._parseREMARK=function(t){var e=t.readInt(8,10),r=this._remarks[e];if(vl.isUndefined(r)){var n=ym[e];vl.isFunction(n)&&(this._remarks[e]=r=new n(this._complex))}vl.isUndefined(r)||r.parse(t)},_c.prototype._parseHELIX=function(t){this._parseSTRUCTURE(t,[20,22,32,34],function(t){this._complex.addHelix(t)}.bind(this))},_c.prototype._parseSHEET=function(t){this._parseSTRUCTURE(t,[22,23,33,34],function(t){this._complex.addSheet(t)}.bind(this))},_c.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),c=t.readInt(15,16),l=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=t.readInt(e[3],e[3]+3),v=0;(d=t.readString(e[3]+4,e[3]+4)).length>0&&(v=d.charCodeAt(0));var y,_=this._sheet;if(83===t.readCharCode(1)){null!==_&&_.getName()!==i&&(_=null,this._sheet=null),null===_?(this._sheet=y=new fm(i,c),r(y)):y=_;var x=new dm(y,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,g,v),s,l,u);y.addStrand(x)}else r(y=new pm(n,i,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,g,v),s,o,a))},_c.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)},_c.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 _m={HEADER:_c.prototype._parseHEADER,"TITLE ":_c.prototype._parseTITLE,"ATOM ":_c.prototype._parseATOM,HETATM:_c.prototype._parseATOM,ENDMDL:_c.prototype._parseENDMDL,CONECT:_c.prototype._parseCONECT,COMPND:_c.prototype._parseCOMPND,REMARK:_c.prototype._parseREMARK,"HELIX ":_c.prototype._parseHELIX,"SHEET ":_c.prototype._parseSHEET,"ATOM 1":_c.prototype._parseATOM,"ATOM 2":_c.prototype._parseATOM,"ATOM 3":_c.prototype._parseATOM,"ATOM 4":_c.prototype._parseATOM,"ATOM 5":_c.prototype._parseATOM,"ATOM 6":_c.prototype._parseATOM,"ATOM 7":_c.prototype._parseATOM,"ATOM 8":_c.prototype._parseATOM,"ATOM 9":_c.prototype._parseATOM};_c.prototype.parseSync=function(){for(var t=new lm(this._data),e=this._complex=new um;!t.end();){var r=t.readString(1,6),n=_m[r];vl.isFunction(n)&&n.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},_c.formats=["pdb"],_c.extensions=[".pdb",".ent"];var xm=xf.Complex,bm=xf.Element,wm=xf.AtomName,Sm=xf.SGroup,Mm=xf.Bond,Am={A:0,S:1,D:2,T:3};(xc.prototype=Object.create(sm.prototype)).constructor=xc,xc.canParse=function(t,e){if(!t)return!1;var r=new RegExp("^\\s*?\\<\\?xml"),n=new RegExp("^\\s*?\\]*\?>\s*<(?:cml|molecule)\b/i;xc.canProbablyParse=function(t){return vl.isString(t)&&Em.test(t)},xc.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){function e(t){return u=l[t],!!(a=n[u.start])&&(a.edges.push(u.end),!!(a=n[u.end])&&(a.edges.push(u.start),!0))}var 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={};return o.atomLabels=null,o.labelsCount=1,o}t.molecule.molecule&&i._extractSGroups(t.molecule.molecule,n);for(var a,s=n.length,c=0;c1)l[h].order=f;else{var d=Am[p];void 0!==d&&(l[h].order=d,"A"===p&&(l[h].type=Mm.BondType.AROMATIC))}}s=n.length;for(var m=0;m0&&o.push(e)}),o},xc.prototype._packLabel=function(t,e){return(e<<16)+t},xc.prototype._unpackLabel=function(t){return{molId:t>>>16,compId:65535&t}},xc.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 c=i.shift();if(c)for(var l=0;l=0){var i=[Math.min(t,e),Math.max(t,e)];this._complex.addBond(i[0],i[1],r,n,!0)}},xc.prototype._fixBondsArray=function(){for(var t=this._serialAtomMap={},e=this._complex,r=e._atoms,n=0,i=r.length;n1){var n=new xm;return n.joinComplexes(t),n.originalCML=t[0].originalCML,n}return 1===t.length?t[0]:new xm},xc.formats=["cml"],xc.extensions=[".cml"];var Cm=e(function(t,e){!function(t,r){r(e)}(0,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,i,o){var a=typeof t;if("string"===a){if(32>(s=r(t)))return i.setUint8(o,160|s),e(i,o+1,t),1+s;if(256>s)return i.setUint8(o,217),i.setUint8(o+1,s),e(i,o+2,t),2+s;if(65536>s)return i.setUint8(o,218),i.setUint16(o+1,s),e(i,o+3,t),3+s;if(4294967296>s)return i.setUint8(o,219),i.setUint32(o+1,s),e(i,o+5,t),5+s}if(t instanceof Uint8Array){var s=t.byteLength,c=new Uint8Array(i.buffer);if(256>s)return i.setUint8(o,196),i.setUint8(o+1,s),c.set(t,o+2),2+s;if(65536>s)return i.setUint8(o,197),i.setUint16(o+1,s),c.set(t,o+3),3+s;if(4294967296>s)return i.setUint8(o,198),i.setUint32(o+1,s),c.set(t,o+5),5+s}if("number"===a){if(!isFinite(t))throw new Error("Number not finite: "+t);if(Math.floor(t)!==t)return i.setUint8(o,203),i.setFloat64(o+1,t),9;if(t>=0){if(128>t)return i.setUint8(o,t),1;if(256>t)return i.setUint8(o,204),i.setUint8(o+1,t),2;if(65536>t)return i.setUint8(o,205),i.setUint16(o+1,t),3;if(4294967296>t)return i.setUint8(o,206),i.setUint32(o+1,t),5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return i.setInt8(o,t),1;if(t>=-128)return i.setUint8(o,208),i.setInt8(o+1,t),2;if(t>=-32768)return i.setUint8(o,209),i.setInt16(o+1,t),3;if(t>=-2147483648)return i.setUint8(o,210),i.setInt32(o+1,t),5;throw new Error("Number too small -0x"+(-t).toString(16).substr(1))}if(null===t)return i.setUint8(o,192),1;if("boolean"===a)return i.setUint8(o,t?195:194),1;if("object"===a){var l=0,u=Array.isArray(t);if(u)s=t.length;else{var h=Object.keys(t);s=h.length}if(16>s?(i.setUint8(o,s|(u?144:128)),l=1):65536>s?(i.setUint8(o,u?220:222),i.setUint16(o+1,s),l=3):4294967296>s&&(i.setUint8(o,u?221:223),i.setUint32(o+1,s),l=5),u)for(p=0;s>p;p++)l+=n(t[p],i,o+l);else for(var p=0;s>p;p++){var f=h[p];l+=n(f,i,o+l),l+=n(t[f],i,o+l)}return l}throw new Error("Unknown type "+a)}function i(t){var e=typeof t;if("string"===e){if(32>(n=r(t)))return 1+n;if(256>n)return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if(t instanceof Uint8Array){if(256>(n=t.byteLength))return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if("number"===e){if(Math.floor(t)!==t)return 9;if(t>=0){if(128>t)return 1;if(256>t)return 2;if(65536>t)return 3;if(4294967296>t)return 5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return 1;if(t>=-128)return 2;if(t>=-32768)return 3;if(t>=-2147483648)return 5;throw new Error("Number too small -0x"+t.toString(16).substr(1))}if("boolean"===e||null===t)return 1;if("object"===e){var n,o=0;if(Array.isArray(t)){n=t.length;for(s=0;n>s;s++)o+=i(t[s])}else{var a=Object.keys(t);n=a.length;for(var s=0;n>s;s++){var c=a[s];o+=i(c)+i(t[c])}}if(16>n)return 1+o;if(65536>n)return 3+o;if(4294967296>n)return 5+o;throw new Error("Array or object too long 0x"+n.toString(16))}throw new Error("Unknown type "+e)}function o(t){var e=new ArrayBuffer(i(t));return n(t,new DataView(e),0),new Uint8Array(e)}function a(t,e,r){return e?new t(e.buffer,e.byteOffset,e.byteLength/(r||1)):void 0}function s(t){return a(DataView,t)}function c(t){return a(Uint8Array,t)}function l(t){return a(Int8Array,t)}function u(t){return a(Int32Array,t,4)}function h(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 p(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 f(t,e){var r=t.length;e||(e=new Uint8Array(4*r));for(var n=s(e),i=0;r>i;++i)n.setInt32(4*i,t[i]);return c(e)}function d(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 m(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 g(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],c=0;s>c;++c)e[o]=a,++o;return e}function v(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 y(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 _(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 x(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 c=0;t[r]===i||t[r]===o;)c+=t[r],++r;c+=t[r],++r,e[n]=c,++n}return e}function b(t,e){var r,n=e?127:32767,i=-n-1,o=t.length,a=0;for(r=0;o>r;++r){0===(l=t[r])?++a:a+=l===n||l===i?2:l>0?Math.ceil(l/n):Math.ceil(l/i)}var s=e?new Int8Array(a):new Int16Array(a),c=0;for(r=0;o>r;++r){var l=t[r];if(l>=0)for(;l>=n;)s[c]=n,++c,l-=n;else for(;i>=l;)s[c]=i,++c,l-=i;s[c]=l,++c}return s}function w(t,e,r){return d(x(t,u(r)),e,r)}function S(t,e,r){var n=x(t,u(r));return function(t,e,r){return d(y(t,u(r)),e,r)}(n,e,function(t){return a(Float32Array,t,4)}(n))}function M(t,e,r){return b(function(t,e,r){return _(m(t,e),r)}(t,e),r)}function A(t){var e=s(t),r=e.getInt32(0),n=e.getInt32(4),i=t.subarray(8,12);return[r,t=t.subarray(12),n,i]}function E(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 C(t){return E(2,t.length,void 0,c(t))}function T(t){return E(4,t.length,void 0,f(t))}function P(t,e){return E(5,t.length/e,f([e]),c(t))}function L(t){return E(6,t.length,void 0,f(v(t)))}function R(t){return E(8,t.length,void 0,f(function(t){return v(_(t))}(t)))}function N(t,e){return E(9,t.length,f([e]),f(function(t,e){return v(m(t,e))}(t,e)))}function I(t,e){return E(10,t.length,f([e]),function(t,e){var r=t.length;e||(e=new Uint8Array(2*r));for(var n=s(e),i=0;r>i;++i)n.setInt16(2*i,t[i]);return c(e)}(M(t,e)))}function O(t){var e={};return V.forEach(function(r){void 0!==t[r]&&(e[r]=t[r])}),t.bondAtomList&&(e.bondAtomList=T(t.bondAtomList)),t.bondOrderList&&(e.bondOrderList=C(t.bondOrderList)),e.xCoordList=I(t.xCoordList,1e3),e.yCoordList=I(t.yCoordList,1e3),e.zCoordList=I(t.zCoordList,1e3),t.bFactorList&&(e.bFactorList=I(t.bFactorList,100)),t.atomIdList&&(e.atomIdList=R(t.atomIdList)),t.altLocList&&(e.altLocList=L(t.altLocList)),t.occupancyList&&(e.occupancyList=N(t.occupancyList,100)),e.groupIdList=R(t.groupIdList),e.groupTypeList=T(t.groupTypeList),t.secStructList&&(e.secStructList=C(t.secStructList)),t.insCodeList&&(e.insCodeList=L(t.insCodeList)),t.sequenceIndexList&&(e.sequenceIndexList=R(t.sequenceIndexList)),e.chainIdList=P(t.chainIdList,4),t.chainNameList&&(e.chainNameList=P(t.chainNameList,4)),e}function D(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;var n=65535;if(e>n){for(var i=[],o=0;or;r++)e[r]=o();return e}function o(){var o,c,l=t[a];if(0==(128&l))return a++,l;if(128==(240&l))return c=15&l,a++,e(c);if(144==(240&l))return c=15&l,a++,i(c);if(160==(224&l))return c=31&l,a++,n(c);if(224==(224&l))return o=s.getInt8(a),a++,o;switch(l){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return c=s.getUint8(a+1),a+=2,r(c);case 197:return c=s.getUint16(a+1),a+=3,r(c);case 198:return c=s.getUint32(a+1),a+=5,r(c);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 c=s.getUint8(a+1),a+=2,n(c);case 218:return c=s.getUint16(a+1),a+=3,n(c);case 219:return c=s.getUint32(a+1),a+=5,n(c);case 220:return c=s.getUint16(a+1),a+=3,i(c);case 221:return c=s.getUint32(a+1),a+=5,i(c);case 222:return c=s.getUint16(a+1),a+=3,e(c);case 223:return c=s.getUint32(a+1),a+=5,e(c)}throw new Error("Unknown type 0x"+l.toString(16))}var a=0,s=new DataView(t.buffer);return o()}function F(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=s(e),i=s(t),o=0,a=0,c=r/4;c>o;++o,a+=4)n.setFloat32(a,i.getFloat32(a),!0);return e}(e);case 2:return l(e);case 3:return h(e);case 4:return p(e);case 5:return c(e);case 6:return g(p(e),new Uint8Array(r));case 7:return g(p(e));case 8:return function(t,e){return y(g(t),e)}(p(e));case 9:return function(t,e,r){return d(g(t,u(r)),e,r)}(p(e),p(n)[0]);case 10:return S(h(e),p(n)[0]);case 11:return d(h(e),p(n)[0]);case 12:return w(h(e),p(n)[0]);case 13:return w(l(e),p(n)[0]);case 14:return x(h(e));case 15:return x(l(e))}}function z(t,e){var r=(e=e||{}).ignoreFields,n={};return j.forEach(function(e){var i=!!r&&-1!==r.indexOf(e),o=t[e];i||void 0===o||(o instanceof Uint8Array?n[e]=F.apply(null,A(o)):n[e]=o)}),n}function k(t){return String.fromCharCode.apply(null,t).replace(/\0/g,"")}function U(t,e){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var r;return r=t instanceof Uint8Array?D(t):t,z(r,e)}function B(t,e,r,n){var i=new XMLHttpRequest;i.addEventListener("load",function(){try{var t=U(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 V=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],j=V.concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]),G="//mmtf.rcsb.org/v1.0/",W=G+"full/",H=G+"reduced/";t.encode=function(t){return o(O(t))},t.decode=U,t.traverse=function(t,e,r){var n,i,o,a,s,c,l=(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&&!(l&&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=k(t.chainIdList.subarray(4*g,4*g+4)),O=null;b&&(O=k(b.subarray(4*g,4*g+4))),h({groupCount:N,chainIndex:g,modelIndex:m,chainId:I,chainName:O})}for(a=0;N>a;++a){var D=t.groupList[t.groupTypeList[v]],F=D.atomNameList.length;if(p){var z=null;w&&(z=w[v]);var U=null;t.insCodeList&&(U=String.fromCharCode(S[v]));var B=null;M&&(B=M[v]),p({atomCount:F,groupIndex:v,chainIndex:g,modelIndex:m,groupId:t.groupIdList[v],groupType:t.groupTypeList[v],groupName:D.groupName,singleLetterCode:D.singleLetterCode,chemCompType:D.chemCompType,secStruct:z,insCode:U,sequenceIndex:B})}for(s=0;F>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:D.elementList[s],atomName:D.atomNameList[s],formalCharge:D.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=D.bondAtomList;for(s=0,c=D.bondOrderList.length;c>s;++s)d({atomIndex1:y-F+H[2*s],atomIndex2:y-F+H[2*s+1],bondOrder:D.bondOrderList[s]})}v+=1}g+=1}if(_=x+1,x=y-1,d&&P)for(s=0,c=P.length;c>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){B(t,W,e,r)},t.fetchReduced=function(t,e,r){B(t,H,e,r)},t.version="v1.1.0dev",t.fetchUrl=W,t.fetchReducedUrl=H,t.encodeMsgpack=o,t.encodeMmtf=O,t.decodeMsgpack=D,t.decodeMmtf=z})}),Tm=xf.Complex,Pm=xf.Chain,Lm=xf.Atom,Rm=xf.AtomName,Nm=xf.Element,Im=xf.Helix,Om=xf.Sheet,Dm=xf.Strand,Fm=xf.Bond,zm=xf.Assembly,km=xf.Molecule;bc.prototype.constructor=bc,bc.prototype.compare=function(t){var e=t.length;if(e!==this._original.length)return!1;var r,n=0;for(r=0;r=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,Fm.BondType.UNKNOWN,!0)}},wc.prototype._updateSecStructure=function(t,e,r){if(!vl.isUndefined(r)&&r.secStruct===this._ssType)return e._secondary=this._ssStruct,void((this._ssStruct instanceof Im||this._ssStruct instanceof Dm)&&this._ssStruct._residues.push(e));if(-1!==this._ssType&&(this._ssStruct instanceof Im||this._ssStruct instanceof Dm)&&(this._ssStruct._end=this._ssStruct._residues[this._ssStruct._residues.length-1]),!vl.isUndefined(r)){this._ssType=r.secStruct,this._ssStart=e;var n=null;switch(this._ssType){case-1:break;case 0:case 2:case 4:n=new Im(0,"",e,null,[3,-1,1,-1,5][this._ssType],"",0),t._helices.push(n);break;case 3:var i=new Om("",0);t._sheets.push(i),n=new Dm(i,e,null,0);break;default:n={type:"mmtf"+this._ssType}}this._ssStruct=n,e._secondary=n}},wc.prototype._updateMolecules=function(t){var e=t.entityList;if(e)for(var r=t.chainsPerModel[0],n=0;n=r)){var l=this._complex._chains[c];a=a.concat(l._residues.slice())}}var u=new km(this._complex,i.description,n+1);u._residues=a,this._complex._molecules[n]=u}},wc.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,Cm.traverse(t,r),this._updateSecStructure(this._complex),this._updateMolecules(t)},wc.prototype._linkAtomsToResidues=function(){for(var t=0;t=e))for(var a=this._complex._chains[o],s=0;s0&&h.addChain(r[g])}h.matrices=p,t.structures.push(h)}}}},Ec._parseToObject=function(t){function e(t){return 32===t||10===t||13===t||9===t}function r(t,e,r){for(var n=e.length,i=-1;r=u||e(t.charCodeAt(c+1)))){if(p&&59===h){l=c;var i=0;do{if(-1===(l=r(10,t,l+1)))return g="unterminated text block found",null;++i}while(l+1=u);return n=t.substring(c+1,l).replace(/\r/g,""),c=l+2,f+=i,d=1,p=!1,n}if(39===h||34===h){l=c;do{if(-1===(l=r(h,t,l+1)))return g="unterminated quoted string found",null}while(l+10){for(var M=0;M-e.near?"hidden":"visible",s=1e4*(e.far- -this._vector.z)/(e.far-e.near),c=t.getElement();if(void 0===r.fog)c.style.color=i(t.userData.color),"transparent"!==t.userData.background&&(c.style.background=i(t.userData.background));else{var u=xh.smoothstep(-this._vector.z,r.fog.near,r.fog.far);c.style.color=n(t.userData.color,r.fog.color,u),"transparent"!==t.userData.background&&(c.style.background=n(t.userData.background,r.fog.color,u))}this._vector.applyMatrix4(this._projectionMatrix);var h=(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)";c.style.visibility=a,c.style.WebkitTransform=h,c.style.MozTransform=h,c.style.oTransform=h,c.style.transform=h,c.style.zIndex=Number(s).toFixed(0),c.parentNode!==this._domElement&&this._domElement.appendChild(c)}for(var p=0,f=t.children.length;p0&&(this._altObj.setObjects(s.objects),this._altObj.pivot=s.pivot,"axis"in s?this._altObj.axis=s.axis.clone():this._altObj.axis.set(0,0,1),this._altObj.translate(new n(a*i,a*o)),this.dispatchEvent({type:"change",action:"translate"}))}else a*=10*(gp.now.inversePanning?-1:1),this.camera.translateX(a*i),this.camera.translateY(a*o),this.dispatchEvent({type:"change",action:"pan"})}}this._lastUpdateTime=t},Oc.prototype.reset=function(){this._state=Jm.NONE,this.object.quaternion.copy(new c(0,0,0,1))},Oc.prototype.mousedown=function(t){if(!1!==this.enabled&&this._state===Jm.NONE){if(t.preventDefault(),t.stopPropagation(),this._state===Jm.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?Jm.TRANSLATE:Jm.ROTATE}else 2===t.button&&(this._state=Jm.TRANSLATE_PIVOT);this._state===Jm.ROTATE&&(this._mouseCurPos.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos)),this._state!==Jm.TRANSLATE&&this._state!==Jm.TRANSLATE_PIVOT||(this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos))}},Oc.prototype.mousemove=function(t){if(!1!==this.enabled&&this._state!==Jm.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case Jm.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 Jm.TRANSLATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translate();break;case Jm.TRANSLATE_PIVOT:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translatePivotByMouse()}},Oc.prototype.mousewheel=function(t){if(!1!==this.enabled&&gp.now.zooming&&this._state===Jm.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})}},Oc.prototype.mouseup=function(t){!1!==this.enabled&&this._state!==Jm.NONE&&(t.preventDefault(),t.stopPropagation(),this._state=Jm.NONE,this._clock.getElapsedTime()-this._lastMouseMoveTime>.1&&this._affectedObj.stop())},Oc.prototype.touchstartend=function(t){if(!1!==this.enabled)switch(t.preventDefault(),t.stopPropagation(),t.touches.length){case 1:this._state=Jm.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=Jm.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 n(.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=Jm.NONE}},Oc.prototype.touchmove=function(t){if(!1!==this.enabled&&this._state!==Jm.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case Jm.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 Jm.SCALE_PAN:if(gp.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 i=this.object.scale.x,o=this._scaleStart*this._touchDistanceCur/this._touchDistanceStart;this.setScale(o),this.dispatchEvent({type:"change",action:"zoom",factor:0===i?1:o/i})}if(gp.now.panning){var a=new n(.5*(t.touches[0].pageX+t.touches[1].pageX),.5*(t.touches[0].pageY+t.touches[1].pageY));a.sub(this._originalPinchCenter),this.camera.position.x=this._originalCameraPos.x-.1*a.x,this.camera.position.y=this._originalCameraPos.y+.1*a.y,this.dispatchEvent({type:"change",action:"pan"})}}},Oc.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()}},Oc.prototype.getKeyBindObject=function(){return window.top},Oc.prototype.dispose=function(){for(var t=0;t0){var o=e[0],a=new l;if(gp.now.draft.clipPlane&&this.hasOwnProperty("clipPlaneValue")){var s;for(s=0;s=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)}}},Uc.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),c=0;s>1e3&&c>>28,y=kc((268435200&g)>>>8>>0),_=kc(((255&g)<<12|(4293918720&m)>>>20)>>0),x=kc((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}l.push(zc(p,a))}this._secondaryData=l,this._data=u},Uc.prototype.nextFrame=function(){this.setFrame((this._currFrame+1)%this._framesCount)},Uc.prototype.needsColorUpdate=function(t){return t instanceof $s},Uc.prototype.getAtomColor=function(t,e){return t.getResidueColor(this._residues[e._residue._index],this._complex)},Uc.prototype.getResidueColor=function(t,e){return t.getResidueColor(this._residues[e._index],this._complex)},Uc.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)},Uc.prototype.disableEvents=function(){this._callbacks=null},Uc.prototype.getAtomPos=function(){var t=new l;return function(e){var r=this._data,n=3*(this._atomsCount*(this._currFrame-this._framesRange.start)+e);return t.set(r[n],r[n+1],r[n+2]),t}}(),Uc.prototype.getResidues=function(){return this._cachedResidues?this._residues:(this._complex.updateToFrame(this),this._residues)},Bc.prototype.type="__",Bc.prototype.identify=function(){var t={type:this.type,params:this.params},e=fp.objectsDiff(this.opts,gp.now.modes[this.id]);return vl.isEmpty(e)||(t.opts=e),t},Bc.prototype.toString=function(){return"o="+this.type+","+this.params.join(",")+fp.compareOptionsWithDefaults(this.opts,gp.defaults.objects[this.type])},Bc.prototype.getGeometry=function(){return this._mesh},Bc.prototype.destroy=function(){this._mesh&&Cf.destroyObject(this._mesh)},fp.deriveClass(Vc,Bc,{type:"line"}),Vc.prototype.constructor=Vc,Vc.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},Vc.prototype.build=function(t){var e=new gt;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 gd.Line(e,new jo({lights:!1,overrideColor:!0,dashedLine:!0})),this._line.material.setUberOptions({fixedColor:new X(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 _e,this._mesh.add(this._line),Cf.applyTransformsToMeshes(this._mesh,r))},Vc.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 ig="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",og="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",ag=Rh.merge([{srcTex:{type:"t",value:null},srcTexSize:{type:"v2",value:new n(512,512)},opacity:{type:"f",value:1}}]),sg="// 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",cg=Rh.merge([{srcTex:{type:"t",value:null},srcTexelSize:{type:"v2",value:new n(1/512,1/512)}}]),lg="#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}",ug="#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",hg="#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}",pg=Rh.merge([{noiseTexture:{type:"t",value:null},noiseTexelSize:{type:"v2",value:new n(1/512,1/512)},diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new n(1/512,1/512)},camNearFar:{type:"v2",value:new n(1,10)},projMatrix:{type:"mat4",value:new u},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 n(100,100)}}]),fg=Rh.merge([{diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new n(1/512,1/512)},aoMap:{type:"t",value:null},samplesOffsets:{type:"fv1",value:null},camNearFar:{type:"v2",value:new n(1,10)},projMatrix:{type:"mat4",value:new u},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0}}]),dg={AOMaterial:function(t){return new Q({uniforms:Wc(t,pg),vertexShader:ig,fragmentShader:lg,transparent:!1,depthTest:!1,depthWrite:!1})},HorBilateralBlurMaterial:function(t){return new Q({uniforms:Wc(t,fg),vertexShader:ig,fragmentShader:ug,transparent:!1,depthTest:!1,depthWrite:!1})},VertBilateralBlurMaterial:function(t){return new Q({uniforms:Wc(t,fg),vertexShader:ig,fragmentShader:hg,transparent:!1,depthTest:!1,depthWrite:!1})}},mg="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",gg=Rh.merge([{srcL:{type:"t",value:null},srcR:{type:"t",value:null}}]);Xc.prototype.set=function(t,e,r){this.position=t,this.scale=e,this.orientation=r};Yc.prototype.setup=function(t,e){this._startTime=void 0,this._endTime=void 0,this._srcView=t,this._dstView=e,this._isMoving=!1},Yc.prototype.isMoving=function(){return this._isMoving},Yc.prototype.wasStarted=function(){return void 0!==this._startTime&&void 0!==this._endTime},Yc.prototype.start=function(){this._startTime=Date.now();var t=gp.now.interpolateViews?1500:0;this._endTime=this._startTime+t,this._isMoving=!0},Yc.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}},Yc.prototype._reset=function(){this._startTime=this._endTime=0,this._isMoving=!1},Yc.prototype.createView=function(){return new Xc};var vg=new Yc,yg=gp.now.fbxprec,_g='; 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',xg='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',bg=null;$c.prototype.queue=[],$c.prototype.busy=!1,$c.prototype.add=function(t,e,r,n){this.queue.push([t,e,r,n]),this.busy||this.next()},$c.prototype.next=function(){var t=this.queue.shift(),e=this;t&&!e.busy&&(this.busy=!0,function(t,e,r,n,i){bg.root.getFile(t,{create:!n},function(t){t.createWriter(function(t){var o=new Blob([e],{type:r?"octet/stream":"text/plain"});n?(t.onwriteend=function(){i()},t.seek(t.length),t.write(o)):(t.onwriteend=function(){0===t.length&&e.length>0?t.write(o):i()},t.truncate(0))},qc)},qc)}(t[0],t[1],t[2],t[3],function(){e.busy=!1,e.next()}))};Xo(el.prototype),el.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?(i.selectionRoot.matrix=i.root.matrix,i.selectionPivot.matrix=i.pivot.matrix,i.renderer.render(i.selectionScene,e,r)):i.renderer.renderDummyQuad(r),i.renderer.renderScreenQuadFromTex(r.texture,.6,n),t.uniforms.srcTex.value=r.texture,t.uniforms.srcTexSize.value.set(r.width,r.height),i.renderer.renderScreenQuad(t,n)}}(),ol.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)},ol.prototype._renderVolume=function(){var t,e=new rm.BackFacePosMaterial,r=new rm.FrontFacePosMaterial,n=(new u).makeTranslation(.5,.5,.5),i=new u;return function(o,a,s,c,l,u){var h=this._gfx;if(void 0===t&&(t=this._checkVolumeRenderingSupport(c)),t){var p=o.getMesh();p.rebuild(a),h.renderer.setClearColor("black",0),h.renderer.clearTarget(c),h.renderer.clearTarget(l),h.renderer.clearTarget(u),a.layers.set(Cf.LAYERS.VOLUME_BFPLANE),h.renderer.render(h.scene,a,c),a.layers.set(Cf.LAYERS.VOLUME),h.scene.overrideMaterial=e,h.renderer.render(h.scene,a,c),a.layers.set(Cf.LAYERS.VOLUME),h.scene.overrideMaterial=r,h.renderer.render(h.scene,a,l),h.scene.overrideMaterial=null,a.layers.set(Cf.LAYERS.DEFAULT),i.getInverse(p.matrixWorld),jo.prototype.uberOptions.world2colorMatrix.multiplyMatrices(n,i),this._setUberMaterialValues({colorFromPos:!0}),h.renderer.render(h.scene,a,u),this._setUberMaterialValues({colorFromPos:!1});var f=p.material;f.uniforms._BFRight.value=c.texture,f.uniforms._FFRight.value=l.texture,f.uniforms._WFFRight.value=u.texture,a.layers.set(Cf.LAYERS.VOLUME),h.renderer.render(h.scene,a,s),a.layers.set(Cf.LAYERS.DEFAULT)}}}(),ol.prototype._renderWithPrepassTransparency=function(t,e){var r=this._gfx;t.layers.set(Cf.LAYERS.DEFAULT),r.renderer.render(r.scene,t,e),t.layers.set(Cf.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(Cf.LAYERS.TRANSPARENT),r.renderer.render(r.scene,t,e),t.layers.set(Cf.LAYERS.DEFAULT)},ol.prototype._performFXAA=function(){var t=new Gc;return function(e,r){if(void 0!==e&&void 0!==r){var n=this._gfx;n.renderer.setClearColor(gp.now.themes[gp.now.theme],1),n.renderer.clearTarget(r),t.uniforms.srcTex.value=e.texture,t.uniforms.srcTexelSize.value.set(1/e.width,1/e.height),t.transparent=!0,n.renderer.renderScreenQuad(t,r)}}}(),ol.prototype._performAO=function(){var t=new dg.AOMaterial,e=new dg.HorBilateralBlurMaterial,r=new dg.VertBilateralBlurMaterial,n=new h(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,Wu,Ru,300,wu,wu,Au,Au,1);n.needsUpdate=!0;var i=[new l(.295184,.077723,.068429),new l(-.271976,-.365221,.838363),new l(.547713,.467576,.488515),new l(.662808,-.031733,.584758),new l(-.025717,.218955,.657094),new l(-.310153,-.365223,.370701),new l(-.101407,-.006313,.747665),new l(-.769138,.360399,.086847),new l(-.271988,-.27514,.905353),new l(.09674,-.566901,.700151),new l(.562872,-.735136,.094647),new l(.379877,.359278,.190061),new l(.519064,-.023055,.405068),new l(-.301036,.114696,.088885),new l(-.282922,.598305,.487214),new l(-.181859,.25167,.679702),new l(-.191463,-.635818,.512919),new l(-.293655,.427423,.078921),new l(-.267983,.680534,.13288),new l(.139611,.319637,.477439),new l(-.352086,.31104,.653913),new l(.321032,.805279,.487345),new l(.073516,.820734,.414183),new l(-.155324,.589983,.41146),new l(.335976,.170782,.527627),new l(.46346,-.355658,.167689),new l(.222654,.59655,.769406),new l(.922138,-.04207,.147555),new l(-.72705,-.329192,.369826),new l(-.090731,.53382,.463767),new l(-.323457,-.876559,.238524),new l(-.663277,-.372384,.342856)],o=[-2,-1,0,1,2];return function(a,s,u,h,p){if(void 0!==a&&void 0!==s&&void 0!==u&&void 0!==h&&void 0!==p){var f=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(f.camera.near,f.camera.far),t.uniforms.projMatrix.value=f.camera.projectionMatrix,t.uniforms.aspectRatio.value=f.camera.aspect,t.uniforms.tanHalfFOV.value=Math.tan(.5*xh.DEG2RAD*f.camera.fov),t.uniforms.samplesKernel.value=i;var d=new l,m=new c,g=new l;f.root.matrix.decompose(d,m,g),t.uniforms.kernelRadius.value=gp.now.debug.ssaoKernelRadius*g.x,t.uniforms.depthThreshold.value=2*this._getBSphereRadius(),t.uniforms.factor.value=gp.now.debug.ssaoFactor,t.uniforms.noiseTexture.value=n,t.uniforms.noiseTexelSize.value.set(.25,.25);var v=f.scene.fog;v&&t.uniforms.fogNearFar.value.set(v.near,v.far),t.transparent=!1,f.renderer.renderScreenQuad(t,p),e.uniforms.aoMap.value=p.texture,e.uniforms.srcTexelSize.value.set(1/p.width,1/p.height),e.uniforms.depthTexture.value=s,e.uniforms.samplesOffsets.value=o,f.renderer.renderScreenQuad(e,h),r.uniforms.aoMap.value=h.texture,r.uniforms.diffuseTexture.value=a.texture,r.uniforms.srcTexelSize.value.set(1/h.width,1/h.height),r.uniforms.depthTexture.value=s,r.uniforms.samplesOffsets.value=o,f.renderer.renderScreenQuad(r,u)}}}(),ol.prototype.reset=function(){this._picker&&this._picker.reset(),this._lastPick=null,this._releaseAllVisuals(),this._setEditMode(Cg.COMPLEX),this._resetObjects(),this._gfx&&(Cf.clearTree(this._gfx.pivot),this._gfx.renderer2d.reset()),this.setNeedRender()},ol.prototype._resetScene=function(){this._objectControls.reset(),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this.resetReps(),this.resetPivot(),this.rebuildAll()},ol.prototype.resetView=function(){this._picker&&this._picker.reset(),this._setEditMode(Cg.COMPLEX),this._resetScene(),this._forEachComplexVisual(function(t){t.updateSelectionMask({}),t.rebuildSelectionGeometry()})},ol.prototype.load=function(t,e){var r=this;r._loader&&r._loader.cancel(),r.dispatchEvent({type:"load",options:e}),t instanceof File&&t.name.match(/.man$/i)?this._fileSourceAnim=nl(t):this._fileSource=nl(t),e&&e.mdFile&&(this._fileSourceAnim=e.mdFile),this.settings.now.use.multiFile||e&&e.animation||this.reset(!0),r._loader=new Ci,r._loader.addEventListener("notification",function(t){r.dispatchEvent(t.slaveEvent)}),r._spinner.spin(this._container);var n=function(t){return r._loader=null,r._spinner.stop(),r._refreshTitle(),t};return function(t,e,r,n){return new Promise(function(i,o){if(e=e||{},t instanceof File&&t.name.match(/.man$/i)&&(e.binary=!0,e.animation=!0),t instanceof File&&(t.name.match(/.mmtf$/i)||t.name.match(/.ccp4$/i))?e.binary=!0:vl.isString(t)&&t.match(/.mmtf$/i)&&(e.binary=!0),!e.mdFile&&!e.fileType&&"string"==typeof t){var a=t.match(/^(?:\s*([+\w]+)\s*:)?\s*(.*)$/);if(a){var s=a[2].trim(),c=a[1];switch(c){case"pubchem":case"pubchem+json":c="pubchem+json",t="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/"+encodeURIComponent(s)+"/JSON?record_type=3d",e.sourceType="url",e.fileName=s+".json";break;default:if(s.match(/^\w{4}$/i))switch(c=c||"pdb"){case"mmtf":t="http://mmtf.rcsb.org/v1.0/full/"+s,e.sourceType="url";break;case"cif":case"pdb":t="http://files.rcsb.org/view/"+s+"."+c,e.sourceType="url"}else c=void 0}c&&(e.fileType=c)}}"mmtf"===e.fileType&&(e.binary=!0);var l=Km.loaders.create(n,t,e),u=vl.get(e,"preset.expression");if(!vl.isUndefined(u)&&(u=JSON.parse(u))&&u.settings)for(var h=["singleUnit","draft.waterBondingHack"],p=0,f=h.length;p0?"Bio molecule "+n:"Asymmetric unit")+")"}if(!r)throw new Error("There is no complex to change!");return r.getComplex().setCurrentStructure(t)&&this._resetScene(),""},ol.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})}},ol.prototype.rebuildAll=function(){this._forEachComplexVisual(function(t){t.setNeedsRebuild()})},ol.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})},ol.prototype.setNeedRender=function(){this._needRender=!0},ol.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"}))},ol.prototype._setReps=function(t){t=t||this._opts&&this._opts.reps||[],this._forEachComplexVisual(function(e){return e.resetReps(t)})},ol.prototype.applyPreset=function(t){for(var e=gp.now.presets,r=[t||gp.defaults.preset,gp.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(Cg.FRAGMENT),this._objectControls.allowTranslation(!1),this._objectControls.allowAltObjFreeRotation(e.isFreeRotationAllowed()),this._needRender=!0)}}},ol.prototype._applyFragmentEdit=function(){if(this._editMode===Cg.FRAGMENT){this._objectControls.stop();for(var t=0;t0){if(t){t=null;break}t=r}}if(t)return t}return{objects:[],pivot:new l(0,0,0)}},ol.prototype.resetPivot=function(){var t=new et;this._forEachVisual(function(e){t.union(e.getBoundaries().boundingBox)}),t.getCenter(this._gfx.pivot.position),this._gfx.pivot.position.negate(),this.dispatchEvent({type:"transform"})},ol.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()})},ol.prototype.screenshot=function(t,e){var r=this._gfx;e=e||t||r.height;var n;if((t=t||r.width)===r.width&&e===r.height)n=r.renderer.domElement.toDataURL("image/png");else{var i=r.camera.aspect,o=r.camera.fov,a=function(t){return Math.tan(xh.degToRad(.5*t))}(r.camera.fov)*Math.min(r.width,r.height)/r.height,s=t/e;r.camera.aspect=s,r.camera.fov=function(t){return 2*xh.radToDeg(Math.atan(t))}(a/Math.min(s,1)),r.camera.updateProjectionMatrix(),r.renderer.setSize(t,e),this._renderFrame("NONE"),n=r.renderer.domElement.toDataURL("image/png"),r.camera.aspect=i,r.camera.fov=o,r.camera.updateProjectionMatrix(),r.renderer.setSize(r.width,r.height),this._needRender=!0}return n},ol.prototype.screenshotSave=function(t,e,r){var n=this.screenshot(e,r);fp.shotDownload(n,t)},ol.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;nn?(o=!1,r.preset="empty"):gp.now.preset!==gp.defaults.preset&&(r.preset=gp.now.preset);for(var a=[],s=!0,c=0,l=n;c0&&(e._objects=a),t.view&&(e.view=this.view()),t.settings){var l=this.settings.getDiffs(!1);vl.isEmpty(l)||(e.settings=l)}return e},ol.prototype.get=function(t,e){return gp.get(t,e)},ol.prototype._clipPlaneUpdateValue=function(t){var e=Math.max(this._gfx.camera.position.z-t*gp.now.draft.clipPlaneFactor,gp.now.camNear),r={clipPlaneValue:e};this._forEachComplexVisual(function(t){t.setUberOptions(r)});for(var n=0,i=this._objects.length;n2&&E.push("'"+this.terminals_[S]+"'");T=f.showPosition?"Parse error on line "+(l+1)+":\n"+f.showPosition()+"\nExpecting "+E.join(", ")+", got '"+(this.terminals_[y]||y)+"'":"Parse error on line "+(l+1)+": Unexpected "+(y==h?"end of input":"'"+(this.terminals_[y]||y)+"'"),this.parseError(T,{text:f.match,token:this.terminals_[y]||y,line:f.yylineno,loc:g,expected:E})}if(b[0]instanceof Array&&b.length>1)throw new Error("Parse Error: multiple actions possible at state: "+x+", token: "+y);switch(b[0]){case 1:n.push(y),o.push(f.yytext),a.push(f.yylloc),n.push(b[1]),y=null,_?(y=_,_=null):(u=f.yyleng,c=f.yytext,l=f.yylineno,g=f.yylloc);break;case 2:if(M=this.productions_[b[1]][1],C.$=o[o.length-M],C._$={first_line:a[a.length-(M||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(M||1)].first_column,last_column:a[a.length-1].last_column},v&&(C._$.range=[a[a.length-(M||1)].range[0],a[a.length-1].range[1]]),void 0!==(w=this.performAction.apply(C,[c,u,l,d.yy,b[1],o,a].concat(p))))return w;M&&(n=n.slice(0,-1*M*2),o=o.slice(0,-1*M),a=a.slice(0,-1*M)),n.push(this.productions_[b[1]][0]),o.push(C.$),a.push(C._$),A=s[n[n.length-2]][n[n.length-1]],n.push(A);break;case 3:return!0}}return!0}},St={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];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;return 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;this._input||(this.done=!0);var t,e,r,n;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}}};return wt.lexer=St,t.prototype=wt,wt.Parser=t,new t}();void 0!==t&&(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=qp.readFileSync($p.normalize(t[1]),"utf8");return r.parser.parse(e)},t.main===e&&r.main(process.argv.slice(1)))}),Rg=Lg.parser,Ng=(Lg.Parser,Lg.parse,Lg.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"]}}),Ig={$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(Gd.get(gp.now.palette).namedColors).sort().join("\n")}}},Og={$help:["Material shortcut"," DF - diffuse"," TR - transparent"," SF - soft plastic"," PL - glossy plastic"," ME - metal"," GL - glass"]},Dg={$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:Ng,c:Ig,mt:Og},Fg={$help:["Parameters of rendering modes customization: modes","Parameters of colorer customization: colorers","Autobuild: autobuild = (|)"],modes:Ng,colorers:Ig},zg={$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:Dg},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:Dg},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:Ng},color:{$help:["color [=...]"," set colorer and apply parameters to current representation"],COLORER_ID:Ig},material:{$help:["material "," set material to current representation"],MATERIAL_ID:Og},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:Fg},set:{$help:["set ","Set with "," - path to option use set.PARAMETER to get more info"],PARAMETER:Fg},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"]}},kg=function(){function t(){yp(this,t)}return _p(t,[{key:"createSelectorFromNode",value:function(t){return cl(t)}}]),t}(),Ug=ol.chem.selectors,Bg=ol.modes,Vg=ol.colorers,jg=ol.materials,Gg=ol.palettes,Wg=ol.options,Hg=ol.settings,Xg=function(){var t=new function(){};return function(){return t}}();ll.prototype.get=function(t){return this.representationMap[t]||this.representationID[t]||""},ll.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"},ll.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])}},ll.prototype.clear=function(){this.representationMap={},this.representationID={}};var Yg=new ll;ul.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 : "'+l+'"\n',i+=" mode : ("+c.id+"), "+c.name+"\n",i+=" colorer : ("+u.id+"), "+u.name+"\n",i+=" material : ("+h.id+"), "+h.name+"\n"),i},ul.prototype.listSelector=function(t,e){var r="";for(var n in e)e.hasOwnProperty(n)&&(r+=n+' : "'+e[n]+'"\n');return r},ul.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 "'+vp(vl.get(Hg.defaults,t))+'"'};if("theme"===t){for(var i=Object.keys(Hg.defaults.themes),o=!1,a=0;a1?(void 0!==n&&n("There are two or more files, please specify one by file_id"),i.finish(t)):void 0!==r?r(a[0].id):i.finish(t)}else i.finish(t)},function(e){void 0!==e&&void 0!==n&&n(e),i.finish(t)})},fl.prototype.requestPdbID=function(t,e,r,n){var i=this,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)}},fl.prototype.requestPresetId=function(t,e,r,n){function i(e){void 0!==e&&void 0!==n&&n(e),a.finish(t)}function o(e){if(e instanceof Array){var i=vl.filter(e,function(t){return t.name.toLowerCase()===s[1].toLowerCase()||t.id===Number(s[1])});i.length<1?(void 0!==n&&n("Preset not found"),a.finish(t)):i.length>1?(void 0!==n&&n("There are two or more presets, please specify one by preset_id"),a.finish(t)):void 0!==r?r(i[0].id):a.finish(t)}else a.finish(t)}var a=this,s=e.split("/");t.awaitWhileCMDisInProcess(),2!==s.length?(void 0!==n&&n("Path can has 2 levels only (pdb/preset)"),a.finish(t)):this.requestPdbID(t,s[0],function(e){t.srvPresetList(e,o,i)},i)},fl.prototype.createScenario=function(t){this.scenarioContext=new pl(t)},fl.prototype.resetScenario=function(){this.scenarioContext=new pl},fl.prototype.deleteScenario=function(t,e,r,n){function i(r){void 0!==r&&e(r),s.finish(t)}function o(e){void 0!==e&&r(e),s.finish(t)}function a(e){t.srvScenarioDelete(e,i,o),s.finish(t)}var s=this;this.init(t,e),t.awaitWhileCMDisInProcess(),"number"==typeof n?a(n):this.requestScenarioID(t,n,a,o)},fl.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 o.finish(t);if(7!==arguments.length)return 5===arguments.length?(r("not supported now"),void o.finish(t)):(r("internal interpreter error"),void o.finish(t));var s=arguments[3],c=arguments[4],l=arguments[5],u=arguments[6];if(vl.isString(s))this.requestPdbID(t,s,function(t){t>=0&&(a[3]=t,o.addScenarioItem.apply(o,a))},i);else if(vl.isString(c))this.requestPresetId(t,s+"/"+c,function(t){t>=0&&(a[4]=t,o.addScenarioItem.apply(o,a))},i);else{if("number"!=typeof s||"number"!=typeof c)return i("Internal error"),void o.finish(t);!function(e,r,a,s){o.scenarioContext.script.addItem(o.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}(e,r,a,s)),t.srvScenarioAdd(o.scenarioContext.id,o.scenarioContext.name,JSON.stringify(o.scenarioContext.script),n,i)}(s,c,l,u)}},fl.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)},fl.prototype.finish=function(t){t.finishAwaitingCMDInProcess()},fl.prototype.fileList=function(t,e,r,n,i){function o(r){if(void 0!==r)for(var n=0;n1?(r("There are two or more presets, please specify one by preset_id"),l.finish(t)):void 0===o?i.call(t,n[0].id,a,c):i.call(t,n[0].id,o,a,c)}else l.finish(t)}function c(e){void 0!==e&&r(e),l.finish(t)}var l=this;this.init(t,e),t.awaitWhileCMDisInProcess();var u=n.split("/");2!==u.length?(r("Path can has 2 levels only (pdb/preset)"),l.finish(t)):t.srvTopologyFind(u[0],function(e){e instanceof Array?e.length<1?(r("File not found"),l.finish(t)):e.length>1?(r("There are two or more files, please specify one by file_id"),l.finish(t)):t.srvPresetList(e[0].id,s,c):l.finish(t)},c)},fl.prototype.coroutineWithFileName=function(t,e,r,n,i){function o(r){void 0!==r&&e(r),s.finish(t)}function a(e){void 0!==e&&r(e),s.finish(t)}var s=this,c=arguments;this.init(t),t.awaitWhileCMDisInProcess();var l=n.split("/");1!==l.length?(r("Path can contain only file name or id"),s.finish(t)):t.srvTopologyFind(l[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(c.length){case 5:i.call(t,e[0].id,o,a);break;case 6:i.call(t,e[0].id,c[5],o,a);break;case 9:i.call(c[5],c[6],c[7],c[8],e[0].id);break;case 10:i.call(c[5],c[6],c[7],c[8],e[0].id,c[9]);break;default:s.finish(t)}s.finish(t)},a)};var $g=new fl;ml.prototype.append=function(t){var e=this._values;return e[e.length]=t,this},ml.prototype.remove=function(t){var e=this._values,r=e.indexOf(t);return r>=0&&e.splice(r,1),this},ml.prototype.toJSO=function(t,e,r){for(var n={},i=this._values,o=0,a=i.length;o0},ol.prototype.callNextCmd=function(){if(this.isScriptingCommandAvailable()){var t=this.cmdQueue.shift(),e={};e.success=!1;try{Rg.parse(t),e.success=!0}catch(t){e.error=t.message,Rg.yy.error(e.error),this.finishAwaitingCMDInProcess()}return e}return""},ol.JSONConverter=kg,Rg.yy=Zg,Rg.yy.parseError=Rg.parseError,ol}); +(function(){var t,r,n,i,o,a,s,c,l,u,h,p,f,d,m,g,v,y,_,x,b,w,S,M,A,E,C=Object.prototype.hasOwnProperty,T=function(t,e){function r(){this.constructor=t}for(var n in e)C.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};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},l=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 r=2*(e-1),(t=h(t,r))>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}(),f=function(t,e){var r,n,i,o;for(o=[],n=0,i=t.length;na;0<=a?l++:l--)r.push(new h(f(t,l),e));return r}(),function(t){var e,r,n,i;for(i=[],r=0,n=m.length;r1&&0!==C&&(u.lerpVectors(_,x,.15/S),h.lerpVectors(_,x,1-.15/S)),C*=.15,u.addScaledVector(M,C),h.addScaledVector(M,C),o.setItem(p,u,h),o.setColor(p++,i.getAtomColor(v,r),i.getAtomColor(y,r))}}o.finalize(),this._chunksIdc=f},xs.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(),c=new l,u=new l,h=new l,p=0,f=t.needsColorUpdate(i),d=0,m=e.length;d1&&0!==C&&(u.lerpVectors(_,x,.15/S),h.lerpVectors(_,x,1-.15/S)),C*=.15,u.addScaledVector(M,C),h.addScaledVector(M,C),o.setItem(p,u,h),f&&o.setColor(p,t.getAtomColor(i,v),t.getAtomColor(i,y)),p++}}o.finalize()};var Rd=Ka,Nd=Qa,Id=Ja,Od=rs,Dd=os,Fd=as,zd=ls,kd=us,Ud=gs,Bd=vs,Vd=_s,jd=xs;(bs.prototype=Object.create(qo.prototype)).constructor=bs,bs.prototype._checkAtom=function(t,e){return t._mask&e},bs.prototype.getSubset=function(t,e){for(var r=[],n=this.children,i=0,o=0,a=n.length;o0&&s.add(h)}return s},(Is.prototype=Object.create(Ns.prototype)).constructor=Is,Is.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")},Is.prototype.buildGeometry=function(t,e,r,n){return this.update(),Ns.prototype.buildGeometry.call(this,t,e,r,n)},_p.deriveClass(Ds,Is,{id:"LN",name:"Lines",shortName:"Lines",depGroups:["ALoopsLines","BondsLines","OrphanedAtomsCrosses"]}),Ds.prototype.drawMultiorderBonds=function(){return this.opts.multibond},Ds.prototype.calcAtomRadius=function(){return this.opts.atom},Ds.prototype.getAromaticOffset=function(){return this.opts.offsarom},Ds.prototype.getAromaticArcChunks=function(){return this.opts.chunkarom},Ds.prototype.showAromaticLoops=function(){return this.opts.showarom},Ds.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!0,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},_p.deriveClass(Fs,Is,{id:"LC",name:"Licorice",shortName:"Licorice",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),Fs.prototype.calcAtomRadius=function(t){return this.opts.bond},Fs.prototype.calcStickRadius=function(){return this.opts.bond},Fs.prototype.calcSpaceFraction=function(){return this.opts.space},Fs.prototype.getAromRadius=function(){return this.opts.aromrad},Fs.prototype.showAromaticLoops=function(){return this.opts.showarom},Fs.prototype.drawMultiorderBonds=function(){return this.opts.multibond},Fs.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},_p.deriveClass(zs,Is,{id:"BS",name:"Balls and Sticks",shortName:"Balls",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),zs.prototype.calcAtomRadius=function(t){return t.element.radius*this.opts.atom},zs.prototype.calcStickRadius=function(){return this.opts.bond},zs.prototype.getAromRadius=function(){return this.opts.aromrad},zs.prototype.showAromaticLoops=function(){return this.opts.showarom},zs.prototype.calcSpaceFraction=function(){return this.opts.space},zs.prototype.drawMultiorderBonds=function(){return this.opts.multibond},zs.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},_p.deriveClass(ks,Ns,{id:"VW",name:"Van der Waals",shortName:"VDW",depGroups:["AtomsSpheres"]}),ks.prototype.calcAtomRadius=function(t){return t.element.radius},_p.deriveClass(Us,Ns,{id:"TR",name:"Trace",shortName:"Trace",depGroups:["TraceChains"]}),Us.prototype.calcStickRadius=function(){return this.opts.radius},_p.deriveClass(Bs,Ns,{id:"TU",name:"Tube",shortName:"Tube",depGroups:["CartoonChains"]}),Bs.prototype.getResidueRadius=function(t){return this.TUBE_RADIUS},Bs.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},Bs.prototype.getTension=function(){return this.opts.tension},Bs.prototype.buildGeometry=function(t,e,r,i){var o=this.opts.radius;return this.TUBE_RADIUS=new n(o,o),Ns.prototype.buildGeometry.call(this,t,e,r,i)},_p.deriveClass(Vs,Ns,{id:"CA",name:"Cartoon",shortName:"Cartoon",depGroups:["CartoonChains","NucleicSpheres","NucleicCylinders"]}),Vs.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},Vs.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},Vs.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)},Vs.prototype.calcStickRadius=function(t){return this.opts.radius},Vs.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},Vs.prototype.getTension=function(){return this.opts.tension},Vs.prototype.buildGeometry=function(t,e,r,i){var o=this.opts.radius,a=this.opts.depth;this.TUBE_RADIUS=new n(o,o),this.ARROW_END=new n(a,o);var s={},c=this.opts.ss;for(var l in c)s[l]={center:new n(a,c[l].width),start:new n(a,c[l].arrow)};return this.secCache=s,Ns.prototype.buildGeometry.call(this,t,e,r,i)};var $d=Tf.selectors;_p.deriveClass(Gs,Ns,{isSurface:!0,surfaceNames:[]}),Gs.prototype.calcAtomRadius=function(t){return t.element.radius},Gs.prototype.getVisibilitySelector=function(){var t=null;if(""!==this.opts.subset){var e=$d.parse(this.opts.subset);e.error||(t=e.selector)}return t},_p.deriveClass(Ws,Gs,{id:"QS",name:"Quick Surface",shortName:"Quick Surf",surfaceNames:["QuickSurfGeo"]}),Ws.prototype.getSurfaceOpts=function(){return{useBeads:!1,isoValue:this.opts.isoValue,gaussLim:this.opts.gaussLim[this.settings.now.resolution],radScale:this.opts.scale,gridSpacing:this.opts.gridSpacing[this.settings.now.resolution],zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector()}},_p.deriveClass(Hs,Gs,{id:"SU",name:"Surface",shortName:"Surface",surfaceNames:["SASSESSurfaceGeo"]}),Hs.prototype._radScale=1,Hs.prototype._isVertexNormalsRendered=!1,Hs.prototype._isSurfaceTransparent=!1,Hs.prototype._clusterViaKMeans=0,Hs.prototype._excludeProbe=!1,Hs.prototype.calcAtomRadius=function(t){return t.element.radius},Hs.prototype.getSurfaceOpts=function(){return{gridSpacing:this.opts.polyComplexity[this.settings.now.resolution],radScale:this._radScale,zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector(),probeRadius:this.opts.probeRadius,excludeProbe:this._excludeProbe,clusterizationType:this._clusterViaKMeans}},_p.deriveClass(Xs,Hs,{id:"SA",name:"Solvent Accessible Surface",shortName:"SAS"}),_p.deriveClass(Ys,Hs,{id:"SE",name:"Solvent Excluded Surface",shortName:"SES"}),_p.deriveClass(qs,Gs,{id:"CS",name:"Contact Surface",shortName:"Contact Surf",isSurface:!0,surfaceNames:["ContactSurfaceGeo"]}),qs.prototype.getSurfaceOpts=function(){return{probeRadius:this.opts.probeRadius,radScale:this.opts.polyComplexity[this.settings.now.resolution],scaleFactor:this.opts.polyComplexity[this.settings.now.resolution],gridSpacing:1/this.opts.polyComplexity[this.settings.now.resolution],isoValue:this.opts.isoValue,probePositions:this.opts.probePositions,zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector()}},_p.deriveClass(Zs,Ns,{id:"TX",name:"Text mode",shortName:"Text",depGroups:["TextLabelsGeo"]}),Zs.prototype.getTemplateOptions=function(){return this.opts.template},Zs.prototype.getLabelOpts=function(){return _.merge(this.opts,{labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0})};var Kd=[],Qd={};!function(t){for(var e=0,r=t.length;e=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=this.gradients[e];if(r){var n=r.length,i=t*(n-1),o=Math.floor(i),a=$s(o+1,0,n-1);return o=$s(o,0,n-1),function(t,e,r){var n=1-r;return n*(t>>16&255)+r*(e>>16&255)<<16|n*(t>>8&255)+r*(e>>8&255)<<8|n*(255&t)+r*(255&e)}(r[o],r[a],i-o)}return this.defaultNamedColor},getNamedColor:function(t,e){var r=this.namedColors[t];return void 0!==r||e?r:this.defaultNamedColor}}).namedColorsArray,em=Ks.prototype.namedColors,rm=0,nm=tm.length;rm=0?this.opts.carbon:this.palette.getElementColor(r)},Js.prototype.getResidueColor=function(t,e){return this.palette.defaultResidueColor},_p.deriveClass(tc,Qs,{id:"RT",name:"Residue Type",shortName:"Residue"}),tc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},tc.prototype.getResidueColor=function(t,e){return this.palette.getResidueColor(t._type._name)},_p.deriveClass(ec,Qs,{id:"SQ",aliases:["RI"],name:"Sequence",shortName:"Sequence"}),ec.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},ec.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)},_p.deriveClass(rc,Qs,{id:"CH",name:"Chain",shortName:"Chain"}),rc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},rc.prototype.getResidueColor=function(t,e){return this.palette.getChainColor(t.getChain()._name)},_p.deriveClass(nc,Qs,{id:"SS",name:"Secondary Structure",shortName:"Structure"}),nc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},nc.prototype.getResidueColor=function(t,e){if(t._type.flags&Ji.Flags.DNA)return this.palette.getSecondaryColor("dna");if(t._type.flags&Ji.Flags.RNA)return this.palette.getSecondaryColor("rna");var r=t.getSecondary();return r?this.palette.getSecondaryColor(r.type,r._type):this.palette.getSecondaryColor("")},_p.deriveClass(ic,Qs,{id:"UN",name:"Uniform",shortName:"Uniform"}),ic.prototype.getAtomColor=function(t,e){return this.opts.color},ic.prototype.getResidueColor=function(t,e){return this.opts.color},_p.deriveClass(oc,Qs,{id:"CO",name:"Conditional",shortName:"Conditional"}),oc.prototype.getAtomColor=function(t,e){return this._subsetCached.includesAtom(t)?this.opts.color:this.opts.baseColor},oc.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},sc.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===Tf.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},_p.deriveClass(cc,Qs,{id:"OC",name:"Occupancy",shortName:"Occupancy"}),cc.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},cc.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===Tf.Element.Constants.Lead&&(n=t._occupancy)}),n>0){var i=1-n;return this.palette.getGradientColor(i,r.gradient)}return this.palette.defaultResidueColor},_p.deriveClass(lc,Qs,{id:"HY",name:"Hydrophobicity",shortName:"Hydrophobicity"}),lc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},lc.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},_p.deriveClass(uc,Qs,{id:"MO",name:"Molecule",shortName:"Molecule"}),uc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},uc.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 dm=[],mm={};!function(t){for(var e=0,r=t.length;e0){(e=new _e).matrixAutoUpdate=!1,e.matrix=this.geo.matrix;for(var n=0;n2)return gp.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 gp.error("Rep "+t+" does not exist!"),null;t===this._reprList.length&&(this.repAdd(e),e=void 0,gp.warn("Rep "+t+" does not exist! New representation was created."));var r=this._reprList[t],n={selector:r.selectorString,mode:r.mode.identify(),colorer:r.colorer.identify(),material:r.materialPreset.id};if(e){var i=!1;if(e.selector){var o=Sm.parse(e.selector).selector,a=String(o);n.selector!==a&&(r.selectorString=n.selector=a,r.selector=o,r.markAtoms(this._complex),i=!0,gp.debug("rep["+t+"].selector changed to"+a))}if(e.mode){var s=e.mode;Sl.isEqual(n.mode,s)||(n.mode=s,r.setMode(Jd.create(e.mode)),i=!0,gp.debug("rep["+t+"].mode changed to "+s),!r.mode.isSurface||"ultra"!==Lp.now.resolution&&"high"!==Lp.now.resolution||(gp.report('Surface resolution was changed to "medium" to avoid hang-ups.'),Lp.now.resolution="medium"))}if(e.colorer){var c=e.colorer;Sl.isEqual(n.colorer,c)||(n.colorer=c,r.colorer=gm.create(e.colorer),i=!0,gp.debug("rep["+t+"].colorer changed to "+c))}if(e.material){var l=e.material;Sl.isEqual(n.material,l)||(n.material=l,r.setMaterialPreset(bm.get(e.material)),i=!0,gp.debug("rep["+t+"].material changed to"+l))}i&&(r.needsRebuild=!0)}return n},vc.prototype.repGet=function(t){return(void 0===t||t instanceof Object)&&(t=this.repCurrent()),t<0||t>=this._reprList.length?null:this._reprList[t]},vc.prototype._getFreeReprIdx=function(){for(var t=this._reprUsedBits,e=0;e<=vc.NUM_REPRESENTATION_BITS;++e,t>>=1)if(0==(1&t))return e;return-1},vc.prototype.repAdd=function(t){if(this._reprList.length>=vc.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)}},vc.prototype.select=function(t,e){e?this._selectionCount+=this._complex.markAtomsAdditionally(t,1<0&&(a=Sm.chain(r),o=o?Sm.or(o,a):a),Object.keys(e).length>0)for(var s in e)e.hasOwnProperty(s)&&(a=Sm.and(Sm.chain(s),Sm.residx(n(e[s]))),o=o?Sm.or(o,a):a);t.length>0&&(a=Sm.serial(n(t)),o=o?Sm.or(o,a):a),o||(o=Sm.none())}return o},vc.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)},vc.prototype.getSelectedComponent=function(){var t=1<=0):a<8+_.indices.length&&(this.cullFlag[a]=!0);var S=this.geometry.getAttribute("position"),M=0;for(a=0;a=3&&(h+=3*(r.indices.length-2));var p=0,f=new Uint16Array(h);for(e=0;ee&&(n._prof.end(),n._prof.start(),++i),c>r||i===t?a(Math.max(i,0)):requestAnimationFrame(s)}requestAnimationFrame(s)})},wc.prototype.mean=function(){return this._prof?this._prof.rawMean():0},wc.prototype.min=function(){return this._prof?this._prof.min():0};var Cm=function(){function t(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];wp(this,t),this._list=[],this._byType={},r.forEach(function(t){return e.register(t)})}return Sp(t,[{key:"register",value:function(t){Ei(this._list,t),Ti(this._byType,t.types,t)}},{key:"unregister",value:function(t){Ci(this._list,t),Pi(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(Cp(e))}},{key:"all",get:function(){return[].concat(Cp(this._list))}},{key:"types",get:function(){return Object.keys(this._byType)}}]),t}(),Tm=function(t){function e(t,r){wp(this,e);var n=Ap(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n._source=t,n._options=r||{},n._abort=!1,n._agent=null,n}return Mp(e,fi),Sp(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}();Jo(Tm.prototype);var Pm=function(t){function e(t,r){wp(this,e);var n=Ap(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r));return r=n._options,n._binary=!0===r.binary,n}return Mp(e,Tm),Sp(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}();Pm.types=["file","blob"];var Lm=/^(https?|ftp):\/\//i,Rm=function(t){function e(t,r){wp(this,e);var n=Ap(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r));return r=n._options,n._binary=!0===r.binary,n}return Mp(e,Tm),Sp(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 Sl.isString(t)&&Lm.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}();Rm.types=["url"];var Nm=function(t){function e(t,r){return wp(this,e),Ap(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r))}return Mp(e,Tm),Sp(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}();Nm.types=["immediate"];var Im=new Cm([Pm,Rm,Nm]),Om=function(){function t(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];wp(this,t),this._list=[],this._byFormat={},this._byExt={},r.forEach(function(t){return e.register(t)})}return Sp(t,[{key:"register",value:function(t){Ei(this._list,t),Ti(this._byFormat,t.formats,t),Ti(this._byExt,t.extensions,t)}},{key:"unregister",value:function(t){Ci(this._list,t),Pi(this._byFormat,t.formats,t),Pi(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(Cp(e))}},{key:"all",get:function(){return[].concat(Cp(this._list))}},{key:"formats",get:function(){return Object.keys(this._byFormat)}},{key:"extensions",get:function(){return Object.keys(this._byExt)}}]),t}(),Dm=function(){function t(e,r){wp(this,t),this._data=e,this._options=r||{},this._abort=!1}return Sp(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}();Jo(Dm.prototype),Sc.prototype.id=290,Sc.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 u,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 Fm=Tf.Assembly;Mc.prototype.id=350,Mc.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 u,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(","),c=0,l=s.length;c0&&e.addChain(h)}else"BIOMOLECULE:"===t.readString(12,23)&&(this._matrix=null,this._matrixIndex=-1,this._assembly=e=new Fm(this._complex),this.assemblies.push(e))};var zm=function(){function t(e){wp(this,t),this._data=e,this._start=0,this._nextCR=-1,this._nextLF=-1,this._next=-1,this._end=e.length,this.next()}return Sp(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,Gm.BondType.UNKNOWN,!0),n&&n>e&&a.addBond(e,n,0,Gm.BondType.UNKNOWN,!0),i&&i>e&&a.addBond(e,i,0,Gm.BondType.UNKNOWN,!0),o&&o>e&&a.addBond(e,o,0,Gm.BondType.UNKNOWN,!0)},Ac.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 Xm={290:Sc,350:Mc};Ac.prototype._parseREMARK=function(t){var e=t.readInt(8,10),r=this._remarks[e];if(Sl.isUndefined(r)){var n=Xm[e];Sl.isFunction(n)&&(this._remarks[e]=r=new n(this._complex))}Sl.isUndefined(r)||r.parse(t)},Ac.prototype._parseHELIX=function(t){this._parseSTRUCTURE(t,[20,22,32,34],function(t){this._complex.addHelix(t)}.bind(this))},Ac.prototype._parseSHEET=function(t){this._parseSTRUCTURE(t,[22,23,33,34],function(t){this._complex.addSheet(t)}.bind(this))},Ac.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),c=t.readInt(15,16),l=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=t.readInt(e[3],e[3]+3),v=0;(d=t.readString(e[3]+4,e[3]+4)).length>0&&(v=d.charCodeAt(0));var y,_=this._sheet;if(83===t.readCharCode(1)){null!==_&&_.getName()!==i&&(_=null,this._sheet=null),null===_?(this._sheet=y=new Vm(i,c),r(y)):y=_;var x=new jm(y,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,g,v),s,l,u);y.addStrand(x)}else r(y=new Bm(n,i,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,g,v),s,o,a))},Ac.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)},Ac.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 Ym={HEADER:Ac.prototype._parseHEADER,"TITLE ":Ac.prototype._parseTITLE,"ATOM ":Ac.prototype._parseATOM,HETATM:Ac.prototype._parseATOM,ENDMDL:Ac.prototype._parseENDMDL,CONECT:Ac.prototype._parseCONECT,COMPND:Ac.prototype._parseCOMPND,REMARK:Ac.prototype._parseREMARK,"HELIX ":Ac.prototype._parseHELIX,"SHEET ":Ac.prototype._parseSHEET,"ATOM 1":Ac.prototype._parseATOM,"ATOM 2":Ac.prototype._parseATOM,"ATOM 3":Ac.prototype._parseATOM,"ATOM 4":Ac.prototype._parseATOM,"ATOM 5":Ac.prototype._parseATOM,"ATOM 6":Ac.prototype._parseATOM,"ATOM 7":Ac.prototype._parseATOM,"ATOM 8":Ac.prototype._parseATOM,"ATOM 9":Ac.prototype._parseATOM};Ac.prototype.parseSync=function(){for(var t=new zm(this._data),e=this._complex=new km;!t.end();){var r=t.readString(1,6),n=Ym[r];Sl.isFunction(n)&&n.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},Ac.formats=["pdb"],Ac.extensions=[".pdb",".ent"];var qm=Tf.Complex,Zm=Tf.Element,$m=Tf.AtomName,Km=Tf.SGroup,Qm=Tf.Bond,Jm={A:0,S:1,D:2,T:3};(Ec.prototype=Object.create(Dm.prototype)).constructor=Ec,Ec.canParse=function(t,e){if(!t)return!1;var r=new RegExp("^\\s*?\\<\\?xml"),n=new RegExp("^\\s*?\\]*\?>\s*<(?:cml|molecule)\b/i;Ec.canProbablyParse=function(t){return Sl.isString(t)&&tg.test(t)},Ec.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){function e(t){return u=l[t],!!(a=n[u.start])&&(a.edges.push(u.end),!!(a=n[u.end])&&(a.edges.push(u.start),!0))}var 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={};return o.atomLabels=null,o.labelsCount=1,o}t.molecule.molecule&&i._extractSGroups(t.molecule.molecule,n);for(var a,s=n.length,c=0;c1)l[h].order=f;else{var d=Jm[p];void 0!==d&&(l[h].order=d,"A"===p&&(l[h].type=Qm.BondType.AROMATIC))}}s=n.length;for(var m=0;m0&&o.push(e)}),o},Ec.prototype._packLabel=function(t,e){return(e<<16)+t},Ec.prototype._unpackLabel=function(t){return{molId:t>>>16,compId:65535&t}},Ec.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 c=i.shift();if(c)for(var l=0;l=0){var i=[Math.min(t,e),Math.max(t,e)];this._complex.addBond(i[0],i[1],r,n,!0)}},Ec.prototype._fixBondsArray=function(){for(var t=this._serialAtomMap={},e=this._complex,r=e._atoms,n=0,i=r.length;n1){var n=new qm;return n.joinComplexes(t),n.originalCML=t[0].originalCML,n}return 1===t.length?t[0]:new qm},Ec.formats=["cml"],Ec.extensions=[".cml"];var eg=e(function(t,e){!function(t,r){r(e)}(0,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,i,o){var a=typeof t;if("string"===a){if(32>(s=r(t)))return i.setUint8(o,160|s),e(i,o+1,t),1+s;if(256>s)return i.setUint8(o,217),i.setUint8(o+1,s),e(i,o+2,t),2+s;if(65536>s)return i.setUint8(o,218),i.setUint16(o+1,s),e(i,o+3,t),3+s;if(4294967296>s)return i.setUint8(o,219),i.setUint32(o+1,s),e(i,o+5,t),5+s}if(t instanceof Uint8Array){var s=t.byteLength,c=new Uint8Array(i.buffer);if(256>s)return i.setUint8(o,196),i.setUint8(o+1,s),c.set(t,o+2),2+s;if(65536>s)return i.setUint8(o,197),i.setUint16(o+1,s),c.set(t,o+3),3+s;if(4294967296>s)return i.setUint8(o,198),i.setUint32(o+1,s),c.set(t,o+5),5+s}if("number"===a){if(!isFinite(t))throw new Error("Number not finite: "+t);if(Math.floor(t)!==t)return i.setUint8(o,203),i.setFloat64(o+1,t),9;if(t>=0){if(128>t)return i.setUint8(o,t),1;if(256>t)return i.setUint8(o,204),i.setUint8(o+1,t),2;if(65536>t)return i.setUint8(o,205),i.setUint16(o+1,t),3;if(4294967296>t)return i.setUint8(o,206),i.setUint32(o+1,t),5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return i.setInt8(o,t),1;if(t>=-128)return i.setUint8(o,208),i.setInt8(o+1,t),2;if(t>=-32768)return i.setUint8(o,209),i.setInt16(o+1,t),3;if(t>=-2147483648)return i.setUint8(o,210),i.setInt32(o+1,t),5;throw new Error("Number too small -0x"+(-t).toString(16).substr(1))}if(null===t)return i.setUint8(o,192),1;if("boolean"===a)return i.setUint8(o,t?195:194),1;if("object"===a){var l=0,u=Array.isArray(t);if(u)s=t.length;else{var h=Object.keys(t);s=h.length}if(16>s?(i.setUint8(o,s|(u?144:128)),l=1):65536>s?(i.setUint8(o,u?220:222),i.setUint16(o+1,s),l=3):4294967296>s&&(i.setUint8(o,u?221:223),i.setUint32(o+1,s),l=5),u)for(var p=0;s>p;p++)l+=n(t[p],i,o+l);else for(p=0;s>p;p++){var f=h[p];l+=n(f,i,o+l),l+=n(t[f],i,o+l)}return l}throw new Error("Unknown type "+a)}function i(t){var e=typeof t;if("string"===e){if(32>(n=r(t)))return 1+n;if(256>n)return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if(t instanceof Uint8Array){if(256>(n=t.byteLength))return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if("number"===e){if(Math.floor(t)!==t)return 9;if(t>=0){if(128>t)return 1;if(256>t)return 2;if(65536>t)return 3;if(4294967296>t)return 5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return 1;if(t>=-128)return 2;if(t>=-32768)return 3;if(t>=-2147483648)return 5;throw new Error("Number too small -0x"+t.toString(16).substr(1))}if("boolean"===e||null===t)return 1;if("object"===e){var n,o=0;if(Array.isArray(t)){n=t.length;for(var a=0;n>a;a++)o+=i(t[a])}else{var s=Object.keys(t);n=s.length;for(a=0;n>a;a++){var c=s[a];o+=i(c)+i(t[c])}}if(16>n)return 1+o;if(65536>n)return 3+o;if(4294967296>n)return 5+o;throw new Error("Array or object too long 0x"+n.toString(16))}throw new Error("Unknown type "+e)}function o(t){var e=new ArrayBuffer(i(t));return n(t,new DataView(e),0),new Uint8Array(e)}function a(t,e,r){return e?new t(e.buffer,e.byteOffset,e.byteLength/(r||1)):void 0}function s(t){return a(DataView,t)}function c(t){return a(Uint8Array,t)}function l(t){return a(Int8Array,t)}function u(t){return a(Int32Array,t,4)}function h(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 p(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 f(t,e){var r=t.length;e||(e=new Uint8Array(4*r));for(var n=s(e),i=0;r>i;++i)n.setInt32(4*i,t[i]);return c(e)}function d(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 m(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 g(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],c=0;s>c;++c)e[o]=a,++o;return e}function v(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 y(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 _(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 x(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 c=0;t[r]===i||t[r]===o;)c+=t[r],++r;c+=t[r],++r,e[n]=c,++n}return e}function b(t,e,r){return d(x(t,u(r)),e,r)}function w(t,e,r){var n=x(t,u(r));return function(t,e,r){return d(y(t,u(r)),e,r)}(n,e,function(t){return a(Float32Array,t,4)}(n))}function S(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===(l=t[r])?++a:a+=l===n||l===i?2:l>0?Math.ceil(l/n):Math.ceil(l/i);var s=e?new Int8Array(a):new Int16Array(a),c=0;for(r=0;o>r;++r){var l;if((l=t[r])>=0)for(;l>=n;)s[c]=n,++c,l-=n;else for(;i>=l;)s[c]=i,++c,l-=i;s[c]=l,++c}return s}(function(t,e,r){return _(m(t,e),r)}(t,e),r)}function M(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 A(t){return M(2,t.length,void 0,c(t))}function E(t){return M(4,t.length,void 0,f(t))}function C(t,e){return M(5,t.length/e,f([e]),c(t))}function T(t){return M(6,t.length,void 0,f(v(t)))}function P(t){return M(8,t.length,void 0,f(function(t){return v(_(t))}(t)))}function L(t,e){return M(9,t.length,f([e]),f(function(t,e){return v(m(t,e))}(t,e)))}function R(t,e){return M(10,t.length,f([e]),function(t,e){var r=t.length;e||(e=new Uint8Array(2*r));for(var n=s(e),i=0;r>i;++i)n.setInt16(2*i,t[i]);return c(e)}(S(t,e)))}function N(t){var e={};return U.forEach(function(r){void 0!==t[r]&&(e[r]=t[r])}),t.bondAtomList&&(e.bondAtomList=E(t.bondAtomList)),t.bondOrderList&&(e.bondOrderList=A(t.bondOrderList)),e.xCoordList=R(t.xCoordList,1e3),e.yCoordList=R(t.yCoordList,1e3),e.zCoordList=R(t.zCoordList,1e3),t.bFactorList&&(e.bFactorList=R(t.bFactorList,100)),t.atomIdList&&(e.atomIdList=P(t.atomIdList)),t.altLocList&&(e.altLocList=T(t.altLocList)),t.occupancyList&&(e.occupancyList=L(t.occupancyList,100)),e.groupIdList=P(t.groupIdList),e.groupTypeList=E(t.groupTypeList),t.secStructList&&(e.secStructList=A(t.secStructList)),t.insCodeList&&(e.insCodeList=T(t.insCodeList)),t.sequenceIndexList&&(e.sequenceIndexList=P(t.sequenceIndexList)),e.chainIdList=C(t.chainIdList,4),t.chainNameList&&(e.chainNameList=C(t.chainNameList,4)),e}function I(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,c,l=t[a];if(0==(128&l))return a++,l;if(128==(240&l))return c=15&l,a++,e(c);if(144==(240&l))return c=15&l,a++,i(c);if(160==(224&l))return c=31&l,a++,n(c);if(224==(224&l))return o=s.getInt8(a),a++,o;switch(l){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return c=s.getUint8(a+1),a+=2,r(c);case 197:return c=s.getUint16(a+1),a+=3,r(c);case 198:return c=s.getUint32(a+1),a+=5,r(c);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 c=s.getUint8(a+1),a+=2,n(c);case 218:return c=s.getUint16(a+1),a+=3,n(c);case 219:return c=s.getUint32(a+1),a+=5,n(c);case 220:return c=s.getUint16(a+1),a+=3,i(c);case 221:return c=s.getUint32(a+1),a+=5,i(c);case 222:return c=s.getUint16(a+1),a+=3,e(c);case 223:return c=s.getUint32(a+1),a+=5,e(c)}throw new Error("Unknown type 0x"+l.toString(16))}var a=0,s=new DataView(t.buffer);return o()}function O(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=s(e),i=s(t),o=0,a=0,c=r/4;c>o;++o,a+=4)n.setFloat32(a,i.getFloat32(a),!0);return e}(e);case 2:return l(e);case 3:return h(e);case 4:return p(e);case 5:return c(e);case 6:return g(p(e),new Uint8Array(r));case 7:return g(p(e));case 8:return function(t,e){return y(g(t),e)}(p(e));case 9:return function(t,e,r){return d(g(t,u(r)),e,r)}(p(e),p(n)[0]);case 10:return w(h(e),p(n)[0]);case 11:return d(h(e),p(n)[0]);case 12:return b(h(e),p(n)[0]);case 13:return b(l(e),p(n)[0]);case 14:return x(h(e));case 15:return x(l(e))}}function D(t,e){var r=(e=e||{}).ignoreFields,n={};return B.forEach(function(e){var i=!!r&&-1!==r.indexOf(e),o=t[e];i||void 0===o||(o instanceof Uint8Array?n[e]=O.apply(null,function(t){var e=s(t),r=e.getInt32(0),n=e.getInt32(4),i=t.subarray(8,12);return[r,t=t.subarray(12),n,i]}(o)):n[e]=o)}),n}function F(t){return String.fromCharCode.apply(null,t).replace(/\0/g,"")}function z(t,e){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var r;return r=t instanceof Uint8Array?I(t):t,D(r,e)}function k(t,e,r,n){var i=new XMLHttpRequest;i.addEventListener("load",function(){try{var t=z(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 U=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],B=U.concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]),V="//mmtf.rcsb.org/v1.0/",j=V+"full/",G=V+"reduced/";t.encode=function(t){return o(N(t))},t.decode=z,t.traverse=function(t,e,r){var n,i,o,a,s,c,l=(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&&!(l&&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=F(t.chainIdList.subarray(4*g,4*g+4)),O=null;b&&(O=F(b.subarray(4*g,4*g+4))),h({groupCount:N,chainIndex:g,modelIndex:m,chainId:I,chainName:O})}for(a=0;N>a;++a){var D=t.groupList[t.groupTypeList[v]],z=D.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:D.groupName,singleLetterCode:D.singleLetterCode,chemCompType:D.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:D.elementList[s],atomName:D.atomNameList[s],formalCharge:D.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=D.bondAtomList;for(s=0,c=D.bondOrderList.length;c>s;++s)d({atomIndex1:y-z+H[2*s],atomIndex2:y-z+H[2*s+1],bondOrder:D.bondOrderList[s]})}v+=1}g+=1}if(_=x+1,x=y-1,d&&P)for(s=0,c=P.length;c>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){k(t,j,e,r)},t.fetchReduced=function(t,e,r){k(t,G,e,r)},t.version="v1.1.0dev",t.fetchUrl=j,t.fetchReducedUrl=G,t.encodeMsgpack=o,t.encodeMmtf=N,t.decodeMsgpack=I,t.decodeMmtf=D})}),rg=Tf.Complex,ng=Tf.Chain,ig=Tf.Atom,og=Tf.AtomName,ag=Tf.Element,sg=Tf.Helix,cg=Tf.Sheet,lg=Tf.Strand,ug=Tf.Bond,hg=Tf.Assembly,pg=Tf.Molecule;Cc.prototype.constructor=Cc,Cc.prototype.compare=function(t){var e=t.length;if(e!==this._original.length)return!1;var r,n=0;for(r=0;r=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,ug.BondType.UNKNOWN,!0)}},Tc.prototype._updateSecStructure=function(t,e,r){if(!Sl.isUndefined(r)&&r.secStruct===this._ssType)return e._secondary=this._ssStruct,void((this._ssStruct instanceof sg||this._ssStruct instanceof lg)&&this._ssStruct._residues.push(e));if(-1!==this._ssType&&(this._ssStruct instanceof sg||this._ssStruct instanceof lg)&&(this._ssStruct._end=this._ssStruct._residues[this._ssStruct._residues.length-1]),!Sl.isUndefined(r)){this._ssType=r.secStruct,this._ssStart=e;var n=null;switch(this._ssType){case-1:break;case 0:case 2:case 4:n=new sg(0,"",e,null,[3,-1,1,-1,5][this._ssType],"",0),t._helices.push(n);break;case 3:var i=new cg("",0);t._sheets.push(i),n=new lg(i,e,null,0);break;default:n={type:"mmtf"+this._ssType}}this._ssStruct=n,e._secondary=n}},Tc.prototype._updateMolecules=function(t){var e=t.entityList;if(e)for(var r=t.chainsPerModel[0],n=0;n=r)){var l=this._complex._chains[c];a=a.concat(l._residues.slice())}}var u=new pg(this._complex,i.description,n+1);u._residues=a,this._complex._molecules[n]=u}},Tc.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,eg.traverse(t,r),this._updateSecStructure(this._complex),this._updateMolecules(t)},Tc.prototype._linkAtomsToResidues=function(){for(var t=0;t=e))for(var a=this._complex._chains[o],s=0;s0&&h.addChain(r[g])}h.matrices=p,t.structures.push(h)}}}},Nc._parseToObject=function(t){function e(t){return 32===t||10===t||13===t||9===t}function r(t,e,r){for(var n=e.length,i=-1;r=u||e(t.charCodeAt(c+1)))){if(p&&59===h){l=c;var i=0;do{if(-1===(l=r(10,t,l+1)))return g="unterminated text block found",null;++i}while(l+1=u);return n=t.substring(c+1,l).replace(/\r/g,""),c=l+2,f+=i,d=1,p=!1,n}if(39===h||34===h){l=c;do{if(-1===(l=r(h,t,l+1)))return g="unterminated quoted string found",null}while(l+10){for(var M=0;M-e.near?"hidden":"visible",s=1e4*(e.far- -this._vector.z)/(e.far-e.near),c=t.getElement();if(void 0===r.fog)c.style.color=i(t.userData.color),"transparent"!==t.userData.background&&(c.style.background=i(t.userData.background));else{var u=Eh.smoothstep(-this._vector.z,r.fog.near,r.fog.far);c.style.color=n(t.userData.color,r.fog.color,u),"transparent"!==t.userData.background&&(c.style.background=n(t.userData.background,r.fog.color,u))}this._vector.applyMatrix4(this._projectionMatrix);var h=(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)";c.style.visibility=a,c.style.WebkitTransform=h,c.style.MozTransform=h,c.style.oTransform=h,c.style.transform=h,c.style.zIndex=Number(s).toFixed(0),c.parentNode!==this._domElement&&this._domElement.appendChild(c)}for(var p=0,f=t.children.length;p0&&(this._altObj.setObjects(s.objects),this._altObj.pivot=s.pivot,"axis"in s?this._altObj.axis=s.axis.clone():this._altObj.axis.set(0,0,1),this._altObj.translate(new n(a*i,a*o)),this.dispatchEvent({type:"change",action:"translate"}))}else a*=10*(Lp.now.inversePanning?-1:1),this.camera.translateX(a*i),this.camera.translateY(a*o),this.dispatchEvent({type:"change",action:"pan"})}}this._lastUpdateTime=t},Bc.prototype.reset=function(){this._state=Cg.NONE,this.object.quaternion.copy(new c(0,0,0,1))},Bc.prototype.mousedown=function(t){if(!1!==this.enabled&&this._state===Cg.NONE){if(t.preventDefault(),t.stopPropagation(),this._state===Cg.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?Cg.TRANSLATE:Cg.ROTATE}else 2===t.button&&(this._state=Cg.TRANSLATE_PIVOT);this._state===Cg.ROTATE&&(this._mouseCurPos.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos)),this._state!==Cg.TRANSLATE&&this._state!==Cg.TRANSLATE_PIVOT||(this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos))}},Bc.prototype.mousemove=function(t){if(!1!==this.enabled&&this._state!==Cg.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case Cg.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 Cg.TRANSLATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translate();break;case Cg.TRANSLATE_PIVOT:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translatePivotByMouse()}},Bc.prototype.mousewheel=function(t){if(!1!==this.enabled&&Lp.now.zooming&&this._state===Cg.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})}},Bc.prototype.mouseup=function(t){!1!==this.enabled&&this._state!==Cg.NONE&&(t.preventDefault(),t.stopPropagation(),this._state=Cg.NONE,this._clock.getElapsedTime()-this._lastMouseMoveTime>.1&&this._affectedObj.stop())},Bc.prototype.touchstartend=function(t){if(!1!==this.enabled)switch(t.preventDefault(),t.stopPropagation(),t.touches.length){case 1:this._state=Cg.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=Cg.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 n(.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=Cg.NONE}},Bc.prototype.touchmove=function(t){if(!1!==this.enabled&&this._state!==Cg.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case Cg.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 Cg.SCALE_PAN:if(Lp.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 i=this.object.scale.x,o=this._scaleStart*this._touchDistanceCur/this._touchDistanceStart;this.setScale(o),this.dispatchEvent({type:"change",action:"zoom",factor:0===i?1:o/i})}if(Lp.now.panning){var a=new n(.5*(t.touches[0].pageX+t.touches[1].pageX),.5*(t.touches[0].pageY+t.touches[1].pageY));a.sub(this._originalPinchCenter),this.camera.position.x=this._originalCameraPos.x-.1*a.x,this.camera.position.y=this._originalCameraPos.y+.1*a.y,this.dispatchEvent({type:"change",action:"pan"})}}},Bc.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()}},Bc.prototype.getKeyBindObject=function(){return window.top},Bc.prototype.dispose=function(){for(var t=0;t0){var o=e[0],a=new l;if(Lp.now.draft.clipPlane&&this.hasOwnProperty("clipPlaneValue")){var s;for(s=0;s=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)}}},Hc.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),c=0;s>1e3&&c>>28,y=Wc((268435200&g)>>>8>>0),_=Wc(((255&g)<<12|(4293918720&m)>>>20)>>0),x=Wc((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}l.push(Gc(p,a))}this._secondaryData=l,this._data=u},Hc.prototype.nextFrame=function(){this.setFrame((this._currFrame+1)%this._framesCount)},Hc.prototype.needsColorUpdate=function(t){return t instanceof nc},Hc.prototype.getAtomColor=function(t,e){return t.getResidueColor(this._residues[e._residue._index],this._complex)},Hc.prototype.getResidueColor=function(t,e){return t.getResidueColor(this._residues[e._index],this._complex)},Hc.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)},Hc.prototype.disableEvents=function(){this._callbacks=null},Hc.prototype.getAtomPos=function(){var t=new l;return function(e){var r=this._data,n=3*(this._atomsCount*(this._currFrame-this._framesRange.start)+e);return t.set(r[n],r[n+1],r[n+2]),t}}(),Hc.prototype.getResidues=function(){return this._cachedResidues?this._residues:(this._complex.updateToFrame(this),this._residues)},Xc.prototype.type="__",Xc.prototype.identify=function(){var t={type:this.type,params:this.params},e=_p.objectsDiff(this.opts,Lp.now.modes[this.id]);return Sl.isEmpty(e)||(t.opts=e),t},Xc.prototype.toString=function(){return"o="+this.type+","+this.params.join(",")+_p.compareOptionsWithDefaults(this.opts,Lp.defaults.objects[this.type])},Xc.prototype.getGeometry=function(){return this._mesh},Xc.prototype.destroy=function(){this._mesh&&Df.destroyObject(this._mesh)},_p.deriveClass(Yc,Xc,{type:"line"}),Yc.prototype.constructor=Yc,Yc.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},Yc.prototype.build=function(t){var e=new gt;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 Sd.Line(e,new Zo({lights:!1,overrideColor:!0,dashedLine:!0})),this._line.material.setUberOptions({fixedColor:new X(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 _e,this._mesh.add(this._line),Df.applyTransformsToMeshes(this._mesh,r))},Yc.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 Ng="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",Ig="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",Og=zh.merge([{srcTex:{type:"t",value:null},srcTexSize:{type:"v2",value:new n(512,512)},opacity:{type:"f",value:1}}]),Dg="// 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",Fg=zh.merge([{srcTex:{type:"t",value:null},srcTexelSize:{type:"v2",value:new n(1/512,1/512)}}]),zg="#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}",kg="#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",Ug="#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}",Bg=zh.merge([{noiseTexture:{type:"t",value:null},noiseTexelSize:{type:"v2",value:new n(1/512,1/512)},diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new n(1/512,1/512)},camNearFar:{type:"v2",value:new n(1,10)},projMatrix:{type:"mat4",value:new u},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 n(100,100)}}]),Vg=zh.merge([{diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new n(1/512,1/512)},aoMap:{type:"t",value:null},samplesOffsets:{type:"fv1",value:null},camNearFar:{type:"v2",value:new n(1,10)},projMatrix:{type:"mat4",value:new u},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0}}]),jg={AOMaterial:function(t){return new Q({uniforms:$c(t,Bg),vertexShader:Ng,fragmentShader:zg,transparent:!1,depthTest:!1,depthWrite:!1})},HorBilateralBlurMaterial:function(t){return new Q({uniforms:$c(t,Vg),vertexShader:Ng,fragmentShader:kg,transparent:!1,depthTest:!1,depthWrite:!1})},VertBilateralBlurMaterial:function(t){return new Q({uniforms:$c(t,Vg),vertexShader:Ng,fragmentShader:Ug,transparent:!1,depthTest:!1,depthWrite:!1})}},Gg="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",Wg=zh.merge([{srcL:{type:"t",value:null},srcR:{type:"t",value:null}}]);Qc.prototype.set=function(t,e,r){this.position=t,this.scale=e,this.orientation=r};Jc.prototype.setup=function(t,e){this._startTime=void 0,this._endTime=void 0,this._srcView=t,this._dstView=e,this._isMoving=!1},Jc.prototype.isMoving=function(){return this._isMoving},Jc.prototype.wasStarted=function(){return void 0!==this._startTime&&void 0!==this._endTime},Jc.prototype.start=function(){this._startTime=Date.now();var t=Lp.now.interpolateViews?1500:0;this._endTime=this._startTime+t,this._isMoving=!0},Jc.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}},Jc.prototype._reset=function(){this._startTime=this._endTime=0,this._isMoving=!1},Jc.prototype.createView=function(){return new Qc};var Hg=new Jc,Xg=Lp.now.fbxprec,Yg='; 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',qg='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',Zg=null;el.prototype.queue=[],el.prototype.busy=!1,el.prototype.add=function(t,e,r,n){this.queue.push([t,e,r,n]),this.busy||this.next()},el.prototype.next=function(){var t=this.queue.shift(),e=this;t&&!e.busy&&(this.busy=!0,function(t,e,r,n,i){Zg.root.getFile(t,{create:!n},function(t){t.createWriter(function(t){var o=new Blob([e],{type:r?"octet/stream":"text/plain"});n?(t.onwriteend=function(){i()},t.seek(t.length),t.write(o)):(t.onwriteend=function(){0===t.length&&e.length>0?t.write(o):i()},t.truncate(0))},tl)},tl)}(t[0],t[1],t[2],t[3],function(){e.busy=!1,e.next()}))};Jo(sl.prototype),sl.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}(),Kg=Tf.selectors,Qg=Tf.Atom,Jg=Tf.Residue,tv=Tf.Chain,ev=Tf.Molecule,rv=0,nv=1,iv=2,ov=_p.createElement;(ul.prototype=Object.create(fi.prototype)).constructor=ul,ul.prototype.getMaxRepresentationCount=function(){return vc.NUM_REPRESENTATION_BITS},ul.prototype.init=function(){var t=this._container,e=_p.createElement("div",{class:"miew-canvas"});hl(t,e),this._container=e;var r=document.createDocumentFragment();if(r.appendChild(this._msgMode=ov("div",{class:"mode-message overlay"},ov("p",{},"COMPONENT EDIT MODE"))),r.appendChild(this._msgAtomInfo=ov("div",{class:"atom-info overlay"},ov("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 dp({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 Bc(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 Vc(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},ul.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},ul.prototype._showMessage=function(t){var e=document.createElement("div");e.setAttribute("class","miew-message"),e.appendChild(document.createElement("p")).appendChild(document.createTextNode(t)),hl(this._container,e)},ul.prototype._showCanvas=function(){hl(this._container,this._gfx.renderer.domElement)},ul.prototype._initGfx=function(){var t={width:this._container.clientWidth,height:this._container.clientHeight},e={preserveDrawingBuffer:!0};Lp.now.antialias&&(e.antialias=!0),t.renderer2d=new kc,t.renderer=new re(e),Rf.init(t.renderer),t.renderer.getContext().getExtension("EXT_frag_depth")||(Lp.now.zSprites=!1),t.renderer.getContext().getExtension("WEBGL_depth_texture")||(Lp.now.ao=!1),t.renderer.autoClear=!1,t.renderer.setPixelRatio(window.devicePixelRatio),t.renderer.setSize(t.width,t.height),t.renderer.setClearColor(Lp.now.themes[Lp.now.theme]),t.renderer.clearColor(),t.renderer2d.setSize(t.width,t.height),t.camera=new ft(Lp.now.camFov,t.width/t.height,Lp.now.camNear,Lp.now.camFar),t.camera.setMinimalFov(Lp.now.camFov),t.camera.position.z=Lp.now.camDistance,t.camera.updateProjectionMatrix(),t.camera.layers.set(Df.LAYERS.DEFAULT),t.camera.layers.enable(Df.LAYERS.VOLUME),t.camera.layers.enable(Df.LAYERS.VOLUME_BFPLANE),t.stereoCam=new mn,t.scene=new oe,t.scene.fog=new ie(Lp.now.themes[Lp.now.theme],Lp.now.camNear,Lp.now.camFar),t.root=new Df.RCGroup,t.scene.add(t.root),t.pivot=new Df.RCGroup,t.root.add(t.pivot),t.selectionScene=new oe,t.selectionRoot=new _e,t.selectionRoot.matrixAutoUpdate=!1,t.selectionScene.add(t.selectionRoot),t.selectionPivot=new _e,t.selectionPivot.matrixAutoUpdate=!1,t.selectionRoot.add(t.selectionPivot);var r=new Lr(16777215,.45);r.position.set(0,.414,1),r.layers.enable(Df.LAYERS.TRANSPARENT),t.scene.add(r);var n=new Rr(6710886);n.layers.enable(Df.LAYERS.TRANSPARENT),t.scene.add(n),t.axes=new jc(t.root,t.camera),t.offscreenBuf=new a(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:Ou,magFilter:Ru,format:Ku,depthBuffer:!0}),t.renderer.getContext().getExtension("WEBGL_depth_texture")&&(t.offscreenBuf.depthTexture=new we,t.offscreenBuf.depthTexture.type=Bu),t.offscreenBuf2=new a(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:Ou,magFilter:Ou,format:Ku,depthBuffer:!1}),t.offscreenBuf3=new a(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:Ou,magFilter:Ou,format:Ku,depthBuffer:!1}),t.offscreenBuf4=new a(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:Ou,magFilter:Ou,format:Ku,depthBuffer:!1}),t.volBFTex=t.offscreenBuf3,t.volFFTex=t.offscreenBuf4,t.volWFFTex=t.offscreenBuf,t.renderer.getContext().getExtension("OES_texture_float")?(t.offscreenBuf5=new a(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:Ou,magFilter:Ou,format:Ku,type:Gu,depthBuffer:!1}),t.offscreenBuf6=new a(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:Ou,magFilter:Ou,format:Ku,type:Gu,depthBuffer:!1}),t.offscreenBuf7=new a(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:Ou,magFilter:Ou,format:Ku,type:Gu,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 a(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:Ou,magFilter:Ou,format:Ku,depthBuffer:!1}),t.stereoBufR=new a(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:Ou,magFilter:Ou,format:Ku,depthBuffer:!1}),this._toggleWebVR("WEBVR"===Lp.now.stereo,t),this._gfx=t,this._showCanvas(),this._container.appendChild(t.renderer2d.getElement());var i=new Ri;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(Lp.now.fps)},ul.prototype._initListeners=function(){var t=this;window.addEventListener("resize",function(){t._onResize()})},ul.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},ul.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},ul.prototype._removeVisual=function(t){var e="",r=null;t instanceof Qo?(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)},ul.prototype._forEachVisual=function(t){for(var e in this._visuals)this._visuals.hasOwnProperty(e)&&t(this._visuals[e])},ul.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={}}},ul.prototype._forEachComplexVisual=function(t){if(this._gfx&&this._gfx.pivot)for(var e in this._visuals)this._visuals.hasOwnProperty(e)&&this._visuals[e]instanceof vc&&t(this._visuals[e])},ul.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},ul.prototype._getVolumeVisual=function(){var t=null;return this._forEachVisual(function(e){e instanceof xc&&(t=e)}),t},ul.prototype._getVisualForComplex=function(t){if(!t)return null;var e=null;return this._forEachComplexVisual(function(r){r.getComplex()===t&&(e=r)}),e},ul.prototype.getVisuals=function(){return Object.keys(this._visuals)},ul.prototype.getCurrentVisual=function(){return this._curVisualName},ul.prototype.setCurrentVisual=function(t){this._visuals[t]&&(this._curVisualName=t)},ul.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()})}},ul.prototype.halt=function(){this._running&&(this._discardComponentEdit(),this._discardFragmentEdit(),this._objectControls.enable(!1),this._halting=!0)},ul.prototype.enableHotKeys=function(t){this._hotKeysEnabled=t,this._objectControls.enableHotkeys(t)},ul.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(Lp.now.camFov),t.camera.updateProjectionMatrix(),t.renderer.setSize(t.width,t.height),t.renderer2d.setSize(t.width,t.height),this.dispatchEvent({type:"resize"})},ul.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))},ul.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=!Lp.now.suspendRender||"WEBVR"===Lp.now.stereo||!!e)},ul.prototype._toggleWebVR=function(){var t=new ft,e=!1,r=null;return function(n,i){var o=i?i.renderer:null;if(!o)throw new Error("No renderer is available to toggle WebVR");if(!i.camera)throw new Error("No camera is available to toggle WebVR");n?(t.copy(i.camera),e=!0,o.vr.enabled=!0,r?r.style.display="block":(r=$g.createButton(o),document.body.appendChild(r))):(o.vr.enabled=!1,r&&(r.style.display="none"),e&&(i.camera.copy(t),this._onResize())),this._needRender=!0}}(),ul.prototype._getWebVRDevice=function(){var t=this._gfx.renderer.vr;return t&&t.enabled?t.getDevice():null},ul.prototype._getBSphereRadius=function(){var t=0;return this._forEachVisual(function(e){t=Math.max(t,e.getBoundaries().boundingSphere.radius)}),t*this._objectControls.getScale()},ul.prototype._updateFog=function(){var t=this._gfx;Lp.now.fog?(void 0!==t.scene.fog&&null!==t.scene.fog||(t.scene.fog=new ie(Lp.now.themes[Lp.now.theme]),this._setUberMaterialValues({fog:Lp.now.fog})),function(t,e,r){t.near=e-r*Lp.now.fogNearFactor,t.far=e+r*Lp.now.fogFarFactor}(t.scene.fog,t.camera.position.z,this._getBSphereRadius())):t.scene.fog&&(t.scene.fog=void 0,this._setUberMaterialValues({fog:Lp.now.fog}))},ul.prototype._onUpdate=function(){void 0!==this.isScriptingCommandAvailable&&this.isScriptingCommandAvailable()&&!this._building&&this.callNextCmd(),this._objectControls.update(),this._forEachComplexVisual(function(t){t.getComplex().update()}),Lp.now.autobuild&&!this._loading.length&&!this._building&&this._needRebuild()&&this.rebuild(),this._loading.length||this._building||this._needRebuild()||this._updateView(),this._updateFog()},ul.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(Lp.now.stereo)},ul.prototype._renderFrame=function(){var t=new Kc;return function(e){var r=this._gfx,n=r.renderer;"NONE"!==e&&(r.stereoCam.aspect="ANAGLYPH"===e?1:.5,r.camera.focus=r.camera.position.z,r.stereoCam.update(r.camera));var i=n.getSize();switch(this._resizeOffscreenBuffers(i.width*window.devicePixelRatio,i.height*window.devicePixelRatio,e),e){case"WEBVR":case"NONE":this._renderScene(r.camera,!1);break;case"SIMPLE":case"DISTORTED":n.setScissorTest(!0),n.setScissor(0,0,i.width/2,i.height),n.setViewport(0,0,i.width/2,i.height),this._renderScene(this._gfx.stereoCam.cameraL,"DISTORTED"===e),n.setScissor(i.width/2,0,i.width/2,i.height),n.setViewport(i.width/2,0,i.width/2,i.height),this._renderScene(this._gfx.stereoCam.cameraR,"DISTORTED"===e),n.setScissorTest(!1);break;case"ANAGLYPH":this._renderScene(this._gfx.stereoCam.cameraL,!1,r.stereoBufL),this._renderScene(this._gfx.stereoCam.cameraR,!1,r.stereoBufR),t.uniforms.srcL.value=r.stereoBufL,t.uniforms.srcR.value=r.stereoBufR,r.renderer.renderScreenQuad(t)}r.renderer2d.render(r.scene,r.camera),Lp.now.axes&&r.axes&&!r.renderer.vr.enabled&&r.axes.render(n)}}(),ul.prototype._onThemeChanged=function(){var t=/\s*theme-\w+\b/g;return function(){var e=Lp.now.theme,r=this._containerRoot;r.className=r.className.replace(t,"")+" theme-"+e;var n=this._gfx;if(n){var i=Lp.now.themes[e];n.scene.fog&&n.scene.fog.color.set(i),n.renderer.setClearColor(i)}}}(),ul.prototype._setUberMaterialValues=function(t){this._gfx.root.traverse(function(e){(e instanceof kt||e instanceof me||e instanceof de)&&e.material instanceof Zo&&(e.material.setValues(t),e.material.needsUpdate=!0)})},ul.prototype._renderScene=function(t,e,r){e=e||!1,r=r||null;var n=this._gfx;if(n.renderer.setClearColor(Lp.now.themes[Lp.now.theme],1),n.renderer.clearTarget(r),n.renderer.vr.enabled)n.renderer.render(n.scene,t);else{n.renderer.clearTarget(n.offscreenBuf),"prepass"===Lp.now.transparency?this._renderWithPrepassTransparency(t,n.offscreenBuf):"standard"===Lp.now.transparency&&n.renderer.render(n.scene,t,n.offscreenBuf);var i=null!==this._getComplexVisual(),o=this._getVolumeVisual(),a=i&&Lp.now.fxaa,s=null!==o&&null!=o.getMesh().material,c=s||a||e?n.offscreenBuf2:r,l=n.offscreenBuf;i&&Lp.now.ao?this._performAO(l,n.offscreenBuf.depthTexture,c,n.offscreenBuf3,n.offscreenBuf2):n.renderer.renderScreenQuadFromTex(l.texture,1,c),this._renderSelection(t,l,c),s&&(n.renderer.renderScreenQuadFromTex(c.texture,1,n.offscreenBuf),c=n.offscreenBuf,this._renderVolume(o,t,c,n.volBFTex,n.volFFTex,n.volWFFTex),a||e||n.renderer.renderScreenQuadFromTex(c.texture,1,r)),l=c,a&&(c=e?n.offscreenBuf3:r,this._performFXAA(l,c),l=c),e&&(c=r,this._performDistortion(l,c,!0))}},ul.prototype._performDistortion=function(){var t=new oe,e=new pt(-1,1,1,-1,-500,1e3),r=new Q({uniforms:{srcTex:{type:"t",value:null},aberration:{type:"fv3",value:new l(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}),n=Df.buildDistorionMesh(10,10,Lp.now.debug.stereoBarrel);return t.add(new Sd.Mesh(n,r)),function(n,i,o){this._gfx.renderer.clearTarget(i),o?(r.uniforms.srcTex.value=n.texture,r.uniforms.aberration.value.set(.995,1,1.01),this._gfx.renderer.render(t,e,i)):this._gfx.renderer.renderScreenQuadFromTexWithDistortion(n,Lp.now.debug.stereoBarrel,i)}}(),ul.prototype._renderSelection=function(){var t=new qc;return function(e,r,n){var i=this._gfx;i.renderer.setClearColor("black",0),i.renderer.clearTarget(r,!0,!1,!1),i.selectionPivot.children.length>0?(i.selectionRoot.matrix=i.root.matrix,i.selectionPivot.matrix=i.pivot.matrix,i.renderer.render(i.selectionScene,e,r)):i.renderer.renderDummyQuad(r),i.renderer.renderScreenQuadFromTex(r.texture,.6,n),t.uniforms.srcTex.value=r.texture,t.uniforms.srcTexSize.value.set(r.width,r.height),i.renderer.renderScreenQuad(t,n)}}(),ul.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)},ul.prototype._renderVolume=function(){var t,e=new Em.BackFacePosMaterial,r=new Em.FrontFacePosMaterial,n=(new u).makeTranslation(.5,.5,.5),i=new u;return function(o,a,s,c,l,u){var h=this._gfx;if(void 0===t&&(t=this._checkVolumeRenderingSupport(c)),t){var p=o.getMesh();p.rebuild(a),h.renderer.setClearColor("black",0),h.renderer.clearTarget(c),h.renderer.clearTarget(l),h.renderer.clearTarget(u),a.layers.set(Df.LAYERS.VOLUME_BFPLANE),h.renderer.render(h.scene,a,c),a.layers.set(Df.LAYERS.VOLUME),h.scene.overrideMaterial=e,h.renderer.render(h.scene,a,c),a.layers.set(Df.LAYERS.VOLUME),h.scene.overrideMaterial=r,h.renderer.render(h.scene,a,l),h.scene.overrideMaterial=null,a.layers.set(Df.LAYERS.DEFAULT),i.getInverse(p.matrixWorld),Zo.prototype.uberOptions.world2colorMatrix.multiplyMatrices(n,i),this._setUberMaterialValues({colorFromPos:!0}),h.renderer.render(h.scene,a,u),this._setUberMaterialValues({colorFromPos:!1});var f=p.material;f.uniforms._BFRight.value=c.texture,f.uniforms._FFRight.value=l.texture,f.uniforms._WFFRight.value=u.texture,a.layers.set(Df.LAYERS.VOLUME),h.renderer.render(h.scene,a,s),a.layers.set(Df.LAYERS.DEFAULT)}}}(),ul.prototype._renderWithPrepassTransparency=function(t,e){var r=this._gfx;t.layers.set(Df.LAYERS.DEFAULT),r.renderer.render(r.scene,t,e),t.layers.set(Df.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(Df.LAYERS.TRANSPARENT),r.renderer.render(r.scene,t,e),t.layers.set(Df.LAYERS.DEFAULT)},ul.prototype._performFXAA=function(){var t=new Zc;return function(e,r){if(void 0!==e&&void 0!==r){var n=this._gfx;n.renderer.setClearColor(Lp.now.themes[Lp.now.theme],1),n.renderer.clearTarget(r),t.uniforms.srcTex.value=e.texture,t.uniforms.srcTexelSize.value.set(1/e.width,1/e.height),t.transparent=!0,n.renderer.renderScreenQuad(t,r)}}}(),ul.prototype._performAO=function(){var t=new jg.AOMaterial,e=new jg.HorBilateralBlurMaterial,r=new jg.VertBilateralBlurMaterial,n=new h(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,$u,zu,300,Tu,Tu,Ru,Ru,1);n.needsUpdate=!0;var i=[new l(.295184,.077723,.068429),new l(-.271976,-.365221,.838363),new l(.547713,.467576,.488515),new l(.662808,-.031733,.584758),new l(-.025717,.218955,.657094),new l(-.310153,-.365223,.370701),new l(-.101407,-.006313,.747665),new l(-.769138,.360399,.086847),new l(-.271988,-.27514,.905353),new l(.09674,-.566901,.700151),new l(.562872,-.735136,.094647),new l(.379877,.359278,.190061),new l(.519064,-.023055,.405068),new l(-.301036,.114696,.088885),new l(-.282922,.598305,.487214),new l(-.181859,.25167,.679702),new l(-.191463,-.635818,.512919),new l(-.293655,.427423,.078921),new l(-.267983,.680534,.13288),new l(.139611,.319637,.477439),new l(-.352086,.31104,.653913),new l(.321032,.805279,.487345),new l(.073516,.820734,.414183),new l(-.155324,.589983,.41146),new l(.335976,.170782,.527627),new l(.46346,-.355658,.167689),new l(.222654,.59655,.769406),new l(.922138,-.04207,.147555),new l(-.72705,-.329192,.369826),new l(-.090731,.53382,.463767),new l(-.323457,-.876559,.238524),new l(-.663277,-.372384,.342856)],o=[-2,-1,0,1,2];return function(a,s,u,h,p){if(void 0!==a&&void 0!==s&&void 0!==u&&void 0!==h&&void 0!==p){var f=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(f.camera.near,f.camera.far),t.uniforms.projMatrix.value=f.camera.projectionMatrix,t.uniforms.aspectRatio.value=f.camera.aspect,t.uniforms.tanHalfFOV.value=Math.tan(.5*Eh.DEG2RAD*f.camera.fov),t.uniforms.samplesKernel.value=i;var d=new l,m=new c,g=new l;f.root.matrix.decompose(d,m,g),t.uniforms.kernelRadius.value=Lp.now.debug.ssaoKernelRadius*g.x,t.uniforms.depthThreshold.value=2*this._getBSphereRadius(),t.uniforms.factor.value=Lp.now.debug.ssaoFactor,t.uniforms.noiseTexture.value=n,t.uniforms.noiseTexelSize.value.set(.25,.25);var v=f.scene.fog;v&&t.uniforms.fogNearFar.value.set(v.near,v.far),t.transparent=!1,f.renderer.renderScreenQuad(t,p),e.uniforms.aoMap.value=p.texture,e.uniforms.srcTexelSize.value.set(1/p.width,1/p.height),e.uniforms.depthTexture.value=s,e.uniforms.samplesOffsets.value=o,f.renderer.renderScreenQuad(e,h),r.uniforms.aoMap.value=h.texture,r.uniforms.diffuseTexture.value=a.texture,r.uniforms.srcTexelSize.value.set(1/h.width,1/h.height),r.uniforms.depthTexture.value=s,r.uniforms.samplesOffsets.value=o,f.renderer.renderScreenQuad(r,u)}}}(),ul.prototype.reset=function(){this._picker&&this._picker.reset(),this._lastPick=null,this._releaseAllVisuals(),this._setEditMode(rv),this._resetObjects(),this._gfx&&(Df.clearTree(this._gfx.pivot),this._gfx.renderer2d.reset()),this.setNeedRender()},ul.prototype._resetScene=function(){this._objectControls.reset(),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this.resetReps(),this.resetPivot(),this.rebuildAll()},ul.prototype.resetView=function(){this._picker&&this._picker.reset(),this._setEditMode(rv),this._resetScene(),this._forEachComplexVisual(function(t){t.updateSelectionMask({}),t.rebuildSelectionGeometry()})},ul.prototype.load=function(t,e){var r=this;e=Sl.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 n=new Tp;this._loading.push(n),n.addEventListener("notification",function(t){r.dispatchEvent(t.slaveEvent)}),this._spinner.spin(this._container);var i=function(t){var e=r._loading.indexOf(n);return-1!==e&&r._loading.splice(e,1),r._spinner.stop(),r._refreshTitle(),t};return pl(t,e,n).then(function(t){return function(t,e,r){return new Promise(function(n,i){if(r.shouldCancel())throw new Error("Operation cancelled");if(r.notify({type:"convert"}),e.mdFile){for(var o=new Array(t.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(),""},ul.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})}},ul.prototype.rebuildAll=function(){this._forEachComplexVisual(function(t){t.setNeedsRebuild()})},ul.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})},ul.prototype.setNeedRender=function(){this._needRender=!0},ul.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"}))},ul.prototype._setReps=function(t){t=t||this._opts&&this._opts.reps||[],this._forEachComplexVisual(function(e){return e.resetReps(t)})},ul.prototype.applyPreset=function(t){for(var e=Lp.now.presets,r=[t||Lp.defaults.preset,Lp.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(iv),this._objectControls.allowTranslation(!1),this._objectControls.allowAltObjFreeRotation(e.isFreeRotationAllowed()),this._needRender=!0)}}},ul.prototype._applyFragmentEdit=function(){if(this._editMode===iv){this._objectControls.stop();for(var t=0;t0){if(t){t=null;break}t=r}}if(t)return t}return{objects:[],pivot:new l(0,0,0)}},ul.prototype.resetPivot=function(){var t=new et;this._forEachVisual(function(e){t.union(e.getBoundaries().boundingBox)}),t.getCenter(this._gfx.pivot.position),this._gfx.pivot.position.negate(),this.dispatchEvent({type:"transform"})},ul.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()})},ul.prototype.screenshot=function(t,e){var r=this._gfx;e=e||t||r.height;var n;if((t=t||r.width)===r.width&&e===r.height)n=r.renderer.domElement.toDataURL("image/png");else{var i=r.camera.aspect,o=r.camera.fov,a=function(t){return Math.tan(Eh.degToRad(.5*t))}(r.camera.fov)*Math.min(r.width,r.height)/r.height,s=t/e;r.camera.aspect=s,r.camera.fov=function(t){return 2*Eh.radToDeg(Math.atan(t))}(a/Math.min(s,1)),r.camera.updateProjectionMatrix(),r.renderer.setSize(t,e),this._renderFrame("NONE"),n=r.renderer.domElement.toDataURL("image/png"),r.camera.aspect=i,r.camera.fov=o,r.camera.updateProjectionMatrix(),r.renderer.setSize(r.width,r.height),this._needRender=!0}return n},ul.prototype.screenshotSave=function(t,e,r){var n=this.screenshot(e,r);_p.shotDownload(n,t)},ul.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;nn?(o=!1,r.preset="empty"):Lp.now.preset!==Lp.defaults.preset&&(r.preset=Lp.now.preset);for(var a=[],s=!0,c=0,l=n;c0&&(e._objects=a),t.view&&(e.view=this.view()),t.settings){var l=this.settings.getDiffs(!1);Sl.isEmpty(l)||(e.settings=l)}return e},ul.prototype.get=function(t,e){return Lp.get(t,e)},ul.prototype._clipPlaneUpdateValue=function(t){var e=Math.max(this._gfx.camera.position.z-t*Lp.now.draft.clipPlaneFactor,Lp.now.camNear),r={clipPlaneValue:e};this._forEachComplexVisual(function(t){t.setUberOptions(r)});for(var n=0,i=this._objects.length;n2&&E.push("'"+this.terminals_[S]+"'");T=f.showPosition?"Parse error on line "+(l+1)+":\n"+f.showPosition()+"\nExpecting "+E.join(", ")+", got '"+(this.terminals_[y]||y)+"'":"Parse error on line "+(l+1)+": Unexpected "+(y==h?"end of input":"'"+(this.terminals_[y]||y)+"'"),this.parseError(T,{text:f.match,token:this.terminals_[y]||y,line:f.yylineno,loc:g,expected:E})}if(b[0]instanceof Array&&b.length>1)throw new Error("Parse Error: multiple actions possible at state: "+x+", token: "+y);switch(b[0]){case 1:n.push(y),o.push(f.yytext),a.push(f.yylloc),n.push(b[1]),y=null,_?(y=_,_=null):(u=f.yyleng,c=f.yytext,l=f.yylineno,g=f.yylloc);break;case 2:if(M=this.productions_[b[1]][1],C.$=o[o.length-M],C._$={first_line:a[a.length-(M||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(M||1)].first_column,last_column:a[a.length-1].last_column},v&&(C._$.range=[a[a.length-(M||1)].range[0],a[a.length-1].range[1]]),void 0!==(w=this.performAction.apply(C,[c,u,l,d.yy,b[1],o,a].concat(p))))return w;M&&(n=n.slice(0,-1*M*2),o=o.slice(0,-1*M),a=a.slice(0,-1*M)),n.push(this.productions_[b[1]][0]),o.push(C.$),a.push(C._$),A=s[n[n.length-2]][n[n.length-1]],n.push(A);break;case 3:return!0}}return!0}},St={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];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;return 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;this._input||(this.done=!0);var t,e,r,n;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}}};return wt.lexer=St,t.prototype=wt,wt.Parser=t,new t}();void 0!==t&&(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=rf.readFileSync(nf.normalize(t[1]),"utf8");return r.parser.parse(e)},t.main===e&&r.main(process.argv.slice(1)))}),hv=uv.parser,pv=(uv.Parser,uv.parse,uv.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"]}}),fv={$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(fm.get(Lp.now.palette).namedColors).sort().join("\n")}}},dv={$help:["Material shortcut"," DF - diffuse"," TR - transparent"," SF - soft plastic"," PL - glossy plastic"," ME - metal"," GL - glass"]},mv={$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:pv,c:fv,mt:dv},gv={$help:["Parameters of rendering modes customization: modes","Parameters of colorer customization: colorers","Autobuild: autobuild = (|)"],modes:pv,colorers:fv},vv={$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:mv},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:mv},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:pv},color:{$help:["color [=...]"," set colorer and apply parameters to current representation"],COLORER_ID:fv},material:{$help:["material "," set material to current representation"],MATERIAL_ID:dv},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:gv},set:{$help:["set ","Set with "," - path to option use set.PARAMETER to get more info"],PARAMETER:gv},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"]}},yv=function(){function t(){wp(this,t)}return Sp(t,[{key:"createSelectorFromNode",value:function(t){return dl(t)}}]),t}(),_v=ul.chem.selectors,xv=ul.modes,bv=ul.colorers,wv=ul.materials,Sv=ul.palettes,Mv=ul.options,Av=ul.settings,Ev=function(){var t=new function(){};return function(){return t}}();ml.prototype.get=function(t){return this.representationMap[t]||this.representationID[t]||""},ml.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"},ml.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])}},ml.prototype.clear=function(){this.representationMap={},this.representationID={}};var Cv=new ml;gl.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 : "'+l+'"\n',i+=" mode : ("+c.id+"), "+c.name+"\n",i+=" colorer : ("+u.id+"), "+u.name+"\n",i+=" material : ("+h.id+"), "+h.name+"\n"),i},gl.prototype.listSelector=function(t,e){var r="";for(var n in e)e.hasOwnProperty(n)&&(r+=n+' : "'+e[n]+'"\n');return r},gl.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 "'+bp(Sl.get(Av.defaults,t))+'"'};if("theme"===t){for(var i=Object.keys(Av.defaults.themes),o=!1,a=0;a1?(void 0!==n&&n("There are two or more files, please specify one by file_id"),i.finish(t)):void 0!==r?r(a[0].id):i.finish(t)}else i.finish(t)},function(e){void 0!==e&&void 0!==n&&n(e),i.finish(t)})},_l.prototype.requestPdbID=function(t,e,r,n){var i=this,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)}},_l.prototype.requestPresetId=function(t,e,r,n){function i(e){void 0!==e&&void 0!==n&&n(e),a.finish(t)}function o(e){if(e instanceof Array){var i=Sl.filter(e,function(t){return t.name.toLowerCase()===s[1].toLowerCase()||t.id===Number(s[1])});i.length<1?(void 0!==n&&n("Preset not found"),a.finish(t)):i.length>1?(void 0!==n&&n("There are two or more presets, please specify one by preset_id"),a.finish(t)):void 0!==r?r(i[0].id):a.finish(t)}else a.finish(t)}var a=this,s=e.split("/");t.awaitWhileCMDisInProcess(),2!==s.length?(void 0!==n&&n("Path can has 2 levels only (pdb/preset)"),a.finish(t)):this.requestPdbID(t,s[0],function(e){t.srvPresetList(e,o,i)},i)},_l.prototype.createScenario=function(t){this.scenarioContext=new yl(t)},_l.prototype.resetScenario=function(){this.scenarioContext=new yl},_l.prototype.deleteScenario=function(t,e,r,n){function i(r){void 0!==r&&e(r),s.finish(t)}function o(e){void 0!==e&&r(e),s.finish(t)}function a(e){t.srvScenarioDelete(e,i,o),s.finish(t)}var s=this;this.init(t,e),t.awaitWhileCMDisInProcess(),"number"==typeof n?a(n):this.requestScenarioID(t,n,a,o)},_l.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 o.finish(t);if(7!==arguments.length)return 5===arguments.length?(r("not supported now"),void o.finish(t)):(r("internal interpreter error"),void o.finish(t));var s=arguments[3],c=arguments[4],l=arguments[5],u=arguments[6];if(Sl.isString(s))this.requestPdbID(t,s,function(t){t>=0&&(a[3]=t,o.addScenarioItem.apply(o,a))},i);else if(Sl.isString(c))this.requestPresetId(t,s+"/"+c,function(t){t>=0&&(a[4]=t,o.addScenarioItem.apply(o,a))},i);else{if("number"!=typeof s||"number"!=typeof c)return i("Internal error"),void o.finish(t);!function(e,r,a,s){o.scenarioContext.script.addItem(o.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}(e,r,a,s)),t.srvScenarioAdd(o.scenarioContext.id,o.scenarioContext.name,JSON.stringify(o.scenarioContext.script),n,i)}(s,c,l,u)}},_l.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)},_l.prototype.finish=function(t){t.finishAwaitingCMDInProcess()},_l.prototype.fileList=function(t,e,r,n,i){function o(r){if(void 0!==r)for(var n=0;n1?(r("There are two or more presets, please specify one by preset_id"),l.finish(t)):void 0===o?i.call(t,n[0].id,a,c):i.call(t,n[0].id,o,a,c)}else l.finish(t)}function c(e){void 0!==e&&r(e),l.finish(t)}var l=this;this.init(t,e),t.awaitWhileCMDisInProcess();var u=n.split("/");2!==u.length?(r("Path can has 2 levels only (pdb/preset)"),l.finish(t)):t.srvTopologyFind(u[0],function(e){e instanceof Array?e.length<1?(r("File not found"),l.finish(t)):e.length>1?(r("There are two or more files, please specify one by file_id"),l.finish(t)):t.srvPresetList(e[0].id,s,c):l.finish(t)},c)},_l.prototype.coroutineWithFileName=function(t,e,r,n,i){function o(r){void 0!==r&&e(r),s.finish(t)}function a(e){void 0!==e&&r(e),s.finish(t)}var s=this,c=arguments;this.init(t),t.awaitWhileCMDisInProcess();var l=n.split("/");1!==l.length?(r("Path can contain only file name or id"),s.finish(t)):t.srvTopologyFind(l[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(c.length){case 5:i.call(t,e[0].id,o,a);break;case 6:i.call(t,e[0].id,c[5],o,a);break;case 9:i.call(c[5],c[6],c[7],c[8],e[0].id);break;case 10:i.call(c[5],c[6],c[7],c[8],e[0].id,c[9]);break;default:s.finish(t)}s.finish(t)},a)};var Pv=new _l;bl.prototype.append=function(t){var e=this._values;return e[e.length]=t,this},bl.prototype.remove=function(t){var e=this._values,r=e.indexOf(t);return r>=0&&e.splice(r,1),this},bl.prototype.toJSO=function(t,e,r){for(var n={},i=this._values,o=0,a=i.length;o0},ul.prototype.callNextCmd=function(){if(this.isScriptingCommandAvailable()){var t=this.cmdQueue.shift(),e={};e.success=!1;try{hv.parse(t),e.success=!0}catch(t){e.error=t.message,hv.yy.error(e.error),this.finishAwaitingCMDInProcess()}return e}return""},ul.JSONConverter=yv,hv.yy=Lv,hv.yy.parseError=hv.parseError,ul}); //# sourceMappingURL=Miew.min.js.map diff --git a/dist/Miew.module.js b/dist/Miew.module.js index 1ce23f31..02d6a84e 100644 --- a/dist/Miew.module.js +++ b/dist/Miew.module.js @@ -1,4 +1,4 @@ -/** Miew - 3D Molecular Viewer v0.7.9 Copyright (c) 2015-2017 EPAM Systems, Inc. */ +/** Miew - 3D Molecular Viewer v0.7.10 Copyright (c) 2015-2017 EPAM Systems, Inc. */ var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; @@ -62045,6 +62045,21 @@ function getUrlParametersAsDict(url) { return result; } +function resolveURL(str) { + if (typeof URL !== 'undefined') { + if (typeof window !== 'undefined') { + return new URL(str, window.location).href; + } else { + return new URL(str).href; + } + } else if (typeof document !== 'undefined') { + var anchor = document.createElement('a'); + anchor.href = str; + return anchor.href; + } + return str; +} + /** * Generates regular expression object that includes all symbols * listed in the argument @@ -62301,6 +62316,12 @@ function getFileExtension(fileName) { return fileName.slice(Math.max(0, fileName.lastIndexOf('.')) || Infinity); } +function splitFileName(fileName) { + var ext = getFileExtension(fileName); + var name = fileName.slice(0, fileName.length - ext.length); + return [name, ext]; +} + function dataUrlToBlob(url) { var parts = url.split(/[:;,]/); var partsCount = parts.length; @@ -62364,6 +62385,45 @@ function correctSelectorIdentifier(value) { return enquoteHelper.join(''); } +function registerInList(list, value) { + if (!list.includes(value)) { + list.push(value); + } +} + +function unregisterFromList(list, value) { + var pos = list.indexOf(value); + if (pos !== -1) { + list.splice(pos, 1); + } +} + +function registerInDict(dict, keys, value) { + keys.forEach(function (key) { + key = key.toLowerCase(); + var list = dict[key] = dict[key] || []; + if (!list.includes(value)) { + list.push(value); + } + }); +} + +function unregisterFromDict(dict, keys, value) { + keys.forEach(function (key) { + key = key.toLowerCase(); + var list = dict[key]; + if (list) { + var pos = list.indexOf(value); + if (pos !== -1) { + list.splice(pos, 1); + } + if (list.length === 0) { + delete dict[key]; + } + } + }); +} + //////////////////////////////////////////////////////////////////////////// // Exports @@ -62373,6 +62433,7 @@ var utils = { decodeQueryComponent: decodeQueryComponent, getUrlParameters: getUrlParameters, getUrlParametersAsDict: getUrlParametersAsDict, + resolveURL: resolveURL, generateRegExp: generateRegExp, createElement: createElement$2, deriveClass: deriveClass, @@ -62394,7 +62455,8 @@ var utils = { copySubArrays: copySubArrays, shallowCloneNode: shallowCloneNode, correctSelectorIdentifier: correctSelectorIdentifier, - getFileExtension: getFileExtension + getFileExtension: getFileExtension, + splitFileName: splitFileName }; var now = utils.Timer.now; @@ -62464,29 +62526,188 @@ Stats.prototype = { }; -function JobHandle() { - EventDispatcher$1.call(this); +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; +} : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; +}; + + + + + + + + - this._cancellationRequested = false; -} -utils.deriveClass(JobHandle, EventDispatcher$1); -JobHandle.prototype.cancel = function () { - this._cancellationRequested = true; - this.dispatchEvent('cancel'); +var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } }; -JobHandle.prototype.isCancellationRequested = function () { - return this._cancellationRequested; +var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; +}(); + + + + + + + + + +var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }; -// slaves use this to notify master about their events -// master routes these notifications to a single event slot -JobHandle.prototype.notify = function (event) { - this.dispatchEvent({ type: 'notification', slaveEvent: event }); + + + + + + + + + + +var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; }; + + + + +var slicedToArray = function () { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + return function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; +}(); + + + + + + + + + + + + + +var toConsumableArray = function (arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + + return arr2; + } else { + return Array.from(arr); + } +}; + +var JobHandle = function (_EventDispatcher) { + inherits(JobHandle, _EventDispatcher); + + function JobHandle() { + classCallCheck(this, JobHandle); + + var _this = possibleConstructorReturn(this, (JobHandle.__proto__ || Object.getPrototypeOf(JobHandle)).call(this)); + + _this._shouldCancel = false; + return _this; + } + + createClass(JobHandle, [{ + key: 'cancel', + value: function cancel() { + this._shouldCancel = true; + this.dispatchEvent({ type: 'cancel' }); + } + }, { + key: 'shouldCancel', + value: function shouldCancel() { + return this._shouldCancel; + } + + // slaves use this to notify master about their events + // master routes these notifications to a single event slot + + }, { + key: 'notify', + value: function notify(event) { + this.dispatchEvent({ type: 'notification', slaveEvent: event }); + } + }]); + return JobHandle; +}(EventDispatcher$1); + var VERSION = 0; ////////////////////////////////////////////////////////////////////////// @@ -62508,7 +62729,7 @@ var VERSION = 0; * @alias SettingsObject * @namespace */ -var defaults = { +var defaults$1 = { /** * Default options for all available modes. * Use {@link Mode.id} as a dictionary key to access mode options. @@ -63304,7 +63525,7 @@ function Settings() { Settings.prototype = { constructor: Settings, - defaults: defaults, + defaults: defaults$1, set: function set(path, value) { lodash.set(this.now, path, value); @@ -63316,7 +63537,7 @@ Settings.prototype = { }, reset: function reset() { - this.now = lodash.cloneDeep(defaults); + this.now = lodash.cloneDeep(defaults$1); this.old = null; this._changed = {}; }, @@ -63357,7 +63578,7 @@ Settings.prototype = { }, getDiffs: function getDiffs(versioned) { - var diffs = utils.objectsDiff(this.now, defaults); + var diffs = utils.objectsDiff(this.now, defaults$1); if (versioned) { diffs.VERSION = VERSION; } @@ -63365,123 +63586,13 @@ Settings.prototype = { }, setPluginOpts: function setPluginOpts(plugin, opts) { - defaults.plugins[plugin] = lodash.cloneDeep(opts); + defaults$1.plugins[plugin] = lodash.cloneDeep(opts); this.now.plugins[plugin] = lodash.cloneDeep(opts); } }; var settings = new Settings(); -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; -} : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; -}; - - - - - - - - - - - -var classCallCheck = function (instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } -}; - -var createClass = function () { - function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps); - if (staticProps) defineProperties(Constructor, staticProps); - return Constructor; - }; -}(); - - - - - - - - - -var inherits = function (subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - enumerable: false, - writable: true, - configurable: true - } - }); - if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; -}; - - - - - - - - - - - -var possibleConstructorReturn = function (self, call) { - if (!self) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return call && (typeof call === "object" || typeof call === "function") ? call : self; -}; - - - - - - - - - - - - - - - - - - - -var toConsumableArray = function (arr) { - if (Array.isArray(arr)) { - for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; - - return arr2; - } else { - return Array.from(arr); - } -}; - var repIndex = 0; function asBoolean(value) { @@ -63601,13 +63712,13 @@ function extractArgs(input, defaultsDict, params) { var args = input.substr(bang + 1).split(cLSep); input = inputVal; if (defaultsDict) { - var defaults = defaultsDict[input]; - var opts = utils.deriveDeep(defaults, true); + var defaults$$1 = defaultsDict[input]; + var opts = utils.deriveDeep(defaults$$1, 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, key))]; + var adapter = adapters[_typeof(lodash.get(defaults$$1, key))]; if (adapter) { lodash.set(opts, key, adapter(value)); } else { @@ -75338,7 +75449,7 @@ var geometries = { LabelsGeometry: LabelsGeometry }; -var UberObject = function (SuperClass) { +function UberObject (SuperClass) { function NewObjectType() { SuperClass.apply(this, arguments); this.onBeforeRender = NewObjectType.prototype.onBeforeRender; @@ -75366,7 +75477,7 @@ var UberObject = function (SuperClass) { }; return NewObjectType; -}; +} var Mesh$1 = UberObject(Mesh); @@ -81728,6 +81839,77 @@ GfxProfiler.prototype.min = function () { return this._prof ? this._prof.min() : 0.0; }; +var LoaderList = function () { + function LoaderList() { + var _this = this; + + var someLoaders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + classCallCheck(this, LoaderList); + + this._list = []; + this._byType = {}; + + someLoaders.forEach(function (SomeLoader) { + return _this.register(SomeLoader); + }); + } + + /** + * Register a parser for a specific data format. + * + * @param {function} SomeLoader - a Parser subclass to register + * @param {string[]} SomeLoader.types - supported data formats + */ + + + createClass(LoaderList, [{ + key: 'register', + value: function register(SomeLoader) { + registerInList(this._list, SomeLoader); + registerInDict(this._byType, SomeLoader.types, SomeLoader); + } + }, { + key: 'unregister', + value: function unregister(SomeLoader) { + unregisterFromList(this._list, SomeLoader); + unregisterFromDict(this._byType, SomeLoader.types, SomeLoader); + } + }, { + key: 'find', + + + /** + * Find a suitable loader for the data source + * + * @param {object} specs - parser specifications + * @param {string=} specs.type - supported source type + * @param {data=} specs.source - source to load from + */ + value: function find(specs) { + var list = []; + if (specs.type) { + list = this._byType[specs.type.toLowerCase()] || []; + } else if (specs.source) { + return this._list.filter(function (SomeLoader) { + return SomeLoader.canProbablyLoad && SomeLoader.canProbablyLoad(specs.source); + }); + } + return [].concat(toConsumableArray(list)); + } + }, { + key: 'all', + get: function get$$1() { + return [].concat(toConsumableArray(this._list)); + } + }, { + key: 'types', + get: function get$$1() { + return Object.keys(this._byType); + } + }]); + return LoaderList; +}(); + var Loader$1 = function (_EventDispatcher) { inherits(Loader, _EventDispatcher); @@ -81738,6 +81920,7 @@ var Loader$1 = function (_EventDispatcher) { _this._source = source; _this._options = options || {}; + _this._abort = false; _this._agent = null; return _this; } @@ -81748,6 +81931,9 @@ var Loader$1 = function (_EventDispatcher) { if (callbacks) { return this._loadOLD(callbacks); } + if (this._abort) { + return Promise.reject(new Error('Loading aborted')); + } return this.loadAsync(); } @@ -81782,10 +81968,16 @@ var Loader$1 = function (_EventDispatcher) { }, { key: 'abort', value: function abort() { + this._abort = true; if (this._agent) { this._agent.abort(); } } + }], [{ + key: 'extractName', + value: function extractName(_source) { + return undefined; + } }]); return Loader; }(EventDispatcher$1); @@ -81801,9 +81993,6 @@ var FileLoader$1 = function (_Loader) { var _this = possibleConstructorReturn(this, (FileLoader.__proto__ || Object.getPrototypeOf(FileLoader)).call(this, source, options)); options = _this._options; - if (!options.fileName) { - options.fileName = source.name; - } _this._binary = options.binary === true; return _this; } @@ -81837,16 +82026,34 @@ var FileLoader$1 = function (_Loader) { } }); } + + /** @deprecated */ + }], [{ key: 'canLoad', value: function canLoad(source, options) { var sourceType = options.sourceType; return source instanceof File && (!sourceType || sourceType === 'file'); } + }, { + key: 'canProbablyLoad', + value: function canProbablyLoad(source) { + return File && source instanceof File || Blob && source instanceof Blob; + } + }, { + key: 'extractName', + value: function extractName(source) { + return source && source.name; + } }]); return FileLoader; }(Loader$1); +FileLoader$1.types = ['file', 'blob']; + +// we don't need to detect all kinds of URLs, just the evident ones +var urlStartRegexp = /^(https?|ftp):\/\//i; + var XHRLoader$1 = function (_Loader) { inherits(XHRLoader, _Loader); @@ -81856,13 +82063,6 @@ var XHRLoader$1 = function (_Loader) { var _this = possibleConstructorReturn(this, (XHRLoader.__proto__ || Object.getPrototypeOf(XHRLoader)).call(this, source, options)); options = _this._options; - if (!options.fileName) { - var last = source.indexOf('?'); - if (last === -1) { - last = source.length; - } - options.fileName = source.slice(source.lastIndexOf('/') + 1, last); - } _this._binary = options.binary === true; return _this; } @@ -81902,16 +82102,35 @@ var XHRLoader$1 = function (_Loader) { request.send(); }); } + + /** @deprecated */ + }], [{ key: 'canLoad', value: function canLoad(source, options) { var sourceType = options.sourceType; return typeof source === 'string' && (!sourceType || sourceType === 'url'); } + }, { + key: 'canProbablyLoad', + value: function canProbablyLoad(source) { + return lodash.isString(source) && urlStartRegexp.test(source); + } + }, { + key: 'extractName', + value: function extractName(source) { + if (source) { + var last = (source.indexOf('?') + 1 || source.lastIndexOf('#') + 1 || source.length + 1) - 1; + return source.slice(source.lastIndexOf('/', last) + 1, last); + } + return undefined; + } }]); return XHRLoader; }(Loader$1); +XHRLoader$1.types = ['url']; + var ImmediateLoader = function (_Loader) { inherits(ImmediateLoader, _Loader); @@ -81925,92 +82144,28 @@ var ImmediateLoader = function (_Loader) { value: function loadAsync() { return Promise.resolve(this._source); } + + /** @deprecated */ + }], [{ key: 'canLoad', value: function canLoad(source, options) { return typeof source !== 'undefined' && typeof options !== 'undefined' && options.sourceType === 'immediate'; } + }, { + key: 'canProbablyLoad', + value: function canProbablyLoad(_source) { + return false; + } }]); return ImmediateLoader; }(Loader$1); -/** - * Loaders list. - * @module io/loaders - */ -// FIXME: deps for amdclean - -var loaderList = []; -var ag$3 = [FileLoader$1, XHRLoader$1, ImmediateLoader]; - -(function (plugins) { - for (var i = 0, n = plugins.length; i < n; ++i) { - var currLoader = plugins[i]; - loaderList.push(currLoader); - } -})(ag$3); - -// NOTE: workaround for https://github.com/gfranko/amdclean/issues/115 -var exports$3 = /** @alias module:io/loaders */{ - /** - * The list of loader constructor functions available. - * @type {Array} - */ - list: loaderList, - - Loader: Loader$1, +ImmediateLoader.types = ['immediate']; - /** - * Create a loader instance. - * @param {object} context - Current context. - * @param {object} source - Data to be loaded. - * @param {object} options - Loader options object overriding defaults. - * @returns {Loader} New loader object. - */ - create: function create(context, source, options) { - var loader = new Loader$1(source, options); // this behaviour was copied from the previous version - var i = 0, - n = loaderList.length; - for (; i < n; ++i) { - var SomeLoader = loaderList[i]; - if (SomeLoader.canLoad && SomeLoader.canLoad(source, options)) { - loader = new SomeLoader(source, options); - break; - } - } - loader.context = context; - if (i === n) { - loader.logger.error('Could not select a suitable Loader.'); - } - return loader; - } -}; - -function registerIn(dict, keys, value) { - keys.forEach(function (key) { - key = key.toLowerCase(); - var list = dict[key] = dict[key] || []; - if (!list.includes(value)) { - list.push(value); - } - }); -} - -function unregisterFrom(dict, keys, value) { - keys.forEach(function (key) { - key = key.toLowerCase(); - var list = dict[key]; - if (list) { - var pos = list.indexOf(value); - if (pos !== -1) { - list.splice(pos, 1); - } - if (list.length === 0) { - delete dict[key]; - } - } - }); -} +var loaders = new LoaderList([ +// note: order might be important +FileLoader$1, XHRLoader$1, ImmediateLoader]); var ParserList = function () { function ParserList() { @@ -82038,26 +82193,21 @@ var ParserList = function () { createClass(ParserList, [{ - key: "register", + key: 'register', value: function register(SomeParser) { - if (!this._list.includes(SomeParser)) { - this._list.push(SomeParser); - } - registerIn(this._byFormat, SomeParser.formats, SomeParser); - registerIn(this._byExt, SomeParser.extensions, SomeParser); + registerInList(this._list, SomeParser); + registerInDict(this._byFormat, SomeParser.formats, SomeParser); + registerInDict(this._byExt, SomeParser.extensions, SomeParser); } }, { - key: "unregister", + key: 'unregister', value: function unregister(SomeParser) { - var pos = this._list.indexOf(SomeParser); - if (pos !== -1) { - this._list.splice(pos, 1); - } - unregisterFrom(this._byFormat, SomeParser.formats, SomeParser); - unregisterFrom(this._byExt, SomeParser.extensions, SomeParser); + unregisterFromList(this._list, SomeParser); + unregisterFromDict(this._byFormat, SomeParser.formats, SomeParser); + unregisterFromDict(this._byExt, SomeParser.extensions, SomeParser); } }, { - key: "find", + key: 'find', /** @@ -82084,17 +82234,17 @@ var ParserList = function () { return [].concat(toConsumableArray(list)); } }, { - key: "all", + key: 'all', get: function get$$1() { return [].concat(toConsumableArray(this._list)); } }, { - key: "formats", + key: 'formats', get: function get$$1() { return Object.keys(this._byFormat); } }, { - key: "extensions", + key: 'extensions', get: function get$$1() { return Object.keys(this._byExt); } @@ -82107,7 +82257,7 @@ var Parser = function () { classCallCheck(this, Parser); this._data = data; - this._options = options; + this._options = options || {}; this._abort = false; } @@ -82407,7 +82557,7 @@ function PDBParser(data, options) { this._molecule = null; this._compndCurrToken = ''; - options.fileType = 'pdb'; + this._options.fileType = 'pdb'; } //////////////////////////////////////////////////////////////////////////// @@ -82866,7 +83016,7 @@ function CMLParser(data, options) { this._lastMolId = -1; this._readOnlyOneMolecule = false; - options.fileType = 'cml'; + this._options.fileType = 'cml'; } //////////////////////////////////////////////////////////////////////////// @@ -83572,7 +83722,7 @@ ArrayComparator.prototype.compare = function (candidate) { function MMTFParser(data, options) { Parser.call(this, data, options); - options.fileType = 'mmtf'; + this._options.fileType = 'mmtf'; } //////////////////////////////////////////////////////////////////////////// @@ -83959,6 +84109,7 @@ MMTFParser.prototype.parseSync = function () { MMTFParser.formats = ['mmtf']; MMTFParser.extensions = ['.mmtf']; +MMTFParser.binary = true; var Complex$5 = chem.Complex; var Element$6 = chem.Element; @@ -84017,7 +84168,7 @@ function CIFParser(data, options) { Parser.call(this, data, options); this.asymDict = {}; this.molecules = []; - options.fileType = 'cif'; + this._options.fileType = 'cif'; } //////////////////////////////////////////////////////////////////////////// @@ -84950,7 +85101,7 @@ Ccp4Model.prototype.toXYZData = function () { function CCP4Parser(data, options) { Parser.call(this, data, options); - options.fileType = 'ccp4'; + this._options.fileType = 'ccp4'; } //////////////////////////////////////////////////////////////////////////// @@ -84981,13 +85132,14 @@ CCP4Parser.prototype.parseSync = function () { CCP4Parser.formats = ['ccp4']; CCP4Parser.extensions = ['.ccp4']; +CCP4Parser.binary = true; var Complex$6 = chem.Complex; var Element$7 = chem.Element; function PubChemParser(data, options) { Parser.call(this, data, options); - options.fileType = 'pubchem+json'; + this._options.fileType = 'pubchem+json'; } //////////////////////////////////////////////////////////////////////////// @@ -85080,7 +85232,7 @@ var parsers = new ParserList([ PDBParser, CIFParser, MMTFParser, CMLParser, PubChemParser, CCP4Parser]); var io = { - loaders: exports$3, + loaders: loaders, parsers: parsers }; @@ -87401,7 +87553,111 @@ Cookies.prototype._exists = function (key) { return document.cookie.match(new RegExp('(?:^|; )' + key + '=([^;]*)')); }; -/* global "0.7.9":false */ +/******* + * Toggling WebVR is done through button.click because of limitations on calling requestPresent in webVR: + * VRDisplay::requestPresent should be called from user gesture: + * https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/requestPresent + */ +var WEBVR = function () { + function WEBVR() { + classCallCheck(this, WEBVR); + } + + createClass(WEBVR, null, [{ + key: 'createButton', + value: function createButton(renderer) { + function showEnterVR(display, button) { + + button.style.display = ''; + button.style.cursor = 'pointer'; + button.style.left = 'calc(50% - 50px)'; + button.style.width = '100px'; + + button.textContent = 'ENTER VR'; + + button.onmouseenter = function () { + button.style.opacity = '1.0'; + }; + button.onmouseleave = function () { + button.style.opacity = '0.5'; + }; + + button.onclick = function () { + if (display.isPresenting) { + display.exitPresent(); + } else { + display.requestPresent([{ source: renderer.domElement }]); + } + }; + renderer.vr.setDevice(display); + } + + function showVRNotFound(button) { + + button.style.display = ''; + button.style.cursor = 'auto'; + button.style.left = 'calc(50% - 75px)'; + button.style.width = '150px'; + button.textContent = 'VR NOT FOUND'; + button.onmouseenter = null; + button.onmouseleave = null; + button.onclick = null; + + renderer.vr.setDevice(null); + } + + function stylizeElement(element) { + element.style.position = 'absolute'; + element.style.bottom = '20px'; + element.style.padding = '12px 6px'; + element.style.border = '1px solid #fff'; + element.style.borderRadius = '4px'; + element.style.background = 'transparent'; + element.style.color = '#fff'; + element.style.font = 'normal 13px sans-serif'; + element.style.textAlign = 'center'; + element.style.opacity = '0.5'; + element.style.outline = 'none'; + element.style.zIndex = '999'; + } + + if ('getVRDisplays' in navigator) { + var button = document.createElement('button'); + button.style.display = 'none'; + stylizeElement(button); + window.addEventListener('vrdisplayconnect', function (event) { + showEnterVR(event.display, button); + }, false); + window.addEventListener('vrdisplaydisconnect', function (_event) { + showVRNotFound(button); + }, false); + window.addEventListener('vrdisplaypresentchange', function (event) { + button.textContent = event.display.isPresenting ? 'EXIT VR' : 'ENTER VR'; + }, false); + navigator.getVRDisplays().then(function (displays) { + if (displays.length > 0) { + showEnterVR(displays[0], button); + } else { + showVRNotFound(button); + } + }); + return button; + } else { + var message = document.createElement('a'); + message.href = 'https://webvr.info'; + message.innerHTML = 'WEBVR NOT SUPPORTED'; + message.style.left = 'calc(50% - 90px)'; + message.style.width = '180px'; + message.style.textDecoration = 'none'; + stylizeElement(message); + return message; + } + } + }]); + return WEBVR; +}(); + +/* global "0.7.10":false */ ////////////////////////////////////////////////////////////////////////////// @@ -87430,25 +87686,6 @@ function removeExtension(fileName) { return fileName; } -function normalizeSource(source) { - // special translation for local data files - if (typeof source === 'string') { - if (source.match(/^[0-9A-Z]{4}$/i)) { - // normalize if PDBID - source = source.toUpperCase(); - } else if (source.match(/^data\/[0-9A-Z]{4}\.pdb$/i)) { - // extract PDBID for cached files - source = source.substr(5, 4).toUpperCase(); - } else { - // otherwise use neat hack to restore the full url (https://gist.github.com/jlong/2428561) - var ref = document.createElement('a'); - ref.href = source; - source = ref.href; - } - } - return source; -} - function hasValidResidues(complex) { var hasValidRes = false; complex.forEachComponent(function (component) { @@ -87463,7 +87700,7 @@ function hasValidResidues(complex) { function reportProgress(log, action, percent) { var TOTAL_PERCENT = 100; - if (percent) { + if (percent !== undefined) { log.debug(action + '... ' + Math.floor(percent * TOTAL_PERCENT) + '%'); } else { log.debug(action + '...'); @@ -87530,8 +87767,8 @@ function Miew$1(opts) { /** @type {?Spinner} */ this._spinner = null; - /** @type {?Loader} */ - this._loader = null; + /** @type {JobHandle[]} */ + this._loading = []; /** @type {?number} */ this._animInterval = null; @@ -87548,8 +87785,8 @@ function Miew$1(opts) { // TODO make this being not so ugly - this._fileSource = null; - this._fileSourceAnim = null; + this._srvTopoSource = null; + this._srvAnimSource = null; this.reset(); @@ -87671,10 +87908,10 @@ Miew$1.prototype.init = function () { */ Miew$1.prototype.term = function () { this._showMessage('Viewer has been terminated.'); - if (this._loader) { - this._loader.cancel(); - this._loader = null; - } + this._loading.forEach(function (job) { + job.cancel(); + }); + this._loading.length = 0; this.halt(); this._gfx = null; }; @@ -87847,6 +88084,8 @@ Miew$1.prototype._initGfx = function () { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat, depthBuffer: false }); + this._toggleWebVR(settings.now.stereo === 'WEBVR', gfx); + this._gfx = gfx; this._showCanvas(); @@ -88070,6 +88309,8 @@ Miew$1.prototype.setCurrentVisual = function (name) { * @see Miew#halt */ Miew$1.prototype.run = function () { + var _this = this; + if (!this._running) { this._running = true; if (this._halting) { @@ -88079,9 +88320,9 @@ Miew$1.prototype.run = function () { this._objectControls.enable(true); - var self = this; - requestAnimationFrame(function _onAnimationFrame() { - self._onTick(); + var device = this._getWebVRDevice(); + (device || window).requestAnimationFrame(function () { + return _this._onTick(); }); } }; @@ -88159,6 +88400,8 @@ Miew$1.prototype._resizeOffscreenBuffers = function (width, height, stereo) { * @private */ Miew$1.prototype._onTick = function () { + var _this2 = this; + if (this._halting) { this._running = false; this._halting = false; @@ -88167,18 +88410,70 @@ Miew$1.prototype._onTick = function () { this._fps.update(); - var self = this; - requestAnimationFrame(function _onAnimationFrame() { - self._onTick(); + var device = this._getWebVRDevice(); + (device || window).requestAnimationFrame(function () { + return _this2._onTick(); }); this._onUpdate(); if (this._needRender) { this._onRender(); - this._needRender = !settings.now.suspendRender; + this._needRender = !settings.now.suspendRender || settings.now.stereo === 'WEBVR' || !!device; } }; +/** + * Turn the WebVR when it is supported + * NOTE: we toggle using button.click, because VRDisplay.requestPresent should be called from user gesture + */ +Miew$1.prototype._toggleWebVR = function () { + + var _mainCamera = new PerspectiveCamera(); + var _cameraWasStored = false; + var _webVRButton = null; + + return function (enable, gfx) { + var self = this; + var renderer = gfx ? gfx.renderer : null; + if (!renderer) { + throw new Error('No renderer is available to toggle WebVR'); + } else if (!gfx.camera) { + throw new Error('No camera is available to toggle WebVR'); + } + + if (enable) { + // store common camera + _mainCamera.copy(gfx.camera); + _cameraWasStored = true; + // enable vr in renderer + renderer.vr.enabled = true; + if (!_webVRButton) { + _webVRButton = WEBVR.createButton(renderer); + document.body.appendChild(_webVRButton); + } else { + _webVRButton.style.display = 'block'; + } + } else { + //disable vr + renderer.vr.enabled = false; + if (_webVRButton) { + _webVRButton.style.display = 'none'; + } + // restore common camera + if (_cameraWasStored) { + gfx.camera.copy(_mainCamera); + self._onResize(); + } + } + self._needRender = true; + }; +}(); + +Miew$1.prototype._getWebVRDevice = function () { + var vr = this._gfx.renderer.vr; + return vr && vr.enabled ? vr.getDevice() : null; +}; + Miew$1.prototype._getBSphereRadius = function () { // calculate radius that would include all visuals var radius = 0; @@ -88215,11 +88510,11 @@ Miew$1.prototype._onUpdate = function () { visual.getComplex().update(); }); - if (settings.now.autobuild && !this._loader && !this._building && this._needRebuild()) { + if (settings.now.autobuild && !this._loading.length && !this._building && this._needRebuild()) { this.rebuild(); } - if (!this._loader && !this._building && !this._needRebuild()) { + if (!this._loading.length && !this._building && !this._needRebuild()) { this._updateView(); } @@ -88264,6 +88559,7 @@ Miew$1.prototype._renderFrame = function () { this._resizeOffscreenBuffers(size.width * window.devicePixelRatio, size.height * window.devicePixelRatio, stereo); switch (stereo) { + case 'WEBVR': case 'NONE': this._renderScene(gfx.camera, false); break; @@ -88293,7 +88589,7 @@ Miew$1.prototype._renderFrame = function () { gfx.renderer2d.render(gfx.scene, gfx.camera); - if (settings.now.axes && gfx.axes) { + if (settings.now.axes && gfx.axes && !gfx.renderer.vr.enabled) { gfx.axes.render(renderer); } }; @@ -88336,6 +88632,10 @@ Miew$1.prototype._renderScene = function () { // render to offscreen buffer gfx.renderer.setClearColor(settings.now.themes[settings.now.theme], 1); gfx.renderer.clearTarget(target); + if (gfx.renderer.vr.enabled) { + gfx.renderer.render(gfx.scene, camera); + return; + } gfx.renderer.clearTarget(gfx.offscreenBuf); // FIXME clean up targets in render selection @@ -88738,55 +89038,61 @@ Miew$1.prototype.resetView = function () { * @returns {Promise} name of the visual that was added to the viewer */ Miew$1.prototype.load = function (source, opts) { - var self = this; + var _this3 = this; - if (self._loader) { - self._loader.cancel(); - } + opts = lodash.merge({}, opts, { + context: this + }); - self.dispatchEvent({ type: 'load', options: opts }); + // for a single-file scenario + if (!this.settings.now.use.multiFile) { - // remember file sources - if (source instanceof File && source.name.match(/.man$/i)) { - this._fileSourceAnim = normalizeSource(source); - } else { - this._fileSource = normalizeSource(source); - } - if (opts && opts.mdFile) { - this._fileSourceAnim = opts.mdFile; - } + // abort all loaders in progress + if (this._loading.length) { + this._loading.forEach(function (job) { + job.cancel(); + }); + this._loading.length = 0; + } - if (!this.settings.now.use.multiFile && !(opts && opts.animation)) { - this.reset(true); + // reset + if (!opts.animation) { + // FIXME: sometimes it is set AFTERWARDS! + this.reset(true); + } } - self._loader = new JobHandle(); - self._loader.addEventListener('notification', function (e) { - self.dispatchEvent(e.slaveEvent); + this.dispatchEvent({ type: 'load', options: opts, source: source }); + + var job = new JobHandle(); + this._loading.push(job); + job.addEventListener('notification', function (e) { + _this3.dispatchEvent(e.slaveEvent); }); - self._spinner.spin(this._container); + this._spinner.spin(this._container); - var onLoadEnd = function onLoadEnd(res) { - self._loader = null; - self._spinner.stop(); - self._refreshTitle(); - return res; + var onLoadEnd = function onLoadEnd(anything) { + var jobIndex = _this3._loading.indexOf(job); + if (jobIndex !== -1) { + _this3._loading.splice(jobIndex, 1); + } + _this3._spinner.stop(); + _this3._refreshTitle(); + return anything; }; - return _fetchData(source, opts, self._loader, self).then(function (res) { - return _convertData(res.data, res.opts, res.master); - }).then(function (res) { - return _parseData(res.data, res.opts, res.master, self); - }).then(function (res) { - return self._onLoad(res.data, res.opts); - }).then(function (res) { - return onLoadEnd(res); + return _fetchData(source, opts, job).then(function (data) { + return _convertData(data, opts, job); + }).then(function (data) { + return _parseData(data, opts, job); + }).then(function (object) { + var name = _this3._onLoad(object, opts); + return onLoadEnd(name); }).catch(function (err) { - onLoadEnd(); - self.logger.error('Could not load data'); - self.logger.debug(err); - throw err; + _this3.logger.error('Could not load data'); + _this3.logger.debug(err); + throw onLoadEnd(err); }); }; @@ -88924,7 +89230,7 @@ Miew$1.prototype._stopAnimation = function () { this._frameInfo.disableEvents(); this._frameInfo = null; this._animInterval = null; - this._fileSourceAnim = null; + this._srvAnimSource = null; this.dispatchEvent({ type: 'mdPlayerStateChanged', state: null @@ -89052,30 +89358,32 @@ Miew$1.prototype.resetEd = function () { this._needRender = true; }; -Miew$1.prototype.loadEd = function (file) { - var self = this; +Miew$1.prototype.loadEd = function (source) { + var _this4 = this; this.resetEd(); - var loader = this._edLoader = io.loaders.create(self, file, { binary: true }); + var TheLoader = lodash.head(io.loaders.find({ source: source })); + if (!TheLoader) { + this.logger.error('Could not find suitable loader for this source'); + return Promise.reject(new Error('Could not find suitable loader for this source')); + } - loader.load({ - ready: function ready(data) { - var parser = io.parsers.create(self, data, { fileType: 'ccp4' }); - parser.parse({ - ready: function ready(dataSource) { - self._onLoadEd(dataSource); - }, - progress: function progress(percent) { - // TODO: Update progress bar - reportProgress(self.logger, 'Parsing ED', percent); - } - }); - }, - progress: function progress(percent) { - // TODO: Update progress bar - reportProgress(self.logger, 'Loading ED', percent); + var loader = this._edLoader = new TheLoader(source, { binary: true }); + loader.context = this; + return loader.load().then(function (data) { + var TheParser = lodash.head(io.parsers.find({ format: 'ccp4' })); + if (!TheParser) { + throw new Error('Could not find suitable parser for this source'); } + var parser = new TheParser(data); + parser.context = _this4; + return parser.parse().then(function (dataSource) { + _this4._onLoadEd(dataSource); + }); + }).catch(function (error) { + _this4.logger.error('Could not load ED data'); + _this4.logger.debug(error); }); }; @@ -89217,7 +89525,7 @@ Miew$1.prototype.setNeedRender = function () { }; Miew$1.prototype._extractRepresentation = function () { - var _this = this; + var _this5 = this; var changed = []; @@ -89235,7 +89543,7 @@ Miew$1.prototype._extractRepresentation = function () { }); if (idx < 0) { if (visual.repCount() === ComplexVisual.NUM_REPRESENTATION_BITS) { - _this.logger.warn('Number of representations is limited to ' + ComplexVisual.NUM_REPRESENTATION_BITS); + _this5.logger.warn('Number of representations is limited to ' + ComplexVisual.NUM_REPRESENTATION_BITS); } return; } @@ -90360,6 +90668,9 @@ Miew$1.prototype._onSettingsChanged = function (changes) { if (changes.autoResolution && !this._gfxScore) { this.logger.warn('Benchmarks are missed, autoresolution will not work! ' + 'Autoresolution should be set during miew startup.'); } + if (changes.stereo) { + this._toggleWebVR(changes.stereo === 'WEBVR', this._gfx); + } this._needRender = true; }; @@ -90607,67 +90918,138 @@ Miew$1.prototype.projected = function (fullAtomName, complexName) { }; }; -// FIXME: rewrite the function, it looks a little bit ugly -function _fetchData(file, opts, master, context) { - return new Promise(function (resolve, reject) { - opts = opts || {}; // TODO: clone - if (file instanceof File && file.name.match(/.man$/i)) { - opts.binary = true; - opts.animation = true; - } - - if (file instanceof File && (file.name.match(/.mmtf$/i) || file.name.match(/.ccp4$/i))) { - opts.binary = true; - } else if (lodash.isString(file) && file.match(/.mmtf$/i)) { - opts.binary = true; - } - - // convert PDB ID to URL - if (!opts.mdFile && !opts.fileType && typeof file === 'string') { - - var matched = file.match(/^(?:\s*([+\w]+)\s*:)?\s*(.*)$/); - if (matched) { - var id = matched[2].trim(); - var type = matched[1]; - switch (type) { - case 'pubchem': - case 'pubchem+json': - type = 'pubchem+json'; - file = 'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/' + encodeURIComponent(id) + '/JSON?record_type=3d'; - opts.sourceType = 'url'; - opts.fileName = id + '.json'; - break; - default: - if (id.match(/^\w{4}$/i)) { - type = type || 'pdb'; - switch (type) { - case 'mmtf': - file = 'http://mmtf.rcsb.org/v1.0/full/' + id; - opts.sourceType = 'url'; - break; - case 'cif': - case 'pdb': - file = 'http://files.rcsb.org/view/' + id + '.' + type; - opts.sourceType = 'url'; - break; - default: - } - } else { - type = undefined; - } - } +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; - if (type) { - opts.fileType = type; - } - } +function resolveSourceShortcut(source, opts) { + if (!lodash.isString(source)) { + return source; + } + + // e.g. "mmtf:1CRN" + var matchesPdbId = rePdbId.exec(source); + if (matchesPdbId) { + var _matchesPdbId = slicedToArray(matchesPdbId, 3), + _matchesPdbId$ = _matchesPdbId[1], + format = _matchesPdbId$ === undefined ? 'pdb' : _matchesPdbId$, + id = _matchesPdbId[2]; + + format = format.toLowerCase(); + id = id.toUpperCase(); + + switch (format) { + case 'pdb': + source = 'http://files.rcsb.org/download/' + id + '.pdb'; + break; + case 'cif': + source = 'http://files.rcsb.org/download/' + id + '.cif'; + break; + case 'mmtf': + source = 'http://mmtf.rcsb.org/v1.0/full/' + id; + break; + case 'ccp4': + source = 'https://www.ebi.ac.uk/pdbe/coordinates/files/' + id.toLowerCase() + '.ccp4'; + break; + default: + throw new Error('Unexpected data format shortcut'); } - if (opts.fileType === 'mmtf') { - opts.binary = true; + opts.fileType = format; + opts.fileName = id + '.' + format; + opts.sourceType = 'url'; + return source; + } + + // e.g. "pc:aspirin" + var matchesPubchem = rePubchem.exec(source); + if (matchesPubchem) { + var compound = matchesPubchem[1].toLowerCase(); + source = 'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/' + compound + '/JSON?record_type=3d'; + opts.fileType = 'pubchem'; + opts.fileName = compound + '.json'; + opts.sourceType = 'url'; + return source; + } + + // otherwise is should be an URL + if (opts.sourceType === 'url' || opts.sourceType === undefined) { + opts.sourceType = 'url'; + + // e.g. "./data/1CRN.pdb" + if (!reUrlScheme.test(source)) { + source = utils.resolveURL(source); } + } - var loader = io.loaders.create(context, file, opts); + return source; +} + +function updateBinaryMode(opts) { + var binary = opts.binary; + + // detect by format + if (opts.fileType !== undefined) { + var TheParser = lodash.head(io.parsers.find({ format: opts.fileType })); + if (TheParser) { + binary = TheParser.binary || false; + } else { + throw new Error('Could not find suitable parser for this format'); + } + } + + // detect by file extension + if (binary === undefined && opts.fileExt !== undefined) { + var _TheParser = lodash.head(io.parsers.find({ ext: opts.fileExt })); + if (_TheParser) { + binary = _TheParser.binary || false; + } + } + + // temporary workaround for animation + if (opts.fileExt !== undefined && opts.fileExt.toLowerCase() === '.man') { + opts.binary = true; + opts.animation = true; // who cares? + } + + // update if detected + if (binary !== undefined) { + if (opts.binary !== undefined && opts.binary !== binary) { + opts.context.logger.warn('Overriding incorrect binary mode'); + } + } + + opts.binary = binary || false; +} + +function _fetchData(source, opts, job) { + return new Promise(function (resolve) { + if (job.shouldCancel()) { + throw new Error('Operation cancelled'); + } + + // allow for source shortcuts + source = resolveSourceShortcut(source, opts); + + // detect a proper loader + var TheLoader = lodash.head(io.loaders.find({ type: opts.sourceType, source: source })); + if (!TheLoader) { + throw new Error('Could not find suitable loader for this source'); + } + + // split file name + var fileName = opts.fileName || TheLoader.extractName(source); + if (fileName) { + var _utils$splitFileName = utils.splitFileName(fileName), + _utils$splitFileName2 = slicedToArray(_utils$splitFileName, 2), + name = _utils$splitFileName2[0], + fileExt = _utils$splitFileName2[1]; + + lodash.defaults(opts, { name: name, fileExt: fileExt, fileName: fileName }); + } + + // should it be text or binary? + updateBinaryMode(opts); // FIXME: All new settings retrieved from server are applied after the loading is complete. However, we need some // flags to alter the loading process itself. Here we apply them in advance. Dirty hack. Kill the server, remove @@ -90687,41 +91069,47 @@ function _fetchData(file, opts, master, context) { } } - if (master) { - master.addEventListener('cancel', function () { - loader.abort(); - }); - if (master.isCancellationRequested()) { - loader.abort(); - } - } + // create a loader + var loader = new TheLoader(source, opts); + loader.context = opts.context; + job.addEventListener('cancel', function () { + return loader.abort(); + }); - console.time('load'); - loader.load({ - ready: function ready(data) { - console.timeEnd('load'); - context.logger.info('Loading finished'); - resolve({ data: data, opts: opts, master: master }); - }, - error: function error(err) { - console.timeEnd('load'); - context.logger.error('Loading failed'); - reject(err); - }, - progress: function progress(percent) { - reportProgress(loader.logger, 'Loading', percent); + loader.addEventListener('progress', function (event) { + if (event.lengthComputable && event.total > 0) { + reportProgress(loader.logger, 'Fetching', event.loaded / event.total); + } else { + reportProgress(loader.logger, 'Fetching'); } }); + + console.time('fetch'); + var promise = loader.load().then(function (data) { + console.timeEnd('fetch'); + opts.context.logger.info('Fetching finished'); + job.notify({ type: 'fetchingFinished', data: data }); + return data; + }).catch(function (error) { + console.timeEnd('fetch'); + opts.context.logger.debug(error.message); + if (error.stack) { + opts.context.logger.debug(error.stack); + } + opts.context.logger.error('Fetching failed'); + job.notify({ type: 'fetchingFinished', error: error }); + throw error; + }); + resolve(promise); }); } -function _convertData(data, opts, master) { +function _convertData(data, opts, job) { return new Promise(function (resolve, reject) { - if (master) { - master.notify({ type: 'convert' }); + if (job.shouldCancel()) { + throw new Error('Operation cancelled'); } - - opts = opts || {}; + job.notify({ type: 'convert' }); if (opts.mdFile) { var byteNumbers = new Array(data.length); @@ -90739,74 +91127,54 @@ function _convertData(data, opts, master) { opts.convertedFile = new File([bytes], opts.fileName); opts.fileName = null; opts.fileType = 'pdb'; - if (master) { - master.notify({ type: 'convertingFinished' }); - } - resolve({ data: newData, opts: opts, master: master }); + job.notify({ type: 'convertingFinished' }); + resolve(newData); } else { opts.converted = false; logger.error(message); opts.error = message; - if (master) { - master.notify({ type: 'convertingFinished', error: message }); - } + job.notify({ type: 'convertingFinished', error: message }); reject(new Error(message)); } }); } else { opts.converted = true; - resolve({ data: data, opts: opts, master: master }); + resolve(data); } }); } -function _parseData(data, opts, master, context) { - if (master) { - master.notify({ type: 'parse' }); +function _parseData(data, opts, job) { + if (job.shouldCancel()) { + return Promise.reject(new Error('Operation cancelled')); } + job.notify({ type: 'parse' }); - opts = opts || {}; // TODO: clone - - var TheParser = lodash.head(io.parsers.find({ - format: opts.fileType, - ext: utils.getFileExtension(opts.fileName || ''), - data: data - })); - + var TheParser = lodash.head(io.parsers.find({ format: opts.fileType, ext: opts.fileExt, data: data })); if (!TheParser) { return Promise.reject(new Error('Could not find suitable parser')); } var parser = new TheParser(data, opts); - parser.context = context; - - if (master) { - master.addEventListener('cancel', function () { - parser.abort(); - }); - if (master.isCancellationRequested()) { - return Promise.reject(); - } - } + parser.context = opts.context; + job.addEventListener('cancel', function () { + return parser.abort(); + }); console.time('parse'); return parser.parse().then(function (dataSet) { console.timeEnd('parse'); - if (master) { - master.notify({ type: 'parsingFinished', data: dataSet }); - } - return { data: dataSet, opts: opts, master: master }; + job.notify({ type: 'parsingFinished', data: dataSet }); + return dataSet; }).catch(function (error) { console.timeEnd('parse'); opts.error = error; - context.logger.debug(error.message); + opts.context.logger.debug(error.message); if (error.stack) { - context.logger.debug(error.stack); - } - context.logger.error('Parsing failed'); - if (master) { - master.notify({ type: 'parsingFinished', error: error }); + opts.context.logger.debug(error.stack); } + opts.context.logger.error('Parsing failed'); + job.notify({ type: 'parsingFinished', error: error }); throw error; }); } @@ -90814,7 +91182,7 @@ function _parseData(data, opts, master, context) { //////////////////////////////////////////////////////////////////////////// // Additional exports -Miew$1.prototype.VERSION = typeof "0.7.9" !== 'undefined' && "0.7.9" || '0.0.0-dev'; +Miew$1.prototype.VERSION = typeof "0.7.10" !== 'undefined' && "0.7.10" || '0.0.0-dev'; // Miew.prototype.debugTracer = new utils.DebugTracer(Miew.prototype); lodash.assign(Miew$1, /** @lends Miew */{ diff --git a/package.json b/package.json index fb8b4079..521ff26a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "miew", - "version": "0.7.9", + "version": "0.7.10", "description": "Miew - 3D Molecular Viewer", "author": "EPAM Systems, Inc.", "main": "dist/Miew.js", diff --git a/sonar-project.properties b/sonar-project.properties index 2650c95d..779d173d 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.9 +sonar.projectVersion=0.7.10 sonar.links.homepage=https://github.com/epam/miew sonar.links.ci=https://travis-ci.org/epam/miew